Changeset 91b60499 in mainline for uspace/lib/c
- Timestamp:
- 2017-09-30T06:29:42Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 300f4c4
- Parents:
- d076f16 (diff), 6636fb19 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- uspace/lib/c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
rd076f16 r91b60499 1048 1048 * 1049 1049 * @param inr IRQ number. 1050 * @param devno Device number of the device generating inr.1051 1050 * @param handler Notification handler. 1052 1051 * @param data Notification handler client data. 1053 1052 * @param ucode Top-half pseudocode handler. 1054 1053 * 1055 * @return Zero on success or a negative error code. 1056 * 1057 */ 1058 int async_irq_subscribe(int inr, int devno, 1059 async_notification_handler_t handler, void *data, const irq_code_t *ucode) 1054 * @return IRQ capability handle on success. 1055 * @return Negative error code. 1056 * 1057 */ 1058 int async_irq_subscribe(int inr, async_notification_handler_t handler, 1059 void *data, const irq_code_t *ucode) 1060 1060 { 1061 1061 notification_t *notification = … … 1077 1077 futex_up(&async_futex); 1078 1078 1079 return ipc_irq_subscribe(inr, devno,imethod, ucode);1079 return ipc_irq_subscribe(inr, imethod, ucode); 1080 1080 } 1081 1081 1082 1082 /** Unsubscribe from IRQ notification. 1083 1083 * 1084 * @param inr IRQ number. 1085 * @param devno Device number of the device generating inr. 1084 * @param cap IRQ capability handle. 1086 1085 * 1087 1086 * @return Zero on success or a negative error code. 1088 1087 * 1089 1088 */ 1090 int async_irq_unsubscribe(int inr, int devno)1089 int async_irq_unsubscribe(int cap) 1091 1090 { 1092 1091 // TODO: Remove entry from hash table 1093 1092 // to avoid memory leak 1094 1093 1095 return ipc_irq_unsubscribe( inr, devno);1094 return ipc_irq_unsubscribe(cap); 1096 1095 } 1097 1096 … … 1384 1383 async_new_connection(call->in_task_id, in_phone_hash, callid, 1385 1384 call, handler, data); 1386 return;1387 }1388 1389 /* Cloned connection */1390 if (IPC_GET_IMETHOD(*call) == IPC_M_CLONE_ESTABLISH) {1391 // TODO: Currently ignores ports altogether1392 1393 /* Open new connection with fibril, etc. */1394 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call),1395 callid, call, fallback_port_handler, fallback_port_data);1396 1385 return; 1397 1386 } … … 2111 2100 2112 2101 return EOK; 2113 }2114 2115 /** Wrapper for making IPC_M_CLONE_ESTABLISH calls using the async framework.2116 *2117 * Ask for a cloned connection to some service.2118 *2119 * @param mgmt Exchange management style.2120 * @param exch Exchange for sending the message.2121 *2122 * @return New session on success or NULL on error.2123 *2124 */2125 async_sess_t *async_clone_establish(exch_mgmt_t mgmt, async_exch_t *exch)2126 {2127 if (exch == NULL) {2128 errno = ENOENT;2129 return NULL;2130 }2131 2132 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));2133 if (sess == NULL) {2134 errno = ENOMEM;2135 return NULL;2136 }2137 2138 ipc_call_t result;2139 2140 amsg_t *msg = amsg_create();2141 if (!msg) {2142 free(sess);2143 errno = ENOMEM;2144 return NULL;2145 }2146 2147 msg->dataptr = &result;2148 msg->wdata.active = true;2149 2150 ipc_call_async_0(exch->phone, IPC_M_CLONE_ESTABLISH, msg,2151 reply_received);2152 2153 sysarg_t rc;2154 async_wait_for((aid_t) msg, &rc);2155 2156 if (rc != EOK) {2157 errno = rc;2158 free(sess);2159 return NULL;2160 }2161 2162 int phone = (int) IPC_GET_ARG5(result);2163 2164 if (phone < 0) {2165 errno = phone;2166 free(sess);2167 return NULL;2168 }2169 2170 sess->iface = 0;2171 sess->mgmt = mgmt;2172 sess->phone = phone;2173 sess->arg1 = 0;2174 sess->arg2 = 0;2175 sess->arg3 = 0;2176 2177 fibril_mutex_initialize(&sess->remote_state_mtx);2178 sess->remote_state_data = NULL;2179 2180 list_initialize(&sess->exch_list);2181 fibril_mutex_initialize(&sess->mutex);2182 atomic_set(&sess->refcnt, 0);2183 2184 return sess;2185 2102 } 2186 2103 … … 3153 3070 } 3154 3071 3155 /** Wrapper for sending an exchange over different exchange for cloning3156 *3157 * @param exch Exchange to be used for sending.3158 * @param clone_exch Exchange to be cloned.3159 *3160 */3161 int async_exchange_clone(async_exch_t *exch, async_exch_t *clone_exch)3162 {3163 return async_req_1_0(exch, IPC_M_CONNECTION_CLONE, clone_exch->phone);3164 }3165 3166 /** Wrapper for receiving the IPC_M_CONNECTION_CLONE calls.3167 *3168 * If the current call is IPC_M_CONNECTION_CLONE then a new3169 * async session is created for the accepted phone.3170 *3171 * @param mgmt Exchange management style.3172 *3173 * @return New async session or NULL on failure.3174 *3175 */3176 async_sess_t *async_clone_receive(exch_mgmt_t mgmt)3177 {3178 /* Accept the phone */3179 ipc_call_t call;3180 ipc_callid_t callid = async_get_call(&call);3181 int phone = (int) IPC_GET_ARG1(call);3182 3183 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||3184 (phone < 0)) {3185 async_answer_0(callid, EINVAL);3186 return NULL;3187 }3188 3189 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));3190 if (sess == NULL) {3191 async_answer_0(callid, ENOMEM);3192 return NULL;3193 }3194 3195 sess->iface = 0;3196 sess->mgmt = mgmt;3197 sess->phone = phone;3198 sess->arg1 = 0;3199 sess->arg2 = 0;3200 sess->arg3 = 0;3201 3202 fibril_mutex_initialize(&sess->remote_state_mtx);3203 sess->remote_state_data = NULL;3204 3205 list_initialize(&sess->exch_list);3206 fibril_mutex_initialize(&sess->mutex);3207 atomic_set(&sess->refcnt, 0);3208 3209 /* Acknowledge the cloned phone */3210 async_answer_0(callid, EOK);3211 3212 return sess;3213 }3214 3215 3072 /** Wrapper for receiving the IPC_M_CONNECT_TO_ME calls. 3216 3073 * -
uspace/lib/c/generic/ddi.c
rd076f16 r91b60499 50 50 #include "private/libc.h" 51 51 52 53 /** Return unique device number.54 *55 * @return New unique device number.56 *57 */58 int device_assign_devno(void)59 {60 return __SYSCALL0(SYS_DEVICE_ASSIGN_DEVNO);61 }62 52 63 53 /** Map a piece of physical memory to task. -
uspace/lib/c/generic/irq.c
rd076f16 r91b60499 55 55 * 56 56 * @param inr IRQ number. 57 * @param devno Device number of the device generating inr.58 57 * @param method Use this method for notifying me. 59 58 * @param ucode Top-half pseudocode handler. 59 * 60 * @return IRQ capability handle returned by the kernel. 61 * @return Error code returned by the kernel. 62 * 63 */ 64 int ipc_irq_subscribe(int inr, sysarg_t method, const irq_code_t *ucode) 65 { 66 if (ucode == NULL) 67 ucode = &default_ucode; 68 69 return __SYSCALL3(SYS_IPC_IRQ_SUBSCRIBE, inr, method, (sysarg_t) ucode); 70 } 71 72 /** Unsubscribe from IRQ notification. 73 * 74 * @param cap IRQ capability handle. 60 75 * 61 76 * @return Value returned by the kernel. 62 77 * 63 78 */ 64 int ipc_irq_subscribe(int inr, int devno, sysarg_t method, 65 const irq_code_t *ucode) 79 int ipc_irq_unsubscribe(int cap) 66 80 { 67 if (ucode == NULL) 68 ucode = &default_ucode; 69 70 return __SYSCALL4(SYS_IPC_IRQ_SUBSCRIBE, inr, devno, method, 71 (sysarg_t) ucode); 72 } 73 74 /** Unsubscribe from IRQ notification. 75 * 76 * @param inr IRQ number. 77 * @param devno Device number of the device generating inr. 78 * 79 * @return Value returned by the kernel. 80 * 81 */ 82 int ipc_irq_unsubscribe(int inr, int devno) 83 { 84 return __SYSCALL2(SYS_IPC_IRQ_UNSUBSCRIBE, inr, devno); 81 return __SYSCALL1(SYS_IPC_IRQ_UNSUBSCRIBE, cap); 85 82 } 86 83 -
uspace/lib/c/include/async.h
rd076f16 r91b60499 166 166 sysarg_t, async_port_handler_t, void *, port_id_t *); 167 167 168 extern int async_irq_subscribe(int, int,async_notification_handler_t, void *,168 extern int async_irq_subscribe(int, async_notification_handler_t, void *, 169 169 const irq_code_t *); 170 extern int async_irq_unsubscribe(int , int);170 extern int async_irq_unsubscribe(int); 171 171 172 172 extern int async_event_subscribe(event_type_t, async_notification_handler_t, … … 343 343 sysarg_t *, sysarg_t *); 344 344 345 extern async_sess_t *async_clone_establish(exch_mgmt_t, async_exch_t *);346 345 extern async_sess_t *async_connect_me_to(exch_mgmt_t, async_exch_t *, sysarg_t, 347 346 sysarg_t, sysarg_t); … … 472 471 sysarg_t, sysarg_t, sysarg_t, ipc_call_t *); 473 472 474 extern int async_exchange_clone(async_exch_t *, async_exch_t *);475 extern async_sess_t *async_clone_receive(exch_mgmt_t);476 473 extern async_sess_t *async_callback_receive(exch_mgmt_t); 477 474 extern async_sess_t *async_callback_receive_start(exch_mgmt_t, ipc_call_t *); -
uspace/lib/c/include/ipc/irq.h
rd076f16 r91b60499 39 39 #include <abi/ddi/irq.h> 40 40 41 extern int ipc_irq_subscribe(int, int,sysarg_t, const irq_code_t *);42 extern int ipc_irq_unsubscribe(int , int);41 extern int ipc_irq_subscribe(int, sysarg_t, const irq_code_t *); 42 extern int ipc_irq_unsubscribe(int); 43 43 44 44 #endif
Note:
See TracChangeset
for help on using the changeset viewer.