Changeset 4d6629f in mainline
- Timestamp:
- 2017-09-03T14:15:32Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9306cd7
- Parents:
- 8a45bf09
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/ipc/methods.h
r8a45bf09 r4d6629f 58 58 */ 59 59 IPC_M_PHONE_HUNGUP = 0, 60 61 /** Clone connection.62 *63 * The calling task clones one of its phones for the callee.64 *65 * - ARG1 - The caller sets ARG1 to the phone of the cloned connection.66 * - The callee gets the new phone from ARG1.67 *68 * - on answer, the callee acknowledges the new connection by sending EOK back69 * or the kernel closes it70 */71 IPC_M_CONNECTION_CLONE,72 73 /** Protocol for establishing a cloned connection.74 *75 * Through this call, the recipient learns about the new cloned connection.76 *77 * - ARG5 - the kernel sets ARG5 to contain the hash of the used phone78 * - on answer, the callee acknowledges the new connection by sending EOK back79 * or the kernel closes it80 */81 IPC_M_CLONE_ESTABLISH,82 60 83 61 /** Protocol for initializing callback connections. -
kernel/Makefile
r8a45bf09 r4d6629f 271 271 generic/src/ipc/sysipc.c \ 272 272 generic/src/ipc/sysipc_ops.c \ 273 generic/src/ipc/ops/clnestab.c \274 273 generic/src/ipc/ops/conctmeto.c \ 275 274 generic/src/ipc/ops/concttome.c \ 276 generic/src/ipc/ops/connclone.c \277 275 generic/src/ipc/ops/dataread.c \ 278 276 generic/src/ipc/ops/datawrite.c \ -
kernel/generic/src/ipc/sysipc.c
r8a45bf09 r4d6629f 85 85 { 86 86 switch (imethod) { 87 case IPC_M_CONNECTION_CLONE:88 case IPC_M_CLONE_ESTABLISH:89 87 case IPC_M_PHONE_HUNGUP: 90 88 /* This message is meant only for the original recipient. */ … … 135 133 { 136 134 switch (IPC_GET_IMETHOD(call->data)) { 137 case IPC_M_CONNECTION_CLONE:138 case IPC_M_CLONE_ESTABLISH:139 135 case IPC_M_CONNECT_TO_ME: 140 136 case IPC_M_CONNECT_ME_TO: -
kernel/generic/src/ipc/sysipc_ops.c
r8a45bf09 r4d6629f 38 38 39 39 /* Forward declarations. */ 40 sysipc_ops_t ipc_m_connection_clone_ops;41 sysipc_ops_t ipc_m_clone_establish_ops;42 40 sysipc_ops_t ipc_m_connect_to_me_ops; 43 41 sysipc_ops_t ipc_m_connect_me_to_ops; … … 51 49 52 50 static sysipc_ops_t *sysipc_ops[] = { 53 [IPC_M_CONNECTION_CLONE] = &ipc_m_connection_clone_ops,54 [IPC_M_CLONE_ESTABLISH] = &ipc_m_clone_establish_ops,55 51 [IPC_M_CONNECT_TO_ME] = &ipc_m_connect_to_me_ops, 56 52 [IPC_M_CONNECT_ME_TO] = &ipc_m_connect_me_to_ops, -
uspace/app/trace/ipc_desc.c
r8a45bf09 r4d6629f 40 40 /* System methods */ 41 41 { IPC_M_PHONE_HUNGUP, "PHONE_HUNGUP" }, 42 { IPC_M_CONNECTION_CLONE, "CONNECTION_CLONE" },43 { IPC_M_CLONE_ESTABLISH, "CLONE_ESTABLISH" },44 42 { IPC_M_CONNECT_ME_TO, "CONNECT_ME_TO" }, 45 43 { IPC_M_CONNECT_TO_ME, "CONNECT_TO_ME" }, -
uspace/lib/c/generic/async.c
r8a45bf09 r4d6629f 1357 1357 async_new_connection(call->in_task_id, in_phone_hash, callid, 1358 1358 call, handler, data); 1359 return;1360 }1361 1362 /* Cloned connection */1363 if (IPC_GET_IMETHOD(*call) == IPC_M_CLONE_ESTABLISH) {1364 // TODO: Currently ignores ports altogether1365 1366 /* Open new connection with fibril, etc. */1367 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call),1368 callid, call, fallback_port_handler, fallback_port_data);1369 1359 return; 1370 1360 } … … 2084 2074 2085 2075 return EOK; 2086 }2087 2088 /** Wrapper for making IPC_M_CLONE_ESTABLISH calls using the async framework.2089 *2090 * Ask for a cloned connection to some service.2091 *2092 * @param mgmt Exchange management style.2093 * @param exch Exchange for sending the message.2094 *2095 * @return New session on success or NULL on error.2096 *2097 */2098 async_sess_t *async_clone_establish(exch_mgmt_t mgmt, async_exch_t *exch)2099 {2100 if (exch == NULL) {2101 errno = ENOENT;2102 return NULL;2103 }2104 2105 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));2106 if (sess == NULL) {2107 errno = ENOMEM;2108 return NULL;2109 }2110 2111 ipc_call_t result;2112 2113 amsg_t *msg = amsg_create();2114 if (!msg) {2115 free(sess);2116 errno = ENOMEM;2117 return NULL;2118 }2119 2120 msg->dataptr = &result;2121 msg->wdata.active = true;2122 2123 ipc_call_async_0(exch->phone, IPC_M_CLONE_ESTABLISH, msg,2124 reply_received);2125 2126 sysarg_t rc;2127 async_wait_for((aid_t) msg, &rc);2128 2129 if (rc != EOK) {2130 errno = rc;2131 free(sess);2132 return NULL;2133 }2134 2135 int phone = (int) IPC_GET_ARG5(result);2136 2137 if (phone < 0) {2138 errno = phone;2139 free(sess);2140 return NULL;2141 }2142 2143 sess->iface = 0;2144 sess->mgmt = mgmt;2145 sess->phone = phone;2146 sess->arg1 = 0;2147 sess->arg2 = 0;2148 sess->arg3 = 0;2149 2150 fibril_mutex_initialize(&sess->remote_state_mtx);2151 sess->remote_state_data = NULL;2152 2153 list_initialize(&sess->exch_list);2154 fibril_mutex_initialize(&sess->mutex);2155 atomic_set(&sess->refcnt, 0);2156 2157 return sess;2158 2076 } 2159 2077 … … 3126 3044 } 3127 3045 3128 /** Wrapper for sending an exchange over different exchange for cloning3129 *3130 * @param exch Exchange to be used for sending.3131 * @param clone_exch Exchange to be cloned.3132 *3133 */3134 int async_exchange_clone(async_exch_t *exch, async_exch_t *clone_exch)3135 {3136 return async_req_1_0(exch, IPC_M_CONNECTION_CLONE, clone_exch->phone);3137 }3138 3139 /** Wrapper for receiving the IPC_M_CONNECTION_CLONE calls.3140 *3141 * If the current call is IPC_M_CONNECTION_CLONE then a new3142 * async session is created for the accepted phone.3143 *3144 * @param mgmt Exchange management style.3145 *3146 * @return New async session or NULL on failure.3147 *3148 */3149 async_sess_t *async_clone_receive(exch_mgmt_t mgmt)3150 {3151 /* Accept the phone */3152 ipc_call_t call;3153 ipc_callid_t callid = async_get_call(&call);3154 int phone = (int) IPC_GET_ARG1(call);3155 3156 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||3157 (phone < 0)) {3158 async_answer_0(callid, EINVAL);3159 return NULL;3160 }3161 3162 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));3163 if (sess == NULL) {3164 async_answer_0(callid, ENOMEM);3165 return NULL;3166 }3167 3168 sess->iface = 0;3169 sess->mgmt = mgmt;3170 sess->phone = phone;3171 sess->arg1 = 0;3172 sess->arg2 = 0;3173 sess->arg3 = 0;3174 3175 fibril_mutex_initialize(&sess->remote_state_mtx);3176 sess->remote_state_data = NULL;3177 3178 list_initialize(&sess->exch_list);3179 fibril_mutex_initialize(&sess->mutex);3180 atomic_set(&sess->refcnt, 0);3181 3182 /* Acknowledge the cloned phone */3183 async_answer_0(callid, EOK);3184 3185 return sess;3186 }3187 3188 3046 /** Wrapper for receiving the IPC_M_CONNECT_TO_ME calls. 3189 3047 * -
uspace/lib/c/include/async.h
r8a45bf09 r4d6629f 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 *);
Note:
See TracChangeset
for help on using the changeset viewer.