Changeset 79ae36dd in mainline for uspace/srv/hid/kbd


Ignore:
Timestamp:
2011-06-08T19:01:55Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
Location:
uspace/srv/hid/kbd
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/kbd/ctl/apple.c

    r764d71e r79ae36dd  
    5252void kbd_ctl_parse_scancode(int scancode)
    5353{
    54         console_ev_type_t type;
     54        kbd_event_type_t type;
    5555        unsigned int key;
    5656
  • uspace/srv/hid/kbd/ctl/pc.c

    r764d71e r79ae36dd  
    205205void kbd_ctl_parse_scancode(int scancode)
    206206{
    207         console_ev_type_t type;
     207        kbd_event_type_t type;
    208208        unsigned int key;
    209209        int *map;
  • uspace/srv/hid/kbd/ctl/sun.c

    r764d71e r79ae36dd  
    5353void kbd_ctl_parse_scancode(int scancode)
    5454{
    55         console_ev_type_t type;
     55        kbd_event_type_t type;
    5656        unsigned int key;
    5757
  • uspace/srv/hid/kbd/generic/kbd.c

    r764d71e r79ae36dd  
    4343#include <stdlib.h>
    4444#include <stdio.h>
    45 #include <ipc/ns.h>
     45#include <ns.h>
     46#include <ns_obsolete.h>
    4647#include <async.h>
     48#include <async_obsolete.h>
    4749#include <errno.h>
    4850#include <adt/fifo.h>
     
    5052#include <io/keycode.h>
    5153#include <devmap.h>
    52 
    5354#include <kbd.h>
    5455#include <kbd_port.h>
    5556#include <kbd_ctl.h>
    5657#include <layout.h>
     58
     59// FIXME: remove this header
     60#include <kernel/ipc/ipc_methods.h>
    5761
    5862#define NAME       "kbd"
     
    8892void kbd_push_ev(int type, unsigned int key)
    8993{
    90         console_event_t ev;
     94        kbd_event_t ev;
    9195        unsigned mod_mask;
    9296
     
    163167        ev.c = layout[active_layout]->parse_ev(&ev);
    164168
    165         async_msg_4(client_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c);
     169        async_obsolete_msg_4(client_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c);
    166170}
    167171
     
    174178        async_answer_0(iid, EOK);
    175179
    176         while (1) {
     180        while (true) {
    177181                callid = async_get_call(&call);
    178                 switch (IPC_GET_IMETHOD(call)) {
    179                 case IPC_M_PHONE_HUNGUP:
     182               
     183                if (!IPC_GET_IMETHOD(call)) {
    180184                        if (client_phone != -1) {
    181                                 async_hangup(client_phone);
     185                                async_obsolete_hangup(client_phone);
    182186                                client_phone = -1;
    183187                        }
     
    185189                        async_answer_0(callid, EOK);
    186190                        return;
     191                }
     192               
     193                switch (IPC_GET_IMETHOD(call)) {
    187194                case IPC_M_CONNECT_TO_ME:
    188195                        if (client_phone != -1) {
     
    222229        if (irc_service) {
    223230                while (irc_phone < 0)
    224                         irc_phone = service_connect_blocking(SERVICE_IRC, 0, 0);
     231                        irc_phone = service_obsolete_connect_blocking(SERVICE_IRC, 0, 0);
    225232        }
    226233       
  • uspace/srv/hid/kbd/include/layout.h

    r764d71e r79ae36dd  
    4343typedef struct {
    4444        void (*reset)(void);
    45         wchar_t (*parse_ev)(console_event_t *);
     45        wchar_t (*parse_ev)(kbd_event_t *);
    4646} layout_op_t;
    4747
  • uspace/srv/hid/kbd/layout/cz.c

    r764d71e r79ae36dd  
    3939
    4040static void layout_reset(void);
    41 static wchar_t layout_parse_ev(console_event_t *ev);
     41static wchar_t layout_parse_ev(kbd_event_t *ev);
    4242
    4343enum m_state {
     
    273273}
    274274
    275 static wchar_t parse_ms_hacek(console_event_t *ev)
     275static wchar_t parse_ms_hacek(kbd_event_t *ev)
    276276{
    277277        wchar_t c;
     
    291291}
    292292
    293 static wchar_t parse_ms_carka(console_event_t *ev)
     293static wchar_t parse_ms_carka(kbd_event_t *ev)
    294294{
    295295        wchar_t c;
     
    309309}
    310310
    311 static wchar_t parse_ms_start(console_event_t *ev)
     311static wchar_t parse_ms_start(kbd_event_t *ev)
    312312{
    313313        wchar_t c;
     
    384384}
    385385
    386 static wchar_t layout_parse_ev(console_event_t *ev)
     386static wchar_t layout_parse_ev(kbd_event_t *ev)
    387387{
    388388        if (ev->type != KEY_PRESS)
  • uspace/srv/hid/kbd/layout/us_dvorak.c

    r764d71e r79ae36dd  
    3838
    3939static void layout_reset(void);
    40 static wchar_t layout_parse_ev(console_event_t *ev);
     40static wchar_t layout_parse_ev(kbd_event_t *ev);
    4141
    4242layout_op_t us_dvorak_op = {
     
    210210}
    211211
    212 static wchar_t layout_parse_ev(console_event_t *ev)
     212static wchar_t layout_parse_ev(kbd_event_t *ev)
    213213{
    214214        wchar_t c;
  • uspace/srv/hid/kbd/layout/us_qwerty.c

    r764d71e r79ae36dd  
    3838
    3939static void layout_reset(void);
    40 static wchar_t layout_parse_ev(console_event_t *ev);
     40static wchar_t layout_parse_ev(kbd_event_t *ev);
    4141
    4242layout_op_t us_qwerty_op = {
     
    204204}
    205205
    206 static wchar_t layout_parse_ev(console_event_t *ev)
     206static wchar_t layout_parse_ev(kbd_event_t *ev)
    207207{
    208208        wchar_t c;
  • uspace/srv/hid/kbd/port/adb.c

    r764d71e r79ae36dd  
    3030 * @ingroup kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    3434 * @brief ADB keyboard port driver.
     
    3737#include <ipc/adb.h>
    3838#include <async.h>
     39#include <async_obsolete.h>
    3940#include <kbd_port.h>
    4041#include <kbd.h>
     
    4243#include <fcntl.h>
    4344#include <errno.h>
     45#include <devmap.h>
     46#include <devmap_obsolete.h>
    4447
    4548static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     
    5255int kbd_port_init(void)
    5356{
    54         const char *input = "/dev/adb/kbd";
    55         int input_fd;
    56 
    57         printf(NAME ": open %s\n", input);
    58 
    59         input_fd = open(input, O_RDONLY);
    60         if (input_fd < 0) {
    61                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    62                 return false;
     57        const char *dev = "adb/kbd";
     58        devmap_handle_t handle;
     59       
     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
     68                return rc;
     69       
     70        /* NB: The callback connection is slotted for removal */
     71        rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events);
     72        if (rc != EOK) {
     73                printf(NAME ": Failed to create callback from device\n");
     74                return rc;
    6375        }
    64 
    65         dev_phone = fd_phone(input_fd);
    66         if (dev_phone < 0) {
    67                 printf(NAME ": Failed to connect to device\n");
    68                 return false;
    69         }
    70 
    71         /* NB: The callback connection is slotted for removal */
    72         if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    73                 printf(NAME ": Failed to create callback from device\n");
    74                 return false;
    75         }
    76 
    77         return 0;
     76       
     77        return EOK;
    7878}
    7979
     
    100100
    101101                int retval;
    102 
    103                 switch (IPC_GET_IMETHOD(call)) {
    104                 case IPC_M_PHONE_HUNGUP:
     102               
     103                if (!IPC_GET_IMETHOD(call)) {
    105104                        /* TODO: Handle hangup */
    106105                        return;
     106                }
     107               
     108                switch (IPC_GET_IMETHOD(call)) {
    107109                case ADB_REG_NOTIF:
    108110                        adb_kbd_reg0_data(IPC_GET_ARG1(call));
  • uspace/srv/hid/kbd/port/chardev.c

    r764d71e r79ae36dd  
    3030 * @ingroup kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    3434 * @brief Chardev keyboard port driver.
     
    3737#include <ipc/char.h>
    3838#include <async.h>
     39#include <async_obsolete.h>
    3940#include <kbd_port.h>
    4041#include <kbd.h>
    41 #include <vfs/vfs.h>
    42 #include <sys/stat.h>
    43 #include <fcntl.h>
     42#include <devmap.h>
     43#include <devmap_obsolete.h>
    4444#include <errno.h>
     45#include <stdio.h>
     46
     47#define NAME  "kbd/chardev"
    4548
    4649static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     
    4851static int dev_phone;
    4952
    50 #define NAME "kbd"
    51 
    5253/** List of devices to try connecting to. */
    5354static const char *in_devs[] = {
    54         "/dev/char/ps2a",
    55         "/dev/char/s3c24ser"
     55        "char/ps2a",
     56        "char/s3c24ser"
    5657};
    5758
    58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
     59static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
    5960
    6061int kbd_port_init(void)
    6162{
    62         int input_fd;
    63         int i;
    64 
    65         input_fd = -1;
     63        devmap_handle_t handle;
     64        unsigned int i;
     65        int rc;
     66       
    6667        for (i = 0; i < num_devs; i++) {
    67                 struct stat s;
    68 
    69                 if (stat(in_devs[i], &s) == EOK)
     68                rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     69                if (rc == EOK)
    7070                        break;
    7171        }
    72 
     72       
    7373        if (i >= num_devs) {
    74                 printf(NAME ": Could not find any suitable input device.\n");
     74                printf("%s: Could not find any suitable input device\n", NAME);
    7575                return -1;
    7676        }
    77 
    78         input_fd = open(in_devs[i], O_RDONLY);
    79         if (input_fd < 0) {
    80                 printf(NAME ": failed opening device %s (%d).\n", in_devs[i],
    81                     input_fd);
    82                 return -1;
     77       
     78        dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING);
     79        if (dev_phone < 0) {
     80                printf("%s: Failed connecting to device\n", NAME);
     81                return ENOENT;
    8382        }
    84 
    85         dev_phone = fd_phone(input_fd);
    86         if (dev_phone < 0) {
    87                 printf(NAME ": Failed connecting to device\n");
    88                 return -1;
    89         }
    90 
     83       
    9184        /* NB: The callback connection is slotted for removal */
    92         if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
     85        if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    9386                printf(NAME ": Failed to create callback from device\n");
    9487                return -1;
     
    108101void kbd_port_write(uint8_t data)
    109102{
    110         async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
     103        async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
    111104}
    112105
     
    118111                ipc_call_t call;
    119112                ipc_callid_t callid = async_get_call(&call);
     113               
     114                if (!IPC_GET_IMETHOD(call)) {
     115                        /* TODO: Handle hangup */
     116                        return;
     117                }
    120118
    121119                int retval;
    122120
    123121                switch (IPC_GET_IMETHOD(call)) {
    124                 case IPC_M_PHONE_HUNGUP:
    125                         /* TODO: Handle hangup */
    126                         return;
    127122                case CHAR_NOTIF_BYTE:
    128123                        kbd_push_scancode(IPC_GET_ARG1(call));
  • uspace/srv/hid/kbd/port/ns16550.c

    r764d71e r79ae36dd  
    3737#include <ipc/irc.h>
    3838#include <async.h>
     39#include <async_obsolete.h>
    3940#include <sysinfo.h>
    4041#include <kbd.h>
     
    121122       
    122123        if (irc_service)
    123                 async_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
     124                async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    124125                    IPC_GET_IMETHOD(*call));
    125126}
  • uspace/srv/hid/kbd/port/z8530.c

    r764d71e r79ae36dd  
    3737#include <ipc/irc.h>
    3838#include <async.h>
     39#include <async_obsolete.h>
    3940#include <sysinfo.h>
    4041#include <kbd.h>
     
    109110       
    110111        if (irc_service)
    111                 async_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
     112                async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    112113                    IPC_GET_IMETHOD(*call));
    113114}
Note: See TracChangeset for help on using the changeset viewer.