Ignore:
File:
1 edited

Legend:

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

    r8b6aa39 rae8d7b0  
    3131#include <macros.h>
    3232
     33volatile uint64_t tohost __attribute__((section(".htif")));
     34volatile uint64_t fromhost __attribute__((section(".htif")));
     35
     36static void poll_fromhost()
     37{
     38        uint64_t val = fromhost;
     39        if (!val)
     40                return;
     41       
     42        fromhost = 0;
     43}
     44
    3345void htif_cmd(uint8_t device, uint8_t cmd, uint64_t payload)
    3446{
     
    3648            (((uint64_t) cmd) << 48) |
    3749            (payload & UINT64_C(0xffffffffffff));
    38         uint64_t retval;
    3950       
    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);
     51        while (tohost)
     52                poll_fromhost();
     53       
     54        tohost = val;
    4755}
Note: See TracChangeset for help on using the changeset viewer.