Changeset ae8d7b0 in mainline for boot/arch/riscv64/src/ucb.c


Ignore:
Timestamp:
2017-08-21T18:23:39Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c58441d
Parents:
fdc29300
Message:

riscv64: update to the latest Privileged Architecture specification (1.10)

File:
1 edited

Legend:

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

    rfdc29300 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.