Changeset 4c53333 in mainline for uspace/srv/hid
- Timestamp:
- 2013-07-11T08:21:10Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 64e63ce1
- Parents:
- 80445cf (diff), c8bb1633 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/srv/hid
- Files:
-
- 12 added
- 15 deleted
- 27 edited
- 30 moved
-
compositor/Makefile (added)
-
compositor/compositor.c (added)
-
compositor/compositor.h (added)
-
compositor/gfx/nameic.tga (moved) (moved from uspace/srv/hid/console/gfx/nameic.tga )
-
console/Makefile (modified) (1 diff)
-
console/console.c (modified) (24 diffs)
-
console/gfx/anim_1.tga (deleted)
-
console/gfx/anim_2.tga (deleted)
-
console/gfx/anim_3.tga (deleted)
-
console/gfx/anim_4.tga (deleted)
-
console/gfx/cons_data.tga (deleted)
-
console/gfx/cons_dis.tga (deleted)
-
console/gfx/cons_dis_sel.tga (deleted)
-
console/gfx/cons_idle.tga (deleted)
-
console/gfx/cons_kernel.tga (deleted)
-
console/gfx/cons_sel.tga (deleted)
-
console/gfx/helenos.tga (deleted)
-
fb/fb.c (deleted)
-
fb/fb.h (deleted)
-
input/Makefile (modified) (2 diffs)
-
input/ctl/apple.c (modified) (1 diff)
-
input/ctl/gxe_fb.c (deleted)
-
input/ctl/kbdev.c (modified) (7 diffs)
-
input/ctl/pc.c (modified) (1 diff)
-
input/ctl/stty.c (modified) (1 diff)
-
input/ctl/sun.c (modified) (1 diff)
-
input/gsp.c (moved) (moved from uspace/srv/hid/input/generic/gsp.c ) (6 diffs)
-
input/gsp.h (moved) (moved from uspace/srv/hid/input/include/gsp.h ) (1 diff)
-
input/input.c (moved) (moved from uspace/srv/hid/input/generic/input.c ) (9 diffs)
-
input/input.h (moved) (moved from uspace/srv/hid/input/include/input.h ) (1 diff)
-
input/kbd.h (moved) (moved from uspace/srv/hid/input/include/kbd.h )
-
input/kbd_ctl.h (moved) (moved from uspace/srv/hid/input/include/kbd_ctl.h ) (2 diffs)
-
input/kbd_port.h (moved) (moved from uspace/srv/hid/input/include/kbd_port.h ) (1 diff)
-
input/layout.c (moved) (moved from uspace/srv/hid/input/generic/layout.c ) (1 diff)
-
input/layout.h (moved) (moved from uspace/srv/hid/input/include/layout.h ) (1 diff)
-
input/layout/ar.c (added)
-
input/layout/cz.c (modified) (1 diff)
-
input/layout/us_dvorak.c (modified) (1 diff)
-
input/layout/us_qwerty.c (modified) (1 diff)
-
input/mouse.h (moved) (moved from uspace/srv/hid/input/include/mouse.h ) (1 diff)
-
input/mouse_port.h (moved) (moved from uspace/srv/hid/input/include/mouse_port.h )
-
input/mouse_proto.h (moved) (moved from uspace/srv/hid/input/include/mouse_proto.h ) (1 diff)
-
input/port/adb.c (modified) (5 diffs)
-
input/port/adb_mouse.c (modified) (2 diffs)
-
input/port/chardev.c (modified) (3 diffs)
-
input/port/gxemul.c (deleted)
-
input/port/msim.c (modified) (1 diff)
-
input/port/niagara.c (modified) (2 diffs)
-
input/port/ns16550.c (modified) (2 diffs)
-
input/port/pl050.c (modified) (2 diffs)
-
input/port/ski.c (modified) (1 diff)
-
input/proto/adb.c (modified) (1 diff)
-
input/proto/mousedev.c (modified) (6 diffs)
-
input/stroke.c (moved) (moved from uspace/srv/hid/input/generic/stroke.c ) (1 diff)
-
input/stroke.h (moved) (moved from uspace/srv/hid/input/include/stroke.h ) (3 diffs)
-
isdv4_tablet/Makefile (added)
-
isdv4_tablet/isdv4.c (added)
-
isdv4_tablet/isdv4.h (added)
-
isdv4_tablet/main.c (added)
-
output/Makefile (moved) (moved from uspace/srv/hid/fb/Makefile ) (1 diff)
-
output/ctl/serial.c (moved) (moved from uspace/srv/hid/fb/ctl/serial.c ) (2 diffs)
-
output/ctl/serial.h (moved) (moved from uspace/srv/hid/fb/ctl/serial.h ) (1 diff)
-
output/gfx/font-8x16.c (added)
-
output/gfx/font-8x16.h (added)
-
output/output.c (added)
-
output/output.h (added)
-
output/port/ega.c (moved) (moved from uspace/srv/hid/fb/port/ega.c ) (8 diffs)
-
output/port/ega.h (moved) (moved from uspace/srv/hid/fb/port/ega.h ) (1 diff)
-
output/port/kchar.c (moved) (moved from uspace/srv/hid/fb/port/kchar.c ) (1 diff)
-
output/port/kchar.h (moved) (moved from uspace/srv/hid/fb/port/kchar.h ) (1 diff)
-
output/port/kfb.c (moved) (moved from uspace/srv/hid/fb/port/kfb.c )
-
output/port/kfb.h (moved) (moved from uspace/srv/hid/fb/port/kfb.h )
-
output/port/niagara.c (moved) (moved from uspace/srv/hid/fb/port/niagara.c ) (1 diff)
-
output/port/niagara.h (moved) (moved from uspace/srv/hid/fb/port/niagara.h ) (2 diffs)
-
output/port/ski.c (moved) (moved from uspace/srv/hid/fb/port/ski.c )
-
output/port/ski.h (moved) (moved from uspace/srv/hid/fb/port/ski.h ) (1 diff)
-
output/proto/vt100.c (moved) (moved from uspace/srv/hid/fb/proto/vt100.c ) (8 diffs)
-
output/proto/vt100.h (moved) (moved from uspace/srv/hid/fb/proto/vt100.h ) (1 diff)
-
remcons/remcons.c (modified) (13 diffs)
-
remcons/telnet.h (modified) (1 diff)
-
remcons/user.c (modified) (3 diffs)
-
remcons/user.h (modified) (3 diffs)
-
s3c24xx_ts/Makefile (modified) (1 diff)
-
s3c24xx_ts/s3c24xx_ts.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/Makefile
r80445cf r4c53333 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBFB_PREFIX)/libfb.a32 EXTRA_CFLAGS += -I$(LIBFB_PREFIX)33 31 BINARY = console 34 32 35 33 SOURCES = \ 36 console.c \ 37 images.c 38 39 IMAGES = \ 40 gfx/helenos.tga \ 41 gfx/nameic.tga \ 42 gfx/cons_data.tga \ 43 gfx/cons_dis.tga \ 44 gfx/cons_dis_sel.tga \ 45 gfx/cons_idle.tga \ 46 gfx/cons_sel.tga \ 47 gfx/cons_kernel.tga \ 48 gfx/anim_1.tga \ 49 gfx/anim_2.tga \ 50 gfx/anim_3.tga \ 51 gfx/anim_4.tga 52 53 PRE_DEPEND = images.c images.h 54 EXTRA_CLEAN = images.c images.h 34 console.c 55 35 56 36 include $(USPACE_PREFIX)/Makefile.common 57 58 images.c images.h: $(IMAGES)59 $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^ -
uspace/srv/hid/console/console.c
r80445cf r4c53333 36 36 #include <stdio.h> 37 37 #include <adt/prodcons.h> 38 #include <ipc/input.h> 39 #include <ipc/console.h> 38 #include <io/input.h> 40 39 #include <ipc/vfs.h> 41 40 #include <errno.h> … … 43 42 #include <loc.h> 44 43 #include <event.h> 44 #include <io/con_srv.h> 45 #include <io/kbd_event.h> 45 46 #include <io/keycode.h> 46 #include <screenbuffer.h> 47 #include <fb.h> 48 #include <imgmap.h> 47 #include <io/chargrid.h> 48 #include <io/output.h> 49 49 #include <align.h> 50 50 #include <malloc.h> 51 51 #include <as.h> 52 52 #include <fibril_synch.h> 53 #include "images.h"54 53 #include "console.h" 55 54 … … 57 56 #define NAMESPACE "term" 58 57 59 #define CONSOLE_TOP 66 60 #define CONSOLE_MARGIN 12 61 62 #define STATE_START 100 63 #define STATE_TOP 8 64 #define STATE_SPACE 4 65 #define STATE_WIDTH 48 66 #define STATE_HEIGHT 48 67 68 typedef enum { 69 CONS_DISCONNECTED = 0, 70 CONS_DISCONNECTED_SELECTED, 71 CONS_SELECTED, 72 CONS_IDLE, 73 CONS_DATA, 74 CONS_KERNEL, 75 CONS_LAST 76 } console_state_t; 58 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1) 77 59 78 60 typedef struct { 79 atomic_t refcnt; /**< Connection reference count */ 80 prodcons_t input_pc; /**< Incoming keyboard events */ 81 82 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ 83 84 size_t index; /**< Console index */ 85 console_state_t state; /**< Console state */ 86 service_id_t dsid; /**< Service handle */ 87 88 vp_handle_t state_vp; /**< State icon viewport */ 89 sysarg_t cols; /**< Number of columns */ 90 sysarg_t rows; /**< Number of rows */ 91 console_caps_t ccaps; /**< Console capabilities */ 92 93 screenbuffer_t *frontbuf; /**< Front buffer */ 94 frontbuf_handle_t fbid; /**< Front buffer handle */ 61 atomic_t refcnt; /**< Connection reference count */ 62 prodcons_t input_pc; /**< Incoming keyboard events */ 63 64 /** 65 * Not yet sent bytes of last char event. 66 */ 67 char char_remains[UTF8_CHAR_BUFFER_SIZE]; 68 size_t char_remains_len; /**< Number of not yet sent bytes. */ 69 70 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ 71 72 size_t index; /**< Console index */ 73 service_id_t dsid; /**< Service handle */ 74 75 sysarg_t cols; /**< Number of columns */ 76 sysarg_t rows; /**< Number of rows */ 77 console_caps_t ccaps; /**< Console capabilities */ 78 79 chargrid_t *frontbuf; /**< Front buffer */ 80 frontbuf_handle_t fbid; /**< Front buffer handle */ 81 con_srvs_t srvs; /**< Console service setup */ 95 82 } console_t; 96 83 97 typedef enum { 98 GRAPHICS_NONE = 0, 99 GRAPHICS_BASIC = 1, 100 GRAPHICS_FULL = 2 101 } graphics_state_t; 102 103 /** Current console state */ 104 static graphics_state_t graphics_state = GRAPHICS_NONE; 105 106 /** State icons */ 107 static imagemap_handle_t state_icons[CONS_LAST]; 108 109 /** Session to the input server */ 110 static async_sess_t *input_sess; 111 112 /** Session to the framebuffer server */ 113 static async_sess_t *fb_sess; 114 115 /** Framebuffer resolution */ 116 static sysarg_t xres; 117 static sysarg_t yres; 84 /** Input server proxy */ 85 static input_t *input; 86 87 /** Session to the output server */ 88 static async_sess_t *output_sess; 89 90 /** Output dimensions */ 91 static sysarg_t cols; 92 static sysarg_t rows; 118 93 119 94 /** Array of data for virtual consoles */ … … 127 102 static console_t *kernel_console = &consoles[KERNEL_CONSOLE]; 128 103 129 static imgmap_t *logo_img; 130 static imgmap_t *nameic_img; 131 132 static imgmap_t *anim_1_img; 133 static imgmap_t *anim_2_img; 134 static imgmap_t *anim_3_img; 135 static imgmap_t *anim_4_img; 136 137 static imagemap_handle_t anim_1; 138 static imagemap_handle_t anim_2; 139 static imagemap_handle_t anim_3; 140 static imagemap_handle_t anim_4; 141 142 static sequence_handle_t anim_seq; 143 144 static imgmap_t *cons_data_img; 145 static imgmap_t *cons_dis_img; 146 static imgmap_t *cons_dis_sel_img; 147 static imgmap_t *cons_idle_img; 148 static imgmap_t *cons_kernel_img; 149 static imgmap_t *cons_sel_img; 150 151 static vp_handle_t logo_vp; 152 static imagemap_handle_t logo_handle; 153 154 static vp_handle_t nameic_vp; 155 static imagemap_handle_t nameic_handle; 156 157 static vp_handle_t screen_vp; 158 static vp_handle_t console_vp; 159 160 struct { 161 sysarg_t x; 162 sysarg_t y; 163 164 sysarg_t btn_x; 165 sysarg_t btn_y; 166 167 bool pressed; 168 } mouse; 169 170 static void cons_redraw_state(console_t *cons) 171 { 172 if (graphics_state == GRAPHICS_FULL) { 173 fibril_mutex_lock(&cons->mtx); 174 175 fb_vp_imagemap_damage(fb_sess, cons->state_vp, 176 state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT); 177 178 if ((cons->state != CONS_DISCONNECTED) && 179 (cons->state != CONS_KERNEL) && 180 (cons->state != CONS_DISCONNECTED_SELECTED)) { 181 char data[5]; 182 snprintf(data, 5, "%zu", cons->index + 1); 183 184 for (size_t i = 0; data[i] != 0; i++) 185 fb_vp_putchar(fb_sess, cons->state_vp, i + 2, 1, data[i]); 186 } 187 188 fibril_mutex_unlock(&cons->mtx); 189 } 190 } 191 192 static void cons_kernel_sequence_start(console_t *cons) 193 { 194 if (graphics_state == GRAPHICS_FULL) { 195 fibril_mutex_lock(&cons->mtx); 196 197 fb_vp_sequence_start(fb_sess, cons->state_vp, anim_seq); 198 fb_vp_imagemap_damage(fb_sess, cons->state_vp, 199 state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT); 200 201 fibril_mutex_unlock(&cons->mtx); 202 } 203 } 204 205 static void cons_update_state(console_t *cons, console_state_t state) 206 { 207 bool update = false; 208 209 fibril_mutex_lock(&cons->mtx); 210 211 if (cons->state != state) { 212 cons->state = state; 213 update = true; 214 } 215 216 fibril_mutex_unlock(&cons->mtx); 217 218 if (update) 219 cons_redraw_state(cons); 220 } 221 222 static void cons_notify_data(console_t *cons) 104 static int input_ev_key(input_t *, kbd_event_type_t, keycode_t, keymod_t, wchar_t); 105 static int input_ev_move(input_t *, int, int); 106 static int input_ev_abs_move(input_t *, unsigned, unsigned, unsigned, unsigned); 107 static int input_ev_button(input_t *, int, int); 108 109 static input_ev_ops_t input_ev_ops = { 110 .key = input_ev_key, 111 .move = input_ev_move, 112 .abs_move = input_ev_abs_move, 113 .button = input_ev_button 114 }; 115 116 static int cons_open(con_srvs_t *, con_srv_t *); 117 static int cons_close(con_srv_t *); 118 static int cons_read(con_srv_t *, void *, size_t); 119 static int cons_write(con_srv_t *, void *, size_t); 120 static void cons_sync(con_srv_t *); 121 static void cons_clear(con_srv_t *); 122 static void cons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row); 123 static int cons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *); 124 static int cons_get_size(con_srv_t *, sysarg_t *, sysarg_t *); 125 static int cons_get_color_cap(con_srv_t *, console_caps_t *); 126 static void cons_set_style(con_srv_t *, console_style_t); 127 static void cons_set_color(con_srv_t *, console_color_t, console_color_t, 128 console_color_attr_t); 129 static void cons_set_rgb_color(con_srv_t *, pixel_t, pixel_t); 130 static void cons_set_cursor_visibility(con_srv_t *, bool); 131 static int cons_get_event(con_srv_t *, cons_event_t *); 132 133 static con_ops_t con_ops = { 134 .open = cons_open, 135 .close = cons_close, 136 .read = cons_read, 137 .write = cons_write, 138 .sync = cons_sync, 139 .clear = cons_clear, 140 .set_pos = cons_set_pos, 141 .get_pos = cons_get_pos, 142 .get_size = cons_get_size, 143 .get_color_cap = cons_get_color_cap, 144 .set_style = cons_set_style, 145 .set_color = cons_set_color, 146 .set_rgb_color = cons_set_rgb_color, 147 .set_cursor_visibility = cons_set_cursor_visibility, 148 .get_event = cons_get_event 149 }; 150 151 static console_t *srv_to_console(con_srv_t *srv) 152 { 153 return srv->srvs->sarg; 154 } 155 156 static void cons_update(console_t *cons) 223 157 { 224 158 fibril_mutex_lock(&switch_mtx); 225 226 if (cons != active_console) 227 cons_update_state(cons, CONS_DATA); 228 159 fibril_mutex_lock(&cons->mtx); 160 161 if ((cons == active_console) && (active_console != kernel_console)) { 162 output_update(output_sess, cons->fbid); 163 output_cursor_update(output_sess, cons->fbid); 164 } 165 166 fibril_mutex_unlock(&cons->mtx); 229 167 fibril_mutex_unlock(&switch_mtx); 230 168 } 231 169 232 static void cons_ notify_connect(console_t *cons)170 static void cons_update_cursor(console_t *cons) 233 171 { 234 172 fibril_mutex_lock(&switch_mtx); 235 236 if (cons == active_console)237 cons_update_state(cons, CONS_SELECTED);238 else239 cons_update_state(cons, CONS_IDLE);240 173 fibril_mutex_lock(&cons->mtx); 174 175 if ((cons == active_console) && (active_console != kernel_console)) 176 output_cursor_update(output_sess, cons->fbid); 177 178 fibril_mutex_unlock(&cons->mtx); 241 179 fibril_mutex_unlock(&switch_mtx); 242 180 } 243 181 244 static void cons_ notify_disconnect(console_t *cons)182 static void cons_damage(console_t *cons) 245 183 { 246 184 fibril_mutex_lock(&switch_mtx); 247 248 if (cons == active_console)249 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);250 else251 cons_update_state(cons, CONS_DISCONNECTED);252 253 fibril_mutex_unlock(&switch_mtx);254 }255 256 static void cons_update(console_t *cons)257 {258 fibril_mutex_lock(&switch_mtx);259 185 fibril_mutex_lock(&cons->mtx); 260 186 261 187 if ((cons == active_console) && (active_console != kernel_console)) { 262 fb_vp_update(fb_sess, console_vp, cons->fbid); 263 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 264 } 265 266 fibril_mutex_unlock(&cons->mtx); 267 fibril_mutex_unlock(&switch_mtx); 268 } 269 270 static void cons_update_cursor(console_t *cons) 271 { 272 fibril_mutex_lock(&switch_mtx); 273 fibril_mutex_lock(&cons->mtx); 274 275 if ((cons == active_console) && (active_console != kernel_console)) 276 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 277 278 fibril_mutex_unlock(&cons->mtx); 279 fibril_mutex_unlock(&switch_mtx); 280 } 281 282 static void cons_clear(console_t *cons) 283 { 284 fibril_mutex_lock(&cons->mtx); 285 screenbuffer_clear(cons->frontbuf); 286 fibril_mutex_unlock(&cons->mtx); 287 288 cons_update(cons); 289 } 290 291 static void cons_damage_all(console_t *cons) 292 { 293 fibril_mutex_lock(&switch_mtx); 294 fibril_mutex_lock(&cons->mtx); 295 296 if ((cons == active_console) && (active_console != kernel_console)) { 297 fb_vp_damage(fb_sess, console_vp, cons->fbid, 0, 0, cons->cols, 188 output_damage(output_sess, cons->fbid, 0, 0, cons->cols, 298 189 cons->rows); 299 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);190 output_cursor_update(output_sess, cons->fbid); 300 191 } 301 192 … … 314 205 315 206 if (cons == kernel_console) { 316 fb_yield(fb_sess);207 output_yield(output_sess); 317 208 if (!console_kcon()) { 318 fb_claim(fb_sess);209 output_claim(output_sess); 319 210 fibril_mutex_unlock(&switch_mtx); 320 211 return; … … 323 214 324 215 if (active_console == kernel_console) 325 fb_claim(fb_sess);216 output_claim(output_sess); 326 217 327 218 prev_console = active_console; 328 219 active_console = cons; 329 220 330 if (prev_console->state == CONS_DISCONNECTED_SELECTED)331 cons_update_state(prev_console, CONS_DISCONNECTED);332 else333 cons_update_state(prev_console, CONS_IDLE);334 335 if ((cons->state == CONS_DISCONNECTED) ||336 (cons->state == CONS_DISCONNECTED_SELECTED))337 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);338 else339 cons_update_state(cons, CONS_SELECTED);340 341 221 fibril_mutex_unlock(&switch_mtx); 342 222 343 cons_damage _all(cons);223 cons_damage(cons); 344 224 } 345 225 … … 347 227 { 348 228 fibril_mutex_lock(&switch_mtx); 349 229 350 230 console_t *active_uspace = active_console; 351 if (active_uspace == kernel_console) {231 if (active_uspace == kernel_console) 352 232 active_uspace = prev_console; 353 }233 354 234 assert(active_uspace != kernel_console); 355 235 356 236 fibril_mutex_unlock(&switch_mtx); 357 237 358 238 return active_uspace; 359 239 } 360 240 361 static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi) 362 { 363 if (val > hi) 364 return hi; 365 366 if (val < lo) 367 return lo; 368 369 return val; 370 } 371 372 static void cons_mouse_move(sysarg_t dx, sysarg_t dy) 373 { 374 ssize_t sx = (ssize_t) dx; 375 ssize_t sy = (ssize_t) dy; 376 377 mouse.x = limit(mouse.x + sx, 0, xres); 378 mouse.y = limit(mouse.y + sy, 0, yres); 379 380 fb_pointer_update(fb_sess, mouse.x, mouse.y, true); 381 } 382 383 static console_t *cons_find_icon(sysarg_t x, sysarg_t y) 384 { 385 sysarg_t status_start = 386 STATE_START + (xres - 800) / 2 + CONSOLE_MARGIN; 387 388 if ((y < STATE_TOP) || (y >= STATE_TOP + STATE_HEIGHT)) 389 return NULL; 390 391 if (x < status_start) 392 return NULL; 393 394 if (x >= status_start + (STATE_WIDTH + STATE_SPACE) * CONSOLE_COUNT) 395 return NULL; 396 397 if (((x - status_start) % (STATE_WIDTH + STATE_SPACE)) >= STATE_WIDTH) 398 return NULL; 399 400 sysarg_t btn = (x - status_start) / (STATE_WIDTH + STATE_SPACE); 401 402 if (btn < CONSOLE_COUNT) 403 return consoles + btn; 404 405 return NULL; 406 } 407 408 /** Handle mouse click 409 * 410 * @param state Button state (true - pressed, false - depressed) 411 * 412 */ 413 static console_t *cons_mouse_button(bool state) 414 { 415 if (graphics_state != GRAPHICS_FULL) 416 return NULL; 417 418 if (state) { 419 console_t *cons = cons_find_icon(mouse.x, mouse.y); 420 if (cons != NULL) { 421 mouse.btn_x = mouse.x; 422 mouse.btn_y = mouse.y; 423 mouse.pressed = true; 424 } 425 426 return NULL; 427 } 428 429 if ((!state) && (!mouse.pressed)) 430 return NULL; 431 432 console_t *cons = cons_find_icon(mouse.x, mouse.y); 433 if (cons == cons_find_icon(mouse.btn_x, mouse.btn_y)) 434 return cons; 435 436 mouse.pressed = false; 437 return NULL; 438 } 439 440 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 441 { 442 /* Ignore parameters, the connection is already opened */ 443 while (true) { 444 ipc_call_t call; 445 ipc_callid_t callid = async_get_call(&call); 446 447 if (!IPC_GET_IMETHOD(call)) { 448 /* TODO: Handle hangup */ 449 async_hangup(input_sess); 450 return; 451 } 452 453 kbd_event_type_t type; 454 keycode_t key; 455 keymod_t mods; 456 wchar_t c; 457 458 switch (IPC_GET_IMETHOD(call)) { 459 case INPUT_EVENT_KEY: 460 type = IPC_GET_ARG1(call); 461 key = IPC_GET_ARG2(call); 462 mods = IPC_GET_ARG3(call); 463 c = IPC_GET_ARG4(call); 464 465 if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) && 466 ((mods & KM_CTRL) == 0)) 467 cons_switch(&consoles[key - KC_F1]); 468 else { 469 /* Got key press/release event */ 470 kbd_event_t *event = 471 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 472 if (event == NULL) { 473 async_answer_0(callid, ENOMEM); 474 break; 475 } 476 477 link_initialize(&event->link); 478 event->type = type; 479 event->key = key; 480 event->mods = mods; 481 event->c = c; 482 483 /* 484 * Kernel console does not read events 485 * from us, so we will redirect them 486 * to the (last) active userspace console 487 * if necessary. 488 */ 489 console_t *target_console = cons_get_active_uspace(); 490 491 prodcons_produce(&target_console->input_pc, 492 &event->link); 493 } 494 495 async_answer_0(callid, EOK); 496 break; 497 case INPUT_EVENT_MOVE: 498 cons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 499 async_answer_0(callid, EOK); 500 break; 501 case INPUT_EVENT_BUTTON: 502 /* Got pointer button press/release event */ 503 if (IPC_GET_ARG1(call) == 1) { 504 console_t *cons = 505 cons_mouse_button((bool) IPC_GET_ARG2(call)); 506 if (cons != NULL) 507 cons_switch(cons); 508 } 509 async_answer_0(callid, EOK); 510 break; 511 default: 512 async_answer_0(callid, EINVAL); 513 } 514 } 241 static int input_ev_key(input_t *input, kbd_event_type_t type, keycode_t key, 242 keymod_t mods, wchar_t c) 243 { 244 if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) && 245 ((mods & KM_CTRL) == 0)) { 246 cons_switch(&consoles[key - KC_F1]); 247 } else { 248 /* Got key press/release event */ 249 kbd_event_t *event = 250 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 251 if (event == NULL) { 252 return ENOMEM; 253 } 254 255 link_initialize(&event->link); 256 event->type = type; 257 event->key = key; 258 event->mods = mods; 259 event->c = c; 260 261 /* 262 * Kernel console does not read events 263 * from us, so we will redirect them 264 * to the (last) active userspace console 265 * if necessary. 266 */ 267 console_t *target_console = cons_get_active_uspace(); 268 269 prodcons_produce(&target_console->input_pc, 270 &event->link); 271 } 272 273 return EOK; 274 } 275 276 static int input_ev_move(input_t *input, int dx, int dy) 277 { 278 return EOK; 279 } 280 281 static int input_ev_abs_move(input_t *input, unsigned x , unsigned y, 282 unsigned max_x, unsigned max_y) 283 { 284 return EOK; 285 } 286 287 static int input_ev_button(input_t *input, int bnum, int bpress) 288 { 289 return EOK; 515 290 } 516 291 … … 524 299 switch (ch) { 525 300 case '\n': 526 updated = screenbuffer_newline(cons->frontbuf);301 updated = chargrid_newline(cons->frontbuf); 527 302 break; 528 303 case '\r': 529 304 break; 530 305 case '\t': 531 updated = screenbuffer_tabstop(cons->frontbuf, 8);306 updated = chargrid_tabstop(cons->frontbuf, 8); 532 307 break; 533 308 case '\b': 534 updated = screenbuffer_backspace(cons->frontbuf);309 updated = chargrid_backspace(cons->frontbuf); 535 310 break; 536 311 default: 537 updated = screenbuffer_putchar(cons->frontbuf, ch, true);312 updated = chargrid_putchar(cons->frontbuf, ch, true); 538 313 } 539 314 … … 544 319 } 545 320 546 static void cons_set_cursor (console_t *cons, sysarg_t col, sysarg_t row)547 { 548 fibril_mutex_lock(&cons->mtx); 549 screenbuffer_set_cursor(cons->frontbuf, col, row);321 static void cons_set_cursor_vis(console_t *cons, bool visible) 322 { 323 fibril_mutex_lock(&cons->mtx); 324 chargrid_set_cursor_visibility(cons->frontbuf, visible); 550 325 fibril_mutex_unlock(&cons->mtx); 551 326 … … 553 328 } 554 329 555 static void cons_set_cursor_visibility(console_t *cons, bool visible) 556 { 557 fibril_mutex_lock(&cons->mtx); 558 screenbuffer_set_cursor_visibility(cons->frontbuf, visible); 559 fibril_mutex_unlock(&cons->mtx); 560 561 cons_update_cursor(cons); 562 } 563 564 static void cons_get_cursor(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 565 { 566 sysarg_t col; 567 sysarg_t row; 568 569 fibril_mutex_lock(&cons->mtx); 570 screenbuffer_get_cursor(cons->frontbuf, &col, &row); 571 fibril_mutex_unlock(&cons->mtx); 572 573 async_answer_2(iid, EOK, col, row); 574 } 575 576 static void cons_write(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 577 { 578 void *buf; 579 size_t size; 580 int rc = async_data_write_accept(&buf, false, 0, 0, 0, &size); 581 582 if (rc != EOK) { 583 async_answer_0(iid, rc); 584 return; 585 } 586 330 static int cons_open(con_srvs_t *srvs, con_srv_t *srv) 331 { 332 return EOK; 333 } 334 335 static int cons_close(con_srv_t *srv) 336 { 337 return EOK; 338 } 339 340 static int cons_read(con_srv_t *srv, void *buf, size_t size) 341 { 342 uint8_t *bbuf = buf; 343 console_t *cons = srv_to_console(srv); 344 size_t pos = 0; 345 346 /* 347 * Read input from keyboard and copy it to the buffer. 348 * We need to handle situation when wchar is split by 2 following 349 * reads. 350 */ 351 while (pos < size) { 352 /* Copy to the buffer remaining characters. */ 353 while ((pos < size) && (cons->char_remains_len > 0)) { 354 bbuf[pos] = cons->char_remains[0]; 355 pos++; 356 357 /* Unshift the array. */ 358 for (size_t i = 1; i < cons->char_remains_len; i++) 359 cons->char_remains[i - 1] = cons->char_remains[i]; 360 361 cons->char_remains_len--; 362 } 363 364 /* Still not enough? Then get another key from the queue. */ 365 if (pos < size) { 366 link_t *link = prodcons_consume(&cons->input_pc); 367 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 368 369 /* Accept key presses of printable chars only. */ 370 if ((event->type == KEY_PRESS) && (event->c != 0)) { 371 wchar_t tmp[2] = { event->c, 0 }; 372 wstr_to_str(cons->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp); 373 cons->char_remains_len = str_size(cons->char_remains); 374 } 375 376 free(event); 377 } 378 } 379 380 return size; 381 } 382 383 static int cons_write(con_srv_t *srv, void *data, size_t size) 384 { 385 console_t *cons = srv_to_console(srv); 386 587 387 size_t off = 0; 588 388 while (off < size) 589 cons_write_char(cons, str_decode(buf, &off, size)); 590 591 async_answer_1(iid, EOK, size); 592 free(buf); 593 594 cons_notify_data(cons); 595 } 596 597 static void cons_read(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 598 { 599 ipc_callid_t callid; 600 size_t size; 601 if (!async_data_read_receive(&callid, &size)) { 602 async_answer_0(callid, EINVAL); 603 async_answer_0(iid, EINVAL); 604 return; 605 } 606 607 char *buf = (char *) malloc(size); 608 if (buf == NULL) { 609 async_answer_0(callid, ENOMEM); 610 async_answer_0(iid, ENOMEM); 611 return; 612 } 613 614 size_t pos = 0; 615 while (pos < size) { 616 link_t *link = prodcons_consume(&cons->input_pc); 617 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 618 619 if (event->type == KEY_PRESS) { 620 buf[pos] = event->c; 621 pos++; 622 } 623 624 free(event); 625 } 626 627 (void) async_data_read_finalize(callid, buf, size); 628 async_answer_1(iid, EOK, size); 629 free(buf); 630 } 631 632 static void cons_set_style(console_t *cons, console_style_t style) 633 { 634 fibril_mutex_lock(&cons->mtx); 635 screenbuffer_set_style(cons->frontbuf, style); 636 fibril_mutex_unlock(&cons->mtx); 637 } 638 639 static void cons_set_color(console_t *cons, console_color_t bgcolor, 389 cons_write_char(cons, str_decode(data, &off, size)); 390 return size; 391 } 392 393 static void cons_sync(con_srv_t *srv) 394 { 395 console_t *cons = srv_to_console(srv); 396 397 cons_update(cons); 398 } 399 400 static void cons_clear(con_srv_t *srv) 401 { 402 console_t *cons = srv_to_console(srv); 403 404 fibril_mutex_lock(&cons->mtx); 405 chargrid_clear(cons->frontbuf); 406 fibril_mutex_unlock(&cons->mtx); 407 408 cons_update(cons); 409 } 410 411 static void cons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row) 412 { 413 console_t *cons = srv_to_console(srv); 414 415 fibril_mutex_lock(&cons->mtx); 416 chargrid_set_cursor(cons->frontbuf, col, row); 417 fibril_mutex_unlock(&cons->mtx); 418 419 cons_update_cursor(cons); 420 } 421 422 static int cons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row) 423 { 424 console_t *cons = srv_to_console(srv); 425 426 fibril_mutex_lock(&cons->mtx); 427 chargrid_get_cursor(cons->frontbuf, col, row); 428 fibril_mutex_unlock(&cons->mtx); 429 430 return EOK; 431 } 432 433 static int cons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows) 434 { 435 console_t *cons = srv_to_console(srv); 436 437 fibril_mutex_lock(&cons->mtx); 438 *cols = cons->cols; 439 *rows = cons->rows; 440 fibril_mutex_unlock(&cons->mtx); 441 442 return EOK; 443 } 444 445 static int cons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps) 446 { 447 console_t *cons = srv_to_console(srv); 448 449 fibril_mutex_lock(&cons->mtx); 450 *ccaps = cons->ccaps; 451 fibril_mutex_unlock(&cons->mtx); 452 453 return EOK; 454 } 455 456 static void cons_set_style(con_srv_t *srv, console_style_t style) 457 { 458 console_t *cons = srv_to_console(srv); 459 460 fibril_mutex_lock(&cons->mtx); 461 chargrid_set_style(cons->frontbuf, style); 462 fibril_mutex_unlock(&cons->mtx); 463 } 464 465 static void cons_set_color(con_srv_t *srv, console_color_t bgcolor, 640 466 console_color_t fgcolor, console_color_attr_t attr) 641 467 { 642 fibril_mutex_lock(&cons->mtx); 643 screenbuffer_set_color(cons->frontbuf, bgcolor, fgcolor, attr); 644 fibril_mutex_unlock(&cons->mtx); 645 } 646 647 static void cons_set_rgb_color(console_t *cons, pixel_t bgcolor, 468 console_t *cons = srv_to_console(srv); 469 470 fibril_mutex_lock(&cons->mtx); 471 chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr); 472 fibril_mutex_unlock(&cons->mtx); 473 } 474 475 static void cons_set_rgb_color(con_srv_t *srv, pixel_t bgcolor, 648 476 pixel_t fgcolor) 649 477 { 650 fibril_mutex_lock(&cons->mtx); 651 screenbuffer_set_rgb_color(cons->frontbuf, bgcolor, fgcolor); 652 fibril_mutex_unlock(&cons->mtx); 653 } 654 655 static void cons_get_event(console_t *cons, ipc_callid_t iid, ipc_call_t *icall) 656 { 478 console_t *cons = srv_to_console(srv); 479 480 fibril_mutex_lock(&cons->mtx); 481 chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor); 482 fibril_mutex_unlock(&cons->mtx); 483 } 484 485 static void cons_set_cursor_visibility(con_srv_t *srv, bool visible) 486 { 487 console_t *cons = srv_to_console(srv); 488 489 cons_set_cursor_vis(cons, visible); 490 } 491 492 static int cons_get_event(con_srv_t *srv, cons_event_t *event) 493 { 494 console_t *cons = srv_to_console(srv); 657 495 link_t *link = prodcons_consume(&cons->input_pc); 658 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 659 660 async_answer_4(iid, EOK, event->type, event->key, event->mods, event->c); 661 free(event); 496 kbd_event_t *kevent = list_get_instance(link, kbd_event_t, link); 497 498 event->type = CEV_KEY; 499 event->ev.key = *kevent; 500 free(kevent); 501 return EOK; 662 502 } 663 503 … … 681 521 } 682 522 683 if (atomic_postinc(&cons->refcnt) == 0) { 684 cons_set_cursor_visibility(cons, true); 685 cons_notify_connect(cons); 686 } 687 688 /* Accept the connection */ 689 async_answer_0(iid, EOK); 690 691 while (true) { 692 ipc_call_t call; 693 ipc_callid_t callid = async_get_call(&call); 694 695 if (!IPC_GET_IMETHOD(call)) { 696 if (atomic_postdec(&cons->refcnt) == 1) 697 cons_notify_disconnect(cons); 698 699 return; 700 } 701 702 switch (IPC_GET_IMETHOD(call)) { 703 case VFS_OUT_READ: 704 cons_read(cons, callid, &call); 705 break; 706 case VFS_OUT_WRITE: 707 cons_write(cons, callid, &call); 708 break; 709 case VFS_OUT_SYNC: 710 cons_update(cons); 711 async_answer_0(callid, EOK); 712 break; 713 case CONSOLE_CLEAR: 714 cons_clear(cons); 715 async_answer_0(callid, EOK); 716 break; 717 case CONSOLE_GOTO: 718 cons_set_cursor(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 719 async_answer_0(callid, EOK); 720 break; 721 case CONSOLE_GET_POS: 722 cons_get_cursor(cons, callid, &call); 723 break; 724 case CONSOLE_GET_SIZE: 725 async_answer_2(callid, EOK, cons->cols, cons->rows); 726 break; 727 case CONSOLE_GET_COLOR_CAP: 728 async_answer_1(callid, EOK, cons->ccaps); 729 break; 730 case CONSOLE_SET_STYLE: 731 cons_set_style(cons, IPC_GET_ARG1(call)); 732 async_answer_0(callid, EOK); 733 break; 734 case CONSOLE_SET_COLOR: 735 cons_set_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call), 736 IPC_GET_ARG3(call)); 737 async_answer_0(callid, EOK); 738 break; 739 case CONSOLE_SET_RGB_COLOR: 740 cons_set_rgb_color(cons, IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 741 async_answer_0(callid, EOK); 742 break; 743 case CONSOLE_CURSOR_VISIBILITY: 744 cons_set_cursor_visibility(cons, IPC_GET_ARG1(call)); 745 async_answer_0(callid, EOK); 746 break; 747 case CONSOLE_GET_EVENT: 748 cons_get_event(cons, callid, &call); 749 break; 750 default: 751 async_answer_0(callid, EINVAL); 752 } 753 } 754 } 755 756 static async_sess_t *input_connect(const char *svc) 523 if (atomic_postinc(&cons->refcnt) == 0) 524 cons_set_cursor_vis(cons, true); 525 526 con_conn(iid, icall, &cons->srvs); 527 } 528 529 530 static int input_connect(const char *svc) 757 531 { 758 532 async_sess_t *sess; … … 760 534 761 535 int rc = loc_service_get_id(svc, &dsid, 0); 762 if (rc == EOK) { 763 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 764 if (sess == NULL) { 765 printf("%s: Unable to connect to input service %s\n", NAME, 766 svc); 767 return NULL; 768 } 769 } else 770 return NULL; 771 772 async_exch_t *exch = async_exchange_begin(sess); 773 rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL); 774 async_exchange_end(exch); 775 536 if (rc != EOK) { 537 printf("%s: Input service %s not found\n", NAME, svc); 538 return rc; 539 } 540 541 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 542 if (sess == NULL) { 543 printf("%s: Unable to connect to input service %s\n", NAME, 544 svc); 545 return EIO; 546 } 547 548 rc = input_open(sess, &input_ev_ops, NULL, &input); 776 549 if (rc != EOK) { 777 550 async_hangup(sess); 778 printf("%s: Unable to c reate callback connection toservice %s (%s)\n",551 printf("%s: Unable to communicate with service %s (%s)\n", 779 552 NAME, svc, str_error(rc)); 780 return NULL;781 } 782 783 return sess;553 return rc; 554 } 555 556 return EOK; 784 557 } 785 558 … … 789 562 } 790 563 791 static async_sess_t * fb_connect(const char *svc)564 static async_sess_t *output_connect(const char *svc) 792 565 { 793 566 async_sess_t *sess; … … 798 571 sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0); 799 572 if (sess == NULL) { 800 printf("%s: Unable to connect to framebufferservice %s\n",573 printf("%s: Unable to connect to output service %s\n", 801 574 NAME, svc); 802 575 return NULL; … … 808 581 } 809 582 810 static bool console_srv_init(char *input_svc, char *fb_svc) 811 { 812 /* Avoid double initialization */ 813 if (graphics_state != GRAPHICS_NONE) 583 static bool console_srv_init(char *input_svc, char *output_svc) 584 { 585 int rc; 586 587 /* Connect to input service */ 588 rc = input_connect(input_svc); 589 if (rc != EOK) 814 590 return false; 815 591 816 /* Connect to input service */ 817 input_sess = input_connect(input_svc); 818 if (input_sess == NULL) 819 return false; 820 821 /* Connect to framebuffer service */ 822 fb_sess = fb_connect(fb_svc); 823 if (fb_sess == NULL) 592 /* Connect to output service */ 593 output_sess = output_connect(output_svc); 594 if (output_sess == NULL) 824 595 return false; 825 596 826 597 /* Register server */ 827 598 async_set_client_connection(client_connection); 828 intrc = loc_server_register(NAME);829 if (rc < 0) {599 rc = loc_server_register(NAME); 600 if (rc != EOK) { 830 601 printf("%s: Unable to register server (%s)\n", NAME, 831 602 str_error(rc)); … … 833 604 } 834 605 835 fb_get_resolution(fb_sess, &xres, &yres); 836 837 /* Initialize the screen */ 838 screen_vp = fb_vp_create(fb_sess, 0, 0, xres, yres); 839 840 if ((xres >= 800) && (yres >= 600)) { 841 logo_vp = fb_vp_create(fb_sess, xres - 66, 2, 64, 60); 842 logo_img = imgmap_decode_tga((void *) helenos_tga, 843 helenos_tga_size, IMGMAP_FLAG_SHARED); 844 logo_handle = fb_imagemap_create(fb_sess, logo_img); 845 846 nameic_vp = fb_vp_create(fb_sess, 5, 17, 100, 26); 847 nameic_img = imgmap_decode_tga((void *) nameic_tga, 848 nameic_tga_size, IMGMAP_FLAG_SHARED); 849 nameic_handle = fb_imagemap_create(fb_sess, nameic_img); 850 851 cons_data_img = imgmap_decode_tga((void *) cons_data_tga, 852 cons_data_tga_size, IMGMAP_FLAG_SHARED); 853 cons_dis_img = imgmap_decode_tga((void *) cons_dis_tga, 854 cons_dis_tga_size, IMGMAP_FLAG_SHARED); 855 cons_dis_sel_img = imgmap_decode_tga((void *) cons_dis_sel_tga, 856 cons_dis_sel_tga_size, IMGMAP_FLAG_SHARED); 857 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga, 858 cons_idle_tga_size, IMGMAP_FLAG_SHARED); 859 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga, 860 cons_kernel_tga_size, IMGMAP_FLAG_SHARED); 861 cons_sel_img = imgmap_decode_tga((void *) cons_sel_tga, 862 cons_sel_tga_size, IMGMAP_FLAG_SHARED); 863 864 state_icons[CONS_DISCONNECTED] = 865 fb_imagemap_create(fb_sess, cons_dis_img); 866 state_icons[CONS_DISCONNECTED_SELECTED] = 867 fb_imagemap_create(fb_sess, cons_dis_sel_img); 868 state_icons[CONS_SELECTED] = 869 fb_imagemap_create(fb_sess, cons_sel_img); 870 state_icons[CONS_IDLE] = 871 fb_imagemap_create(fb_sess, cons_idle_img); 872 state_icons[CONS_DATA] = 873 fb_imagemap_create(fb_sess, cons_data_img); 874 state_icons[CONS_KERNEL] = 875 fb_imagemap_create(fb_sess, cons_kernel_img); 876 877 anim_1_img = imgmap_decode_tga((void *) anim_1_tga, 878 anim_1_tga_size, IMGMAP_FLAG_SHARED); 879 anim_2_img = imgmap_decode_tga((void *) anim_2_tga, 880 anim_2_tga_size, IMGMAP_FLAG_SHARED); 881 anim_3_img = imgmap_decode_tga((void *) anim_3_tga, 882 anim_3_tga_size, IMGMAP_FLAG_SHARED); 883 anim_4_img = imgmap_decode_tga((void *) anim_4_tga, 884 anim_4_tga_size, IMGMAP_FLAG_SHARED); 885 886 anim_1 = fb_imagemap_create(fb_sess, anim_1_img); 887 anim_2 = fb_imagemap_create(fb_sess, anim_2_img); 888 anim_3 = fb_imagemap_create(fb_sess, anim_3_img); 889 anim_4 = fb_imagemap_create(fb_sess, anim_4_img); 890 891 anim_seq = fb_sequence_create(fb_sess); 892 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_1); 893 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_2); 894 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_3); 895 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_4); 896 897 console_vp = fb_vp_create(fb_sess, CONSOLE_MARGIN, CONSOLE_TOP, 898 xres - 2 * CONSOLE_MARGIN, yres - (CONSOLE_TOP + CONSOLE_MARGIN)); 899 900 fb_vp_clear(fb_sess, screen_vp); 901 fb_vp_imagemap_damage(fb_sess, logo_vp, logo_handle, 902 0, 0, 64, 60); 903 fb_vp_imagemap_damage(fb_sess, nameic_vp, nameic_handle, 904 0, 0, 100, 26); 905 906 graphics_state = GRAPHICS_FULL; 907 } else { 908 console_vp = screen_vp; 909 graphics_state = GRAPHICS_BASIC; 910 } 911 912 fb_vp_set_style(fb_sess, console_vp, STYLE_NORMAL); 913 fb_vp_clear(fb_sess, console_vp); 914 915 sysarg_t cols; 916 sysarg_t rows; 917 fb_vp_get_dimensions(fb_sess, console_vp, &cols, &rows); 606 output_get_dimensions(output_sess, &cols, &rows); 607 output_set_style(output_sess, STYLE_NORMAL); 918 608 919 609 console_caps_t ccaps; 920 fb_vp_get_caps(fb_sess, console_vp, &ccaps); 921 922 mouse.x = xres / 2; 923 mouse.y = yres / 2; 924 mouse.pressed = false; 610 output_get_caps(output_sess, &ccaps); 925 611 926 612 /* Inititalize consoles */ … … 930 616 fibril_mutex_initialize(&consoles[i].mtx); 931 617 prodcons_initialize(&consoles[i].input_pc); 932 933 if (graphics_state == GRAPHICS_FULL) { 934 /* Create state buttons */ 935 consoles[i].state_vp = 936 fb_vp_create(fb_sess, STATE_START + (xres - 800) / 2 + 937 CONSOLE_MARGIN + i * (STATE_WIDTH + STATE_SPACE), 938 STATE_TOP, STATE_WIDTH, STATE_HEIGHT); 939 } 940 941 if (i == KERNEL_CONSOLE) { 942 consoles[i].state = CONS_KERNEL; 943 cons_redraw_state(&consoles[i]); 944 cons_kernel_sequence_start(&consoles[i]); 618 consoles[i].char_remains_len = 0; 619 620 if (i == KERNEL_CONSOLE) 945 621 continue; 946 }947 948 if (i == 0)949 consoles[i].state = CONS_DISCONNECTED_SELECTED;950 else951 consoles[i].state = CONS_DISCONNECTED;952 622 953 623 consoles[i].cols = cols; … … 955 625 consoles[i].ccaps = ccaps; 956 626 consoles[i].frontbuf = 957 screenbuffer_create(cols, rows, SCREENBUFFER_FLAG_SHARED);627 chargrid_create(cols, rows, CHARGRID_FLAG_SHARED); 958 628 959 629 if (consoles[i].frontbuf == NULL) { … … 962 632 } 963 633 964 consoles[i].fbid = fb_frontbuf_create(fb_sess, consoles[i].frontbuf); 634 consoles[i].fbid = output_frontbuf_create(output_sess, 635 consoles[i].frontbuf); 965 636 if (consoles[i].fbid == 0) { 966 637 printf("%s: Unable to create frontbuffer %zu\n", NAME, i); … … 968 639 } 969 640 970 cons_redraw_state(&consoles[i]); 641 con_srvs_init(&consoles[i].srvs); 642 consoles[i].srvs.ops = &con_ops; 643 consoles[i].srvs.sarg = &consoles[i]; 971 644 972 645 char vc[LOC_NAME_MAXLEN + 1]; … … 978 651 } 979 652 } 653 654 cons_damage(active_console); 980 655 981 656 /* Receive kernel notifications */ … … 989 664 } 990 665 991 static void usage( void)992 { 993 printf("Usage: console <input_dev> <framebuffer_dev>\n");666 static void usage(char *name) 667 { 668 printf("Usage: %s <input_dev> <output_dev>\n", name); 994 669 } 995 670 … … 997 672 { 998 673 if (argc < 3) { 999 usage( );674 usage(argv[0]); 1000 675 return -1; 1001 676 } … … 1010 685 async_manager(); 1011 686 687 /* Never reached */ 1012 688 return 0; 1013 689 } -
uspace/srv/hid/input/Makefile
r80445cf r4c53333 29 29 30 30 USPACE_PREFIX = ../../.. 31 EXTRA_CFLAGS = -Iinclude32 31 BINARY = input 33 32 34 33 SOURCES = \ 35 generic/gsp.c \36 generic/input.c \37 generic/layout.c \38 generic/stroke.c \39 34 layout/cz.c \ 40 35 layout/us_qwerty.c \ 41 36 layout/us_dvorak.c \ 37 layout/ar.c \ 42 38 port/adb.c \ 43 39 port/adb_mouse.c \ 44 40 port/chardev.c \ 45 port/gxemul.c \46 41 port/msim.c \ 47 42 port/niagara.c \ … … 52 47 proto/mousedev.c \ 53 48 ctl/apple.c \ 54 ctl/gxe_fb.c \55 49 ctl/kbdev.c \ 56 50 ctl/pc.c \ 57 51 ctl/stty.c \ 58 ctl/sun.c 52 ctl/sun.c \ 53 gsp.c \ 54 input.c \ 55 layout.c \ 56 stroke.c 59 57 60 58 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/hid/input/ctl/apple.c
r80445cf r4c53333 36 36 */ 37 37 38 #include <kbd.h>39 38 #include <io/console.h> 40 39 #include <io/keycode.h> 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 40 #include "../kbd.h" 41 #include "../kbd_ctl.h" 42 #include "../kbd_port.h" 43 43 44 44 static void apple_ctl_parse(sysarg_t); -
uspace/srv/hid/input/ctl/kbdev.c
r80445cf r4c53333 37 37 38 38 #include <async.h> 39 #include < bool.h>39 #include <stdbool.h> 40 40 #include <errno.h> 41 41 #include <fcntl.h> 42 #include <gsp.h>43 42 #include <io/console.h> 44 43 #include <io/keycode.h> 45 44 #include <ipc/kbdev.h> 46 #include <input.h>47 #include <kbd.h>48 #include <kbd_ctl.h>49 #include <kbd_port.h>50 45 #include <loc.h> 51 46 #include <stdlib.h> 52 47 #include <vfs/vfs_sess.h> 53 48 #include <sys/typefmt.h> 49 #include "../gsp.h" 50 #include "../input.h" 51 #include "../kbd.h" 52 #include "../kbd_ctl.h" 53 #include "../kbd_port.h" 54 54 55 55 static int kbdev_ctl_init(kbd_dev_t *); … … 68 68 /** Link to generic keyboard device */ 69 69 kbd_dev_t *kbd_dev; 70 70 71 71 /** Session with kbdev device */ 72 72 async_sess_t *sess; … … 75 75 static kbdev_t *kbdev_new(kbd_dev_t *kdev) 76 76 { 77 kbdev_t *kbdev; 78 79 kbdev = calloc(1, sizeof(kbdev_t)); 77 kbdev_t *kbdev = calloc(1, sizeof(kbdev_t)); 80 78 if (kbdev == NULL) 81 79 return NULL; 82 80 83 81 kbdev->kbd_dev = kdev; 84 82 … … 90 88 if (kbdev->sess != NULL) 91 89 async_hangup(kbdev->sess); 90 92 91 free(kbdev); 93 92 } … … 95 94 static int kbdev_ctl_init(kbd_dev_t *kdev) 96 95 { 97 async_sess_t *sess; 98 async_exch_t *exch; 99 kbdev_t *kbdev; 100 int rc; 101 102 sess = loc_service_connect(EXCHANGE_SERIALIZE, kdev->svc_id, 0); 96 async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, 97 kdev->svc_id, 0); 103 98 if (sess == NULL) { 104 99 printf("%s: Failed starting session with '%s.'\n", NAME, 105 100 kdev->svc_name); 106 return -1;101 return ENOENT; 107 102 } 108 109 kbdev = kbdev_new(kdev);103 104 kbdev_t *kbdev = kbdev_new(kdev); 110 105 if (kbdev == NULL) { 111 106 printf("%s: Failed allocating device structure for '%s'.\n", 112 107 NAME, kdev->svc_name); 113 108 async_hangup(sess); 114 return -1;109 return ENOMEM; 115 110 } 116 111 117 112 kbdev->sess = sess; 118 119 exch = async_exchange_begin(sess);113 114 async_exch_t *exch = async_exchange_begin(sess); 120 115 if (exch == NULL) { 121 116 printf("%s: Failed starting exchange with '%s'.\n", NAME, 122 117 kdev->svc_name); 123 118 kbdev_destroy(kbdev); 124 return -1;119 return ENOENT; 125 120 } 126 127 rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev);121 122 int rc = async_connect_to_me(exch, 0, 0, 0, kbdev_callback_conn, kbdev); 128 123 if (rc != EOK) { 129 124 printf("%s: Failed creating callback connection from '%s'.\n", … … 131 126 async_exchange_end(exch); 132 127 kbdev_destroy(kbdev); 133 return -1;128 return rc; 134 129 } 135 130 136 131 async_exchange_end(exch); 137 132 138 133 kdev->ctl_private = (void *) kbdev; 139 134 return 0; … … 142 137 static void kbdev_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 143 138 { 144 async_sess_t *sess; 145 async_exch_t *exch; 146 147 sess = ((kbdev_t *) kdev->ctl_private)->sess; 148 149 exch = async_exchange_begin(sess); 139 async_sess_t *sess = ((kbdev_t *) kdev->ctl_private)->sess; 140 async_exch_t *exch = async_exchange_begin(sess); 150 141 if (!exch) 151 142 return; 152 143 153 144 async_msg_1(exch, KBDEV_SET_IND, mods); 154 145 async_exchange_end(exch); -
uspace/srv/hid/input/ctl/pc.c
r80445cf r4c53333 36 36 */ 37 37 38 #include <kbd.h>39 38 #include <io/console.h> 40 39 #include <io/keycode.h> 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 43 #include <gsp.h> 40 #include "../gsp.h" 41 #include "../kbd.h" 42 #include "../kbd_port.h" 43 #include "../kbd_ctl.h" 44 44 45 45 static void pc_ctl_parse(sysarg_t); -
uspace/srv/hid/input/ctl/stty.c
r80445cf r4c53333 38 38 */ 39 39 40 #include <kbd.h>41 40 #include <io/keycode.h> 42 #include <kbd_ctl.h> 43 #include <kbd_port.h> 44 #include <gsp.h> 45 #include <stroke.h> 41 #include "../stroke.h" 42 #include "../gsp.h" 43 #include "../kbd.h" 44 #include "../kbd_port.h" 45 #include "../kbd_ctl.h" 46 46 47 47 static void stty_ctl_parse(sysarg_t); -
uspace/srv/hid/input/ctl/sun.c
r80445cf r4c53333 37 37 */ 38 38 39 #include <kbd.h>40 39 #include <io/console.h> 41 40 #include <io/keycode.h> 42 #include <kbd_ctl.h> 43 #include <kbd_port.h> 41 #include "../kbd.h" 42 #include "../kbd_port.h" 43 #include "../kbd_ctl.h" 44 44 45 45 static void sun_ctl_parse(sysarg_t); -
uspace/srv/hid/input/gsp.c
r80445cf r4c53333 31 31 * @ingroup input 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 * @brief Generic scancode parser.35 * @brief Generic scancode parser. 36 36 * 37 37 * The scancode parser is a simple finite state machine. It is described … … 49 49 */ 50 50 51 #include <gsp.h>52 51 #include <adt/hash_table.h> 52 #include <adt/hash.h> 53 53 #include <stdlib.h> 54 54 #include <stdio.h> 55 56 #define TRANS_TABLE_CHAINS 256 55 #include "gsp.h" 57 56 58 57 /* 59 * Hash table operations for the transition function. 60 */ 61 62 static hash_index_t trans_op_hash(unsigned long key[]); 63 static int trans_op_compare(unsigned long key[], hash_count_t keys, 64 link_t *item); 65 static void trans_op_remove_callback(link_t *item); 66 67 static hash_table_operations_t trans_ops = { 68 .hash = trans_op_hash, 69 .compare = trans_op_compare, 70 .remove_callback = trans_op_remove_callback 58 * Transition function hash table operations. 59 */ 60 typedef struct { 61 int old_state; 62 int input; 63 } trans_key_t; 64 65 static size_t trans_key_hash(void *key) 66 { 67 trans_key_t *trans_key = (trans_key_t *)key; 68 return hash_combine(trans_key->input, trans_key->old_state); 69 } 70 71 static size_t trans_hash(const ht_link_t *item) 72 { 73 gsp_trans_t *t = hash_table_get_inst(item, gsp_trans_t, link); 74 return hash_combine(t->input, t->old_state); 75 } 76 77 static bool trans_key_equal(void *key, const ht_link_t *item) 78 { 79 trans_key_t *trans_key = (trans_key_t *)key; 80 gsp_trans_t *t = hash_table_get_inst(item, gsp_trans_t, link); 81 82 return trans_key->input == t->input && trans_key->old_state == t->old_state; 83 } 84 85 static hash_table_ops_t trans_ops = { 86 .hash = trans_hash, 87 .key_hash = trans_key_hash, 88 .key_equal = trans_key_equal, 89 .equal = NULL, 90 .remove_callback = NULL 71 91 }; 92 72 93 73 94 static gsp_trans_t *trans_lookup(gsp_t *p, int state, int input); … … 75 96 static gsp_trans_t *trans_new(void); 76 97 77 /** Initiali se scancode parser. */98 /** Initialize scancode parser. */ 78 99 void gsp_init(gsp_t *p) 79 100 { 80 101 p->states = 1; 81 hash_table_create(&p->trans, TRANS_TABLE_CHAINS, 2, &trans_ops);102 hash_table_create(&p->trans, 0, 0, &trans_ops); 82 103 } 83 104 … … 223 244 static gsp_trans_t *trans_lookup(gsp_t *p, int state, int input) 224 245 { 225 link_t *item; 226 unsigned long key[2]; 227 228 key[0] = state; 229 key[1] = input; 230 231 item = hash_table_find(&p->trans, key); 246 ht_link_t *item; 247 248 trans_key_t key = { 249 .input = input, 250 .old_state = state 251 }; 252 253 item = hash_table_find(&p->trans, &key); 232 254 if (item == NULL) return NULL; 233 255 234 return hash_table_get_inst ance(item, gsp_trans_t, link);256 return hash_table_get_inst(item, gsp_trans_t, link); 235 257 } 236 258 … … 242 264 static void trans_insert(gsp_t *p, gsp_trans_t *t) 243 265 { 244 unsigned long key[2]; 245 246 key[0] = t->old_state; 247 key[1] = t->input; 248 249 hash_table_insert(&p->trans, key, &t->link); 266 hash_table_insert(&p->trans, &t->link); 250 267 } 251 268 … … 264 281 } 265 282 266 /*267 * Transition function hash table operations.268 */269 270 static hash_index_t trans_op_hash(unsigned long key[])271 {272 return (key[0] * 17 + key[1]) % TRANS_TABLE_CHAINS;273 }274 275 static int trans_op_compare(unsigned long key[], hash_count_t keys,276 link_t *item)277 {278 gsp_trans_t *t;279 280 t = hash_table_get_instance(item, gsp_trans_t, link);281 return ((key[0] == (unsigned long) t->old_state)282 && (key[1] == (unsigned long) t->input));283 }284 285 static void trans_op_remove_callback(link_t *item)286 {287 }288 283 289 284 /** -
uspace/srv/hid/input/gsp.h
r80445cf r4c53333 56 56 /** Scancode parser transition. */ 57 57 typedef struct { 58 link_t link; /**< Link to hash table in @c gsp_t */58 ht_link_t link; /**< Link to hash table in @c gsp_t */ 59 59 60 60 /* Preconditions */ -
uspace/srv/hid/input/input.c
r80445cf r4c53333 38 38 39 39 #include <adt/list.h> 40 #include < bool.h>40 #include <stdbool.h> 41 41 #include <fibril_synch.h> 42 42 #include <ipc/services.h> … … 54 54 #include <io/keycode.h> 55 55 #include <loc.h> 56 #include <input.h>57 #include <kbd.h>58 #include <kbd_port.h>59 #include <kbd_ctl.h>60 #include <mouse_proto.h>61 #include <layout.h>62 #include <mouse.h>63 64 #define NUM_LAYOUTS 356 #include "layout.h" 57 #include "kbd.h" 58 #include "kbd_port.h" 59 #include "kbd_ctl.h" 60 #include "mouse.h" 61 #include "mouse_proto.h" 62 #include "input.h" 63 64 #define NUM_LAYOUTS 4 65 65 66 66 static layout_ops_t *layout[NUM_LAYOUTS] = { 67 67 &us_qwerty_ops, 68 68 &us_dvorak_ops, 69 &cz_ops 69 &cz_ops, 70 &ar_ops 70 71 }; 71 72 … … 163 164 } 164 165 166 if (type == KEY_PRESS && (kdev->mods & KM_LCTRL) && 167 key == KC_F4) { 168 layout_destroy(kdev->active_layout); 169 kdev->active_layout = layout_create(layout[3]); 170 return; 171 } 172 165 173 ev.type = type; 166 174 ev.key = key; … … 189 197 } 190 198 async_exchange_end(exch); 199 } 200 201 /** Mouse pointer has moved in absolute mode. */ 202 void mouse_push_event_abs_move(mouse_dev_t *mdev, unsigned int x, unsigned int y, 203 unsigned int max_x, unsigned int max_y) 204 { 205 if (max_x && max_y) { 206 async_exch_t *exch = async_exchange_begin(client_sess); 207 async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y); 208 async_exchange_end(exch); 209 } 191 210 } 192 211 … … 412 431 kbd_add_dev(&chardev_port, &stty_ctl); 413 432 #endif 414 #if defined(UARCH_arm32) && defined(MACHINE_testarm) && defined(CONFIG_FB)415 kbd_add_dev(&gxemul_port, &gxe_fb_ctl);416 #endif417 #if defined(UARCH_arm32) && defined(MACHINE_testarm) && !defined(CONFIG_FB)418 kbd_add_dev(&gxemul_port, &stty_ctl);419 #endif420 433 #if defined(UARCH_arm32) && defined(MACHINE_integratorcp) 421 434 kbd_add_dev(&pl050_port, &pc_ctl); … … 426 439 #if defined(MACHINE_msim) 427 440 kbd_add_dev(&msim_port, &stty_ctl); 428 #endif429 #if (defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul)) && defined(CONFIG_FB)430 kbd_add_dev(&gxemul_port, &gxe_fb_ctl);431 #endif432 #if defined(MACHINE_lgxemul) || defined(MACHINE_bgxemul) && !defined(CONFIG_FB)433 kbd_add_dev(&gxemul_port, &stty_ctl);434 441 #endif 435 442 #if defined(UARCH_ppc32) … … 635 642 } 636 643 644 static void usage(char *name) 645 { 646 printf("Usage: %s <service_name>\n", name); 647 } 648 637 649 int main(int argc, char **argv) 638 650 { 651 if (argc < 2) { 652 usage(argv[0]); 653 return 1; 654 } 655 639 656 printf("%s: HelenOS input service\n", NAME); 640 657 … … 662 679 async_set_client_connection(client_connection); 663 680 int rc = loc_server_register(NAME); 664 if (rc < 0) { 665 printf("%s: Unable to register server (%d)\n", NAME, rc); 666 return -1; 667 } 668 669 char kbd[LOC_NAME_MAXLEN + 1]; 670 snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME); 681 if (rc != EOK) { 682 printf("%s: Unable to register server\n", NAME); 683 return rc; 684 } 671 685 672 686 service_id_t service_id; 673 if (loc_service_register(kbd, &service_id) != EOK) { 674 printf("%s: Unable to register service %s\n", NAME, kbd); 675 return -1; 687 rc = loc_service_register(argv[1], &service_id); 688 if (rc != EOK) { 689 printf("%s: Unable to register service %s\n", NAME, argv[1]); 690 return rc; 676 691 } 677 692 … … 680 695 681 696 printf("%s: Accepting connections\n", NAME); 697 task_retval(0); 682 698 async_manager(); 683 699 -
uspace/srv/hid/input/input.h
r80445cf r4c53333 39 39 #define INPUT_H_ 40 40 41 #include < bool.h>41 #include <stdbool.h> 42 42 #include <async.h> 43 43 44 #define NAME "input" 45 #define NAMESPACE "hid" 44 #define NAME "input" 46 45 47 46 extern bool irc_service; -
uspace/srv/hid/input/kbd_ctl.h
r80445cf r4c53333 38 38 #define KBD_CTL_H_ 39 39 40 #include <kbd_port.h>40 #include "kbd_port.h" 41 41 42 42 struct kbd_dev; … … 49 49 50 50 extern kbd_ctl_ops_t apple_ctl; 51 extern kbd_ctl_ops_t gxe_fb_ctl;52 51 extern kbd_ctl_ops_t kbdev_ctl; 53 52 extern kbd_ctl_ops_t pc_ctl; -
uspace/srv/hid/input/kbd_port.h
r80445cf r4c53333 51 51 extern kbd_port_ops_t adb_port; 52 52 extern kbd_port_ops_t chardev_port; 53 extern kbd_port_ops_t gxemul_port;54 53 extern kbd_port_ops_t msim_port; 55 54 extern kbd_port_ops_t niagara_port; -
uspace/srv/hid/input/layout.c
r80445cf r4c53333 37 37 38 38 #include <errno.h> 39 #include <input.h>40 #include <layout.h>41 39 #include <stdlib.h> 40 #include "input.h" 41 #include "layout.h" 42 42 43 43 /** Create a new layout instance. */ -
uspace/srv/hid/input/layout.h
r80445cf r4c53333 60 60 extern layout_ops_t us_dvorak_ops; 61 61 extern layout_ops_t cz_ops; 62 extern layout_ops_t ar_ops; 62 63 63 64 extern layout_t *layout_create(layout_ops_t *); -
uspace/srv/hid/input/layout/cz.c
r80445cf r4c53333 33 33 34 34 #include <errno.h> 35 #include <input.h>36 35 #include <io/console.h> 37 36 #include <io/keycode.h> 38 #include <bool.h> 39 #include <layout.h> 37 #include <stdbool.h> 40 38 #include <stdlib.h> 39 #include "../input.h" 40 #include "../layout.h" 41 41 42 42 static int cz_create(layout_t *); -
uspace/srv/hid/input/layout/us_dvorak.c
r80445cf r4c53333 33 33 34 34 #include <errno.h> 35 #include <kbd.h>36 35 #include <io/console.h> 37 36 #include <io/keycode.h> 38 #include <layout.h> 37 #include "../layout.h" 38 #include "../kbd.h" 39 39 40 40 static int us_dvorak_create(layout_t *); -
uspace/srv/hid/input/layout/us_qwerty.c
r80445cf r4c53333 28 28 29 29 /** @addtogroup input 30 * @brief US QWERTY layout.30 * @brief US QWERTY layout. 31 31 * @{ 32 32 */ 33 33 34 34 #include <errno.h> 35 #include <kbd.h>36 35 #include <io/console.h> 37 36 #include <io/keycode.h> 38 #include <layout.h> 37 #include "../layout.h" 38 #include "../kbd.h" 39 39 40 40 static int us_qwerty_create(layout_t *); -
uspace/srv/hid/input/mouse.h
r80445cf r4c53333 63 63 extern void mouse_push_data(mouse_dev_t *, sysarg_t); 64 64 extern void mouse_push_event_move(mouse_dev_t *, int, int, int); 65 extern void mouse_push_event_abs_move(mouse_dev_t *, unsigned int, unsigned int, 66 unsigned int, unsigned int); 65 67 extern void mouse_push_event_button(mouse_dev_t *, int, int); 66 68 -
uspace/srv/hid/input/mouse_proto.h
r80445cf r4c53333 38 38 #define MOUSE_PROTO_H_ 39 39 40 #include <mouse_port.h>40 #include "mouse_port.h" 41 41 42 42 struct mouse_dev; -
uspace/srv/hid/input/port/adb.c
r80445cf r4c53333 37 37 #include <ipc/adb.h> 38 38 #include <async.h> 39 #include <input.h>40 #include <kbd_port.h>41 #include <kbd.h>42 39 #include <vfs/vfs.h> 43 40 #include <fcntl.h> 44 41 #include <errno.h> 45 42 #include <loc.h> 43 #include "../input.h" 44 #include "../kbd_port.h" 45 #include "../kbd.h" 46 46 47 47 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 65 65 static int adb_port_init(kbd_dev_t *kdev) 66 66 { 67 kbd_dev = kdev; 68 67 69 const char *dev = "adb/kbd"; 68 70 service_id_t service_id; 69 async_exch_t *exch; 70 int rc; 71 72 kbd_dev = kdev; 73 74 rc = loc_service_get_id(dev, &service_id, 0); 71 int rc = loc_service_get_id(dev, &service_id, 0); 75 72 if (rc != EOK) 76 73 return rc; … … 82 79 } 83 80 84 exch = async_exchange_begin(dev_sess);81 async_exch_t *exch = async_exchange_begin(dev_sess); 85 82 if (exch == NULL) { 86 83 printf("%s: Failed starting exchange with device\n", NAME); … … 89 86 } 90 87 91 /* NB: The callback connection is slotted for removal */92 88 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 93 89 async_exchange_end(exch); … … 122 118 ipc_callid_t callid = async_get_call(&call); 123 119 124 int retval ;120 int retval = EOK; 125 121 126 122 if (!IPC_GET_IMETHOD(call)) { -
uspace/srv/hid/input/port/adb_mouse.c
r80445cf r4c53333 37 37 #include <ipc/adb.h> 38 38 #include <async.h> 39 #include <input.h>40 #include <mouse_port.h>41 #include <mouse.h>42 39 #include <errno.h> 43 40 #include <loc.h> 44 41 #include <stdio.h> 42 #include "../mouse.h" 43 #include "../mouse_port.h" 44 #include "../input.h" 45 45 46 46 static mouse_dev_t *mouse_dev; … … 54 54 ipc_callid_t callid = async_get_call(&call); 55 55 56 int retval ;56 int retval = EOK; 57 57 58 58 if (!IPC_GET_IMETHOD(call)) { -
uspace/srv/hid/input/port/chardev.c
r80445cf r4c53333 37 37 #include <ipc/char.h> 38 38 #include <async.h> 39 #include <input.h>40 #include <kbd_port.h>41 #include <kbd.h>42 39 #include <loc.h> 43 40 #include <errno.h> 44 41 #include <stdio.h> 42 #include "../input.h" 43 #include "../kbd_port.h" 44 #include "../kbd.h" 45 45 46 46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); … … 63 63 /** List of devices to try connecting to. */ 64 64 static const char *in_devs[] = { 65 "char/s3c24 ser"65 "char/s3c24xx_uart" 66 66 }; 67 67 … … 148 148 } 149 149 150 int retval ;150 int retval = EOK; 151 151 152 152 switch (IPC_GET_IMETHOD(call)) { -
uspace/srv/hid/input/port/msim.c
r80445cf r4c53333 38 38 #include <async.h> 39 39 #include <sysinfo.h> 40 #include <kbd_port.h>41 #include <kbd.h>42 40 #include <ddi.h> 43 41 #include <errno.h> 42 #include "../kbd_port.h" 43 #include "../kbd.h" 44 44 45 45 static int msim_port_init(kbd_dev_t *); -
uspace/srv/hid/input/port/niagara.c
r80445cf r4c53333 31 31 * @ingroup kbd 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 * @brief Niagara console keyboard port driver.35 * @brief Niagara console keyboard port driver. 36 36 */ 37 37 … … 39 39 #include <ddi.h> 40 40 #include <async.h> 41 #include <kbd.h>42 #include <kbd_port.h>43 41 #include <sysinfo.h> 44 42 #include <stdio.h> 45 43 #include <thread.h> 46 #include < bool.h>44 #include <stdbool.h> 47 45 #include <errno.h> 46 #include "../kbd_port.h" 47 #include "../kbd.h" 48 48 49 49 static int niagara_port_init(kbd_dev_t *); -
uspace/srv/hid/input/port/ns16550.c
r80445cf r4c53333 39 39 #include <async.h> 40 40 #include <sysinfo.h> 41 #include <input.h>42 #include <kbd.h>43 #include <kbd_port.h>44 41 #include <ddi.h> 45 42 #include <errno.h> 43 #include "../input.h" 44 #include "../kbd_port.h" 45 #include "../kbd.h" 46 46 47 47 static int ns16550_port_init(kbd_dev_t *); … … 84 84 }, 85 85 { 86 .cmd = CMD_ BTEST,86 .cmd = CMD_AND, 87 87 .value = LSR_DATA_READY, 88 88 .srcarg = 1, -
uspace/srv/hid/input/port/pl050.c
r80445cf r4c53333 37 37 38 38 #include <ddi.h> 39 #include <libarch/ddi.h>40 39 #include <async.h> 41 40 #include <unistd.h> 42 41 #include <sysinfo.h> 43 #include <kbd_port.h>44 #include <kbd.h>45 #include <ddi.h>46 42 #include <stdio.h> 47 43 #include <errno.h> 44 #include "../kbd_port.h" 45 #include "../kbd.h" 48 46 49 47 static int pl050_port_init(kbd_dev_t *); … … 80 78 }, 81 79 { 82 .cmd = CMD_ BTEST,80 .cmd = CMD_AND, 83 81 .value = PL050_STAT_RXFULL, 84 82 .srcarg = 1, -
uspace/srv/hid/input/port/ski.c
r80445cf r4c53333 31 31 * @ingroup kbd 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 * @brief Ski console keyboard port driver.35 * @brief Ski console keyboard port driver. 36 36 */ 37 38 37 39 38 #include <stdlib.h> 40 39 #include <unistd.h> 41 #include <kbd.h>42 #include <kbd_port.h>43 40 #include <sys/types.h> 44 41 #include <thread.h> 45 #include <bool.h> 42 #include <stdbool.h> 43 #include "../kbd_port.h" 44 #include "../kbd.h" 46 45 47 46 static int ski_port_init(kbd_dev_t *); -
uspace/srv/hid/input/proto/adb.c
r80445cf r4c53333 36 36 */ 37 37 38 #include < bool.h>39 #include <mouse.h>40 #include <mouse_port.h>41 #include <mouse_proto.h>38 #include <stdbool.h> 39 #include "../mouse.h" 40 #include "../mouse_port.h" 41 #include "../mouse_proto.h" 42 42 43 43 static mouse_dev_t *mouse_dev; -
uspace/srv/hid/input/proto/mousedev.c
r80445cf r4c53333 43 43 #include <errno.h> 44 44 #include <ipc/mouseev.h> 45 #include <input.h>46 45 #include <loc.h> 47 #include <mouse.h>48 #include <mouse_port.h>49 #include <mouse_proto.h>50 46 #include <sys/typefmt.h> 47 #include "../mouse.h" 48 #include "../mouse_port.h" 49 #include "../mouse_proto.h" 50 #include "../input.h" 51 51 52 52 /** Mousedev softstate */ … … 96 96 retval = EOK; 97 97 break; 98 case MOUSEEV_ABS_MOVE_EVENT: 99 mouse_push_event_abs_move(mousedev->mouse_dev, 100 IPC_GET_ARG1(call), IPC_GET_ARG2(call), 101 IPC_GET_ARG3(call), IPC_GET_ARG4(call)); 102 retval = EOK; 103 break; 98 104 case MOUSEEV_BUTTON_EVENT: 99 105 mouse_push_event_button(mousedev->mouse_dev, … … 117 123 printf("%s: Failed starting session with '%s'\n", NAME, 118 124 mdev->svc_name); 119 return -1;125 return ENOENT; 120 126 } 121 127 … … 125 131 NAME, mdev->svc_name); 126 132 async_hangup(sess); 127 return -1;133 return ENOMEM; 128 134 } 129 135 … … 134 140 mousedev_destroy(mousedev); 135 141 async_hangup(sess); 136 return -1;142 return ENOENT; 137 143 } 138 144 … … 145 151 NAME, mdev->svc_name); 146 152 mousedev_destroy(mousedev); 147 return -1;153 return rc; 148 154 } 149 155 150 return 0;156 return EOK; 151 157 } 152 158 -
uspace/srv/hid/input/stroke.c
r80445cf r4c53333 40 40 */ 41 41 42 #include <stroke.h>43 #include <kbd.h>44 42 #include <io/console.h> 45 43 #include <io/keycode.h> 44 #include "stroke.h" 45 #include "kbd.h" 46 46 47 47 /** Correspondence between modifers and the modifier keycodes. */ -
uspace/srv/hid/input/stroke.h
r80445cf r4c53333 28 28 29 29 /** @addtogroup inputgen generic 30 * @brief Generic scancode parser.31 * @ingroup input30 * @brief Generic scancode parser. 31 * @ingroup input 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ … … 38 38 #define KBD_STROKE_H_ 39 39 40 #include <kbd.h>40 #include "kbd.h" 41 41 42 42 extern void stroke_sim(kbd_dev_t *, unsigned, unsigned); … … 46 46 /** 47 47 * @} 48 */ 49 48 */ -
uspace/srv/hid/output/Makefile
r80445cf r4c53333 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBFB_PREFIX)/libfb.a 32 EXTRA_CFLAGS += -I$(LIBFB_PREFIX) 33 BINARY = fb 31 BINARY = output 34 32 35 33 SOURCES = \ 36 gfx/font-8x16.c \37 34 ctl/serial.c \ 38 35 port/ega.c \ 39 port/kfb.c \40 36 port/kchar.c \ 41 37 port/niagara.c \ 42 38 port/ski.c \ 43 39 proto/vt100.c \ 44 fb.c40 output.c 45 41 46 42 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/hid/output/ctl/serial.c
r80445cf r4c53333 28 28 */ 29 29 30 /** @file 30 /** @addtogroup console 31 * @{ 32 */ 33 /** 34 * @file 31 35 */ 32 36 33 37 #include <sys/types.h> 34 38 #include <errno.h> 35 #include < malloc.h>36 #include <screenbuffer.h>39 #include <io/chargrid.h> 40 #include "../output.h" 37 41 #include "../proto/vt100.h" 38 #include "../fb.h"39 42 #include "serial.h" 40 43 41 /** Draw the character at the specified position in viewport. 44 #define SERIAL_COLS 80 45 #define SERIAL_ROWS 24 46 47 /** Draw the character at the specified position. 42 48 * 43 49 * @param state VT100 protocol state. 44 * @param vp Viewport.45 * @param col Screen position relative to viewport.46 * @param row Screen position relative to viewport.50 * @param field Character field. 51 * @param col Horizontal screen position. 52 * @param row Vertical screen position. 47 53 * 48 54 */ 49 static void draw_ vp_char(vt100_state_t *state, fbvp_t *vp, sysarg_t col,50 sysarg_t row)55 static void draw_char(vt100_state_t *state, charfield_t *field, 56 sysarg_t col, sysarg_t row) 51 57 { 52 sysarg_t x = vp->x + col; 53 sysarg_t y = vp->y + row; 54 55 charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row); 56 57 vt100_goto(state, x, y); 58 vt100_goto(state, col, row); 58 59 vt100_set_attr(state, field->attrs); 59 60 vt100_putchar(state, field->ch); 60 61 } 61 62 62 static int serial_yield( fbdev_t *dev)63 static int serial_yield(outdev_t *dev) 63 64 { 64 65 vt100_state_t *state = (vt100_state_t *) dev->data; 66 65 67 return vt100_yield(state); 66 68 } 67 69 68 static int serial_claim( fbdev_t *dev)70 static int serial_claim(outdev_t *dev) 69 71 { 70 72 vt100_state_t *state = (vt100_state_t *) dev->data; 73 71 74 return vt100_claim(state); 72 75 } 73 76 74 static int serial_get_resolution(fbdev_t *dev, sysarg_t *width, sysarg_t *height) 75 { 76 vt100_state_t *state = (vt100_state_t *) dev->data; 77 vt100_get_resolution(state, width, height); 78 return EOK; 79 } 80 81 static void serial_font_metrics(fbdev_t *dev, sysarg_t width, sysarg_t height, 82 sysarg_t *cols, sysarg_t *rows) 83 { 84 *cols = width; 85 *rows = height; 86 } 87 88 static int serial_vp_create(fbdev_t *dev, fbvp_t *vp) 89 { 90 vp->attrs.type = CHAR_ATTR_STYLE; 91 vp->attrs.val.style = STYLE_NORMAL; 92 vp->data = NULL; 93 94 return EOK; 95 } 96 97 static void serial_vp_destroy(fbdev_t *dev, fbvp_t *vp) 98 { 99 /* No-op */ 100 } 101 102 static void serial_vp_clear(fbdev_t *dev, fbvp_t *vp) 77 static void serial_get_dimensions(outdev_t *dev, sysarg_t *cols, 78 sysarg_t *rows) 103 79 { 104 80 vt100_state_t *state = (vt100_state_t *) dev->data; 105 81 106 for (sysarg_t row = 0; row < vp->rows; row++) { 107 for (sysarg_t col = 0; col < vp->cols; col++) { 108 charfield_t *field = 109 screenbuffer_field_at(vp->backbuf, col, row); 110 111 field->ch = 0; 112 field->attrs = vp->attrs; 113 114 draw_vp_char(state, vp, col, row); 115 } 116 } 82 vt100_get_dimensions(state, cols, rows); 117 83 } 118 84 119 static console_caps_t serial_ vp_get_caps(fbdev_t *dev, fbvp_t *vp)85 static console_caps_t serial_get_caps(outdev_t *dev) 120 86 { 121 87 return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED); 122 88 } 123 89 124 static void serial_vp_cursor_update(fbdev_t *dev, fbvp_t *vp, 125 sysarg_t prev_col, sysarg_t prev_row, sysarg_t col, sysarg_t row, 126 bool visible) 90 static void serial_cursor_update(outdev_t *dev, sysarg_t prev_col, 91 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) 127 92 { 128 93 vt100_state_t *state = (vt100_state_t *) dev->data; 129 94 130 vt100_goto(state, vp->x + col, vp->y +row);95 vt100_goto(state, col, row); 131 96 vt100_cursor_visibility(state, visible); 132 97 } 133 98 134 static void serial_vp_char_update(fbdev_t *dev, fbvp_t *vp, sysarg_t col, 135 sysarg_t row) 99 static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) 136 100 { 137 101 vt100_state_t *state = (vt100_state_t *) dev->data; 138 draw_vp_char(state, vp, col, row); 102 charfield_t *field = 103 chargrid_charfield_at(dev->backbuf, col, row); 104 105 draw_char(state, field, col, row); 139 106 } 140 107 141 static fbdev_ops_t serial_ops = {108 static outdev_ops_t serial_ops = { 142 109 .yield = serial_yield, 143 110 .claim = serial_claim, 144 .get_resolution = serial_get_resolution, 145 .font_metrics = serial_font_metrics, 146 .vp_create = serial_vp_create, 147 .vp_destroy = serial_vp_destroy, 148 .vp_clear = serial_vp_clear, 149 .vp_get_caps = serial_vp_get_caps, 150 .vp_cursor_update = serial_vp_cursor_update, 151 .vp_char_update = serial_vp_char_update 111 .get_dimensions = serial_get_dimensions, 112 .get_caps = serial_get_caps, 113 .cursor_update = serial_cursor_update, 114 .char_update = serial_char_update 152 115 }; 153 116 … … 156 119 { 157 120 vt100_state_t *state = 158 vt100_state_create(80, 24, putchar_fn, control_puts_fn); 121 vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putchar_fn, 122 control_puts_fn); 159 123 if (state == NULL) 160 124 return ENOMEM; 161 125 162 fbdev_t *dev = fbdev_register(&serial_ops, state); 163 if (dev == NULL) 164 return EINVAL; 126 outdev_t *dev = outdev_register(&serial_ops, state); 127 if (dev == NULL) { 128 vt100_state_destroy(state); 129 return ENOMEM; 130 } 165 131 166 132 return EOK; -
uspace/srv/hid/output/ctl/serial.h
r80445cf r4c53333 31 31 */ 32 32 33 #ifndef FB_CTL_SERIAL_H_34 #define FB_CTL_SERIAL_H_33 #ifndef OUTPUT_CTL_SERIAL_H_ 34 #define OUTPUT_CTL_SERIAL_H_ 35 35 36 36 #include "../proto/vt100.h" -
uspace/srv/hid/output/port/ega.c
r80445cf r4c53333 33 33 #include <errno.h> 34 34 #include <sysinfo.h> 35 #include <task.h> 35 #include <align.h> 36 #include <as.h> 36 37 #include <ddi.h> 37 #include <libarch/ddi.h> 38 #include <as.h> 39 #include <malloc.h> 40 #include <align.h> 41 #include <screenbuffer.h> 42 #include "../fb.h" 38 #include <io/chargrid.h> 39 #include "../output.h" 43 40 #include "ega.h" 44 41 … … 46 43 #define EGA_IO_SIZE 2 47 44 48 #define FB_POS(x, y) (((y) * ega. width+ (x)) << 1)45 #define FB_POS(x, y) (((y) * ega.cols + (x)) << 1) 49 46 50 47 typedef struct { 51 sysarg_t width; 52 sysarg_t height; 48 sysarg_t cols; 49 sysarg_t rows; 50 51 uint8_t style_normal; 52 uint8_t style_inverted; 53 53 54 54 size_t size; 55 55 uint8_t *addr; 56 57 uint8_t style_normal;58 uint8_t style_inverted;59 60 uint8_t *backbuf;61 56 } ega_t; 62 57 … … 101 96 } 102 97 103 /** Draw the character at the specified position in viewport. 104 * 105 * @param vp Viewport. 106 * @param col Screen position relative to viewport. 107 * @param row Screen position relative to viewport. 108 * 109 */ 110 static void draw_vp_char(fbvp_t *vp, sysarg_t col, sysarg_t row) 111 { 112 sysarg_t x = vp->x + col; 113 sysarg_t y = vp->y + row; 114 115 charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row); 116 98 /** Draw the character at the specified position. 99 * 100 * @param field Character field. 101 * @param col Horizontal screen position. 102 * @param row Vertical screen position. 103 * 104 */ 105 static void draw_char(charfield_t *field, sysarg_t col, sysarg_t row) 106 { 117 107 uint8_t glyph; 118 108 … … 124 114 uint8_t attr = attrs_attr(field->attrs); 125 115 126 ega.addr[FB_POS(x, y)] = glyph; 127 ega.addr[FB_POS(x, y) + 1] = attr; 128 } 129 130 static int ega_yield(fbdev_t *dev) 131 { 132 if (ega.backbuf == NULL) { 133 ega.backbuf = malloc(ega.size); 134 if (ega.backbuf == NULL) 135 return ENOMEM; 136 } 137 138 memcpy(ega.backbuf, ega.addr, ega.size); 116 ega.addr[FB_POS(col, row)] = glyph; 117 ega.addr[FB_POS(col, row) + 1] = attr; 118 } 119 120 static int ega_yield(outdev_t *dev) 121 { 139 122 return EOK; 140 123 } 141 124 142 static int ega_claim(fbdev_t *dev) 143 { 144 if (ega.backbuf == NULL) 145 return ENOENT; 146 147 memcpy(ega.addr, ega.backbuf, ega.size); 125 static int ega_claim(outdev_t *dev) 126 { 148 127 return EOK; 149 128 } 150 129 151 static int ega_get_resolution(fbdev_t *dev, sysarg_t *width, sysarg_t *height) 152 { 153 *width = ega.width; 154 *height = ega.height; 155 return EOK; 156 } 157 158 static void ega_font_metrics(fbdev_t *dev, sysarg_t width, sysarg_t height, 159 sysarg_t *cols, sysarg_t *rows) 160 { 161 *cols = width; 162 *rows = height; 163 } 164 165 static int ega_vp_create(fbdev_t *dev, fbvp_t *vp) 166 { 167 vp->attrs.type = CHAR_ATTR_STYLE; 168 vp->attrs.val.style = STYLE_NORMAL; 169 vp->data = NULL; 170 171 return EOK; 172 } 173 174 static void ega_vp_destroy(fbdev_t *dev, fbvp_t *vp) 175 { 176 /* No-op */ 177 } 178 179 static void ega_vp_clear(fbdev_t *dev, fbvp_t *vp) 180 { 181 for (sysarg_t row = 0; row < vp->rows; row++) { 182 for (sysarg_t col = 0; col < vp->cols; col++) { 183 charfield_t *field = 184 screenbuffer_field_at(vp->backbuf, col, row); 185 186 field->ch = 0; 187 field->attrs = vp->attrs; 188 189 draw_vp_char(vp, col, row); 190 } 191 } 192 } 193 194 static console_caps_t ega_vp_get_caps(fbdev_t *dev, fbvp_t *vp) 130 static void ega_get_dimensions(outdev_t *dev, sysarg_t *cols, sysarg_t *rows) 131 { 132 *cols = ega.cols; 133 *rows = ega.rows; 134 } 135 136 static console_caps_t ega_get_caps(outdev_t *dev) 195 137 { 196 138 return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED); 197 139 } 198 140 199 static void ega_ vp_cursor_update(fbdev_t *dev, fbvp_t *vp, sysarg_t prev_col,141 static void ega_cursor_update(outdev_t *dev, sysarg_t prev_col, 200 142 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) 201 143 { 202 144 /* Cursor position */ 203 uint16_t cursor = row * ega. width+ col;145 uint16_t cursor = row * ega.cols + col; 204 146 205 147 pio_write_8(EGA_IO_BASE, 0x0e); … … 220 162 } 221 163 222 static void ega_vp_char_update(fbdev_t *dev, fbvp_t *vp, sysarg_t col, 223 sysarg_t row) 224 { 225 draw_vp_char(vp, col, row); 226 } 227 228 static fbdev_ops_t ega_ops = { 164 static void ega_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) 165 { 166 charfield_t *field = 167 chargrid_charfield_at(dev->backbuf, col, row); 168 169 draw_char(field, col, row); 170 } 171 172 static outdev_ops_t ega_ops = { 229 173 .yield = ega_yield, 230 174 .claim = ega_claim, 231 .get_resolution = ega_get_resolution, 232 .font_metrics = ega_font_metrics, 233 .vp_create = ega_vp_create, 234 .vp_destroy = ega_vp_destroy, 235 .vp_clear = ega_vp_clear, 236 .vp_get_caps = ega_vp_get_caps, 237 .vp_cursor_update = ega_vp_cursor_update, 238 .vp_char_update = ega_vp_char_update 175 .get_dimensions = ega_get_dimensions, 176 .get_caps = ega_get_caps, 177 .cursor_update = ega_cursor_update, 178 .char_update = ega_char_update 239 179 }; 240 180 … … 262 202 return rc; 263 203 264 sysarg_t width; 265 rc = sysinfo_get_value("fb.width", &width); 266 if (rc != EOK) 267 return rc; 268 269 sysarg_t height; 270 rc = sysinfo_get_value("fb.height", &height); 271 if (rc != EOK) 272 return rc; 273 274 rc = iospace_enable(task_get_id(), (void *) EGA_IO_BASE, EGA_IO_SIZE); 275 if (rc != EOK) 276 return rc; 277 278 ega.width = width; 279 ega.height = height; 280 281 ega.size = (width * height) << 1; 204 rc = sysinfo_get_value("fb.width", &ega.cols); 205 if (rc != EOK) 206 return rc; 207 208 rc = sysinfo_get_value("fb.height", &ega.rows); 209 if (rc != EOK) 210 return rc; 211 212 rc = pio_enable((void*)EGA_IO_BASE, EGA_IO_SIZE, NULL); 213 if (rc != EOK) 214 return rc; 215 216 ega.size = (ega.cols * ega.rows) << 1; 282 217 283 218 rc = physmem_map((void *) paddr, … … 300 235 } 301 236 302 ega.backbuf = NULL; 303 304 fbdev_t *dev = fbdev_register(&ega_ops, (void *) &ega); 237 outdev_t *dev = outdev_register(&ega_ops, (void *) &ega); 305 238 if (dev == NULL) { 306 239 as_area_destroy(ega.addr); … … 311 244 } 312 245 313 /** 314 * @} 315 */ 246 /** @} 247 */ -
uspace/srv/hid/output/port/ega.h
r80445cf r4c53333 30 30 */ 31 31 32 #ifndef FB_PORT_EGA_H_33 #define FB_PORT_EGA_H_32 #ifndef OUTPUT_PORT_EGA_H_ 33 #define OUTPUT_PORT_EGA_H_ 34 34 35 35 extern int ega_init(void); -
uspace/srv/hid/output/port/kchar.c
r80445cf r4c53333 33 33 #include <sys/types.h> 34 34 #include <errno.h> 35 #include <str.h> 35 36 #include <sysinfo.h> 36 37 #include <ddi.h> 38 #include <align.h> 37 39 #include <as.h> 38 #include <align.h>39 40 #include "../ctl/serial.h" 40 41 #include "kchar.h" -
uspace/srv/hid/output/port/kchar.h
r80445cf r4c53333 31 31 */ 32 32 33 #ifndef FB_PORT_KCHAR_H_34 #define FB_PORT_KCHAR_H_33 #ifndef OUTPUT_PORT_KCHAR_H_ 34 #define OUTPUT_PORT_KCHAR_H_ 35 35 36 36 extern int kchar_init(void); -
uspace/srv/hid/output/port/niagara.c
r80445cf r4c53333 38 38 #include <as.h> 39 39 #include <align.h> 40 #include <str.h> 40 41 #include "../ctl/serial.h" 41 42 #include "niagara.h" -
uspace/srv/hid/output/port/niagara.h
r80445cf r4c53333 30 30 */ 31 31 32 #ifndef FB_PORT_NIAGARA_H_33 #define FB_PORT_NIAGARA_H_32 #ifndef OUTPUT_PORT_NIAGARA_H_ 33 #define OUTPUT_PORT_NIAGARA_H_ 34 34 35 35 extern int niagara_init(void); … … 37 37 #endif 38 38 39 /** 40 * @} 39 /** @} 41 40 */ -
uspace/srv/hid/output/port/ski.h
r80445cf r4c53333 27 27 */ 28 28 29 /** @file 29 /** @addtogroup console 30 * @{ 31 */ 32 /** 33 * @file 30 34 */ 31 35 32 #ifndef FB_PORT_SKI_H_33 #define FB_PORT_SKI_H_36 #ifndef OUTPUT_PORT_SKI_H_ 37 #define OUTPUT_PORT_SKI_H_ 34 38 35 39 extern int ski_init(void); -
uspace/srv/hid/output/proto/vt100.c
r80445cf r4c53333 32 32 #include <sys/types.h> 33 33 #include <inttypes.h> 34 #include <errno.h> 34 35 #include <stdio.h> 36 #include <unistd.h> 37 #include <malloc.h> 35 38 #include <io/color.h> 36 #include <malloc.h>37 #include <errno.h>38 39 #include "vt100.h" 39 40 40 41 #define MAX_CONTROL 20 41 42 #define BACKBUF_POS(state, x, y) ((y) * ((state)->width) + (x))43 44 struct vt100_state {45 vt100_putchar_t putchar;46 vt100_control_puts_t control_puts;47 48 sysarg_t width;49 sysarg_t height;50 51 sysarg_t cur_col;52 sysarg_t cur_row;53 54 char_attrs_t cur_attrs;55 56 charfield_t backbuf[];57 };58 42 59 43 typedef enum { … … 154 138 } 155 139 156 vt100_state_t *vt100_state_create(sysarg_t width, sysarg_t height,140 vt100_state_t *vt100_state_create(sysarg_t cols, sysarg_t rows, 157 141 vt100_putchar_t putchar_fn, vt100_control_puts_t control_puts_fn) 158 142 { 159 size_t sz = width * height * sizeof(charfield_t);160 161 143 vt100_state_t *state = 162 malloc(sizeof(vt100_state_t) + sz);144 malloc(sizeof(vt100_state_t)); 163 145 if (state == NULL) 164 146 return NULL; … … 167 149 state->control_puts = control_puts_fn; 168 150 169 state-> width = width;170 state-> height = height;151 state->cols = cols; 152 state->rows = rows; 171 153 172 154 state->cur_col = (sysarg_t) -1; … … 175 157 state->cur_attrs.type = CHAR_ATTR_STYLE; 176 158 state->cur_attrs.val.style = STYLE_NORMAL; 177 178 memset(state->backbuf, 0, sz);179 159 180 160 /* Initialize graphic rendition attributes */ … … 183 163 vt100_sgr(state, SGR_BGCOLOR + CI_WHITE); 184 164 state->control_puts("\033[2J"); 165 state->control_puts("\033[?25l"); 185 166 186 167 return state; 187 168 } 188 169 189 void vt100_get_resolution(vt100_state_t *state, sysarg_t *width, 190 sysarg_t *height) 191 { 192 *width = state->width; 193 *height = state->height; 170 void vt100_state_destroy(vt100_state_t *state) 171 { 172 free(state); 173 } 174 175 void vt100_get_dimensions(vt100_state_t *state, sysarg_t *cols, 176 sysarg_t *rows) 177 { 178 *cols = state->cols; 179 *rows = state->rows; 194 180 } 195 181 … … 201 187 int vt100_claim(vt100_state_t *state) 202 188 { 203 for (sysarg_t row = 0; row < state->height; row++) {204 vt100_set_pos(state, 0, row);205 for (sysarg_t col = 0; col < state->width; col++) {206 charfield_t *field = state->backbuf +207 BACKBUF_POS(state, col, row);208 vt100_set_sgr(state, field->attrs);209 state->putchar(field->ch);210 }211 }212 213 vt100_set_pos(state, state->cur_col, state->cur_row);214 vt100_set_sgr(state, state->cur_attrs);215 216 189 return EOK; 217 190 } 218 191 219 void vt100_putchar(vt100_state_t *state, wchar_t ch)220 {221 charfield_t *field = state->backbuf +222 BACKBUF_POS(state, state->cur_col, state->cur_row);223 field->ch = ch;224 field->attrs = state->cur_attrs;225 226 state->putchar(ch);227 state->cur_col++;228 229 if (state->cur_col >= state->width) {230 state->cur_row += state->cur_col / state->width;231 state->cur_col %= state->width;232 }233 }234 235 void vt100_set_attr(vt100_state_t *state, char_attrs_t attrs)236 {237 if (!attrs_same(state->cur_attrs, attrs)) {238 vt100_set_sgr(state, attrs);239 state->cur_attrs = attrs;240 }241 }242 243 192 void vt100_goto(vt100_state_t *state, sysarg_t col, sysarg_t row) 244 193 { 245 if ((col >= state-> width) || (row >= state->height))194 if ((col >= state->cols) || (row >= state->rows)) 246 195 return; 247 196 … … 253 202 } 254 203 204 void vt100_set_attr(vt100_state_t *state, char_attrs_t attrs) 205 { 206 if (!attrs_same(state->cur_attrs, attrs)) { 207 vt100_set_sgr(state, attrs); 208 state->cur_attrs = attrs; 209 } 210 } 211 255 212 void vt100_cursor_visibility(vt100_state_t *state, bool visible) 256 213 { … … 261 218 } 262 219 220 void vt100_putchar(vt100_state_t *state, wchar_t ch) 221 { 222 state->putchar(ch == 0 ? ' ' : ch); 223 state->cur_col++; 224 225 if (state->cur_col >= state->cols) { 226 state->cur_row += state->cur_col / state->cols; 227 state->cur_col %= state->cols; 228 } 229 } 230 263 231 /** @} 264 232 */ -
uspace/srv/hid/output/proto/vt100.h
r80445cf r4c53333 30 30 */ 31 31 32 #ifndef FB_PROTO_VT100_H_33 #define FB_PROTO_VT100_H_32 #ifndef OUTPUT_PROTO_VT100_H_ 33 #define OUTPUT_PROTO_VT100_H_ 34 34 35 35 #include <sys/types.h> 36 #include < screenbuffer.h>36 #include <io/charfield.h> 37 37 38 38 typedef void (* vt100_putchar_t)(wchar_t ch); 39 39 typedef void (* vt100_control_puts_t)(const char *str); 40 40 41 /** Forward declaration */ 42 struct vt100_state; 43 typedef struct vt100_state vt100_state_t; 41 typedef struct { 42 sysarg_t cols; 43 sysarg_t rows; 44 45 sysarg_t cur_col; 46 sysarg_t cur_row; 47 char_attrs_t cur_attrs; 48 49 vt100_putchar_t putchar; 50 vt100_control_puts_t control_puts; 51 } vt100_state_t; 44 52 45 53 extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putchar_t, 46 54 vt100_control_puts_t); 47 extern void vt100_get_resolution(vt100_state_t *, sysarg_t *, sysarg_t *); 55 extern void vt100_state_destroy(vt100_state_t *); 56 48 57 extern int vt100_yield(vt100_state_t *); 49 58 extern int vt100_claim(vt100_state_t *); 59 extern void vt100_get_dimensions(vt100_state_t *, sysarg_t *, sysarg_t *); 50 60 61 extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t); 62 extern void vt100_set_attr(vt100_state_t *, char_attrs_t); 63 extern void vt100_cursor_visibility(vt100_state_t *, bool); 51 64 extern void vt100_putchar(vt100_state_t *, wchar_t); 52 53 extern void vt100_set_attr(vt100_state_t *, char_attrs_t);54 extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t);55 extern void vt100_cursor_visibility(vt100_state_t *, bool);56 65 57 66 #endif -
uspace/srv/hid/remcons/remcons.c
r80445cf r4c53333 34 34 35 35 #include <async.h> 36 #include <errno.h> 37 #include <io/con_srv.h> 36 38 #include <stdio.h> 37 #include <adt/prodcons.h> 38 #include <ipc/input.h> 39 #include <ipc/console.h> 40 #include <ipc/vfs.h> 41 #include <errno.h> 39 #include <stdlib.h> 42 40 #include <str_error.h> 43 41 #include <loc.h> … … 45 43 #include <io/keycode.h> 46 44 #include <align.h> 47 #include <malloc.h>48 #include <as.h>49 45 #include <fibril_synch.h> 50 46 #include <task.h> … … 71 67 TELNET_IAC, TELNET_WONT, TELNET_LINEMODE 72 68 }; 69 73 70 static const size_t telnet_force_character_mode_command_count = 74 71 sizeof(telnet_force_character_mode_command) / sizeof(telnet_cmd_t); 75 72 76 77 /** Handling client requests (VFS and console interface). 78 * 79 * @param user Telnet user the requests belong to. 80 */ 81 static void client_connection_message_loop(telnet_user_t *user) 82 { 83 while (true) { 84 ipc_call_t call; 85 ipc_callid_t callid = 0; 86 87 /* 88 * The getterm task might terminate while we are here, 89 * waiting for a call. Also, the socket might be closed 90 * meanwhile. 91 * We want to detect this situation early, so we use a 92 * timeout variant of async_get_call(). 93 */ 94 while (callid == 0) { 95 callid = async_get_call_timeout(&call, 1000); 96 97 if (telnet_user_is_zombie(user)) { 98 if (callid != 0) { 99 async_answer_0(callid, EINTR); 100 } 101 return; 102 } 103 } 104 105 if (!IPC_GET_IMETHOD(call)) { 106 return; 107 } 108 109 switch (IPC_GET_IMETHOD(call)) { 110 case CONSOLE_GET_SIZE: 111 async_answer_2(callid, EOK, 100, 1); 112 break; 113 case CONSOLE_GET_POS: 114 fibril_mutex_lock(&user->guard); 115 async_answer_2(callid, EOK, user->cursor_x, 0); 116 fibril_mutex_unlock(&user->guard); 117 break; 118 case CONSOLE_GET_EVENT: { 119 kbd_event_t event; 120 int rc = telnet_user_get_next_keyboard_event(user, &event); 121 if (rc != EOK) { 122 /* Silently ignore. */ 123 async_answer_0(callid, EOK); 124 break; 125 } 126 async_answer_4(callid, EOK, event.type, event.key, event.mods, event.c); 127 break; 128 } 129 case CONSOLE_GOTO: { 130 int new_x = IPC_GET_ARG1(call); 131 telnet_user_update_cursor_x(user, new_x); 132 async_answer_0(callid, ENOTSUP); 133 break; 134 } 135 case VFS_OUT_READ: 136 async_answer_0(callid, ENOTSUP); 137 break; 138 case VFS_OUT_WRITE: { 139 uint8_t *buf; 140 size_t size; 141 int rc = async_data_write_accept((void **)&buf, false, 0, 0, 0, &size); 142 143 if (rc != EOK) { 144 async_answer_0(callid, rc); 145 break; 146 } 147 148 rc = telnet_user_send_data(user, buf, size); 149 free(buf); 150 151 if (rc != EOK) { 152 async_answer_0(callid, rc); 153 break; 154 } 155 156 async_answer_1(callid, EOK, size); 157 break; 158 } 159 case VFS_OUT_SYNC: 160 async_answer_0(callid, EOK); 161 break; 162 case CONSOLE_CLEAR: 163 async_answer_0(callid, EOK); 164 break; 165 166 case CONSOLE_GET_COLOR_CAP: 167 async_answer_1(callid, EOK, CONSOLE_CAP_NONE); 168 break; 169 case CONSOLE_SET_STYLE: 170 async_answer_0(callid, ENOTSUP); 171 break; 172 case CONSOLE_SET_COLOR: 173 async_answer_0(callid, ENOTSUP); 174 break; 175 case CONSOLE_SET_RGB_COLOR: 176 async_answer_0(callid, ENOTSUP); 177 break; 178 179 case CONSOLE_CURSOR_VISIBILITY: 180 async_answer_0(callid, ENOTSUP); 181 break; 182 183 default: 184 async_answer_0(callid, EINVAL); 185 break; 186 } 187 } 73 static int remcons_open(con_srvs_t *, con_srv_t *); 74 static int remcons_close(con_srv_t *); 75 static int remcons_write(con_srv_t *, void *, size_t); 76 static void remcons_sync(con_srv_t *); 77 static void remcons_clear(con_srv_t *); 78 static void remcons_set_pos(con_srv_t *, sysarg_t col, sysarg_t row); 79 static int remcons_get_pos(con_srv_t *, sysarg_t *, sysarg_t *); 80 static int remcons_get_size(con_srv_t *, sysarg_t *, sysarg_t *); 81 static int remcons_get_color_cap(con_srv_t *, console_caps_t *); 82 static int remcons_get_event(con_srv_t *, cons_event_t *); 83 84 static con_ops_t con_ops = { 85 .open = remcons_open, 86 .close = remcons_close, 87 .read = NULL, 88 .write = remcons_write, 89 .sync = remcons_sync, 90 .clear = remcons_clear, 91 .set_pos = remcons_set_pos, 92 .get_pos = remcons_get_pos, 93 .get_size = remcons_get_size, 94 .get_color_cap = remcons_get_color_cap, 95 .set_style = NULL, 96 .set_color = NULL, 97 .set_rgb_color = NULL, 98 .set_cursor_visibility = NULL, 99 .get_event = remcons_get_event 100 }; 101 102 static telnet_user_t *srv_to_user(con_srv_t *srv) 103 { 104 return srv->srvs->sarg; 105 } 106 107 static int remcons_open(con_srvs_t *srvs, con_srv_t *srv) 108 { 109 telnet_user_t *user = srv_to_user(srv); 110 111 telnet_user_log(user, "New client connected (%p).", srv); 112 113 /* Force character mode. */ 114 send(user->socket, (void *)telnet_force_character_mode_command, 115 telnet_force_character_mode_command_count, 0); 116 117 return EOK; 118 } 119 120 static int remcons_close(con_srv_t *srv) 121 { 122 telnet_user_t *user = srv_to_user(srv); 123 124 telnet_user_notify_client_disconnected(user); 125 telnet_user_log(user, "Client disconnected (%p).", srv); 126 127 return EOK; 128 } 129 130 static int remcons_write(con_srv_t *srv, void *data, size_t size) 131 { 132 telnet_user_t *user = srv_to_user(srv); 133 int rc; 134 135 rc = telnet_user_send_data(user, data, size); 136 if (rc != EOK) 137 return rc; 138 139 return size; 140 } 141 142 static void remcons_sync(con_srv_t *srv) 143 { 144 (void) srv; 145 } 146 147 static void remcons_clear(con_srv_t *srv) 148 { 149 (void) srv; 150 } 151 152 static void remcons_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row) 153 { 154 telnet_user_t *user = srv_to_user(srv); 155 156 telnet_user_update_cursor_x(user, col); 157 } 158 159 static int remcons_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row) 160 { 161 telnet_user_t *user = srv_to_user(srv); 162 163 *col = user->cursor_x; 164 *row = 0; 165 166 return EOK; 167 } 168 169 static int remcons_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows) 170 { 171 (void) srv; 172 173 *cols = 100; 174 *rows = 1; 175 176 return EOK; 177 } 178 179 static int remcons_get_color_cap(con_srv_t *srv, console_caps_t *ccaps) 180 { 181 (void) srv; 182 *ccaps = CONSOLE_CAP_NONE; 183 184 return EOK; 185 } 186 187 static int remcons_get_event(con_srv_t *srv, cons_event_t *event) 188 { 189 telnet_user_t *user = srv_to_user(srv); 190 kbd_event_t kevent; 191 int rc; 192 193 rc = telnet_user_get_next_keyboard_event(user, &kevent); 194 if (rc != EOK) { 195 /* XXX What? */ 196 memset(event, 0, sizeof(*event)); 197 return EOK; 198 } 199 200 event->type = CEV_KEY; 201 event->ev.key = kevent; 202 203 return EOK; 188 204 } 189 205 … … 197 213 return; 198 214 } 199 async_answer_0(iid, EOK);200 201 telnet_user_log(user, "New client connected (%" PRIxn").", iid);202 203 /* Force character mode. */204 send(user->socket, (void *)telnet_force_character_mode_command,205 telnet_force_character_mode_command_count, 0);206 215 207 216 /* Handle messages. */ 208 client_connection_message_loop(user); 209 210 telnet_user_notify_client_disconnected(user); 211 telnet_user_log(user, "Client disconnected (%" PRIxn").", iid); 217 con_conn(iid, icall, &user->srvs); 212 218 } 213 219 … … 231 237 fibril_mutex_lock(&user->guard); 232 238 user->task_finished = true; 239 user->srvs.aborted = true; 233 240 fibril_condvar_signal(&user->refcount_cv); 234 241 fibril_mutex_unlock(&user->guard); … … 250 257 fibril_mutex_lock(&user->guard); 251 258 user->task_finished = true; 259 user->srvs.aborted = true; 252 260 fibril_condvar_signal(&user->refcount_cv); 253 261 fibril_mutex_unlock(&user->guard); … … 272 280 static int network_user_fibril(void *arg) 273 281 { 274 int rc;275 282 telnet_user_t *user = arg; 276 283 277 rc = loc_service_register(user->service_name, &user->service_id);284 int rc = loc_service_register(user->service_name, &user->service_id); 278 285 if (rc != EOK) { 279 286 telnet_user_error(user, "Unable to register %s with loc: %s.", … … 284 291 telnet_user_log(user, "Service %s registerd with id %" PRIun ".", 285 292 user->service_name, user->service_id); 286 293 287 294 fid_t spawn_fibril = fibril_create(spawn_task_fibril, user); 288 295 assert(spawn_fibril); 289 296 fibril_add_ready(spawn_fibril); 290 297 291 298 /* Wait for all clients to exit. */ 292 299 fibril_mutex_lock(&user->guard); … … 295 302 closesocket(user->socket); 296 303 user->socket_closed = true; 304 user->srvs.aborted = true; 297 305 continue; 298 306 } else if (user->socket_closed) { … … 304 312 } 305 313 fibril_mutex_unlock(&user->guard); 306 314 307 315 rc = loc_service_unregister(user->service_id); 308 316 if (rc != EOK) { … … 324 332 async_set_client_connection(client_connection); 325 333 int rc = loc_server_register(NAME); 326 if (rc < 0) { 327 fprintf(stderr, NAME ": Unable to register server: %s.\n", 328 str_error(rc)); 329 return 1; 330 } 331 334 if (rc != EOK) { 335 fprintf(stderr, "%s: Unable to register server\n", NAME); 336 return rc; 337 } 338 332 339 struct sockaddr_in addr; 333 340 334 341 addr.sin_family = AF_INET; 335 342 addr.sin_port = htons(port); 336 343 337 344 rc = inet_pton(AF_INET, "127.0.0.1", (void *) 338 345 &addr.sin_addr.s_addr); … … 364 371 365 372 printf("%s: HelenOS Remote console service\n", NAME); 373 task_retval(0); 366 374 367 375 while (true) { … … 380 388 assert(user); 381 389 390 con_srvs_init(&user->srvs); 391 user->srvs.ops = &con_ops; 392 user->srvs.sarg = user; 393 user->srvs.abort_timeout = 1000; 394 395 telnet_user_add(user); 396 382 397 fid_t fid = fibril_create(network_user_fibril, user); 383 398 assert(fid); -
uspace/srv/hid/remcons/telnet.h
r80445cf r4c53333 57 57 #define TELNET_LINEMODE 34 58 58 59 60 59 #endif 61 60 -
uspace/srv/hid/remcons/user.c
r80445cf r4c53333 35 35 #include <stdio.h> 36 36 #include <adt/prodcons.h> 37 #include <ipc/input.h>38 #include <ipc/console.h>39 #include <ipc/vfs.h>40 37 #include <errno.h> 41 38 #include <str_error.h> … … 95 92 user->locsrv_connection_count = 0; 96 93 97 94 user->cursor_x = 0; 95 96 return user; 97 } 98 99 void telnet_user_add(telnet_user_t *user) 100 { 98 101 fibril_mutex_lock(&users_guard); 99 102 list_append(&user->link, &users); 100 103 fibril_mutex_unlock(&users_guard); 101 102 user->cursor_x = 0;103 104 return user;105 104 } 106 105 … … 199 198 if ((recv_length == 0) || (recv_length == ENOTCONN)) { 200 199 user->socket_closed = true; 200 user->srvs.aborted = true; 201 201 return ENOENT; 202 202 } -
uspace/srv/hid/remcons/user.h
r80445cf r4c53333 36 36 #define TELNET_USER_H_ 37 37 38 #include <adt/prodcons.h> 38 39 #include <fibril_synch.h> 39 40 #include <inttypes.h> 41 #include <io/con_srv.h> 40 42 #include "remcons.h" 41 43 … … 55 57 /** Path name of the service. */ 56 58 char *service_name; 59 /** Console service setup */ 60 con_srvs_t srvs; 57 61 58 62 /** Producer-consumer of kbd_event_t. */ … … 76 80 } telnet_user_t; 77 81 78 telnet_user_t *telnet_user_create(int socket); 79 void telnet_user_destroy(telnet_user_t *user); 80 telnet_user_t *telnet_user_get_for_client_connection(service_id_t id); 81 bool telnet_user_is_zombie(telnet_user_t *user); 82 void telnet_user_notify_client_disconnected(telnet_user_t *user); 83 int telnet_user_get_next_keyboard_event(telnet_user_t *user, kbd_event_t *event); 84 int telnet_user_send_data(telnet_user_t *user, uint8_t *data, size_t size); 85 void telnet_user_update_cursor_x(telnet_user_t *user, int new_x); 82 extern telnet_user_t *telnet_user_create(int); 83 extern void telnet_user_add(telnet_user_t *); 84 extern void telnet_user_destroy(telnet_user_t *); 85 extern telnet_user_t *telnet_user_get_for_client_connection(service_id_t); 86 extern bool telnet_user_is_zombie(telnet_user_t *); 87 extern void telnet_user_notify_client_disconnected(telnet_user_t *); 88 extern int telnet_user_get_next_keyboard_event(telnet_user_t *, kbd_event_t *); 89 extern int telnet_user_send_data(telnet_user_t *, uint8_t *, size_t); 90 extern void telnet_user_update_cursor_x(telnet_user_t *, int); 86 91 87 92 /** Print informational message about connected user. */ 88 93 #ifdef CONFIG_DEBUG 89 94 #define telnet_user_log(user, fmt, ...) \ 90 printf(NAME " [console %d (%d)]: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__) 95 printf(NAME " [console %d (%d)]: " fmt "\n", \ 96 user->id, (int) user->service_id, ##__VA_ARGS__) 91 97 #else 92 #define telnet_user_log(user, fmt, ...) ( void)098 #define telnet_user_log(user, fmt, ...) ((void) 0) 93 99 #endif 94 100 95 101 /** Print error message associated with connected user. */ 96 102 #define telnet_user_error(user, fmt, ...) \ 97 fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", user->id, (int) user->service_id, ##__VA_ARGS__) 103 fprintf(stderr, NAME " [console %d (%d)]: ERROR: " fmt "\n", \ 104 user->id, (int) user->service_id, ##__VA_ARGS__) 98 105 99 106 #endif -
uspace/srv/hid/s3c24xx_ts/Makefile
r80445cf r4c53333 29 29 USPACE_PREFIX = ../../.. 30 30 31 # Need to use short name because of FAT 8+3 limit 32 BINARY = s3c24ts 31 BINARY = s3c24xx_ts 33 32 34 33 SOURCES = \ -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
r80445cf r4c53333 38 38 39 39 #include <ddi.h> 40 #include <libarch/ddi.h>41 40 #include <loc.h> 42 41 #include <io/console.h> … … 52 51 #include "s3c24xx_ts.h" 53 52 54 #define NAME "s3c24 ser"53 #define NAME "s3c24xx_ts" 55 54 #define NAMESPACE "hid" 56 55 … … 84 83 int main(int argc, char *argv[]) 85 84 { 86 int rc; 87 88 printf(NAME ": S3C24xx touchscreen driver\n"); 85 printf("%s: S3C24xx touchscreen driver\n", NAME); 89 86 90 87 async_set_client_connection(s3c24xx_ts_connection); 91 rc = loc_server_register(NAME);92 if (rc < 0) {93 printf( NAME ": Unable to register driver.\n");94 return -1;88 int rc = loc_server_register(NAME); 89 if (rc != EOK) { 90 printf("%s: Unable to register driver.\n", NAME); 91 return rc; 95 92 } 96 93
Note:
See TracChangeset
for help on using the changeset viewer.
