Changes in uspace/lib/c/generic/async.c [4d6629f:ae6021d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r4d6629f rae6021d 1022 1022 * 1023 1023 * @param inr IRQ number. 1024 * @param devno Device number of the device generating inr. 1024 1025 * @param handler Notification handler. 1025 1026 * @param data Notification handler client data. 1026 1027 * @param ucode Top-half pseudocode handler. 1027 1028 * 1028 * @return IRQ capability handle on success. 1029 * @return Negative error code. 1030 * 1031 */ 1032 int async_irq_subscribe(int inr, async_notification_handler_t handler, 1033 void *data, const irq_code_t *ucode) 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) 1034 1034 { 1035 1035 notification_t *notification = … … 1051 1051 futex_up(&async_futex); 1052 1052 1053 return ipc_irq_subscribe(inr, imethod, ucode);1053 return ipc_irq_subscribe(inr, devno, imethod, ucode); 1054 1054 } 1055 1055 1056 1056 /** Unsubscribe from IRQ notification. 1057 1057 * 1058 * @param cap IRQ capability handle. 1058 * @param inr IRQ number. 1059 * @param devno Device number of the device generating inr. 1059 1060 * 1060 1061 * @return Zero on success or a negative error code. 1061 1062 * 1062 1063 */ 1063 int async_irq_unsubscribe(int cap)1064 int async_irq_unsubscribe(int inr, int devno) 1064 1065 { 1065 1066 // TODO: Remove entry from hash table 1066 1067 // to avoid memory leak 1067 1068 1068 return ipc_irq_unsubscribe( cap);1069 return ipc_irq_unsubscribe(inr, devno); 1069 1070 } 1070 1071 … … 1357 1358 async_new_connection(call->in_task_id, in_phone_hash, callid, 1358 1359 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); 1359 1370 return; 1360 1371 } … … 2074 2085 2075 2086 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; 2076 2159 } 2077 2160 … … 3044 3127 } 3045 3128 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 3046 3189 /** Wrapper for receiving the IPC_M_CONNECT_TO_ME calls. 3047 3190 *
Note:
See TracChangeset
for help on using the changeset viewer.