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