Changeset 79ae36dd in mainline for uspace/srv/hid/char_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/char_mouse
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/char_mouse/char_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 <char_mouse.h>
    4949#include <mouse_port.h>
    5050#include <mouse_proto.h>
     51
     52// FIXME: remove this header
     53#include <kernel/ipc/ipc_methods.h>
    5154
    5255#define NAME       "mouse"
     
    6568/*      printf("ev_btn: button %d, press %d\n", button, press);*/
    6669        if (client_phone != -1) {
    67                 async_msg_2(client_phone, MEVENT_BUTTON, button, press);
     70                async_obsolete_msg_2(client_phone, MEVENT_BUTTON, button, press);
    6871        }
    6972}
     
    7376/*      printf("ev_move: dx %d, dy %d\n", dx, dy);*/
    7477        if (client_phone != -1)
    75                 async_msg_2(client_phone, MEVENT_MOVE, dx, dy);
     78                async_obsolete_msg_2(client_phone, MEVENT_MOVE, dx, dy);
    7679}
    7780
     
    8689        while (1) {
    8790                callid = async_get_call(&call);
    88                 switch (IPC_GET_IMETHOD(call)) {
    89                 case IPC_M_PHONE_HUNGUP:
     91               
     92                if (!IPC_GET_IMETHOD(call)) {
    9093                        if (client_phone != -1) {
    91                                 async_hangup(client_phone);
     94                                async_obsolete_hangup(client_phone);
    9295                                client_phone = -1;
    9396                        }
     
    9598                        async_answer_0(callid, EOK);
    9699                        return;
     100                }
     101               
     102                switch (IPC_GET_IMETHOD(call)) {
    97103                case IPC_M_CONNECT_TO_ME:
    98104                        if (client_phone != -1) {
  • uspace/srv/hid/char_mouse/chardev.c

    r764d71e r79ae36dd  
    3636#include <ipc/char.h>
    3737#include <async.h>
     38#include <async_obsolete.h>
    3839#include <vfs/vfs.h>
    3940#include <fcntl.h>
    4041#include <errno.h>
    41 
     42#include <devmap.h>
     43#include <devmap_obsolete.h>
    4244#include <char_mouse.h>
    4345#include <mouse_port.h>
     
    5153int mouse_port_init(void)
    5254{
    53         const char *input = "/dev/char/ps2b";
    54         int input_fd;
    55 
    56         printf(NAME ": open %s\n", input);
    57 
    58         input_fd = open(input, O_RDONLY);
    59         if (input_fd < 0) {
    60                 printf(NAME ": Failed opening %s (%d)\n", input, input_fd);
    61                 return false;
     55        devmap_handle_t handle;
     56        int rc = devmap_device_get_handle("char/ps2b", &handle,
     57            IPC_FLAG_BLOCKING);
     58       
     59        if (rc != EOK) {
     60                printf("%s: Failed resolving PS/2\n", NAME);
     61                return rc;
    6262        }
    63 
    64         dev_phone = fd_phone(input_fd);
     63       
     64        dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING);
    6565        if (dev_phone < 0) {
    66                 printf(NAME ": Failed to connect to device\n");
    67                 return false;
     66                printf("%s: Failed connecting to PS/2\n", NAME);
     67                return ENOENT;
    6868        }
    69 
     69       
    7070        /* NB: The callback connection is slotted for removal */
    71         if (async_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) {
     71        if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) {
    7272                printf(NAME ": Failed to create callback from device\n");
    7373                return false;
    7474        }
    75 
     75       
    7676        return 0;
    7777}
     
    8787void mouse_port_write(uint8_t data)
    8888{
    89         async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
     89        async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
    9090}
    9191
     
    9999
    100100                int retval;
     101               
     102                if (!IPC_GET_IMETHOD(call)) {
     103                        /* TODO: Handle hangup */
     104                        return;
     105                }
    101106
    102107                switch (IPC_GET_IMETHOD(call)) {
    103                 case IPC_M_PHONE_HUNGUP:
    104                         /* TODO: Handle hangup */
    105                         return;
    106108                case IPC_FIRST_USER_METHOD:
    107109                        mouse_handle_byte(IPC_GET_ARG1(call));
Note: See TracChangeset for help on using the changeset viewer.