Changes in uspace/srv/hid/output/ctl/serial.c [d31c3ea:28a5ebd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/ctl/serial.c
rd31c3ea r28a5ebd 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda3 2 * Copyright (c) 2006 Ondrej Palkovsky 4 3 * Copyright (c) 2008 Martin Decky … … 38 37 #include <errno.h> 39 38 #include <io/chargrid.h> 40 #include <vt/vt100.h>41 39 #include "../output.h" 40 #include "../proto/vt100.h" 42 41 #include "serial.h" 43 42 44 43 #define SERIAL_COLS 80 45 44 #define SERIAL_ROWS 24 46 47 static serial_putuchar_t serial_putuchar_fn;48 static serial_control_puts_t serial_control_puts_fn;49 static serial_flush_t serial_flush_fn;50 51 static void serial_vt_putuchar(void *, char32_t);52 static void serial_vt_control_puts(void *, const char *);53 static void serial_vt_flush(void *);54 55 static vt100_cb_t serial_vt_cb = {56 .putuchar = serial_vt_putuchar,57 .control_puts = serial_vt_control_puts,58 .flush = serial_vt_flush59 };60 45 61 46 /** Draw the character at the specified position. … … 67 52 * 68 53 */ 69 static void draw_char(vt100_ t *state, charfield_t *field,54 static void draw_char(vt100_state_t *state, charfield_t *field, 70 55 sysarg_t col, sysarg_t row) 71 56 { … … 77 62 static errno_t serial_yield(outdev_t *dev) 78 63 { 79 vt100_ t *state = (vt100_t *) dev->data;64 vt100_state_t *state = (vt100_state_t *) dev->data; 80 65 81 66 return vt100_yield(state); … … 84 69 static errno_t serial_claim(outdev_t *dev) 85 70 { 86 vt100_ t *state = (vt100_t *) dev->data;71 vt100_state_t *state = (vt100_state_t *) dev->data; 87 72 88 73 return vt100_claim(state); … … 92 77 sysarg_t *rows) 93 78 { 94 vt100_ t *state = (vt100_t *) dev->data;79 vt100_state_t *state = (vt100_state_t *) dev->data; 95 80 96 81 vt100_get_dimensions(state, cols, rows); … … 99 84 static console_caps_t serial_get_caps(outdev_t *dev) 100 85 { 101 return (CONSOLE_CAP_CURSORCTL | CONSOLE_CAP_STYLE | 102 CONSOLE_CAP_INDEXED | CONSOLE_CAP_RGB); 86 return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED); 103 87 } 104 88 … … 106 90 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) 107 91 { 108 vt100_ t *state = (vt100_t *) dev->data;92 vt100_state_t *state = (vt100_state_t *) dev->data; 109 93 110 94 vt100_goto(state, col, row); … … 114 98 static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) 115 99 { 116 vt100_ t *state = (vt100_t *) dev->data;100 vt100_state_t *state = (vt100_state_t *) dev->data; 117 101 charfield_t *field = 118 102 chargrid_charfield_at(dev->backbuf, col, row); … … 123 107 static void serial_flush(outdev_t *dev) 124 108 { 125 vt100_ t *state = (vt100_t *) dev->data;109 vt100_state_t *state = (vt100_state_t *) dev->data; 126 110 127 111 vt100_flush(state); … … 138 122 }; 139 123 140 errno_t serial_init( serial_putuchar_t putuchar_fn,141 serial_control_puts_t control_puts_fn, serial_flush_t flush_fn)124 errno_t serial_init(vt100_putuchar_t putuchar_fn, 125 vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn) 142 126 { 143 char_attrs_t attrs; 144 vt100_t *vt100; 127 vt100_state_t *state = 128 vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putuchar_fn, 129 control_puts_fn, flush_fn); 130 if (state == NULL) 131 return ENOMEM; 145 132 146 serial_putuchar_fn = putuchar_fn; 147 serial_control_puts_fn = control_puts_fn; 148 serial_flush_fn = flush_fn; 149 150 vt100 = vt100_create(NULL, SERIAL_COLS, SERIAL_ROWS, &serial_vt_cb); 151 if (vt100 == NULL) 152 return ENOMEM; 153 vt100->enable_rgb = true; 154 155 vt100_cursor_visibility(vt100, false); 156 attrs.type = CHAR_ATTR_STYLE; 157 attrs.val.style = STYLE_NORMAL; 158 vt100_set_attr(vt100, attrs); 159 vt100_cls(vt100); 160 161 outdev_t *dev = outdev_register(&serial_ops, vt100); 133 outdev_t *dev = outdev_register(&serial_ops, state); 162 134 if (dev == NULL) { 163 vt100_ destroy(vt100);135 vt100_state_destroy(state); 164 136 return ENOMEM; 165 137 } … … 168 140 } 169 141 170 static void serial_vt_putuchar(void *arg, char32_t c)171 {172 (void)arg;173 serial_putuchar_fn(c);174 }175 176 static void serial_vt_control_puts(void *arg, const char *str)177 {178 (void)arg;179 serial_control_puts_fn(str);180 }181 182 static void serial_vt_flush(void *arg)183 {184 (void)arg;185 serial_flush_fn();186 }187 188 142 /** @} 189 143 */
Note:
See TracChangeset
for help on using the changeset viewer.