Changeset 98e15b1 in mainline for uspace/srv/hid/console/console.c


Ignore:
Timestamp:
2011-05-29T21:58:31Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
95067954, d600874
Parents:
6ab7f3e9 (diff), bd7acda (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.
Message:

merge with usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/console.c

    r6ab7f3e9 r98e15b1  
    5757#include <io/style.h>
    5858#include <io/screenbuffer.h>
     59#include <inttypes.h>
    5960
    6061#include "console.h"
     
    6768/** Interval for checking for new keyboard (1/4s). */
    6869#define HOTPLUG_WATCH_INTERVAL (1000 * 250)
     70
     71/* Kernel defines 32 but does not export it. */
     72#define MAX_IPC_OUTGOING_PHONES 128
     73/** To allow proper phone closing. */
     74static ipc_callid_t driver_phones[MAX_IPC_OUTGOING_PHONES] = { 0 };
    6975
    7076/** Phone to the keyboard driver. */
     
    9096                                       contents and related settings. */
    9197} console_t;
     98
     99
    92100
    93101/** Array of data for virtual consoles */
     
    401409}
    402410
     411static void close_driver_phone(ipc_callid_t hash)
     412{
     413        int i;
     414        for (i = 0; i < MAX_IPC_OUTGOING_PHONES; i++) {
     415                if (driver_phones[i] == hash) {
     416                        printf("Device %" PRIxn " gone.\n", hash);
     417                        driver_phones[i] = 0;
     418                        async_hangup(i);
     419                        return;
     420                }
     421        }
     422}
     423
    403424/** Handler for keyboard */
    404425static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
     
    415436                case IPC_M_PHONE_HUNGUP:
    416437                        /* TODO: Handle hangup */
     438                        close_driver_phone(iid);
    417439                        return;
    418440                case KBD_EVENT:
     
    458480                case IPC_M_PHONE_HUNGUP:
    459481                        /* TODO: Handle hangup */
     482                        close_driver_phone(iid);
    460483                        return;
    461484                case MEVENT_BUTTON:
     
    715738}
    716739
     740static int async_connect_to_me_hack(int phone, sysarg_t arg1, sysarg_t arg2,
     741sysarg_t arg3, async_client_conn_t client_receiver, ipc_callid_t *hash)
     742{
     743        sysarg_t task_hash;
     744        sysarg_t phone_hash;
     745        int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
     746            NULL, NULL, NULL, &task_hash, &phone_hash);
     747        if (rc != EOK)
     748                return rc;
     749
     750        if (client_receiver != NULL)
     751                async_new_connection(task_hash, phone_hash, phone_hash, NULL,
     752                    client_receiver);
     753
     754        if (hash != NULL) {
     755                *hash = phone_hash;
     756        }
     757
     758        return EOK;
     759}
     760
    717761static int connect_keyboard_or_mouse(const char *devname,
    718762    async_client_conn_t handler, const char *path)
     
    729773        }
    730774       
    731         int rc = async_connect_to_me(phone, SERVICE_CONSOLE, 0, 0, handler);
     775        ipc_callid_t hash;
     776        int rc = async_connect_to_me_hack(phone, SERVICE_CONSOLE, 0, phone,
     777            handler, &hash);
    732778        if (rc != EOK) {
    733779                printf(NAME ": " \
     
    737783        }
    738784       
    739         printf(NAME ": found %s \"%s\".\n", devname, path);
     785        driver_phones[phone] = hash;
     786
     787        printf(NAME ": found %s \"%s\" (%" PRIxn ").\n", devname, path, hash);
    740788
    741789        return phone;
Note: See TracChangeset for help on using the changeset viewer.