Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    ra35b458 readaeae8  
    133133
    134134        /** Session identification */
    135         int phone;
     135        cap_phone_handle_t phone;
    136136
    137137        /** First clone connection argument */
     
    169169
    170170        /** Exchange identification */
    171         int phone;
     171        cap_phone_handle_t phone;
    172172};
    173173
     
    185185        link_t link;
    186186
    187         cap_handle_t chandle;
     187        cap_call_handle_t chandle;
    188188        ipc_call_t call;
    189189} msg_t;
     
    237237
    238238        /** Identification of the opening call. */
    239         cap_handle_t chandle;
     239        cap_call_handle_t chandle;
    240240
    241241        /** Call data of the opening call. */
     
    243243
    244244        /** Identification of the closing call. */
    245         cap_handle_t close_chandle;
     245        cap_call_handle_t close_chandle;
    246246
    247247        /** Fibril function that will be used to handle the connection. */
     
    382382 *
    383383 */
    384 static void default_fallback_port_handler(cap_handle_t chandle,
     384static void default_fallback_port_handler(cap_call_handle_t chandle,
    385385    ipc_call_t *call, void *arg)
    386386{
     
    786786 */
    787787static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
    788     cap_handle_t chandle, ipc_call_t *call, async_port_handler_t handler,
     788    cap_call_handle_t chandle, ipc_call_t *call, async_port_handler_t handler,
    789789    void *data)
    790790{
     
    968968 *
    969969 */
    970 static bool route_call(cap_handle_t chandle, ipc_call_t *call)
     970static bool route_call(cap_call_handle_t chandle, ipc_call_t *call)
    971971{
    972972        assert(call);
     
    10571057 */
    10581058errno_t async_irq_subscribe(int inr, async_notification_handler_t handler,
    1059     void *data, const irq_code_t *ucode, cap_handle_t *handle)
     1059    void *data, const irq_code_t *ucode, cap_irq_handle_t *handle)
    10601060{
    10611061        notification_t *notification =
     
    10771077        futex_up(&async_futex);
    10781078
    1079         cap_handle_t cap;
    1080         errno_t rc = ipc_irq_subscribe(inr, imethod, ucode, &cap);
     1079        cap_irq_handle_t ihandle;
     1080        errno_t rc = ipc_irq_subscribe(inr, imethod, ucode, &ihandle);
    10811081        if (rc == EOK && handle != NULL) {
    1082                 *handle = cap;
     1082                *handle = ihandle;
    10831083        }
    10841084        return rc;
     
    10871087/** Unsubscribe from IRQ notification.
    10881088 *
    1089  * @param cap     IRQ capability handle.
     1089 * @param handle  IRQ capability handle.
    10901090 *
    10911091 * @return Zero on success or an error code.
    10921092 *
    10931093 */
    1094 errno_t async_irq_unsubscribe(int cap)
     1094errno_t async_irq_unsubscribe(cap_irq_handle_t ihandle)
    10951095{
    10961096        // TODO: Remove entry from hash table
    10971097        //       to avoid memory leak
    10981098
    1099         return ipc_irq_unsubscribe(cap);
     1099        return ipc_irq_unsubscribe(ihandle);
    11001100}
    11011101
     
    12001200 *          message. In that case zero CAP_NIL is returned.
    12011201 */
    1202 cap_handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
     1202cap_call_handle_t async_get_call_timeout(ipc_call_t *call, suseconds_t usecs)
    12031203{
    12041204        assert(call);
     
    12671267        list_remove(&msg->link);
    12681268
    1269         cap_handle_t chandle = msg->chandle;
     1269        cap_call_handle_t chandle = msg->chandle;
    12701270        *call = msg->call;
    12711271        free(msg);
     
    13391339 *
    13401340 */
    1341 static void handle_call(cap_handle_t chandle, ipc_call_t *call)
     1341static void handle_call(cap_call_handle_t chandle, ipc_call_t *call)
    13421342{
    13431343        assert(call);
     
    20422042}
    20432043
    2044 errno_t async_answer_0(cap_handle_t chandle, errno_t retval)
     2044errno_t async_answer_0(cap_call_handle_t chandle, errno_t retval)
    20452045{
    20462046        return ipc_answer_0(chandle, retval);
    20472047}
    20482048
    2049 errno_t async_answer_1(cap_handle_t chandle, errno_t retval, sysarg_t arg1)
     2049errno_t async_answer_1(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1)
    20502050{
    20512051        return ipc_answer_1(chandle, retval, arg1);
    20522052}
    20532053
    2054 errno_t async_answer_2(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
     2054errno_t async_answer_2(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1,
    20552055    sysarg_t arg2)
    20562056{
     
    20582058}
    20592059
    2060 errno_t async_answer_3(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
     2060errno_t async_answer_3(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1,
    20612061    sysarg_t arg2, sysarg_t arg3)
    20622062{
     
    20642064}
    20652065
    2066 errno_t async_answer_4(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
     2066errno_t async_answer_4(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1,
    20672067    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
    20682068{
     
    20702070}
    20712071
    2072 errno_t async_answer_5(cap_handle_t chandle, errno_t retval, sysarg_t arg1,
     2072errno_t async_answer_5(cap_call_handle_t chandle, errno_t retval, sysarg_t arg1,
    20732073    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
    20742074{
     
    20762076}
    20772077
    2078 errno_t async_forward_fast(cap_handle_t chandle, async_exch_t *exch,
     2078errno_t async_forward_fast(cap_call_handle_t chandle, async_exch_t *exch,
    20792079    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, unsigned int mode)
    20802080{
     
    20852085}
    20862086
    2087 errno_t async_forward_slow(cap_handle_t chandle, async_exch_t *exch,
     2087errno_t async_forward_slow(cap_call_handle_t chandle, async_exch_t *exch,
    20882088    sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3,
    20892089    sysarg_t arg4, sysarg_t arg5, unsigned int mode)
     
    21262126}
    21272127
    2128 static errno_t async_connect_me_to_internal(int phone, sysarg_t arg1, sysarg_t arg2,
    2129     sysarg_t arg3, sysarg_t arg4, int *out_phone)
     2128static errno_t async_connect_me_to_internal(cap_phone_handle_t phone,
     2129    sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4,
     2130    cap_phone_handle_t *out_phone)
    21302131{
    21312132        ipc_call_t result;
     
    21332134        // XXX: Workaround for GCC's inability to infer association between
    21342135        // rc == EOK and *out_phone being assigned.
    2135         *out_phone = -1;
     2136        *out_phone = CAP_NIL;
    21362137
    21372138        amsg_t *msg = amsg_create();
     
    21512152                return rc;
    21522153
    2153         *out_phone = (int) IPC_GET_ARG5(result);
     2154        *out_phone = (cap_phone_handle_t) IPC_GET_ARG5(result);
    21542155        return EOK;
    21552156}
     
    21822183        }
    21832184
    2184         int phone;
     2185        cap_phone_handle_t phone;
    21852186        errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
    21862187            0, &phone);
     
    22352236        }
    22362237
    2237         int phone;
     2238        cap_phone_handle_t phone;
    22382239        errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2,
    22392240            arg3, 0, &phone);
     
    23062307        }
    23072308
    2308         int phone;
     2309        cap_phone_handle_t phone;
    23092310        errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
    23102311            IPC_FLAG_BLOCKING, &phone);
     
    23602361        }
    23612362
    2362         int phone;
     2363        cap_phone_handle_t phone;
    23632364        errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2,
    23642365            arg3, IPC_FLAG_BLOCKING, &phone);
     
    23962397        }
    23972398
    2398         cap_handle_t phone;
     2399        cap_phone_handle_t phone;
    23992400        errno_t rc = ipc_connect_kbox(id, &phone);
    24002401        if (rc != EOK) {
     
    24212422}
    24222423
    2423 static errno_t async_hangup_internal(int phone)
     2424static errno_t async_hangup_internal(cap_phone_handle_t phone)
    24242425{
    24252426        return ipc_hangup(phone);
     
    25152516                        }
    25162517                } else if (mgmt == EXCHANGE_PARALLEL) {
    2517                         int phone;
     2518                        cap_phone_handle_t phone;
    25182519                        errno_t rc;
    25192520
     
    26452646 *
    26462647 */
    2647 bool async_share_in_receive(cap_handle_t *chandle, size_t *size)
     2648bool async_share_in_receive(cap_call_handle_t *chandle, size_t *size)
    26482649{
    26492650        assert(chandle);
     
    26732674 *
    26742675 */
    2675 errno_t async_share_in_finalize(cap_handle_t chandle, void *src, unsigned int flags)
     2676errno_t async_share_in_finalize(cap_call_handle_t chandle, void *src,
     2677    unsigned int flags)
    26762678{
    26772679        return ipc_answer_3(chandle, EOK, (sysarg_t) src, (sysarg_t) flags,
     
    27122714 *
    27132715 */
    2714 bool async_share_out_receive(cap_handle_t *chandle, size_t *size,
     2716bool async_share_out_receive(cap_call_handle_t *chandle, size_t *size,
    27152717    unsigned int *flags)
    27162718{
     
    27432745 *
    27442746 */
    2745 errno_t async_share_out_finalize(cap_handle_t chandle, void **dst)
     2747errno_t async_share_out_finalize(cap_call_handle_t chandle, void **dst)
    27462748{
    27472749        return ipc_answer_2(chandle, EOK, (sysarg_t) __entry, (sysarg_t) dst);
     
    27972799 *
    27982800 */
    2799 bool async_data_read_receive(cap_handle_t *chandle, size_t *size)
     2801bool async_data_read_receive(cap_call_handle_t *chandle, size_t *size)
    28002802{
    28012803        ipc_call_t data;
     
    28172819 *
    28182820 */
    2819 bool async_data_read_receive_call(cap_handle_t *chandle, ipc_call_t *data,
     2821bool async_data_read_receive_call(cap_call_handle_t *chandle, ipc_call_t *data,
    28202822    size_t *size)
    28212823{
     
    28482850 *
    28492851 */
    2850 errno_t async_data_read_finalize(cap_handle_t chandle, const void *src, size_t size)
     2852errno_t async_data_read_finalize(cap_call_handle_t chandle, const void *src,
     2853    size_t size)
    28512854{
    28522855        return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size);
     
    28632866                return ENOENT;
    28642867
    2865         cap_handle_t chandle;
     2868        cap_call_handle_t chandle;
    28662869        if (!async_data_read_receive(&chandle, NULL)) {
    28672870                ipc_answer_0(chandle, EINVAL);
     
    29222925 *
    29232926 */
    2924 bool async_data_write_receive(cap_handle_t *chandle, size_t *size)
     2927bool async_data_write_receive(cap_call_handle_t *chandle, size_t *size)
    29252928{
    29262929        ipc_call_t data;
     
    29432946 *
    29442947 */
    2945 bool async_data_write_receive_call(cap_handle_t *chandle, ipc_call_t *data,
     2948bool async_data_write_receive_call(cap_call_handle_t *chandle, ipc_call_t *data,
    29462949    size_t *size)
    29472950{
     
    29732976 *
    29742977 */
    2975 errno_t async_data_write_finalize(cap_handle_t chandle, void *dst, size_t size)
     2978errno_t async_data_write_finalize(cap_call_handle_t chandle, void *dst,
     2979    size_t size)
    29762980{
    29772981        return ipc_answer_2(chandle, EOK, (sysarg_t) dst, (sysarg_t) size);
     
    30053009        assert(data);
    30063010
    3007         cap_handle_t chandle;
     3011        cap_call_handle_t chandle;
    30083012        size_t size;
    30093013        if (!async_data_write_receive(&chandle, &size)) {
     
    30643068void async_data_write_void(errno_t retval)
    30653069{
    3066         cap_handle_t chandle;
     3070        cap_call_handle_t chandle;
    30673071        async_data_write_receive(&chandle, NULL);
    30683072        ipc_answer_0(chandle, retval);
     
    30793083                return ENOENT;
    30803084
    3081         cap_handle_t chandle;
     3085        cap_call_handle_t chandle;
    30823086        if (!async_data_write_receive(&chandle, NULL)) {
    30833087                ipc_answer_0(chandle, EINVAL);
     
    31213125        /* Accept the phone */
    31223126        ipc_call_t call;
    3123         cap_handle_t chandle = async_get_call(&call);
    3124         cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call);
    3125 
    3126         if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) {
     3127        cap_call_handle_t chandle = async_get_call(&call);
     3128        cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call);
     3129
     3130        if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) ||
     3131            !CAP_HANDLE_VALID((phandle))) {
    31273132                async_answer_0(chandle, EINVAL);
    31283133                return NULL;
     
    31713176async_sess_t *async_callback_receive_start(exch_mgmt_t mgmt, ipc_call_t *call)
    31723177{
    3173         cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call);
    3174 
    3175         if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || (phandle < 0))
     3178        cap_phone_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call);
     3179
     3180        if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) ||
     3181            !CAP_HANDLE_VALID((phandle)))
    31763182                return NULL;
    31773183
     
    32013207{
    32023208        return async_req_5_0(exch, IPC_M_STATE_CHANGE_AUTHORIZE,
    3203             arg1, arg2, arg3, 0, other_exch->phone);
    3204 }
    3205 
    3206 bool async_state_change_receive(cap_handle_t *chandle, sysarg_t *arg1,
     3209            arg1, arg2, arg3, 0, CAP_HANDLE_RAW(other_exch->phone));
     3210}
     3211
     3212bool async_state_change_receive(cap_call_handle_t *chandle, sysarg_t *arg1,
    32073213    sysarg_t *arg2, sysarg_t *arg3)
    32083214{
     
    32253231}
    32263232
    3227 errno_t async_state_change_finalize(cap_handle_t chandle, async_exch_t *other_exch)
    3228 {
    3229         return ipc_answer_1(chandle, EOK, other_exch->phone);
     3233errno_t async_state_change_finalize(cap_call_handle_t chandle,
     3234    async_exch_t *other_exch)
     3235{
     3236        return ipc_answer_1(chandle, EOK, CAP_HANDLE_RAW(other_exch->phone));
    32303237}
    32313238
Note: See TracChangeset for help on using the changeset viewer.