Changeset c1d2c9d in mainline for libc/generic/ipc.c
- Timestamp:
- 2006-06-01T21:51:35Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da0c91e7
- Parents:
- 3993b3d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/ipc.c
r3993b3d rc1d2c9d 116 116 } 117 117 118 /** Send asynchronous message 119 * 120 * - if fatal error, call callback handler with proper error code 121 * - if message cannot be temporarily sent, add to queue 122 */ 123 void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1, 124 ipcarg_t arg2, void *private, 125 ipc_async_callback_t callback) 118 /** Prolog to ipc_async_send functions */ 119 static inline async_call_t *ipc_prepare_async(void *private, ipc_async_callback_t callback) 126 120 { 127 121 async_call_t *call; 128 ipc_callid_t callid;129 122 130 123 call = malloc(sizeof(*call)); … … 132 125 if (callback) 133 126 callback(private, ENOMEM, NULL); 134 return; 135 } 136 127 return NULL; 128 } 137 129 call->callback = callback; 138 130 call->private = private; 131 132 return call; 133 } 134 135 /** Epilogue of ipc_async_send functions */ 136 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, async_call_t *call) 137 { 138 if (callid == IPC_CALLRET_FATAL) { 139 futex_up(&ipc_futex); 140 /* Call asynchronous handler with error code */ 141 if (call->callback) 142 call->callback(call->private, ENOENT, NULL); 143 free(call); 144 return; 145 } 146 147 if (callid == IPC_CALLRET_TEMPORARY) { 148 futex_up(&ipc_futex); 149 150 call->u.msg.phoneid = phoneid; 151 152 call->ptid = psthread_get_id(); 153 futex_down(&async_futex); 154 list_append(&call->list, &queued_calls); 155 156 psthread_schedule_next_adv(PS_TO_MANAGER); 157 /* Async futex unlocked by previous call */ 158 return; 159 } 160 call->u.callid = callid; 161 /* Add call to list of dispatched calls */ 162 list_append(&call->list, &dispatched_calls); 163 futex_up(&ipc_futex); 164 165 } 166 167 /** Send asynchronous message 168 * 169 * - if fatal error, call callback handler with proper error code 170 * - if message cannot be temporarily sent, add to queue 171 */ 172 void ipc_call_async_2(int phoneid, ipcarg_t method, ipcarg_t arg1, 173 ipcarg_t arg2, void *private, 174 ipc_async_callback_t callback) 175 { 176 async_call_t *call; 177 ipc_callid_t callid; 178 179 call = ipc_prepare_async(private, callback); 180 if (!call) 181 return; 139 182 140 183 /* We need to make sure that we get callid before … … 142 185 futex_down(&ipc_futex); 143 186 callid = __SYSCALL4(SYS_IPC_CALL_ASYNC_FAST, phoneid, method, arg1, arg2); 144 if (callid == IPC_CALLRET_FATAL) {145 futex_up(&ipc_futex);146 /* Call asynchronous handler with error code */147 if (callback)148 callback(private, ENOENT, NULL);149 free(call);150 return;151 }152 187 153 188 if (callid == IPC_CALLRET_TEMPORARY) { 154 futex_up(&ipc_futex);155 156 call->u.msg.phoneid = phoneid;157 189 IPC_SET_METHOD(call->u.msg.data, method); 158 190 IPC_SET_ARG1(call->u.msg.data, arg1); 159 191 IPC_SET_ARG2(call->u.msg.data, arg2); 160 161 call->ptid = psthread_get_id(); 162 futex_down(&async_futex); 163 list_append(&call->list, &queued_calls); 164 165 psthread_schedule_next_adv(PS_TO_MANAGER); 166 /* Async futex unlocked by previous call */ 192 } 193 ipc_finish_async(callid, phoneid, call); 194 } 195 196 /** Send asynchronous message 197 * 198 * - if fatal error, call callback handler with proper error code 199 * - if message cannot be temporarily sent, add to queue 200 */ 201 void ipc_call_async_3(int phoneid, ipcarg_t method, ipcarg_t arg1, 202 ipcarg_t arg2, ipcarg_t arg3, void *private, 203 ipc_async_callback_t callback) 204 { 205 async_call_t *call; 206 ipc_callid_t callid; 207 208 call = ipc_prepare_async(private, callback); 209 if (!call) 167 210 return; 168 } 169 call->u.callid = callid; 170 /* Add call to list of dispatched calls */ 171 list_append(&call->list, &dispatched_calls); 172 futex_up(&ipc_futex); 211 212 IPC_SET_METHOD(call->u.msg.data, method); 213 IPC_SET_ARG1(call->u.msg.data, arg1); 214 IPC_SET_ARG2(call->u.msg.data, arg2); 215 IPC_SET_ARG3(call->u.msg.data, arg3); 216 /* We need to make sure that we get callid before 217 * another thread accesses the queue again */ 218 futex_down(&ipc_futex); 219 callid = _ipc_call_async(phoneid, &call->u.msg.data); 220 221 ipc_finish_async(callid, phoneid, call); 173 222 } 174 223
Note:
See TracChangeset
for help on using the changeset viewer.