Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/riscv64/src/ucb.c

    rae8d7b0 r8b6aa39  
    3131#include <macros.h>
    3232
    33 volatile uint64_t tohost __attribute__((section(".htif")));
    34 volatile uint64_t fromhost __attribute__((section(".htif")));
    35 
    36 static void poll_fromhost()
    37 {
    38         uint64_t val = fromhost;
    39         if (!val)
    40                 return;
    41        
    42         fromhost = 0;
    43 }
    44 
    4533void htif_cmd(uint8_t device, uint8_t cmd, uint64_t payload)
    4634{
     
    4836            (((uint64_t) cmd) << 48) |
    4937            (payload & UINT64_C(0xffffffffffff));
     38        uint64_t retval;
    5039       
    51         while (tohost)
    52                 poll_fromhost();
    53        
    54         tohost = val;
     40        do {
     41                asm volatile (
     42                        "csrrw %[retval], " STRING(CSR_MTOHOST) ", %[val]\n"
     43                        : [retval] "=r" (retval)
     44                        : [val] "r" (val)
     45                );
     46        } while (retval != 0);
    5547}
Note: See TracChangeset for help on using the changeset viewer.