Changeset 7cfe5c0 in mainline for uspace/srv/hid
- Timestamp:
- 2012-08-20T19:16:24Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6b99156
- Parents:
- b9cb911 (diff), 01e397ac (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:
-
- 11 added
- 12 deleted
- 24 edited
- 31 moved
-
compositor/Makefile (added)
-
compositor/compositor.c (added)
-
compositor/compositor.h (added)
-
compositor/gfx/helenos.tga (moved) (moved from uspace/srv/hid/console/gfx/helenos.tga )
-
compositor/gfx/nameic.tga (moved) (moved from uspace/srv/hid/console/gfx/nameic.tga )
-
console/Makefile (modified) (1 diff)
-
console/console.c (modified) (31 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)
-
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 (modified) (1 diff)
-
input/ctl/kbdev.c (modified) (1 diff)
-
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 ) (2 diffs)
-
input/gsp.h (moved) (moved from uspace/srv/hid/input/include/gsp.h )
-
input/input.c (moved) (moved from uspace/srv/hid/input/generic/input.c ) (5 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 ) (1 diff)
-
input/kbd_port.h (moved) (moved from uspace/srv/hid/input/include/kbd_port.h )
-
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 )
-
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) (1 diff)
-
input/port/adb_mouse.c (modified) (1 diff)
-
input/port/chardev.c (modified) (1 diff)
-
input/port/gxemul.c (modified) (1 diff)
-
input/port/msim.c (modified) (1 diff)
-
input/port/niagara.c (modified) (3 diffs)
-
input/port/ns16550.c (modified) (1 diff)
-
input/port/pl050.c (modified) (1 diff)
-
input/port/ski.c (modified) (1 diff)
-
input/proto/adb.c (modified) (1 diff)
-
input/proto/mousedev.c (modified) (2 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) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/Makefile
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 36 36 #include <stdio.h> 37 37 #include <adt/prodcons.h> 38 #include <i pc/input.h>38 #include <io/input.h> 39 39 #include <ipc/console.h> 40 40 #include <ipc/vfs.h> … … 43 43 #include <loc.h> 44 44 #include <event.h> 45 #include <io/kbd_event.h> 45 46 #include <io/keycode.h> 46 #include < screenbuffer.h>47 #include < fb.h>48 #include <i mgmap.h>47 #include <io/chargrid.h> 48 #include <io/console.h> 49 #include <io/output.h> 49 50 #include <align.h> 50 51 #include <malloc.h> 51 52 #include <as.h> 52 53 #include <fibril_synch.h> 53 #include "images.h"54 54 #include "console.h" 55 55 … … 57 57 #define NAMESPACE "term" 58 58 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; 77 78 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1) 59 #define UTF8_CHAR_BUFFER_SIZE (STR_BOUNDS(1) + 1) 79 60 80 61 typedef struct { 81 atomic_t refcnt; /**< Connection reference count */ 82 prodcons_t input_pc; /**< Incoming keyboard events */ 83 char char_remains[UTF8_CHAR_BUFFER_SIZE]; /**< Not yet sent bytes of last char event. */ 84 size_t char_remains_len; /**< Number of not yet sent bytes. */ 85 86 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ 87 88 size_t index; /**< Console index */ 89 console_state_t state; /**< Console state */ 90 service_id_t dsid; /**< Service handle */ 91 92 vp_handle_t state_vp; /**< State icon viewport */ 93 sysarg_t cols; /**< Number of columns */ 94 sysarg_t rows; /**< Number of rows */ 95 console_caps_t ccaps; /**< Console capabilities */ 96 97 screenbuffer_t *frontbuf; /**< Front buffer */ 98 frontbuf_handle_t fbid; /**< Front buffer handle */ 62 atomic_t refcnt; /**< Connection reference count */ 63 prodcons_t input_pc; /**< Incoming keyboard events */ 64 65 /** 66 * Not yet sent bytes of last char event. 67 */ 68 char char_remains[UTF8_CHAR_BUFFER_SIZE]; 69 size_t char_remains_len; /**< Number of not yet sent bytes. */ 70 71 fibril_mutex_t mtx; /**< Lock protecting mutable fields */ 72 73 size_t index; /**< Console index */ 74 service_id_t dsid; /**< Service handle */ 75 76 sysarg_t cols; /**< Number of columns */ 77 sysarg_t rows; /**< Number of rows */ 78 console_caps_t ccaps; /**< Console capabilities */ 79 80 chargrid_t *frontbuf; /**< Front buffer */ 81 frontbuf_handle_t fbid; /**< Front buffer handle */ 99 82 } console_t; 100 83 101 typedef enum { 102 GRAPHICS_NONE = 0, 103 GRAPHICS_BASIC = 1, 104 GRAPHICS_FULL = 2 105 } graphics_state_t; 106 107 /** Current console state */ 108 static graphics_state_t graphics_state = GRAPHICS_NONE; 109 110 /** State icons */ 111 static imagemap_handle_t state_icons[CONS_LAST]; 112 113 /** Session to the input server */ 114 static async_sess_t *input_sess; 115 116 /** Session to the framebuffer server */ 117 static async_sess_t *fb_sess; 118 119 /** Framebuffer resolution */ 120 static sysarg_t xres; 121 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; 122 93 123 94 /** Array of data for virtual consoles */ … … 131 102 static console_t *kernel_console = &consoles[KERNEL_CONSOLE]; 132 103 133 static imgmap_t *logo_img; 134 static imgmap_t *nameic_img; 135 136 static imgmap_t *anim_1_img; 137 static imgmap_t *anim_2_img; 138 static imgmap_t *anim_3_img; 139 static imgmap_t *anim_4_img; 140 141 static imagemap_handle_t anim_1; 142 static imagemap_handle_t anim_2; 143 static imagemap_handle_t anim_3; 144 static imagemap_handle_t anim_4; 145 146 static sequence_handle_t anim_seq; 147 148 static imgmap_t *cons_data_img; 149 static imgmap_t *cons_dis_img; 150 static imgmap_t *cons_dis_sel_img; 151 static imgmap_t *cons_idle_img; 152 static imgmap_t *cons_kernel_img; 153 static imgmap_t *cons_sel_img; 154 155 static vp_handle_t logo_vp; 156 static imagemap_handle_t logo_handle; 157 158 static vp_handle_t nameic_vp; 159 static imagemap_handle_t nameic_handle; 160 161 static vp_handle_t screen_vp; 162 static vp_handle_t console_vp; 163 164 struct { 165 sysarg_t x; 166 sysarg_t y; 167 168 sysarg_t btn_x; 169 sysarg_t btn_y; 170 171 bool pressed; 172 } mouse; 173 174 static void cons_redraw_state(console_t *cons) 175 { 176 if (graphics_state == GRAPHICS_FULL) { 177 fibril_mutex_lock(&cons->mtx); 178 179 fb_vp_imagemap_damage(fb_sess, cons->state_vp, 180 state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT); 181 182 if ((cons->state != CONS_DISCONNECTED) && 183 (cons->state != CONS_KERNEL) && 184 (cons->state != CONS_DISCONNECTED_SELECTED)) { 185 char data[5]; 186 snprintf(data, 5, "%zu", cons->index + 1); 187 188 for (size_t i = 0; data[i] != 0; i++) 189 fb_vp_putchar(fb_sess, cons->state_vp, i + 2, 1, data[i]); 190 } 191 192 fibril_mutex_unlock(&cons->mtx); 193 } 194 } 195 196 static void cons_kernel_sequence_start(console_t *cons) 197 { 198 if (graphics_state == GRAPHICS_FULL) { 199 fibril_mutex_lock(&cons->mtx); 200 201 fb_vp_sequence_start(fb_sess, cons->state_vp, anim_seq); 202 fb_vp_imagemap_damage(fb_sess, cons->state_vp, 203 state_icons[cons->state], 0, 0, STATE_WIDTH, STATE_HEIGHT); 204 205 fibril_mutex_unlock(&cons->mtx); 206 } 207 } 208 209 static void cons_update_state(console_t *cons, console_state_t state) 210 { 211 bool update = false; 212 213 fibril_mutex_lock(&cons->mtx); 214 215 if (cons->state != state) { 216 cons->state = state; 217 update = true; 218 } 219 220 fibril_mutex_unlock(&cons->mtx); 221 222 if (update) 223 cons_redraw_state(cons); 224 } 225 226 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 void cons_update(console_t *cons) 227 117 { 228 118 fibril_mutex_lock(&switch_mtx); 229 230 if (cons != active_console) 231 cons_update_state(cons, CONS_DATA); 232 119 fibril_mutex_lock(&cons->mtx); 120 121 if ((cons == active_console) && (active_console != kernel_console)) { 122 output_update(output_sess, cons->fbid); 123 output_cursor_update(output_sess, cons->fbid); 124 } 125 126 fibril_mutex_unlock(&cons->mtx); 233 127 fibril_mutex_unlock(&switch_mtx); 234 128 } 235 129 236 static void cons_ notify_connect(console_t *cons)130 static void cons_update_cursor(console_t *cons) 237 131 { 238 132 fibril_mutex_lock(&switch_mtx); 239 240 if (cons == active_console)241 cons_update_state(cons, CONS_SELECTED);242 else243 cons_update_state(cons, CONS_IDLE);244 133 fibril_mutex_lock(&cons->mtx); 134 135 if ((cons == active_console) && (active_console != kernel_console)) 136 output_cursor_update(output_sess, cons->fbid); 137 138 fibril_mutex_unlock(&cons->mtx); 245 139 fibril_mutex_unlock(&switch_mtx); 246 140 } 247 141 248 static void cons_notify_disconnect(console_t *cons) 142 static void cons_clear(console_t *cons) 143 { 144 fibril_mutex_lock(&cons->mtx); 145 chargrid_clear(cons->frontbuf); 146 fibril_mutex_unlock(&cons->mtx); 147 148 cons_update(cons); 149 } 150 151 static void cons_damage(console_t *cons) 249 152 { 250 153 fibril_mutex_lock(&switch_mtx); 251 252 if (cons == active_console)253 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);254 else255 cons_update_state(cons, CONS_DISCONNECTED);256 257 fibril_mutex_unlock(&switch_mtx);258 }259 260 static void cons_update(console_t *cons)261 {262 fibril_mutex_lock(&switch_mtx);263 154 fibril_mutex_lock(&cons->mtx); 264 155 265 156 if ((cons == active_console) && (active_console != kernel_console)) { 266 fb_vp_update(fb_sess, console_vp, cons->fbid); 267 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 268 } 269 270 fibril_mutex_unlock(&cons->mtx); 271 fibril_mutex_unlock(&switch_mtx); 272 } 273 274 static void cons_update_cursor(console_t *cons) 275 { 276 fibril_mutex_lock(&switch_mtx); 277 fibril_mutex_lock(&cons->mtx); 278 279 if ((cons == active_console) && (active_console != kernel_console)) 280 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid); 281 282 fibril_mutex_unlock(&cons->mtx); 283 fibril_mutex_unlock(&switch_mtx); 284 } 285 286 static void cons_clear(console_t *cons) 287 { 288 fibril_mutex_lock(&cons->mtx); 289 screenbuffer_clear(cons->frontbuf); 290 fibril_mutex_unlock(&cons->mtx); 291 292 cons_update(cons); 293 } 294 295 static void cons_damage_all(console_t *cons) 296 { 297 fibril_mutex_lock(&switch_mtx); 298 fibril_mutex_lock(&cons->mtx); 299 300 if ((cons == active_console) && (active_console != kernel_console)) { 301 fb_vp_damage(fb_sess, console_vp, cons->fbid, 0, 0, cons->cols, 157 output_damage(output_sess, cons->fbid, 0, 0, cons->cols, 302 158 cons->rows); 303 fb_vp_cursor_update(fb_sess, console_vp, cons->fbid);159 output_cursor_update(output_sess, cons->fbid); 304 160 } 305 161 … … 318 174 319 175 if (cons == kernel_console) { 320 fb_yield(fb_sess);176 output_yield(output_sess); 321 177 if (!console_kcon()) { 322 fb_claim(fb_sess);178 output_claim(output_sess); 323 179 fibril_mutex_unlock(&switch_mtx); 324 180 return; … … 327 183 328 184 if (active_console == kernel_console) 329 fb_claim(fb_sess);185 output_claim(output_sess); 330 186 331 187 prev_console = active_console; 332 188 active_console = cons; 333 189 334 if (prev_console->state == CONS_DISCONNECTED_SELECTED)335 cons_update_state(prev_console, CONS_DISCONNECTED);336 else337 cons_update_state(prev_console, CONS_IDLE);338 339 if ((cons->state == CONS_DISCONNECTED) ||340 (cons->state == CONS_DISCONNECTED_SELECTED))341 cons_update_state(cons, CONS_DISCONNECTED_SELECTED);342 else343 cons_update_state(cons, CONS_SELECTED);344 345 190 fibril_mutex_unlock(&switch_mtx); 346 191 347 cons_damage _all(cons);192 cons_damage(cons); 348 193 } 349 194 … … 351 196 { 352 197 fibril_mutex_lock(&switch_mtx); 353 198 354 199 console_t *active_uspace = active_console; 355 if (active_uspace == kernel_console) {200 if (active_uspace == kernel_console) 356 201 active_uspace = prev_console; 357 }202 358 203 assert(active_uspace != kernel_console); 359 204 360 205 fibril_mutex_unlock(&switch_mtx); 361 206 362 207 return active_uspace; 363 208 } 364 209 365 static ssize_t limit(ssize_t val, ssize_t lo, ssize_t hi) 366 { 367 if (val > hi) 368 return hi; 369 370 if (val < lo) 371 return lo; 372 373 return val; 374 } 375 376 static void cons_mouse_move(sysarg_t dx, sysarg_t dy) 377 { 378 ssize_t sx = (ssize_t) dx; 379 ssize_t sy = (ssize_t) dy; 380 381 mouse.x = limit(mouse.x + sx, 0, xres); 382 mouse.y = limit(mouse.y + sy, 0, yres); 383 384 fb_pointer_update(fb_sess, mouse.x, mouse.y, true); 385 } 386 387 static console_t *cons_find_icon(sysarg_t x, sysarg_t y) 388 { 389 sysarg_t status_start = 390 STATE_START + (xres - 800) / 2 + CONSOLE_MARGIN; 391 392 if ((y < STATE_TOP) || (y >= STATE_TOP + STATE_HEIGHT)) 393 return NULL; 394 395 if (x < status_start) 396 return NULL; 397 398 if (x >= status_start + (STATE_WIDTH + STATE_SPACE) * CONSOLE_COUNT) 399 return NULL; 400 401 if (((x - status_start) % (STATE_WIDTH + STATE_SPACE)) >= STATE_WIDTH) 402 return NULL; 403 404 sysarg_t btn = (x - status_start) / (STATE_WIDTH + STATE_SPACE); 405 406 if (btn < CONSOLE_COUNT) 407 return consoles + btn; 408 409 return NULL; 410 } 411 412 /** Handle mouse click 413 * 414 * @param state Button state (true - pressed, false - depressed) 415 * 416 */ 417 static console_t *cons_mouse_button(bool state) 418 { 419 if (graphics_state != GRAPHICS_FULL) 420 return NULL; 421 422 if (state) { 423 console_t *cons = cons_find_icon(mouse.x, mouse.y); 424 if (cons != NULL) { 425 mouse.btn_x = mouse.x; 426 mouse.btn_y = mouse.y; 427 mouse.pressed = true; 428 } 429 430 return NULL; 431 } 432 433 if ((!state) && (!mouse.pressed)) 434 return NULL; 435 436 console_t *cons = cons_find_icon(mouse.x, mouse.y); 437 if (cons == cons_find_icon(mouse.btn_x, mouse.btn_y)) 438 return cons; 439 440 mouse.pressed = false; 441 return NULL; 442 } 443 444 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 445 { 446 /* Ignore parameters, the connection is already opened */ 447 while (true) { 448 ipc_call_t call; 449 ipc_callid_t callid = async_get_call(&call); 450 451 if (!IPC_GET_IMETHOD(call)) { 452 /* TODO: Handle hangup */ 453 async_hangup(input_sess); 454 return; 455 } 456 457 kbd_event_type_t type; 458 keycode_t key; 459 keymod_t mods; 460 wchar_t c; 461 462 switch (IPC_GET_IMETHOD(call)) { 463 case INPUT_EVENT_KEY: 464 type = IPC_GET_ARG1(call); 465 key = IPC_GET_ARG2(call); 466 mods = IPC_GET_ARG3(call); 467 c = IPC_GET_ARG4(call); 468 469 if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) && 470 ((mods & KM_CTRL) == 0)) 471 cons_switch(&consoles[key - KC_F1]); 472 else { 473 /* Got key press/release event */ 474 kbd_event_t *event = 475 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 476 if (event == NULL) { 477 async_answer_0(callid, ENOMEM); 478 break; 479 } 480 481 link_initialize(&event->link); 482 event->type = type; 483 event->key = key; 484 event->mods = mods; 485 event->c = c; 486 487 /* 488 * Kernel console does not read events 489 * from us, so we will redirect them 490 * to the (last) active userspace console 491 * if necessary. 492 */ 493 console_t *target_console = cons_get_active_uspace(); 494 495 prodcons_produce(&target_console->input_pc, 496 &event->link); 497 } 498 499 async_answer_0(callid, EOK); 500 break; 501 case INPUT_EVENT_MOVE: 502 cons_mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 503 async_answer_0(callid, EOK); 504 break; 505 case INPUT_EVENT_BUTTON: 506 /* Got pointer button press/release event */ 507 if (IPC_GET_ARG1(call) == 1) { 508 console_t *cons = 509 cons_mouse_button((bool) IPC_GET_ARG2(call)); 510 if (cons != NULL) 511 cons_switch(cons); 512 } 513 async_answer_0(callid, EOK); 514 break; 515 default: 516 async_answer_0(callid, EINVAL); 517 } 518 } 210 static int input_ev_key(input_t *input, kbd_event_type_t type, keycode_t key, 211 keymod_t mods, wchar_t c) 212 { 213 if ((key >= KC_F1) && (key < KC_F1 + CONSOLE_COUNT) && 214 ((mods & KM_CTRL) == 0)) { 215 cons_switch(&consoles[key - KC_F1]); 216 } else { 217 /* Got key press/release event */ 218 kbd_event_t *event = 219 (kbd_event_t *) malloc(sizeof(kbd_event_t)); 220 if (event == NULL) { 221 return ENOMEM; 222 } 223 224 link_initialize(&event->link); 225 event->type = type; 226 event->key = key; 227 event->mods = mods; 228 event->c = c; 229 230 /* 231 * Kernel console does not read events 232 * from us, so we will redirect them 233 * to the (last) active userspace console 234 * if necessary. 235 */ 236 console_t *target_console = cons_get_active_uspace(); 237 238 prodcons_produce(&target_console->input_pc, 239 &event->link); 240 } 241 242 return EOK; 243 } 244 245 static int input_ev_move(input_t *input, int dx, int dy) 246 { 247 return EOK; 248 } 249 250 static int input_ev_abs_move(input_t *input, unsigned x , unsigned y, 251 unsigned max_x, unsigned max_y) 252 { 253 return EOK; 254 } 255 256 static int input_ev_button(input_t *input, int bnum, int bpress) 257 { 258 return EOK; 519 259 } 520 260 … … 528 268 switch (ch) { 529 269 case '\n': 530 updated = screenbuffer_newline(cons->frontbuf);270 updated = chargrid_newline(cons->frontbuf); 531 271 break; 532 272 case '\r': 533 273 break; 534 274 case '\t': 535 updated = screenbuffer_tabstop(cons->frontbuf, 8);275 updated = chargrid_tabstop(cons->frontbuf, 8); 536 276 break; 537 277 case '\b': 538 updated = screenbuffer_backspace(cons->frontbuf);278 updated = chargrid_backspace(cons->frontbuf); 539 279 break; 540 280 default: 541 updated = screenbuffer_putchar(cons->frontbuf, ch, true);281 updated = chargrid_putchar(cons->frontbuf, ch, true); 542 282 } 543 283 … … 551 291 { 552 292 fibril_mutex_lock(&cons->mtx); 553 screenbuffer_set_cursor(cons->frontbuf, col, row);293 chargrid_set_cursor(cons->frontbuf, col, row); 554 294 fibril_mutex_unlock(&cons->mtx); 555 295 … … 560 300 { 561 301 fibril_mutex_lock(&cons->mtx); 562 screenbuffer_set_cursor_visibility(cons->frontbuf, visible);302 chargrid_set_cursor_visibility(cons->frontbuf, visible); 563 303 fibril_mutex_unlock(&cons->mtx); 564 304 … … 572 312 573 313 fibril_mutex_lock(&cons->mtx); 574 screenbuffer_get_cursor(cons->frontbuf, &col, &row);314 chargrid_get_cursor(cons->frontbuf, &col, &row); 575 315 fibril_mutex_unlock(&cons->mtx); 576 316 … … 595 335 async_answer_1(iid, EOK, size); 596 336 free(buf); 597 598 cons_notify_data(cons);599 337 } 600 338 … … 660 398 { 661 399 fibril_mutex_lock(&cons->mtx); 662 screenbuffer_set_style(cons->frontbuf, style);400 chargrid_set_style(cons->frontbuf, style); 663 401 fibril_mutex_unlock(&cons->mtx); 664 402 } … … 668 406 { 669 407 fibril_mutex_lock(&cons->mtx); 670 screenbuffer_set_color(cons->frontbuf, bgcolor, fgcolor, attr);408 chargrid_set_color(cons->frontbuf, bgcolor, fgcolor, attr); 671 409 fibril_mutex_unlock(&cons->mtx); 672 410 } … … 676 414 { 677 415 fibril_mutex_lock(&cons->mtx); 678 screenbuffer_set_rgb_color(cons->frontbuf, bgcolor, fgcolor);416 chargrid_set_rgb_color(cons->frontbuf, bgcolor, fgcolor); 679 417 fibril_mutex_unlock(&cons->mtx); 680 418 } … … 708 446 } 709 447 710 if (atomic_postinc(&cons->refcnt) == 0) {448 if (atomic_postinc(&cons->refcnt) == 0) 711 449 cons_set_cursor_visibility(cons, true); 712 cons_notify_connect(cons);713 }714 450 715 451 /* Accept the connection */ … … 720 456 ipc_callid_t callid = async_get_call(&call); 721 457 722 if (!IPC_GET_IMETHOD(call)) { 723 if (atomic_postdec(&cons->refcnt) == 1) 724 cons_notify_disconnect(cons); 725 458 if (!IPC_GET_IMETHOD(call)) 726 459 return; 727 }728 460 729 461 switch (IPC_GET_IMETHOD(call)) { … … 781 513 } 782 514 783 static async_sess_t *input_connect(const char *svc)515 static int input_connect(const char *svc) 784 516 { 785 517 async_sess_t *sess; … … 787 519 788 520 int rc = loc_service_get_id(svc, &dsid, 0); 789 if (rc == EOK) { 790 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 791 if (sess == NULL) { 792 printf("%s: Unable to connect to input service %s\n", NAME, 793 svc); 794 return NULL; 795 } 796 } else 797 return NULL; 798 799 async_exch_t *exch = async_exchange_begin(sess); 800 rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL); 801 async_exchange_end(exch); 802 521 if (rc != EOK) { 522 printf("%s: Input service %s not found\n", NAME, svc); 523 return rc; 524 } 525 526 sess = loc_service_connect(EXCHANGE_ATOMIC, dsid, 0); 527 if (sess == NULL) { 528 printf("%s: Unable to connect to input service %s\n", NAME, 529 svc); 530 return EIO; 531 } 532 533 rc = input_open(sess, &input_ev_ops, NULL, &input); 803 534 if (rc != EOK) { 804 535 async_hangup(sess); 805 printf("%s: Unable to c reate callback connection toservice %s (%s)\n",536 printf("%s: Unable to communicate with service %s (%s)\n", 806 537 NAME, svc, str_error(rc)); 807 return NULL;808 } 809 810 return sess;538 return rc; 539 } 540 541 return EOK; 811 542 } 812 543 … … 816 547 } 817 548 818 static async_sess_t * fb_connect(const char *svc)549 static async_sess_t *output_connect(const char *svc) 819 550 { 820 551 async_sess_t *sess; … … 825 556 sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0); 826 557 if (sess == NULL) { 827 printf("%s: Unable to connect to framebufferservice %s\n",558 printf("%s: Unable to connect to output service %s\n", 828 559 NAME, svc); 829 560 return NULL; … … 835 566 } 836 567 837 static bool console_srv_init(char *input_svc, char *fb_svc) 838 { 839 /* Avoid double initialization */ 840 if (graphics_state != GRAPHICS_NONE) 568 static bool console_srv_init(char *input_svc, char *output_svc) 569 { 570 int rc; 571 572 /* Connect to input service */ 573 rc = input_connect(input_svc); 574 if (rc != EOK) 841 575 return false; 842 576 843 /* Connect to input service */ 844 input_sess = input_connect(input_svc); 845 if (input_sess == NULL) 846 return false; 847 848 /* Connect to framebuffer service */ 849 fb_sess = fb_connect(fb_svc); 850 if (fb_sess == NULL) 577 /* Connect to output service */ 578 output_sess = output_connect(output_svc); 579 if (output_sess == NULL) 851 580 return false; 852 581 853 582 /* Register server */ 854 583 async_set_client_connection(client_connection); 855 intrc = loc_server_register(NAME);584 rc = loc_server_register(NAME); 856 585 if (rc != EOK) { 857 586 printf("%s: Unable to register server (%s)\n", NAME, … … 860 589 } 861 590 862 fb_get_resolution(fb_sess, &xres, &yres); 863 864 /* Initialize the screen */ 865 screen_vp = fb_vp_create(fb_sess, 0, 0, xres, yres); 866 867 if ((xres >= 800) && (yres >= 600)) { 868 logo_vp = fb_vp_create(fb_sess, xres - 66, 2, 64, 60); 869 logo_img = imgmap_decode_tga((void *) helenos_tga, 870 helenos_tga_size, IMGMAP_FLAG_SHARED); 871 logo_handle = fb_imagemap_create(fb_sess, logo_img); 872 873 nameic_vp = fb_vp_create(fb_sess, 5, 17, 100, 26); 874 nameic_img = imgmap_decode_tga((void *) nameic_tga, 875 nameic_tga_size, IMGMAP_FLAG_SHARED); 876 nameic_handle = fb_imagemap_create(fb_sess, nameic_img); 877 878 cons_data_img = imgmap_decode_tga((void *) cons_data_tga, 879 cons_data_tga_size, IMGMAP_FLAG_SHARED); 880 cons_dis_img = imgmap_decode_tga((void *) cons_dis_tga, 881 cons_dis_tga_size, IMGMAP_FLAG_SHARED); 882 cons_dis_sel_img = imgmap_decode_tga((void *) cons_dis_sel_tga, 883 cons_dis_sel_tga_size, IMGMAP_FLAG_SHARED); 884 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga, 885 cons_idle_tga_size, IMGMAP_FLAG_SHARED); 886 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga, 887 cons_kernel_tga_size, IMGMAP_FLAG_SHARED); 888 cons_sel_img = imgmap_decode_tga((void *) cons_sel_tga, 889 cons_sel_tga_size, IMGMAP_FLAG_SHARED); 890 891 state_icons[CONS_DISCONNECTED] = 892 fb_imagemap_create(fb_sess, cons_dis_img); 893 state_icons[CONS_DISCONNECTED_SELECTED] = 894 fb_imagemap_create(fb_sess, cons_dis_sel_img); 895 state_icons[CONS_SELECTED] = 896 fb_imagemap_create(fb_sess, cons_sel_img); 897 state_icons[CONS_IDLE] = 898 fb_imagemap_create(fb_sess, cons_idle_img); 899 state_icons[CONS_DATA] = 900 fb_imagemap_create(fb_sess, cons_data_img); 901 state_icons[CONS_KERNEL] = 902 fb_imagemap_create(fb_sess, cons_kernel_img); 903 904 anim_1_img = imgmap_decode_tga((void *) anim_1_tga, 905 anim_1_tga_size, IMGMAP_FLAG_SHARED); 906 anim_2_img = imgmap_decode_tga((void *) anim_2_tga, 907 anim_2_tga_size, IMGMAP_FLAG_SHARED); 908 anim_3_img = imgmap_decode_tga((void *) anim_3_tga, 909 anim_3_tga_size, IMGMAP_FLAG_SHARED); 910 anim_4_img = imgmap_decode_tga((void *) anim_4_tga, 911 anim_4_tga_size, IMGMAP_FLAG_SHARED); 912 913 anim_1 = fb_imagemap_create(fb_sess, anim_1_img); 914 anim_2 = fb_imagemap_create(fb_sess, anim_2_img); 915 anim_3 = fb_imagemap_create(fb_sess, anim_3_img); 916 anim_4 = fb_imagemap_create(fb_sess, anim_4_img); 917 918 anim_seq = fb_sequence_create(fb_sess); 919 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_1); 920 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_2); 921 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_3); 922 fb_sequence_add_imagemap(fb_sess, anim_seq, anim_4); 923 924 console_vp = fb_vp_create(fb_sess, CONSOLE_MARGIN, CONSOLE_TOP, 925 xres - 2 * CONSOLE_MARGIN, yres - (CONSOLE_TOP + CONSOLE_MARGIN)); 926 927 fb_vp_clear(fb_sess, screen_vp); 928 fb_vp_imagemap_damage(fb_sess, logo_vp, logo_handle, 929 0, 0, 64, 60); 930 fb_vp_imagemap_damage(fb_sess, nameic_vp, nameic_handle, 931 0, 0, 100, 26); 932 933 graphics_state = GRAPHICS_FULL; 934 } else { 935 console_vp = screen_vp; 936 graphics_state = GRAPHICS_BASIC; 937 } 938 939 fb_vp_set_style(fb_sess, console_vp, STYLE_NORMAL); 940 fb_vp_clear(fb_sess, console_vp); 941 942 sysarg_t cols; 943 sysarg_t rows; 944 fb_vp_get_dimensions(fb_sess, console_vp, &cols, &rows); 591 output_get_dimensions(output_sess, &cols, &rows); 592 output_set_style(output_sess, STYLE_NORMAL); 945 593 946 594 console_caps_t ccaps; 947 fb_vp_get_caps(fb_sess, console_vp, &ccaps); 948 949 mouse.x = xres / 2; 950 mouse.y = yres / 2; 951 mouse.pressed = false; 595 output_get_caps(output_sess, &ccaps); 952 596 953 597 /* Inititalize consoles */ … … 959 603 consoles[i].char_remains_len = 0; 960 604 961 if (graphics_state == GRAPHICS_FULL) { 962 /* Create state buttons */ 963 consoles[i].state_vp = 964 fb_vp_create(fb_sess, STATE_START + (xres - 800) / 2 + 965 CONSOLE_MARGIN + i * (STATE_WIDTH + STATE_SPACE), 966 STATE_TOP, STATE_WIDTH, STATE_HEIGHT); 967 } 968 969 if (i == KERNEL_CONSOLE) { 970 consoles[i].state = CONS_KERNEL; 971 cons_redraw_state(&consoles[i]); 972 cons_kernel_sequence_start(&consoles[i]); 605 if (i == KERNEL_CONSOLE) 973 606 continue; 974 }975 976 if (i == 0)977 consoles[i].state = CONS_DISCONNECTED_SELECTED;978 else979 consoles[i].state = CONS_DISCONNECTED;980 607 981 608 consoles[i].cols = cols; … … 983 610 consoles[i].ccaps = ccaps; 984 611 consoles[i].frontbuf = 985 screenbuffer_create(cols, rows, SCREENBUFFER_FLAG_SHARED);612 chargrid_create(cols, rows, CHARGRID_FLAG_SHARED); 986 613 987 614 if (consoles[i].frontbuf == NULL) { … … 990 617 } 991 618 992 consoles[i].fbid = fb_frontbuf_create(fb_sess, consoles[i].frontbuf); 619 consoles[i].fbid = output_frontbuf_create(output_sess, 620 consoles[i].frontbuf); 993 621 if (consoles[i].fbid == 0) { 994 622 printf("%s: Unable to create frontbuffer %zu\n", NAME, i); … … 996 624 } 997 625 998 cons_redraw_state(&consoles[i]);999 1000 626 char vc[LOC_NAME_MAXLEN + 1]; 1001 627 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); … … 1006 632 } 1007 633 } 634 635 cons_damage(active_console); 1008 636 1009 637 /* Receive kernel notifications */ … … 1017 645 } 1018 646 1019 static void usage( void)1020 { 1021 printf("Usage: console <input_dev> <framebuffer_dev>\n");647 static void usage(char *name) 648 { 649 printf("Usage: %s <input_dev> <output_dev>\n", name); 1022 650 } 1023 651 … … 1025 653 { 1026 654 if (argc < 3) { 1027 usage( );655 usage(argv[0]); 1028 656 return -1; 1029 657 } … … 1038 666 async_manager(); 1039 667 668 /* Never reached */ 1040 669 return 0; 1041 670 } -
uspace/srv/hid/input/Makefile
rb9cb911 r7cfe5c0 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 \ … … 56 51 ctl/pc.c \ 57 52 ctl/stty.c \ 58 ctl/sun.c 53 ctl/sun.c \ 54 gsp.c \ 55 input.c \ 56 layout.c \ 57 stroke.c 59 58 60 59 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/hid/input/ctl/apple.c
rb9cb911 r7cfe5c0 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/gxe_fb.c
rb9cb911 r7cfe5c0 33 33 /** 34 34 * @file 35 * @brief GXEmul framebuffer-mode keyboard controller driver.35 * @brief GXEmul framebuffer-mode keyboard controller driver. 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> 44 #include <stroke.h> 40 #include "../stroke.h" 41 #include "../gsp.h" 42 #include "../kbd.h" 43 #include "../kbd_port.h" 44 #include "../kbd_ctl.h" 45 45 46 46 static void gxe_fb_ctl_parse(sysarg_t); -
uspace/srv/hid/input/ctl/kbdev.c
rb9cb911 r7cfe5c0 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 *); -
uspace/srv/hid/input/ctl/pc.c
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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> 53 52 #include <adt/hash.h> 54 53 #include <stdlib.h> 55 54 #include <stdio.h> 55 #include "gsp.h" 56 56 57 57 /* -
uspace/srv/hid/input/input.c
rb9cb911 r7cfe5c0 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>56 #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 63 64 64 #define NUM_LAYOUTS 3 … … 189 189 } 190 190 async_exchange_end(exch); 191 } 192 193 /** Mouse pointer has moved in absolute mode. */ 194 void mouse_push_event_abs_move(mouse_dev_t *mdev, unsigned int x, unsigned int y, 195 unsigned int max_x, unsigned int max_y) 196 { 197 if (max_x && max_y) { 198 async_exch_t *exch = async_exchange_begin(client_sess); 199 async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y); 200 async_exchange_end(exch); 201 } 191 202 } 192 203 … … 635 646 } 636 647 648 static void usage(char *name) 649 { 650 printf("Usage: %s <service_name>\n", name); 651 } 652 637 653 int main(int argc, char **argv) 638 654 { 655 if (argc < 2) { 656 usage(argv[0]); 657 return 1; 658 } 659 639 660 printf("%s: HelenOS input service\n", NAME); 640 661 … … 667 688 } 668 689 669 char kbd[LOC_NAME_MAXLEN + 1];670 snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);671 672 690 service_id_t service_id; 673 rc = loc_service_register( kbd, &service_id);674 if (rc != EOK) { 675 printf("%s: Unable to register service %s\n", NAME, kbd);691 rc = loc_service_register(argv[1], &service_id); 692 if (rc != EOK) { 693 printf("%s: Unable to register service %s\n", NAME, argv[1]); 676 694 return rc; 677 695 } … … 681 699 682 700 printf("%s: Accepting connections\n", NAME); 701 task_retval(0); 683 702 async_manager(); 684 703 -
uspace/srv/hid/input/input.h
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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; -
uspace/srv/hid/input/layout.c
rb9cb911 r7cfe5c0 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/cz.c
rb9cb911 r7cfe5c0 33 33 34 34 #include <errno.h> 35 #include <input.h>36 35 #include <io/console.h> 37 36 #include <io/keycode.h> 38 37 #include <bool.h> 39 #include <layout.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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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); -
uspace/srv/hid/input/port/adb_mouse.c
rb9cb911 r7cfe5c0 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; -
uspace/srv/hid/input/port/chardev.c
rb9cb911 r7cfe5c0 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); -
uspace/srv/hid/input/port/gxemul.c
rb9cb911 r7cfe5c0 31 31 * @{ 32 32 * @ingroup kbd 33 */ 33 */ 34 34 /** @file 35 * @brief GXEmul keyboard port driver.35 * @brief GXEmul keyboard port driver. 36 36 */ 37 37 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 gxemul_port_init(kbd_dev_t *); -
uspace/srv/hid/input/port/msim.c
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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> … … 46 44 #include <bool.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
rb9cb911 r7cfe5c0 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 *); -
uspace/srv/hid/input/port/pl050.c
rb9cb911 r7cfe5c0 41 41 #include <unistd.h> 42 42 #include <sysinfo.h> 43 #include <kbd_port.h>44 #include <kbd.h>45 43 #include <ddi.h> 46 44 #include <stdio.h> 47 45 #include <errno.h> 46 #include "../kbd_port.h" 47 #include "../kbd.h" 48 48 49 49 static int pl050_port_init(kbd_dev_t *); -
uspace/srv/hid/input/port/ski.c
rb9cb911 r7cfe5c0 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 42 #include <bool.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
rb9cb911 r7cfe5c0 37 37 38 38 #include <bool.h> 39 #include <mouse.h>40 #include <mouse_port.h>41 #include <mouse_proto.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
rb9cb911 r7cfe5c0 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 */ … … 94 94 IPC_GET_ARG1(call), IPC_GET_ARG2(call), 95 95 IPC_GET_ARG3(call)); 96 retval = EOK; 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)); 96 102 retval = EOK; 97 103 break; -
uspace/srv/hid/input/stroke.c
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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 38 #include <libarch/ddi.h> 38 #include <as.h> 39 #include <malloc.h> 40 #include <align.h> 41 #include <screenbuffer.h> 42 #include "../fb.h" 39 #include <io/chargrid.h> 40 #include "../output.h" 43 41 #include "ega.h" 44 42 … … 46 44 #define EGA_IO_SIZE 2 47 45 48 #define FB_POS(x, y) (((y) * ega. width+ (x)) << 1)46 #define FB_POS(x, y) (((y) * ega.cols + (x)) << 1) 49 47 50 48 typedef struct { 51 sysarg_t width; 52 sysarg_t height; 49 sysarg_t cols; 50 sysarg_t rows; 51 52 uint8_t style_normal; 53 uint8_t style_inverted; 53 54 54 55 size_t size; 55 56 uint8_t *addr; 56 57 uint8_t style_normal;58 uint8_t style_inverted;59 60 uint8_t *backbuf;61 57 } ega_t; 62 58 … … 101 97 } 102 98 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 99 /** Draw the character at the specified position. 100 * 101 * @param field Character field. 102 * @param col Horizontal screen position. 103 * @param row Vertical screen position. 104 * 105 */ 106 static void draw_char(charfield_t *field, sysarg_t col, sysarg_t row) 107 { 117 108 uint8_t glyph; 118 109 … … 124 115 uint8_t attr = attrs_attr(field->attrs); 125 116 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); 117 ega.addr[FB_POS(col, row)] = glyph; 118 ega.addr[FB_POS(col, row) + 1] = attr; 119 } 120 121 static int ega_yield(outdev_t *dev) 122 { 139 123 return EOK; 140 124 } 141 125 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); 126 static int ega_claim(outdev_t *dev) 127 { 148 128 return EOK; 149 129 } 150 130 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) 131 static void ega_get_dimensions(outdev_t *dev, sysarg_t *cols, sysarg_t *rows) 132 { 133 *cols = ega.cols; 134 *rows = ega.rows; 135 } 136 137 static console_caps_t ega_get_caps(outdev_t *dev) 195 138 { 196 139 return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED); 197 140 } 198 141 199 static void ega_ vp_cursor_update(fbdev_t *dev, fbvp_t *vp, sysarg_t prev_col,142 static void ega_cursor_update(outdev_t *dev, sysarg_t prev_col, 200 143 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) 201 144 { 202 145 /* Cursor position */ 203 uint16_t cursor = row * ega. width+ col;146 uint16_t cursor = row * ega.cols + col; 204 147 205 148 pio_write_8(EGA_IO_BASE, 0x0e); … … 220 163 } 221 164 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 = { 165 static void ega_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) 166 { 167 charfield_t *field = 168 chargrid_charfield_at(dev->backbuf, col, row); 169 170 draw_char(field, col, row); 171 } 172 173 static outdev_ops_t ega_ops = { 229 174 .yield = ega_yield, 230 175 .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 176 .get_dimensions = ega_get_dimensions, 177 .get_caps = ega_get_caps, 178 .cursor_update = ega_cursor_update, 179 .char_update = ega_char_update 239 180 }; 240 181 … … 262 203 return rc; 263 204 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; 205 rc = sysinfo_get_value("fb.width", &ega.cols); 206 if (rc != EOK) 207 return rc; 208 209 rc = sysinfo_get_value("fb.height", &ega.rows); 210 if (rc != EOK) 211 return rc; 212 213 rc = iospace_enable(task_get_id(), (void *) EGA_IO_BASE, 214 EGA_IO_SIZE); 215 if (rc != EOK) 216 return rc; 217 218 ega.size = (ega.cols * ega.rows) << 1; 282 219 283 220 rc = physmem_map((void *) paddr, … … 300 237 } 301 238 302 ega.backbuf = NULL; 303 304 fbdev_t *dev = fbdev_register(&ega_ops, (void *) &ega); 239 outdev_t *dev = outdev_register(&ega_ops, (void *) &ega); 305 240 if (dev == NULL) { 306 241 as_area_destroy(ega.addr); … … 311 246 } 312 247 313 /** 314 * @} 315 */ 248 /** @} 249 */ -
uspace/srv/hid/output/port/ega.h
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 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
rb9cb911 r7cfe5c0 363 363 364 364 printf("%s: HelenOS Remote console service\n", NAME); 365 task_retval(0); 365 366 366 367 while (true) {
Note:
See TracChangeset
for help on using the changeset viewer.
