Changeset 984a9ba in mainline for uspace/drv/hid


Ignore:
Timestamp:
2018-07-05T09:34:09Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63d46341
Parents:
76f566d
Message:

do not expose the call capability handler from the async framework

Keep the call capability handler encapsulated within the async framework
and do not expose it explicitly via its API. Use the pointer to
ipc_call_t as the sole object identifying an IPC call in the code that
uses the async framework.

This plugs a major leak in the abstraction and also simplifies both the
async framework (slightly) and all IPC servers.

Location:
uspace/drv/hid
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/hid/adb-kbd/adb-kbd.c

    r76f566d r984a9ba  
    4343#include "ctl.h"
    4444
    45 static void adb_kbd_events(cap_call_handle_t, ipc_call_t *, void *);
     45static void adb_kbd_events(ipc_call_t *, void *);
    4646static void adb_kbd_reg0_data(adb_kbd_t *, uint16_t);
    47 static void adb_kbd_conn(cap_call_handle_t, ipc_call_t *, void *);
     47static void adb_kbd_conn(ipc_call_t *, void *);
    4848
    4949/** Add ADB keyboard device */
     
    130130}
    131131
    132 static void adb_kbd_events(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
     132static void adb_kbd_events(ipc_call_t *icall, void *arg)
    133133{
    134134        adb_kbd_t *kbd = (adb_kbd_t *) arg;
     
    136136        /* Ignore parameters, the connection is already opened */
    137137        while (true) {
    138 
    139138                ipc_call_t call;
    140                 cap_call_handle_t chandle = async_get_call(&call);
     139                async_get_call(&call);
    141140
    142141                errno_t retval = EOK;
     
    154153                        retval = ENOENT;
    155154                }
    156                 async_answer_0(chandle, retval);
     155                async_answer_0(&call, retval);
    157156        }
    158157}
     
    191190
    192191/** Handle client connection */
    193 static void adb_kbd_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    194 {
    195         cap_call_handle_t chandle;
     192static void adb_kbd_conn(ipc_call_t *icall, void *arg)
     193{
    196194        ipc_call_t call;
    197195        sysarg_t method;
     
    201199         * Answer the first IPC_M_CONNECT_ME_TO call.
    202200         */
    203         async_answer_0(icall_handle, EOK);
     201        async_answer_0(icall, EOK);
    204202
    205203        kbd = (adb_kbd_t *)ddf_dev_data_get(ddf_fun_get_dev((ddf_fun_t *)arg));
    206204
    207205        while (true) {
    208                 chandle = async_get_call(&call);
     206                async_get_call(&call);
    209207                method = IPC_GET_IMETHOD(call);
    210208
    211209                if (!method) {
    212210                        /* The other side has hung up. */
    213                         async_answer_0(chandle, EOK);
     211                        async_answer_0(&call, EOK);
    214212                        return;
    215213                }
     
    219217                if (sess != NULL) {
    220218                        kbd->client_sess = sess;
    221                         async_answer_0(chandle, EOK);
     219                        async_answer_0(&call, EOK);
    222220                } else {
    223                         async_answer_0(chandle, EINVAL);
     221                        async_answer_0(&call, EINVAL);
    224222                }
    225223        }
  • uspace/drv/hid/adb-mouse/adb-mouse.c

    r76f566d r984a9ba  
    4141#include "adb-mouse.h"
    4242
    43 static void adb_mouse_conn(cap_call_handle_t, ipc_call_t *, void *);
     43static void adb_mouse_conn(ipc_call_t *, void *);
    4444
    4545static void adb_mouse_event_button(adb_mouse_t *mouse, int bnum, int bpress)
     
    8888}
    8989
    90 static void adb_mouse_events(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
     90static void adb_mouse_events(ipc_call_t *icall, void *arg)
    9191{
    9292        adb_mouse_t *mouse = (adb_mouse_t *) arg;
     
    9595        while (true) {
    9696                ipc_call_t call;
    97                 cap_call_handle_t chandle = async_get_call(&call);
     97                async_get_call(&call);
    9898
    9999                errno_t retval = EOK;
     
    112112                }
    113113
    114                 async_answer_0(chandle, retval);
     114                async_answer_0(&call, retval);
    115115        }
    116116}
     
    200200
    201201/** Handle client connection */
    202 static void adb_mouse_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    203 {
    204         cap_call_handle_t chandle;
     202static void adb_mouse_conn(ipc_call_t *icall, void *arg)
     203{
    205204        ipc_call_t call;
    206205        sysarg_t method;
     
    210209         * Answer the first IPC_M_CONNECT_ME_TO call.
    211210         */
    212         async_answer_0(icall_handle, EOK);
     211        async_answer_0(icall, EOK);
    213212
    214213        mouse = (adb_mouse_t *)ddf_dev_data_get(ddf_fun_get_dev((ddf_fun_t *)arg));
    215214
    216215        while (true) {
    217                 chandle = async_get_call(&call);
     216                async_get_call(&call);
    218217                method = IPC_GET_IMETHOD(call);
    219218
    220219                if (!method) {
    221220                        /* The other side has hung up. */
    222                         async_answer_0(chandle, EOK);
     221                        async_answer_0(&call, EOK);
    223222                        return;
    224223                }
     
    228227                if (sess != NULL) {
    229228                        mouse->client_sess = sess;
    230                         async_answer_0(chandle, EOK);
     229                        async_answer_0(&call, EOK);
    231230                } else {
    232                         async_answer_0(chandle, EINVAL);
    233                 }
    234         }
    235 }
    236 
     231                        async_answer_0(&call, EINVAL);
     232                }
     233        }
     234}
    237235
    238236/**
  • uspace/drv/hid/atkbd/atkbd.c

    r76f566d r984a9ba  
    292292/** Default handler for IPC methods not handled by DDF.
    293293 *
    294  * @param fun           Device function handling the call.
    295  * @param icall_handle  Call handle.
    296  * @param icall         Call data.
    297  *
    298  */
    299 static void
    300 default_connection_handler(ddf_fun_t *fun, cap_call_handle_t icall_handle,
    301     ipc_call_t *icall)
     294 * @param fun   Device function handling the call.
     295 * @param icall Call data.
     296 *
     297 */
     298static void default_connection_handler(ddf_fun_t *fun, ipc_call_t *icall)
    302299{
    303300        const sysarg_t method = IPC_GET_IMETHOD(*icall);
     
    307304        switch (method) {
    308305        case KBDEV_SET_IND:
    309                 async_answer_0(icall_handle, ENOTSUP);
     306                async_answer_0(icall, ENOTSUP);
    310307                break;
    311308        case IPC_M_CONNECT_TO_ME:
     
    320317                        ddf_msg(LVL_WARN,
    321318                            "Failed creating callback session");
    322                         async_answer_0(icall_handle, EAGAIN);
     319                        async_answer_0(icall, EAGAIN);
    323320                        break;
    324321                }
     
    327324                        kbd->client_sess = sess;
    328325                        ddf_msg(LVL_DEBUG, "Set client session");
    329                         async_answer_0(icall_handle, EOK);
     326                        async_answer_0(icall, EOK);
    330327                } else {
    331328                        ddf_msg(LVL_ERROR, "Client session already set");
    332                         async_answer_0(icall_handle, ELIMIT);
     329                        async_answer_0(icall, ELIMIT);
    333330                }
    334331
     
    336333        default:
    337334                ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
    338                 async_answer_0(icall_handle, EINVAL);
     335                async_answer_0(icall, EINVAL);
    339336                break;
    340337        }
  • uspace/drv/hid/ps2mouse/ps2mouse.c

    r76f566d r984a9ba  
    104104static errno_t polling_intellimouse(void *);
    105105static errno_t probe_intellimouse(ps2_mouse_t *, bool);
    106 static void default_connection_handler(ddf_fun_t *, cap_call_handle_t, ipc_call_t *);
     106static void default_connection_handler(ddf_fun_t *, ipc_call_t *);
    107107
    108108/** ps/2 mouse driver ops. */
     
    401401/** Default handler for IPC methods not handled by DDF.
    402402 *
    403  * @param fun           Device function handling the call.
    404  * @param icall_handle  Call handle.
    405  * @param icall         Call data.
    406  */
    407 void default_connection_handler(ddf_fun_t *fun, cap_call_handle_t icall_handle,
    408     ipc_call_t *icall)
     403 * @param fun   Device function handling the call.
     404 * @param icall Call data.
     405 *
     406 */
     407void default_connection_handler(ddf_fun_t *fun, ipc_call_t *icall)
    409408{
    410409        const sysarg_t method = IPC_GET_IMETHOD(*icall);
     
    423422                        ddf_msg(LVL_WARN,
    424423                            "Failed creating client callback session");
    425                         async_answer_0(icall_handle, EAGAIN);
     424                        async_answer_0(icall, EAGAIN);
    426425                        break;
    427426                }
     
    429428                        mouse->client_sess = sess;
    430429                        ddf_msg(LVL_DEBUG, "Set client session");
    431                         async_answer_0(icall_handle, EOK);
     430                        async_answer_0(icall, EOK);
    432431                } else {
    433432                        ddf_msg(LVL_ERROR, "Client session already set");
    434                         async_answer_0(icall_handle, ELIMIT);
     433                        async_answer_0(icall, ELIMIT);
    435434                }
    436435                break;
    437436        default:
    438437                ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
    439                 async_answer_0(icall_handle, EINVAL);
     438                async_answer_0(icall, EINVAL);
    440439                break;
    441440        }
  • uspace/drv/hid/usbhid/kbd/kbddev.c

    r76f566d r984a9ba  
    7272#include "../usbhid.h"
    7373
    74 static void default_connection_handler(ddf_fun_t *, cap_call_handle_t, ipc_call_t *);
     74static void default_connection_handler(ddf_fun_t *, ipc_call_t *);
    7575static ddf_dev_ops_t kbdops = { .default_handler = default_connection_handler };
    7676
     
    148148/* IPC method handler                                                         */
    149149
    150 /**
    151  * Default handler for IPC methods not handled by DDF.
     150/** Default handler for IPC methods not handled by DDF.
    152151 *
    153152 * Currently recognizes only two methods (IPC_M_CONNECT_TO_ME and KBDEV_SET_IND)
     
    156155 * KBDEV_SET_IND sets LED keyboard indicators.
    157156 *
    158  * @param fun           Device function handling the call.
    159  * @param icall_handle  Call handle.
    160  * @param icall         Call data.
    161  */
    162 static void
    163 default_connection_handler(ddf_fun_t *fun, cap_call_handle_t icall_handle,
    164     ipc_call_t *icall)
     157 * @param fun   Device function handling the call.
     158 * @param icall Call data.
     159 *
     160 */
     161static void default_connection_handler(ddf_fun_t *fun, ipc_call_t *icall)
    165162{
    166163        const sysarg_t method = IPC_GET_IMETHOD(*icall);
     
    172169                kbd_dev->mods = IPC_GET_ARG1(*icall);
    173170                usb_kbd_set_led(kbd_dev->hid_dev, kbd_dev);
    174                 async_answer_0(icall_handle, EOK);
     171                async_answer_0(icall, EOK);
    175172                break;
    176173                /*
     
    184181                        usb_log_warning(
    185182                            "Failed to create start console session.\n");
    186                         async_answer_0(icall_handle, EAGAIN);
     183                        async_answer_0(icall, EAGAIN);
    187184                        break;
    188185                }
     
    190187                        kbd_dev->client_sess = sess;
    191188                        usb_log_debug("%s: OK", __FUNCTION__);
    192                         async_answer_0(icall_handle, EOK);
     189                        async_answer_0(icall, EOK);
    193190                } else {
    194191                        usb_log_error("%s: console session already set",
    195192                            __FUNCTION__);
    196                         async_answer_0(icall_handle, ELIMIT);
     193                        async_answer_0(icall, ELIMIT);
    197194                }
    198195                break;
     
    200197                usb_log_error("%s: Unknown method: %d.",
    201198                    __FUNCTION__, (int) method);
    202                 async_answer_0(icall_handle, EINVAL);
     199                async_answer_0(icall, EINVAL);
    203200                break;
    204201        }
  • uspace/drv/hid/usbhid/mouse/mousedev.c

    r76f566d r984a9ba  
    5656#define NAME "mouse"
    5757
    58 static void default_connection_handler(ddf_fun_t *, cap_call_handle_t, ipc_call_t *);
     58static void default_connection_handler(ddf_fun_t *, ipc_call_t *);
    5959
    6060static ddf_dev_ops_t ops = { .default_handler = default_connection_handler };
     
    110110/** Default handler for IPC methods not handled by DDF.
    111111 *
    112  * @param fun           Device function handling the call.
    113  * @param icall_handle  Call handle.
    114  * @param icall         Call data.
    115  */
    116 static void
    117 default_connection_handler(ddf_fun_t *fun, cap_call_handle_t icall_handle,
    118     ipc_call_t *icall)
     112 * @param fun   Device function handling the call.
     113 * @param icall Call data.
     114 *
     115 */
     116static void default_connection_handler(ddf_fun_t *fun, ipc_call_t *icall)
    119117{
    120118        usb_mouse_t *mouse_dev = ddf_fun_data_get(fun);
     
    122120        if (mouse_dev == NULL) {
    123121                usb_log_debug("%s: Missing parameters.", __FUNCTION__);
    124                 async_answer_0(icall_handle, EINVAL);
     122                async_answer_0(icall, EINVAL);
    125123                return;
    126124        }
     
    137135                        usb_log_debug("Console session to %s set ok (%p).",
    138136                            ddf_fun_get_name(fun), sess);
    139                         async_answer_0(icall_handle, EOK);
     137                        async_answer_0(icall, EOK);
    140138                } else {
    141139                        usb_log_error("Console session to %s already set.",
    142140                            ddf_fun_get_name(fun));
    143                         async_answer_0(icall_handle, ELIMIT);
     141                        async_answer_0(icall, ELIMIT);
    144142                        async_hangup(sess);
    145143                }
    146144        } else {
    147145                usb_log_debug("%s: Invalid function.", __FUNCTION__);
    148                 async_answer_0(icall_handle, EINVAL);
     146                async_answer_0(icall, EINVAL);
    149147        }
    150148}
  • uspace/drv/hid/usbhid/multimedia/multimedia.c

    r76f566d r984a9ba  
    7373
    7474
    75 /**
    76  * Default handler for IPC methods not handled by DDF.
     75/** Default handler for IPC methods not handled by DDF.
    7776 *
    7877 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
     
    8079 * later use by the driver to notify about key events.
    8180 *
    82  * @param fun           Device function handling the call.
    83  * @param icall_handle  Call handle.
    84  * @param icall         Call data.
    85  */
    86 static void
    87 default_connection_handler(ddf_fun_t *fun, cap_call_handle_t icall_handle,
    88     ipc_call_t *icall)
     81 * @param fun   Device function handling the call.
     82 * @param icall Call data.
     83 *
     84 */
     85static void default_connection_handler(ddf_fun_t *fun, ipc_call_t *icall)
    8986{
    9087        usb_log_debug(NAME " default_connection_handler()");
     
    9996                        usb_log_debug(NAME " Saved session to console: %p",
    10097                            sess);
    101                         async_answer_0(icall_handle, EOK);
     98                        async_answer_0(icall, EOK);
    10299                } else
    103                         async_answer_0(icall_handle, ELIMIT);
     100                        async_answer_0(icall, ELIMIT);
    104101        } else
    105                 async_answer_0(icall_handle, EINVAL);
     102                async_answer_0(icall, EINVAL);
    106103}
    107104
  • uspace/drv/hid/xtkbd/xtkbd.c

    r76f566d r984a9ba  
    328328/** Default handler for IPC methods not handled by DDF.
    329329 *
    330  * @param fun           Device function handling the call.
    331  * @param icall_handle  Call handle.
    332  * @param icall         Call data.
    333  *
    334  */
    335 static void default_connection_handler(ddf_fun_t *fun,
    336     cap_call_handle_t icall_handle, ipc_call_t *icall)
     330 * @param fun   Device function handling the call.
     331 * @param icall Call data.
     332 *
     333 */
     334static void default_connection_handler(ddf_fun_t *fun, ipc_call_t *icall)
    337335{
    338336        const sysarg_t method = IPC_GET_IMETHOD(*icall);
     
    357355                errno_t rc = chardev_write(kbd->chardev, &cmds[0], 1, &nwr);
    358356                if (rc != EOK) {
    359                         async_answer_0(icall_handle, rc);
     357                        async_answer_0(icall, rc);
    360358                        break;
    361359                }
    362360
    363361                rc = chardev_write(kbd->chardev, &cmds[1], 1, &nwr);
    364                 async_answer_0(icall_handle, rc);
     362                async_answer_0(icall, rc);
    365363                break;
    366364        case IPC_M_CONNECT_TO_ME:
     
    375373                        ddf_msg(LVL_WARN,
    376374                            "Failed creating callback session");
    377                         async_answer_0(icall_handle, EAGAIN);
     375                        async_answer_0(icall, EAGAIN);
    378376                        break;
    379377                }
     
    382380                        kbd->client_sess = sess;
    383381                        ddf_msg(LVL_DEBUG, "Set client session");
    384                         async_answer_0(icall_handle, EOK);
     382                        async_answer_0(icall, EOK);
    385383                } else {
    386384                        ddf_msg(LVL_ERROR, "Client session already set");
    387                         async_answer_0(icall_handle, ELIMIT);
     385                        async_answer_0(icall, ELIMIT);
    388386                }
    389387
     
    391389        default:
    392390                ddf_msg(LVL_ERROR, "Unknown method: %d.", (int)method);
    393                 async_answer_0(icall_handle, EINVAL);
     391                async_answer_0(icall, EINVAL);
    394392                break;
    395393        }
Note: See TracChangeset for help on using the changeset viewer.