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


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/adb_mouse
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/adb_mouse/adb_dev.c

    r764d71e r79ae36dd  
    3939#include <fcntl.h>
    4040#include <errno.h>
     41#include <devmap.h>
     42#include <devmap_obsolete.h>
     43#include <async.h>
     44#include <async_obsolete.h>
     45#include <kernel/ipc/ipc_methods.h>
    4146
    4247#include "adb_mouse.h"
     
    4550static void adb_dev_events(ipc_callid_t iid, ipc_call_t *icall);
    4651
    47 static int dev_phone;
    48 
    4952int adb_dev_init(void)
    5053{
    51         const char *input = "/dev/adb/mouse";
    52         int input_fd;
    53 
    54         printf(NAME ": open %s\n", input);
    55 
    56         input_fd = open(input, O_RDONLY);
    57         if (input_fd < 0) {
    58                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    59                 return false;
     54        devmap_handle_t handle;
     55        int rc = devmap_device_get_handle("adb/mouse", &handle,
     56            IPC_FLAG_BLOCKING);
     57       
     58        if (rc != EOK) {
     59                printf("%s: Failed resolving ADB\n", NAME);
     60                return rc;
    6061        }
    61 
    62         dev_phone = fd_phone(input_fd);
     62       
     63        int dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING);
    6364        if (dev_phone < 0) {
    64                 printf(NAME ": Failed to connect to device\n");
    65                 return false;
     65                printf("%s: Failed connecting to ADB\n", NAME);
     66                return ENOENT;
    6667        }
    67 
     68       
    6869        /* NB: The callback connection is slotted for removal */
    69         if (async_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) {
     70        if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, adb_dev_events) != 0) {
    7071                printf(NAME ": Failed to create callback from device\n");
    7172                return false;
     
    8485
    8586                int retval;
     87               
     88                if (!IPC_GET_IMETHOD(call)) {
     89                        /* TODO: Handle hangup */
     90                        return;
     91                }
    8692
    8793                switch (IPC_GET_IMETHOD(call)) {
    88                 case IPC_M_PHONE_HUNGUP:
    89                         /* TODO: Handle hangup */
    90                         return;
    9194                case IPC_FIRST_USER_METHOD:
    9295                        mouse_handle_data(IPC_GET_ARG1(call));
  • uspace/srv/hid/adb_mouse/adb_mouse.c

    r764d71e r79ae36dd  
    4343#include <stdlib.h>
    4444#include <async.h>
     45#include <async_obsolete.h>
    4546#include <errno.h>
    4647#include <devmap.h>
    47 
    4848#include "adb_mouse.h"
    4949#include "adb_dev.h"
     50
     51// FIXME: remove this header
     52#include <kernel/ipc/ipc_methods.h>
    5053
    5154static void client_connection(ipc_callid_t iid, ipc_call_t *icall);
     
    101104        while (1) {
    102105                callid = async_get_call(&call);
    103                 switch (IPC_GET_IMETHOD(call)) {
    104                 case IPC_M_PHONE_HUNGUP:
     106               
     107                if (!IPC_GET_IMETHOD(call)) {
    105108                        if (client_phone != -1) {
    106                                 async_hangup(client_phone);
     109                                async_obsolete_hangup(client_phone);
    107110                                client_phone = -1;
    108111                        }
     
    110113                        async_answer_0(callid, EOK);
    111114                        return;
     115                }
     116               
     117                switch (IPC_GET_IMETHOD(call)) {
    112118                case IPC_M_CONNECT_TO_ME:
    113119                        if (client_phone != -1) {
     
    158164{
    159165        if (client_phone != -1) {
    160                 async_msg_2(client_phone, MEVENT_BUTTON, button, press);
     166                async_obsolete_msg_2(client_phone, MEVENT_BUTTON, button, press);
    161167        }
    162168}
     
    165171{
    166172        if (client_phone != -1)
    167                 async_msg_2(client_phone, MEVENT_MOVE, dx, dy);
     173                async_obsolete_msg_2(client_phone, MEVENT_MOVE, dx, dy);
    168174}
    169175
Note: See TracChangeset for help on using the changeset viewer.