Changeset 44c6d88d in mainline
- Timestamp:
- 2006-05-30T17:23:33Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eaf34f7
- Parents:
- 79460ae
- Location:
- libc
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/async.c
r79460ae r44c6d88d 270 270 } 271 271 272 /** Function that gets created on interrupt receival 273 * 274 * This function is defined as a weak symbol - to be redefined in 275 * user code. 276 */ 277 void interrupt_received(ipc_call_t *call) 278 { 279 } 280 281 272 282 /** Wrapper for client connection thread 273 283 * … … 309 319 * threads. 310 320 * 321 * @param in_phone_hash Identification of the incoming connection 311 322 * @param callid Callid of the IPC_M_CONNECT_ME_TO packet 312 323 * @param call Call data of the opening packet … … 315 326 * @return New thread id 316 327 */ 317 pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call, 328 pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, 329 ipc_call_t *call, 318 330 void (*cthread)(ipc_callid_t,ipc_call_t *)) 319 331 { … … 327 339 return NULL; 328 340 } 329 conn->in_phone_hash = IPC_GET_ARG3(*call);341 conn->in_phone_hash = in_phone_hash; 330 342 list_initialize(&conn->msg_queue); 331 343 conn->ptid = psthread_create(connection_thread, conn); … … 354 366 static void handle_call(ipc_callid_t callid, ipc_call_t *call) 355 367 { 368 /* Unrouted call - do some default behaviour */ 369 switch (IPC_GET_METHOD(*call)) { 370 case IPC_M_INTERRUPT: 371 interrupt_received(call); 372 return; 373 case IPC_M_CONNECT_ME_TO: 374 /* Open new connection with thread etc. */ 375 async_new_connection(IPC_GET_ARG3(*call), callid, call, client_connection); 376 return; 377 } 378 379 /* Try to route call through connection tables */ 356 380 if (route_call(callid, call)) 357 381 return; 358 382 359 switch (IPC_GET_METHOD(*call)) { 360 case IPC_M_INTERRUPT: 361 break; 362 case IPC_M_CONNECT_ME_TO: 363 /* Open new connection with thread etc. */ 364 async_new_connection(callid, call, client_connection); 365 break; 366 default: 367 ipc_answer_fast(callid, EHANGUP, 0, 0); 368 } 383 /* Unknown call from unknown phone - hang it up */ 384 ipc_answer_fast(callid, EHANGUP, 0, 0); 369 385 } 370 386 … … 622 638 } 623 639 640 /** Wait specified time, but in the meantime handle incoming events 641 * 642 * @param timeout Time in microseconds to wait 643 */ 644 void async_usleep(suseconds_t timeout) 645 { 646 amsg_t *msg; 647 648 msg = malloc(sizeof(*msg)); 649 if (!msg) 650 return; 651 652 msg->ptid = psthread_get_id(); 653 msg->active = 0; 654 msg->has_timeout = 1; 655 656 gettimeofday(&msg->expires, NULL); 657 tv_add(&msg->expires, timeout); 658 659 futex_down(&async_futex); 660 insert_timeout(msg); 661 /* Leave locked async_futex when entering this function */ 662 psthread_schedule_next_adv(PS_TO_MANAGER); 663 /* futex is up automatically after psthread_schedule_next...*/ 664 free(msg); 665 } -
libc/generic/io/stream.c
r79460ae r44c6d88d 65 65 if (console_phone < 0) { 66 66 while ((console_phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0)) < 0) { 67 volatile int a; 68 for (a = 0; a < 1048576; a++); 67 usleep(10000); 69 68 } 70 69 } -
libc/generic/time.c
r79460ae r44c6d88d 32 32 #include <stdio.h> 33 33 #include <arch/barrier.h> 34 #include <unistd.h> 35 #include <atomic.h> 36 #include <futex.h> 34 37 35 38 #include <sysinfo.h> … … 94 97 return 0; 95 98 } 99 100 /** Wait unconditionally for specified miliseconds */ 101 void usleep(unsigned long usec) 102 { 103 atomic_t futex = FUTEX_INITIALIZER; 104 105 futex_initialize(&futex,0); 106 futex_down_timeout(&futex, usec, 0); 107 } -
libc/include/async.h
r79460ae r44c6d88d 14 14 ipc_callid_t async_get_call(ipc_call_t *data); 15 15 16 pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call,17 void (*cthread)(ipc_callid_t,ipc_call_t *));18 16 aid_t async_send_2(int phoneid, ipcarg_t method, ipcarg_t arg1, ipcarg_t arg2, 19 17 ipc_call_t *dataptr); 20 18 void async_wait_for(aid_t amsgid, ipcarg_t *result); 21 19 int async_wait_timeout(aid_t amsgid, ipcarg_t *retval, suseconds_t timeout); 22 20 pstid_t async_new_connection(ipcarg_t in_phone_hash,ipc_callid_t callid, 21 ipc_call_t *call, 22 void (*cthread)(ipc_callid_t,ipc_call_t *)); 23 void async_usleep(suseconds_t timeout); 23 24 24 25 /* Should be defined by application */ 25 26 void client_connection(ipc_callid_t callid, ipc_call_t *call) __attribute__((weak)); 27 void interrupt_received(ipc_call_t *call) __attribute__((weak)); 26 28 27 29 #endif -
libc/include/unistd.h
r79460ae r44c6d88d 39 39 extern void _exit(int status); 40 40 void *sbrk(ssize_t incr); 41 void usleep(unsigned long usec); 41 42 42 43 #endif
Note:
See TracChangeset
for help on using the changeset viewer.