Changeset 4e49572 in mainline for generic/src/ipc/sysipc.c
- Timestamp:
- 2006-03-17T11:41:05Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 23d22eb
- Parents:
- 5a7d9d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/ipc/sysipc.c
r5a7d9d1 r4e49572 36 36 #include <ipc/ipc.h> 37 37 #include <ipc/sysipc.h> 38 #include <ipc/ipcrsc.h> 38 39 39 40 … … 63 64 { 64 65 return 1; 65 }66 67 /** Find call_t * in call table according to callid68 *69 * @return NULL on not found, otherwise pointer to call structure70 */71 static inline call_t * get_call(__native callid)72 {73 /* TODO: Traverse list of dispatched calls and find one */74 /* TODO: locking of call, ripping it from dispatched calls etc. */75 return (call_t *) callid;76 }77 78 /** Return pointer to phone identified by phoneid or NULL if non-existent */79 static phone_t * get_phone(__native phoneid)80 {81 phone_t *phone;82 83 if (phoneid >= IPC_MAX_PHONES)84 return NULL;85 86 phone = &TASK->phones[phoneid];87 if (!phone->callee)88 return NULL;89 return phone;90 }91 92 /** Allocate new phone slot in current TASK structure */93 static int phone_alloc(void)94 {95 int i;96 97 spinlock_lock(&TASK->lock);98 99 for (i=0; i < IPC_MAX_PHONES; i++) {100 if (!TASK->phones[i].busy) {101 TASK->phones[i].busy = 1;102 break;103 }104 }105 spinlock_unlock(&TASK->lock);106 107 if (i >= IPC_MAX_PHONES)108 return -1;109 return i;110 }111 112 /** Disconnect phone */113 static void phone_dealloc(int phoneid)114 {115 spinlock_lock(&TASK->lock);116 117 ASSERT(TASK->phones[phoneid].busy);118 119 if (TASK->phones[phoneid].callee)120 ipc_phone_destroy(&TASK->phones[phoneid]);121 122 TASK->phones[phoneid].busy = 0;123 spinlock_unlock(&TASK->lock);124 }125 126 static void phone_connect(int phoneid, answerbox_t *box)127 {128 phone_t *phone = &TASK->phones[phoneid];129 130 ipc_phone_connect(phone, box);131 66 } 132 67 … … 213 148 phone_t *phone; 214 149 215 phone = get_phone(phoneid);216 if (!phone)217 return ENOENT;218 219 150 if (is_system_method(method)) 220 151 return EPERM; 152 153 phone = get_phone_and_lock(phoneid); 154 if (!phone) 155 return ENOENT; 221 156 222 157 ipc_call_init(&call); … … 238 173 phone_t *phone; 239 174 240 phone = get_phone(phoneid);241 if (!phone)242 return ENOENT;243 244 175 ipc_call_init(&call); 245 176 copy_from_uspace(&call.data, question, sizeof(call.data)); … … 248 179 return EPERM; 249 180 181 phone = get_phone_and_lock(phoneid); 182 if (!phone) 183 return ENOENT; 184 250 185 ipc_call_sync(phone, &call); 251 186 … … 279 214 phone_t *phone; 280 215 281 phone = get_phone(phoneid);282 if (!phone)283 return IPC_CALLRET_FATAL;284 285 216 if (is_system_method(method)) 286 217 return IPC_CALLRET_FATAL; … … 288 219 if (check_call_limit()) 289 220 return IPC_CALLRET_TEMPORARY; 221 222 phone = get_phone_and_lock(phoneid); 223 if (!phone) 224 return IPC_CALLRET_FATAL; 290 225 291 226 call = ipc_call_alloc(); … … 308 243 phone_t *phone; 309 244 310 phone = get_phone(phoneid);311 if (!phone)312 return IPC_CALLRET_FATAL;313 314 245 if (check_call_limit()) 315 246 return IPC_CALLRET_TEMPORARY; 247 248 phone = get_phone_and_lock(phoneid); 249 if (!phone) 250 return IPC_CALLRET_FATAL; 316 251 317 252 call = ipc_call_alloc(); … … 345 280 return ENOENT; 346 281 347 phone = get_phone (phoneid);282 phone = get_phone_and_lock(phoneid); 348 283 if (!phone) { 349 284 IPC_SET_RETVAL(call->data, EFORWARD); … … 437 372 phone_t *phone; 438 373 439 phone = get_phone(phoneid);440 if (!phone)441 return ENOENT;442 443 374 ipc_call_init(&call); 444 375 IPC_SET_METHOD(call.data, IPC_M_CONNECTTOME); … … 446 377 IPC_SET_ARG2(call.data, arg2); 447 378 379 phone = get_phone_and_lock(phoneid); 380 if (!phone) 381 return ENOENT; 382 448 383 ipc_call_sync(phone, &call); 449 384 … … 467 402 int newphid; 468 403 469 phone = get_phone (phoneid);404 phone = get_phone_and_lock(phoneid); 470 405 if (!phone) 471 406 return ENOENT;
Note:
See TracChangeset
for help on using the changeset viewer.