Changes in kernel/arch/riscv64/src/drivers/ucb.c [28a5ebd:e9bc927] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/riscv64/src/drivers/ucb.c
r28a5ebd re9bc927 41 41 static volatile uint64_t *fromhost; 42 42 43 static outdev_operations_t htifdev_ops = {44 .write = htif_putuchar,45 .redraw = NULL,46 .scroll_up = NULL,47 .scroll_down = NULL48 };49 50 43 static void poll_fromhost() 51 44 { … … 56 49 *fromhost = 0; 57 50 } 51 52 static void htif_cmd(uint8_t device, uint8_t cmd, uint64_t payload) 53 { 54 uint64_t val = (((uint64_t) device) << 56) | 55 (((uint64_t) cmd) << 48) | 56 (payload & UINT64_C(0xffffffffffff)); 57 58 while (*tohost) 59 poll_fromhost(); 60 61 *tohost = val; 62 } 63 64 static void htif_write(outdev_t *dev, const char *s, size_t n) 65 { 66 const char *top = s + n; 67 assert(top >= s); 68 69 for (; s < top; s++) { 70 if (*s == '\n') 71 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, '\r'); 72 73 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, (uint8_t) *s); 74 } 75 } 76 77 static outdev_operations_t htifdev_ops = { 78 .write = htif_write, 79 .redraw = NULL, 80 .scroll_up = NULL, 81 .scroll_down = NULL 82 }; 58 83 59 84 void htif_init(volatile uint64_t *tohost_addr, volatile uint64_t *fromhost_addr) … … 72 97 return htifdev; 73 98 } 74 75 static void htif_cmd(uint8_t device, uint8_t cmd, uint64_t payload)76 {77 uint64_t val = (((uint64_t) device) << 56) |78 (((uint64_t) cmd) << 48) |79 (payload & UINT64_C(0xffffffffffff));80 81 while (*tohost)82 poll_fromhost();83 84 *tohost = val;85 }86 87 void htif_putuchar(outdev_t *dev, const char32_t ch)88 {89 if (ascii_check(ch))90 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, ch);91 else92 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, U_SPECIAL);93 }
Note:
See TracChangeset
for help on using the changeset viewer.