Changeset bbc6277 in mainline
- Timestamp:
- 2017-11-30T17:00:09Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b5abaf7
- Parents:
- 7f345cd0
- Location:
- uspace/srv/hid/output
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/ctl/serial.c
r7f345cd0 rbbc6277 105 105 } 106 106 107 static void serial_flush(outdev_t *dev) 108 { 109 vt100_state_t *state = (vt100_state_t *) dev->data; 110 111 vt100_flush(state); 112 } 113 107 114 static outdev_ops_t serial_ops = { 108 115 .yield = serial_yield, … … 111 118 .get_caps = serial_get_caps, 112 119 .cursor_update = serial_cursor_update, 113 .char_update = serial_char_update 120 .char_update = serial_char_update, 121 .flush = serial_flush 114 122 }; 115 123 116 124 int serial_init(vt100_putchar_t putchar_fn, 117 vt100_control_puts_t control_puts_fn )125 vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn) 118 126 { 119 127 vt100_state_t *state = 120 128 vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putchar_fn, 121 control_puts_fn );129 control_puts_fn, flush_fn); 122 130 if (state == NULL) 123 131 return ENOMEM; -
uspace/srv/hid/output/ctl/serial.h
r7f345cd0 rbbc6277 36 36 #include "../proto/vt100.h" 37 37 38 extern int serial_init(vt100_putchar_t, vt100_control_puts_t );38 extern int serial_init(vt100_putchar_t, vt100_control_puts_t, vt100_flush_t); 39 39 40 40 #endif -
uspace/srv/hid/output/output.c
r7f345cd0 rbbc6277 219 219 dev->ops.cursor_update(dev, prev_col, prev_row, col, row, 220 220 visible); 221 dev->ops.flush(dev); 222 221 223 } 222 224 … … 342 344 } 343 345 } 344 } 346 347 dev->ops.flush(dev); 348 } 349 345 350 346 351 async_answer_0(iid, EOK); … … 380 385 } 381 386 } 382 } 383 387 dev->ops.flush(dev); 388 389 } 384 390 async_answer_0(iid, EOK); 385 391 } -
uspace/srv/hid/output/output.h
r7f345cd0 rbbc6277 52 52 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible); 53 53 void (* char_update)(struct outdev *dev, sysarg_t col, sysarg_t row); 54 void (* flush)(struct outdev *dev); 54 55 } outdev_ops_t; 55 56 -
uspace/srv/hid/output/port/chardev.c
r7f345cd0 rbbc6277 46 46 #include "chardev.h" 47 47 48 enum { 49 chardev_buf_size = 4096 50 }; 51 48 52 static char *console; 49 53 … … 53 57 static service_id_t console_cat_id; 54 58 59 static uint8_t chardev_buf[chardev_buf_size]; 60 static size_t chardev_bused; 61 55 62 static FIBRIL_MUTEX_INITIALIZE(discovery_lock); 56 63 static bool discovery_finished; 57 64 static FIBRIL_CONDVAR_INITIALIZE(discovery_cv); 58 65 66 static void chardev_flush(void) 67 { 68 size_t nwr; 69 70 if (chardev_bused == 0) 71 return; 72 73 chardev_write(chardev, chardev_buf, chardev_bused, &nwr); 74 /* XXX Handle error */ 75 76 chardev_bused = 0; 77 } 78 59 79 static void chardev_putchar(wchar_t ch) 60 80 { 61 uint8_t byte = (uint8_t) ch; 62 size_t nwr; 63 chardev_write(chardev, &byte, 1, &nwr); 64 /* XXX Handle error */ 81 if (chardev_bused == chardev_buf_size) 82 chardev_flush(); 83 if (!ascii_check(ch)) 84 ch = '?'; 85 chardev_buf[chardev_bused++] = (uint8_t) ch; 65 86 } 66 87 67 88 static void chardev_control_puts(const char *str) 68 89 { 69 size_t nwr; 70 chardev_write(chardev, (void *) str, str_size(str), &nwr); 71 /* XXX Handle error */ 90 const char *p; 91 92 p = str; 93 while (*p != '\0') 94 chardev_putchar(*p++); 72 95 } 73 96 … … 175 198 } 176 199 177 serial_init(chardev_putchar, chardev_control_puts );200 serial_init(chardev_putchar, chardev_control_puts, chardev_flush); 178 201 179 202 discovery_finished = true; -
uspace/srv/hid/output/port/ega.c
r7f345cd0 rbbc6277 169 169 } 170 170 171 static void ega_flush(outdev_t *dev) 172 { 173 } 174 171 175 static outdev_ops_t ega_ops = { 172 176 .yield = ega_yield, … … 175 179 .get_caps = ega_get_caps, 176 180 .cursor_update = ega_cursor_update, 177 .char_update = ega_char_update 181 .char_update = ega_char_update, 182 .flush = ega_flush 178 183 }; 179 184 -
uspace/srv/hid/output/proto/vt100.c
r7f345cd0 rbbc6277 139 139 140 140 vt100_state_t *vt100_state_create(sysarg_t cols, sysarg_t rows, 141 vt100_putchar_t putchar_fn, vt100_control_puts_t control_puts_fn) 141 vt100_putchar_t putchar_fn, vt100_control_puts_t control_puts_fn, 142 vt100_flush_t flush_fn) 142 143 { 143 144 vt100_state_t *state = malloc(sizeof(vt100_state_t)); … … 147 148 state->putchar = putchar_fn; 148 149 state->control_puts = control_puts_fn; 150 state->flush = flush_fn; 149 151 150 152 state->cols = cols; … … 228 230 } 229 231 232 void vt100_flush(vt100_state_t *state) 233 { 234 state->flush(); 235 } 236 230 237 /** @} 231 238 */ -
uspace/srv/hid/output/proto/vt100.h
r7f345cd0 rbbc6277 37 37 typedef void (* vt100_putchar_t)(wchar_t ch); 38 38 typedef void (* vt100_control_puts_t)(const char *str); 39 typedef void (* vt100_flush_t)(void); 39 40 40 41 typedef struct { … … 48 49 vt100_putchar_t putchar; 49 50 vt100_control_puts_t control_puts; 51 vt100_flush_t flush; 50 52 } vt100_state_t; 51 53 52 54 extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putchar_t, 53 vt100_control_puts_t );55 vt100_control_puts_t, vt100_flush_t); 54 56 extern void vt100_state_destroy(vt100_state_t *); 55 57 … … 62 64 extern void vt100_cursor_visibility(vt100_state_t *, bool); 63 65 extern void vt100_putchar(vt100_state_t *, wchar_t); 66 extern void vt100_flush(vt100_state_t *); 64 67 65 68 #endif
Note:
See TracChangeset
for help on using the changeset viewer.