Ignore:
File:
1 edited

Legend:

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

    rae6021d r4d6629f  
    10221022 *
    10231023 * @param inr     IRQ number.
    1024  * @param devno   Device number of the device generating inr.
    10251024 * @param handler Notification handler.
    10261025 * @param data    Notification handler client data.
    10271026 * @param ucode   Top-half pseudocode handler.
    10281027 *
    1029  * @return Zero on success or a negative error code.
    1030  *
    1031  */
    1032 int async_irq_subscribe(int inr, int devno,
    1033     async_notification_handler_t handler, void *data, const irq_code_t *ucode)
     1028 * @return IRQ capability handle on success.
     1029 * @return Negative error code.
     1030 *
     1031 */
     1032int async_irq_subscribe(int inr, async_notification_handler_t handler,
     1033    void *data, const irq_code_t *ucode)
    10341034{
    10351035        notification_t *notification =
     
    10511051        futex_up(&async_futex);
    10521052       
    1053         return ipc_irq_subscribe(inr, devno, imethod, ucode);
     1053        return ipc_irq_subscribe(inr, imethod, ucode);
    10541054}
    10551055
    10561056/** Unsubscribe from IRQ notification.
    10571057 *
    1058  * @param inr     IRQ number.
    1059  * @param devno   Device number of the device generating inr.
     1058 * @param cap     IRQ capability handle.
    10601059 *
    10611060 * @return Zero on success or a negative error code.
    10621061 *
    10631062 */
    1064 int async_irq_unsubscribe(int inr, int devno)
     1063int async_irq_unsubscribe(int cap)
    10651064{
    10661065        // TODO: Remove entry from hash table
    10671066        //       to avoid memory leak
    10681067       
    1069         return ipc_irq_unsubscribe(inr, devno);
     1068        return ipc_irq_unsubscribe(cap);
    10701069}
    10711070
     
    13581357                async_new_connection(call->in_task_id, in_phone_hash, callid,
    13591358                    call, handler, data);
    1360                 return;
    1361         }
    1362        
    1363         /* Cloned connection */
    1364         if (IPC_GET_IMETHOD(*call) == IPC_M_CLONE_ESTABLISH) {
    1365                 // TODO: Currently ignores ports altogether
    1366                
    1367                 /* Open new connection with fibril, etc. */
    1368                 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call),
    1369                     callid, call, fallback_port_handler, fallback_port_data);
    13701359                return;
    13711360        }
     
    20852074       
    20862075        return EOK;
    2087 }
    2088 
    2089 /** Wrapper for making IPC_M_CLONE_ESTABLISH calls using the async framework.
    2090  *
    2091  * Ask for a cloned connection to some service.
    2092  *
    2093  * @param mgmt Exchange management style.
    2094  * @param exch Exchange for sending the message.
    2095  *
    2096  * @return New session on success or NULL on error.
    2097  *
    2098  */
    2099 async_sess_t *async_clone_establish(exch_mgmt_t mgmt, async_exch_t *exch)
    2100 {
    2101         if (exch == NULL) {
    2102                 errno = ENOENT;
    2103                 return NULL;
    2104         }
    2105        
    2106         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
    2107         if (sess == NULL) {
    2108                 errno = ENOMEM;
    2109                 return NULL;
    2110         }
    2111        
    2112         ipc_call_t result;
    2113        
    2114         amsg_t *msg = amsg_create();
    2115         if (!msg) {
    2116                 free(sess);
    2117                 errno = ENOMEM;
    2118                 return NULL;
    2119         }
    2120        
    2121         msg->dataptr = &result;
    2122         msg->wdata.active = true;
    2123        
    2124         ipc_call_async_0(exch->phone, IPC_M_CLONE_ESTABLISH, msg,
    2125             reply_received);
    2126        
    2127         sysarg_t rc;
    2128         async_wait_for((aid_t) msg, &rc);
    2129        
    2130         if (rc != EOK) {
    2131                 errno = rc;
    2132                 free(sess);
    2133                 return NULL;
    2134         }
    2135        
    2136         int phone = (int) IPC_GET_ARG5(result);
    2137        
    2138         if (phone < 0) {
    2139                 errno = phone;
    2140                 free(sess);
    2141                 return NULL;
    2142         }
    2143        
    2144         sess->iface = 0;
    2145         sess->mgmt = mgmt;
    2146         sess->phone = phone;
    2147         sess->arg1 = 0;
    2148         sess->arg2 = 0;
    2149         sess->arg3 = 0;
    2150        
    2151         fibril_mutex_initialize(&sess->remote_state_mtx);
    2152         sess->remote_state_data = NULL;
    2153        
    2154         list_initialize(&sess->exch_list);
    2155         fibril_mutex_initialize(&sess->mutex);
    2156         atomic_set(&sess->refcnt, 0);
    2157        
    2158         return sess;
    21592076}
    21602077
     
    31273044}
    31283045
    3129 /** Wrapper for sending an exchange over different exchange for cloning
    3130  *
    3131  * @param exch       Exchange to be used for sending.
    3132  * @param clone_exch Exchange to be cloned.
    3133  *
    3134  */
    3135 int async_exchange_clone(async_exch_t *exch, async_exch_t *clone_exch)
    3136 {
    3137         return async_req_1_0(exch, IPC_M_CONNECTION_CLONE, clone_exch->phone);
    3138 }
    3139 
    3140 /** Wrapper for receiving the IPC_M_CONNECTION_CLONE calls.
    3141  *
    3142  * If the current call is IPC_M_CONNECTION_CLONE then a new
    3143  * async session is created for the accepted phone.
    3144  *
    3145  * @param mgmt Exchange management style.
    3146  *
    3147  * @return New async session or NULL on failure.
    3148  *
    3149  */
    3150 async_sess_t *async_clone_receive(exch_mgmt_t mgmt)
    3151 {
    3152         /* Accept the phone */
    3153         ipc_call_t call;
    3154         ipc_callid_t callid = async_get_call(&call);
    3155         int phone = (int) IPC_GET_ARG1(call);
    3156        
    3157         if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||
    3158             (phone < 0)) {
    3159                 async_answer_0(callid, EINVAL);
    3160                 return NULL;
    3161         }
    3162        
    3163         async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
    3164         if (sess == NULL) {
    3165                 async_answer_0(callid, ENOMEM);
    3166                 return NULL;
    3167         }
    3168        
    3169         sess->iface = 0;
    3170         sess->mgmt = mgmt;
    3171         sess->phone = phone;
    3172         sess->arg1 = 0;
    3173         sess->arg2 = 0;
    3174         sess->arg3 = 0;
    3175        
    3176         fibril_mutex_initialize(&sess->remote_state_mtx);
    3177         sess->remote_state_data = NULL;
    3178        
    3179         list_initialize(&sess->exch_list);
    3180         fibril_mutex_initialize(&sess->mutex);
    3181         atomic_set(&sess->refcnt, 0);
    3182        
    3183         /* Acknowledge the cloned phone */
    3184         async_answer_0(callid, EOK);
    3185        
    3186         return sess;
    3187 }
    3188 
    31893046/** Wrapper for receiving the IPC_M_CONNECT_TO_ME calls.
    31903047 *
Note: See TracChangeset for help on using the changeset viewer.