Changeset 8ff0bd2 in mainline for uspace/srv/hid
- Timestamp:
- 2011-09-04T11:30:58Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03bc76a
- Parents:
- d2c67e7 (diff), deac215e (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:
-
- 21 added
- 17 deleted
- 14 edited
- 31 moved
-
adb_mouse/adb_dev.c (deleted)
-
adb_mouse/adb_mouse.c (deleted)
-
char_mouse/char_mouse.c (deleted)
-
console/Makefile (modified) (1 diff)
-
console/console.c (modified) (30 diffs)
-
console/gcons.c (modified) (15 diffs)
-
console/gfx/anim_1.ppm (deleted)
-
console/gfx/anim_1.tga (added)
-
console/gfx/anim_2.ppm (deleted)
-
console/gfx/anim_2.tga (added)
-
console/gfx/anim_3.ppm (deleted)
-
console/gfx/anim_3.tga (added)
-
console/gfx/anim_4.ppm (deleted)
-
console/gfx/anim_4.tga (added)
-
console/gfx/cons_has_data.ppm (deleted)
-
console/gfx/cons_has_data.tga (added)
-
console/gfx/cons_idle.ppm (deleted)
-
console/gfx/cons_idle.tga (added)
-
console/gfx/cons_kernel.ppm (deleted)
-
console/gfx/cons_kernel.tga (added)
-
console/gfx/cons_selected.ppm (deleted)
-
console/gfx/cons_selected.tga (added)
-
console/gfx/helenos.ppm (deleted)
-
console/gfx/helenos.tga (added)
-
console/gfx/nameic.ppm (deleted)
-
console/gfx/nameic.tga (added)
-
fb/Makefile (modified) (2 diffs)
-
fb/ega.c (modified) (3 diffs)
-
fb/fb.c (modified) (31 diffs)
-
fb/fb.h (modified) (1 diff)
-
fb/main.c (modified) (2 diffs)
-
fb/niagara.c (modified) (1 diff)
-
fb/niagara.h (modified) (1 diff)
-
fb/ppm.c (deleted)
-
fb/serial_console.c (modified) (2 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 ) (5 diffs)
-
input/port/adb_mouse.c (moved) (moved from uspace/srv/hid/char_mouse/chardev.c ) (3 diffs)
-
input/port/chardev.c (moved) (moved from uspace/srv/hid/kbd/port/chardev.c ) (5 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)
-
s3c24xx_ts/s3c24xx_ts.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/console/Makefile
rd2c67e7 r8ff0bd2 29 29 30 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a 32 EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) 31 33 BINARY = console 32 34 33 GENERIC_SOURCES = \35 SOURCES = \ 34 36 console.c \ 35 37 keybuffer.c \ 38 images.c \ 36 39 gcons.c 37 40 38 41 IMAGES = \ 39 gfx/helenos. ppm\40 gfx/nameic. ppm\41 gfx/cons_selected. ppm\42 gfx/cons_idle. ppm\43 gfx/cons_has_data. ppm\44 gfx/cons_kernel. ppm\45 gfx/anim_1. ppm\46 gfx/anim_2. ppm\47 gfx/anim_3. ppm\48 gfx/anim_4. ppm42 gfx/helenos.tga \ 43 gfx/nameic.tga \ 44 gfx/cons_selected.tga \ 45 gfx/cons_idle.tga \ 46 gfx/cons_has_data.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 49 52 50 SOURCES = \ 51 $(GENERIC_SOURCES) \ 52 $(IMAGES) 53 PRE_DEPEND = images.c images.h 54 EXTRA_CLEAN = images.c images.h 53 55 54 56 include $(USPACE_PREFIX)/Makefile.common 55 57 56 %.o: %.ppm 57 $( OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@58 images.c images.h: $(IMAGES) 59 $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^ -
uspace/srv/hid/console/console.c
rd2c67e7 r8ff0bd2 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> … … 53 53 #include <sysinfo.h> 54 54 #include <event.h> 55 #include <devmap.h> 56 #include <devmap_obsolete.h> 55 #include <loc.h> 57 56 #include <fcntl.h> 58 57 #include <vfs/vfs.h> … … 60 59 #include <io/style.h> 61 60 #include <io/screenbuffer.h> 62 #include <inttypes.h>63 61 64 62 #include "console.h" … … 66 64 #include "keybuffer.h" 67 65 68 // FIXME: remove this header69 #include <kernel/ipc/ipc_methods.h>70 71 66 #define NAME "console" 72 67 #define NAMESPACE "term" 73 68 74 /** Interval for checking for new keyboard (1/4s). */ 75 #define HOTPLUG_WATCH_INTERVAL (1000 * 250) 76 77 /* Kernel defines 32 but does not export it. */ 78 #define MAX_IPC_OUTGOING_PHONES 128 79 80 /** To allow proper phone closing. */ 81 static ipc_callid_t driver_phones[MAX_IPC_OUTGOING_PHONES] = { 0 }; 82 83 /** Phone to the keyboard driver. */ 84 static int kbd_phone; 85 86 /** Phone to the mouse driver. */ 87 static int mouse_phone; 69 /** Session with the input server. */ 70 static async_sess_t *input_sess; 88 71 89 72 /** Information about framebuffer */ … … 98 81 size_t index; /**< Console index */ 99 82 size_t refcount; /**< Connection reference count */ 100 devmap_handle_t devmap_handle; /**< Device handle*/83 service_id_t service_id; /**< Service ID */ 101 84 keybuffer_t keybuffer; /**< Buffer for incoming keys. */ 102 85 screenbuffer_t scr; /**< Screenbuffer for saving screen … … 125 108 static FIBRIL_CONDVAR_INITIALIZE(input_cv); 126 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 127 122 static void curs_visibility(bool visible) 128 123 { … … 155 150 } 156 151 157 static void kbd_yield(void) 158 { 159 async_obsolete_req_0_0(kbd_phone, KBD_YIELD); 160 } 161 162 static void kbd_reclaim(void) 163 { 164 async_obsolete_req_0_0(kbd_phone, KBD_RECLAIM); 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); 165 176 } 166 177 … … 339 350 340 351 if (cons == kernel_console) { 341 async_obsolete_serialize_start();352 console_serialize_start(); 342 353 curs_hide_sync(); 343 354 gcons_in_kernel(); 344 355 screen_yield(); 345 kbd_yield();346 async_obsolete_serialize_end();347 348 if ( __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {356 input_yield(); 357 console_serialize_end(); 358 359 if (console_kcon()) { 349 360 prev_console = active_console; 350 361 active_console = kernel_console; … … 354 365 355 366 if (cons != kernel_console) { 356 async_obsolete_serialize_start();367 console_serialize_start(); 357 368 358 369 if (active_console == kernel_console) { 359 370 screen_reclaim(); 360 kbd_reclaim();371 input_reclaim(); 361 372 gcons_redraw_console(); 362 373 } … … 409 420 curs_visibility(cons->scr.is_cursor_visible); 410 421 411 async_obsolete_serialize_end(); 412 } 413 } 414 415 static void close_driver_phone(ipc_callid_t hash) 416 { 417 int i; 418 for (i = 0; i < MAX_IPC_OUTGOING_PHONES; i++) { 419 if (driver_phones[i] == hash) { 420 printf("Device %" PRIxn " gone.\n", hash); 421 driver_phones[i] = 0; 422 async_obsolete_hangup(i); 423 return; 424 } 425 } 426 } 427 428 /** Handler for keyboard */ 429 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) 430 428 { 431 429 /* Ignore parameters, the connection is already opened */ … … 439 437 if (!IPC_GET_IMETHOD(call)) { 440 438 /* TODO: Handle hangup */ 441 close_driver_phone(iid);439 async_hangup(input_sess); 442 440 return; 443 441 } 444 442 445 443 switch (IPC_GET_IMETHOD(call)) { 446 case KBD_EVENT:447 /* Got event from keyboard driver.*/444 case INPUT_EVENT_KEY: 445 /* Got key press/release event */ 448 446 retval = 0; 449 447 ev.type = IPC_GET_ARG1(call); … … 466 464 fibril_mutex_unlock(&input_mutex); 467 465 break; 468 default: 469 retval = ENOENT; 470 } 471 async_answer_0(callid, retval); 472 } 473 } 474 475 /** Handler for mouse events */ 476 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall) 477 { 478 /* Ignore parameters, the connection is already opened */ 479 while (true) { 480 ipc_call_t call; 481 ipc_callid_t callid = async_get_call(&call); 482 483 int retval; 484 485 if (!IPC_GET_IMETHOD(call)) { 486 /* TODO: Handle hangup */ 487 close_driver_phone(iid); 488 return; 489 } 490 491 switch (IPC_GET_IMETHOD(call)) { 492 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 */ 493 474 if (IPC_GET_ARG1(call) == 1) { 494 475 int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call)); … … 498 479 retval = 0; 499 480 break; 500 case MEVENT_MOVE:501 gcons_mouse_move((int) IPC_GET_ARG1(call),502 (int) IPC_GET_ARG2(call));503 retval = 0;504 break;505 481 default: 506 482 retval = ENOENT; … … 522 498 } 523 499 524 async_obsolete_serialize_start();500 console_serialize_start(); 525 501 526 502 size_t off = 0; … … 530 506 } 531 507 532 async_obsolete_serialize_end();508 console_serialize_end(); 533 509 534 510 gcons_notify_char(cons->index); … … 597 573 598 574 /** Default thread for new connections */ 599 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) 600 576 { 601 577 console_t *cons = NULL; … … 606 582 continue; 607 583 608 if (consoles[i]. devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {584 if (consoles[i].service_id == (service_id_t) IPC_GET_ARG1(*icall)) { 609 585 cons = &consoles[i]; 610 586 break; … … 625 601 int rc; 626 602 627 async_obsolete_serialize_start();603 console_serialize_start(); 628 604 if (cons->refcount == 0) 629 605 gcons_notify_connect(cons->index); … … 635 611 636 612 while (true) { 637 async_obsolete_serialize_end();613 console_serialize_end(); 638 614 callid = async_get_call(&call); 639 async_obsolete_serialize_start();615 console_serialize_start(); 640 616 641 617 arg1 = 0; … … 647 623 if (cons->refcount == 0) 648 624 gcons_notify_disconnect(cons->index); 625 console_serialize_end(); 649 626 return; 650 627 } … … 652 629 switch (IPC_GET_IMETHOD(call)) { 653 630 case VFS_OUT_READ: 654 async_obsolete_serialize_end();631 console_serialize_end(); 655 632 cons_read(cons, callid, &call); 656 async_obsolete_serialize_start();633 console_serialize_start(); 657 634 continue; 658 635 case VFS_OUT_WRITE: 659 async_obsolete_serialize_end();636 console_serialize_end(); 660 637 cons_write(cons, callid, &call); 661 async_obsolete_serialize_start();638 console_serialize_start(); 662 639 continue; 663 640 case VFS_OUT_SYNC: … … 730 707 break; 731 708 case CONSOLE_GET_EVENT: 732 async_obsolete_serialize_end();709 console_serialize_end(); 733 710 cons_get_event(cons, callid, &call); 734 async_obsolete_serialize_start();711 console_serialize_start(); 735 712 continue; 736 case CONSOLE_KCON_ENABLE:737 change_console(kernel_console);738 break;739 713 } 740 714 async_answer_3(callid, EOK, arg1, arg2, arg3); … … 747 721 } 748 722 749 static int async_connect_to_me_hack(int phone, sysarg_t arg1, sysarg_t arg2, 750 sysarg_t arg3, async_client_conn_t client_receiver, ipc_callid_t *hash) 751 { 752 sysarg_t task_hash; 753 sysarg_t phone_hash; 754 int rc = async_obsolete_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 755 NULL, NULL, NULL, &task_hash, &phone_hash); 756 if (rc != EOK) 757 return rc; 758 759 if (client_receiver != NULL) 760 async_new_connection(task_hash, phone_hash, phone_hash, NULL, 761 client_receiver); 762 763 if (hash != NULL) 764 *hash = phone_hash; 765 766 return EOK; 767 } 768 769 static int connect_keyboard_or_mouse(const char *devname, 770 async_client_conn_t handler, const char *dev) 771 { 772 int phone; 773 devmap_handle_t handle; 774 775 int rc = devmap_device_get_handle(dev, &handle, 0); 723 static async_sess_t *connect_input(const char *svc_path) 724 { 725 async_sess_t *sess; 726 async_exch_t *exch; 727 service_id_t service_id; 728 729 int rc = loc_service_get_id(svc_path, &service_id, 0); 776 730 if (rc == EOK) { 777 phone = devmap_obsolete_device_connect(handle, 0); 778 if (phone < 0) { 779 printf("%s: Failed to connect to input device\n", NAME); 780 return phone; 781 } 782 } else 783 return rc; 731 sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 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 } 784 745 785 746 /* NB: The callback connection is slotted for removal */ 786 ipc_callid_t hash; 787 rc = async_connect_to_me_hack(phone, SERVICE_CONSOLE, 0, phone, 788 handler, &hash); 747 rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL); 748 749 async_exchange_end(exch); 750 789 751 if (rc != EOK) { 790 async_ obsolete_hangup(phone);791 printf("%s: Failed to create callback from input device(%s).\n",752 async_hangup(sess); 753 printf("%s: Failed to create callback from input server (%s).\n", 792 754 NAME, str_error(rc)); 793 return rc; 794 } 795 796 driver_phones[phone] = hash; 797 printf("%s: found %s \"%s\" (%" PRIxn ").\n", NAME, devname, dev, hash); 798 return phone; 799 } 800 801 static int connect_keyboard(const char *dev) 802 { 803 return connect_keyboard_or_mouse("keyboard", keyboard_events, dev); 804 } 805 806 static int connect_mouse(const char *dev) 807 { 808 return connect_keyboard_or_mouse("mouse", mouse_events, dev); 809 } 810 811 struct hid_class_info { 812 char *classname; 813 int (*connection_func)(const char *); 814 }; 815 816 /** Periodically check for new keyboards in /dev/class/. 817 * 818 * @param arg Class name. 819 * 820 * @return This function should never exit. 821 * 822 */ 823 static int check_new_device_fibril(void *arg) 824 { 825 struct hid_class_info *dev_info = (struct hid_class_info *) arg; 826 827 size_t index = 1; 828 829 while (true) { 830 async_usleep(HOTPLUG_WATCH_INTERVAL); 831 832 char *dev; 833 int rc = asprintf(&dev, "class/%s\\%zu", 834 dev_info->classname, index); 835 if (rc < 0) 836 continue; 837 838 rc = dev_info->connection_func(dev); 839 if (rc > 0) { 840 /* We do not allow unplug. */ 841 index++; 842 } 843 844 free(dev); 845 } 846 847 return EOK; 848 } 849 850 /** Start a fibril monitoring hot-plugged keyboards. 851 */ 852 static void check_new_devices_in_background(int (*connection_func)(const char *), 853 const char *classname) 854 { 855 struct hid_class_info *dev_info = malloc(sizeof(struct hid_class_info)); 856 if (dev_info == NULL) { 857 printf("%s: Out of memory, no hot-plug support.\n", NAME); 858 return; 859 } 860 861 int rc = asprintf(&dev_info->classname, "%s", classname); 862 if (rc < 0) { 863 printf("%s: Failed to format classname: %s.\n", NAME, 864 str_error(rc)); 865 return; 866 } 867 868 dev_info->connection_func = connection_func; 869 870 fid_t fid = fibril_create(check_new_device_fibril, (void *) dev_info); 871 if (!fid) { 872 printf("%s: Failed to create hot-plug fibril for %s.\n", NAME, 873 classname); 874 return; 875 } 876 877 fibril_add_ready(fid); 878 } 879 880 static bool console_srv_init(char *kdev) 881 { 882 /* Connect to input device */ 883 kbd_phone = connect_keyboard(kdev); 884 if (kbd_phone < 0) 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) 885 766 return false; 886 887 mouse_phone = connect_mouse("hid_in/mouse");888 if (mouse_phone < 0) {889 printf("%s: Failed to connect to mouse device %s\n", NAME,890 str_error(mouse_phone));891 }892 767 893 768 /* Connect to framebuffer driver */ … … 898 773 } 899 774 900 /* Register driver */901 int rc = devmap_driver_register(NAME, client_connection);775 /* Register server */ 776 int rc = loc_server_register(NAME, client_connection); 902 777 if (rc < 0) { 903 printf("%s: Unable to register driver (%d)\n", NAME, rc);778 printf("%s: Unable to register server (%d)\n", NAME, rc); 904 779 return false; 905 780 } … … 945 820 consoles[i].refcount = 0; 946 821 947 char vc[ DEVMAP_NAME_MAXLEN + 1];948 snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);822 char vc[LOC_NAME_MAXLEN + 1]; 823 snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i); 949 824 950 if ( devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {951 printf("%s: Unable to register device %s\n", NAME, vc);825 if (loc_service_register(vc, &consoles[i].service_id) != EOK) { 826 printf("%s: Unable to register service %s\n", NAME, vc); 952 827 return false; 953 828 } … … 955 830 } 956 831 957 /* Disable kernel output to the console */958 __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);959 960 832 /* Initialize the screen */ 961 async_obsolete_serialize_start();833 console_serialize_start(); 962 834 gcons_redraw_console(); 963 835 set_style(STYLE_NORMAL); … … 965 837 curs_goto(0, 0); 966 838 curs_visibility(active_console->scr.is_cursor_visible); 967 async_obsolete_serialize_end();839 console_serialize_end(); 968 840 969 841 /* Receive kernel notifications */ … … 972 844 printf("%s: Error registering kconsole notifications\n", NAME); 973 845 974 /* Start fibril for checking on hot-plugged keyboards. */975 check_new_devices_in_background(connect_keyboard, "keyboard");976 check_new_devices_in_background(connect_mouse, "mouse");977 978 846 return true; 979 847 } … … 981 849 static void usage(void) 982 850 { 983 printf("Usage: console <input >\n");851 printf("Usage: console <input_dev>\n"); 984 852 } 985 853 -
uspace/srv/hid/console/gcons.c
rd2c67e7 r8ff0bd2 41 41 #include <align.h> 42 42 #include <bool.h> 43 #include <imgmap.h> 43 44 44 45 #include "console.h" 45 46 #include "gcons.h" 47 #include "images.h" 46 48 47 49 #define CONSOLE_TOP 66 … … 58 60 #define COLOR_BACKGROUND 0xffffff 59 61 60 extern char _binary_gfx_helenos_ppm_start[0];61 extern int _binary_gfx_helenos_ppm_size;62 extern char _binary_gfx_nameic_ppm_start[0];63 extern int _binary_gfx_nameic_ppm_size;64 65 extern char _binary_gfx_anim_1_ppm_start[0];66 extern int _binary_gfx_anim_1_ppm_size;67 extern char _binary_gfx_anim_2_ppm_start[0];68 extern int _binary_gfx_anim_2_ppm_size;69 extern char _binary_gfx_anim_3_ppm_start[0];70 extern int _binary_gfx_anim_3_ppm_size;71 extern char _binary_gfx_anim_4_ppm_start[0];72 extern int _binary_gfx_anim_4_ppm_size;73 74 extern char _binary_gfx_cons_selected_ppm_start[0];75 extern int _binary_gfx_cons_selected_ppm_size;76 extern char _binary_gfx_cons_idle_ppm_start[0];77 extern int _binary_gfx_cons_idle_ppm_size;78 extern char _binary_gfx_cons_has_data_ppm_start[0];79 extern int _binary_gfx_cons_has_data_ppm_size;80 extern char _binary_gfx_cons_kernel_ppm_start[0];81 extern int _binary_gfx_cons_kernel_ppm_size;82 83 62 static bool use_gcons = false; 84 63 static sysarg_t xres; 85 64 static sysarg_t yres; 65 66 static imgmap_t *helenos_img; 67 static imgmap_t *nameic_img; 68 69 static imgmap_t *anim_1_img; 70 static imgmap_t *anim_2_img; 71 static imgmap_t *anim_3_img; 72 static imgmap_t *anim_4_img; 73 74 static imgmap_t *cons_has_data_img; 75 static imgmap_t *cons_idle_img; 76 static imgmap_t *cons_kernel_img; 77 static imgmap_t *cons_selected_img; 86 78 87 79 enum butstate { … … 101 93 static int fbphone; 102 94 103 /** List of pixmaps identifying these icons */104 static int ic_ pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};95 /** List of image maps identifying these icons */ 96 static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1}; 105 97 static int animation = -1; 106 98 … … 149 141 enum butstate state = console_state[index]; 150 142 151 if (ic_ pixmaps[state] != -1)152 async_obsolete_msg_2(fbphone, FB_VP_DRAW_ PIXMAP, cstatus_vp[index],153 ic_ pixmaps[state]);143 if (ic_imgmaps[state] != -1) 144 async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index], 145 ic_imgmaps[state]); 154 146 155 147 if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL) … … 168 160 void gcons_change_console(size_t index) 169 161 { 170 if (!use_gcons) 171 return; 162 if (!use_gcons) { 163 active_console = index; 164 return; 165 } 172 166 173 167 if (active_console == KERNEL_CONSOLE) { … … 356 350 } 357 351 358 /** Draw a PPM pixmap to framebuffer 359 * 360 * @param logo Pointer to PPM data 361 * @param size Size of PPM data 362 * @param x Coordinate of upper left corner 363 * @param y Coordinate of upper left corner 364 * 365 */ 366 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y) 367 { 352 /** Draw an image map to framebuffer 353 * 354 * @param img Image map 355 * @param x Coordinate of upper left corner 356 * @param y Coordinate of upper left corner 357 * 358 */ 359 static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y) 360 { 361 if (img == NULL) 362 return; 363 368 364 /* Create area */ 369 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |365 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED | 370 366 MAP_ANONYMOUS, 0, 0); 371 367 if (shm == MAP_FAILED) 372 368 return; 373 369 374 memcpy(shm, logo,size);370 memcpy(shm, img, img->size); 375 371 376 372 /* Send area */ … … 384 380 385 381 /* Draw logo */ 386 async_obsolete_msg_2(fbphone, FB_DRAW_ PPM, x, y);382 async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y); 387 383 388 384 drop: … … 392 388 exit: 393 389 /* Remove area */ 394 munmap(shm, size);390 munmap(shm, img->size); 395 391 } 396 392 … … 404 400 set_rgb_color(COLOR_MAIN, COLOR_MAIN); 405 401 clear(); 406 draw_pixmap(_binary_gfx_helenos_ppm_start, 407 (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2); 408 draw_pixmap(_binary_gfx_nameic_ppm_start, 409 (size_t) &_binary_gfx_nameic_ppm_size, 5, 17); 402 draw_imgmap(helenos_img, xres - 66, 2); 403 draw_imgmap(nameic_img, 5, 17); 410 404 411 405 unsigned int i; … … 416 410 } 417 411 418 /** Creates a pixmap on framebuffer 419 * 420 * @param data PPM data 421 * @param size PPM data size 422 * 423 * @return Pixmap identification 424 * 425 */ 426 static int make_pixmap(char *data, size_t size) 427 { 412 /** Create an image map on framebuffer 413 * 414 * @param img Image map. 415 * 416 * @return Image map identification 417 * 418 */ 419 static int make_imgmap(imgmap_t *img) 420 { 421 if (img == NULL) 422 return -1; 423 428 424 /* Create area */ 429 char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |430 MAP_ ANONYMOUS, 0, 0);425 char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, 426 MAP_SHARED | MAP_ANONYMOUS, 0, 0); 431 427 if (shm == MAP_FAILED) 432 428 return -1; 433 429 434 memcpy(shm, data,size);435 436 int pxid = -1;430 memcpy(shm, img, img->size); 431 432 int id = -1; 437 433 438 434 /* Send area */ … … 445 441 goto drop; 446 442 447 /* Obtain pixmap*/448 rc = async_obsolete_req_0_0(fbphone, FB_SHM2 PIXMAP);443 /* Obtain image map identifier */ 444 rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP); 449 445 if (rc < 0) 450 446 goto drop; 451 447 452 pxid = rc;448 id = rc; 453 449 454 450 drop: … … 458 454 exit: 459 455 /* Remove area */ 460 munmap(shm, size);461 462 return pxid;456 munmap(shm, img->size); 457 458 return id; 463 459 } 464 460 … … 470 466 return; 471 467 472 int pm = make_pixmap(_binary_gfx_anim_1_ppm_start, 473 (size_t) &_binary_gfx_anim_1_ppm_size); 474 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 475 476 pm = make_pixmap(_binary_gfx_anim_2_ppm_start, 477 (size_t) &_binary_gfx_anim_2_ppm_size); 478 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 479 480 pm = make_pixmap(_binary_gfx_anim_3_ppm_start, 481 (size_t) &_binary_gfx_anim_3_ppm_size); 482 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 483 484 pm = make_pixmap(_binary_gfx_anim_4_ppm_start, 485 (size_t) &_binary_gfx_anim_4_ppm_size); 486 async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm); 468 int pm = make_imgmap(anim_1_img); 469 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 470 471 pm = make_imgmap(anim_2_img); 472 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 473 474 pm = make_imgmap(anim_3_img); 475 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 476 477 pm = make_imgmap(anim_4_img); 478 async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm); 487 479 488 480 async_obsolete_msg_1(fbphone, FB_ANIM_START, an); … … 502 494 if ((xres < 800) || (yres < 600)) 503 495 return; 496 497 /* Create image maps */ 498 helenos_img = imgmap_decode_tga((void *) helenos_tga, 499 helenos_tga_size); 500 nameic_img = imgmap_decode_tga((void *) nameic_tga, 501 nameic_tga_size); 502 503 anim_1_img = imgmap_decode_tga((void *) anim_1_tga, 504 anim_1_tga_size); 505 anim_2_img = imgmap_decode_tga((void *) anim_2_tga, 506 anim_2_tga_size); 507 anim_3_img = imgmap_decode_tga((void *) anim_3_tga, 508 anim_3_tga_size); 509 anim_4_img = imgmap_decode_tga((void *) anim_4_tga, 510 anim_4_tga_size); 511 512 cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga, 513 cons_has_data_tga_size); 514 cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga, 515 cons_idle_tga_size); 516 cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga, 517 cons_kernel_tga_size); 518 cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga, 519 cons_selected_tga_size); 504 520 505 521 /* Create console viewport */ … … 529 545 530 546 /* Initialize icons */ 531 ic_pixmaps[CONS_SELECTED] = 532 make_pixmap(_binary_gfx_cons_selected_ppm_start, 533 (size_t) &_binary_gfx_cons_selected_ppm_size); 534 ic_pixmaps[CONS_IDLE] = 535 make_pixmap(_binary_gfx_cons_idle_ppm_start, 536 (size_t) &_binary_gfx_cons_idle_ppm_size); 537 ic_pixmaps[CONS_HAS_DATA] = 538 make_pixmap(_binary_gfx_cons_has_data_ppm_start, 539 (size_t) &_binary_gfx_cons_has_data_ppm_size); 540 ic_pixmaps[CONS_DISCONNECTED] = 541 make_pixmap(_binary_gfx_cons_idle_ppm_start, 542 (size_t) &_binary_gfx_cons_idle_ppm_size); 543 ic_pixmaps[CONS_KERNEL] = 544 make_pixmap(_binary_gfx_cons_kernel_ppm_start, 545 (size_t) &_binary_gfx_cons_kernel_ppm_size); 546 ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; 547 ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img); 548 ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img); 549 ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img); 550 ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img); 551 ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img); 552 ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED]; 547 553 548 554 make_anim(); -
uspace/srv/hid/fb/Makefile
rd2c67e7 r8ff0bd2 40 40 41 41 SOURCES = \ 42 main.c \ 43 ppm.c 42 main.c 44 43 45 44 ifneq ($(UARCH),ia64) … … 84 83 EXTRA_CFLAGS += -DNIAGARA_ENABLED 85 84 endif 86 87 ifeq ($(MACHINE),serengeti)88 SOURCES += \89 sgcn.c \90 serial_console.c91 EXTRA_CFLAGS += -DSGCN_ENABLED92 endif93 85 endif 94 86 95 EXTRA_CFLAGS += -D$(UARCH) 87 LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a 88 EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) -D$(UARCH) 96 89 97 90 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/hid/fb/ega.c
rd2c67e7 r8ff0bd2 56 56 57 57 // FIXME: remove this header 58 #include < kernel/ipc/ipc_methods.h>58 #include <abi/ipc/methods.h> 59 59 60 60 #define MAX_SAVED_SCREENS 256 … … 256 256 } 257 257 258 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) 259 260 { 260 261 size_t intersize = 0; … … 413 414 retval = 0; 414 415 break; 415 case FB_VP_DRAW_ PIXMAP:416 case FB_VP_DRAW_IMGMAP: 416 417 scr = IPC_GET_ARG2(call); 417 418 retval = print_screen(scr); 418 419 break; 419 case FB_VP2 PIXMAP:420 case FB_VP2IMGMAP: 420 421 retval = save_screen(); 421 422 break; 422 case FB_DROP_ PIXMAP:423 case FB_DROP_IMGMAP: 423 424 scr = IPC_GET_ARG1(call); 424 425 -
uspace/srv/hid/fb/fb.c
rd2c67e7 r8ff0bd2 49 49 #include <ipc/ns.h> 50 50 #include <ipc/services.h> 51 #include < kernel/errno.h>52 #include < kernel/genarch/fb/visuals.h>51 #include <errno.h> 52 #include <abi/fb/visuals.h> 53 53 #include <io/color.h> 54 54 #include <io/style.h> … … 59 59 #include <byteorder.h> 60 60 #include <io/screenbuffer.h> 61 #include <imgmap.h> 61 62 #include "font-8x16.h" 62 63 #include "fb.h" 63 64 #include "main.h" 64 #include "ppm.h"65 65 #include "pointer.xbm" 66 66 #include "pointer_mask.xbm" 67 67 68 68 // FIXME: remove this header 69 #include < kernel/ipc/ipc_methods.h>69 #include <abi/ipc/methods.h> 70 70 71 71 #define DEFAULT_BGCOLOR 0xf0f0f0 … … 76 76 #define MAX_ANIM_LEN 8 77 77 #define MAX_ANIMATIONS 4 78 #define MAX_ PIXMAPS 256 /**< Maximum number of saved pixmaps */78 #define MAX_IMGMAPS 256 /**< Maximum number of saved image maps */ 79 79 #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ 80 80 … … 160 160 unsigned int pos; 161 161 unsigned int animlen; 162 unsigned int pixmaps[MAX_ANIM_LEN];162 unsigned int imgmaps[MAX_ANIM_LEN]; 163 163 } animation_t; 164 164 … … 166 166 static bool anims_enabled; 167 167 168 typedef struct { 169 unsigned int width; 170 unsigned int height; 171 uint8_t *data; 172 } pixmap_t; 173 174 static pixmap_t pixmaps[MAX_PIXMAPS]; 168 static imgmap_t *imgmaps[MAX_IMGMAPS]; 175 169 static viewport_t viewports[128]; 176 170 … … 212 206 static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col, 213 207 unsigned int row); 214 215 208 216 209 #define RED(x, bits) (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1)) … … 875 868 } 876 869 877 878 870 /** Show cursor if cursor showing is enabled 879 871 * … … 888 880 } 889 881 890 891 882 /** Invert cursor, if it is enabled 892 883 * … … 899 890 cursor_show(vport); 900 891 } 901 902 892 903 893 /** Draw character at given position relative to viewport … … 981 971 } 982 972 983 984 static void putpixel_pixmap(void *data, unsigned int x, unsigned int y, uint32_t color) 985 { 986 int pm = *((int *) data); 987 pixmap_t *pmap = &pixmaps[pm]; 988 unsigned int pos = (y * pmap->width + x) * screen.pixelbytes; 989 990 screen.rgb_conv(&pmap->data[pos], color); 991 } 992 993 994 static void putpixel(void *data, unsigned int x, unsigned int y, uint32_t color) 995 { 996 viewport_t *vport = (viewport_t *) data; 973 static void putpixel(viewport_t *vport, unsigned int x, unsigned int y, 974 uint32_t color) 975 { 997 976 unsigned int dx = vport->x + x; 998 977 unsigned int dy = vport->y + y; … … 1001 980 } 1002 981 1003 1004 /** Return first free pixmap 1005 * 1006 */ 1007 static int find_free_pixmap(void) 982 /** Draw image map 983 * 984 * @param[in] img Image map. 985 * @param[in] sx Coordinate of upper left corner. 986 * @param[in] sy Coordinate of upper left corner. 987 * @param[in] maxwidth Maximum allowed width for picture. 988 * @param[in] maxheight Maximum allowed height for picture. 989 * @param[in] vport Viewport. 990 * 991 * @return EOK on success. 992 * 993 */ 994 static int imgmap_draw(imgmap_t *img, unsigned int sx, unsigned int sy, 995 unsigned int maxwidth, unsigned int maxheight, void *vport) 996 { 997 if (img->visual != VISUAL_BGR_8_8_8) 998 return EINVAL; 999 1000 uint8_t *data = (uint8_t *) img->data; 1001 1002 for (sysarg_t y = 0; y < img->height; y++) { 1003 for (sysarg_t x = 0; x < img->width; x++) { 1004 if ((x > maxwidth) || (y > maxheight)) { 1005 data += 3; 1006 continue; 1007 } 1008 1009 uint32_t color = (data[2] << 16) + (data[1] << 8) + data[0]; 1010 1011 putpixel(vport, sx + x, sy + y, color); 1012 data += 3; 1013 } 1014 } 1015 1016 return EOK; 1017 } 1018 1019 /** Return first free image map 1020 * 1021 */ 1022 static int find_free_imgmap(void) 1008 1023 { 1009 1024 unsigned int i; 1010 1025 1011 for (i = 0; i < MAX_ PIXMAPS; i++)1012 if (! pixmaps[i].data)1026 for (i = 0; i < MAX_IMGMAPS; i++) 1027 if (!imgmaps[i]) 1013 1028 return i; 1014 1029 … … 1016 1031 } 1017 1032 1018 1019 /** Create a new pixmap and return appropriate ID 1020 * 1021 */ 1022 static int shm2pixmap(unsigned char *shm, size_t size) 1023 { 1024 int pm; 1025 pixmap_t *pmap; 1026 1027 pm = find_free_pixmap(); 1028 if (pm == -1) 1033 /** Create a new image map and return appropriate ID 1034 * 1035 */ 1036 static int shm2imgmap(imgmap_t *shm, size_t size) 1037 { 1038 int im = find_free_imgmap(); 1039 if (im == -1) 1029 1040 return ELIMIT; 1030 1041 1031 pmap = &pixmaps[pm]; 1032 1033 if (ppm_get_data(shm, size, &pmap->width, &pmap->height)) 1034 return EINVAL; 1035 1036 pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes); 1037 if (!pmap->data) 1042 imgmap_t *imap = malloc(size); 1043 if (!imap) 1038 1044 return ENOMEM; 1039 1045 1040 ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, putpixel_pixmap, (void *) &pm); 1041 1042 return pm; 1043 } 1044 1046 memcpy(imap, shm, size); 1047 imgmaps[im] = imap; 1048 return im; 1049 } 1045 1050 1046 1051 /** Handle shared memory communication calls 1047 1052 * 1048 * Protocol for drawing pixmaps:1053 * Protocol for drawing image maps: 1049 1054 * - FB_PREPARE_SHM(client shm identification) 1050 1055 * - IPC_M_AS_AREA_SEND 1051 * - FB_DRAW_ PPM(startx, starty)1056 * - FB_DRAW_IMGMAP(startx, starty) 1052 1057 * - FB_DROP_SHM 1053 1058 * … … 1071 1076 static size_t intersize = 0; 1072 1077 1073 static unsigned char*shm = NULL;1078 static imgmap_t *shm = NULL; 1074 1079 static sysarg_t shm_id = 0; 1075 1080 static size_t shm_size; … … 1093 1098 return false; 1094 1099 } 1100 1095 1101 shm = dest; 1096 1097 if (shm[0] != 'P')1098 return false;1099 1100 1102 return true; 1101 1103 } else { … … 1107 1109 if (shm_id) 1108 1110 retval = EBUSY; 1109 else 1111 else 1110 1112 shm_id = IPC_GET_ARG1(*call); 1111 1113 break; 1112 1113 1114 case FB_DROP_SHM: 1114 1115 if (shm) { … … 1118 1119 shm_id = 0; 1119 1120 break; 1120 1121 case FB_SHM2PIXMAP: 1121 case FB_SHM2IMGMAP: 1122 1122 if (!shm) { 1123 1123 retval = EINVAL; 1124 1124 break; 1125 1125 } 1126 retval = shm2 pixmap(shm, shm_size);1127 break; 1128 case FB_DRAW_ PPM:1126 retval = shm2imgmap(shm, shm_size); 1127 break; 1128 case FB_DRAW_IMGMAP: 1129 1129 if (!shm) { 1130 1130 retval = EINVAL; 1131 1131 break; 1132 1132 } 1133 1133 1134 x = IPC_GET_ARG1(*call); 1134 1135 y = IPC_GET_ARG2(*call); … … 1139 1140 } 1140 1141 1141 ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),1142 IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *)vport);1142 imgmap_draw(shm, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), 1143 vport->width - x, vport->height - y, vport); 1143 1144 break; 1144 1145 case FB_DRAW_TEXT_DATA: … … 1167 1168 if (handled) 1168 1169 async_answer_0(callid, retval); 1170 1169 1171 return handled; 1170 1172 } 1171 1173 1172 1173 static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap) 1174 static void copy_vp_to_imgmap(viewport_t *vport, imgmap_t *imap) 1174 1175 { 1175 1176 unsigned int width = vport->width; … … 1178 1179 if (width + vport->x > screen.xres) 1179 1180 width = screen.xres - vport->x; 1181 1180 1182 if (height + vport->y > screen.yres) 1181 1183 height = screen.yres - vport->y; 1182 1184 1183 unsigned int realwidth = pmap->width <= width ? pmap->width : width;1184 unsigned int realheight = pmap->height <= height ? pmap->height : height;1185 unsigned int realwidth = imap->width <= width ? imap->width : width; 1186 unsigned int realheight = imap->height <= height ? imap->height : height; 1185 1187 1186 1188 unsigned int srcrowsize = vport->width * screen.pixelbytes; … … 1190 1192 for (y = 0; y < realheight; y++) { 1191 1193 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes; 1192 memcpy(pmap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize); 1193 } 1194 } 1195 1196 1197 /** Save viewport to pixmap 1198 * 1199 */ 1200 static int save_vp_to_pixmap(viewport_t *vport) 1201 { 1202 int pm; 1203 pixmap_t *pmap; 1204 1205 pm = find_free_pixmap(); 1206 if (pm == -1) 1194 memcpy(imap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize); 1195 } 1196 } 1197 1198 /** Save viewport to image map 1199 * 1200 */ 1201 static int save_vp_to_imgmap(viewport_t *vport) 1202 { 1203 int im = find_free_imgmap(); 1204 if (im == -1) 1207 1205 return ELIMIT; 1208 1206 1209 pmap = &pixmaps[pm];1210 pmap->data = malloc(screen.pixelbytes * vport->width * vport->height);1211 if (! pmap->data)1207 size_t size = screen.pixelbytes * vport->width * vport->height; 1208 imgmap_t *imap = malloc(sizeof(imgmap_t) + size); 1209 if (!imap) 1212 1210 return ENOMEM; 1213 1211 1214 pmap->width = vport->width; 1215 pmap->height = vport->height; 1216 1217 copy_vp_to_pixmap(vport, pmap); 1218 1219 return pm; 1220 } 1221 1222 1223 /** Draw pixmap on screen 1224 * 1225 * @param vp Viewport to draw on 1226 * @param pm Pixmap identifier 1227 * 1228 */ 1229 static int draw_pixmap(int vp, int pm) 1230 { 1231 pixmap_t *pmap = &pixmaps[pm]; 1212 imap->size = sizeof(imgmap_t) + size; 1213 imap->width = vport->width; 1214 imap->height = vport->height; 1215 imap->visual = (visual_t) -1; 1216 1217 copy_vp_to_imgmap(vport, imap); 1218 imgmaps[im] = imap; 1219 return im; 1220 } 1221 1222 /** Draw image map to screen 1223 * 1224 * @param vp Viewport to draw to 1225 * @param im Image map identifier 1226 * 1227 */ 1228 static int draw_imgmap(int vp, int im) 1229 { 1230 imgmap_t *imap = imgmaps[im]; 1231 if (!imap) 1232 return EINVAL; 1233 1232 1234 viewport_t *vport = &viewports[vp]; 1233 1235 … … 1237 1239 if (width + vport->x > screen.xres) 1238 1240 width = screen.xres - vport->x; 1241 1239 1242 if (height + vport->y > screen.yres) 1240 1243 height = screen.yres - vport->y; 1241 1244 1242 if (!pmap->data)1243 return EINVAL;1244 1245 unsigned int realwidth = pmap->width <= width ? pmap->width : width;1246 unsigned int realheight = pmap->height <= height ? pmap->height : height;1247 1248 unsigned int srcrowsize = vport->width * screen.pixelbytes;1249 unsigned int realrowsize = realwidth * screen.pixelbytes;1250 1251 unsigned int y;1252 for (y = 0; y < realheight; y++) {1253 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;1254 memcpy(screen.fb_addr + tmp, pmap->data + y * srcrowsize, realrowsize);1255 }1245 unsigned int realwidth = imap->width <= width ? imap->width : width; 1246 unsigned int realheight = imap->height <= height ? imap->height : height; 1247 1248 if (imap->visual == (visual_t) -1) { 1249 unsigned int srcrowsize = vport->width * screen.pixelbytes; 1250 unsigned int realrowsize = realwidth * screen.pixelbytes; 1251 1252 unsigned int y; 1253 for (y = 0; y < realheight; y++) { 1254 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes; 1255 memcpy(screen.fb_addr + tmp, imap->data + y * srcrowsize, realrowsize); 1256 } 1257 } else 1258 imgmap_draw(imap, 0, 0, realwidth, realheight, vport); 1256 1259 1257 1260 return EOK; 1258 1261 } 1259 1260 1262 1261 1263 /** Tick animation one step forward … … 1277 1279 continue; 1278 1280 1279 draw_ pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]);1281 draw_imgmap(animations[i].vp, animations[i].imgmaps[animations[i].pos]); 1280 1282 animations[i].pos = (animations[i].pos + 1) % animations[i].animlen; 1281 1283 } … … 1287 1289 static bool pointer_shown, pointer_enabled; 1288 1290 static int pointer_vport = -1; 1289 static int pointer_ pixmap = -1;1291 static int pointer_imgmap = -1; 1290 1292 1291 1293 … … 1310 1312 } 1311 1313 1312 if (pointer_ pixmap == -1)1313 pointer_ pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);1314 if (pointer_imgmap == -1) 1315 pointer_imgmap = save_vp_to_imgmap(&viewports[pointer_vport]); 1314 1316 else 1315 copy_vp_to_ pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);1317 copy_vp_to_imgmap(&viewports[pointer_vport], imgmaps[pointer_imgmap]); 1316 1318 1317 1319 /* Draw mouse pointer. */ … … 1338 1340 /* Restore image under the pointer. */ 1339 1341 if (pointer_shown) { 1340 draw_ pixmap(pointer_vport, pointer_pixmap);1342 draw_imgmap(pointer_vport, pointer_imgmap); 1341 1343 pointer_shown = 0; 1342 1344 } … … 1393 1395 animations[i].initialized = 0; 1394 1396 break; 1395 case FB_ANIM_ADD PIXMAP:1397 case FB_ANIM_ADDIMGMAP: 1396 1398 i = IPC_GET_ARG1(*call); 1397 1399 if (i >= MAX_ANIMATIONS || i < 0 || … … 1405 1407 } 1406 1408 newval = IPC_GET_ARG2(*call); 1407 if (newval < 0 || newval > MAX_ PIXMAPS ||1408 ! pixmaps[newval].data) {1409 if (newval < 0 || newval > MAX_IMGMAPS || 1410 !imgmaps[newval]) { 1409 1411 retval = EINVAL; 1410 1412 break; 1411 1413 } 1412 animations[i]. pixmaps[animations[i].animlen++] = newval;1414 animations[i].imgmaps[animations[i].animlen++] = newval; 1413 1415 break; 1414 1416 case FB_ANIM_CHGVP: … … 1449 1451 } 1450 1452 1451 1452 /** Handler for messages concerning pixmap handling 1453 * 1454 */ 1455 static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) 1453 /** Handler for messages concerning image map handling 1454 * 1455 */ 1456 static int imgmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp) 1456 1457 { 1457 1458 bool handled = true; … … 1460 1461 1461 1462 switch (IPC_GET_IMETHOD(*call)) { 1462 case FB_VP_DRAW_ PIXMAP:1463 case FB_VP_DRAW_IMGMAP: 1463 1464 nvp = IPC_GET_ARG1(*call); 1464 1465 if (nvp == -1) 1465 1466 nvp = vp; 1467 1466 1468 if (nvp < 0 || nvp >= MAX_VIEWPORTS || 1467 !viewports[nvp].initialized) {1469 !viewports[nvp].initialized) { 1468 1470 retval = EINVAL; 1469 1471 break; 1470 1472 } 1473 1471 1474 i = IPC_GET_ARG2(*call); 1472 retval = draw_ pixmap(nvp, i);1473 break; 1474 case FB_VP2 PIXMAP:1475 retval = draw_imgmap(nvp, i); 1476 break; 1477 case FB_VP2IMGMAP: 1475 1478 nvp = IPC_GET_ARG1(*call); 1476 1479 if (nvp == -1) 1477 1480 nvp = vp; 1481 1478 1482 if (nvp < 0 || nvp >= MAX_VIEWPORTS || 1479 !viewports[nvp].initialized)1483 !viewports[nvp].initialized) { 1480 1484 retval = EINVAL; 1481 else 1482 retval = save_vp_to_pixmap(&viewports[nvp]); 1483 break; 1484 case FB_DROP_PIXMAP: 1485 break; 1486 } 1487 1488 retval = save_vp_to_imgmap(&viewports[nvp]); 1489 break; 1490 case FB_DROP_IMGMAP: 1485 1491 i = IPC_GET_ARG1(*call); 1486 if (i >= MAX_ PIXMAPS) {1492 if (i >= MAX_IMGMAPS) { 1487 1493 retval = EINVAL; 1488 1494 break; 1489 1495 } 1490 if (pixmaps[i].data) { 1491 free(pixmaps[i].data); 1492 pixmaps[i].data = NULL; 1493 } 1496 1497 if (imgmaps[i]) { 1498 free(imgmaps[i]); 1499 imgmaps[i] = NULL; 1500 } 1501 1494 1502 break; 1495 1503 default: … … 1576 1584 * 1577 1585 */ 1578 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall) 1586 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall, 1587 void *arg) 1579 1588 { 1580 1589 unsigned int vp = 0; … … 1615 1624 continue; 1616 1625 1617 if ( pixmap_handle(callid, &call, vp))1626 if (imgmap_handle(callid, &call, vp)) 1618 1627 continue; 1619 1628 -
uspace/srv/hid/fb/fb.h
rd2c67e7 r8ff0bd2 39 39 #include <stdint.h> 40 40 41 typedef void (* putpixel_cb_t)(void *, unsigned int, unsigned int, uint32_t);42 43 41 extern int fb_init(void); 44 42 -
uspace/srv/hid/fb/main.c
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 53 53 54 54 // FIXME: remove this header 55 #include < kernel/ipc/ipc_methods.h>55 #include <abi/ipc/methods.h> 56 56 57 57 #define MAX_CONTROL 20 … … 315 315 * Main function of the thread serving client connections. 316 316 */ 317 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) 318 318 { 319 319 keyfield_t *interbuf = NULL; -
uspace/srv/hid/fb/serial_console.h
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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 219 kbd_event_type_t type; … … 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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(kbd_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( kbd_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( kbd_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( kbd_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(kbd_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
rd2c67e7 r8ff0bd2 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(kbd_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(kbd_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
rd2c67e7 r8ff0bd2 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(kbd_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(kbd_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
rd2c67e7 r8ff0bd2 1 1 /* 2 * Copyright (c) 201 0Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #include <ipc/adb.h> 38 38 #include <async.h> 39 #include < async_obsolete.h>39 #include <input.h> 40 40 #include <kbd_port.h> 41 41 #include <kbd.h> … … 43 43 #include <fcntl.h> 44 44 #include <errno.h> 45 #include <devmap.h> 46 #include <devmap_obsolete.h> 45 #include <loc.h> 47 46 48 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); 49 48 static void adb_kbd_reg0_data(uint16_t data); 50 49 51 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); 52 54 53 #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 }; 54 61 55 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) 56 66 { 57 67 const char *dev = "adb/kbd"; 58 devmap_handle_t handle; 68 service_id_t service_id; 69 async_exch_t *exch; 70 int rc; 59 71 60 int rc = devmap_device_get_handle(dev, &handle, 0); 61 if (rc == EOK) { 62 dev_phone = devmap_obsolete_device_connect(handle, 0); 63 if (dev_phone < 0) { 64 printf("%s: Failed to connect to device\n", NAME); 65 return dev_phone; 66 } 67 } else 72 kbd_dev = kdev; 73 74 rc = loc_service_get_id(dev, &service_id, 0); 75 if (rc != EOK) 68 76 return rc; 69 77 78 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0); 79 if (dev_sess == NULL) { 80 printf("%s: Failed to connect to device\n", NAME); 81 return ENOENT; 82 } 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; 89 } 90 70 91 /* NB: The callback connection is slotted for removal */ 71 rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events); 92 rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL); 93 async_exchange_end(exch); 72 94 if (rc != EOK) { 73 printf(NAME ": Failed to create callback from device\n"); 95 printf("%s: Failed to create callback from device\n", NAME); 96 async_hangup(dev_sess); 74 97 return rc; 75 98 } … … 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 */ … … 119 142 static void adb_kbd_reg0_data(uint16_t data) 120 143 { 121 uint8_t b0, b1; 122 123 b0 = (data >> 8) & 0xff; 124 b1 = data & 0xff; 125 144 uint8_t b0 = (data >> 8) & 0xff; 145 uint8_t b1 = data & 0xff; 146 126 147 if (b0 != 0xff) 127 kbd_push_scancode(b0); 148 kbd_push_data(kbd_dev, b0); 149 128 150 if (b1 != 0xff) 129 kbd_push_ scancode(b1);151 kbd_push_data(kbd_dev, b1); 130 152 } 131 153 -
uspace/srv/hid/input/port/adb_mouse.c
rd2c67e7 r8ff0bd2 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 < async_obsolete.h>39 #include < vfs/vfs.h>40 #include < fcntl.h>39 #include <input.h> 40 #include <mouse_port.h> 41 #include <mouse.h> 41 42 #include <errno.h> 42 #include <devmap.h> 43 #include <devmap_obsolete.h> 44 #include <char_mouse.h> 45 #include <mouse_port.h> 43 #include <loc.h> 44 #include <stdio.h> 46 45 47 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall); 46 static mouse_dev_t *mouse_dev; 47 static async_sess_t *dev_sess; 48 48 49 static int dev_phone; 50 51 #define NAME "char_mouse" 52 53 int mouse_port_init(void) 54 { 55 devmap_handle_t handle; 56 int rc = devmap_device_get_handle("char/ps2b", &handle, 57 IPC_FLAG_BLOCKING); 58 59 if (rc != EOK) { 60 printf("%s: Failed resolving PS/2\n", NAME); 61 return rc; 62 } 63 64 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 65 if (dev_phone < 0) { 66 printf("%s: Failed connecting to PS/2\n", NAME); 67 return ENOENT; 68 } 69 70 /* NB: The callback connection is slotted for removal */ 71 if (async_obsolete_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_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data); 90 } 91 92 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall) 49 static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg) 93 50 { 94 51 /* Ignore parameters, the connection is already opened */ 95 52 while (true) { 96 97 53 ipc_call_t call; 98 54 ipc_callid_t callid = async_get_call(&call); 99 55 100 56 int retval; 101 57 … … 104 60 return; 105 61 } 106 62 107 63 switch (IPC_GET_IMETHOD(call)) { 108 case IPC_FIRST_USER_METHOD:109 mouse_ handle_byte(IPC_GET_ARG1(call));64 case ADB_REG_NOTIF: 65 mouse_push_data(mouse_dev, IPC_GET_ARG1(call)); 110 66 break; 111 67 default: 112 68 retval = ENOENT; 113 69 } 70 114 71 async_answer_0(callid, retval); 115 72 } 116 73 } 117 74 75 static int adb_port_init(mouse_dev_t *mdev) 76 { 77 const char *dev = "adb/mouse"; 78 79 mouse_dev = mdev; 80 81 service_id_t service_id; 82 int rc = loc_service_get_id(dev, &service_id, 0); 83 if (rc != EOK) 84 return rc; 85 86 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0); 87 if (dev_sess == NULL) { 88 printf("%s: Failed to connect to device\n", NAME); 89 return ENOENT; 90 } 91 92 async_exch_t *exch = async_exchange_begin(dev_sess); 93 if (exch == NULL) { 94 printf("%s: Failed starting exchange with device\n", NAME); 95 async_hangup(dev_sess); 96 return ENOMEM; 97 } 98 99 /* NB: The callback connection is slotted for removal */ 100 rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL); 101 async_exchange_end(exch); 102 if (rc != EOK) { 103 printf("%s: Failed to create callback from device\n", NAME); 104 async_hangup(dev_sess); 105 return rc; 106 } 107 108 return EOK; 109 } 110 111 static void adb_port_yield(void) 112 { 113 } 114 115 static void adb_port_reclaim(void) 116 { 117 } 118 119 static void adb_port_write(uint8_t data) 120 { 121 } 122 123 mouse_port_ops_t adb_mouse_port = { 124 .init = adb_port_init, 125 .yield = adb_port_yield, 126 .reclaim = adb_port_reclaim, 127 .write = adb_port_write 128 }; 129 118 130 /** 119 131 * @} -
uspace/srv/hid/input/port/chardev.c
rd2c67e7 r8ff0bd2 1 1 /* 2 * Copyright (c) 20 09Jiri Svoboda2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #include <ipc/char.h> 38 38 #include <async.h> 39 #include < async_obsolete.h>39 #include <input.h> 40 40 #include <kbd_port.h> 41 41 #include <kbd.h> 42 #include <devmap.h> 43 #include <devmap_obsolete.h> 42 #include <loc.h> 44 43 #include <errno.h> 45 44 #include <stdio.h> 46 45 47 #define NAME "kbd/chardev" 46 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg); 48 47 49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall); 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); 50 52 51 static int dev_phone; 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; 52 62 53 63 /** List of devices to try connecting to. */ … … 59 69 static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]); 60 70 61 int kbd_port_init(void)71 static int chardev_port_init(kbd_dev_t *kdev) 62 72 { 63 devmap_handle_t handle; 73 service_id_t service_id; 74 async_exch_t *exch; 64 75 unsigned int i; 65 76 int rc; 66 77 78 kbd_dev = kdev; 79 67 80 for (i = 0; i < num_devs; i++) { 68 rc = devmap_device_get_handle(in_devs[i], &handle, 0);81 rc = loc_service_get_id(in_devs[i], &service_id, 0); 69 82 if (rc == EOK) 70 83 break; … … 76 89 } 77 90 78 dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING); 79 if (dev_phone < 0) { 91 dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 92 IPC_FLAG_BLOCKING); 93 if (dev_sess == NULL) { 80 94 printf("%s: Failed connecting to device\n", NAME); 81 95 return ENOENT; 82 96 } 83 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 84 105 /* NB: The callback connection is slotted for removal */ 85 if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) { 86 printf(NAME ": Failed to create callback from device\n"); 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); 87 112 return -1; 88 113 } 89 114 90 115 return 0; 91 116 } 92 117 93 void kbd_port_yield(void)118 static void chardev_port_yield(void) 94 119 { 95 120 } 96 121 97 void kbd_port_reclaim(void)122 static void chardev_port_reclaim(void) 98 123 { 99 124 } 100 125 101 void kbd_port_write(uint8_t data)126 static void chardev_port_write(uint8_t data) 102 127 { 103 async_obsolete_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); 104 136 } 105 137 106 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) 107 139 { 108 140 /* Ignore parameters, the connection is already opened */ … … 121 153 switch (IPC_GET_IMETHOD(call)) { 122 154 case CHAR_NOTIF_BYTE: 123 kbd_push_ scancode(IPC_GET_ARG1(call));155 kbd_push_data(kbd_dev, IPC_GET_ARG1(call)); 124 156 break; 125 157 default: -
uspace/srv/hid/input/port/gxemul.c
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 1 1 /* 2 2 * Copyright (c) 2006 Josef Cejka 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 39 40 #include <async_obsolete.h> 40 41 #include <sysinfo.h> 42 #include <input.h> 41 43 #include <kbd.h> 42 44 #include <kbd_port.h> 43 #include <sun.h>44 45 #include <ddi.h> 45 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; 46 61 47 62 /* NS16550 registers */ … … 91 106 92 107 static uintptr_t ns16550_physical; 93 static uintptr_t ns16550_kernel; 108 static uintptr_t ns16550_kernel; 94 109 95 int ns16550_port_init(void) 110 static kbd_dev_t *kbd_dev; 111 112 static int ns16550_port_init(kbd_dev_t *kdev) 96 113 { 97 114 void *vaddr; 98 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 99 124 if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK) 100 125 return -1; … … 116 141 } 117 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 118 156 static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call) 119 157 { 120 int scan_code = IPC_GET_ARG2(*call); 121 kbd_push_scancode(scan_code); 158 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 122 159 123 160 if (irc_service) -
uspace/srv/hid/input/port/pl050.c
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 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
rd2c67e7 r8ff0bd2 39 39 #include <ddi.h> 40 40 #include <libarch/ddi.h> 41 #include < devmap.h>41 #include <loc.h> 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 46 #include <async_obsolete.h> … … 54 54 55 55 // FIXME: remove this header 56 #include < kernel/ipc/ipc_methods.h>56 #include <abi/ipc/methods.h> 57 57 58 58 #define NAME "s3c24ser" 59 #define NAMESPACE "hid _in"59 #define NAMESPACE "hid" 60 60 61 61 static irq_cmd_t ts_irq_cmds[] = { … … 73 73 static s3c24xx_ts_t *ts; 74 74 75 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); 76 77 static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call); 77 78 static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts); … … 89 90 printf(NAME ": S3C24xx touchscreen driver\n"); 90 91 91 rc = devmap_driver_register(NAME, s3c24xx_ts_connection);92 rc = loc_server_register(NAME, s3c24xx_ts_connection); 92 93 if (rc < 0) { 93 94 printf(NAME ": Unable to register driver.\n"); … … 102 103 return -1; 103 104 104 rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);105 rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id); 105 106 if (rc != EOK) { 106 107 printf(NAME ": Unable to register device %s.\n", … … 283 284 button = 1; 284 285 press = 0; 285 async_obsolete_msg_2(ts->client_phone, M EVENT_BUTTON, button, press);286 async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press); 286 287 287 288 s3c24xx_ts_wait_for_int_mode(ts, updn_down); … … 324 325 325 326 /* Send notifications to client. */ 326 async_obsolete_msg_2(ts->client_phone, M EVENT_MOVE, dx, dy);327 async_obsolete_msg_2(ts->client_phone, M EVENT_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); 328 329 329 330 ts->last_x = x_pos; … … 373 374 374 375 /** Handle mouse client connection. */ 375 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) 376 378 { 377 379 ipc_callid_t callid; -
uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h
rd2c67e7 r8ff0bd2 124 124 int client_phone; 125 125 126 /** Device handle*/127 devmap_handle_t devmap_handle;126 /** Service ID */ 127 service_id_t service_id; 128 128 129 129 /** Device/driver state */
Note:
See TracChangeset
for help on using the changeset viewer.
