Changeset 00aece0 in mainline for uspace/srv/hid/input
- Timestamp:
- 2012-02-18T16:47:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (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/input
- Files:
-
- 2 deleted
- 14 edited
-
Makefile (modified) (2 diffs)
-
ctl/kbdev.c (modified) (2 diffs)
-
generic/input.c (modified) (14 diffs)
-
include/input.h (modified) (2 diffs)
-
include/mouse.h (modified) (1 diff)
-
include/mouse_proto.h (modified) (1 diff)
-
port/chardev.c (modified) (1 diff)
-
port/chardev_mouse.c (deleted)
-
port/gxemul.c (modified) (4 diffs)
-
port/msim.c (modified) (4 diffs)
-
port/niagara.c (modified) (3 diffs)
-
port/ns16550.c (modified) (6 diffs)
-
port/pl050.c (modified) (4 diffs)
-
proto/adb.c (modified) (1 diff)
-
proto/mousedev.c (modified) (7 diffs)
-
proto/ps2.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/Makefile
rbd5f3b7 r00aece0 43 43 port/adb_mouse.c \ 44 44 port/chardev.c \ 45 port/chardev_mouse.c \46 45 port/gxemul.c \ 47 46 port/msim.c \ … … 52 51 proto/adb.c \ 53 52 proto/mousedev.c \ 54 proto/ps2.c \55 53 ctl/apple.c \ 56 54 ctl/gxe_fb.c \ -
uspace/srv/hid/input/ctl/kbdev.c
rbd5f3b7 r00aece0 111 111 printf("%s: Failed allocating device structure for '%s'.\n", 112 112 NAME, kdev->svc_name); 113 async_hangup(sess); 113 114 return -1; 114 115 } … … 169 170 callid = async_get_call(&call); 170 171 if (!IPC_GET_IMETHOD(call)) { 171 /* XXX Handle hangup */172 kbdev_destroy(kbdev); 172 173 return; 173 174 } -
uspace/srv/hid/input/generic/input.c
rbd5f3b7 r00aece0 39 39 #include <adt/list.h> 40 40 #include <bool.h> 41 #include <fibril_synch.h> 41 42 #include <ipc/services.h> 42 43 #include <ipc/input.h> … … 47 48 #include <stdio.h> 48 49 #include <ns.h> 49 #include <ns_obsolete.h>50 50 #include <async.h> 51 #include <async_obsolete.h>52 51 #include <errno.h> 53 52 #include <adt/fifo.h> … … 63 62 #include <mouse.h> 64 63 65 // FIXME: remove this header66 #include <abi/ipc/methods.h>67 68 64 #define NUM_LAYOUTS 3 69 65 … … 77 73 static void kbd_devs_reclaim(void); 78 74 79 int client_phone = -1;75 async_sess_t *client_sess = NULL; 80 76 81 77 /** List of keyboard devices */ … … 86 82 87 83 bool irc_service = false; 88 int irc_phone = -1; 84 async_sess_t *irc_sess = NULL; 85 86 static FIBRIL_MUTEX_INITIALIZE(discovery_lock); 89 87 90 88 void kbd_push_data(kbd_dev_t *kdev, sysarg_t data) … … 170 168 171 169 ev.c = layout_parse_ev(kdev->active_layout, &ev); 172 async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, ev.type, ev.key, 173 ev.mods, ev.c); 170 171 async_exch_t *exch = async_exchange_begin(client_sess); 172 async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c); 173 async_exchange_end(exch); 174 174 } 175 175 176 176 /** Mouse pointer has moved. */ 177 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy) 178 { 179 async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy); 177 void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz) 178 { 179 async_exch_t *exch = async_exchange_begin(client_sess); 180 if (dx || dy) 181 async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy); 182 if (dz) { 183 // TODO: Implement proper wheel support 184 keycode_t code = dz > 0 ? KC_UP : KC_DOWN; 185 for (int i = 0; i < 3; ++i) { 186 async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0); 187 } 188 async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0); 189 } 190 async_exchange_end(exch); 180 191 } 181 192 … … 183 194 void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press) 184 195 { 185 async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press); 196 async_exch_t *exch = async_exchange_begin(client_sess); 197 async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press); 198 async_exchange_end(exch); 186 199 } 187 200 188 201 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg) 189 202 { 190 ipc_callid_t callid;191 ipc_call_t call;192 int retval;193 194 203 async_answer_0(iid, EOK); 195 204 196 205 while (true) { 197 callid = async_get_call(&call); 206 ipc_call_t call; 207 ipc_callid_t callid = async_get_call(&call); 198 208 199 209 if (!IPC_GET_IMETHOD(call)) { 200 if (client_ phone != -1) {201 async_ obsolete_hangup(client_phone);202 client_ phone = -1;210 if (client_sess != NULL) { 211 async_hangup(client_sess); 212 client_sess = NULL; 203 213 } 204 214 … … 207 217 } 208 218 209 switch (IPC_GET_IMETHOD(call)) { 210 case IPC_M_CONNECT_TO_ME: 211 if (client_phone != -1) { 212 retval = ELIMIT; 219 async_sess_t *sess = 220 async_callback_receive_start(EXCHANGE_SERIALIZE, &call); 221 if (sess != NULL) { 222 if (client_sess == NULL) { 223 client_sess = sess; 224 async_answer_0(callid, EOK); 225 } else 226 async_answer_0(callid, ELIMIT); 227 } else { 228 switch (IPC_GET_IMETHOD(call)) { 229 case INPUT_YIELD: 230 kbd_devs_yield(); 231 async_answer_0(callid, EOK); 213 232 break; 233 case INPUT_RECLAIM: 234 kbd_devs_reclaim(); 235 async_answer_0(callid, EOK); 236 break; 237 default: 238 async_answer_0(callid, EINVAL); 214 239 } 215 client_phone = IPC_GET_ARG5(call); 216 retval = 0; 217 break; 218 case INPUT_YIELD: 219 kbd_devs_yield(); 220 retval = 0; 221 break; 222 case INPUT_RECLAIM: 223 kbd_devs_reclaim(); 224 retval = 0; 225 break; 226 default: 227 retval = EINVAL; 228 } 229 230 async_answer_0(callid, retval); 240 } 231 241 } 232 242 } … … 399 409 * them automatically. 400 410 */ 401 #if defined(UARCH_amd64)402 kbd_add_dev(&chardev_port, &pc_ctl);403 #endif404 411 #if defined(UARCH_arm32) && defined(MACHINE_gta02) 405 412 kbd_add_dev(&chardev_port, &stty_ctl); … … 413 420 #if defined(UARCH_arm32) && defined(MACHINE_integratorcp) 414 421 kbd_add_dev(&pl050_port, &pc_ctl); 415 #endif416 #if defined(UARCH_ia32)417 kbd_add_dev(&chardev_port, &pc_ctl);418 #endif419 #if defined(MACHINE_i460GX)420 kbd_add_dev(&chardev_port, &pc_ctl);421 422 #endif 422 423 #if defined(MACHINE_ski) … … 452 453 * them automatically. 453 454 */ 454 #if defined(UARCH_amd64)455 mouse_add_dev(&chardev_mouse_port, &ps2_proto);456 #endif457 #if defined(UARCH_ia32)458 mouse_add_dev(&chardev_mouse_port, &ps2_proto);459 #endif460 #if defined(MACHINE_i460GX)461 mouse_add_dev(&chardev_mouse_port, &ps2_proto);462 #endif463 455 #if defined(UARCH_ppc32) 464 456 mouse_add_dev(&adb_mouse_port, &adb_proto); … … 604 596 int rc; 605 597 598 fibril_mutex_lock(&discovery_lock); 599 606 600 rc = dev_check_new_kbdevs(); 607 if (rc != EOK) 601 if (rc != EOK) { 602 fibril_mutex_unlock(&discovery_lock); 608 603 return rc; 604 } 609 605 610 606 rc = dev_check_new_mousedevs(); 611 if (rc != EOK) 607 if (rc != EOK) { 608 fibril_mutex_unlock(&discovery_lock); 612 609 return rc; 613 610 } 611 612 fibril_mutex_unlock(&discovery_lock); 613 614 614 return EOK; 615 615 } … … 648 648 649 649 if (irc_service) { 650 while (irc_phone < 0) 651 irc_phone = service_obsolete_connect_blocking(SERVICE_IRC, 0, 0); 650 while (irc_sess == NULL) 651 irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE, 652 SERVICE_IRC, 0, 0); 652 653 } 653 654 … … 659 660 660 661 /* Register driver */ 661 int rc = loc_server_register(NAME, client_connection); 662 async_set_client_connection(client_connection); 663 int rc = loc_server_register(NAME); 662 664 if (rc < 0) { 663 665 printf("%s: Unable to register server (%d)\n", NAME, rc); -
uspace/srv/hid/input/include/input.h
rbd5f3b7 r00aece0 40 40 41 41 #include <bool.h> 42 #include <async.h> 42 43 43 44 #define NAME "input" … … 45 46 46 47 extern bool irc_service; 47 extern int irc_phone;48 extern async_sess_t *irc_sess; 48 49 49 50 #endif -
uspace/srv/hid/input/include/mouse.h
rbd5f3b7 r00aece0 62 62 63 63 extern void mouse_push_data(mouse_dev_t *, sysarg_t); 64 extern void mouse_push_event_move(mouse_dev_t *, int, int );64 extern void mouse_push_event_move(mouse_dev_t *, int, int, int); 65 65 extern void mouse_push_event_button(mouse_dev_t *, int, int); 66 66 -
uspace/srv/hid/input/include/mouse_proto.h
rbd5f3b7 r00aece0 48 48 49 49 extern mouse_proto_ops_t adb_proto; 50 extern mouse_proto_ops_t ps2_proto;51 50 extern mouse_proto_ops_t mousedev_proto; 52 51 -
uspace/srv/hid/input/port/chardev.c
rbd5f3b7 r00aece0 63 63 /** List of devices to try connecting to. */ 64 64 static const char *in_devs[] = { 65 "char/ps2a",66 65 "char/s3c24ser" 67 66 }; -
uspace/srv/hid/input/port/gxemul.c
rbd5f3b7 r00aece0 57 57 static kbd_dev_t *kbd_dev; 58 58 59 static irq_pio_range_t gxemul_ranges[] = { 60 { 61 .base = 0, 62 .size = 1 63 } 64 }; 65 59 66 static irq_cmd_t gxemul_cmds[] = { 60 67 { … … 69 76 70 77 static irq_code_t gxemul_kbd = { 78 sizeof(gxemul_ranges) / sizeof(irq_pio_range_t), 79 gxemul_ranges, 71 80 sizeof(gxemul_cmds) / sizeof(irq_cmd_t), 72 81 gxemul_cmds … … 81 90 82 91 sysarg_t addr; 83 if (sysinfo_get_value("kbd.address. virtual", &addr) != EOK)92 if (sysinfo_get_value("kbd.address.physical", &addr) != EOK) 84 93 return -1; 85 94 … … 89 98 90 99 async_set_interrupt_received(gxemul_irq_handler); 100 gxemul_ranges[0].base = addr; 91 101 gxemul_cmds[0].addr = (void *) addr; 92 register_irq(inr, device_assign_devno(), 0, &gxemul_kbd);102 irq_register(inr, device_assign_devno(), 0, &gxemul_kbd); 93 103 return 0; 94 104 } -
uspace/srv/hid/input/port/msim.c
rbd5f3b7 r00aece0 57 57 static kbd_dev_t *kbd_dev; 58 58 59 static irq_pio_range_t msim_ranges[] = { 60 { 61 .base = 0, 62 .size = 1 63 } 64 }; 65 59 66 static irq_cmd_t msim_cmds[] = { 60 67 { … … 69 76 70 77 static irq_code_t msim_kbd = { 78 sizeof(msim_ranges) / sizeof(irq_pio_range_t), 79 msim_ranges, 71 80 sizeof(msim_cmds) / sizeof(irq_cmd_t), 72 81 msim_cmds … … 79 88 kbd_dev = kdev; 80 89 81 sysarg_t vaddr;82 if (sysinfo_get_value("kbd.address. virtual", &vaddr) != EOK)90 sysarg_t paddr; 91 if (sysinfo_get_value("kbd.address.physical", &paddr) != EOK) 83 92 return -1; 84 93 … … 87 96 return -1; 88 97 89 msim_cmds[0].addr = (void *) vaddr; 98 msim_ranges[0].base = paddr; 99 msim_cmds[0].addr = (void *) paddr; 90 100 async_set_interrupt_received(msim_irq_handler); 91 register_irq(inr, device_assign_devno(), 0, &msim_kbd);101 irq_register(inr, device_assign_devno(), 0, &msim_kbd); 92 102 93 103 return 0; -
uspace/srv/hid/input/port/niagara.c
rbd5f3b7 r00aece0 63 63 #define POLL_INTERVAL 10000 64 64 65 /**66 * Virtual address mapped to the buffer shared with the kernel counterpart.67 */68 static uintptr_t input_buffer_addr;69 70 65 /* 71 66 * Kernel counterpart of the driver pushes characters (it has read) here. … … 102 97 return -1; 103 98 104 input_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE); 105 int rc = physmem_map((void *) paddr, (void *) input_buffer_addr, 106 1, AS_AREA_READ | AS_AREA_WRITE); 107 99 int rc = physmem_map((void *) paddr, 1, 100 AS_AREA_READ | AS_AREA_WRITE, (void *) &input_buffer); 108 101 if (rc != 0) { 109 102 printf("Niagara: uspace driver couldn't map physical memory: %d\n", … … 111 104 return rc; 112 105 } 113 114 input_buffer = (input_buffer_t) input_buffer_addr;115 106 116 107 thread_id_t tid; -
uspace/srv/hid/input/port/ns16550.c
rbd5f3b7 r00aece0 38 38 #include <ipc/irc.h> 39 39 #include <async.h> 40 #include <async_obsolete.h>41 40 #include <sysinfo.h> 42 41 #include <input.h> … … 71 70 #define LSR_DATA_READY 0x01 72 71 72 static irq_pio_range_t ns16550_ranges[] = { 73 { 74 .base = 0, 75 .size = 8 76 } 77 }; 78 73 79 static irq_cmd_t ns16550_cmds[] = { 74 80 { … … 99 105 100 106 irq_code_t ns16550_kbd = { 107 sizeof(ns16550_ranges) / sizeof(irq_pio_range_t), 108 ns16550_ranges, 101 109 sizeof(ns16550_cmds) / sizeof(irq_cmd_t), 102 110 ns16550_cmds … … 106 114 107 115 static uintptr_t ns16550_physical; 108 static uintptr_t ns16550_kernel;109 116 110 117 static kbd_dev_t *kbd_dev; … … 125 132 return -1; 126 133 127 if (sysinfo_get_value("kbd.address.kernel", &ns16550_kernel) != EOK)128 return -1;129 130 134 sysarg_t inr; 131 135 if (sysinfo_get_value("kbd.inr", &inr) != EOK) 132 136 return -1; 133 137 134 ns16550_kbd.cmds[0].addr = (void *) (ns16550_kernel + LSR_REG); 135 ns16550_kbd.cmds[3].addr = (void *) (ns16550_kernel + RBR_REG); 138 ns16550_kbd.ranges[0].base = ns16550_physical; 139 ns16550_kbd.cmds[0].addr = (void *) (ns16550_physical + LSR_REG); 140 ns16550_kbd.cmds[3].addr = (void *) (ns16550_physical + RBR_REG); 136 141 137 142 async_set_interrupt_received(ns16550_irq_handler); 138 register_irq(inr, device_assign_devno(), inr, &ns16550_kbd);143 irq_register(inr, device_assign_devno(), inr, &ns16550_kbd); 139 144 140 145 return pio_enable((void *) ns16550_physical, 8, &vaddr); … … 158 163 kbd_push_data(kbd_dev, IPC_GET_ARG2(*call)); 159 164 160 if (irc_service) 161 async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT, 162 IPC_GET_IMETHOD(*call)); 165 if (irc_service) { 166 async_exch_t *exch = async_exchange_begin(irc_sess); 167 async_msg_1(exch, IRC_CLEAR_INTERRUPT, IPC_GET_IMETHOD(*call)); 168 async_exchange_end(exch); 169 } 163 170 } 164 171 -
uspace/srv/hid/input/port/pl050.c
rbd5f3b7 r00aece0 61 61 static kbd_dev_t *kbd_dev; 62 62 63 #define PL050_STAT 4 64 #define PL050_DATA 8 65 63 66 #define PL050_STAT_RXFULL (1 << 4) 67 68 static irq_pio_range_t pl050_ranges[] = { 69 { 70 .base = 0, 71 .size = 9, 72 } 73 }; 64 74 65 75 static irq_cmd_t pl050_cmds[] = { … … 91 101 92 102 static irq_code_t pl050_kbd = { 103 sizeof(pl050_ranges) / sizeof(irq_pio_range_t), 104 pl050_ranges, 93 105 sizeof(pl050_cmds) / sizeof(irq_cmd_t), 94 106 pl050_cmds … … 102 114 103 115 sysarg_t addr; 104 if (sysinfo_get_value("kbd.address. status", &addr) != EOK)116 if (sysinfo_get_value("kbd.address.physical", &addr) != EOK) 105 117 return -1; 106 118 107 pl050_kbd.cmds[0].addr = (void *) addr; 108 109 if (sysinfo_get_value("kbd.address.data", &addr) != EOK) 110 return -1; 111 112 pl050_kbd.cmds[3].addr = (void *) addr; 119 pl050_kbd.ranges[0].base = addr; 120 pl050_kbd.cmds[0].addr = (void *) addr + PL050_STAT; 121 pl050_kbd.cmds[3].addr = (void *) addr + PL050_DATA; 113 122 114 123 sysarg_t inr; … … 117 126 118 127 async_set_interrupt_received(pl050_irq_handler); 119 register_irq(inr, device_assign_devno(), 0, &pl050_kbd);128 irq_register(inr, device_assign_devno(), 0, &pl050_kbd); 120 129 121 130 return 0; -
uspace/srv/hid/input/proto/adb.c
rbd5f3b7 r00aece0 82 82 83 83 if (dx != 0 || dy != 0) 84 mouse_push_event_move(mouse_dev, dx, dy );84 mouse_push_event_move(mouse_dev, dx, dy, 0); 85 85 } 86 86 -
uspace/srv/hid/input/proto/mousedev.c
rbd5f3b7 r00aece0 54 54 /** Link to generic mouse device */ 55 55 mouse_dev_t *mouse_dev; 56 57 /** Session to mouse device */58 async_sess_t *sess;59 56 } mousedev_t; 60 57 … … 72 69 static void mousedev_destroy(mousedev_t *mousedev) 73 70 { 74 if (mousedev->sess != NULL)75 async_hangup(mousedev->sess);76 77 71 free(mousedev); 78 72 } … … 89 83 90 84 if (!IPC_GET_IMETHOD(call)) { 91 /* XXX Handle hangup */85 mousedev_destroy(mousedev); 92 86 return; 93 87 } … … 97 91 switch (IPC_GET_IMETHOD(call)) { 98 92 case MOUSEEV_MOVE_EVENT: 99 mouse_push_event_move(mousedev->mouse_dev, IPC_GET_ARG1(call), 100 IPC_GET_ARG2(call)); 93 mouse_push_event_move(mousedev->mouse_dev, 94 IPC_GET_ARG1(call), IPC_GET_ARG2(call), 95 IPC_GET_ARG3(call)); 101 96 retval = EOK; 102 97 break; 103 98 case MOUSEEV_BUTTON_EVENT: 104 mouse_push_event_button(mousedev->mouse_dev, IPC_GET_ARG1(call),105 IPC_GET_ARG 2(call));99 mouse_push_event_button(mousedev->mouse_dev, 100 IPC_GET_ARG1(call), IPC_GET_ARG2(call)); 106 101 retval = EOK; 107 102 break; … … 129 124 printf("%s: Failed allocating device structure for '%s'.\n", 130 125 NAME, mdev->svc_name); 126 async_hangup(sess); 131 127 return -1; 132 128 } 133 134 mousedev->sess = sess;135 129 136 130 async_exch_t *exch = async_exchange_begin(sess); … … 139 133 mdev->svc_name); 140 134 mousedev_destroy(mousedev); 135 async_hangup(sess); 141 136 return -1; 142 137 } … … 144 139 int rc = async_connect_to_me(exch, 0, 0, 0, mousedev_callback_conn, mousedev); 145 140 async_exchange_end(exch); 141 async_hangup(sess); 146 142 147 143 if (rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.
