[51d6f80] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2006 Josef Cejka
|
---|
[9be360ee] | 3 | * Copyright (c) 2011 Jiri Svoboda
|
---|
[51d6f80] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
[231a60a] | 30 | /**
|
---|
[5f88293] | 31 | * @addtogroup inputgen generic
|
---|
| 32 | * @brief HelenOS input server.
|
---|
| 33 | * @ingroup input
|
---|
[ce5bcb4] | 34 | * @{
|
---|
[215abc1] | 35 | */
|
---|
[ce5bcb4] | 36 | /** @file
|
---|
| 37 | */
|
---|
| 38 |
|
---|
[74017ce] | 39 | #include <adt/fifo.h>
|
---|
[9be360ee] | 40 | #include <adt/list.h>
|
---|
[fa09449] | 41 | #include <async.h>
|
---|
[74017ce] | 42 | #include <config.h>
|
---|
[51d6f80] | 43 | #include <errno.h>
|
---|
[74017ce] | 44 | #include <fibril.h>
|
---|
| 45 | #include <fibril_synch.h>
|
---|
| 46 | #include <io/chardev.h>
|
---|
[215abc1] | 47 | #include <io/console.h>
|
---|
| 48 | #include <io/keycode.h>
|
---|
[74017ce] | 49 | #include <ipc/services.h>
|
---|
| 50 | #include <ipc/input.h>
|
---|
[15f3c3f] | 51 | #include <loc.h>
|
---|
[74017ce] | 52 | #include <ns.h>
|
---|
| 53 | #include <stdbool.h>
|
---|
| 54 | #include <stdio.h>
|
---|
| 55 | #include <stdlib.h>
|
---|
[593e023] | 56 | #include <str_error.h>
|
---|
[74017ce] | 57 |
|
---|
| 58 | #include "input.h"
|
---|
[b6a088f] | 59 | #include "kbd.h"
|
---|
| 60 | #include "kbd_port.h"
|
---|
| 61 | #include "kbd_ctl.h"
|
---|
[74017ce] | 62 | #include "layout.h"
|
---|
[b6a088f] | 63 | #include "mouse.h"
|
---|
| 64 | #include "mouse_proto.h"
|
---|
[2a72d9f] | 65 | #include "serial.h"
|
---|
[51d6f80] | 66 |
|
---|
[c928bb7] | 67 | #define NUM_LAYOUTS 4
|
---|
[1875a0c] | 68 |
|
---|
| 69 | static layout_ops_t *layout[NUM_LAYOUTS] = {
|
---|
| 70 | &us_qwerty_ops,
|
---|
| 71 | &us_dvorak_ops,
|
---|
[c928bb7] | 72 | &cz_ops,
|
---|
| 73 | &ar_ops
|
---|
[1875a0c] | 74 | };
|
---|
[854387b] | 75 |
|
---|
[593e023] | 76 | typedef struct {
|
---|
| 77 | /** Link into the list of clients */
|
---|
| 78 | link_t link;
|
---|
| 79 |
|
---|
| 80 | /** Indicate whether the client is active */
|
---|
| 81 | bool active;
|
---|
| 82 |
|
---|
| 83 | /** Client callback session */
|
---|
| 84 | async_sess_t *sess;
|
---|
| 85 | } client_t;
|
---|
[9be360ee] | 86 |
|
---|
[593e023] | 87 | /** List of clients */
|
---|
| 88 | static list_t clients;
|
---|
| 89 | static client_t *active_client = NULL;
|
---|
[d1eece6] | 90 |
|
---|
[380e23a3] | 91 | /** Kernel override */
|
---|
| 92 | static bool active = true;
|
---|
| 93 |
|
---|
[a79b42a] | 94 | /** Serial console specified by the user */
|
---|
| 95 | static char *serial_console;
|
---|
| 96 |
|
---|
[9be360ee] | 97 | /** List of keyboard devices */
|
---|
[b72efe8] | 98 | static list_t kbd_devs;
|
---|
[b1bdc7a4] | 99 |
|
---|
[854eddd6] | 100 | /** List of mouse devices */
|
---|
[1875a0c] | 101 | static list_t mouse_devs;
|
---|
[854eddd6] | 102 |
|
---|
[2a72d9f] | 103 | /** List of serial devices */
|
---|
| 104 | static list_t serial_devs;
|
---|
| 105 |
|
---|
[10a5479d] | 106 | static FIBRIL_MUTEX_INITIALIZE(discovery_lock);
|
---|
| 107 |
|
---|
[593e023] | 108 | static void *client_data_create(void)
|
---|
| 109 | {
|
---|
| 110 | client_t *client = (client_t *) calloc(1, sizeof(client_t));
|
---|
| 111 | if (client == NULL)
|
---|
| 112 | return NULL;
|
---|
| 113 |
|
---|
| 114 | link_initialize(&client->link);
|
---|
| 115 | client->active = false;
|
---|
| 116 | client->sess = NULL;
|
---|
| 117 |
|
---|
| 118 | list_append(&client->link, &clients);
|
---|
| 119 |
|
---|
| 120 | return client;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | static void client_data_destroy(void *data)
|
---|
| 124 | {
|
---|
| 125 | client_t *client = (client_t *) data;
|
---|
| 126 |
|
---|
| 127 | list_remove(&client->link);
|
---|
| 128 | free(client);
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[1875a0c] | 131 | void kbd_push_data(kbd_dev_t *kdev, sysarg_t data)
|
---|
| 132 | {
|
---|
| 133 | (*kdev->ctl_ops->parse)(data);
|
---|
| 134 | }
|
---|
[0175246] | 135 |
|
---|
[1875a0c] | 136 | void mouse_push_data(mouse_dev_t *mdev, sysarg_t data)
|
---|
[f89979b] | 137 | {
|
---|
[1875a0c] | 138 | (*mdev->proto_ops->parse)(data);
|
---|
[f89979b] | 139 | }
|
---|
| 140 |
|
---|
[1875a0c] | 141 | void kbd_push_event(kbd_dev_t *kdev, int type, unsigned int key)
|
---|
[085bd54] | 142 | {
|
---|
[79ae36dd] | 143 | kbd_event_t ev;
|
---|
[1875a0c] | 144 | unsigned int mod_mask;
|
---|
| 145 |
|
---|
[d1eece6] | 146 | switch (key) {
|
---|
[ce3efa0] | 147 | case KC_LCTRL:
|
---|
| 148 | mod_mask = KM_LCTRL;
|
---|
| 149 | break;
|
---|
| 150 | case KC_RCTRL:
|
---|
| 151 | mod_mask = KM_RCTRL;
|
---|
| 152 | break;
|
---|
| 153 | case KC_LSHIFT:
|
---|
| 154 | mod_mask = KM_LSHIFT;
|
---|
| 155 | break;
|
---|
| 156 | case KC_RSHIFT:
|
---|
| 157 | mod_mask = KM_RSHIFT;
|
---|
| 158 | break;
|
---|
| 159 | case KC_LALT:
|
---|
| 160 | mod_mask = KM_LALT;
|
---|
| 161 | break;
|
---|
| 162 | case KC_RALT:
|
---|
| 163 | mod_mask = KM_RALT;
|
---|
| 164 | break;
|
---|
| 165 | default:
|
---|
| 166 | mod_mask = 0;
|
---|
[d1eece6] | 167 | }
|
---|
[1875a0c] | 168 |
|
---|
[d1eece6] | 169 | if (mod_mask != 0) {
|
---|
[215abc1] | 170 | if (type == KEY_PRESS)
|
---|
[2f7a564] | 171 | kdev->mods = kdev->mods | mod_mask;
|
---|
[d1eece6] | 172 | else
|
---|
[2f7a564] | 173 | kdev->mods = kdev->mods & ~mod_mask;
|
---|
[d1eece6] | 174 | }
|
---|
[1875a0c] | 175 |
|
---|
[d1eece6] | 176 | switch (key) {
|
---|
[ce3efa0] | 177 | case KC_CAPS_LOCK:
|
---|
| 178 | mod_mask = KM_CAPS_LOCK;
|
---|
| 179 | break;
|
---|
| 180 | case KC_NUM_LOCK:
|
---|
| 181 | mod_mask = KM_NUM_LOCK;
|
---|
| 182 | break;
|
---|
| 183 | case KC_SCROLL_LOCK:
|
---|
| 184 | mod_mask = KM_SCROLL_LOCK;
|
---|
| 185 | break;
|
---|
| 186 | default:
|
---|
| 187 | mod_mask = 0;
|
---|
[d1eece6] | 188 | }
|
---|
[1875a0c] | 189 |
|
---|
[12b6796] | 190 | if (mod_mask != 0) {
|
---|
[215abc1] | 191 | if (type == KEY_PRESS) {
|
---|
[12b6796] | 192 | /*
|
---|
| 193 | * Only change lock state on transition from released
|
---|
| 194 | * to pressed. This prevents autorepeat from messing
|
---|
| 195 | * up the lock state.
|
---|
| 196 | */
|
---|
[2f7a564] | 197 | kdev->mods = kdev->mods ^ (mod_mask & ~kdev->lock_keys);
|
---|
| 198 | kdev->lock_keys = kdev->lock_keys | mod_mask;
|
---|
[1875a0c] | 199 |
|
---|
[c145bc2] | 200 | /* Update keyboard lock indicator lights. */
|
---|
[2f7a564] | 201 | (*kdev->ctl_ops->set_ind)(kdev, kdev->mods);
|
---|
[12b6796] | 202 | } else {
|
---|
[2f7a564] | 203 | kdev->lock_keys = kdev->lock_keys & ~mod_mask;
|
---|
[12b6796] | 204 | }
|
---|
| 205 | }
|
---|
[1875a0c] | 206 |
|
---|
[ce3efa0] | 207 | // TODO: More elegant layout switching
|
---|
| 208 |
|
---|
| 209 | if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
|
---|
| 210 | (key == KC_F1)) {
|
---|
[2f7a564] | 211 | layout_destroy(kdev->active_layout);
|
---|
| 212 | kdev->active_layout = layout_create(layout[0]);
|
---|
[0175246] | 213 | return;
|
---|
| 214 | }
|
---|
[1875a0c] | 215 |
|
---|
[ce3efa0] | 216 | if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
|
---|
| 217 | (key == KC_F2)) {
|
---|
[2f7a564] | 218 | layout_destroy(kdev->active_layout);
|
---|
| 219 | kdev->active_layout = layout_create(layout[1]);
|
---|
[0175246] | 220 | return;
|
---|
| 221 | }
|
---|
[1875a0c] | 222 |
|
---|
[ce3efa0] | 223 | if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
|
---|
| 224 | (key == KC_F3)) {
|
---|
[2f7a564] | 225 | layout_destroy(kdev->active_layout);
|
---|
| 226 | kdev->active_layout = layout_create(layout[2]);
|
---|
[0175246] | 227 | return;
|
---|
| 228 | }
|
---|
[1875a0c] | 229 |
|
---|
[ce3efa0] | 230 | if ((type == KEY_PRESS) && (kdev->mods & KM_LCTRL) &&
|
---|
| 231 | (key == KC_F4)) {
|
---|
[c928bb7] | 232 | layout_destroy(kdev->active_layout);
|
---|
| 233 | kdev->active_layout = layout_create(layout[3]);
|
---|
| 234 | return;
|
---|
| 235 | }
|
---|
| 236 |
|
---|
[f89979b] | 237 | ev.type = type;
|
---|
| 238 | ev.key = key;
|
---|
[2f7a564] | 239 | ev.mods = kdev->mods;
|
---|
[1875a0c] | 240 |
|
---|
[2f7a564] | 241 | ev.c = layout_parse_ev(kdev->active_layout, &ev);
|
---|
[5da7199] | 242 |
|
---|
[593e023] | 243 | list_foreach(clients, link, client_t, client) {
|
---|
| 244 | if (client->active) {
|
---|
| 245 | async_exch_t *exch = async_exchange_begin(client->sess);
|
---|
| 246 | async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
|
---|
| 247 | async_exchange_end(exch);
|
---|
| 248 | }
|
---|
| 249 | }
|
---|
[854eddd6] | 250 | }
|
---|
| 251 |
|
---|
[593e023] | 252 | /** Mouse pointer has moved (relative mode). */
|
---|
[edb3cf2] | 253 | void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy, int dz)
|
---|
[854eddd6] | 254 | {
|
---|
[593e023] | 255 | list_foreach(clients, link, client_t, client) {
|
---|
| 256 | if (client->active) {
|
---|
| 257 | async_exch_t *exch = async_exchange_begin(client->sess);
|
---|
| 258 |
|
---|
| 259 | if ((dx) || (dy))
|
---|
| 260 | async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
|
---|
| 261 |
|
---|
| 262 | if (dz) {
|
---|
| 263 | // TODO: Implement proper wheel support
|
---|
| 264 | keycode_t code = dz > 0 ? KC_UP : KC_DOWN;
|
---|
| 265 |
|
---|
| 266 | for (unsigned int i = 0; i < 3; i++)
|
---|
| 267 | async_msg_4(exch, INPUT_EVENT_KEY, KEY_PRESS, code, 0, 0);
|
---|
| 268 |
|
---|
| 269 | async_msg_4(exch, INPUT_EVENT_KEY, KEY_RELEASE, code, 0, 0);
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 | async_exchange_end(exch);
|
---|
[edb3cf2] | 273 | }
|
---|
| 274 | }
|
---|
[854eddd6] | 275 | }
|
---|
| 276 |
|
---|
[593e023] | 277 | /** Mouse pointer has moved (absolute mode). */
|
---|
[8a99c7e] | 278 | void mouse_push_event_abs_move(mouse_dev_t *mdev, unsigned int x, unsigned int y,
|
---|
| 279 | unsigned int max_x, unsigned int max_y)
|
---|
| 280 | {
|
---|
[593e023] | 281 | list_foreach(clients, link, client_t, client) {
|
---|
| 282 | if (client->active) {
|
---|
| 283 | if ((max_x) && (max_y)) {
|
---|
| 284 | async_exch_t *exch = async_exchange_begin(client->sess);
|
---|
| 285 | async_msg_4(exch, INPUT_EVENT_ABS_MOVE, x, y, max_x, max_y);
|
---|
| 286 | async_exchange_end(exch);
|
---|
| 287 | }
|
---|
| 288 | }
|
---|
[8a99c7e] | 289 | }
|
---|
| 290 | }
|
---|
| 291 |
|
---|
[854eddd6] | 292 | /** Mouse button has been pressed. */
|
---|
[1875a0c] | 293 | void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press)
|
---|
[854eddd6] | 294 | {
|
---|
[593e023] | 295 | list_foreach(clients, link, client_t, client) {
|
---|
| 296 | if (client->active) {
|
---|
| 297 | async_exch_t *exch = async_exchange_begin(client->sess);
|
---|
| 298 | async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
|
---|
| 299 | async_exchange_end(exch);
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
[085bd54] | 302 | }
|
---|
| 303 |
|
---|
[593e023] | 304 | /** Arbitrate client actiovation */
|
---|
[380e23a3] | 305 | static void client_arbitration(void)
|
---|
[593e023] | 306 | {
|
---|
| 307 | /* Mutual exclusion of active clients */
|
---|
| 308 | list_foreach(clients, link, client_t, client)
|
---|
[380e23a3] | 309 | client->active = ((active) && (client == active_client));
|
---|
[593e023] | 310 |
|
---|
| 311 | /* Notify clients about the arbitration */
|
---|
| 312 | list_foreach(clients, link, client_t, client) {
|
---|
| 313 | async_exch_t *exch = async_exchange_begin(client->sess);
|
---|
| 314 | async_msg_0(exch, client->active ?
|
---|
| 315 | INPUT_EVENT_ACTIVE : INPUT_EVENT_DEACTIVE);
|
---|
| 316 | async_exchange_end(exch);
|
---|
| 317 | }
|
---|
| 318 | }
|
---|
| 319 |
|
---|
| 320 | /** New client connection */
|
---|
[9934f7d] | 321 | static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
|
---|
[085bd54] | 322 | {
|
---|
[593e023] | 323 | client_t *client = (client_t *) async_get_client_data();
|
---|
| 324 | if (client == NULL) {
|
---|
| 325 | async_answer_0(iid, ENOMEM);
|
---|
| 326 | return;
|
---|
| 327 | }
|
---|
| 328 |
|
---|
[ffa2c8ef] | 329 | async_answer_0(iid, EOK);
|
---|
[1875a0c] | 330 |
|
---|
[79ae36dd] | 331 | while (true) {
|
---|
[5da7199] | 332 | ipc_call_t call;
|
---|
| 333 | ipc_callid_t callid = async_get_call(&call);
|
---|
[79ae36dd] | 334 |
|
---|
| 335 | if (!IPC_GET_IMETHOD(call)) {
|
---|
[593e023] | 336 | if (client->sess != NULL) {
|
---|
| 337 | async_hangup(client->sess);
|
---|
| 338 | client->sess = NULL;
|
---|
[47a350f] | 339 | }
|
---|
| 340 |
|
---|
[ffa2c8ef] | 341 | async_answer_0(callid, EOK);
|
---|
[085bd54] | 342 | return;
|
---|
[79ae36dd] | 343 | }
|
---|
| 344 |
|
---|
[5da7199] | 345 | async_sess_t *sess =
|
---|
| 346 | async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
|
---|
| 347 | if (sess != NULL) {
|
---|
[593e023] | 348 | if (client->sess == NULL) {
|
---|
| 349 | client->sess = sess;
|
---|
[5da7199] | 350 | async_answer_0(callid, EOK);
|
---|
| 351 | } else
|
---|
| 352 | async_answer_0(callid, ELIMIT);
|
---|
| 353 | } else {
|
---|
| 354 | switch (IPC_GET_IMETHOD(call)) {
|
---|
[593e023] | 355 | case INPUT_ACTIVATE:
|
---|
| 356 | active_client = client;
|
---|
[380e23a3] | 357 | client_arbitration();
|
---|
[5da7199] | 358 | async_answer_0(callid, EOK);
|
---|
[085bd54] | 359 | break;
|
---|
[5da7199] | 360 | default:
|
---|
| 361 | async_answer_0(callid, EINVAL);
|
---|
[085bd54] | 362 | }
|
---|
| 363 | }
|
---|
[1875a0c] | 364 | }
|
---|
[085bd54] | 365 | }
|
---|
| 366 |
|
---|
[01c3bb4] | 367 | static void kconsole_event_handler(ipc_call_t *call, void *arg)
|
---|
[593e023] | 368 | {
|
---|
| 369 | if (IPC_GET_ARG1(*call)) {
|
---|
| 370 | /* Kernel console activated */
|
---|
[380e23a3] | 371 | active = false;
|
---|
[593e023] | 372 | } else {
|
---|
| 373 | /* Kernel console deactivated */
|
---|
[380e23a3] | 374 | active = true;
|
---|
[593e023] | 375 | }
|
---|
[380e23a3] | 376 |
|
---|
| 377 | client_arbitration();
|
---|
[593e023] | 378 | }
|
---|
| 379 |
|
---|
[2f7a564] | 380 | static kbd_dev_t *kbd_dev_new(void)
|
---|
[b1bdc7a4] | 381 | {
|
---|
[1875a0c] | 382 | kbd_dev_t *kdev = calloc(1, sizeof(kbd_dev_t));
|
---|
[9be360ee] | 383 | if (kdev == NULL) {
|
---|
[1875a0c] | 384 | printf("%s: Error allocating keyboard device. "
|
---|
| 385 | "Out of memory.\n", NAME);
|
---|
[2f7a564] | 386 | return NULL;
|
---|
[9be360ee] | 387 | }
|
---|
[1875a0c] | 388 |
|
---|
[593e023] | 389 | link_initialize(&kdev->link);
|
---|
[1875a0c] | 390 |
|
---|
[2f7a564] | 391 | kdev->mods = KM_NUM_LOCK;
|
---|
| 392 | kdev->lock_keys = 0;
|
---|
| 393 | kdev->active_layout = layout_create(layout[0]);
|
---|
[1875a0c] | 394 |
|
---|
[2f7a564] | 395 | return kdev;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
[1875a0c] | 398 | static mouse_dev_t *mouse_dev_new(void)
|
---|
| 399 | {
|
---|
| 400 | mouse_dev_t *mdev = calloc(1, sizeof(mouse_dev_t));
|
---|
| 401 | if (mdev == NULL) {
|
---|
[2a72d9f] | 402 | printf("%s: Error allocating mouse device. "
|
---|
[1875a0c] | 403 | "Out of memory.\n", NAME);
|
---|
| 404 | return NULL;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[593e023] | 407 | link_initialize(&mdev->link);
|
---|
[1875a0c] | 408 |
|
---|
| 409 | return mdev;
|
---|
| 410 | }
|
---|
| 411 |
|
---|
[2a72d9f] | 412 | static serial_dev_t *serial_dev_new(void)
|
---|
| 413 | {
|
---|
| 414 | serial_dev_t *sdev = calloc(1, sizeof(serial_dev_t));
|
---|
| 415 | if (sdev == NULL) {
|
---|
| 416 | printf("%s: Error allocating serial device. "
|
---|
| 417 | "Out of memory.\n", NAME);
|
---|
| 418 | return NULL;
|
---|
| 419 | }
|
---|
| 420 |
|
---|
| 421 | sdev->kdev = kbd_dev_new();
|
---|
| 422 | if (sdev->kdev == NULL) {
|
---|
| 423 | free(sdev);
|
---|
| 424 | return NULL;
|
---|
| 425 | }
|
---|
| 426 |
|
---|
| 427 | link_initialize(&sdev->link);
|
---|
| 428 |
|
---|
| 429 | return sdev;
|
---|
| 430 | }
|
---|
| 431 |
|
---|
[2f7a564] | 432 | /** Add new legacy keyboard device. */
|
---|
| 433 | static void kbd_add_dev(kbd_port_ops_t *port, kbd_ctl_ops_t *ctl)
|
---|
| 434 | {
|
---|
[1875a0c] | 435 | kbd_dev_t *kdev = kbd_dev_new();
|
---|
[2f7a564] | 436 | if (kdev == NULL)
|
---|
| 437 | return;
|
---|
[1875a0c] | 438 |
|
---|
[9be360ee] | 439 | kdev->port_ops = port;
|
---|
| 440 | kdev->ctl_ops = ctl;
|
---|
[cce8a83] | 441 | kdev->svc_id = 0;
|
---|
[1875a0c] | 442 |
|
---|
[9be360ee] | 443 | /* Initialize port driver. */
|
---|
[af897ff0] | 444 | if ((*kdev->port_ops->init)(kdev) != 0)
|
---|
| 445 | goto fail;
|
---|
[1875a0c] | 446 |
|
---|
[9be360ee] | 447 | /* Initialize controller driver. */
|
---|
| 448 | if ((*kdev->ctl_ops->init)(kdev) != 0) {
|
---|
| 449 | /* XXX Uninit port */
|
---|
| 450 | goto fail;
|
---|
| 451 | }
|
---|
[1875a0c] | 452 |
|
---|
[593e023] | 453 | list_append(&kdev->link, &kbd_devs);
|
---|
[9be360ee] | 454 | return;
|
---|
[1875a0c] | 455 |
|
---|
[9be360ee] | 456 | fail:
|
---|
| 457 | free(kdev);
|
---|
| 458 | }
|
---|
| 459 |
|
---|
[af897ff0] | 460 | /** Add new kbdev device.
|
---|
| 461 | *
|
---|
[593e023] | 462 | * @param service_id Service ID of the keyboard device
|
---|
[1875a0c] | 463 | *
|
---|
[af897ff0] | 464 | */
|
---|
[cce8a83] | 465 | static int kbd_add_kbdev(service_id_t service_id, kbd_dev_t **kdevp)
|
---|
[af897ff0] | 466 | {
|
---|
[1875a0c] | 467 | kbd_dev_t *kdev = kbd_dev_new();
|
---|
[2f7a564] | 468 | if (kdev == NULL)
|
---|
[af897ff0] | 469 | return -1;
|
---|
[1875a0c] | 470 |
|
---|
[cce8a83] | 471 | kdev->svc_id = service_id;
|
---|
[af897ff0] | 472 | kdev->port_ops = NULL;
|
---|
| 473 | kdev->ctl_ops = &kbdev_ctl;
|
---|
[1875a0c] | 474 |
|
---|
[46577995] | 475 | errno_t rc = loc_service_get_name(service_id, &kdev->svc_name);
|
---|
[cce8a83] | 476 | if (rc != EOK) {
|
---|
| 477 | kdev->svc_name = NULL;
|
---|
| 478 | goto fail;
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[af897ff0] | 481 | /* Initialize controller driver. */
|
---|
| 482 | if ((*kdev->ctl_ops->init)(kdev) != 0) {
|
---|
| 483 | goto fail;
|
---|
| 484 | }
|
---|
[1875a0c] | 485 |
|
---|
[593e023] | 486 | list_append(&kdev->link, &kbd_devs);
|
---|
[cce8a83] | 487 | *kdevp = kdev;
|
---|
[d5c1051] | 488 | return 0;
|
---|
[1875a0c] | 489 |
|
---|
[af897ff0] | 490 | fail:
|
---|
[cce8a83] | 491 | if (kdev->svc_name != NULL)
|
---|
| 492 | free(kdev->svc_name);
|
---|
[af897ff0] | 493 | free(kdev);
|
---|
| 494 | return -1;
|
---|
| 495 | }
|
---|
| 496 |
|
---|
[1875a0c] | 497 | /** Add new mousedev device.
|
---|
| 498 | *
|
---|
[593e023] | 499 | * @param service_id Service ID of the mouse device
|
---|
[1875a0c] | 500 | *
|
---|
| 501 | */
|
---|
[cce8a83] | 502 | static int mouse_add_mousedev(service_id_t service_id, mouse_dev_t **mdevp)
|
---|
[1875a0c] | 503 | {
|
---|
| 504 | mouse_dev_t *mdev = mouse_dev_new();
|
---|
| 505 | if (mdev == NULL)
|
---|
| 506 | return -1;
|
---|
| 507 |
|
---|
[cce8a83] | 508 | mdev->svc_id = service_id;
|
---|
[1875a0c] | 509 | mdev->port_ops = NULL;
|
---|
| 510 | mdev->proto_ops = &mousedev_proto;
|
---|
| 511 |
|
---|
[46577995] | 512 | errno_t rc = loc_service_get_name(service_id, &mdev->svc_name);
|
---|
[cce8a83] | 513 | if (rc != EOK) {
|
---|
| 514 | mdev->svc_name = NULL;
|
---|
| 515 | goto fail;
|
---|
| 516 | }
|
---|
| 517 |
|
---|
[1875a0c] | 518 | /* Initialize controller driver. */
|
---|
| 519 | if ((*mdev->proto_ops->init)(mdev) != 0) {
|
---|
| 520 | goto fail;
|
---|
| 521 | }
|
---|
| 522 |
|
---|
[593e023] | 523 | list_append(&mdev->link, &mouse_devs);
|
---|
[cce8a83] | 524 | *mdevp = mdev;
|
---|
[d5c1051] | 525 | return 0;
|
---|
[1875a0c] | 526 |
|
---|
| 527 | fail:
|
---|
| 528 | free(mdev);
|
---|
| 529 | return -1;
|
---|
| 530 | }
|
---|
| 531 |
|
---|
[46577995] | 532 | static errno_t serial_consumer(void *arg)
|
---|
[2a72d9f] | 533 | {
|
---|
| 534 | serial_dev_t *sdev = (serial_dev_t *) arg;
|
---|
| 535 |
|
---|
| 536 | while (true) {
|
---|
| 537 | uint8_t data;
|
---|
[74017ce] | 538 | size_t nread;
|
---|
[2a72d9f] | 539 |
|
---|
[74017ce] | 540 | chardev_read(sdev->chardev, &data, sizeof(data), &nread);
|
---|
| 541 | /* XXX Handle error */
|
---|
[2a72d9f] | 542 | kbd_push_data(sdev->kdev, data);
|
---|
| 543 | }
|
---|
| 544 |
|
---|
| 545 | return EOK;
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /** Add new serial console device.
|
---|
| 549 | *
|
---|
| 550 | * @param service_id Service ID of the chardev device
|
---|
| 551 | *
|
---|
| 552 | */
|
---|
| 553 | static int serial_add_srldev(service_id_t service_id, serial_dev_t **sdevp)
|
---|
| 554 | {
|
---|
[a79b42a] | 555 | bool match = false;
|
---|
[46577995] | 556 | errno_t rc;
|
---|
[a79b42a] | 557 |
|
---|
[2a72d9f] | 558 | serial_dev_t *sdev = serial_dev_new();
|
---|
| 559 | if (sdev == NULL)
|
---|
| 560 | return -1;
|
---|
| 561 |
|
---|
| 562 | sdev->kdev->svc_id = service_id;
|
---|
| 563 |
|
---|
[74017ce] | 564 | rc = loc_service_get_name(service_id, &sdev->kdev->svc_name);
|
---|
[a79b42a] | 565 | if (rc != EOK)
|
---|
[2a72d9f] | 566 | goto fail;
|
---|
| 567 |
|
---|
| 568 | list_append(&sdev->link, &serial_devs);
|
---|
| 569 |
|
---|
[a79b42a] | 570 | /*
|
---|
| 571 | * Is this the device the user wants to use as a serial console?
|
---|
| 572 | */
|
---|
| 573 | match = (serial_console != NULL) &&
|
---|
| 574 | !str_cmp(serial_console, sdev->kdev->svc_name);
|
---|
| 575 |
|
---|
| 576 | if (match) {
|
---|
| 577 | sdev->kdev->ctl_ops = &stty_ctl;
|
---|
| 578 |
|
---|
| 579 | /* Initialize controller driver. */
|
---|
| 580 | if ((*sdev->kdev->ctl_ops->init)(sdev->kdev) != 0) {
|
---|
| 581 | list_remove(&sdev->link);
|
---|
| 582 | goto fail;
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | sdev->sess = loc_service_connect(service_id, INTERFACE_DDF,
|
---|
| 586 | IPC_FLAG_BLOCKING);
|
---|
| 587 |
|
---|
[74017ce] | 588 | rc = chardev_open(sdev->sess, &sdev->chardev);
|
---|
| 589 | if (rc != EOK) {
|
---|
| 590 | async_hangup(sdev->sess);
|
---|
| 591 | sdev->sess = NULL;
|
---|
| 592 | list_remove(&sdev->link);
|
---|
| 593 | goto fail;
|
---|
| 594 | }
|
---|
| 595 |
|
---|
[a79b42a] | 596 | fid_t fid = fibril_create(serial_consumer, sdev);
|
---|
| 597 | fibril_add_ready(fid);
|
---|
| 598 | }
|
---|
[2a72d9f] | 599 |
|
---|
| 600 | *sdevp = sdev;
|
---|
[d5c1051] | 601 | return 0;
|
---|
[2a72d9f] | 602 |
|
---|
| 603 | fail:
|
---|
| 604 | if (sdev->kdev->svc_name != NULL)
|
---|
| 605 | free(sdev->kdev->svc_name);
|
---|
| 606 | free(sdev->kdev);
|
---|
| 607 | free(sdev);
|
---|
| 608 | return -1;
|
---|
| 609 | }
|
---|
| 610 |
|
---|
| 611 |
|
---|
[9be360ee] | 612 | /** Add legacy drivers/devices. */
|
---|
| 613 | static void kbd_add_legacy_devs(void)
|
---|
| 614 | {
|
---|
| 615 | /*
|
---|
| 616 | * Need to add these drivers based on config unless we can probe
|
---|
| 617 | * them automatically.
|
---|
| 618 | */
|
---|
| 619 | #if defined(UARCH_arm32) && defined(MACHINE_gta02)
|
---|
| 620 | kbd_add_dev(&chardev_port, &stty_ctl);
|
---|
| 621 | #endif
|
---|
[6d15572] | 622 | #if defined(UARCH_ia64) && defined(MACHINE_ski)
|
---|
| 623 | kbd_add_dev(&chardev_port, &stty_ctl);
|
---|
[9be360ee] | 624 | #endif
|
---|
| 625 | #if defined(MACHINE_msim)
|
---|
[676e833] | 626 | kbd_add_dev(&chardev_port, &stty_ctl);
|
---|
[9be360ee] | 627 | #endif
|
---|
| 628 | #if defined(UARCH_sparc64) && defined(PROCESSOR_sun4v)
|
---|
[7aa94304] | 629 | kbd_add_dev(&chardev_port, &stty_ctl);
|
---|
[9be360ee] | 630 | #endif
|
---|
[af897ff0] | 631 | /* Silence warning on abs32le about kbd_add_dev() being unused */
|
---|
| 632 | (void) kbd_add_dev;
|
---|
[9be360ee] | 633 | }
|
---|
| 634 |
|
---|
[46577995] | 635 | static errno_t dev_check_new_kbdevs(void)
|
---|
[af897ff0] | 636 | {
|
---|
[12f9f0d0] | 637 | category_id_t keyboard_cat;
|
---|
[cc574511] | 638 | service_id_t *svcs;
|
---|
| 639 | size_t count, i;
|
---|
| 640 | bool already_known;
|
---|
[46577995] | 641 | errno_t rc;
|
---|
[1875a0c] | 642 |
|
---|
[cc574511] | 643 | rc = loc_category_get_id("keyboard", &keyboard_cat, IPC_FLAG_BLOCKING);
|
---|
| 644 | if (rc != EOK) {
|
---|
| 645 | printf("%s: Failed resolving category 'keyboard'.\n", NAME);
|
---|
| 646 | return ENOENT;
|
---|
| 647 | }
|
---|
| 648 |
|
---|
[12f9f0d0] | 649 | /*
|
---|
| 650 | * Check for new keyboard devices
|
---|
| 651 | */
|
---|
| 652 | rc = loc_category_get_svcs(keyboard_cat, &svcs, &count);
|
---|
| 653 | if (rc != EOK) {
|
---|
| 654 | printf("%s: Failed getting list of keyboard devices.\n",
|
---|
| 655 | NAME);
|
---|
| 656 | return EIO;
|
---|
| 657 | }
|
---|
| 658 |
|
---|
| 659 | for (i = 0; i < count; i++) {
|
---|
| 660 | already_known = false;
|
---|
| 661 |
|
---|
| 662 | /* Determine whether we already know this device. */
|
---|
[593e023] | 663 | list_foreach(kbd_devs, link, kbd_dev_t, kdev) {
|
---|
[12f9f0d0] | 664 | if (kdev->svc_id == svcs[i]) {
|
---|
| 665 | already_known = true;
|
---|
| 666 | break;
|
---|
| 667 | }
|
---|
| 668 | }
|
---|
| 669 |
|
---|
| 670 | if (!already_known) {
|
---|
| 671 | kbd_dev_t *kdev;
|
---|
[d5c1051] | 672 | if (kbd_add_kbdev(svcs[i], &kdev) == 0) {
|
---|
[12f9f0d0] | 673 | printf("%s: Connected keyboard device '%s'\n",
|
---|
| 674 | NAME, kdev->svc_name);
|
---|
| 675 | }
|
---|
| 676 | }
|
---|
| 677 | }
|
---|
| 678 |
|
---|
[99ac5cf] | 679 | free(svcs);
|
---|
| 680 |
|
---|
[12f9f0d0] | 681 | /* XXX Handle device removal */
|
---|
| 682 |
|
---|
| 683 | return EOK;
|
---|
| 684 | }
|
---|
| 685 |
|
---|
[46577995] | 686 | static errno_t dev_check_new_mousedevs(void)
|
---|
[12f9f0d0] | 687 | {
|
---|
| 688 | category_id_t mouse_cat;
|
---|
| 689 | service_id_t *svcs;
|
---|
| 690 | size_t count, i;
|
---|
| 691 | bool already_known;
|
---|
[46577995] | 692 | errno_t rc;
|
---|
[12f9f0d0] | 693 |
|
---|
[cc574511] | 694 | rc = loc_category_get_id("mouse", &mouse_cat, IPC_FLAG_BLOCKING);
|
---|
| 695 | if (rc != EOK) {
|
---|
| 696 | printf("%s: Failed resolving category 'mouse'.\n", NAME);
|
---|
| 697 | return ENOENT;
|
---|
| 698 | }
|
---|
| 699 |
|
---|
[12f9f0d0] | 700 | /*
|
---|
| 701 | * Check for new mouse devices
|
---|
| 702 | */
|
---|
| 703 | rc = loc_category_get_svcs(mouse_cat, &svcs, &count);
|
---|
| 704 | if (rc != EOK) {
|
---|
| 705 | printf("%s: Failed getting list of mouse devices.\n",
|
---|
| 706 | NAME);
|
---|
| 707 | return EIO;
|
---|
| 708 | }
|
---|
| 709 |
|
---|
| 710 | for (i = 0; i < count; i++) {
|
---|
| 711 | already_known = false;
|
---|
[1875a0c] | 712 |
|
---|
[12f9f0d0] | 713 | /* Determine whether we already know this device. */
|
---|
[593e023] | 714 | list_foreach(mouse_devs, link, mouse_dev_t, mdev) {
|
---|
[12f9f0d0] | 715 | if (mdev->svc_id == svcs[i]) {
|
---|
| 716 | already_known = true;
|
---|
| 717 | break;
|
---|
[cc574511] | 718 | }
|
---|
[854eddd6] | 719 | }
|
---|
[1875a0c] | 720 |
|
---|
[12f9f0d0] | 721 | if (!already_known) {
|
---|
| 722 | mouse_dev_t *mdev;
|
---|
[d5c1051] | 723 | if (mouse_add_mousedev(svcs[i], &mdev) == 0) {
|
---|
[12f9f0d0] | 724 | printf("%s: Connected mouse device '%s'\n",
|
---|
| 725 | NAME, mdev->svc_name);
|
---|
[cc574511] | 726 | }
|
---|
[af897ff0] | 727 | }
|
---|
| 728 | }
|
---|
[1875a0c] | 729 |
|
---|
[99ac5cf] | 730 | free(svcs);
|
---|
| 731 |
|
---|
[12f9f0d0] | 732 | /* XXX Handle device removal */
|
---|
| 733 |
|
---|
[af897ff0] | 734 | return EOK;
|
---|
| 735 | }
|
---|
| 736 |
|
---|
[46577995] | 737 | static errno_t dev_check_new_serialdevs(void)
|
---|
[2a72d9f] | 738 | {
|
---|
| 739 | category_id_t serial_cat;
|
---|
| 740 | service_id_t *svcs;
|
---|
| 741 | size_t count, i;
|
---|
| 742 | bool already_known;
|
---|
[46577995] | 743 | errno_t rc;
|
---|
[2a72d9f] | 744 |
|
---|
| 745 | rc = loc_category_get_id("serial", &serial_cat, IPC_FLAG_BLOCKING);
|
---|
| 746 | if (rc != EOK) {
|
---|
| 747 | printf("%s: Failed resolving category 'serial'.\n", NAME);
|
---|
| 748 | return ENOENT;
|
---|
| 749 | }
|
---|
| 750 |
|
---|
| 751 | /*
|
---|
| 752 | * Check for new serial devices
|
---|
| 753 | */
|
---|
| 754 | rc = loc_category_get_svcs(serial_cat, &svcs, &count);
|
---|
| 755 | if (rc != EOK) {
|
---|
| 756 | printf("%s: Failed getting list of serial devices.\n",
|
---|
| 757 | NAME);
|
---|
| 758 | return EIO;
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 | for (i = 0; i < count; i++) {
|
---|
| 762 | already_known = false;
|
---|
| 763 |
|
---|
| 764 | /* Determine whether we already know this device. */
|
---|
| 765 | list_foreach(serial_devs, link, serial_dev_t, sdev) {
|
---|
| 766 | if (sdev->kdev->svc_id == svcs[i]) {
|
---|
| 767 | already_known = true;
|
---|
| 768 | break;
|
---|
| 769 | }
|
---|
| 770 | }
|
---|
| 771 |
|
---|
| 772 | if (!already_known) {
|
---|
| 773 | serial_dev_t *sdev;
|
---|
[d5c1051] | 774 | if (serial_add_srldev(svcs[i], &sdev) == 0) {
|
---|
[2a72d9f] | 775 | printf("%s: Connected serial device '%s'\n",
|
---|
| 776 | NAME, sdev->kdev->svc_name);
|
---|
| 777 | }
|
---|
| 778 | }
|
---|
| 779 | }
|
---|
| 780 |
|
---|
| 781 | free(svcs);
|
---|
| 782 |
|
---|
| 783 | /* XXX Handle device removal */
|
---|
| 784 |
|
---|
| 785 | return EOK;
|
---|
| 786 | }
|
---|
| 787 |
|
---|
[46577995] | 788 | static errno_t dev_check_new(void)
|
---|
[af897ff0] | 789 | {
|
---|
[46577995] | 790 | errno_t rc;
|
---|
[1875a0c] | 791 |
|
---|
[10a5479d] | 792 | fibril_mutex_lock(&discovery_lock);
|
---|
| 793 |
|
---|
[73d8600] | 794 | if (!serial_console) {
|
---|
| 795 | rc = dev_check_new_kbdevs();
|
---|
| 796 | if (rc != EOK) {
|
---|
| 797 | fibril_mutex_unlock(&discovery_lock);
|
---|
| 798 | return rc;
|
---|
| 799 | }
|
---|
[12f9f0d0] | 800 |
|
---|
[73d8600] | 801 | rc = dev_check_new_mousedevs();
|
---|
| 802 | if (rc != EOK) {
|
---|
| 803 | fibril_mutex_unlock(&discovery_lock);
|
---|
| 804 | return rc;
|
---|
| 805 | }
|
---|
| 806 | } else {
|
---|
| 807 | rc = dev_check_new_serialdevs();
|
---|
| 808 | if (rc != EOK) {
|
---|
| 809 | fibril_mutex_unlock(&discovery_lock);
|
---|
| 810 | return rc;
|
---|
| 811 | }
|
---|
[2a72d9f] | 812 | }
|
---|
[10a5479d] | 813 |
|
---|
| 814 | fibril_mutex_unlock(&discovery_lock);
|
---|
| 815 |
|
---|
[12f9f0d0] | 816 | return EOK;
|
---|
| 817 | }
|
---|
| 818 |
|
---|
| 819 | static void cat_change_cb(void)
|
---|
| 820 | {
|
---|
| 821 | dev_check_new();
|
---|
| 822 | }
|
---|
| 823 |
|
---|
| 824 | /** Start listening for new devices. */
|
---|
[46577995] | 825 | static errno_t input_start_dev_discovery(void)
|
---|
[12f9f0d0] | 826 | {
|
---|
[46577995] | 827 | errno_t rc = loc_register_cat_change_cb(cat_change_cb);
|
---|
[12f9f0d0] | 828 | if (rc != EOK) {
|
---|
[dd8ab1c] | 829 | printf("%s: Failed registering callback for device discovery: "
|
---|
| 830 | "%s\n", NAME, str_error(rc));
|
---|
[12f9f0d0] | 831 | return rc;
|
---|
| 832 | }
|
---|
[ce3efa0] | 833 |
|
---|
[12f9f0d0] | 834 | return dev_check_new();
|
---|
[af897ff0] | 835 | }
|
---|
| 836 |
|
---|
[b6a088f] | 837 | static void usage(char *name)
|
---|
| 838 | {
|
---|
| 839 | printf("Usage: %s <service_name>\n", name);
|
---|
| 840 | }
|
---|
| 841 |
|
---|
[51d6f80] | 842 | int main(int argc, char **argv)
|
---|
| 843 | {
|
---|
[46577995] | 844 | errno_t rc;
|
---|
[a79b42a] | 845 |
|
---|
[b6a088f] | 846 | if (argc < 2) {
|
---|
| 847 | usage(argv[0]);
|
---|
| 848 | return 1;
|
---|
| 849 | }
|
---|
| 850 |
|
---|
[5f88293] | 851 | printf("%s: HelenOS input service\n", NAME);
|
---|
[e00938c] | 852 |
|
---|
[593e023] | 853 | list_initialize(&clients);
|
---|
[9be360ee] | 854 | list_initialize(&kbd_devs);
|
---|
[854eddd6] | 855 | list_initialize(&mouse_devs);
|
---|
[2a72d9f] | 856 | list_initialize(&serial_devs);
|
---|
[9be360ee] | 857 |
|
---|
[03e0beaf] | 858 | serial_console = config_get_value("console");
|
---|
[3e5a814] | 859 |
|
---|
[854eddd6] | 860 | /* Add legacy keyboard devices. */
|
---|
[9be360ee] | 861 | kbd_add_legacy_devs();
|
---|
[6d605e6] | 862 |
|
---|
[47a350f] | 863 | /* Register driver */
|
---|
[593e023] | 864 | async_set_client_data_constructor(client_data_create);
|
---|
| 865 | async_set_client_data_destructor(client_data_destroy);
|
---|
[b688fd8] | 866 | async_set_fallback_port_handler(client_connection, NULL);
|
---|
[ce3efa0] | 867 |
|
---|
[a79b42a] | 868 | rc = loc_server_register(NAME);
|
---|
[3123d2a] | 869 | if (rc != EOK) {
|
---|
| 870 | printf("%s: Unable to register server\n", NAME);
|
---|
[84a1a54] | 871 | return EXIT_RC(rc);
|
---|
[47a350f] | 872 | }
|
---|
| 873 |
|
---|
[15f3c3f] | 874 | service_id_t service_id;
|
---|
[b6a088f] | 875 | rc = loc_service_register(argv[1], &service_id);
|
---|
[3123d2a] | 876 | if (rc != EOK) {
|
---|
[b6a088f] | 877 | printf("%s: Unable to register service %s\n", NAME, argv[1]);
|
---|
[84a1a54] | 878 | return EXIT_RC(rc);
|
---|
[47a350f] | 879 | }
|
---|
[1875a0c] | 880 |
|
---|
[593e023] | 881 | /* Receive kernel notifications */
|
---|
[8820544] | 882 | rc = async_event_subscribe(EVENT_KCONSOLE, kconsole_event_handler, NULL);
|
---|
[593e023] | 883 | if (rc != EOK)
|
---|
| 884 | printf("%s: Failed to register kconsole notifications (%s)\n",
|
---|
| 885 | NAME, str_error(rc));
|
---|
| 886 |
|
---|
[854eddd6] | 887 | /* Start looking for new input devices */
|
---|
| 888 | input_start_dev_discovery();
|
---|
[1875a0c] | 889 |
|
---|
| 890 | printf("%s: Accepting connections\n", NAME);
|
---|
[b6a088f] | 891 | task_retval(0);
|
---|
[085bd54] | 892 | async_manager();
|
---|
[1875a0c] | 893 |
|
---|
[f89979b] | 894 | /* Not reached. */
|
---|
[153a209] | 895 | return 0;
|
---|
[51d6f80] | 896 | }
|
---|
[ce5bcb4] | 897 |
|
---|
| 898 | /**
|
---|
| 899 | * @}
|
---|
[5f88293] | 900 | */
|
---|