Changes in kernel/arch/riscv64/src/drivers/ucb.c [e9bc927:28a5ebd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/riscv64/src/drivers/ucb.c
re9bc927 r28a5ebd 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 = NULL 48 }; 49 43 50 static void poll_fromhost() 44 51 { … … 49 56 *fromhost = 0; 50 57 } 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 = NULL82 };83 58 84 59 void htif_init(volatile uint64_t *tohost_addr, volatile uint64_t *fromhost_addr) … … 97 72 return htifdev; 98 73 } 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 else 92 htif_cmd(HTIF_DEVICE_CONSOLE, HTIF_CONSOLE_PUTC, U_SPECIAL); 93 }
Note:
See TracChangeset
for help on using the changeset viewer.