Changeset 79ae36dd in mainline for uspace/srv/hid/kbd/port/adb.c


Ignore:
Timestamp:
2011-06-08T19:01:55Z (13 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.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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));
Note: See TracChangeset for help on using the changeset viewer.