Changeset a33f0a6 in mainline for uspace/srv/hid
- Timestamp:
- 2011-08-03T17:34:57Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1940326
- Parents:
- 52a79081 (diff), 3fab770 (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
- 5 deleted
- 13 edited
- 31 moved
-
adb_mouse/adb_mouse.c (deleted)
-
char_mouse/char_mouse.c (deleted)
-
console/console.c (modified) (34 diffs)
-
console/gcons.c (modified) (16 diffs)
-
console/keybuffer.c (modified) (2 diffs)
-
console/keybuffer.h (modified) (2 diffs)
-
fb/Makefile (modified) (1 diff)
-
fb/ega.c (modified) (4 diffs)
-
fb/fb.c (modified) (4 diffs)
-
fb/main.c (modified) (3 diffs)
-
fb/niagara.c (modified) (1 diff)
-
fb/niagara.h (modified) (1 diff)
-
fb/serial_console.c (modified) (4 diffs)
-
fb/serial_console.h (modified) (1 diff)
-
fb/sgcn.c (deleted)
-
input/Makefile (added)
-
input/ctl/apple.c (moved) (moved from uspace/srv/hid/kbd/ctl/apple.c ) (4 diffs)
-
input/ctl/gxe_fb.c (moved) (moved from uspace/srv/hid/kbd/ctl/gxe_fb.c ) (7 diffs)
-
input/ctl/kbdev.c (added)
-
input/ctl/pc.c (moved) (moved from uspace/srv/hid/kbd/ctl/pc.c ) (7 diffs)
-
input/ctl/stty.c (moved) (moved from uspace/srv/hid/kbd/ctl/stty.c ) (8 diffs)
-
input/ctl/sun.c (moved) (moved from uspace/srv/hid/kbd/ctl/sun.c ) (5 diffs)
-
input/generic/gsp.c (moved) (moved from uspace/srv/hid/kbd/genarch/gsp.c ) (4 diffs)
-
input/generic/input.c (added)
-
input/generic/layout.c (added)
-
input/generic/stroke.c (moved) (moved from uspace/srv/hid/kbd/genarch/stroke.c ) (6 diffs)
-
input/include/gsp.h (moved) (moved from uspace/srv/hid/kbd/include/gsp.h ) (1 diff)
-
input/include/input.h (moved) (moved from uspace/srv/hid/kbd/include/kbd.h ) (3 diffs)
-
input/include/kbd.h (added)
-
input/include/kbd_ctl.h (moved) (moved from uspace/srv/hid/kbd/include/kbd_ctl.h ) (4 diffs)
-
input/include/kbd_port.h (added)
-
input/include/layout.h (added)
-
input/include/mouse.h (added)
-
input/include/mouse_port.h (moved) (moved from uspace/srv/hid/char_mouse/include/mouse_port.h ) (4 diffs)
-
input/include/mouse_proto.h (moved) (moved from uspace/srv/hid/char_mouse/include/mouse_proto.h ) (3 diffs)
-
input/include/stroke.h (moved) (moved from uspace/srv/hid/kbd/include/stroke.h ) (3 diffs)
-
input/include/sun.h (moved) (moved from uspace/srv/hid/kbd/include/sun.h )
-
input/layout/cz.c (moved) (moved from uspace/srv/hid/kbd/layout/cz.c ) (9 diffs)
-
input/layout/us_dvorak.c (moved) (moved from uspace/srv/hid/kbd/layout/us_dvorak.c ) (4 diffs)
-
input/layout/us_qwerty.c (moved) (moved from uspace/srv/hid/kbd/layout/us_qwerty.c ) (4 diffs)
-
input/port/adb.c (moved) (moved from uspace/srv/hid/kbd/port/adb.c ) (6 diffs)
-
input/port/adb_mouse.c (moved) (moved from uspace/srv/hid/char_mouse/chardev.c ) (2 diffs)
-
input/port/chardev.c (moved) (moved from uspace/srv/hid/kbd/port/chardev.c ) (4 diffs)
-
input/port/chardev_mouse.c (added)
-
input/port/dummy.c (moved) (moved from uspace/srv/hid/kbd/port/dummy.c )
-
input/port/gxemul.c (moved) (moved from uspace/srv/hid/kbd/port/gxemul.c ) (5 diffs)
-
input/port/msim.c (moved) (moved from uspace/srv/hid/kbd/port/msim.c ) (6 diffs)
-
input/port/niagara.c (moved) (moved from uspace/srv/hid/kbd/port/niagara.c ) (6 diffs)
-
input/port/ns16550.c (moved) (moved from uspace/srv/hid/kbd/port/ns16550.c ) (4 diffs)
-
input/port/pl050.c (moved) (moved from uspace/srv/hid/kbd/port/pl050.c ) (5 diffs)
-
input/port/sgcn.c (moved) (moved from uspace/srv/hid/kbd/port/sgcn.c )
-
input/port/ski.c (moved) (moved from uspace/srv/hid/kbd/port/ski.c ) (7 diffs)
-
input/port/sun.c (moved) (moved from uspace/srv/hid/kbd/port/sun.c )
-
input/port/z8530.c (moved) (moved from uspace/srv/hid/kbd/port/z8530.c )
-
input/proto/adb.c (added)
-
input/proto/mousedev.c (added)
-
input/proto/ps2.c (moved) (moved from uspace/srv/hid/char_mouse/proto/ps2.c ) (5 diffs)
-
kbd/Makefile (deleted)
-
kbd/generic/kbd.c (deleted)
-
s3c24xx_ts/s3c24xx_ts.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/console.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 34 35 35 36 #include <libc.h> 36 #include <ipc/ kbd.h>37 #include <ipc/input.h> 37 38 #include <io/keycode.h> 38 #include <ipc/mouse.h>39 39 #include <ipc/fb.h> 40 40 #include <ipc/services.h> 41 #include <ipc/ns.h> 41 #include <ns.h> 42 #include <ns_obsolete.h> 42 43 #include <errno.h> 44 #include <str_error.h> 43 45 #include <ipc/console.h> 44 46 #include <unistd.h> 45 47 #include <async.h> 48 #include <async_obsolete.h> 46 49 #include <adt/fifo.h> 47 50 #include <sys/mman.h> … … 61 64 #include "keybuffer.h" 62 65 63 64 66 #define NAME "console" 65 67 #define NAMESPACE "term" 66 68 67 /** Phone to the keyboard driver. */ 68 static int kbd_phone; 69 70 /** Phone to the mouse driver. */ 71 static int mouse_phone; 69 /** Session with the input server. */ 70 static async_sess_t *input_sess; 72 71 73 72 /** Information about framebuffer */ … … 109 108 static FIBRIL_CONDVAR_INITIALIZE(input_cv); 110 109 110 static FIBRIL_MUTEX_INITIALIZE(big_console_lock); 111 112 static void console_serialize_start(void) 113 { 114 fibril_mutex_lock(&big_console_lock); 115 } 116 117 static void console_serialize_end(void) 118 { 119 fibril_mutex_unlock(&big_console_lock); 120 } 121 111 122 static void curs_visibility(bool visible) 112 123 { 113 async_ msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible);124 async_obsolete_msg_1(fb_info.phone, FB_CURSOR_VISIBILITY, visible); 114 125 } 115 126 116 127 static void curs_hide_sync(void) 117 128 { 118 async_ req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false);129 async_obsolete_req_1_0(fb_info.phone, FB_CURSOR_VISIBILITY, false); 119 130 } 120 131 121 132 static void curs_goto(sysarg_t x, sysarg_t y) 122 133 { 123 async_ msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y);134 async_obsolete_msg_2(fb_info.phone, FB_CURSOR_GOTO, x, y); 124 135 } 125 136 126 137 static void screen_clear(void) 127 138 { 128 async_ msg_0(fb_info.phone, FB_CLEAR);139 async_obsolete_msg_0(fb_info.phone, FB_CLEAR); 129 140 } 130 141 131 142 static void screen_yield(void) 132 143 { 133 async_ req_0_0(fb_info.phone, FB_SCREEN_YIELD);144 async_obsolete_req_0_0(fb_info.phone, FB_SCREEN_YIELD); 134 145 } 135 146 136 147 static void screen_reclaim(void) 137 148 { 138 async_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM); 139 } 140 141 static void kbd_yield(void) 142 { 143 async_req_0_0(kbd_phone, KBD_YIELD); 144 } 145 146 static void kbd_reclaim(void) 147 { 148 async_req_0_0(kbd_phone, KBD_RECLAIM); 149 async_obsolete_req_0_0(fb_info.phone, FB_SCREEN_RECLAIM); 150 } 151 152 static void input_yield(void) 153 { 154 async_exch_t *exch = async_exchange_begin(input_sess); 155 if (exch == NULL) { 156 printf("%s: Failed starting exchange with input device.\n", 157 NAME); 158 return; 159 } 160 161 async_req_0_0(exch, INPUT_YIELD); 162 async_exchange_end(exch); 163 } 164 165 static void input_reclaim(void) 166 { 167 async_exch_t *exch = async_exchange_begin(input_sess); 168 if (exch == NULL) { 169 printf("%s: Failed starting exchange with input device.\n", 170 NAME); 171 return; 172 } 173 174 async_req_0_0(exch, INPUT_RECLAIM); 175 async_exchange_end(exch); 149 176 } 150 177 151 178 static void set_style(uint8_t style) 152 179 { 153 async_ msg_1(fb_info.phone, FB_SET_STYLE, style);180 async_obsolete_msg_1(fb_info.phone, FB_SET_STYLE, style); 154 181 } 155 182 156 183 static void set_color(uint8_t fgcolor, uint8_t bgcolor, uint8_t flags) 157 184 { 158 async_ msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags);185 async_obsolete_msg_3(fb_info.phone, FB_SET_COLOR, fgcolor, bgcolor, flags); 159 186 } 160 187 161 188 static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor) 162 189 { 163 async_ msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor);190 async_obsolete_msg_2(fb_info.phone, FB_SET_RGB_COLOR, fgcolor, bgcolor); 164 191 } 165 192 … … 216 243 } 217 244 218 async_ req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,245 async_obsolete_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA, 219 246 x0, y0, width, height); 220 247 } … … 257 284 static void fb_putchar(wchar_t c, sysarg_t col, sysarg_t row) 258 285 { 259 async_ msg_3(fb_info.phone, FB_PUTCHAR, c, col, row);286 async_obsolete_msg_3(fb_info.phone, FB_PUTCHAR, c, col, row); 260 287 } 261 288 … … 306 333 307 334 if (cons == active_console) 308 async_ msg_1(fb_info.phone, FB_SCROLL, 1);335 async_obsolete_msg_1(fb_info.phone, FB_SCROLL, 1); 309 336 } 310 337 … … 323 350 324 351 if (cons == kernel_console) { 325 async_serialize_start();352 console_serialize_start(); 326 353 curs_hide_sync(); 327 354 gcons_in_kernel(); 328 355 screen_yield(); 329 kbd_yield();330 async_serialize_end();331 332 if ( __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {356 input_yield(); 357 console_serialize_end(); 358 359 if (console_kcon()) { 333 360 prev_console = active_console; 334 361 active_console = kernel_console; … … 338 365 339 366 if (cons != kernel_console) { 340 async_serialize_start();367 console_serialize_start(); 341 368 342 369 if (active_console == kernel_console) { 343 370 screen_reclaim(); 344 kbd_reclaim();371 input_reclaim(); 345 372 gcons_redraw_console(); 346 373 } … … 365 392 366 393 /* This call can preempt, but we are already at the end */ 367 rc = async_ req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA,394 rc = async_obsolete_req_4_0(fb_info.phone, FB_DRAW_TEXT_DATA, 368 395 0, 0, cons->scr.size_x, 369 396 cons->scr.size_y); … … 393 420 curs_visibility(cons->scr.is_cursor_visible); 394 421 395 async_serialize_end();396 } 397 } 398 399 /** Handler for keyboard*/400 static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)422 console_serialize_end(); 423 } 424 } 425 426 /** Handler for input events */ 427 static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 401 428 { 402 429 /* Ignore parameters, the connection is already opened */ … … 406 433 407 434 int retval; 408 console_event_t ev; 435 kbd_event_t ev; 436 437 if (!IPC_GET_IMETHOD(call)) { 438 /* TODO: Handle hangup */ 439 async_hangup(input_sess); 440 return; 441 } 409 442 410 443 switch (IPC_GET_IMETHOD(call)) { 411 case IPC_M_PHONE_HUNGUP: 412 /* TODO: Handle hangup */ 413 return; 414 case KBD_EVENT: 415 /* Got event from keyboard driver. */ 444 case INPUT_EVENT_KEY: 445 /* Got key press/release event */ 416 446 retval = 0; 417 447 ev.type = IPC_GET_ARG1(call); … … 434 464 fibril_mutex_unlock(&input_mutex); 435 465 break; 436 default: 437 retval = ENOENT; 438 } 439 async_answer_0(callid, retval); 440 } 441 } 442 443 /** Handler for mouse events */ 444 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall) 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 int retval; 452 453 switch (IPC_GET_IMETHOD(call)) { 454 case IPC_M_PHONE_HUNGUP: 455 /* TODO: Handle hangup */ 456 return; 457 case MEVENT_BUTTON: 466 case INPUT_EVENT_MOVE: 467 /* Got pointer move event */ 468 gcons_mouse_move((int) IPC_GET_ARG1(call), 469 (int) IPC_GET_ARG2(call)); 470 retval = 0; 471 break; 472 case INPUT_EVENT_BUTTON: 473 /* Got pointer button press/release event */ 458 474 if (IPC_GET_ARG1(call) == 1) { 459 475 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); … … 463 479 retval = 0; 464 480 break; 465 case MEVENT_MOVE:466 gcons_mouse_move((int) IPC_GET_ARG1(call),467 (int) IPC_GET_ARG2(call));468 retval = 0;469 break;470 481 default: 471 482 retval = ENOENT; … … 487 498 } 488 499 489 async_serialize_start();500 console_serialize_start(); 490 501 491 502 size_t off = 0; … … 495 506 } 496 507 497 async_serialize_end();508 console_serialize_end(); 498 509 499 510 gcons_notify_char(cons->index); … … 521 532 522 533 size_t pos = 0; 523 console_event_t ev;534 kbd_event_t ev; 524 535 fibril_mutex_lock(&input_mutex); 525 536 … … 546 557 static void cons_get_event(console_t *cons, ipc_callid_t rid, ipc_call_t *request) 547 558 { 548 console_event_t ev;559 kbd_event_t ev; 549 560 550 561 fibril_mutex_lock(&input_mutex); … … 562 573 563 574 /** Default thread for new connections */ 564 static void client_connection(ipc_callid_t iid, ipc_call_t *icall )575 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 565 576 { 566 577 console_t *cons = NULL; … … 590 601 int rc; 591 602 592 async_serialize_start();603 console_serialize_start(); 593 604 if (cons->refcount == 0) 594 605 gcons_notify_connect(cons->index); … … 600 611 601 612 while (true) { 602 async_serialize_end();613 console_serialize_end(); 603 614 callid = async_get_call(&call); 604 async_serialize_start();615 console_serialize_start(); 605 616 606 617 arg1 = 0; … … 608 619 arg3 = 0; 609 620 610 switch (IPC_GET_IMETHOD(call)) { 611 case IPC_M_PHONE_HUNGUP: 621 if (!IPC_GET_IMETHOD(call)) { 612 622 cons->refcount--; 613 623 if (cons->refcount == 0) 614 624 gcons_notify_disconnect(cons->index); 625 console_serialize_end(); 615 626 return; 627 } 628 629 switch (IPC_GET_IMETHOD(call)) { 616 630 case VFS_OUT_READ: 617 async_serialize_end();631 console_serialize_end(); 618 632 cons_read(cons, callid, &call); 619 async_serialize_start();633 console_serialize_start(); 620 634 continue; 621 635 case VFS_OUT_WRITE: 622 async_serialize_end();636 console_serialize_end(); 623 637 cons_write(cons, callid, &call); 624 async_serialize_start();638 console_serialize_start(); 625 639 continue; 626 640 case VFS_OUT_SYNC: 627 641 fb_pending_flush(); 628 642 if (cons == active_console) { 629 async_ req_0_0(fb_info.phone, FB_FLUSH);643 async_obsolete_req_0_0(fb_info.phone, FB_FLUSH); 630 644 curs_goto(cons->scr.position_x, cons->scr.position_y); 631 645 } … … 634 648 /* Send message to fb */ 635 649 if (cons == active_console) 636 async_ msg_0(fb_info.phone, FB_CLEAR);650 async_obsolete_msg_0(fb_info.phone, FB_CLEAR); 637 651 638 652 screenbuffer_clear(&cons->scr); … … 693 707 break; 694 708 case CONSOLE_GET_EVENT: 695 async_serialize_end();709 console_serialize_end(); 696 710 cons_get_event(cons, callid, &call); 697 async_serialize_start();711 console_serialize_start(); 698 712 continue; 699 case CONSOLE_KCON_ENABLE:700 change_console(kernel_console);701 break;702 713 } 703 714 async_answer_3(callid, EOK, arg1, arg2, arg3); … … 710 721 } 711 722 712 static bool console_init(char *input) 713 { 714 /* Connect to input device */ 715 int input_fd = open(input, O_RDONLY); 716 if (input_fd < 0) { 717 printf(NAME ": Failed opening %s\n", input); 723 static async_sess_t *connect_input(const char *dev_path) 724 { 725 async_sess_t *sess; 726 async_exch_t *exch; 727 devmap_handle_t handle; 728 729 int rc = devmap_device_get_handle(dev_path, &handle, 0); 730 if (rc == EOK) { 731 sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0); 732 if (sess == NULL) { 733 printf("%s: Failed to connect to input server\n", NAME); 734 return NULL; 735 } 736 } else { 737 return NULL; 738 } 739 740 exch = async_exchange_begin(sess); 741 if (exch == NULL) { 742 printf("%s: Failed to create callback from input server.\n", NAME); 743 return NULL; 744 } 745 746 /* NB: The callback connection is slotted for removal */ 747 rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL); 748 749 async_exchange_end(exch); 750 751 if (rc != EOK) { 752 async_hangup(sess); 753 printf("%s: Failed to create callback from input server (%s).\n", 754 NAME, str_error(rc)); 755 return NULL; 756 } 757 758 return sess; 759 } 760 761 static bool console_srv_init(char *input_dev) 762 { 763 /* Connect to input server */ 764 input_sess = connect_input(input_dev); 765 if (input_sess == NULL) 718 766 return false; 719 }720 721 kbd_phone = fd_phone(input_fd);722 if ( kbd_phone < 0) {723 printf( NAME ": Failed to connect to input device\n");767 768 /* Connect to framebuffer driver */ 769 fb_info.phone = service_obsolete_connect_blocking(SERVICE_VIDEO, 0, 0); 770 if (fb_info.phone < 0) { 771 printf("%s: Failed to connect to video service\n", NAME); 724 772 return false; 725 }726 727 /* NB: The callback connection is slotted for removal */728 if (async_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, keyboard_events)729 != 0) {730 printf(NAME ": Failed to create callback from input device\n");731 return false;732 }733 734 /* Connect to mouse device */735 mouse_phone = -1;736 int mouse_fd = open("/dev/hid_in/mouse", O_RDONLY);737 738 if (mouse_fd < 0) {739 printf(NAME ": Notice - failed opening %s\n", "/dev/hid_in/mouse");740 goto skip_mouse;741 }742 743 mouse_phone = fd_phone(mouse_fd);744 if (mouse_phone < 0) {745 printf(NAME ": Failed to connect to mouse device\n");746 goto skip_mouse;747 }748 749 if (async_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, mouse_events)750 != 0) {751 printf(NAME ": Failed to create callback from mouse device\n");752 mouse_phone = -1;753 goto skip_mouse;754 }755 756 skip_mouse:757 758 /* Connect to framebuffer driver */759 fb_info.phone = service_connect_blocking(SERVICE_VIDEO, 0, 0);760 if (fb_info.phone < 0) {761 printf(NAME ": Failed to connect to video service\n");762 return -1;763 773 } 764 774 … … 766 776 int rc = devmap_driver_register(NAME, client_connection); 767 777 if (rc < 0) { 768 printf( NAME ": Unable to register driver (%d)\n", rc);778 printf("%s: Unable to register driver (%d)\n", NAME, rc); 769 779 return false; 770 780 } … … 774 784 775 785 /* Synchronize, the gcons could put something in queue */ 776 async_ req_0_0(fb_info.phone, FB_FLUSH);777 async_ req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows);778 async_ req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap);786 async_obsolete_req_0_0(fb_info.phone, FB_FLUSH); 787 async_obsolete_req_0_2(fb_info.phone, FB_GET_CSIZE, &fb_info.cols, &fb_info.rows); 788 async_obsolete_req_0_1(fb_info.phone, FB_GET_COLOR_CAP, &fb_info.color_cap); 779 789 780 790 /* Set up shared memory buffer. */ … … 787 797 788 798 if (interbuffer) { 789 if (async_ share_out_start(fb_info.phone, interbuffer,799 if (async_obsolete_share_out_start(fb_info.phone, interbuffer, 790 800 AS_AREA_READ) != EOK) { 791 801 as_area_destroy(interbuffer); … … 802 812 if (screenbuffer_init(&consoles[i].scr, 803 813 fb_info.cols, fb_info.rows) == NULL) { 804 printf( NAME ": Unable to allocate screen buffer %zu\n", i);814 printf("%s: Unable to allocate screen buffer %zu\n", NAME, i); 805 815 return false; 806 816 } … … 814 824 815 825 if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) { 816 printf( NAME ": Unable to register device %s\n", vc);826 printf("%s: Unable to register device %s\n", NAME, vc); 817 827 return false; 818 828 } … … 820 830 } 821 831 822 /* Disable kernel output to the console */823 __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);824 825 832 /* Initialize the screen */ 826 async_serialize_start();833 console_serialize_start(); 827 834 gcons_redraw_console(); 828 835 set_style(STYLE_NORMAL); … … 830 837 curs_goto(0, 0); 831 838 curs_visibility(active_console->scr.is_cursor_visible); 832 async_serialize_end();839 console_serialize_end(); 833 840 834 841 /* Receive kernel notifications */ 835 842 async_set_interrupt_received(interrupt_received); 836 843 if (event_subscribe(EVENT_KCONSOLE, 0) != EOK) 837 printf( NAME ": Error registering kconsole notifications\n");844 printf("%s: Error registering kconsole notifications\n", NAME); 838 845 839 846 return true; … … 842 849 static void usage(void) 843 850 { 844 printf("Usage: console <input >\n");851 printf("Usage: console <input_dev>\n"); 845 852 } 846 853 … … 854 861 printf(NAME ": HelenOS Console service\n"); 855 862 856 if (!console_ init(argv[1]))863 if (!console_srv_init(argv[1])) 857 864 return -1; 858 865 -
uspace/srv/hid/console/gcons.c
r52a79081 ra33f0a6 35 35 #include <ipc/fb.h> 36 36 #include <async.h> 37 #include <async_obsolete.h> 37 38 #include <stdio.h> 38 39 #include <sys/mman.h> … … 115 116 static void vp_switch(int vp) 116 117 { 117 async_ msg_1(fbphone, FB_VIEWPORT_SWITCH, vp);118 async_obsolete_msg_1(fbphone, FB_VIEWPORT_SWITCH, vp); 118 119 } 119 120 … … 121 122 static int vp_create(sysarg_t x, sysarg_t y, sysarg_t width, sysarg_t height) 122 123 { 123 return async_ req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y,124 return async_obsolete_req_2_0(fbphone, FB_VIEWPORT_CREATE, (x << 16) | y, 124 125 (width << 16) | height); 125 126 } … … 127 128 static void clear(void) 128 129 { 129 async_ msg_0(fbphone, FB_CLEAR);130 async_obsolete_msg_0(fbphone, FB_CLEAR); 130 131 } 131 132 132 133 static void set_rgb_color(uint32_t fgcolor, uint32_t bgcolor) 133 134 { 134 async_ msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor);135 async_obsolete_msg_2(fbphone, FB_SET_RGB_COLOR, fgcolor, bgcolor); 135 136 } 136 137 … … 138 139 static void tran_putch(wchar_t ch, sysarg_t col, sysarg_t row) 139 140 { 140 async_ msg_3(fbphone, FB_PUTCHAR, ch, col, row);141 async_obsolete_msg_3(fbphone, FB_PUTCHAR, ch, col, row); 141 142 } 142 143 … … 149 150 150 151 if (ic_pixmaps[state] != -1) 151 async_ msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],152 async_obsolete_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index], 152 153 ic_pixmaps[state]); 153 154 … … 167 168 void gcons_change_console(size_t index) 168 169 { 169 if (!use_gcons) 170 return; 170 if (!use_gcons) { 171 active_console = index; 172 return; 173 } 171 174 172 175 if (active_console == KERNEL_CONSOLE) { … … 177 180 178 181 if (animation != -1) 179 async_ msg_1(fbphone, FB_ANIM_START, animation);182 async_obsolete_msg_1(fbphone, FB_ANIM_START, animation); 180 183 } else { 181 184 if (console_state[active_console] == CONS_DISCONNECTED_SEL) … … 258 261 { 259 262 if (animation != -1) 260 async_ msg_1(fbphone, FB_ANIM_STOP, animation);263 async_obsolete_msg_1(fbphone, FB_ANIM_STOP, animation); 261 264 262 265 active_console = KERNEL_CONSOLE; … … 294 297 295 298 if (active_console != KERNEL_CONSOLE) 296 async_ msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y);299 async_obsolete_msg_2(fbphone, FB_POINTER_MOVE, mouse_x, mouse_y); 297 300 } 298 301 … … 374 377 375 378 /* Send area */ 376 int rc = async_ req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);379 int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm); 377 380 if (rc) 378 381 goto exit; 379 382 380 rc = async_ share_out_start(fbphone, shm, PROTO_READ);383 rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ); 381 384 if (rc) 382 385 goto drop; 383 386 384 387 /* Draw logo */ 385 async_ msg_2(fbphone, FB_DRAW_PPM, x, y);388 async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y); 386 389 387 390 drop: 388 391 /* Drop area */ 389 async_ msg_0(fbphone, FB_DROP_SHM);392 async_obsolete_msg_0(fbphone, FB_DROP_SHM); 390 393 391 394 exit: … … 436 439 437 440 /* Send area */ 438 int rc = async_ req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm);441 int rc = async_obsolete_req_1_0(fbphone, FB_PREPARE_SHM, (sysarg_t) shm); 439 442 if (rc) 440 443 goto exit; 441 444 442 rc = async_ share_out_start(fbphone, shm, PROTO_READ);445 rc = async_obsolete_share_out_start(fbphone, shm, PROTO_READ); 443 446 if (rc) 444 447 goto drop; 445 448 446 449 /* Obtain pixmap */ 447 rc = async_ req_0_0(fbphone, FB_SHM2PIXMAP);450 rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP); 448 451 if (rc < 0) 449 452 goto drop; … … 453 456 drop: 454 457 /* Drop area */ 455 async_ msg_0(fbphone, FB_DROP_SHM);458 async_obsolete_msg_0(fbphone, FB_DROP_SHM); 456 459 457 460 exit: … … 464 467 static void make_anim(void) 465 468 { 466 int an = async_ req_1_0(fbphone, FB_ANIM_CREATE,469 int an = async_obsolete_req_1_0(fbphone, FB_ANIM_CREATE, 467 470 cstatus_vp[KERNEL_CONSOLE]); 468 471 if (an < 0) … … 471 474 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 472 475 (size_t) &_binary_gfx_anim_1_ppm_size); 473 async_ msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);476 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 474 477 475 478 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 476 479 (size_t) &_binary_gfx_anim_2_ppm_size); 477 async_ msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);480 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 478 481 479 482 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 480 483 (size_t) &_binary_gfx_anim_3_ppm_size); 481 async_ msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);484 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 482 485 483 486 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 484 487 (size_t) &_binary_gfx_anim_4_ppm_size); 485 async_ msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);486 487 async_ msg_1(fbphone, FB_ANIM_START, an);488 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 489 490 async_obsolete_msg_1(fbphone, FB_ANIM_START, an); 488 491 489 492 animation = an; … … 495 498 fbphone = phone; 496 499 497 int rc = async_ req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres);500 int rc = async_obsolete_req_0_2(phone, FB_GET_RESOLUTION, &xres, &yres); 498 501 if (rc) 499 502 return; -
uspace/srv/hid/console/keybuffer.c
r52a79081 ra33f0a6 90 90 * 91 91 */ 92 void keybuffer_push(keybuffer_t *keybuffer, const console_event_t *ev)92 void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev) 93 93 { 94 94 futex_down(&keybuffer_futex); … … 110 110 * 111 111 */ 112 bool keybuffer_pop(keybuffer_t *keybuffer, console_event_t *edst)112 bool keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst) 113 113 { 114 114 futex_down(&keybuffer_futex); -
uspace/srv/hid/console/keybuffer.h
r52a79081 ra33f0a6 46 46 47 47 typedef struct { 48 console_event_t fifo[KEYBUFFER_SIZE];48 kbd_event_t fifo[KEYBUFFER_SIZE]; 49 49 size_t head; 50 50 size_t tail; … … 56 56 extern size_t keybuffer_available(keybuffer_t *); 57 57 extern bool keybuffer_empty(keybuffer_t *); 58 extern void keybuffer_push(keybuffer_t *, const console_event_t *);59 extern bool keybuffer_pop(keybuffer_t *, console_event_t *);58 extern void keybuffer_push(keybuffer_t *, const kbd_event_t *); 59 extern bool keybuffer_pop(keybuffer_t *, kbd_event_t *); 60 60 61 61 #endif -
uspace/srv/hid/fb/Makefile
r52a79081 ra33f0a6 84 84 EXTRA_CFLAGS += -DNIAGARA_ENABLED 85 85 endif 86 87 ifeq ($(MACHINE),serengeti)88 SOURCES += \89 sgcn.c \90 serial_console.c91 EXTRA_CFLAGS += -DSGCN_ENABLED92 endif93 86 endif 94 87 -
uspace/srv/hid/fb/ega.c
r52a79081 ra33f0a6 52 52 #include <io/screenbuffer.h> 53 53 #include <sys/types.h> 54 55 54 #include "ega.h" 56 55 #include "main.h" 56 57 // FIXME: remove this header 58 #include <kernel/ipc/ipc_methods.h> 57 59 58 60 #define MAX_SAVED_SCREENS 256 … … 254 256 } 255 257 256 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall) 258 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall, 259 void *arg) 257 260 { 258 261 size_t intersize = 0; … … 291 294 int retval; 292 295 293 switch (IPC_GET_IMETHOD(call)) { 294 case IPC_M_PHONE_HUNGUP: 296 if (!IPC_GET_IMETHOD(call)) { 295 297 client_connected = 0; 296 298 async_answer_0(callid, EOK); … … 298 300 /* Exit thread */ 299 301 return; 302 } 303 304 switch (IPC_GET_IMETHOD(call)) { 300 305 case IPC_M_SHARE_OUT: 301 306 /* We accept one area for data interchange */ -
uspace/srv/hid/fb/fb.c
r52a79081 ra33f0a6 59 59 #include <byteorder.h> 60 60 #include <io/screenbuffer.h> 61 62 61 #include "font-8x16.h" 63 62 #include "fb.h" 64 63 #include "main.h" 65 64 #include "ppm.h" 66 67 65 #include "pointer.xbm" 68 66 #include "pointer_mask.xbm" 67 68 // FIXME: remove this header 69 #include <kernel/ipc/ipc_methods.h> 69 70 70 71 #define DEFAULT_BGCOLOR 0xf0f0f0 … … 1575 1576 * 1576 1577 */ 1577 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) 1578 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall, 1579 void *arg) 1578 1580 { 1579 1581 unsigned int vp = 0; … … 1620 1622 continue; 1621 1623 1622 switch (IPC_GET_IMETHOD(call)) { 1623 case IPC_M_PHONE_HUNGUP: 1624 if (!IPC_GET_IMETHOD(call)) { 1624 1625 client_connected = false; 1625 1626 … … 1630 1631 /* Exit thread */ 1631 1632 return; 1633 } 1632 1634 1635 switch (IPC_GET_IMETHOD(call)) { 1633 1636 case FB_PUTCHAR: 1634 1637 ch = IPC_GET_ARG1(call); -
uspace/srv/hid/fb/main.c
r52a79081 ra33f0a6 28 28 29 29 #include <ipc/services.h> 30 #include < ipc/ns.h>30 #include <ns.h> 31 31 #include <sysinfo.h> 32 32 #include <async.h> … … 40 40 #include "msim.h" 41 41 #include "ski.h" 42 #include "sgcn.h"43 42 #include "niagara.h" 44 43 #include "main.h" … … 92 91 } 93 92 #endif 94 #ifdef SGCN_ENABLED95 if ((!initialized) && (fb_kind == 4)) {96 if (sgcn_init() == 0)97 initialized = true;98 }99 #endif100 93 #ifdef NIAGARA_ENABLED 101 94 if ((!initialized) && (fb_kind == 5)) { -
uspace/srv/hid/fb/niagara.c
r52a79081 ra33f0a6 29 29 */ 30 30 31 /** @defgroup niagarafb SGCN31 /** @defgroup niagarafb 32 32 * @brief userland driver of the Niagara console output 33 33 * @{ -
uspace/srv/hid/fb/niagara.h
r52a79081 ra33f0a6 27 27 */ 28 28 29 /** @defgroup sgcnfb SGCN30 * @brief userland driver of the Serengeticonsole output29 /** @defgroup niagarafb 30 * @brief userland driver of the Niagara console output 31 31 * @{ 32 32 */ -
uspace/srv/hid/fb/serial_console.c
r52a79081 ra33f0a6 52 52 #include "serial_console.h" 53 53 54 // FIXME: remove this header 55 #include <kernel/ipc/ipc_methods.h> 56 54 57 #define MAX_CONTROL 20 55 58 … … 312 315 * Main function of the thread serving client connections. 313 316 */ 314 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall )317 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 315 318 { 316 319 keyfield_t *interbuf = NULL; … … 344 347 int retval; 345 348 346 switch (IPC_GET_IMETHOD(call)) { 347 case IPC_M_PHONE_HUNGUP: 349 if (!IPC_GET_IMETHOD(call)) { 348 350 client_connected = 0; 349 351 async_answer_0(callid, EOK); … … 351 353 /* Exit thread */ 352 354 return; 355 } 356 357 switch (IPC_GET_IMETHOD(call)) { 353 358 case IPC_M_SHARE_OUT: 354 359 /* We accept one area for data interchange */ -
uspace/srv/hid/fb/serial_console.h
r52a79081 ra33f0a6 52 52 extern void serial_set_scroll_region(sysarg_t); 53 53 extern void serial_console_init(putc_function_t, sysarg_t, sysarg_t); 54 extern void serial_client_connection(ipc_callid_t, ipc_call_t * );54 extern void serial_client_connection(ipc_callid_t, ipc_call_t *, void *arg); 55 55 56 56 #endif -
uspace/srv/hid/input/ctl/apple.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ 33 33 /** 34 34 * @file 35 * @brief Apple ADB keyboard controller driver.35 * @brief Apple ADB keyboard controller driver. 36 36 */ 37 37 … … 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 43 44 static void apple_ctl_parse(sysarg_t); 45 static int apple_ctl_init(kbd_dev_t *); 46 static void apple_ctl_set_ind(kbd_dev_t *, unsigned int); 47 48 kbd_ctl_ops_t apple_ctl = { 49 .parse = apple_ctl_parse, 50 .init = apple_ctl_init, 51 .set_ind = apple_ctl_set_ind 52 }; 42 53 43 54 #define KBD_KEY_RELEASE 0x80 44 55 56 static kbd_dev_t *kbd_dev; 57 45 58 static int scanmap[]; 46 59 47 int kbd_ctl_init(void)60 static int apple_ctl_init(kbd_dev_t *kdev) 48 61 { 62 kbd_dev = kdev; 49 63 return 0; 50 64 } 51 65 52 void kbd_ctl_parse_scancode(int scancode)66 static void apple_ctl_parse(sysarg_t scancode) 53 67 { 54 console_ev_type_t type;68 kbd_event_type_t type; 55 69 unsigned int key; 56 70 57 if (scancode < 0 || scancode>= 0x100)71 if (scancode >= 0x100) 58 72 return; 59 73 … … 67 81 key = scanmap[scancode]; 68 82 if (key != 0) 69 kbd_push_ev (type, key);83 kbd_push_event(kbd_dev, type, key); 70 84 } 71 85 72 void kbd_ctl_set_ind(unsigned mods)86 static void apple_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 73 87 { 74 88 (void) mods; -
uspace/srv/hid/input/ctl/gxe_fb.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ … … 40 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 #include <kbd_port.h> 42 43 #include <gsp.h> 43 44 #include <stroke.h> 44 45 46 static void gxe_fb_ctl_parse(sysarg_t); 47 static int gxe_fb_ctl_init(kbd_dev_t *); 48 static void gxe_fb_ctl_set_ind(kbd_dev_t *, unsigned int); 49 50 kbd_ctl_ops_t gxe_fb_ctl = { 51 .parse = gxe_fb_ctl_parse, 52 .init = gxe_fb_ctl_init, 53 .set_ind = gxe_fb_ctl_set_ind 54 }; 55 56 static kbd_dev_t *kbd_dev; 57 45 58 /** Scancode parser */ 46 59 static gsp_t sp; … … 51 64 #include <stdio.h> 52 65 53 int seq_defs[] = {66 static int seq_defs[] = { 54 67 /* Not shifted */ 55 68 … … 207 220 }; 208 221 209 int kbd_ctl_init(void)222 static int gxe_fb_ctl_init(kbd_dev_t *kdev) 210 223 { 224 kbd_dev = kdev; 211 225 ds = 0; 212 226 … … 215 229 } 216 230 217 void kbd_ctl_parse_scancode(int scancode)231 static void gxe_fb_ctl_parse(sysarg_t scancode) 218 232 { 219 233 unsigned mods, key; … … 221 235 ds = gsp_step(&sp, ds, scancode, &mods, &key); 222 236 if (key != 0) { 223 stroke_sim( mods, key);237 stroke_sim(kbd_dev, mods, key); 224 238 } 225 239 } 226 240 227 void kbd_ctl_set_ind(unsigned mods)241 static void gxe_fb_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 228 242 { 229 243 (void) mods; -
uspace/srv/hid/input/ctl/pc.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ … … 43 43 #include <gsp.h> 44 44 45 static void pc_ctl_parse(sysarg_t); 46 static int pc_ctl_init(kbd_dev_t *); 47 static void pc_ctl_set_ind(kbd_dev_t *, unsigned int); 48 49 kbd_ctl_ops_t pc_ctl = { 50 .parse = pc_ctl_parse, 51 .init = pc_ctl_init, 52 .set_ind = pc_ctl_set_ind 53 }; 54 45 55 enum dec_state { 46 56 ds_s, … … 64 74 65 75 static enum dec_state ds; 76 static kbd_dev_t *kbd_dev; 66 77 67 78 static int scanmap_simple[] = { … … 197 208 }; 198 209 199 int kbd_ctl_init(void)210 static int pc_ctl_init(kbd_dev_t *kdev) 200 211 { 212 kbd_dev = kdev; 201 213 ds = ds_s; 202 214 return 0; 203 215 } 204 216 205 void kbd_ctl_parse_scancode(int scancode)217 static void pc_ctl_parse(sysarg_t scancode) 206 218 { 207 console_ev_type_t type;219 kbd_event_type_t type; 208 220 unsigned int key; 209 221 int *map; … … 245 257 } 246 258 247 if ((s cancode < 0) || ((size_t) scancode >= map_length))259 if ((size_t) scancode >= map_length) 248 260 return; 249 261 250 262 key = map[scancode]; 251 263 if (key != 0) 252 kbd_push_ev (type, key);264 kbd_push_event(kbd_dev, type, key); 253 265 } 254 266 255 void kbd_ctl_set_ind(unsigned mods)267 static void pc_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 256 268 { 257 269 uint8_t b; … … 265 277 b = b | LI_SCROLL; 266 278 267 kbd_port_write(KBD_CMD_SET_LEDS);268 kbd_port_write(b);279 (*kbd_dev->port_ops->write)(KBD_CMD_SET_LEDS); 280 (*kbd_dev->port_ops->write)(b); 269 281 } 270 282 -
uspace/srv/hid/input/ctl/stty.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 28 28 29 29 /** @addtogroup kbd_ctl 30 * @ingroup kbd30 * @ingroup input 31 31 * @{ 32 32 */ 33 33 /** 34 34 * @file 35 * @brief Serial TTY-like keyboard controller driver. 35 * @brief Serial TTY-like keyboard controller driver. 36 * 37 * Keyboard emulation on a serial terminal. 36 38 */ 37 39 … … 39 41 #include <io/keycode.h> 40 42 #include <kbd_ctl.h> 43 #include <kbd_port.h> 41 44 #include <gsp.h> 42 45 #include <stroke.h> 43 46 47 static void stty_ctl_parse(sysarg_t); 48 static int stty_ctl_init(kbd_dev_t *); 49 static void stty_ctl_set_ind(kbd_dev_t *, unsigned int); 50 51 kbd_ctl_ops_t stty_ctl = { 52 .parse = stty_ctl_parse, 53 .init = stty_ctl_init, 54 .set_ind = stty_ctl_set_ind 55 }; 56 57 static kbd_dev_t *kbd_dev; 58 44 59 /** Scancode parser */ 45 60 static gsp_t sp; … … 50 65 #include <stdio.h> 51 66 52 int seq_defs[] = { 67 /** 68 * Sequnece definitions are primarily for Xterm. Additionally we define 69 * sequences that are unique to Gnome terminal -- most are the same but 70 * some differ. 71 */ 72 static int seq_defs[] = { 53 73 /* Not shifted */ 54 74 … … 68 88 0, KC_MINUS, 0x2d, GSP_END, 69 89 0, KC_EQUALS, 0x3d, GSP_END, 90 70 91 0, KC_BACKSPACE, 0x08, GSP_END, 71 92 … … 203 224 0, KC_RIGHT, 0x1b, 0x5b, 0x43, GSP_END, 204 225 226 /* 227 * Sequences specific to Gnome terminal 228 */ 229 0, KC_BACKSPACE, 0x7f, GSP_END, /* ASCII DEL */ 230 0, KC_HOME, 0x1b, 0x4f, 0x48, GSP_END, 231 0, KC_END, 0x1b, 0x4f, 0x46, GSP_END, 232 205 233 0, 0 206 234 }; 207 235 208 int kbd_ctl_init(void)236 static int stty_ctl_init(kbd_dev_t *kdev) 209 237 { 238 kbd_dev = kdev; 210 239 ds = 0; 211 240 … … 214 243 } 215 244 216 void kbd_ctl_parse_scancode(int scancode)245 static void stty_ctl_parse(sysarg_t scancode) 217 246 { 218 247 unsigned mods, key; … … 220 249 ds = gsp_step(&sp, ds, scancode, &mods, &key); 221 250 if (key != 0) { 222 stroke_sim( mods, key);251 stroke_sim(kbd_dev, mods, key); 223 252 } 224 253 } 225 254 226 void kbd_ctl_set_ind(unsigned mods)255 static void stty_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 227 256 { 228 257 (void) mods; -
uspace/srv/hid/input/ctl/sun.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2006 Jakub Jermar 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 28 29 29 30 /** @addtogroup kbd_ctl 30 * @ingroup kbd31 * @ingroup input 31 32 * @{ 32 33 */ 33 34 /** 34 35 * @file 35 * @brief Sun keyboard controller driver.36 * @brief Sun keyboard controller driver. 36 37 */ 37 38 … … 40 41 #include <io/keycode.h> 41 42 #include <kbd_ctl.h> 43 #include <kbd_port.h> 44 45 static void sun_ctl_parse(sysarg_t); 46 static int sun_ctl_init(kbd_dev_t *); 47 static void sun_ctl_set_ind(kbd_dev_t *, unsigned int); 48 49 kbd_ctl_ops_t sun_ctl = { 50 .parse = sun_ctl_parse, 51 .init = sun_ctl_init, 52 .set_ind = sun_ctl_set_ind 53 }; 54 55 static kbd_dev_t *kbd_dev; 42 56 43 57 #define KBD_KEY_RELEASE 0x80 … … 46 60 static int scanmap_simple[]; 47 61 48 int kbd_ctl_init(void)62 static int sun_ctl_init(kbd_dev_t *kdev) 49 63 { 64 kbd_dev = kdev; 50 65 return 0; 51 66 } 52 67 53 void kbd_ctl_parse_scancode(int scancode)68 static void sun_ctl_parse(sysarg_t scancode) 54 69 { 55 console_ev_type_t type;70 kbd_event_type_t type; 56 71 unsigned int key; 57 72 58 if (scancode < 0 || scancode>= 0x100)73 if (scancode >= 0x100) 59 74 return; 60 75 … … 71 86 key = scanmap_simple[scancode]; 72 87 if (key != 0) 73 kbd_push_ev (type, key);88 kbd_push_event(kbd_dev, type, key); 74 89 } 75 90 76 void kbd_ctl_set_ind(unsigned mods)91 static void sun_ctl_set_ind(kbd_dev_t *kdev, unsigned mods) 77 92 { 78 93 (void) mods; -
uspace/srv/hid/input/generic/gsp.c
r52a79081 ra33f0a6 29 29 /** 30 30 * @addtogroup kbdgen generic 31 * @ingroup kbd31 * @ingroup input 32 32 * @{ 33 33 */ … … 104 104 if (key == 0) break; 105 105 106 /* Insert one sequence. */ 106 /* Insert one sequence. */ 107 107 rc = gsp_insert_seq(p, dp, mods, key); 108 108 if (rc != 0) … … 197 197 198 198 if (t == NULL) { 199 printf("gsp_step: not found\n"); 199 printf("gsp_step: not found, state=%d, input=0x%x\n", 200 state, input); 200 201 *mods = 0; 201 202 *key = 0; … … 205 206 *mods = t->out_mods; 206 207 *key = t->out_key; 208 207 209 return t->new_state; 208 210 } -
uspace/srv/hid/input/generic/stroke.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @{ 31 31 */ … … 52 52 53 53 /** Simulate keystroke using sequences of key presses and releases. */ 54 void stroke_sim( unsigned mod, unsigned key)54 void stroke_sim(kbd_dev_t *kdev, unsigned mod, unsigned key) 55 55 { 56 56 int i; … … 60 60 while (mods_keys[i][0] != 0) { 61 61 if (mod & mods_keys[i][0]) { 62 kbd_push_ev (KEY_PRESS, mods_keys[i][1]);62 kbd_push_event(kdev, KEY_PRESS, mods_keys[i][1]); 63 63 } 64 64 ++i; … … 67 67 /* Simulate key press and release. */ 68 68 if (key != 0) { 69 kbd_push_ev (KEY_PRESS, key);70 kbd_push_ev (KEY_RELEASE, key);69 kbd_push_event(kdev, KEY_PRESS, key); 70 kbd_push_event(kdev, KEY_RELEASE, key); 71 71 } 72 72 … … 75 75 while (mods_keys[i][0] != 0) { 76 76 if (mod & mods_keys[i][0]) { 77 kbd_push_ev (KEY_RELEASE, mods_keys[i][1]);77 kbd_push_event(kdev, KEY_RELEASE, mods_keys[i][1]); 78 78 } 79 79 ++i; -
uspace/srv/hid/input/include/gsp.h
r52a79081 ra33f0a6 27 27 */ 28 28 29 /** @addtogroup kbdgen generic29 /** @addtogroup inputgen generic 30 30 * @brief Generic scancode parser. 31 * @ingroup kbd31 * @ingroup input 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ -
uspace/srv/hid/input/include/input.h
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 27 28 */ 28 29 29 /** @addtogroup kbdgen generic30 * @brief HelenOS generic uspace keyboard handler.31 * @ingroup kbd30 /** @addtogroup inputgen generic 31 * @brief HelenOS input server. 32 * @ingroup input 32 33 * @{ 33 34 */ … … 35 36 */ 36 37 37 #ifndef KBD_KBD_H_38 #define KBD_KBD_H_38 #ifndef INPUT_H_ 39 #define INPUT_H_ 39 40 40 41 #include <bool.h> 41 42 43 #define NAME "input" 44 #define NAMESPACE "hid" 45 42 46 extern bool irc_service; 43 47 extern int irc_phone; 44 45 extern void kbd_push_scancode(int);46 extern void kbd_push_ev(int, unsigned int);47 48 48 49 #endif -
uspace/srv/hid/input/include/kbd_ctl.h
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbdgen generic30 * @brief HelenOS generic uspace keyboard handler.31 * @ingroup kbd29 /** @addtogroup inputgen generic 30 * @brief Keyboard controller driver interface. 31 * @ingroup input 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ … … 38 38 #define KBD_CTL_H_ 39 39 40 extern void kbd_ctl_parse_scancode(int); 41 extern int kbd_ctl_init(void); 42 extern void kbd_ctl_set_ind(unsigned); 40 #include <kbd_port.h> 41 42 struct kbd_dev; 43 44 typedef struct kbd_ctl_ops { 45 void (*parse)(sysarg_t); 46 int (*init)(struct kbd_dev *); 47 void (*set_ind)(struct kbd_dev *, unsigned int); 48 } kbd_ctl_ops_t; 49 50 extern kbd_ctl_ops_t apple_ctl; 51 extern kbd_ctl_ops_t gxe_fb_ctl; 52 extern kbd_ctl_ops_t kbdev_ctl; 53 extern kbd_ctl_ops_t pc_ctl; 54 extern kbd_ctl_ops_t stty_ctl; 55 extern kbd_ctl_ops_t sun_ctl; 43 56 44 57 #endif … … 46 59 /** 47 60 * @} 48 */ 49 61 */ -
uspace/srv/hid/input/include/mouse_port.h
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup inputgen generic 30 * @brief Mouse port driver interface. 31 * @ingroup input 31 32 * @{ 32 33 */ … … 39 40 #include <sys/types.h> 40 41 41 extern int mouse_port_init(void); 42 extern void mouse_port_yield(void); 43 extern void mouse_port_reclaim(void); 44 extern void mouse_port_write(uint8_t); 42 struct mouse_dev; 43 44 typedef struct mouse_port_ops { 45 int (*init)(struct mouse_dev *); 46 void (*yield)(void); 47 void (*reclaim)(void); 48 void (*write)(uint8_t); 49 } mouse_port_ops_t; 50 51 extern mouse_port_ops_t adb_mouse_port; 52 extern mouse_port_ops_t chardev_mouse_port; 45 53 46 54 #endif … … 48 56 /** 49 57 * @} 50 */ 51 58 */ -
uspace/srv/hid/input/include/mouse_proto.h
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 30 * @brief 29 /** @addtogroup inputgen generic 30 * @brief Mouse protocol driver interface. 31 * @ingroup input 31 32 * @{ 32 33 */ … … 37 38 #define MOUSE_PROTO_H_ 38 39 39 extern void mouse_proto_parse_byte(int); 40 extern int mouse_proto_init(void); 40 #include <mouse_port.h> 41 42 struct mouse_dev; 43 44 typedef struct mouse_proto_ops { 45 void (*parse)(sysarg_t); 46 int (*init)(struct mouse_dev *); 47 } mouse_proto_ops_t; 48 49 extern mouse_proto_ops_t adb_proto; 50 extern mouse_proto_ops_t ps2_proto; 51 extern mouse_proto_ops_t mousedev_proto; 41 52 42 53 #endif -
uspace/srv/hid/input/include/stroke.h
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbdgen generic29 /** @addtogroup inputgen generic 30 30 * @brief Generic scancode parser. 31 * @ingroup kbd31 * @ingroup input 32 32 * @{ 33 33 */ … … 38 38 #define KBD_STROKE_H_ 39 39 40 extern void stroke_sim(unsigned, unsigned); 40 #include <kbd.h> 41 42 extern void stroke_sim(kbd_dev_t *, unsigned, unsigned); 41 43 42 44 #endif -
uspace/srv/hid/input/layout/cz.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief Czech QWERTZ layout. 31 31 * @{ 32 32 */ 33 33 34 #include <kbd.h> 34 #include <errno.h> 35 #include <input.h> 35 36 #include <io/console.h> 36 37 #include <io/keycode.h> 37 38 #include <bool.h> 38 39 #include <layout.h> 39 40 static void layout_reset(void); 41 static wchar_t layout_parse_ev(console_event_t *ev); 40 #include <stdlib.h> 41 42 static int cz_create(layout_t *); 43 static void cz_destroy(layout_t *); 44 static wchar_t cz_parse_ev(layout_t *, kbd_event_t *ev); 42 45 43 46 enum m_state { … … 47 50 }; 48 51 49 static enum m_state mstate; 50 51 layout_op_t cz_op = { 52 layout_reset, 53 layout_parse_ev 52 typedef struct { 53 enum m_state mstate; 54 } layout_cz_t; 55 56 layout_ops_t cz_ops = { 57 .create = cz_create, 58 .destroy = cz_destroy, 59 .parse_ev = cz_parse_ev 54 60 }; 55 61 … … 273 279 } 274 280 275 static wchar_t parse_ms_hacek( console_event_t *ev)281 static wchar_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev) 276 282 { 277 283 wchar_t c; 278 284 279 mstate = ms_start;285 cz_state->mstate = ms_start; 280 286 281 287 /* Produce no characters when Ctrl or Alt is pressed. */ … … 291 297 } 292 298 293 static wchar_t parse_ms_carka( console_event_t *ev)299 static wchar_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev) 294 300 { 295 301 wchar_t c; 296 302 297 mstate = ms_start;303 cz_state->mstate = ms_start; 298 304 299 305 /* Produce no characters when Ctrl or Alt is pressed. */ … … 309 315 } 310 316 311 static wchar_t parse_ms_start( console_event_t *ev)317 static wchar_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev) 312 318 { 313 319 wchar_t c; … … 319 325 if (ev->key == KC_EQUALS) { 320 326 if ((ev->mods & KM_SHIFT) != 0) 321 mstate = ms_hacek;327 cz_state->mstate = ms_hacek; 322 328 else 323 mstate = ms_carka;329 cz_state->mstate = ms_carka; 324 330 325 331 return 0; … … 379 385 } 380 386 381 static void layout_reset(void) 382 { 383 mstate = ms_start; 384 } 385 386 static wchar_t layout_parse_ev(console_event_t *ev) 387 { 387 static int cz_create(layout_t *state) 388 { 389 layout_cz_t *cz_state; 390 391 cz_state = malloc(sizeof(layout_cz_t)); 392 if (cz_state == NULL) { 393 printf("%s: Out of memory.\n", NAME); 394 return ENOMEM; 395 } 396 397 cz_state->mstate = ms_start; 398 state->layout_priv = (void *) cz_state; 399 400 return EOK; 401 } 402 403 static void cz_destroy(layout_t *state) 404 { 405 free(state->layout_priv); 406 } 407 408 static wchar_t cz_parse_ev(layout_t *state, kbd_event_t *ev) 409 { 410 layout_cz_t *cz_state = (layout_cz_t *) state->layout_priv; 411 388 412 if (ev->type != KEY_PRESS) 389 413 return 0; … … 392 416 return 0; 393 417 394 switch ( mstate) {418 switch (cz_state->mstate) { 395 419 case ms_start: 396 return parse_ms_start( ev);420 return parse_ms_start(cz_state, ev); 397 421 case ms_hacek: 398 return parse_ms_hacek( ev);422 return parse_ms_hacek(cz_state, ev); 399 423 case ms_carka: 400 return parse_ms_carka( ev);424 return parse_ms_carka(cz_state, ev); 401 425 } 402 426 -
uspace/srv/hid/input/layout/us_dvorak.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief US Dvorak Simplified Keyboard layout. 31 31 * @{ 32 32 */ 33 33 34 #include <errno.h> 34 35 #include <kbd.h> 35 36 #include <io/console.h> … … 37 38 #include <layout.h> 38 39 39 static void layout_reset(void); 40 static wchar_t layout_parse_ev(console_event_t *ev); 41 42 layout_op_t us_dvorak_op = { 43 layout_reset, 44 layout_parse_ev 40 static int us_dvorak_create(layout_t *); 41 static void us_dvorak_destroy(layout_t *); 42 static wchar_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev); 43 44 layout_ops_t us_dvorak_ops = { 45 .create = us_dvorak_create, 46 .destroy = us_dvorak_destroy, 47 .parse_ev = us_dvorak_parse_ev 45 48 }; 46 49 … … 206 209 } 207 210 208 static void layout_reset(void) 209 { 210 } 211 212 static wchar_t layout_parse_ev(console_event_t *ev) 211 static int us_dvorak_create(layout_t *state) 212 { 213 return EOK; 214 } 215 216 static void us_dvorak_destroy(layout_t *state) 217 { 218 } 219 220 static wchar_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev) 213 221 { 214 222 wchar_t c; -
uspace/srv/hid/input/layout/us_qwerty.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup kbd29 /** @addtogroup input 30 30 * @brief US QWERTY layout. 31 31 * @{ 32 */ 33 32 */ 33 34 #include <errno.h> 34 35 #include <kbd.h> 35 36 #include <io/console.h> … … 37 38 #include <layout.h> 38 39 39 static void layout_reset(void); 40 static wchar_t layout_parse_ev(console_event_t *ev); 41 42 layout_op_t us_qwerty_op = { 43 layout_reset, 44 layout_parse_ev 40 static int us_qwerty_create(layout_t *); 41 static void us_qwerty_destroy(layout_t *); 42 static wchar_t us_qwerty_parse_ev(layout_t *, kbd_event_t *ev); 43 44 layout_ops_t us_qwerty_ops = { 45 .create = us_qwerty_create, 46 .destroy = us_qwerty_destroy, 47 .parse_ev = us_qwerty_parse_ev 45 48 }; 46 49 … … 200 203 } 201 204 202 static void layout_reset(void) 203 { 204 } 205 206 static wchar_t layout_parse_ev(console_event_t *ev) 205 static int us_qwerty_create(layout_t *state) 206 { 207 return EOK; 208 } 209 210 static void us_qwerty_destroy(layout_t *state) 211 { 212 } 213 214 static wchar_t us_qwerty_parse_ev(layout_t *state, kbd_event_t *ev) 207 215 { 208 216 wchar_t c; -
uspace/srv/hid/input/port/adb.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 34 * @brief ADB keyboard port driver. … … 37 37 #include <ipc/adb.h> 38 38 #include <async.h> 39 #include <input.h> 39 40 #include <kbd_port.h> 40 41 #include <kbd.h> … … 42 43 #include <fcntl.h> 43 44 #include <errno.h> 45 #include <devmap.h> 44 46 45 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall );47 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 46 48 static void adb_kbd_reg0_data(uint16_t data); 47 49 48 static int dev_phone; 50 static int adb_port_init(kbd_dev_t *); 51 static void adb_port_yield(void); 52 static void adb_port_reclaim(void); 53 static void adb_port_write(uint8_t data); 49 54 50 #define NAME "kbd" 55 kbd_port_ops_t adb_port = { 56 .init = adb_port_init, 57 .yield = adb_port_yield, 58 .reclaim = adb_port_reclaim, 59 .write = adb_port_write 60 }; 51 61 52 int kbd_port_init(void) 62 static kbd_dev_t *kbd_dev; 63 static async_sess_t *dev_sess; 64 65 static int adb_port_init(kbd_dev_t *kdev) 53 66 { 54 const char *input = "/dev/adb/kbd"; 55 int input_fd; 56 57 printf(NAME ": open %s\n", input); 58 59 input_fd = open(input, O_RDONLY); 60 if (input_fd < 0) { 61 printf(NAME ": Failed opening %s (%d)\n", input, input_fd); 62 return false; 67 const char *dev = "adb/kbd"; 68 devmap_handle_t handle; 69 async_exch_t *exch; 70 int rc; 71 72 kbd_dev = kdev; 73 74 rc = devmap_device_get_handle(dev, &handle, 0); 75 if (rc != EOK) 76 return rc; 77 78 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0); 79 if (dev_sess == NULL) { 80 printf("%s: Failed to connect to device\n", NAME); 81 return ENOENT; 63 82 } 64 65 dev_phone = fd_phone(input_fd); 66 if (dev_phone < 0) { 67 printf(NAME ": Failed to connect to device\n"); 68 return false; 83 84 exch = async_exchange_begin(dev_sess); 85 if (exch == NULL) { 86 printf("%s: Failed starting exchange with device\n", NAME); 87 async_hangup(dev_sess); 88 return ENOMEM; 69 89 } 70 90 71 91 /* NB: The callback connection is slotted for removal */ 72 if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 73 printf(NAME ": Failed to create callback from device\n"); 74 return false; 92 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 93 async_exchange_end(exch); 94 if (rc != EOK) { 95 printf("%s: Failed to create callback from device\n", NAME); 96 async_hangup(dev_sess); 97 return rc; 75 98 } 76 77 return 0;99 100 return EOK; 78 101 } 79 102 80 void kbd_port_yield(void)103 static void adb_port_yield(void) 81 104 { 82 105 } 83 106 84 void kbd_port_reclaim(void)107 static void adb_port_reclaim(void) 85 108 { 86 109 } 87 110 88 void kbd_port_write(uint8_t data)111 static void adb_port_write(uint8_t data) 89 112 { 90 113 /*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/ 91 114 } 92 115 93 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall )116 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 94 117 { 95 118 /* Ignore parameters, the connection is already opened */ … … 100 123 101 124 int retval; 102 103 switch (IPC_GET_IMETHOD(call)) { 104 case IPC_M_PHONE_HUNGUP: 125 126 if (!IPC_GET_IMETHOD(call)) { 105 127 /* TODO: Handle hangup */ 106 128 return; 129 } 130 131 switch (IPC_GET_IMETHOD(call)) { 107 132 case ADB_REG_NOTIF: 108 133 adb_kbd_reg0_data(IPC_GET_ARG1(call)); … … 117 142 static void adb_kbd_reg0_data(uint16_t data) 118 143 { 119 uint8_t b0, b1; 120 121 b0 = (data >> 8) & 0xff; 122 b1 = data & 0xff; 123 144 uint8_t b0 = (data >> 8) & 0xff; 145 uint8_t b1 = data & 0xff; 146 124 147 if (b0 != 0xff) 125 kbd_push_scancode(b0); 148 kbd_push_data(kbd_dev, b0); 149 126 150 if (b1 != 0xff) 127 kbd_push_ scancode(b1);151 kbd_push_data(kbd_dev, b1); 128 152 } 129 153 -
uspace/srv/hid/input/port/adb_mouse.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09 Jiri Svoboda2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 29 /** @addtogroup mouse_port 30 * @ingroup mouse 30 31 * @{ 31 */ 32 */ 32 33 /** @file 33 * @brief 34 * @brief ADB mouse port driver. 34 35 */ 35 36 36 #include <ipc/ char.h>37 #include <ipc/adb.h> 37 38 #include <async.h> 38 #include <vfs/vfs.h> 39 #include <fcntl.h> 39 #include <input.h> 40 #include <mouse_port.h> 41 #include <mouse.h> 40 42 #include <errno.h> 43 #include <devmap.h> 41 44 42 #include <char_mouse.h> 43 #include <mouse_port.h> 45 static mouse_dev_t *mouse_dev; 46 static async_sess_t *dev_sess; 44 47 45 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall); 46 47 static int dev_phone; 48 49 #define NAME "char_mouse" 50 51 int mouse_port_init(void) 52 { 53 const char *input = "/dev/char/ps2b"; 54 int input_fd; 55 56 printf(NAME ": open %s\n", input); 57 58 input_fd = open(input, O_RDONLY); 59 if (input_fd < 0) { 60 printf(NAME ": Failed opening %s (%d)\n", input, input_fd); 61 return false; 62 } 63 64 dev_phone = fd_phone(input_fd); 65 if (dev_phone < 0) { 66 printf(NAME ": Failed to connect to device\n"); 67 return false; 68 } 69 70 /* NB: The callback connection is slotted for removal */ 71 if (async_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) { 72 printf(NAME ": Failed to create callback from device\n"); 73 return false; 74 } 75 76 return 0; 77 } 78 79 void mouse_port_yield(void) 80 { 81 } 82 83 void mouse_port_reclaim(void) 84 { 85 } 86 87 void mouse_port_write(uint8_t data) 88 { 89 async_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 90 } 91 92 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall) 48 static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 93 49 { 94 50 /* Ignore parameters, the connection is already opened */ 95 51 while (true) { 96 97 52 ipc_call_t call; 98 53 ipc_callid_t callid = async_get_call(&call); 99 54 100 55 int retval; 101 102 switch (IPC_GET_IMETHOD(call)) { 103 case IPC_M_PHONE_HUNGUP: 56 57 if (!IPC_GET_IMETHOD(call)) { 104 58 /* TODO: Handle hangup */ 105 59 return; 106 case IPC_FIRST_USER_METHOD: 107 mouse_handle_byte(IPC_GET_ARG1(call)); 60 } 61 62 switch (IPC_GET_IMETHOD(call)) { 63 case ADB_REG_NOTIF: 64 mouse_push_data(mouse_dev, IPC_GET_ARG1(call)); 108 65 break; 109 66 default: 110 67 retval = ENOENT; 111 68 } 69 112 70 async_answer_0(callid, retval); 113 71 } 114 72 } 115 73 74 static int adb_port_init(mouse_dev_t *mdev) 75 { 76 const char *dev = "adb/mouse"; 77 78 mouse_dev = mdev; 79 80 devmap_handle_t handle; 81 int rc = devmap_device_get_handle(dev, &handle, 0); 82 if (rc != EOK) 83 return rc; 84 85 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0); 86 if (dev_sess == NULL) { 87 printf("%s: Failed to connect to device\n", NAME); 88 return ENOENT; 89 } 90 91 async_exch_t *exch = async_exchange_begin(dev_sess); 92 if (exch == NULL) { 93 printf("%s: Failed starting exchange with device\n", NAME); 94 async_hangup(dev_sess); 95 return ENOMEM; 96 } 97 98 /* NB: The callback connection is slotted for removal */ 99 rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL); 100 async_exchange_end(exch); 101 if (rc != EOK) { 102 printf("%s: Failed to create callback from device\n", NAME); 103 async_hangup(dev_sess); 104 return rc; 105 } 106 107 return EOK; 108 } 109 110 static void adb_port_yield(void) 111 { 112 } 113 114 static void adb_port_reclaim(void) 115 { 116 } 117 118 static void adb_port_write(uint8_t data) 119 { 120 } 121 122 mouse_port_ops_t adb_mouse_port = { 123 .init = adb_port_init, 124 .yield = adb_port_yield, 125 .reclaim = adb_port_reclaim, 126 .write = adb_port_write 127 }; 128 116 129 /** 117 130 * @} -
uspace/srv/hid/input/port/chardev.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 30 30 * @ingroup kbd 31 31 * @{ 32 */ 32 */ 33 33 /** @file 34 34 * @brief Chardev keyboard port driver. … … 37 37 #include <ipc/char.h> 38 38 #include <async.h> 39 #include <input.h> 39 40 #include <kbd_port.h> 40 41 #include <kbd.h> 41 #include <vfs/vfs.h> 42 #include <sys/stat.h> 43 #include <fcntl.h> 42 #include <devmap.h> 44 43 #include <errno.h> 44 #include <stdio.h> 45 45 46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall );46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 47 47 48 static int dev_phone; 48 static int chardev_port_init(kbd_dev_t *); 49 static void chardev_port_yield(void); 50 static void chardev_port_reclaim(void); 51 static void chardev_port_write(uint8_t data); 49 52 50 #define NAME "kbd" 53 kbd_port_ops_t chardev_port = { 54 .init = chardev_port_init, 55 .yield = chardev_port_yield, 56 .reclaim = chardev_port_reclaim, 57 .write = chardev_port_write 58 }; 59 60 static kbd_dev_t *kbd_dev; 61 static async_sess_t *dev_sess; 51 62 52 63 /** List of devices to try connecting to. */ 53 64 static const char *in_devs[] = { 54 " /dev/char/ps2a",55 " /dev/char/s3c24ser"65 "char/ps2a", 66 "char/s3c24ser" 56 67 }; 57 68 58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);69 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 59 70 60 int kbd_port_init(void)71 static int chardev_port_init(kbd_dev_t *kdev) 61 72 { 62 int input_fd; 63 int i; 64 65 input_fd = -1; 73 devmap_handle_t handle; 74 async_exch_t *exch; 75 unsigned int i; 76 int rc; 77 78 kbd_dev = kdev; 79 66 80 for (i = 0; i < num_devs; i++) { 67 struct stat s; 68 69 if (stat(in_devs[i], &s) == EOK) 81 rc = devmap_device_get_handle(in_devs[i], &handle, 0); 82 if (rc == EOK) 70 83 break; 71 84 } 72 85 73 86 if (i >= num_devs) { 74 printf( NAME ": Could not find any suitable input device.\n");87 printf("%s: Could not find any suitable input device\n", NAME); 75 88 return -1; 76 89 } 77 78 input_fd = open(in_devs[i], O_RDONLY); 79 if (input_fd < 0) { 80 printf(NAME ": failed opening device %s (%d).\n", in_devs[i], 81 input_fd); 90 91 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 92 IPC_FLAG_BLOCKING); 93 if (dev_sess == NULL) { 94 printf("%s: Failed connecting to device\n", NAME); 95 return ENOENT; 96 } 97 98 exch = async_exchange_begin(dev_sess); 99 if (exch == NULL) { 100 printf("%s: Failed starting exchange with device\n", NAME); 101 async_hangup(dev_sess); 102 return ENOMEM; 103 } 104 105 /* NB: The callback connection is slotted for removal */ 106 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 107 async_exchange_end(exch); 108 109 if (rc != 0) { 110 printf("%s: Failed to create callback from device\n", NAME); 111 async_hangup(dev_sess); 82 112 return -1; 83 113 } 84 85 dev_phone = fd_phone(input_fd); 86 if (dev_phone < 0) { 87 printf(NAME ": Failed connecting to device\n"); 88 return -1; 89 } 90 91 /* NB: The callback connection is slotted for removal */ 92 if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 93 printf(NAME ": Failed to create callback from device\n"); 94 return -1; 95 } 96 114 97 115 return 0; 98 116 } 99 117 100 void kbd_port_yield(void)118 static void chardev_port_yield(void) 101 119 { 102 120 } 103 121 104 void kbd_port_reclaim(void)122 static void chardev_port_reclaim(void) 105 123 { 106 124 } 107 125 108 void kbd_port_write(uint8_t data)126 static void chardev_port_write(uint8_t data) 109 127 { 110 async_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 128 async_exch_t *exch = async_exchange_begin(dev_sess); 129 if (exch == NULL) { 130 printf("%s: Failed starting exchange with device\n", NAME); 131 return; 132 } 133 134 async_msg_1(exch, CHAR_WRITE_BYTE, data); 135 async_exchange_end(exch); 111 136 } 112 137 113 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall )138 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 114 139 { 115 140 /* Ignore parameters, the connection is already opened */ … … 118 143 ipc_call_t call; 119 144 ipc_callid_t callid = async_get_call(&call); 145 146 if (!IPC_GET_IMETHOD(call)) { 147 /* TODO: Handle hangup */ 148 return; 149 } 120 150 121 151 int retval; 122 152 123 153 switch (IPC_GET_IMETHOD(call)) { 124 case IPC_M_PHONE_HUNGUP:125 /* TODO: Handle hangup */126 return;127 154 case CHAR_NOTIF_BYTE: 128 kbd_push_ scancode(IPC_GET_ARG1(call));155 kbd_push_data(kbd_dev, IPC_GET_ARG1(call)); 129 156 break; 130 157 default: -
uspace/srv/hid/input/port/gxemul.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2007 Michal Kebrt 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 42 43 #include <errno.h> 43 44 45 static int gxemul_port_init(kbd_dev_t *); 46 static void gxemul_port_yield(void); 47 static void gxemul_port_reclaim(void); 48 static void gxemul_port_write(uint8_t data); 49 50 kbd_port_ops_t gxemul_port = { 51 .init = gxemul_port_init, 52 .yield = gxemul_port_yield, 53 .reclaim = gxemul_port_reclaim, 54 .write = gxemul_port_write 55 }; 56 57 static kbd_dev_t *kbd_dev; 58 44 59 static irq_cmd_t gxemul_cmds[] = { 45 60 { … … 61 76 62 77 /** Initializes keyboard handler. */ 63 int kbd_port_init(void)78 static int gxemul_port_init(kbd_dev_t *kdev) 64 79 { 80 kbd_dev = kdev; 81 65 82 sysarg_t addr; 66 83 if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK) … … 77 94 } 78 95 79 void kbd_port_yield(void)96 static void gxemul_port_yield(void) 80 97 { 81 98 } 82 99 83 void kbd_port_reclaim(void)100 static void gxemul_port_reclaim(void) 84 101 { 85 102 } 86 103 87 void kbd_port_write(uint8_t data)104 static void gxemul_port_write(uint8_t data) 88 105 { 89 106 (void) data; … … 91 108 92 109 /** Process data sent when a key is pressed. 93 *94 * @param keybuffer Buffer of pressed keys.95 * @param call IPC call.96 110 * 97 * @return Always 1. 111 * @param keybuffer Buffer of pressed keys. 112 * @param call IPC call. 113 * 98 114 */ 99 115 static void gxemul_irq_handler(ipc_callid_t iid, ipc_call_t *call) 100 116 { 101 int scan_code = IPC_GET_ARG2(*call); 102 103 kbd_push_scancode(scan_code); 117 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 104 118 } 105 119 -
uspace/srv/hid/input/port/msim.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 42 43 #include <errno.h> 43 44 44 irq_cmd_t msim_cmds[] = { 45 static int msim_port_init(kbd_dev_t *); 46 static void msim_port_yield(void); 47 static void msim_port_reclaim(void); 48 static void msim_port_write(uint8_t data); 49 50 kbd_port_ops_t msim_port = { 51 .init = msim_port_init, 52 .yield = msim_port_yield, 53 .reclaim = msim_port_reclaim, 54 .write = msim_port_write 55 }; 56 57 static kbd_dev_t *kbd_dev; 58 59 static irq_cmd_t msim_cmds[] = { 45 60 { 46 61 .cmd = CMD_PIO_READ_8, … … 51 66 .cmd = CMD_ACCEPT 52 67 } 53 54 68 }; 55 69 56 irq_code_t msim_kbd = {70 static irq_code_t msim_kbd = { 57 71 sizeof(msim_cmds) / sizeof(irq_cmd_t), 58 72 msim_cmds … … 61 75 static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call); 62 76 63 int kbd_port_init(void)77 static int msim_port_init(kbd_dev_t *kdev) 64 78 { 79 kbd_dev = kdev; 80 65 81 sysarg_t vaddr; 66 82 if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK) … … 78 94 } 79 95 80 void kbd_port_yield(void)96 static void msim_port_yield(void) 81 97 { 82 98 } 83 99 84 void kbd_port_reclaim(void)100 static void msim_port_reclaim(void) 85 101 { 86 102 } 87 103 88 void kbd_port_write(uint8_t data)104 static void msim_port_write(uint8_t data) 89 105 { 90 106 (void) data; … … 93 109 static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call) 94 110 { 95 int scan_code = IPC_GET_ARG2(*call); 96 kbd_push_scancode(scan_code); 111 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 97 112 } 98 113 99 114 /** @} 100 */115 */ -
uspace/srv/hid/input/port/niagara.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2008 Pavel Rimsky 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 46 47 #include <errno.h> 47 48 49 static int niagara_port_init(kbd_dev_t *); 50 static void niagara_port_yield(void); 51 static void niagara_port_reclaim(void); 52 static void niagara_port_write(uint8_t data); 53 54 kbd_port_ops_t niagara_port = { 55 .init = niagara_port_init, 56 .yield = niagara_port_yield, 57 .reclaim = niagara_port_reclaim, 58 .write = niagara_port_write 59 }; 60 61 static kbd_dev_t *kbd_dev; 62 48 63 #define POLL_INTERVAL 10000 49 64 … … 70 85 71 86 /* virtual address of the shared buffer */ 72 input_buffer_t input_buffer;87 static input_buffer_t input_buffer; 73 88 74 89 static volatile bool polling_disabled = false; … … 79 94 * Maps the shared buffer and creates the polling thread. 80 95 */ 81 int kbd_port_init(void)96 static int niagara_port_init(kbd_dev_t *kdev) 82 97 { 98 kbd_dev = kdev; 99 83 100 sysarg_t paddr; 84 101 if (sysinfo_get_value("niagara.inbuf.address", &paddr) != EOK) … … 105 122 } 106 123 107 void kbd_port_yield(void)124 static void niagara_port_yield(void) 108 125 { 109 126 polling_disabled = true; 110 127 } 111 128 112 void kbd_port_reclaim(void)129 static void niagara_port_reclaim(void) 113 130 { 114 131 polling_disabled = false; 115 132 } 116 133 117 void kbd_port_write(uint8_t data)134 static void niagara_port_write(uint8_t data) 118 135 { 119 136 (void) data; … … 131 148 c = input_buffer->data[input_buffer->read_ptr]; 132 149 input_buffer->read_ptr = 133 ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;134 kbd_push_ scancode(c);150 ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE; 151 kbd_push_data(kbd_dev, c); 135 152 } 136 153 } 137 154 138 155 /** 139 * Thread to poll SGCNfor keypresses.156 * Thread to poll Niagara console for keypresses. 140 157 */ 141 158 static void niagara_thread_impl(void *arg) -
uspace/srv/hid/input/port/ns16550.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 37 38 #include <ipc/irc.h> 38 39 #include <async.h> 40 #include <async_obsolete.h> 39 41 #include <sysinfo.h> 42 #include <input.h> 40 43 #include <kbd.h> 41 44 #include <kbd_port.h> 42 #include <sun.h>43 45 #include <ddi.h> 44 46 #include <errno.h> 47 48 static int ns16550_port_init(kbd_dev_t *); 49 static void ns16550_port_yield(void); 50 static void ns16550_port_reclaim(void); 51 static void ns16550_port_write(uint8_t data); 52 53 kbd_port_ops_t ns16550_port = { 54 .init = ns16550_port_init, 55 .yield = ns16550_port_yield, 56 .reclaim = ns16550_port_reclaim, 57 .write = ns16550_port_write 58 }; 59 60 static kbd_dev_t *kbd_dev; 45 61 46 62 /* NS16550 registers */ … … 90 106 91 107 static uintptr_t ns16550_physical; 92 static uintptr_t ns16550_kernel; 108 static uintptr_t ns16550_kernel; 93 109 94 int ns16550_port_init(void) 110 static kbd_dev_t *kbd_dev; 111 112 static int ns16550_port_init(kbd_dev_t *kdev) 95 113 { 96 114 void *vaddr; 97 115 116 kbd_dev = kdev; 117 118 sysarg_t ns16550; 119 if (sysinfo_get_value("kbd.type.ns16550", &ns16550) != EOK) 120 return -1; 121 if (!ns16550) 122 return -1; 123 98 124 if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK) 99 125 return -1; … … 115 141 } 116 142 143 static void ns16550_port_yield(void) 144 { 145 } 146 147 static void ns16550_port_reclaim(void) 148 { 149 } 150 151 static void ns16550_port_write(uint8_t data) 152 { 153 (void) data; 154 } 155 117 156 static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call) 118 157 { 119 int scan_code = IPC_GET_ARG2(*call); 120 kbd_push_scancode(scan_code); 158 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 121 159 122 160 if (irc_service) 123 async_ msg_1(irc_phone, IRC_CLEAR_INTERRUPT,161 async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT, 124 162 IPC_GET_IMETHOD(*call)); 125 163 } -
uspace/srv/hid/input/port/pl050.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2009 Vineeth Pillai 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 46 47 #include <errno.h> 47 48 49 static int pl050_port_init(kbd_dev_t *); 50 static void pl050_port_yield(void); 51 static void pl050_port_reclaim(void); 52 static void pl050_port_write(uint8_t data); 53 54 kbd_port_ops_t pl050_port = { 55 .init = pl050_port_init, 56 .yield = pl050_port_yield, 57 .reclaim = pl050_port_reclaim, 58 .write = pl050_port_write 59 }; 60 61 static kbd_dev_t *kbd_dev; 62 48 63 #define PL050_STAT_RXFULL (1 << 4) 49 64 … … 82 97 static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call); 83 98 84 int kbd_port_init(void)99 static int pl050_port_init(kbd_dev_t *kdev) 85 100 { 101 kbd_dev = kdev; 102 86 103 sysarg_t addr; 87 104 if (sysinfo_get_value("kbd.address.status", &addr) != EOK) … … 105 122 } 106 123 107 void kbd_port_yield(void)124 static void pl050_port_yield(void) 108 125 { 109 126 } 110 127 111 void kbd_port_reclaim(void)128 static void pl050_port_reclaim(void) 112 129 { 113 130 } 114 131 115 void kbd_port_write(uint8_t data)132 static void pl050_port_write(uint8_t data) 116 133 { 117 134 (void) data; … … 120 137 static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call) 121 138 { 122 int scan_code = IPC_GET_ARG2(*call); 123 124 kbd_push_scancode(scan_code); 125 return; 139 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 126 140 } 127 141 128 142 /** 129 143 * @} 130 */ 144 */ -
uspace/srv/hid/input/port/ski.c
r52a79081 ra33f0a6 1 1 /* 2 2 * Copyright (c) 2005 Jakub Jermar 3 * Copyright (c) 20 09Jiri Svoboda3 * Copyright (c) 2011 Jiri Svoboda 4 4 * All rights reserved. 5 5 * … … 45 45 #include <bool.h> 46 46 47 static int ski_port_init(kbd_dev_t *); 48 static void ski_port_yield(void); 49 static void ski_port_reclaim(void); 50 static void ski_port_write(uint8_t data); 51 52 kbd_port_ops_t ski_port = { 53 .init = ski_port_init, 54 .yield = ski_port_yield, 55 .reclaim = ski_port_reclaim, 56 .write = ski_port_write 57 }; 58 59 static kbd_dev_t *kbd_dev; 60 47 61 #define SKI_GETCHAR 21 48 62 … … 55 69 56 70 /** Initialize Ski port driver. */ 57 int kbd_port_init(void)71 static int ski_port_init(kbd_dev_t *kdev) 58 72 { 59 73 thread_id_t tid; 60 74 int rc; 75 76 kbd_dev = kdev; 61 77 62 78 rc = thread_create(ski_thread_impl, NULL, "kbd_poll", &tid); … … 68 84 } 69 85 70 void kbd_port_yield(void)86 static void ski_port_yield(void) 71 87 { 72 88 polling_disabled = true; 73 89 } 74 90 75 void kbd_port_reclaim(void)91 static void ski_port_reclaim(void) 76 92 { 77 93 polling_disabled = false; 78 94 } 79 95 80 void kbd_port_write(uint8_t data)96 static void ski_port_write(uint8_t data) 81 97 { 82 98 (void) data; … … 94 110 if (c == 0) 95 111 break; 96 kbd_push_ scancode(c);112 kbd_push_data(kbd_dev, c); 97 113 } 98 114 … … 112 128 uint64_t ch; 113 129 130 #ifdef UARCH_ia64 114 131 asm volatile ( 115 132 "mov r15 = %1\n" … … 121 138 : "r15", "r8" 122 139 ); 123 140 #else 141 ch = 0; 142 #endif 124 143 return (int32_t) ch; 125 144 } -
uspace/srv/hid/input/proto/ps2.c
r52a79081 ra33f0a6 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2011 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup mouse 29 /** @addtogroup mouse_proto 30 * @ingroup input 30 31 * @{ 31 32 */ 32 33 /** 33 34 * @file 34 * @brief PS/2 mouseprotocol driver.35 * @brief PS/2 protocol driver. 35 36 */ 36 37 37 #include < stdio.h>38 #include <mouse.h> 38 39 #include <mouse_port.h> 39 #include <char_mouse.h>40 40 #include <mouse_proto.h> 41 42 #define BUFSIZE 343 41 44 42 #define PS2_MOUSE_OUT_INIT 0xf4 45 43 #define PS2_MOUSE_ACK 0xfa 44 45 #define BUFSIZE 3 46 46 47 47 typedef struct { … … 49 49 unsigned char data[BUFSIZE]; 50 50 struct { 51 unsigned leftbtn : 1;52 unsigned rightbtn : 1;53 unsigned middlebtn : 1;54 unsigned i sone : 1; /* Always one */55 unsigned xsign : 1;56 unsigned ysign : 1;57 unsigned xovfl : 1;58 unsigned yovfl : 1;51 unsigned int leftbtn : 1; 52 unsigned int rightbtn : 1; 53 unsigned int middlebtn : 1; 54 unsigned int isone : 1; /* Always one */ 55 unsigned int xsign : 1; 56 unsigned int ysign : 1; 57 unsigned int xovfl : 1; 58 unsigned int yovfl : 1; 59 59 unsigned char x; 60 60 unsigned char y; … … 64 64 65 65 static ps2packet_t buf; 66 static int bufpos = 0;67 static int leftbtn = 0;68 static int rightbtn = 0;69 static int middlebtn = 0;66 static unsigned int bufpos; 67 static unsigned int leftbtn; 68 static unsigned int rightbtn; 69 static unsigned int middlebtn; 70 70 71 int mouse_proto_init(void) 71 static mouse_dev_t *mouse_dev; 72 73 static int ps2_proto_init(mouse_dev_t *mdev) 72 74 { 73 mouse_port_write(PS2_MOUSE_OUT_INIT); 75 mouse_dev = mdev; 76 bufpos = 0; 77 leftbtn = 0; 78 rightbtn = 0; 79 80 mouse_dev->port_ops->write(PS2_MOUSE_OUT_INIT); 74 81 return 0; 75 82 } … … 79 86 { 80 87 int tmp; 81 88 82 89 if (!sign) 83 90 return data; 84 85 tmp = ((unsigned char) ~data) + 1;91 92 tmp = ((unsigned char) ~data) + 1; 86 93 return -tmp; 87 94 } 88 95 89 96 /** Process mouse data */ 90 void mouse_proto_parse_byte(int data)97 static void ps2_proto_parse(sysarg_t data) 91 98 { 92 99 int x, y; 93 100 94 101 /* Check that we have not lost synchronization */ 95 102 if (bufpos == 0 && !(data & 0x8)) 96 103 return; /* Synchro lost, ignore byte */ 97 104 98 105 buf.u.data[bufpos++] = data; 99 106 if (bufpos == BUFSIZE) { 100 107 bufpos = 0; 101 108 102 109 if (buf.u.val.leftbtn ^ leftbtn) { 103 110 leftbtn = buf.u.val.leftbtn; 104 mouse_ ev_btn(1, leftbtn);111 mouse_push_event_button(mouse_dev, 1, leftbtn); 105 112 } 106 113 107 114 if (buf.u.val.rightbtn ^ rightbtn) { 108 115 rightbtn = buf.u.val.rightbtn; 109 mouse_ ev_btn(2, rightbtn);116 mouse_push_event_button(mouse_dev, 2, rightbtn); 110 117 } 111 118 112 119 if (buf.u.val.middlebtn ^ middlebtn) { 113 120 middlebtn = buf.u.val.middlebtn; 114 mouse_ ev_btn(3, middlebtn);121 mouse_push_event_button(mouse_dev, 3, middlebtn); 115 122 } 123 124 x = bit9toint(buf.u.val.xsign, buf.u.val.x); 125 y = -bit9toint(buf.u.val.ysign, buf.u.val.y); 126 127 if (x != 0 || y != 0) 128 mouse_push_event_move(mouse_dev, x, y); 129 } 130 } 116 131 117 x = bit9toint(buf.u.val.xsign, buf.u.val.x); 118 y = - bit9toint(buf.u.val.ysign, buf.u.val.y); 119 120 if (x != 0 || y != 0) { 121 mouse_ev_move(x, y); 122 } 123 } 124 125 return; 126 } 132 mouse_proto_ops_t ps2_proto = { 133 .parse = ps2_proto_parse, 134 .init = ps2_proto_init 135 }; 127 136 128 137 /** -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
r52a79081 ra33f0a6 42 42 #include <io/console.h> 43 43 #include <vfs/vfs.h> 44 #include <ipc/mouse .h>44 #include <ipc/mouseev.h> 45 45 #include <async.h> 46 #include <async_obsolete.h> 46 47 #include <unistd.h> 47 48 #include <stdio.h> … … 50 51 #include <errno.h> 51 52 #include <inttypes.h> 52 53 53 #include "s3c24xx_ts.h" 54 54 55 // FIXME: remove this header 56 #include <kernel/ipc/ipc_methods.h> 57 55 58 #define NAME "s3c24ser" 56 #define NAMESPACE "hid _in"59 #define NAMESPACE "hid" 57 60 58 61 static irq_cmd_t ts_irq_cmds[] = { … … 70 73 static s3c24xx_ts_t *ts; 71 74 72 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall); 75 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall, 76 void *arg); 73 77 static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call); 74 78 static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts); … … 280 284 button = 1; 281 285 press = 0; 282 async_ msg_2(ts->client_phone, MEVENT_BUTTON, button, press);286 async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press); 283 287 284 288 s3c24xx_ts_wait_for_int_mode(ts, updn_down); … … 321 325 322 326 /* Send notifications to client. */ 323 async_ msg_2(ts->client_phone, MEVENT_MOVE, dx, dy);324 async_ msg_2(ts->client_phone, MEVENT_BUTTON, button, press);327 async_obsolete_msg_2(ts->client_phone, MOUSEEV_MOVE_EVENT, dx, dy); 328 async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press); 325 329 326 330 ts->last_x = x_pos; … … 370 374 371 375 /** Handle mouse client connection. */ 372 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall) 376 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall, 377 void *arg) 373 378 { 374 379 ipc_callid_t callid; … … 380 385 while (1) { 381 386 callid = async_get_call(&call); 382 switch (IPC_GET_IMETHOD(call)) {383 case IPC_M_PHONE_HUNGUP:387 388 if (!IPC_GET_IMETHOD(call)) { 384 389 if (ts->client_phone != -1) { 385 async_ hangup(ts->client_phone);390 async_obsolete_hangup(ts->client_phone); 386 391 ts->client_phone = -1; 387 392 } … … 389 394 async_answer_0(callid, EOK); 390 395 return; 396 } 397 398 switch (IPC_GET_IMETHOD(call)) { 391 399 case IPC_M_CONNECT_TO_ME: 392 400 if (ts->client_phone != -1) {
Note:
See TracChangeset
for help on using the changeset viewer.
