Changeset 5da7199 in mainline


Ignore:
Timestamp:
2011-09-09T17:18:06Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3781092, b7c33b0
Parents:
c69646f8
Message:

remove the obsolete async API

Location:
uspace
Files:
4 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.c

    rc69646f8 r5da7199  
    4343#include <ipc/kbdev.h>
    4444#include <async.h>
    45 #include <async_obsolete.h>
    4645#include <fibril.h>
    4746#include <fibril_synch.h>
     
    7069
    7170#include "../usbhid.h"
    72 
    73 // FIXME: remove this header
    74 #include <abi/ipc/methods.h>
    7571
    7672/*----------------------------------------------------------------------------*/
     
    167163 *
    168164 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
    169  * assumes the caller is the console and thus it stores IPC phone to it for
     165 * assumes the caller is the console and thus it stores IPC session to it for
    170166 * later use by the driver to notify about key events.
    171167 *
     
    178174{
    179175        sysarg_t method = IPC_GET_IMETHOD(*icall);
    180         int callback;
    181        
    182         usb_kbd_t *kbd_dev = (usb_kbd_t *)fun->driver_data;
     176       
     177        usb_kbd_t *kbd_dev = (usb_kbd_t *) fun->driver_data;
    183178        if (kbd_dev == NULL) {
    184179                usb_log_debug("default_connection_handler: "
     
    187182                return;
    188183        }
    189 
    190         switch (method) {
    191         case IPC_M_CONNECT_TO_ME:
    192                 callback = IPC_GET_ARG5(*icall);
    193 
    194                 if (kbd_dev->console_phone != -1) {
     184       
     185        async_sess_t *sess =
     186            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     187        if (sess != NULL) {
     188                if (kbd_dev->console_sess == NULL) {
     189                        kbd_dev->console_sess = sess;
     190                        usb_log_debug("default_connection_handler: OK\n");
     191                        async_answer_0(icallid, EOK);
     192                } else {
    195193                        usb_log_debug("default_connection_handler: "
    196                             "console phone already set\n");
     194                            "console session already set\n");
    197195                        async_answer_0(icallid, ELIMIT);
    198                         return;
    199                 }
    200 
    201                 kbd_dev->console_phone = callback;
    202                
    203                 usb_log_debug("default_connection_handler: OK\n");
    204                 async_answer_0(icallid, EOK);
    205                 break;
    206         case KBDEV_SET_IND:
    207                 kbd_dev->mods = IPC_GET_ARG1(*icall);
    208                 usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev);
    209                 async_answer_0(icallid, EOK);
    210                 break;
    211         default:
    212                 usb_log_debug("default_connection_handler: Wrong function.\n");
    213                 async_answer_0(icallid, EINVAL);
    214                 break;
     196                }
     197        } else {
     198                switch (method) {
     199                case KBDEV_SET_IND:
     200                        kbd_dev->mods = IPC_GET_ARG1(*icall);
     201                        usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev);
     202                        async_answer_0(icallid, EOK);
     203                        break;
     204                default:
     205                        usb_log_debug("default_connection_handler: Wrong function.\n");
     206                        async_answer_0(icallid, EINVAL);
     207                        break;
     208                }
    215209        }
    216210}
     
    301295{
    302296        usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key);
    303         if (kbd_dev->console_phone < 0) {
     297        if (kbd_dev->console_sess == NULL) {
    304298                usb_log_warning(
    305299                    "Connection to console not ready, key discarded.\n");
     
    307301        }
    308302       
    309         async_obsolete_msg_2(kbd_dev->console_phone, KBDEV_EVENT, type, key);
     303        async_exch_t *exch = async_exchange_begin(kbd_dev->console_sess);
     304        async_msg_2(exch, KBDEV_EVENT, type, key);
     305        async_exchange_end(exch);
    310306}
    311307
     
    510506        }
    511507       
    512         kbd_dev->console_phone = -1;
     508        kbd_dev->console_sess = NULL;
    513509        kbd_dev->initialized = USB_KBD_STATUS_UNINITIALIZED;
    514510       
     
    785781        }
    786782       
    787         // hangup phone to the console
    788         async_obsolete_hangup(kbd_dev->console_phone);
     783        // hangup session to the console
     784        async_hangup(kbd_dev->console_sess);
    789785       
    790786        if (kbd_dev->repeat_mtx != NULL) {
  • uspace/drv/bus/usb/usbhid/kbd/kbddev.h

    rc69646f8 r5da7199  
    3838
    3939#include <stdint.h>
    40 
     40#include <async.h>
    4141#include <fibril_synch.h>
    42 
    4342#include <usb/hid/hid.h>
    4443#include <usb/hid/hidparser.h>
     
    5857 * data, such as currently pressed keys, modifiers and lock keys.
    5958 *
    60  * Also holds a IPC phone to the console (since there is now no other way to
     59 * Also holds a IPC session to the console (since there is now no other way to
    6160 * communicate with it).
    6261 *
     
    8382        unsigned lock_keys;
    8483       
    85         /** IPC phone to the console device (for sending key events). */
    86         int console_phone;
     84        /** IPC session to the console device (for sending key events). */
     85        async_sess_t *console_sess;
    8786       
    8887        /** @todo What is this actually? */
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.c

    rc69646f8 r5da7199  
    4242#include <errno.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544#include <str_error.h>
    4645#include <ipc/mouseev.h>
     
    5655#define ARROWS_PER_SINGLE_WHEEL 3
    5756
    58 // FIXME: remove this header
    59 #include <abi/ipc/methods.h>
    60 
    61 #define NAME "mouse"
     57#define NAME  "mouse"
    6258
    6359/*----------------------------------------------------------------------------*/
     
    128124    ipc_callid_t icallid, ipc_call_t *icall)
    129125{
    130         sysarg_t method = IPC_GET_IMETHOD(*icall);
    131        
    132         usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;
     126        usb_mouse_t *mouse_dev = (usb_mouse_t *) fun->driver_data;
    133127       
    134128        if (mouse_dev == NULL) {
     
    141135        usb_log_debug("default_connection_handler: fun->name: %s\n",
    142136                      fun->name);
    143         usb_log_debug("default_connection_handler: mouse_phone: %d, wheel "
    144             "phone: %d\n", mouse_dev->mouse_phone, mouse_dev->wheel_phone);
    145        
    146         int *phone = (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0)
    147                      ? &mouse_dev->mouse_phone : &mouse_dev->wheel_phone;
    148        
    149         if (method == IPC_M_CONNECT_TO_ME) {
    150                 int callback = IPC_GET_ARG5(*icall);
    151 
    152                 if (*phone != -1) {
     137        usb_log_debug("default_connection_handler: mouse_sess: %p, "
     138            "wheel_sess: %p\n", mouse_dev->mouse_sess, mouse_dev->wheel_sess);
     139       
     140        async_sess_t **sess_ptr =
     141            (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) ?
     142            &mouse_dev->mouse_sess : &mouse_dev->wheel_sess;
     143       
     144        async_sess_t *sess =
     145            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     146        if (sess != NULL) {
     147                if (*sess_ptr == NULL) {
     148                        *sess_ptr = sess;
     149                        usb_log_debug("Console session to mouse set ok (%p).\n",
     150                            sess);
     151                        async_answer_0(icallid, EOK);
     152                } else {
    153153                        usb_log_debug("default_connection_handler: Console "
    154                             "phone to mouse already set.\n");
     154                            "session to mouse already set.\n");
    155155                        async_answer_0(icallid, ELIMIT);
    156                         return;
    157156                }
    158 
    159                 *phone = callback;
    160                 usb_log_debug("Console phone to mouse set ok (%d).\n", *phone);
    161                 async_answer_0(icallid, EOK);
    162                 return;
    163         }
    164 
    165         usb_log_debug("default_connection_handler: Invalid function.\n");
    166         async_answer_0(icallid, EINVAL);
     157        } else {
     158                usb_log_debug("default_connection_handler: Invalid function.\n");
     159                async_answer_0(icallid, EINVAL);
     160        }
    167161}
    168162
     
    175169                return NULL;
    176170        }
    177         mouse->mouse_phone = -1;
    178         mouse->wheel_phone = -1;
     171        mouse->mouse_sess = NULL;
     172        mouse->wheel_sess = NULL;
    179173       
    180174        return mouse;
     
    187181        assert(mouse_dev != NULL);
    188182       
    189         // hangup phone to the console
    190         if (mouse_dev->mouse_phone >= 0) {
    191                 async_obsolete_hangup(mouse_dev->mouse_phone);
    192         }
    193        
    194         if (mouse_dev->wheel_phone >= 0) {
    195                 async_obsolete_hangup(mouse_dev->wheel_phone);
    196         }
     183        // hangup session to the console
     184        if (mouse_dev->mouse_sess != NULL)
     185                async_hangup(mouse_dev->mouse_sess);
     186       
     187        if (mouse_dev->wheel_sess != NULL)
     188                async_hangup(mouse_dev->wheel_sess);
    197189}
    198190
     
    203195        unsigned int key = (wheel > 0) ? KC_UP : KC_DOWN;
    204196
    205         if (mouse_dev->wheel_phone < 0) {
     197        if (mouse_dev->wheel_sess == NULL) {
    206198                usb_log_warning(
    207199                    "Connection to console not ready, wheel roll discarded.\n");
     
    215207                /* Send arrow press and release. */
    216208                usb_log_debug2("Sending key %d to the console\n", key);
    217                 async_obsolete_msg_4(mouse_dev->wheel_phone, KBDEV_EVENT,
    218                     KEY_PRESS, key, 0, 0);
    219                 async_obsolete_msg_4(mouse_dev->wheel_phone, KBDEV_EVENT,
    220                     KEY_RELEASE, key, 0, 0);
     209               
     210                async_exch_t *exch = async_exchange_begin(mouse_dev->wheel_sess);
     211               
     212                async_msg_4(exch, KBDEV_EVENT, KEY_PRESS, key, 0, 0);
     213                async_msg_4(exch, KBDEV_EVENT, KEY_RELEASE, key, 0, 0);
     214               
     215                async_exchange_end(exch);
    221216        }
    222217}
     
    253248        assert(mouse_dev != NULL);
    254249       
    255         if (mouse_dev->mouse_phone < 0) {
    256                 usb_log_warning(NAME " No console phone.\n");
     250        if (mouse_dev->mouse_sess == NULL) {
     251                usb_log_warning(NAME " No console session.\n");
    257252                return true;
    258253        }
     
    266261
    267262        if ((shift_x != 0) || (shift_y != 0)) {
    268                 async_obsolete_req_2_0(mouse_dev->mouse_phone,
    269                     MOUSEEV_MOVE_EVENT, shift_x, shift_y);
    270         }
    271 
    272         if (wheel != 0) {
     263                async_exch_t *exch = async_exchange_begin(mouse_dev->mouse_sess);
     264                async_req_2_0(exch, MOUSEEV_MOVE_EVENT, shift_x, shift_y);
     265                async_exchange_end(exch);
     266        }
     267       
     268        if (wheel != 0)
    273269                usb_mouse_send_wheel(mouse_dev, wheel);
    274         }
    275270       
    276271        /*
     
    292287                if (mouse_dev->buttons[field->usage - field->usage_minimum] == 0
    293288                    && field->value != 0) {
    294                         async_obsolete_req_2_0(mouse_dev->mouse_phone,
    295                             MOUSEEV_BUTTON_EVENT, field->usage, 1);
     289                        async_exch_t *exch =
     290                            async_exchange_begin(mouse_dev->mouse_sess);
     291                        async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 1);
     292                        async_exchange_end(exch);
     293                       
    296294                        mouse_dev->buttons[field->usage - field->usage_minimum]
    297295                            = field->value;
    298296                } else if (mouse_dev->buttons[field->usage - field->usage_minimum] != 0
    299297                    && field->value == 0) {
    300                         async_obsolete_req_2_0(mouse_dev->mouse_phone,
    301                            MOUSEEV_BUTTON_EVENT, field->usage, 0);
     298                        async_exch_t *exch =
     299                            async_exchange_begin(mouse_dev->mouse_sess);
     300                        async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, field->usage, 0);
     301                        async_exchange_end(exch);
     302                       
    302303                        mouse_dev->buttons[field->usage - field->usage_minimum] =
    303304                           field->value;
  • uspace/drv/bus/usb/usbhid/mouse/mousedev.h

    rc69646f8 r5da7199  
    3838
    3939#include <usb/dev/driver.h>
     40#include <async.h>
    4041
    4142struct usb_hid_dev;
     
    4546/** Container for USB mouse device. */
    4647typedef struct {
    47         /** IPC phone to console (consumer). */
    48         int mouse_phone;
    49         int wheel_phone;
     48        /** IPC session to console (consumer). */
     49        async_sess_t *mouse_sess;
     50        async_sess_t *wheel_sess;
    5051       
    5152        int32_t *buttons;
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.c

    rc69646f8 r5da7199  
    4747#include <errno.h>
    4848#include <async.h>
    49 #include <async_obsolete.h>
    5049#include <str_error.h>
    5150
     
    5352#include <io/console.h>
    5453
    55 // FIXME: remove this header
    56 #include <abi/ipc/methods.h>
    57 
    58 #define NAME "multimedia-keys"
     54#define NAME  "multimedia-keys"
    5955
    6056/*----------------------------------------------------------------------------*/
     
    6965        /** Count of stored keys (i.e. number of keys in the report). */
    7066        //size_t key_count;     
    71         /** IPC phone to the console device (for sending key events). */
    72         int console_phone;
     67        /** IPC session to the console device (for sending key events). */
     68        async_sess_t *console_sess;
    7369} usb_multimedia_t;
    7470
     
    7975 *
    8076 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
    81  * assumes the caller is the console and thus it stores IPC phone to it for
     77 * assumes the caller is the console and thus it stores IPC session to it for
    8278 * later use by the driver to notify about key events.
    8379 *
     
    9187        usb_log_debug(NAME " default_connection_handler()\n");
    9288       
    93         sysarg_t method = IPC_GET_IMETHOD(*icall);
    94        
    9589        usb_multimedia_t *multim_dev = (usb_multimedia_t *)fun->driver_data;
    9690       
     
    9993                return;
    10094        }
    101 
    102         if (method == IPC_M_CONNECT_TO_ME) {
    103                 int callback = IPC_GET_ARG5(*icall);
    104 
    105                 if (multim_dev->console_phone != -1) {
     95       
     96        async_sess_t *sess =
     97            async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
     98        if (sess != NULL) {
     99                if (multim_dev->console_sess == NULL) {
     100                        multim_dev->console_sess = sess;
     101                        usb_log_debug(NAME " Saved session to console: %p\n",
     102                            sess);
     103                        async_answer_0(icallid, EOK);
     104                } else
    106105                        async_answer_0(icallid, ELIMIT);
    107                         return;
    108                 }
    109 
    110                 multim_dev->console_phone = callback;
    111                 usb_log_debug(NAME " Saved phone to console: %d\n", callback);
    112                 async_answer_0(icallid, EOK);
    113                 return;
    114         }
    115        
    116         async_answer_0(icallid, EINVAL);
     106        } else
     107                async_answer_0(icallid, EINVAL);
    117108}
    118109
     
    155146
    156147        usb_log_debug2(NAME " Sending key %d to the console\n", ev.key);
    157         if (multim_dev->console_phone < 0) {
     148        if (multim_dev->console_sess == NULL) {
    158149                usb_log_warning(
    159150                    "Connection to console not ready, key discarded.\n");
     
    161152        }
    162153       
    163         async_obsolete_msg_4(multim_dev->console_phone, KBDEV_EVENT, ev.type, ev.key,
    164             ev.mods, ev.c);
     154        async_exch_t *exch = async_exchange_begin(multim_dev->console_sess);
     155        async_msg_4(exch, KBDEV_EVENT, ev.type, ev.key, ev.mods, ev.c);
     156        async_exchange_end(exch);
    165157}
    166158
     
    222214        }
    223215       
    224         multim_dev->console_phone = -1;
     216        multim_dev->console_sess = NULL;
    225217       
    226218        /*! @todo Autorepeat */
     
    250242        if (data != NULL) {
    251243                usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;
    252                 // hangup phone to the console
    253                 async_obsolete_hangup(multim_dev->console_phone);
     244                // hangup session to the console
     245                async_hangup(multim_dev->console_sess);
    254246        }
    255247}
  • uspace/lib/c/Makefile

    rc69646f8 r5da7199  
    9797        generic/ipc.c \
    9898        generic/ns.c \
    99         generic/ns_obsolete.c \
    10099        generic/async.c \
    101         generic/async_obsolete.c \
    102100        generic/loader.c \
    103101        generic/getopt.c \
  • uspace/lib/c/generic/async.c

    rc69646f8 r5da7199  
    118118#define CONN_HASH_TABLE_BUCKETS    32
    119119
     120/** Session data */
     121struct async_sess {
     122        /** List of inactive exchanges */
     123        list_t exch_list;
     124       
     125        /** Exchange management style */
     126        exch_mgmt_t mgmt;
     127       
     128        /** Session identification */
     129        int phone;
     130       
     131        /** First clone connection argument */
     132        sysarg_t arg1;
     133       
     134        /** Second clone connection argument */
     135        sysarg_t arg2;
     136       
     137        /** Third clone connection argument */
     138        sysarg_t arg3;
     139       
     140        /** Exchange mutex */
     141        fibril_mutex_t mutex;
     142       
     143        /** Number of opened exchanges */
     144        atomic_t refcnt;
     145       
     146        /** Mutex for stateful connections */
     147        fibril_mutex_t remote_state_mtx;
     148       
     149        /** Data for stateful connections */
     150        void *remote_state_data;
     151};
     152
     153/** Exchange data */
     154struct async_exch {
     155        /** Link into list of inactive exchanges */
     156        link_t sess_link;
     157       
     158        /** Link into global list of inactive exchanges */
     159        link_t global_link;
     160       
     161        /** Session pointer */
     162        async_sess_t *sess;
     163       
     164        /** Exchange identification */
     165        int phone;
     166};
     167
    120168/** Async framework global futex */
    121169atomic_t async_futex = FUTEX_INITIALIZER;
     
    134182        ipc_call_t call;
    135183} msg_t;
     184
     185/** Message data */
     186typedef struct {
     187        awaiter_t wdata;
     188       
     189        /** If reply was received. */
     190        bool done;
     191       
     192        /** Pointer to where the answer data is stored. */
     193        ipc_call_t *dataptr;
     194       
     195        sysarg_t retval;
     196} amsg_t;
    136197
    137198/* Client connection data */
  • uspace/lib/c/generic/private/async.h

    rc69646f8 r5da7199  
    4343#include <bool.h>
    4444
    45 /** Session data */
    46 struct _async_sess {
    47         /** List of inactive exchanges */
    48         list_t exch_list;
    49        
    50         /** Exchange management style */
    51         exch_mgmt_t mgmt;
    52        
    53         /** Session identification */
    54         int phone;
    55        
    56         /** First clone connection argument */
    57         sysarg_t arg1;
    58        
    59         /** Second clone connection argument */
    60         sysarg_t arg2;
    61        
    62         /** Third clone connection argument */
    63         sysarg_t arg3;
    64        
    65         /** Exchange mutex */
    66         fibril_mutex_t mutex;
    67        
    68         /** Number of opened exchanges */
    69         atomic_t refcnt;
    70        
    71         /** Mutex for stateful connections */
    72         fibril_mutex_t remote_state_mtx;
    73        
    74         /** Data for stateful connections */
    75         void *remote_state_data;
    76 };
    77 
    78 /** Exchange data */
    79 struct _async_exch {
    80         /** Link into list of inactive exchanges */
    81         link_t sess_link;
    82        
    83         /** Link into global list of inactive exchanges */
    84         link_t global_link;
    85        
    86         /** Session pointer */
    87         async_sess_t *sess;
    88        
    89         /** Exchange identification */
    90         int phone;
    91 };
    92 
    9345/** Structures of this type are used to track the timeout events. */
    9446typedef struct {
     
    12981} awaiter_t;
    13082
    131 /** Message data */
    132 typedef struct {
    133         awaiter_t wdata;
    134        
    135         /** If reply was received. */
    136         bool done;
    137        
    138         /** Pointer to where the answer data is stored. */
    139         ipc_call_t *dataptr;
    140        
    141         sysarg_t retval;
    142 } amsg_t;
    143 
    14483extern void __async_init(void);
    14584extern void async_insert_timeout(awaiter_t *);
  • uspace/lib/c/include/async.h

    rc69646f8 r5da7199  
    9696
    9797/** Forward declarations */
    98 struct _async_exch;
    99 struct _async_sess;
    100 
    101 typedef struct _async_sess async_sess_t;
    102 typedef struct _async_exch async_exch_t;
     98struct async_exch;
     99struct async_sess;
     100
     101typedef struct async_sess async_sess_t;
     102typedef struct async_exch async_exch_t;
    103103
    104104extern atomic_t threads_in_ipc_wait;
  • uspace/srv/hid/input/generic/input.c

    rc69646f8 r5da7199  
    4747#include <stdio.h>
    4848#include <ns.h>
    49 #include <ns_obsolete.h>
    5049#include <async.h>
    51 #include <async_obsolete.h>
    5250#include <errno.h>
    5351#include <adt/fifo.h>
     
    6361#include <mouse.h>
    6462
    65 // FIXME: remove this header
    66 #include <abi/ipc/methods.h>
    67 
    6863#define NUM_LAYOUTS  3
    6964
     
    7772static void kbd_devs_reclaim(void);
    7873
    79 int client_phone = -1;
     74async_sess_t *client_sess = NULL;
    8075
    8176/** List of keyboard devices */
     
    8681
    8782bool irc_service = false;
    88 int irc_phone = -1;
     83async_sess_t *irc_sess = NULL;
    8984
    9085void kbd_push_data(kbd_dev_t *kdev, sysarg_t data)
     
    170165       
    171166        ev.c = layout_parse_ev(kdev->active_layout, &ev);
    172         async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, ev.type, ev.key,
    173             ev.mods, ev.c);
     167       
     168        async_exch_t *exch = async_exchange_begin(client_sess);
     169        async_msg_4(exch, INPUT_EVENT_KEY, ev.type, ev.key, ev.mods, ev.c);
     170        async_exchange_end(exch);
    174171}
    175172
     
    177174void mouse_push_event_move(mouse_dev_t *mdev, int dx, int dy)
    178175{
    179         async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy);
     176        async_exch_t *exch = async_exchange_begin(client_sess);
     177        async_msg_2(exch, INPUT_EVENT_MOVE, dx, dy);
     178        async_exchange_end(exch);
    180179}
    181180
     
    183182void mouse_push_event_button(mouse_dev_t *mdev, int bnum, int press)
    184183{
    185         async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press);
     184        async_exch_t *exch = async_exchange_begin(client_sess);
     185        async_msg_2(exch, INPUT_EVENT_BUTTON, bnum, press);
     186        async_exchange_end(exch);
    186187}
    187188
    188189static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    189190{
    190         ipc_callid_t callid;
    191         ipc_call_t call;
    192         int retval;
    193        
    194191        async_answer_0(iid, EOK);
    195192       
    196193        while (true) {
    197                 callid = async_get_call(&call);
     194                ipc_call_t call;
     195                ipc_callid_t callid = async_get_call(&call);
    198196               
    199197                if (!IPC_GET_IMETHOD(call)) {
    200                         if (client_phone != -1) {
    201                                 async_obsolete_hangup(client_phone);
    202                                 client_phone = -1;
     198                        if (client_sess != NULL) {
     199                                async_hangup(client_sess);
     200                                client_sess = NULL;
    203201                        }
    204202                       
     
    207205                }
    208206               
    209                 switch (IPC_GET_IMETHOD(call)) {
    210                 case IPC_M_CONNECT_TO_ME:
    211                         if (client_phone != -1) {
    212                                 retval = ELIMIT;
     207                async_sess_t *sess =
     208                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     209                if (sess != NULL) {
     210                        if (client_sess == NULL) {
     211                                client_sess = sess;
     212                                async_answer_0(callid, EOK);
     213                        } else
     214                                async_answer_0(callid, ELIMIT);
     215                } else {
     216                        switch (IPC_GET_IMETHOD(call)) {
     217                        case INPUT_YIELD:
     218                                kbd_devs_yield();
     219                                async_answer_0(callid, EOK);
    213220                                break;
     221                        case INPUT_RECLAIM:
     222                                kbd_devs_reclaim();
     223                                async_answer_0(callid, EOK);
     224                                break;
     225                        default:
     226                                async_answer_0(callid, EINVAL);
    214227                        }
    215                         client_phone = IPC_GET_ARG5(call);
    216                         retval = 0;
    217                         break;
    218                 case INPUT_YIELD:
    219                         kbd_devs_yield();
    220                         retval = 0;
    221                         break;
    222                 case INPUT_RECLAIM:
    223                         kbd_devs_reclaim();
    224                         retval = 0;
    225                         break;
    226                 default:
    227                         retval = EINVAL;
    228228                }
    229                
    230                 async_answer_0(callid, retval);
    231229        }
    232230}
     
    648646       
    649647        if (irc_service) {
    650                 while (irc_phone < 0)
    651                         irc_phone = service_obsolete_connect_blocking(SERVICE_IRC, 0, 0);
     648                while (irc_sess == NULL)
     649                        irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     650                            SERVICE_IRC, 0, 0);
    652651        }
    653652       
  • uspace/srv/hid/input/include/input.h

    rc69646f8 r5da7199  
    4040
    4141#include <bool.h>
     42#include <async.h>
    4243
    4344#define NAME       "input"
     
    4546
    4647extern bool irc_service;
    47 extern int irc_phone;
     48extern async_sess_t *irc_sess;
    4849
    4950#endif
  • uspace/srv/hid/input/port/ns16550.c

    rc69646f8 r5da7199  
    3838#include <ipc/irc.h>
    3939#include <async.h>
    40 #include <async_obsolete.h>
    4140#include <sysinfo.h>
    4241#include <input.h>
     
    158157        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    159158       
    160         if (irc_service)
    161                 async_obsolete_msg_1(irc_phone, IRC_CLEAR_INTERRUPT,
    162                     IPC_GET_IMETHOD(*call));
     159        if (irc_service) {
     160                async_exch_t *exch = async_exchange_begin(irc_sess);
     161                async_msg_1(exch, IRC_CLEAR_INTERRUPT, IPC_GET_IMETHOD(*call));
     162                async_exchange_end(exch);
     163        }
    163164}
    164165
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    rc69646f8 r5da7199  
    4444#include <ipc/mouseev.h>
    4545#include <async.h>
    46 #include <async_obsolete.h>
    4746#include <unistd.h>
    4847#include <stdio.h>
     
    5352#include "s3c24xx_ts.h"
    5453
    55 // FIXME: remove this header
    56 #include <abi/ipc/methods.h>
    57 
    58 #define NAME "s3c24ser"
    59 #define NAMESPACE "hid"
     54#define NAME       "s3c24ser"
     55#define NAMESPACE  "hid"
    6056
    6157static irq_cmd_t ts_irq_cmds[] = {
     
    134130
    135131        ts->io = vaddr;
    136         ts->client_phone = -1;
     132        ts->client_sess = NULL;
    137133        ts->state = ts_wait_pendown;
    138134        ts->last_x = 0;
     
    284280        button = 1;
    285281        press = 0;
    286         async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press);
     282       
     283        async_exch_t *exch = async_exchange_begin(ts->client_sess);
     284        async_msg_2(exch, MOUSEEV_BUTTON_EVENT, button, press);
     285        async_exchange_end(exch);
    287286
    288287        s3c24xx_ts_wait_for_int_mode(ts, updn_down);
     
    325324
    326325        /* Send notifications to client. */
    327         async_obsolete_msg_2(ts->client_phone, MOUSEEV_MOVE_EVENT, dx, dy);
    328         async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press);
     326        async_exch_t *exch = async_exchange_begin(ts->client_sess);
     327        async_msg_2(exch, MOUSEEV_MOVE_EVENT, dx, dy);
     328        async_msg_2(exch, MOUSEEV_BUTTON_EVENT, button, press);
     329        async_exchange_end(exch);
    329330
    330331        ts->last_x = x_pos;
     
    377378    void *arg)
    378379{
    379         ipc_callid_t callid;
    380         ipc_call_t call;
    381         int retval;
    382 
    383380        async_answer_0(iid, EOK);
    384 
    385         while (1) {
    386                 callid = async_get_call(&call);
     381       
     382        while (true) {
     383                ipc_call_t call;
     384                ipc_callid_t callid = async_get_call(&call);
    387385               
    388386                if (!IPC_GET_IMETHOD(call)) {
    389                         if (ts->client_phone != -1) {
    390                                 async_obsolete_hangup(ts->client_phone);
    391                                 ts->client_phone = -1;
     387                        if (ts->client_sess != NULL) {
     388                                async_hangup(ts->client_sess);
     389                                ts->client_sess = NULL;
    392390                        }
    393 
     391                       
    394392                        async_answer_0(callid, EOK);
    395393                        return;
    396394                }
    397395               
    398                 switch (IPC_GET_IMETHOD(call)) {
    399                 case IPC_M_CONNECT_TO_ME:
    400                         if (ts->client_phone != -1) {
    401                                 retval = ELIMIT;
    402                                 break;
    403                         }
    404                         ts->client_phone = IPC_GET_ARG5(call);
    405                         retval = 0;
    406                         break;
    407                 default:
    408                         retval = EINVAL;
    409                 }
    410                 async_answer_0(callid, retval);
     396                async_sess_t *sess =
     397                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     398                if (sess != NULL) {
     399                        if (ts->client_sess == NULL) {
     400                                ts->client_sess = sess;
     401                                async_answer_0(callid, EOK);
     402                        } else
     403                                async_answer_0(callid, ELIMIT);
     404                } else
     405                        async_answer_0(callid, EINVAL);
    411406        }
    412407}
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h

    rc69646f8 r5da7199  
    3939
    4040#include <sys/types.h>
     41#include <async.h>
    4142
    4243/** S3C24xx ADC and touch-screen I/O */
     
    121122        s3c24xx_adc_io_t *io;
    122123
    123         /** Callback phone to the client */
    124         int client_phone;
     124        /** Callback session to the client */
     125        async_sess_t *client_sess;
    125126
    126127        /** Service ID */
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.c

    rc69646f8 r5da7199  
    4848#include <ipc/adb.h>
    4949#include <async.h>
    50 #include <async_obsolete.h>
    5150#include <assert.h>
    5251#include "cuda_adb.h"
    5352
    54 // FIXME: remove this header
    55 #include <abi/ipc/methods.h>
    56 
    57 #define NAME "cuda_adb"
     53#define NAME  "cuda_adb"
    5854
    5955static void cuda_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    154150
    155151        for (i = 0; i < ADB_MAX_ADDR; ++i) {
    156                 adb_dev[i].client_phone = -1;
     152                adb_dev[i].client_sess = NULL;
    157153                adb_dev[i].service_id = 0;
    158154        }
     
    199195        sysarg_t method;
    200196        service_id_t dsid;
    201         int retval;
    202197        int dev_addr, i;
    203198
     
    220215        async_answer_0(iid, EOK);
    221216
    222         while (1) {
     217        while (true) {
    223218                callid = async_get_call(&call);
    224219                method = IPC_GET_IMETHOD(call);
     
    230225                }
    231226               
    232                 switch (method) {
    233                 case IPC_M_CONNECT_TO_ME:
    234                         if (adb_dev[dev_addr].client_phone != -1) {
    235                                 retval = ELIMIT;
    236                                 break;
    237                         }
    238                         adb_dev[dev_addr].client_phone = IPC_GET_ARG5(call);
    239                         /*
    240                          * A hack so that we send the data to the phone
    241                          * regardless of which address the device is on.
    242                          */
    243                         for (i = 0; i < ADB_MAX_ADDR; ++i) {
    244                                 if (adb_dev[i].service_id == dsid) {
    245                                         adb_dev[i].client_phone = IPC_GET_ARG5(call);
     227                async_sess_t *sess =
     228                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     229                if (sess != NULL) {
     230                        if (adb_dev[dev_addr].client_sess == NULL) {
     231                                adb_dev[dev_addr].client_sess = sess;
     232                               
     233                                /*
     234                                 * A hack so that we send the data to the session
     235                                 * regardless of which address the device is on.
     236                                 */
     237                                for (i = 0; i < ADB_MAX_ADDR; ++i) {
     238                                        if (adb_dev[i].service_id == dsid)
     239                                                adb_dev[i].client_sess = sess;
    246240                                }
    247                         }
    248                         retval = 0;
    249                         break;
    250                 default:
    251                         retval = EINVAL;
    252                         break;
    253                 }
    254                 async_answer_0(callid, retval);
     241                               
     242                                async_answer_0(callid, EOK);
     243                        } else
     244                                async_answer_0(callid, ELIMIT);
     245                } else
     246                        async_answer_0(callid, EINVAL);
    255247        }
    256248}
     
    483475        reg_val = ((uint16_t) data[1] << 8) | (uint16_t) data[2];
    484476
    485         if (adb_dev[dev_addr].client_phone == -1)
    486                 return;
    487 
    488         async_obsolete_msg_1(adb_dev[dev_addr].client_phone, ADB_REG_NOTIF, reg_val);
     477        if (adb_dev[dev_addr].client_sess == NULL)
     478                return;
     479
     480        async_exch_t *exch =
     481            async_exchange_begin(adb_dev[dev_addr].client_sess);
     482        async_msg_1(exch, ADB_REG_NOTIF, reg_val);
     483        async_exchange_end(exch);
    489484}
    490485
  • uspace/srv/hw/bus/cuda_adb/cuda_adb.h

    rc69646f8 r5da7199  
    3838
    3939#include <sys/types.h>
    40 #include <ipc/loc.h>
     40#include <async.h>
    4141#include <fibril_synch.h>
    4242
     
    105105typedef struct {
    106106        service_id_t service_id;
    107         int client_phone;
     107        async_sess_t *client_sess;
    108108} adb_dev_t;
    109109
  • uspace/srv/hw/char/i8042/i8042.c

    rc69646f8 r5da7199  
    3232 * @ingroup kbd
    3333 * @{
    34  */ 
     34 */
    3535/** @file
    3636 * @brief i8042 PS/2 port driver.
     
    4141#include <loc.h>
    4242#include <async.h>
    43 #include <async_obsolete.h>
    4443#include <unistd.h>
    4544#include <sysinfo.h>
     
    4948#include "i8042.h"
    5049
    51 // FIXME: remove this header
    52 #include <abi/ipc/methods.h>
    53 
    54 #define NAME "i8042"
    55 #define NAMESPACE "char"
     50#define NAME       "i8042"
     51#define NAMESPACE  "char"
    5652
    5753/* Interesting bits for status register */
     
    145141
    146142        for (i = 0; i < MAX_DEVS; i++) {
    147                 i8042_port[i].client_phone = -1;
     143                i8042_port[i].client_sess = NULL;
    148144
    149145                snprintf(name, 16, "%s/ps2%c", NAMESPACE, dchar[i]);
     
    257253                }
    258254               
    259                 switch (method) {
    260                 case IPC_M_CONNECT_TO_ME:
    261                         printf(NAME ": creating callback connection\n");
    262                         if (i8042_port[dev_id].client_phone != -1) {
     255                async_sess_t *sess =
     256                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     257                if (sess != NULL) {
     258                        if (i8042_port[dev_id].client_sess == NULL) {
     259                                i8042_port[dev_id].client_sess = sess;
     260                                retval = EOK;
     261                        } else
    263262                                retval = ELIMIT;
     263                } else {
     264                        switch (method) {
     265                        case IPC_FIRST_USER_METHOD:
     266                                printf(NAME ": write %" PRIun " to devid %d\n",
     267                                    IPC_GET_ARG1(call), dev_id);
     268                                i8042_port_write(dev_id, IPC_GET_ARG1(call));
     269                                retval = 0;
     270                                break;
     271                        default:
     272                                retval = EINVAL;
    264273                                break;
    265274                        }
    266                         i8042_port[dev_id].client_phone = IPC_GET_ARG5(call);
    267                         retval = 0;
    268                         break;
    269                 case IPC_FIRST_USER_METHOD:
    270                         printf(NAME ": write %" PRIun " to devid %d\n",
    271                             IPC_GET_ARG1(call), dev_id);
    272                         i8042_port_write(dev_id, IPC_GET_ARG1(call));
    273                         retval = 0;
    274                         break;
    275                 default:
    276                         retval = EINVAL;
    277                         break;
    278275                }
     276               
    279277                async_answer_0(callid, retval);
    280278        }
     
    305303        }
    306304
    307         if (i8042_port[devid].client_phone != -1) {
    308                 async_obsolete_msg_1(i8042_port[devid].client_phone,
    309                     IPC_FIRST_USER_METHOD, data);
     305        if (i8042_port[devid].client_sess != NULL) {
     306                async_exch_t *exch =
     307                    async_exchange_begin(i8042_port[devid].client_sess);
     308                async_msg_1(exch, IPC_FIRST_USER_METHOD, data);
     309                async_exchange_end(exch);
    310310        }
    311311}
  • uspace/srv/hw/char/i8042/i8042.h

    rc69646f8 r5da7199  
    3939#define i8042_H_
    4040
     41#include <sys/types.h>
    4142#include <libarch/ddi.h>
    42 #include <libarch/types.h>
     43#include <async.h>
    4344
    4445/** i8042 HW I/O interface */
     
    5354typedef struct {
    5455        service_id_t service_id;
    55         int client_phone;
     56        async_sess_t *client_sess;
    5657} i8042_port_t;
    5758
     
    6061/**
    6162 * @}
    62  */ 
     63 */
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c

    rc69646f8 r5da7199  
    4242#include <ipc/char.h>
    4343#include <async.h>
    44 #include <async_obsolete.h>
    4544#include <unistd.h>
    4645#include <stdio.h>
     
    5150#include "s3c24xx_uart.h"
    5251
    53 // FIXME: remove this header
    54 #include <abi/ipc/methods.h>
    55 
    56 #define NAME "s3c24ser"
    57 #define NAMESPACE "char"
     52#define NAME       "s3c24ser"
     53#define NAMESPACE  "char"
    5854
    5955static irq_cmd_t uart_irq_cmds[] = {
     
    117113    void *arg)
    118114{
    119         ipc_callid_t callid;
    120         ipc_call_t call;
    121         sysarg_t method;
    122         int retval;
    123 
    124115        /* Answer the IPC_M_CONNECT_ME_TO call. */
    125116        async_answer_0(iid, EOK);
    126 
    127         while (1) {
    128                 callid = async_get_call(&call);
    129                 method = IPC_GET_IMETHOD(call);
     117       
     118        while (true) {
     119                ipc_call_t call;
     120                ipc_callid_t callid = async_get_call(&call);
     121                sysarg_t method = IPC_GET_IMETHOD(call);
    130122               
    131123                if (!method) {
     
    135127                }
    136128               
    137                 switch (method) {
    138                 case IPC_M_CONNECT_TO_ME:
    139                         printf(NAME ": creating callback connection\n");
    140                         uart->client_phone = IPC_GET_ARG5(call);
    141                         retval = 0;
    142                         break;
    143                 case CHAR_WRITE_BYTE:
    144                         printf(NAME ": write %" PRIun " to device\n",
    145                             IPC_GET_ARG1(call));
    146                         s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call));
    147                         retval = 0;
    148                         break;
    149                 default:
    150                         retval = EINVAL;
    151                         break;
     129                async_sess_t *sess =
     130                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     131                if (sess != NULL) {
     132                        if (uart->client_sess == NULL) {
     133                                uart->client_sess = sess;
     134                                async_answer_0(callid, EOK);
     135                        } else
     136                                async_answer_0(callid, ELIMIT);
     137                } else {
     138                        switch (method) {
     139                        case CHAR_WRITE_BYTE:
     140                                printf(NAME ": write %" PRIun " to device\n",
     141                                    IPC_GET_ARG1(call));
     142                                s3c24xx_uart_sendb(uart, (uint8_t) IPC_GET_ARG1(call));
     143                                async_answer_0(callid, EOK);
     144                                break;
     145                        default:
     146                                async_answer_0(callid, EINVAL);
     147                        }
    152148                }
    153                 async_answer_0(callid, retval);
    154149        }
    155150}
     
    163158                uint32_t status = pio_read_32(&uart->io->uerstat);
    164159
    165                 if (uart->client_phone != -1) {
    166                         async_obsolete_msg_1(uart->client_phone, CHAR_NOTIF_BYTE,
    167                             data);
     160                if (uart->client_sess != NULL) {
     161                        async_exch_t *exch = async_exchange_begin(uart->client_sess);
     162                        async_msg_1(exch, CHAR_NOTIF_BYTE, data);
     163                        async_exchange_end(exch);
    168164                }
    169165
     
    191187
    192188        uart->io = vaddr;
    193         uart->client_phone = -1;
     189        uart->client_sess = NULL;
    194190
    195191        printf(NAME ": device at physical address %p, inr %" PRIun ".\n",
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.h

    rc69646f8 r5da7199  
    3939
    4040#include <sys/types.h>
     41#include <async.h>
    4142
    4243/** S3C24xx UART I/O */
     
    8485        s3c24xx_uart_io_t *io;
    8586
    86         /** Callback phone to the client */
    87         int client_phone;
     87        /** Callback session to the client */
     88        async_sess_t *client_sess;
    8889
    8990        /** Service ID */
Note: See TracChangeset for help on using the changeset viewer.