Changes in / [6aef742:197ef43] in mainline
- Files:
-
- 4 added
- 1 deleted
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ipc/event_types.h
r6aef742 r197ef43 41 41 /** Returning from kernel console to userspace */ 42 42 EVENT_KCONSOLE, 43 /** A t hread has faulted and will be terminated */43 /** A task/thread has faulted and will be terminated */ 44 44 EVENT_FAULT, 45 45 EVENT_END -
kernel/generic/include/proc/task.h
r6aef742 r197ef43 131 131 extern task_t *task_find_by_id(task_id_t); 132 132 extern int task_kill(task_id_t); 133 extern void task_kill_self(bool) __attribute__((noreturn)); 133 134 extern void task_get_accounting(task_t *, uint64_t *, uint64_t *); 134 135 extern void task_print_list(bool); … … 155 156 extern sysarg_t sys_task_set_name(const char *, size_t); 156 157 extern sysarg_t sys_task_kill(task_id_t *); 158 extern sysarg_t sys_task_exit(sysarg_t); 157 159 158 160 #endif -
kernel/generic/include/syscall/syscall.h
r6aef742 r197ef43 48 48 SYS_TASK_SET_NAME, 49 49 SYS_TASK_KILL, 50 SYS_TASK_EXIT, 50 51 SYS_PROGRAM_SPAWN_LOADER, 51 52 -
kernel/generic/src/interrupt/interrupt.c
r6aef742 r197ef43 45 45 #include <console/console.h> 46 46 #include <console/cmd.h> 47 #include <ipc/event.h>48 47 #include <synch/mutex.h> 49 48 #include <time/delay.h> … … 188 187 printf("\n"); 189 188 190 /* 191 * Userspace can subscribe for FAULT events to take action 192 * whenever a thread faults. (E.g. take a dump, run a debugger). 193 * The notification is always available, but unless Udebug is enabled, 194 * that's all you get. 195 */ 196 if (event_is_subscribed(EVENT_FAULT)) { 197 /* Notify the subscriber that a fault occurred. */ 198 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid), 199 UPPER32(TASK->taskid), (sysarg_t) THREAD); 200 201 #ifdef CONFIG_UDEBUG 202 /* Wait for a debugging session. */ 203 udebug_thread_fault(); 204 #endif 205 } 206 207 task_kill(TASK->taskid); 208 thread_exit(); 189 task_kill_self(true); 209 190 } 210 191 -
kernel/generic/src/proc/task.c
r6aef742 r197ef43 384 384 { 385 385 task_id_t taskid; 386 int rc; 387 388 rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid)); 386 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid)); 389 387 if (rc != 0) 390 388 return (sysarg_t) rc; 391 389 392 390 return (sysarg_t) task_kill(taskid); 393 391 } … … 520 518 } 521 519 520 /** Kill the currently running task. 521 * 522 * @param notify Send out fault notifications. 523 * 524 * @return Zero on success or an error code from errno.h. 525 * 526 */ 527 void task_kill_self(bool notify) 528 { 529 /* 530 * User space can subscribe for FAULT events to take action 531 * whenever a task faults (to take a dump, run a debugger, etc.). 532 * The notification is always available, but unless udebug is enabled, 533 * that's all you get. 534 */ 535 if (notify) { 536 if (event_is_subscribed(EVENT_FAULT)) { 537 /* Notify the subscriber that a fault occurred. */ 538 event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid), 539 UPPER32(TASK->taskid), (sysarg_t) THREAD); 540 541 #ifdef CONFIG_UDEBUG 542 /* Wait for a debugging session. */ 543 udebug_thread_fault(); 544 #endif 545 } 546 } 547 548 irq_spinlock_lock(&tasks_lock, true); 549 task_kill_internal(TASK); 550 irq_spinlock_unlock(&tasks_lock, true); 551 552 thread_exit(); 553 } 554 555 /** Process syscall to terminate the current task. 556 * 557 * @param notify Send out fault notifications. 558 * 559 */ 560 sysarg_t sys_task_exit(sysarg_t notify) 561 { 562 task_kill_self(notify); 563 564 /* Unreachable */ 565 return EOK; 566 } 567 522 568 static bool task_print_walker(avltree_node_t *node, void *arg) 523 569 { -
kernel/generic/src/syscall/syscall.c
r6aef742 r197ef43 86 86 } else { 87 87 printf("Task %" PRIu64": Unknown syscall %#" PRIxn, TASK->taskid, id); 88 task_kill(TASK->taskid); 89 thread_exit(); 88 task_kill_self(true); 90 89 } 91 90 … … 131 130 (syshandler_t) sys_task_set_name, 132 131 (syshandler_t) sys_task_kill, 132 (syshandler_t) sys_task_exit, 133 133 (syshandler_t) sys_program_spawn_loader, 134 134 -
uspace/lib/c/Makefile
r6aef742 r197ef43 97 97 generic/adt/char_map.c \ 98 98 generic/time.c \ 99 generic/err.c \100 99 generic/stdlib.c \ 101 100 generic/mman.c \ -
uspace/lib/c/arch/abs32le/src/entry.c
r6aef742 r197ef43 37 37 { 38 38 __main(NULL); 39 __exit();40 39 } 41 40 -
uspace/lib/c/arch/abs32le/src/thread_entry.c
r6aef742 r197ef43 31 31 32 32 #include <unistd.h> 33 #include <thread.h>33 #include "../../../generic/private/thread.h" 34 34 35 35 void __thread_entry(void) -
uspace/lib/c/arch/amd64/src/entry.s
r6aef742 r197ef43 47 47 # Pass PCB pointer to __main (no operation) 48 48 call __main 49 50 call __exit -
uspace/lib/c/arch/arm32/src/entry.s
r6aef742 r197ef43 42 42 ldr r0, =ras_page 43 43 str r2, [r0] 44 44 45 45 # 46 46 # Create the first stack frame. … … 50 50 push {fp, ip, lr, pc} 51 51 sub fp, ip, #4 52 52 53 53 # Pass pcb_ptr to __main as the first argument (in r0) 54 54 mov r0, r1 55 55 bl __main 56 57 bl __exit58 56 59 57 .data … … 62 60 ras_page: 63 61 .long 0 64 -
uspace/lib/c/arch/ia32/src/entry.s
r6aef742 r197ef43 46 46 mov %ax, %fs 47 47 # Do not set %gs, it contains descriptor that can see TLS 48 48 49 49 # Detect the mechanism used for making syscalls 50 50 movl $(INTEL_CPUID_STANDARD), %eax … … 58 58 # Create the first stack frame. 59 59 # 60 pushl $0 60 pushl $0 61 61 movl %esp, %ebp 62 62 63 63 # Pass the PCB pointer to __main as the first argument 64 64 pushl %edi 65 65 call __main 66 67 call __exit -
uspace/lib/c/arch/ia64/src/entry.s
r6aef742 r197ef43 40 40 alloc loc0 = ar.pfs, 0, 1, 2, 0 41 41 movl gp = _gp 42 42 43 43 # Pass PCB pointer as the first argument to __main 44 44 mov out0 = r2 45 45 br.call.sptk.many b0 = __main 46 0:47 br.call.sptk.many b0 = __exit -
uspace/lib/c/arch/mips32/src/entry.s
r6aef742 r197ef43 56 56 jal __main 57 57 nop 58 59 jal __exit60 nop61 58 .end 62 59 -
uspace/lib/c/arch/ppc32/src/entry.s
r6aef742 r197ef43 44 44 stw %r3, 0(%r1) 45 45 stwu %r1, -16(%r1) 46 46 47 47 # Pass the PCB pointer to __main() as the first argument. 48 48 # The first argument is passed in r3. 49 49 mr %r3, %r6 50 50 bl __main 51 52 bl __exit -
uspace/lib/c/arch/sparc64/src/entry.s
r6aef742 r197ef43 45 45 flushw 46 46 add %g0, -0x7ff, %fp 47 47 48 48 # Pass pcb_ptr as the first argument to __main() 49 49 mov %i1, %o0 … … 51 51 call __main 52 52 or %l7, %lo(_gp), %l7 53 54 call __exit55 nop -
uspace/lib/c/generic/async.c
r6aef742 r197ef43 42 42 * You should be able to write very simple multithreaded programs, the async 43 43 * framework will automatically take care of most synchronization problems. 44 *45 * Default semantics:46 * - async_send_*(): Send asynchronously. If the kernel refuses to send47 * more messages, [ try to get responses from kernel, if48 * nothing found, might try synchronous ]49 44 * 50 45 * Example of use (pseudo C): … … 127 122 128 123 /** 129 * Structures of this type are used to group information about a call and a130 * message queue link.124 * Structures of this type are used to group information about 125 * a call and about a message queue link. 131 126 */ 132 127 typedef struct { … … 156 151 /** Link to the client tracking structure. */ 157 152 client_t *client; 158 153 159 154 /** Messages that should be delivered to this fibril. */ 160 155 link_t msg_queue; … … 173 168 174 169 /** Identifier of the incoming connection handled by the current fibril. */ 175 fibril_local connection_t *FIBRIL_connection;170 static fibril_local connection_t *FIBRIL_connection; 176 171 177 172 static void *default_client_data_constructor(void) … … 202 197 { 203 198 assert(FIBRIL_connection); 204 205 199 return FIBRIL_connection->client->data; 206 200 } 207 201 208 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); 209 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call); 202 /** Default fibril function that gets called to handle new connection. 203 * 204 * This function is defined as a weak symbol - to be redefined in user code. 205 * 206 * @param callid Hash of the incoming call. 207 * @param call Data of the incoming call. 208 * 209 */ 210 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call) 211 { 212 ipc_answer_0(callid, ENOENT); 213 } 210 214 211 215 /** … … 213 217 */ 214 218 static async_client_conn_t client_connection = default_client_connection; 219 220 /** Default fibril function that gets called to handle interrupt notifications. 221 * 222 * This function is defined as a weak symbol - to be redefined in user code. 223 * 224 * @param callid Hash of the incoming call. 225 * @param call Data of the incoming call. 226 * 227 */ 228 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call) 229 { 230 } 215 231 216 232 /** … … 224 240 static LIST_INITIALIZE(timeout_list); 225 241 226 #define CLIENT_HASH_TABLE_BUCKETS 227 #define CONN_HASH_TABLE_BUCKETS 228 229 static hash_index_t client_hash(unsigned long *key)242 #define CLIENT_HASH_TABLE_BUCKETS 32 243 #define CONN_HASH_TABLE_BUCKETS 32 244 245 static hash_index_t client_hash(unsigned long key[]) 230 246 { 231 247 assert(key); 232 return ((( *key) >> 4) % CLIENT_HASH_TABLE_BUCKETS);248 return (((key[0]) >> 4) % CLIENT_HASH_TABLE_BUCKETS); 233 249 } 234 250 235 251 static int client_compare(unsigned long key[], hash_count_t keys, link_t *item) 236 252 { 237 client_t *cl = hash_table_get_instance(item, client_t, link);238 return (key[0] == cl ->in_task_hash);253 client_t *client = hash_table_get_instance(item, client_t, link); 254 return (key[0] == client->in_task_hash); 239 255 } 240 256 … … 257 273 * 258 274 */ 259 static hash_index_t conn_hash(unsigned long *key)275 static hash_index_t conn_hash(unsigned long key[]) 260 276 { 261 277 assert(key); 262 return ((( *key) >> 4) % CONN_HASH_TABLE_BUCKETS);278 return (((key[0]) >> 4) % CONN_HASH_TABLE_BUCKETS); 263 279 } 264 280 … … 274 290 static int conn_compare(unsigned long key[], hash_count_t keys, link_t *item) 275 291 { 276 connection_t * hs= hash_table_get_instance(item, connection_t, link);277 return (key[0] == hs->in_phone_hash);292 connection_t *conn = hash_table_get_instance(item, connection_t, link); 293 return (key[0] == conn->in_phone_hash); 278 294 } 279 295 … … 290 306 free(hash_table_get_instance(item, connection_t, link)); 291 307 } 292 293 308 294 309 /** Operations for the connection hash table. */ … … 311 326 link_t *tmp = timeout_list.next; 312 327 while (tmp != &timeout_list) { 313 awaiter_t *cur ;314 315 cur = list_get_instance(tmp, awaiter_t, to_event.link);328 awaiter_t *cur 329 = list_get_instance(tmp, awaiter_t, to_event.link); 330 316 331 if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires)) 317 332 break; 333 318 334 tmp = tmp->next; 319 335 } … … 332 348 * 333 349 * @return False if the call doesn't match any connection. 334 * 350 * @return True if the call was passed to the respective connection fibril. 335 351 * 336 352 */ … … 469 485 * the first IPC_M_PHONE_HUNGUP call and continues to 470 486 * call async_get_call_timeout(). Repeat 471 * IPC_M_PHONE_HUNGUP until the caller notices. 487 * IPC_M_PHONE_HUNGUP until the caller notices. 472 488 */ 473 489 memset(call, 0, sizeof(ipc_call_t)); … … 476 492 return conn->close_callid; 477 493 } 478 494 479 495 if (usecs) 480 496 async_insert_timeout(&conn->wdata); … … 514 530 } 515 531 516 /** Default fibril function that gets called to handle new connection.517 *518 * This function is defined as a weak symbol - to be redefined in user code.519 *520 * @param callid Hash of the incoming call.521 * @param call Data of the incoming call.522 *523 */524 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)525 {526 ipc_answer_0(callid, ENOENT);527 }528 529 /** Default fibril function that gets called to handle interrupt notifications.530 *531 * This function is defined as a weak symbol - to be redefined in user code.532 *533 * @param callid Hash of the incoming call.534 * @param call Data of the incoming call.535 *536 */537 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call)538 {539 }540 541 532 /** Wrapper for client connection fibril. 542 533 * … … 551 542 static int connection_fibril(void *arg) 552 543 { 553 unsigned long key;554 client_t *cl;555 link_t *lnk;556 bool destroy = false;557 558 544 /* 559 545 * Setup fibril-local connection pointer. 560 546 */ 561 547 FIBRIL_connection = (connection_t *) arg; 562 548 549 futex_down(&async_futex); 550 563 551 /* 564 552 * Add our reference for the current connection in the client task … … 566 554 * hash in a new tracking structure. 567 555 */ 568 futex_down(&async_futex); 569 key = FIBRIL_connection->in_task_hash; 570 lnk = hash_table_find(&client_hash_table, &key); 556 557 unsigned long key = FIBRIL_connection->in_task_hash; 558 link_t *lnk = hash_table_find(&client_hash_table, &key); 559 560 client_t *client; 561 571 562 if (lnk) { 572 cl = hash_table_get_instance(lnk, client_t, link);573 cl ->refcnt++;563 client = hash_table_get_instance(lnk, client_t, link); 564 client->refcnt++; 574 565 } else { 575 cl = malloc(sizeof(client_t));576 if (!cl ) {566 client = malloc(sizeof(client_t)); 567 if (!client) { 577 568 ipc_answer_0(FIBRIL_connection->callid, ENOMEM); 578 569 futex_up(&async_futex); 579 570 return 0; 580 571 } 581 cl->in_task_hash = FIBRIL_connection->in_task_hash; 572 573 client->in_task_hash = FIBRIL_connection->in_task_hash; 574 582 575 async_serialize_start(); 583 cl ->data = async_client_data_create();576 client->data = async_client_data_create(); 584 577 async_serialize_end(); 585 cl->refcnt = 1; 586 hash_table_insert(&client_hash_table, &key, &cl->link); 587 } 578 579 client->refcnt = 1; 580 hash_table_insert(&client_hash_table, &key, &client->link); 581 } 582 588 583 futex_up(&async_futex); 589 590 FIBRIL_connection->client = cl ;591 584 585 FIBRIL_connection->client = client; 586 592 587 /* 593 588 * Call the connection handler function. … … 599 594 * Remove the reference for this client task connection. 600 595 */ 596 bool destroy; 597 601 598 futex_down(&async_futex); 602 if (--cl->refcnt == 0) { 599 600 if (--client->refcnt == 0) { 603 601 hash_table_remove(&client_hash_table, &key, 1); 604 602 destroy = true; 605 } 603 } else 604 destroy = false; 605 606 606 futex_up(&async_futex); 607 607 608 608 if (destroy) { 609 if (cl->data) 610 async_client_data_destroy(cl->data); 611 free(cl); 612 } 613 609 if (client->data) 610 async_client_data_destroy(client->data); 611 612 free(client); 613 } 614 614 615 /* 615 616 * Remove myself from the connection hash table. … … 624 625 */ 625 626 while (!list_empty(&FIBRIL_connection->msg_queue)) { 626 msg_t *msg ;627 628 msg = list_get_instance(FIBRIL_connection->msg_queue.next,629 msg_t, link);627 msg_t *msg = 628 list_get_instance(FIBRIL_connection->msg_queue.next, msg_t, 629 link); 630 630 631 list_remove(&msg->link); 631 632 ipc_answer_0(msg->callid, EHANGUP); … … 670 671 if (callid) 671 672 ipc_answer_0(callid, ENOMEM); 673 672 674 return (uintptr_t) NULL; 673 675 } … … 717 719 static void handle_call(ipc_callid_t callid, ipc_call_t *call) 718 720 { 719 /* Unrouted call - do some default behaviour*/721 /* Unrouted call - take some default action */ 720 722 if ((callid & IPC_CALLID_NOTIFICATION)) { 721 723 process_notification(callid, call); 722 goto out;724 return; 723 725 } 724 726 … … 726 728 case IPC_M_CONNECT_ME: 727 729 case IPC_M_CONNECT_ME_TO: 728 /* Open new connection with fibril etc. */730 /* Open new connection with fibril, etc. */ 729 731 async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call), 730 732 callid, call, client_connection); 731 goto out;733 return; 732 734 } 733 735 734 736 /* Try to route the call through the connection hash table */ 735 737 if (route_call(callid, call)) 736 goto out;738 return; 737 739 738 740 /* Unknown call from unknown phone - hang it up */ 739 741 ipc_answer_0(callid, EHANGUP); 740 return;741 742 out:743 ;744 742 } 745 743 … … 754 752 link_t *cur = timeout_list.next; 755 753 while (cur != &timeout_list) { 756 awaiter_t *waiter ;757 758 waiter = list_get_instance(cur, awaiter_t, to_event.link);754 awaiter_t *waiter = 755 list_get_instance(cur, awaiter_t, to_event.link); 756 759 757 if (tv_gt(&waiter->to_event.expires, &tv)) 760 758 break; 761 759 762 760 cur = cur->next; 763 761 764 762 list_remove(&waiter->to_event.link); 765 763 waiter->to_event.inlist = false; … … 788 786 while (true) { 789 787 if (fibril_switch(FIBRIL_FROM_MANAGER)) { 790 futex_up(&async_futex); 788 futex_up(&async_futex); 791 789 /* 792 790 * async_futex is always held when entering a manager … … 811 809 continue; 812 810 } else 813 timeout = tv_sub(&waiter->to_event.expires, 814 &tv); 811 timeout = tv_sub(&waiter->to_event.expires, &tv); 815 812 } else 816 813 timeout = SYNCH_NO_TIMEOUT; 817 814 818 815 futex_up(&async_futex); 819 816 820 817 atomic_inc(&threads_in_ipc_wait); 821 818 … … 825 822 826 823 atomic_dec(&threads_in_ipc_wait); 827 824 828 825 if (!callid) { 829 826 handle_expired_timeouts(); … … 875 872 /** Initialize the async framework. 876 873 * 877 * @return Zero on success or an error code. 878 */ 879 int __async_init(void) 874 */ 875 void __async_init(void) 880 876 { 881 877 if (!hash_table_create(&client_hash_table, CLIENT_HASH_TABLE_BUCKETS, 1, 882 &client_hash_table_ops) || !hash_table_create(&conn_hash_table, 883 CONN_HASH_TABLE_BUCKETS, 1, &conn_hash_table_ops)) { 884 return ENOMEM; 885 } 886 887 _async_sess_init(); 888 889 return 0; 878 &client_hash_table_ops)) 879 abort(); 880 881 if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_BUCKETS, 1, 882 &conn_hash_table_ops)) 883 abort(); 890 884 } 891 885 … … 900 894 * @param retval Value returned in the answer. 901 895 * @param data Call data of the answer. 896 * 902 897 */ 903 898 static void reply_received(void *arg, int retval, ipc_call_t *data) … … 947 942 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, ipc_call_t *dataptr) 948 943 { 949 amsg_t *msg = malloc(sizeof( *msg));944 amsg_t *msg = malloc(sizeof(amsg_t)); 950 945 951 946 if (!msg) … … 956 951 957 952 msg->wdata.to_event.inlist = false; 958 /* We may sleep in the next method, but it will use its own mechanism */ 953 954 /* 955 * We may sleep in the next method, 956 * but it will use its own means 957 */ 959 958 msg->wdata.active = true; 960 959 … … 987 986 ipc_call_t *dataptr) 988 987 { 989 amsg_t *msg = malloc(sizeof( *msg));988 amsg_t *msg = malloc(sizeof(amsg_t)); 990 989 991 990 if (!msg) … … 996 995 997 996 msg->wdata.to_event.inlist = false; 998 /* We may sleep in next method, but it will use its own mechanism */ 997 998 /* 999 * We may sleep in the next method, 1000 * but it will use its own means 1001 */ 999 1002 msg->wdata.active = true; 1000 1003 … … 1095 1098 void async_usleep(suseconds_t timeout) 1096 1099 { 1097 amsg_t *msg = malloc(sizeof( *msg));1100 amsg_t *msg = malloc(sizeof(amsg_t)); 1098 1101 1099 1102 if (!msg) … … 1307 1310 } 1308 1311 1309 int async_forward_fast(ipc_callid_t callid, int phoneid, int imethod,1310 sysarg_t arg1, sysarg_t arg2, int mode)1312 int async_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod, 1313 sysarg_t arg1, sysarg_t arg2, unsigned int mode) 1311 1314 { 1312 1315 return ipc_forward_fast(callid, phoneid, imethod, arg1, arg2, mode); 1313 1316 } 1314 1317 1315 int async_forward_slow(ipc_callid_t callid, int phoneid, int imethod,1318 int async_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod, 1316 1319 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, 1317 int mode)1320 unsigned int mode) 1318 1321 { 1319 1322 return ipc_forward_slow(callid, phoneid, imethod, arg1, arg2, arg3, arg4, … … 1428 1431 } 1429 1432 1430 /** Wrapper for makingIPC_M_SHARE_IN calls using the async framework.1431 * 1432 * @param phoneid 1433 * @param dst 1434 * @param size 1435 * @param arg 1436 * @param flags Storage where the received flags will be stored. Can be1437 * NULL.1438 * 1439 * @return Zero on success or a negative error code from errno.h.1433 /** Wrapper for IPC_M_SHARE_IN calls using the async framework. 1434 * 1435 * @param phoneid Phone that will be used to contact the receiving side. 1436 * @param dst Destination address space area base. 1437 * @param size Size of the destination address space area. 1438 * @param arg User defined argument. 1439 * @param flags Storage for the received flags. Can be NULL. 1440 * 1441 * @return Zero on success or a negative error code from errno.h. 1442 * 1440 1443 */ 1441 1444 int async_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg, 1442 int *flags) 1443 { 1444 int res; 1445 unsigned int *flags) 1446 { 1445 1447 sysarg_t tmp_flags; 1446 res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst,1448 int res = async_req_3_2(phoneid, IPC_M_SHARE_IN, (sysarg_t) dst, 1447 1449 (sysarg_t) size, arg, NULL, &tmp_flags); 1450 1448 1451 if (flags) 1449 *flags = tmp_flags; 1452 *flags = (unsigned int) tmp_flags; 1453 1450 1454 return res; 1451 1455 } … … 1453 1457 /** Wrapper for receiving the IPC_M_SHARE_IN calls using the async framework. 1454 1458 * 1455 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN calls 1456 * so that the user doesn't have to remember the meaning of each IPC argument. 1459 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_IN 1460 * calls so that the user doesn't have to remember the meaning of each IPC 1461 * argument. 1457 1462 * 1458 1463 * So far, this wrapper is to be used from within a connection fibril. 1459 1464 * 1460 * @param callid Storage where the hash of the IPC_M_SHARE_IN call will 1461 * be stored. 1462 * @param size Destination address space area size. 1463 * 1464 * @return Non-zero on success, zero on failure. 1465 */ 1466 int async_share_in_receive(ipc_callid_t *callid, size_t *size) 1467 { 1468 ipc_call_t data; 1469 1465 * @param callid Storage for the hash of the IPC_M_SHARE_IN call. 1466 * @param size Destination address space area size. 1467 * 1468 * @return True on success, false on failure. 1469 * 1470 */ 1471 bool async_share_in_receive(ipc_callid_t *callid, size_t *size) 1472 { 1470 1473 assert(callid); 1471 1474 assert(size); 1472 1475 1476 ipc_call_t data; 1473 1477 *callid = async_get_call(&data); 1478 1474 1479 if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN) 1475 return 0; 1480 return false; 1481 1476 1482 *size = (size_t) IPC_GET_ARG2(data); 1477 return 1;1483 return true; 1478 1484 } 1479 1485 1480 1486 /** Wrapper for answering the IPC_M_SHARE_IN calls using the async framework. 1481 1487 * 1482 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls 1483 * so that the user doesn't have to remember the meaning of each IPC argument. 1484 * 1485 * @param callid Hash of the IPC_M_DATA_READ call to answer. 1486 * @param src Source address space base. 1487 * @param flags Flags to be used for sharing. Bits can be only cleared. 1488 * 1489 * @return Zero on success or a value from @ref errno.h on failure. 1490 */ 1491 int async_share_in_finalize(ipc_callid_t callid, void *src, int flags) 1488 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ 1489 * calls so that the user doesn't have to remember the meaning of each IPC 1490 * argument. 1491 * 1492 * @param callid Hash of the IPC_M_DATA_READ call to answer. 1493 * @param src Source address space base. 1494 * @param flags Flags to be used for sharing. Bits can be only cleared. 1495 * 1496 * @return Zero on success or a value from @ref errno.h on failure. 1497 * 1498 */ 1499 int async_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags) 1492 1500 { 1493 1501 return ipc_share_in_finalize(callid, src, flags); 1494 1502 } 1495 1503 1496 /** Wrapper for making IPC_M_SHARE_OUT calls using the async framework. 1497 * 1498 * @param phoneid Phone that will be used to contact the receiving side. 1499 * @param src Source address space area base address. 1500 * @param flags Flags to be used for sharing. Bits can be only cleared. 1501 * 1502 * @return Zero on success or a negative error code from errno.h. 1503 */ 1504 int async_share_out_start(int phoneid, void *src, int flags) 1504 /** Wrapper for IPC_M_SHARE_OUT calls using the async framework. 1505 * 1506 * @param phoneid Phone that will be used to contact the receiving side. 1507 * @param src Source address space area base address. 1508 * @param flags Flags to be used for sharing. Bits can be only cleared. 1509 * 1510 * @return Zero on success or a negative error code from errno.h. 1511 * 1512 */ 1513 int async_share_out_start(int phoneid, void *src, unsigned int flags) 1505 1514 { 1506 1515 return async_req_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0, … … 1510 1519 /** Wrapper for receiving the IPC_M_SHARE_OUT calls using the async framework. 1511 1520 * 1512 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT calls 1513 * so that the user doesn't have to remember the meaning of each IPC argument. 1521 * This wrapper only makes it more comfortable to receive IPC_M_SHARE_OUT 1522 * calls so that the user doesn't have to remember the meaning of each IPC 1523 * argument. 1514 1524 * 1515 1525 * So far, this wrapper is to be used from within a connection fibril. 1516 1526 * 1517 * @param callid Storage where the hash of the IPC_M_SHARE_OUT call will 1518 * be stored. 1519 * @param size Storage where the source address space area size will be 1520 * stored. 1521 * @param flags Storage where the sharing flags will be stored. 1522 * 1523 * @return Non-zero on success, zero on failure. 1524 */ 1525 int async_share_out_receive(ipc_callid_t *callid, size_t *size, int *flags) 1526 { 1527 ipc_call_t data; 1528 1527 * @param callid Storage for the hash of the IPC_M_SHARE_OUT call. 1528 * @param size Storage for the source address space area size. 1529 * @param flags Storage for the sharing flags. 1530 * 1531 * @return True on success, false on failure. 1532 * 1533 */ 1534 bool async_share_out_receive(ipc_callid_t *callid, size_t *size, unsigned int *flags) 1535 { 1529 1536 assert(callid); 1530 1537 assert(size); 1531 1538 assert(flags); 1532 1539 1540 ipc_call_t data; 1533 1541 *callid = async_get_call(&data); 1542 1534 1543 if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT) 1535 return 0; 1544 return false; 1545 1536 1546 *size = (size_t) IPC_GET_ARG2(data); 1537 *flags = ( int) IPC_GET_ARG3(data);1538 return 1;1547 *flags = (unsigned int) IPC_GET_ARG3(data); 1548 return true; 1539 1549 } 1540 1550 1541 1551 /** Wrapper for answering the IPC_M_SHARE_OUT calls using the async framework. 1542 1552 * 1543 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls 1544 * so that the user doesn't have to remember the meaning of each IPC argument. 1545 * 1546 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 1547 * @param dst Destination address space area base address. 1548 * 1549 * @return Zero on success or a value from @ref errno.h on failure. 1553 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT 1554 * calls so that the user doesn't have to remember the meaning of each IPC 1555 * argument. 1556 * 1557 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 1558 * @param dst Destination address space area base address. 1559 * 1560 * @return Zero on success or a value from @ref errno.h on failure. 1561 * 1550 1562 */ 1551 1563 int async_share_out_finalize(ipc_callid_t callid, void *dst) … … 1554 1566 } 1555 1567 1556 1557 /** Wrapper for making IPC_M_DATA_READ calls using the async framework. 1558 * 1559 * @param phoneid Phone that will be used to contact the receiving side.1560 * @param dst Address of the beginningof the destination buffer.1561 * @param size Size of the destination buffer.1562 * 1563 * @return Zero on success or a negative error code from errno.h.1568 /** Wrapper for IPC_M_DATA_READ calls using the async framework. 1569 * 1570 * @param phoneid Phone that will be used to contact the receiving side. 1571 * @param dst Address of the beginning of the destination buffer. 1572 * @param size Size of the destination buffer. 1573 * 1574 * @return Zero on success or a negative error code from errno.h. 1575 * 1564 1576 */ 1565 1577 int async_data_read_start(int phoneid, void *dst, size_t size) … … 1571 1583 /** Wrapper for receiving the IPC_M_DATA_READ calls using the async framework. 1572 1584 * 1573 * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ calls 1574 * so that the user doesn't have to remember the meaning of each IPC argument. 1585 * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ 1586 * calls so that the user doesn't have to remember the meaning of each IPC 1587 * argument. 1575 1588 * 1576 1589 * So far, this wrapper is to be used from within a connection fibril. 1577 1590 * 1578 * @param callid Storage where the hash of the IPC_M_DATA_READ call will 1579 * be stored. 1580 * @param size Storage where the maximum size will be stored. Can be 1581 * NULL. 1582 * 1583 * @return Non-zero on success, zero on failure. 1584 */ 1585 int async_data_read_receive(ipc_callid_t *callid, size_t *size) 1586 { 1591 * @param callid Storage for the hash of the IPC_M_DATA_READ. 1592 * @param size Storage for the maximum size. Can be NULL. 1593 * 1594 * @return True on success, false on failure. 1595 * 1596 */ 1597 bool async_data_read_receive(ipc_callid_t *callid, size_t *size) 1598 { 1599 assert(callid); 1600 1587 1601 ipc_call_t data; 1588 1589 assert(callid);1590 1591 1602 *callid = async_get_call(&data); 1603 1592 1604 if (IPC_GET_IMETHOD(data) != IPC_M_DATA_READ) 1593 return 0; 1605 return false; 1606 1594 1607 if (size) 1595 1608 *size = (size_t) IPC_GET_ARG2(data); 1596 return 1; 1609 1610 return true; 1597 1611 } 1598 1612 1599 1613 /** Wrapper for answering the IPC_M_DATA_READ calls using the async framework. 1600 1614 * 1601 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls 1602 * so that the user doesn't have to remember the meaning of each IPC argument. 1603 * 1604 * @param callid Hash of the IPC_M_DATA_READ call to answer. 1605 * @param src Source address for the IPC_M_DATA_READ call. 1606 * @param size Size for the IPC_M_DATA_READ call. Can be smaller than 1607 * the maximum size announced by the sender. 1608 * 1609 * @return Zero on success or a value from @ref errno.h on failure. 1615 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ 1616 * calls so that the user doesn't have to remember the meaning of each IPC 1617 * argument. 1618 * 1619 * @param callid Hash of the IPC_M_DATA_READ call to answer. 1620 * @param src Source address for the IPC_M_DATA_READ call. 1621 * @param size Size for the IPC_M_DATA_READ call. Can be smaller than 1622 * the maximum size announced by the sender. 1623 * 1624 * @return Zero on success or a value from @ref errno.h on failure. 1625 * 1610 1626 */ 1611 1627 int async_data_read_finalize(ipc_callid_t callid, const void *src, size_t size) … … 1647 1663 } 1648 1664 1649 /** Wrapper for makingIPC_M_DATA_WRITE calls using the async framework.1665 /** Wrapper for IPC_M_DATA_WRITE calls using the async framework. 1650 1666 * 1651 1667 * @param phoneid Phone that will be used to contact the receiving side. … … 1664 1680 /** Wrapper for receiving the IPC_M_DATA_WRITE calls using the async framework. 1665 1681 * 1666 * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE calls 1667 * so that the user doesn't have to remember the meaning of each IPC argument. 1682 * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE 1683 * calls so that the user doesn't have to remember the meaning of each IPC 1684 * argument. 1668 1685 * 1669 1686 * So far, this wrapper is to be used from within a connection fibril. 1670 1687 * 1671 * @param callid Storage where the hash of the IPC_M_DATA_WRITE call will1672 * be stored.1673 * @param size Storage where the suggested size will be stored. May be1674 * NULL1675 * 1676 * @return Non-zero on success, zero on failure.1677 * 1678 */ 1679 int async_data_write_receive(ipc_callid_t *callid, size_t *size) 1680 { 1688 * @param callid Storage for the hash of the IPC_M_DATA_WRITE. 1689 * @param size Storage for the suggested size. May be NULL. 1690 * 1691 * @return True on success, false on failure. 1692 * 1693 */ 1694 bool async_data_write_receive(ipc_callid_t *callid, size_t *size) 1695 { 1696 assert(callid); 1697 1681 1698 ipc_call_t data; 1682 1683 assert(callid);1684 1685 1699 *callid = async_get_call(&data); 1700 1686 1701 if (IPC_GET_IMETHOD(data) != IPC_M_DATA_WRITE) 1687 return 0;1702 return false; 1688 1703 1689 1704 if (size) 1690 1705 *size = (size_t) IPC_GET_ARG2(data); 1691 1706 1692 return 1;1707 return true; 1693 1708 } 1694 1709 1695 1710 /** Wrapper for answering the IPC_M_DATA_WRITE calls using the async framework. 1696 1711 * 1697 * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls 1698 * so that the user doesn't have to remember the meaning of each IPC argument. 1712 * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE 1713 * calls so that the user doesn't have to remember the meaning of each IPC 1714 * argument. 1699 1715 * 1700 1716 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. … … 1792 1808 * 1793 1809 */ 1794 void async_data_write_void( const int retval)1810 void async_data_write_void(sysarg_t retval) 1795 1811 { 1796 1812 ipc_callid_t callid; -
uspace/lib/c/generic/async_sess.c
r6aef742 r197ef43 105 105 #include <errno.h> 106 106 #include <assert.h> 107 #include "private/async_sess.h" 107 108 108 109 /** An inactive open connection. */ … … 137 138 * 138 139 * Needs to be called prior to any other interface in this file. 139 */ 140 void _async_sess_init(void) 140 * 141 */ 142 void __async_sess_init(void) 141 143 { 142 144 fibril_mutex_initialize(&async_sess_mutex); -
uspace/lib/c/generic/fibril_synch.c
r6aef742 r197ef43 105 105 106 106 if (fibril_get_sercount() != 0) 107 core();107 abort(); 108 108 109 109 futex_down(&async_futex); … … 198 198 199 199 if (fibril_get_sercount() != 0) 200 core();200 abort(); 201 201 202 202 futex_down(&async_futex); … … 226 226 227 227 if (fibril_get_sercount() != 0) 228 core();228 abort(); 229 229 230 230 futex_down(&async_futex); -
uspace/lib/c/generic/io/io.c
r6aef742 r197ef43 46 46 #include <ipc/devmap.h> 47 47 #include <adt/list.h> 48 #include "../private/io.h" 48 49 49 50 static void _ffillbuf(FILE *stream); -
uspace/lib/c/generic/ipc.c
r6aef742 r197ef43 49 49 50 50 /** 51 * Structures of this type are used for keeping track of sent asynchronous calls52 * and queing unsent calls.51 * Structures of this type are used for keeping track 52 * of sent asynchronous calls and queing unsent calls. 53 53 */ 54 54 typedef struct { 55 55 link_t list; 56 56 57 57 ipc_async_callback_t callback; 58 58 void *private; 59 59 60 union { 60 61 ipc_callid_t callid; … … 64 65 } msg; 65 66 } u; 66 fid_t fid; /**< Fibril waiting for sending this call. */ 67 68 /** Fibril waiting for sending this call. */ 69 fid_t fid; 67 70 } async_call_t; 68 71 … … 71 74 /** List of asynchronous calls that were not accepted by kernel. 72 75 * 73 * It is protected by async_futex, because if the call cannot be sent into the 74 * kernel, the async framework is used automatically. 76 * Protected by async_futex, because if the call is not accepted 77 * by the kernel, the async framework is used automatically. 78 * 75 79 */ 76 80 LIST_INITIALIZE(queued_calls); … … 78 82 static atomic_t ipc_futex = FUTEX_INITIALIZER; 79 83 80 /** Make a fast synchronous call.81 * 82 * Only three payload arguments can be passed using this function. However, this83 * function is faster than the generic ipc_call_sync_slow() because the payload84 * is passed directly in registers.85 * 86 * @param phoneid 87 * @param method 88 * @param arg1 89 * @param arg2 90 * @param arg3 91 * @param result1 92 * @param result2 93 * @param result3 94 * @param result4 95 * @param result5 96 * 97 * @return Negative values represent errors returned by IPC.98 * Otherwise the RETVAL of the answer is returned.99 * /100 int 101 i pc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1, sysarg_t arg2,102 sysarg_t arg 3, sysarg_t *result1, sysarg_t *result2, sysarg_t *result3,103 sysarg_t *result 4, sysarg_t *result5)84 /** Fast synchronous call. 85 * 86 * Only three payload arguments can be passed using this function. However, 87 * this function is faster than the generic ipc_call_sync_slow() because 88 * the payload is passed directly in registers. 89 * 90 * @param phoneid Phone handle for the call. 91 * @param method Requested method. 92 * @param arg1 Service-defined payload argument. 93 * @param arg2 Service-defined payload argument. 94 * @param arg3 Service-defined payload argument. 95 * @param result1 If non-NULL, the return ARG1 will be stored there. 96 * @param result2 If non-NULL, the return ARG2 will be stored there. 97 * @param result3 If non-NULL, the return ARG3 will be stored there. 98 * @param result4 If non-NULL, the return ARG4 will be stored there. 99 * @param result5 If non-NULL, the return ARG5 will be stored there. 100 * 101 * @return Negative values representing IPC errors. 102 * @return Otherwise the RETVAL of the answer. 103 * 104 */ 105 int ipc_call_sync_fast(int phoneid, sysarg_t method, sysarg_t arg1, 106 sysarg_t arg2, sysarg_t arg3, sysarg_t *result1, sysarg_t *result2, 107 sysarg_t *result3, sysarg_t *result4, sysarg_t *result5) 104 108 { 105 109 ipc_call_t resdata; 106 int callres; 107 108 callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1, 110 int callres = __SYSCALL6(SYS_IPC_CALL_SYNC_FAST, phoneid, method, arg1, 109 111 arg2, arg3, (sysarg_t) &resdata); 110 112 if (callres) 111 113 return callres; 114 112 115 if (result1) 113 116 *result1 = IPC_GET_ARG1(resdata); … … 120 123 if (result5) 121 124 *result5 = IPC_GET_ARG5(resdata); 122 125 123 126 return IPC_GET_RETVAL(resdata); 124 127 } 125 128 126 /** Make a synchronous call transmitting 5 arguments of payload.129 /** Synchronous call transmitting 5 arguments of payload. 127 130 * 128 131 * @param phoneid Phone handle for the call. … … 139 142 * @param result5 If non-NULL, storage for the fifth return argument. 140 143 * 141 * @return Negative value means IPC error.142 * 143 * 144 */ 145 int 146 ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2,147 sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, sysarg_t *result1,148 sysarg_t *result 2, sysarg_t *result3, sysarg_t *result4, sysarg_t *result5)144 * @return Negative values representing IPC errors. 145 * @return Otherwise the RETVAL of the answer. 146 * 147 */ 148 int ipc_call_sync_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, 149 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, 150 sysarg_t *result1, sysarg_t *result2, sysarg_t *result3, sysarg_t *result4, 151 sysarg_t *result5) 149 152 { 150 153 ipc_call_t data; … … 176 179 } 177 180 178 /** S yscall to send asynchronous message.181 /** Send asynchronous message via syscall. 179 182 * 180 183 * @param phoneid Phone handle for the call. … … 184 187 * 185 188 */ 186 static ipc_callid_t _ipc_call_async(int phoneid, ipc_call_t *data)189 static ipc_callid_t ipc_call_async_internal(int phoneid, ipc_call_t *data) 187 190 { 188 191 return __SYSCALL2(SYS_IPC_CALL_ASYNC_SLOW, phoneid, (sysarg_t) data); 189 192 } 190 193 191 /** Prolog to ipc_call_async_*() functions. 192 * 193 * @param private Argument for the answer/error callback. 194 * @param callback Answer/error callback. 195 * 196 * @return New, partially initialized async_call structure or NULL. 194 /** Prolog for ipc_call_async_*() functions. 195 * 196 * @param private Argument for the answer/error callback. 197 * @param callback Answer/error callback. 198 * 199 * @return New, partially initialized async_call structure or NULL. 200 * 197 201 */ 198 202 static inline async_call_t *ipc_prepare_async(void *private, 199 203 ipc_async_callback_t callback) 200 204 { 201 async_call_t *call; 202 203 call = malloc(sizeof(*call)); 205 async_call_t *call = 206 (async_call_t *) malloc(sizeof(async_call_t)); 204 207 if (!call) { 205 208 if (callback) 206 209 callback(private, ENOMEM, NULL); 210 207 211 return NULL; 208 212 } 213 209 214 call->callback = callback; 210 215 call->private = private; 211 216 212 217 return call; 213 218 } 214 219 215 /** Epilogue of ipc_call_async_*() functions. 216 * 217 * @param callid Value returned by the SYS_IPC_CALL_ASYNC_* syscall. 218 * @param phoneid Phone handle through which the call was made. 219 * @param call async_call structure returned by ipc_prepare_async(). 220 * @param can_preempt If non-zero, the current fibril can be preempted in this 221 * call. 220 /** Epilog for ipc_call_async_*() functions. 221 * 222 * @param callid Value returned by the SYS_IPC_CALL_ASYNC_* syscall. 223 * @param phoneid Phone handle through which the call was made. 224 * @param call Structure returned by ipc_prepare_async(). 225 * @param can_preempt If true, the current fibril can be preempted 226 * in this call. 227 * 222 228 */ 223 229 static inline void ipc_finish_async(ipc_callid_t callid, int phoneid, 224 async_call_t *call, int can_preempt) 225 { 226 if (!call) { /* Nothing to do regardless if failed or not */ 230 async_call_t *call, bool can_preempt) 231 { 232 if (!call) { 233 /* Nothing to do regardless if failed or not */ 227 234 futex_up(&ipc_futex); 228 235 return; 229 236 } 230 237 231 238 if (callid == (ipc_callid_t) IPC_CALLRET_FATAL) { 232 239 futex_up(&ipc_futex); 240 233 241 /* Call asynchronous handler with error code */ 234 242 if (call->callback) 235 243 call->callback(call->private, ENOENT, NULL); 244 236 245 free(call); 237 246 return; 238 247 } 239 248 240 249 if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) { 241 250 futex_up(&ipc_futex); 242 251 243 252 call->u.msg.phoneid = phoneid; 244 253 245 254 futex_down(&async_futex); 246 255 list_append(&call->list, &queued_calls); 247 256 248 257 if (can_preempt) { 249 258 call->fid = fibril_get_id(); … … 254 263 futex_up(&async_futex); 255 264 } 265 256 266 return; 257 267 } 268 258 269 call->u.callid = callid; 270 259 271 /* Add call to the list of dispatched calls */ 260 272 list_append(&call->list, &dispatched_calls); 261 273 futex_up(&ipc_futex); 262 263 } 264 265 /** Make a fast asynchronous call. 274 } 275 276 /** Fast asynchronous call. 266 277 * 267 278 * This function can only handle four arguments of payload. It is, however, … … 269 280 * 270 281 * Note that this function is a void function. 271 * During normal opertation, answering this call will trigger the callback. 272 * In case of fatal error, call the callback handler with the proper error code. 273 * If the call cannot be temporarily made, queue it. 282 * 283 * During normal operation, answering this call will trigger the callback. 284 * In case of fatal error, the callback handler is called with the proper 285 * error code. If the call cannot be temporarily made, it is queued. 274 286 * 275 287 * @param phoneid Phone handle for the call. … … 281 293 * @param private Argument to be passed to the answer/error callback. 282 294 * @param callback Answer or error callback. 283 * @param can_preempt If non-zero, the current fibril will be preempted in295 * @param can_preempt If true, the current fibril will be preempted in 284 296 * case the kernel temporarily refuses to accept more 285 297 * asynchronous calls. … … 288 300 void ipc_call_async_fast(int phoneid, sysarg_t imethod, sysarg_t arg1, 289 301 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, void *private, 290 ipc_async_callback_t callback, intcan_preempt)302 ipc_async_callback_t callback, bool can_preempt) 291 303 { 292 304 async_call_t *call = NULL; … … 299 311 300 312 /* 301 * We need to make sure that we get callid before another thread302 * accesses the queue again.313 * We need to make sure that we get callid 314 * before another thread accesses the queue again. 303 315 */ 316 304 317 futex_down(&ipc_futex); 305 318 ipc_callid_t callid = __SYSCALL6(SYS_IPC_CALL_ASYNC_FAST, phoneid, … … 312 325 return; 313 326 } 327 314 328 IPC_SET_IMETHOD(call->u.msg.data, imethod); 315 329 IPC_SET_ARG1(call->u.msg.data, arg1); … … 317 331 IPC_SET_ARG3(call->u.msg.data, arg3); 318 332 IPC_SET_ARG4(call->u.msg.data, arg4); 333 319 334 /* 320 335 * To achieve deterministic behavior, we always zero out the 321 336 * arguments that are beyond the limits of the fast version. 322 337 */ 338 323 339 IPC_SET_ARG5(call->u.msg.data, 0); 324 340 } 341 325 342 ipc_finish_async(callid, phoneid, call, can_preempt); 326 343 } 327 344 328 /** Make an asynchronous call transmitting the entire payload.345 /** Asynchronous call transmitting the entire payload. 329 346 * 330 347 * Note that this function is a void function. 331 * During normal opertation, answering this call will trigger the callback. 332 * In case of fatal error, call the callback handler with the proper error code. 333 * If the call cannot be temporarily made, queue it. 348 * 349 * During normal operation, answering this call will trigger the callback. 350 * In case of fatal error, the callback handler is called with the proper 351 * error code. If the call cannot be temporarily made, it is queued. 334 352 * 335 353 * @param phoneid Phone handle for the call. … … 342 360 * @param private Argument to be passed to the answer/error callback. 343 361 * @param callback Answer or error callback. 344 * @param can_preempt If non-zero, the current fibril will be preempted in362 * @param can_preempt If true, the current fibril will be preempted in 345 363 * case the kernel temporarily refuses to accept more 346 364 * asynchronous calls. … … 349 367 void ipc_call_async_slow(int phoneid, sysarg_t imethod, sysarg_t arg1, 350 368 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, void *private, 351 ipc_async_callback_t callback, int can_preempt) 352 { 353 async_call_t *call; 354 ipc_callid_t callid; 355 356 call = ipc_prepare_async(private, callback); 369 ipc_async_callback_t callback, bool can_preempt) 370 { 371 async_call_t *call = ipc_prepare_async(private, callback); 357 372 if (!call) 358 373 return; 359 374 360 375 IPC_SET_IMETHOD(call->u.msg.data, imethod); 361 376 IPC_SET_ARG1(call->u.msg.data, arg1); … … 364 379 IPC_SET_ARG4(call->u.msg.data, arg4); 365 380 IPC_SET_ARG5(call->u.msg.data, arg5); 381 366 382 /* 367 * We need to make sure that we get callid before another thread368 * accesses the queue again.383 * We need to make sure that we get callid 384 * before another threadaccesses the queue again. 369 385 */ 386 370 387 futex_down(&ipc_futex); 371 callid = _ipc_call_async(phoneid, &call->u.msg.data); 372 388 ipc_callid_t callid = 389 ipc_call_async_internal(phoneid, &call->u.msg.data); 390 373 391 ipc_finish_async(callid, phoneid, call, can_preempt); 374 392 } 375 393 376 377 /** Answer a received call - fast version. 394 /** Answer received call (fast version). 378 395 * 379 396 * The fast answer makes use of passing retval and first four arguments in 380 397 * registers. If you need to return more, use the ipc_answer_slow() instead. 381 398 * 382 * @param callid Hash of the call being answered. 383 * @param retval Return value. 384 * @param arg1 First return argument. 385 * @param arg2 Second return argument. 386 * @param arg3 Third return argument. 387 * @param arg4 Fourth return argument. 388 * 389 * @return Zero on success or a value from @ref errno.h on failure. 399 * @param callid Hash of the call being answered. 400 * @param retval Return value. 401 * @param arg1 First return argument. 402 * @param arg2 Second return argument. 403 * @param arg3 Third return argument. 404 * @param arg4 Fourth return argument. 405 * 406 * @return Zero on success. 407 * @return Value from @ref errno.h on failure. 408 * 390 409 */ 391 410 sysarg_t ipc_answer_fast(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, … … 396 415 } 397 416 398 /** Answer a received call - slow full version. 399 * 400 * @param callid Hash of the call being answered. 401 * @param retval Return value. 402 * @param arg1 First return argument. 403 * @param arg2 Second return argument. 404 * @param arg3 Third return argument. 405 * @param arg4 Fourth return argument. 406 * @param arg5 Fifth return argument. 407 * 408 * @return Zero on success or a value from @ref errno.h on failure. 417 /** Answer received call (entire payload). 418 * 419 * @param callid Hash of the call being answered. 420 * @param retval Return value. 421 * @param arg1 First return argument. 422 * @param arg2 Second return argument. 423 * @param arg3 Third return argument. 424 * @param arg4 Fourth return argument. 425 * @param arg5 Fifth return argument. 426 * 427 * @return Zero on success. 428 * @return Value from @ref errno.h on failure. 429 * 409 430 */ 410 431 sysarg_t ipc_answer_slow(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, … … 412 433 { 413 434 ipc_call_t data; 414 435 415 436 IPC_SET_RETVAL(data, retval); 416 437 IPC_SET_ARG1(data, arg1); … … 419 440 IPC_SET_ARG4(data, arg4); 420 441 IPC_SET_ARG5(data, arg5); 421 442 422 443 return __SYSCALL2(SYS_IPC_ANSWER_SLOW, callid, (sysarg_t) &data); 423 444 } 424 445 425 426 /** Try to dispatch queued calls from the async queue. */ 427 static void try_dispatch_queued_calls(void) 428 { 429 async_call_t *call; 430 ipc_callid_t callid; 431 446 /** Try to dispatch queued calls from the async queue. 447 * 448 */ 449 static void dispatch_queued_calls(void) 450 { 432 451 /** @todo 433 * Integrate intelligently ipc_futex ,so that it is locked during434 * ipc_call_async_*() ,until it is added to dispatched_calls.452 * Integrate intelligently ipc_futex so that it is locked during 453 * ipc_call_async_*() until it is added to dispatched_calls. 435 454 */ 455 436 456 futex_down(&async_futex); 457 437 458 while (!list_empty(&queued_calls)) { 438 call = list_get_instance(queued_calls.next, async_call_t, list); 439 callid = _ipc_call_async(call->u.msg.phoneid, 440 &call->u.msg.data); 441 if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) { 459 async_call_t *call = 460 list_get_instance(queued_calls.next, async_call_t, list); 461 ipc_callid_t callid = 462 ipc_call_async_internal(call->u.msg.phoneid, &call->u.msg.data); 463 464 if (callid == (ipc_callid_t) IPC_CALLRET_TEMPORARY) 442 465 break; 443 }466 444 467 list_remove(&call->list); 445 468 446 469 futex_up(&async_futex); 470 447 471 if (call->fid) 448 472 fibril_add_ready(call->fid); … … 451 475 if (call->callback) 452 476 call->callback(call->private, ENOENT, NULL); 477 453 478 free(call); 454 479 } else { 455 480 call->u.callid = callid; 481 456 482 futex_down(&ipc_futex); 457 483 list_append(&call->list, &dispatched_calls); 458 484 futex_up(&ipc_futex); 459 485 } 486 460 487 futex_down(&async_futex); 461 488 } 489 462 490 futex_up(&async_futex); 463 491 } 464 492 465 /** Handle areceived answer.493 /** Handle received answer. 466 494 * 467 495 * Find the hash of the answer and call the answer callback. 468 496 * 469 * @todo Make it use hash table. 470 * 471 * @param callid Hash of the received answer. 472 * The answer has the same hash as the request OR'ed with 473 * the IPC_CALLID_ANSWERED bit. 474 * @param data Call data of the answer. 497 * The answer has the same hash as the request OR'ed with 498 * the IPC_CALLID_ANSWERED bit. 499 * 500 * @todo Use hash table. 501 * 502 * @param callid Hash of the received answer. 503 * @param data Call data of the answer. 504 * 475 505 */ 476 506 static void handle_answer(ipc_callid_t callid, ipc_call_t *data) 477 507 { 508 callid &= ~IPC_CALLID_ANSWERED; 509 510 futex_down(&ipc_futex); 511 478 512 link_t *item; 479 async_call_t *call;480 481 callid &= ~IPC_CALLID_ANSWERED;482 483 futex_down(&ipc_futex);484 513 for (item = dispatched_calls.next; item != &dispatched_calls; 485 514 item = item->next) { 486 call = list_get_instance(item, async_call_t, list); 515 async_call_t *call = 516 list_get_instance(item, async_call_t, list); 517 487 518 if (call->u.callid == callid) { 488 519 list_remove(&call->list); 520 489 521 futex_up(&ipc_futex); 522 490 523 if (call->callback) 491 call->callback(call->private, 524 call->callback(call->private, 492 525 IPC_GET_RETVAL(*data), data); 526 493 527 free(call); 494 528 return; 495 529 } 496 530 } 531 497 532 futex_up(&ipc_futex); 498 533 } 499 534 500 501 /** Wait for a first call to come. 502 * 503 * @param call Storage where the incoming call data will be stored.504 * @param usec Timeout in microseconds505 * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking).506 * 507 * @return Hash of the call. Note that certain bits have special508 * meaning. IPC_CALLID_ANSWERED will be set in an answer509 * and IPC_CALLID_NOTIFICATION is used for notifications.510 * 511 */ 512 ipc_callid_t ipc_wait_cycle(ipc_call_t *call, uint32_t usec,int flags)513 { 514 ipc_callid_t callid ;515 516 callid = __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags);535 /** Wait for first IPC call to come. 536 * 537 * @param call Incoming call storage. 538 * @param usec Timeout in microseconds 539 * @param flags Flags passed to SYS_IPC_WAIT (blocking, nonblocking). 540 * 541 * @return Hash of the call. Note that certain bits have special 542 * meaning: IPC_CALLID_ANSWERED is set in an answer 543 * and IPC_CALLID_NOTIFICATION is used for notifications. 544 * 545 */ 546 ipc_callid_t ipc_wait_cycle(ipc_call_t *call, sysarg_t usec, 547 unsigned int flags) 548 { 549 ipc_callid_t callid = 550 __SYSCALL3(SYS_IPC_WAIT, (sysarg_t) call, usec, flags); 551 517 552 /* Handle received answers */ 518 553 if (callid & IPC_CALLID_ANSWERED) { 519 554 handle_answer(callid, call); 520 try_dispatch_queued_calls();555 dispatch_queued_calls(); 521 556 } 522 557 523 558 return callid; 524 559 } 525 560 526 /** Wait some time for an IPC call. 527 * 528 * The call will return after an answer is received. 529 * 530 * @param call Storage where the incoming call data will be stored. 531 * @param usec Timeout in microseconds. 532 * 533 * @return Hash of the answer. 534 */ 535 ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, uint32_t usec) 561 /** Interrupt one thread of this task from waiting for IPC. 562 * 563 */ 564 void ipc_poke(void) 565 { 566 __SYSCALL0(SYS_IPC_POKE); 567 } 568 569 /** Wait for first IPC call to come. 570 * 571 * Only requests are returned, answers are processed internally. 572 * 573 * @param call Incoming call storage. 574 * @param usec Timeout in microseconds 575 * 576 * @return Hash of the call. 577 * 578 */ 579 ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *call, sysarg_t usec) 536 580 { 537 581 ipc_callid_t callid; 538 582 539 583 do { 540 584 callid = ipc_wait_cycle(call, usec, SYNCH_FLAGS_NONE); 541 585 } while (callid & IPC_CALLID_ANSWERED); 542 586 543 587 return callid; 544 588 } … … 546 590 /** Check if there is an IPC call waiting to be picked up. 547 591 * 548 * @param call Storage where the incoming call will be stored. 549 * @return Hash of the answer. 592 * Only requests are returned, answers are processed internally. 593 * 594 * @param call Incoming call storage. 595 * 596 * @return Hash of the call. 597 * 550 598 */ 551 599 ipc_callid_t ipc_trywait_for_call(ipc_call_t *call) 552 600 { 553 601 ipc_callid_t callid; 554 602 555 603 do { 556 604 callid = ipc_wait_cycle(call, SYNCH_NO_TIMEOUT, 557 605 SYNCH_FLAGS_NON_BLOCKING); 558 606 } while (callid & IPC_CALLID_ANSWERED); 559 607 560 608 return callid; 561 609 } 562 610 563 /** Interrupt one thread of this task from waiting for IPC. */ 564 void ipc_poke(void) 565 { 566 __SYSCALL0(SYS_IPC_POKE); 567 } 568 569 /** Ask destination to do a callback connection. 570 * 571 * @param phoneid Phone handle used for contacting the other side. 572 * @param arg1 Service-defined argument. 573 * @param arg2 Service-defined argument. 574 * @param arg3 Service-defined argument. 575 * @param taskhash Storage where the kernel will store an opaque 576 * identifier of the client task. 577 * @param phonehash Storage where the kernel will store an opaque 578 * identifier of the phone that will be used for incoming 579 * calls. This identifier can be used for connection 580 * tracking. 581 * 582 * @return Zero on success or a negative error code. 583 */ 584 int ipc_connect_to_me(int phoneid, int arg1, int arg2, int arg3, 611 /** Request callback connection. 612 * 613 * The @a taskhash and @a phonehash identifiers returned 614 * by the kernel can be used for connection tracking. 615 * 616 * @param phoneid Phone handle used for contacting the other side. 617 * @param arg1 User defined argument. 618 * @param arg2 User defined argument. 619 * @param arg3 User defined argument. 620 * @param taskhash Opaque identifier of the client task. 621 * @param phonehash Opaque identifier of the phone that will 622 * be used for incoming calls. 623 * 624 * @return Zero on success or a negative error code. 625 * 626 */ 627 int ipc_connect_to_me(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 585 628 sysarg_t *taskhash, sysarg_t *phonehash) 586 629 { … … 589 632 } 590 633 591 /** Ask through phone for a new connection to some service. 592 * 593 * @param phoneid Phone handle used for contacting the other side. 594 * @param arg1 User defined argument. 595 * @param arg2 User defined argument. 596 * @param arg3 User defined argument. 597 * 598 * @return New phone handle on success or a negative error code. 599 */ 600 int ipc_connect_me_to(int phoneid, int arg1, int arg2, int arg3) 634 /** Request new connection. 635 * 636 * @param phoneid Phone handle used for contacting the other side. 637 * @param arg1 User defined argument. 638 * @param arg2 User defined argument. 639 * @param arg3 User defined argument. 640 * 641 * @return New phone handle on success or a negative error code. 642 * 643 */ 644 int ipc_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3) 601 645 { 602 646 sysarg_t newphid; 603 int res; 604 605 res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 647 int res = ipc_call_sync_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 606 648 NULL, NULL, NULL, NULL, &newphid); 607 649 if (res) 608 650 return res; 651 609 652 return newphid; 610 653 } 611 654 612 /** Ask through phone for a new connection to some service.655 /** Request new connection (blocking) 613 656 * 614 657 * If the connection is not available at the moment, the 615 * call will block. 616 * 617 * @param phoneid Phone handle used for contacting the other side. 618 * @param arg1 User defined argument. 619 * @param arg2 User defined argument. 620 * @param arg3 User defined argument. 621 * 622 * @return New phone handle on success or a negative error code. 623 */ 624 int ipc_connect_me_to_blocking(int phoneid, int arg1, int arg2, int arg3) 658 * call should block. This has to be, however, implemented 659 * on the server side. 660 * 661 * @param phoneid Phone handle used for contacting the other side. 662 * @param arg1 User defined argument. 663 * @param arg2 User defined argument. 664 * @param arg3 User defined argument. 665 * 666 * @return New phone handle on success or a negative error code. 667 * 668 */ 669 int ipc_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2, 670 sysarg_t arg3) 625 671 { 626 672 sysarg_t newphid; 627 int res; 628 629 res = ipc_call_sync_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 673 int res = ipc_call_sync_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 630 674 IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid); 631 675 if (res) 632 676 return res; 677 633 678 return newphid; 634 679 } … … 636 681 /** Hang up a phone. 637 682 * 638 * @param phoneid Handle of the phone to be hung up. 639 * 640 * @return Zero on success or a negative error code. 683 * @param phoneid Handle of the phone to be hung up. 684 * 685 * @return Zero on success or a negative error code. 686 * 641 687 */ 642 688 int ipc_hangup(int phoneid) … … 646 692 647 693 /** Forward a received call to another destination. 694 * 695 * For non-system methods, the old method, arg1 and arg2 are rewritten 696 * by the new values. For system methods, the new method, arg1 and arg2 697 * are written to the old arg1, arg2 and arg3, respectivelly. Calls with 698 * immutable methods are forwarded verbatim. 648 699 * 649 700 * @param callid Hash of the call to forward. … … 656 707 * @return Zero on success or an error code. 657 708 * 658 * For non-system methods, the old method, arg1 and arg2 are rewritten by the 659 * new values. For system methods, the new method, arg1 and arg2 are written 660 * to the old arg1, arg2 and arg3, respectivelly. Calls with immutable 661 * methods are forwarded verbatim. 662 */ 663 int ipc_forward_fast(ipc_callid_t callid, int phoneid, int imethod, 664 sysarg_t arg1, sysarg_t arg2, int mode) 709 */ 710 int ipc_forward_fast(ipc_callid_t callid, int phoneid, sysarg_t imethod, 711 sysarg_t arg1, sysarg_t arg2, unsigned int mode) 665 712 { 666 713 return __SYSCALL6(SYS_IPC_FORWARD_FAST, callid, phoneid, imethod, arg1, … … 668 715 } 669 716 670 671 int ipc_forward_slow(ipc_callid_t callid, int phoneid, int imethod, 717 int ipc_forward_slow(ipc_callid_t callid, int phoneid, sysarg_t imethod, 672 718 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, 673 int mode)719 unsigned int mode) 674 720 { 675 721 ipc_call_t data; … … 682 728 IPC_SET_ARG5(data, arg5); 683 729 684 return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, mode); 685 } 686 687 /** Wrapper for making IPC_M_SHARE_IN calls. 688 * 689 * @param phoneid Phone that will be used to contact the receiving side. 690 * @param dst Destination address space area base. 691 * @param size Size of the destination address space area. 692 * @param arg User defined argument. 693 * @param flags Storage where the received flags will be stored. Can be 694 * NULL. 695 * 696 * @return Zero on success or a negative error code from errno.h. 730 return __SYSCALL4(SYS_IPC_FORWARD_SLOW, callid, phoneid, (sysarg_t) &data, 731 mode); 732 } 733 734 /** Wrapper for IPC_M_SHARE_IN calls. 735 * 736 * @param phoneid Phone that will be used to contact the receiving side. 737 * @param dst Destination address space area base. 738 * @param size Size of the destination address space area. 739 * @param arg User defined argument. 740 * @param flags Storage for received flags. Can be NULL. 741 * 742 * @return Zero on success or a negative error code from errno.h. 743 * 697 744 */ 698 745 int ipc_share_in_start(int phoneid, void *dst, size_t size, sysarg_t arg, 699 int *flags)746 unsigned int *flags) 700 747 { 701 748 sysarg_t tmp_flags = 0; … … 704 751 705 752 if (flags) 706 *flags = tmp_flags;753 *flags = (unsigned int) tmp_flags; 707 754 708 755 return res; … … 711 758 /** Wrapper for answering the IPC_M_SHARE_IN calls. 712 759 * 713 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls 714 * so that the user doesn't have to remember the meaning of each IPC argument. 715 * 716 * @param callid Hash of the IPC_M_DATA_READ call to answer. 717 * @param src Source address space base. 718 * @param flags Flags to be used for sharing. Bits can be only cleared. 719 * 720 * @return Zero on success or a value from @ref errno.h on failure. 721 */ 722 int ipc_share_in_finalize(ipc_callid_t callid, void *src, int flags) 760 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ 761 * calls so that the user doesn't have to remember the meaning of each 762 * IPC argument. 763 * 764 * @param callid Hash of the IPC_M_DATA_READ call to answer. 765 * @param src Source address space base. 766 * @param flags Flags to be used for sharing. Bits can be only cleared. 767 * 768 * @return Zero on success or a value from @ref errno.h on failure. 769 * 770 */ 771 int ipc_share_in_finalize(ipc_callid_t callid, void *src, unsigned int flags) 723 772 { 724 773 return ipc_answer_2(callid, EOK, (sysarg_t) src, (sysarg_t) flags); 725 774 } 726 775 727 /** Wrapper for making IPC_M_SHARE_OUT calls. 728 * 729 * @param phoneid Phone that will be used to contact the receiving side. 730 * @param src Source address space area base address. 731 * @param flags Flags to be used for sharing. Bits can be only cleared. 732 * 733 * @return Zero on success or a negative error code from errno.h. 734 */ 735 int ipc_share_out_start(int phoneid, void *src, int flags) 776 /** Wrapper for IPC_M_SHARE_OUT calls. 777 * 778 * @param phoneid Phone that will be used to contact the receiving side. 779 * @param src Source address space area base address. 780 * @param flags Flags to be used for sharing. Bits can be only cleared. 781 * 782 * @return Zero on success or a negative error code from errno.h. 783 * 784 */ 785 int ipc_share_out_start(int phoneid, void *src, unsigned int flags) 736 786 { 737 787 return ipc_call_sync_3_0(phoneid, IPC_M_SHARE_OUT, (sysarg_t) src, 0, … … 741 791 /** Wrapper for answering the IPC_M_SHARE_OUT calls. 742 792 * 743 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT calls 744 * so that the user doesn't have to remember the meaning of each IPC argument. 745 * 746 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 747 * @param dst Destination address space area base address. 748 * 749 * @return Zero on success or a value from @ref errno.h on failure. 793 * This wrapper only makes it more comfortable to answer IPC_M_SHARE_OUT 794 * calls so that the user doesn't have to remember the meaning of each 795 * IPC argument. 796 * 797 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 798 * @param dst Destination address space area base address. 799 * 800 * @return Zero on success or a value from @ref errno.h on failure. 801 * 750 802 */ 751 803 int ipc_share_out_finalize(ipc_callid_t callid, void *dst) … … 754 806 } 755 807 756 757 /** Wrapper for making IPC_M_DATA_READ calls. 758 * 759 * @param phoneid Phone that will be used to contact the receiving side.760 * @param dst Address of the beginningof the destination buffer.761 * @param size Size of the destination buffer.762 * 763 * @return Zero on success or a negative error code from errno.h.808 /** Wrapper for IPC_M_DATA_READ calls. 809 * 810 * @param phoneid Phone that will be used to contact the receiving side. 811 * @param dst Address of the beginning of the destination buffer. 812 * @param size Size of the destination buffer. 813 * 814 * @return Zero on success or a negative error code from errno.h. 815 * 764 816 */ 765 817 int ipc_data_read_start(int phoneid, void *dst, size_t size) … … 771 823 /** Wrapper for answering the IPC_M_DATA_READ calls. 772 824 * 773 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ calls 774 * so that the user doesn't have to remember the meaning of each IPC argument. 775 * 776 * @param callid Hash of the IPC_M_DATA_READ call to answer. 777 * @param src Source address for the IPC_M_DATA_READ call. 778 * @param size Size for the IPC_M_DATA_READ call. Can be smaller than 779 * the maximum size announced by the sender. 780 * 781 * @return Zero on success or a value from @ref errno.h on failure. 825 * This wrapper only makes it more comfortable to answer IPC_M_DATA_READ 826 * calls so that the user doesn't have to remember the meaning of each 827 * IPC argument. 828 * 829 * @param callid Hash of the IPC_M_DATA_READ call to answer. 830 * @param src Source address for the IPC_M_DATA_READ call. 831 * @param size Size for the IPC_M_DATA_READ call. Can be smaller than 832 * the maximum size announced by the sender. 833 * 834 * @return Zero on success or a value from @ref errno.h on failure. 835 * 782 836 */ 783 837 int ipc_data_read_finalize(ipc_callid_t callid, const void *src, size_t size) … … 786 840 } 787 841 788 /** Wrapper for making IPC_M_DATA_WRITE calls. 789 * 790 * @param phoneid Phone that will be used to contact the receiving side. 791 * @param src Address of the beginning of the source buffer. 792 * @param size Size of the source buffer. 793 * 794 * @return Zero on success or a negative error code from errno.h. 842 /** Wrapper for IPC_M_DATA_WRITE calls. 843 * 844 * @param phoneid Phone that will be used to contact the receiving side. 845 * @param src Address of the beginning of the source buffer. 846 * @param size Size of the source buffer. 847 * 848 * @return Zero on success or a negative error code from errno.h. 849 * 795 850 */ 796 851 int ipc_data_write_start(int phoneid, const void *src, size_t size) … … 802 857 /** Wrapper for answering the IPC_M_DATA_WRITE calls. 803 858 * 804 * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE calls 805 * so that the user doesn't have to remember the meaning of each IPC argument. 806 * 807 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 808 * @param dst Final destination address for the IPC_M_DATA_WRITE call. 809 * @param size Final size for the IPC_M_DATA_WRITE call. 810 * 811 * @return Zero on success or a value from @ref errno.h on failure. 859 * This wrapper only makes it more comfortable to answer IPC_M_DATA_WRITE 860 * calls so that the user doesn't have to remember the meaning of each 861 * IPC argument. 862 * 863 * @param callid Hash of the IPC_M_DATA_WRITE call to answer. 864 * @param dst Final destination address for the IPC_M_DATA_WRITE call. 865 * @param size Final size for the IPC_M_DATA_WRITE call. 866 * 867 * @return Zero on success or a value from @ref errno.h on failure. 868 * 812 869 */ 813 870 int ipc_data_write_finalize(ipc_callid_t callid, void *dst, size_t size) -
uspace/lib/c/generic/libc.c
r6aef742 r197ef43 41 41 */ 42 42 43 #include <stdio.h> 44 #include <unistd.h> 45 #include <malloc.h> 43 #include <libc.h> 44 #include <stdlib.h> 46 45 #include <tls.h> 47 #include <thread.h>48 46 #include <fibril.h> 49 #include <async.h> 50 #include <as.h> 47 #include <task.h> 51 48 #include <loader/pcb.h> 52 49 #include "private/libc.h" 50 #include "private/async.h" 51 #include "private/async_sess.h" 52 #include "private/malloc.h" 53 #include "private/io.h" 53 54 54 void _exit(int status) 55 { 56 thread_exit(status); 57 } 55 static bool env_setup = false; 58 56 59 57 void __main(void *pcb_ptr) 60 58 { 61 59 /* Initialize user task run-time environment */ 62 __ heap_init();60 __malloc_init(); 63 61 __async_init(); 62 __async_sess_init(); 63 64 64 fibril_t *fibril = fibril_setup(); 65 if (fibril == NULL) 66 abort(); 67 65 68 __tcb_set(fibril->tcb); 66 69 … … 68 71 __pcb = (pcb_t *) pcb_ptr; 69 72 73 /* The basic run-time environment is setup */ 74 env_setup = true; 75 70 76 int argc; 71 77 char **argv; 72 78 73 /* Get command line arguments and initialize 74 standard input and output */ 79 /* 80 * Get command line arguments and initialize 81 * standard input and output 82 */ 75 83 if (__pcb == NULL) { 76 84 argc = 0; … … 84 92 } 85 93 86 /* Run main() and set task return value 87 according the result */ 88 (void) task_retval(main(argc, argv)); 94 /* 95 * Run main() and set task return value 96 * according the result 97 */ 98 int retval = main(argc, argv); 99 exit(retval); 89 100 } 90 101 91 void __exit(void)102 void exit(int status) 92 103 { 93 __stdio_done(); 94 fibril_teardown(__tcb_get()->fibril_data); 95 _exit(0); 104 if (env_setup) { 105 __stdio_done(); 106 task_retval(status); 107 fibril_teardown(__tcb_get()->fibril_data); 108 } 109 110 __SYSCALL1(SYS_TASK_EXIT, false); 111 112 /* Unreachable */ 113 while (1); 114 } 115 116 void abort(void) 117 { 118 __SYSCALL1(SYS_TASK_EXIT, true); 119 120 /* Unreachable */ 121 while (1); 96 122 } 97 123 -
uspace/lib/c/generic/malloc.c
r6aef742 r197ef43 45 45 #include <futex.h> 46 46 #include <adt/gcdlcm.h> 47 #include "private/malloc.h" 47 48 48 49 /* Magic used in heap headers. */ … … 215 216 /** Initialize the heap allocator 216 217 * 217 * Find how much physical memory we have and create 218 * the heap management structures that mark the whole 219 * physical memory as a single free block. 220 * 221 */ 222 void __heap_init(void) 223 { 224 futex_down(&malloc_futex); 225 226 if (as_area_create((void *) &_heap, PAGE_SIZE, 227 AS_AREA_WRITE | AS_AREA_READ)) { 228 heap_pages = 1; 229 heap_start = (void *) ALIGN_UP((uintptr_t) &_heap, BASE_ALIGN); 230 heap_end = 231 (void *) ALIGN_DOWN(((uintptr_t) &_heap) + PAGE_SIZE, BASE_ALIGN); 232 233 /* Make the entire area one large block. */ 234 block_init(heap_start, heap_end - heap_start, true); 235 } 236 237 futex_up(&malloc_futex); 218 * Create initial heap memory area. This routine is 219 * only called from libc initialization, thus we do not 220 * take any locks. 221 * 222 */ 223 void __malloc_init(void) 224 { 225 if (!as_area_create((void *) &_heap, PAGE_SIZE, 226 AS_AREA_WRITE | AS_AREA_READ)) 227 abort(); 228 229 heap_pages = 1; 230 heap_start = (void *) ALIGN_UP((uintptr_t) &_heap, BASE_ALIGN); 231 heap_end = 232 (void *) ALIGN_DOWN(((uintptr_t) &_heap) + PAGE_SIZE, BASE_ALIGN); 233 234 /* Make the entire area one large block. */ 235 block_init(heap_start, heap_end - heap_start, true); 238 236 } 239 237 -
uspace/lib/c/generic/private/async.h
r6aef742 r197ef43 79 79 } awaiter_t; 80 80 81 extern void __async_init(void); 81 82 extern void async_insert_timeout(awaiter_t *); 82 83 -
uspace/lib/c/generic/private/libc.h
r6aef742 r197ef43 37 37 38 38 extern int main(int, char *[]); 39 extern void __main(void *); 40 extern void __exit(void); 39 extern void __main(void *) __attribute__((noreturn)); 41 40 42 41 #endif -
uspace/lib/c/generic/thread.c
r6aef742 r197ef43 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #include <thread.h> … … 41 41 #include <str.h> 42 42 #include <async.h> 43 #include "private/thread.h" 43 44 44 45 #ifndef THREAD_INITIAL_STACK_PAGES_NO … … 50 51 * This function is called from __thread_entry() and is used 51 52 * to call the thread's implementing function and perform cleanup 52 * and exit when thread returns back. Do not call this function 53 * directly. 53 * and exit when thread returns back. 54 54 * 55 55 * @param uarg Pointer to userspace argument structure. 56 * 56 57 */ 57 58 void __thread_main(uspace_arg_t *uarg) 58 59 { 59 fibril_t *f; 60 61 f = fibril_setup(); 62 __tcb_set(f->tcb); 63 60 fibril_t *fibril = fibril_setup(); 61 if (fibril == NULL) 62 thread_exit(0); 63 64 __tcb_set(fibril->tcb); 65 64 66 uarg->uspace_thread_function(uarg->uspace_thread_arg); 65 /* XXX: we cannot free the userspace stack while running on it */ 66 // free(uarg->uspace_stack); 67 // free(uarg); 68 67 /* XXX: we cannot free the userspace stack while running on it 68 free(uarg->uspace_stack); 69 free(uarg); 70 */ 71 69 72 /* If there is a manager, destroy it */ 70 73 async_destroy_manager(); 71 fibril_teardown(f );72 74 fibril_teardown(fibril); 75 73 76 thread_exit(0); 74 77 } … … 127 130 * 128 131 * @param status Exit status. Currently not used. 132 * 129 133 */ 130 134 void thread_exit(int status) 131 135 { 132 136 __SYSCALL1(SYS_THREAD_EXIT, (sysarg_t) status); 133 for (;;) 134 ; 137 138 /* Unreachable */ 139 while (1); 135 140 } 136 141 -
uspace/lib/c/include/async.h
r6aef742 r197ef43 57 57 extern atomic_t threads_in_ipc_wait; 58 58 59 extern int __async_init(void); 59 #define async_manager() \ 60 fibril_switch(FIBRIL_TO_MANAGER) 61 62 #define async_get_call(data) \ 63 async_get_call_timeout(data, 0) 64 60 65 extern ipc_callid_t async_get_call_timeout(ipc_call_t *, suseconds_t); 61 62 static inline ipc_callid_t async_get_call(ipc_call_t *data)63 {64 return async_get_call_timeout(data, 0);65 }66 67 static inline void async_manager(void)68 {69 fibril_switch(FIBRIL_TO_MANAGER);70 }71 66 72 67 /* … … 143 138 */ 144 139 145 extern int async_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int); 146 extern int async_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t, 147 sysarg_t, sysarg_t, sysarg_t, int); 140 extern int async_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t, 141 unsigned int); 142 extern int async_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t, 143 sysarg_t, sysarg_t, sysarg_t, unsigned int); 148 144 149 145 /* … … 306 302 async_share_in_start((phoneid), (dst), (size), (arg), (flags)) 307 303 308 extern int async_share_in_start(int, void *, size_t, sysarg_t, int *); 309 extern int async_share_in_receive(ipc_callid_t *, size_t *); 310 extern int async_share_in_finalize(ipc_callid_t, void *, int ); 311 extern int async_share_out_start(int, void *, int); 312 extern int async_share_out_receive(ipc_callid_t *, size_t *, int *); 304 extern int async_share_in_start(int, void *, size_t, sysarg_t, unsigned int *); 305 extern bool async_share_in_receive(ipc_callid_t *, size_t *); 306 extern int async_share_in_finalize(ipc_callid_t, void *, unsigned int); 307 308 extern int async_share_out_start(int, void *, unsigned int); 309 extern bool async_share_out_receive(ipc_callid_t *, size_t *, unsigned int *); 313 310 extern int async_share_out_finalize(ipc_callid_t, void *); 314 311 … … 344 341 345 342 extern int async_data_read_start(int, void *, size_t); 346 extern intasync_data_read_receive(ipc_callid_t *, size_t *);343 extern bool async_data_read_receive(ipc_callid_t *, size_t *); 347 344 extern int async_data_read_finalize(ipc_callid_t, const void *, size_t); 348 345 … … 383 380 384 381 extern int async_data_write_start(int, const void *, size_t); 385 extern intasync_data_write_receive(ipc_callid_t *, size_t *);382 extern bool async_data_write_receive(ipc_callid_t *, size_t *); 386 383 extern int async_data_write_finalize(ipc_callid_t, void *, size_t); 387 384 388 385 extern int async_data_write_accept(void **, const bool, const size_t, 389 386 const size_t, const size_t, size_t *); 390 extern void async_data_write_void( const int);387 extern void async_data_write_void(sysarg_t); 391 388 392 389 extern int async_data_write_forward_fast(int, sysarg_t, sysarg_t, sysarg_t, -
uspace/lib/c/include/async_sess.h
r6aef742 r197ef43 45 45 } async_sess_t; 46 46 47 extern void _async_sess_init(void);48 47 extern void async_session_create(async_sess_t *, int, sysarg_t); 49 48 extern void async_session_destroy(async_sess_t *); -
uspace/lib/c/include/byteorder.h
r6aef742 r197ef43 80 80 #endif 81 81 82 #define htons(n) 83 #define htonl(n) 84 #define ntohs(n) 85 #define ntohl(n) 82 #define htons(n) host2uint16_t_be((n)) 83 #define htonl(n) host2uint32_t_be((n)) 84 #define ntohs(n) uint16_t_be2host((n)) 85 #define ntohl(n) uint32_t_be2host((n)) 86 86 87 87 static inline uint64_t uint64_t_byteorder_swap(uint64_t n) -
uspace/lib/c/include/err.h
r6aef742 r197ef43 39 39 40 40 #define errx(status, fmt, ...) \ 41 { \41 do { \ 42 42 printf((fmt), ##__VA_ARGS__); \ 43 _exit(status); \44 } 43 exit(status); \ 44 } while (0) 45 45 46 46 #endif -
uspace/lib/c/include/errno.h
r6aef742 r197ef43 39 39 #include <fibril.h> 40 40 41 #define errno _errno 42 41 43 extern int _errno; 42 43 #define errno _errno44 44 45 45 #define EMFILE (-18) … … 57 57 58 58 /** An API function is called while another blocking function is in progress. */ 59 #define EINPROGRESS 59 #define EINPROGRESS (-10036) 60 60 61 61 /** The socket identifier is not valid. */ 62 #define ENOTSOCK 62 #define ENOTSOCK (-10038) 63 63 64 64 /** The destination address required. */ 65 #define EDESTADDRREQ 65 #define EDESTADDRREQ (-10039) 66 66 67 67 /** Protocol is not supported. */ 68 #define EPROTONOSUPPORT 68 #define EPROTONOSUPPORT (-10043) 69 69 70 70 /** Socket type is not supported. */ 71 #define ESOCKTNOSUPPORT 71 #define ESOCKTNOSUPPORT (-10044) 72 72 73 73 /** Protocol family is not supported. */ 74 #define EPFNOSUPPORT 74 #define EPFNOSUPPORT (-10046) 75 75 76 76 /** Address family is not supported. */ 77 #define EAFNOSUPPORT 77 #define EAFNOSUPPORT (-10047) 78 78 79 79 /** Address is already in use. */ 80 #define EADDRINUSE 80 #define EADDRINUSE (-10048) 81 81 82 82 /** The socket is not connected or bound. */ 83 #define ENOTCONN 83 #define ENOTCONN (-10057) 84 84 85 85 /** The requested operation was not performed. Try again later. */ 86 #define EAGAIN 86 #define EAGAIN (-11002) 87 87 88 /** No data. 89 */ 90 #define NO_DATA (-11004) 88 /** No data. */ 89 #define NO_DATA (-11004) 91 90 92 91 #endif -
uspace/lib/c/include/ipc/ipc.h
r6aef742 r197ef43 53 53 * possible, the fast version is used. 54 54 */ 55 55 56 #define ipc_call_sync_0_0(phoneid, method) \ 56 57 ipc_call_sync_fast((phoneid), (method), 0, 0, 0, 0, 0, 0, 0, 0) … … 182 183 sysarg_t *); 183 184 184 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, uint32_t, int); 185 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, uint32_t); 185 extern ipc_callid_t ipc_wait_cycle(ipc_call_t *, sysarg_t, unsigned int); 186 186 extern void ipc_poke(void); 187 187 188 static inline ipc_callid_t ipc_wait_for_call(ipc_call_t *data) 189 { 190 return ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT); 191 } 192 188 #define ipc_wait_for_call(data) \ 189 ipc_wait_for_call_timeout(data, SYNCH_NO_TIMEOUT); 190 191 extern ipc_callid_t ipc_wait_for_call_timeout(ipc_call_t *, sysarg_t); 193 192 extern ipc_callid_t ipc_trywait_for_call(ipc_call_t *); 194 193 … … 199 198 * to m. 200 199 */ 200 201 201 #define ipc_answer_0(callid, retval) \ 202 202 ipc_answer_fast((callid), (retval), 0, 0, 0, 0) … … 223 223 * to m. 224 224 */ 225 225 226 #define ipc_call_async_0(phoneid, method, private, callback, can_preempt) \ 226 227 ipc_call_async_fast((phoneid), (method), 0, 0, 0, 0, (private), \ … … 248 249 249 250 extern void ipc_call_async_fast(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 250 sysarg_t, void *, ipc_async_callback_t, int);251 sysarg_t, void *, ipc_async_callback_t, bool); 251 252 extern void ipc_call_async_slow(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t, 252 sysarg_t, sysarg_t, void *, ipc_async_callback_t, int); 253 254 extern int ipc_connect_to_me(int, int, int, int, sysarg_t *, sysarg_t *); 255 extern int ipc_connect_me_to(int, int, int, int); 256 extern int ipc_connect_me_to_blocking(int, int, int, int); 253 sysarg_t, sysarg_t, void *, ipc_async_callback_t, bool); 254 255 extern int ipc_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, sysarg_t *, 256 sysarg_t *); 257 extern int ipc_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t); 258 extern int ipc_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t); 259 257 260 extern int ipc_hangup(int); 258 extern int ipc_forward_fast(ipc_callid_t, int, int, sysarg_t, sysarg_t, int); 259 extern int ipc_forward_slow(ipc_callid_t, int, int, sysarg_t, sysarg_t, 260 sysarg_t, sysarg_t, sysarg_t, int); 261 262 extern int ipc_forward_fast(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t, 263 unsigned int); 264 extern int ipc_forward_slow(ipc_callid_t, int, sysarg_t, sysarg_t, sysarg_t, 265 sysarg_t, sysarg_t, sysarg_t, unsigned int); 261 266 262 267 /* 263 268 * User-friendly wrappers for ipc_share_in_start(). 264 269 */ 270 265 271 #define ipc_share_in_start_0_0(phoneid, dst, size) \ 266 272 ipc_share_in_start((phoneid), (dst), (size), 0, NULL) … … 272 278 ipc_share_in_start((phoneid), (dst), (size), (arg), (flags)) 273 279 274 extern int ipc_share_in_start(int, void *, size_t, sysarg_t, int *);275 extern int ipc_share_in_finalize(ipc_callid_t, void *, int);276 extern int ipc_share_out_start(int, void *, int);280 extern int ipc_share_in_start(int, void *, size_t, sysarg_t, unsigned int *); 281 extern int ipc_share_in_finalize(ipc_callid_t, void *, unsigned int); 282 extern int ipc_share_out_start(int, void *, unsigned int); 277 283 extern int ipc_share_out_finalize(ipc_callid_t, void *); 278 284 extern int ipc_data_read_start(int, void *, size_t); -
uspace/lib/c/include/loader/pcb.h
r6aef742 r197ef43 52 52 /** Program entry point. */ 53 53 entry_point_t entry; 54 54 55 55 /** Current working directory. */ 56 56 char *cwd; -
uspace/lib/c/include/malloc.h
r6aef742 r197ef43 38 38 #include <sys/types.h> 39 39 40 extern void __heap_init(void);41 40 extern uintptr_t get_max_heap_addr(void); 42 41 -
uspace/lib/c/include/setjmp.h
r6aef742 r197ef43 41 41 42 42 extern int setjmp(jmp_buf env); 43 extern void longjmp(jmp_buf env, int val) __attribute__((__noreturn__));43 extern void longjmp(jmp_buf env, int val) __attribute__((noreturn)); 44 44 45 45 #endif -
uspace/lib/c/include/stdlib.h
r6aef742 r197ef43 40 40 #include <stacktrace.h> 41 41 42 #define abort() \ 43 do { \ 44 stacktrace_print(); \ 45 _exit(1); \ 46 } while (0) 42 #define RAND_MAX 714025 47 43 48 #define core() \ 49 *((int *) 0) = 0xbadbad; 50 51 #define exit(status) _exit((status)) 52 53 #define RAND_MAX 714025 44 #define rand() random() 45 #define srand(seed) srandom(seed) 54 46 55 47 extern long int random(void); 56 48 extern void srandom(unsigned int seed); 57 49 58 static inline int rand(void) 59 { 60 return random(); 61 } 62 63 static inline void srand(unsigned int seed) 64 { 65 srandom(seed); 66 } 50 extern void abort(void) __attribute__((noreturn)); 67 51 68 52 #endif -
uspace/lib/c/include/syscall.h
r6aef742 r197ef43 32 32 /** 33 33 * @file 34 * @brief 35 * 36 * 34 * @brief Syscall function declaration for architectures that don't 35 * inline syscalls or architectures that handle syscalls 36 * according to the number of arguments. 37 37 */ 38 38 … … 40 40 #define LIBC_SYSCALL_H_ 41 41 42 #ifndef 43 #error "You can't include this file directly." 42 #ifndef LIBARCH_SYSCALL_GENERIC 43 #error You cannot include this file directly 44 44 #endif 45 45 … … 47 47 #include <kernel/syscall/syscall.h> 48 48 49 #define __syscall0 50 #define __syscall1 51 #define __syscall2 52 #define __syscall3 53 #define __syscall4 54 #define __syscall5 55 #define __syscall6 49 #define __syscall0 __syscall 50 #define __syscall1 __syscall 51 #define __syscall2 __syscall 52 #define __syscall3 __syscall 53 #define __syscall4 __syscall 54 #define __syscall5 __syscall 55 #define __syscall6 __syscall 56 56 57 57 extern sysarg_t __syscall(const sysarg_t p1, const sysarg_t p2, -
uspace/lib/c/include/thread.h
r6aef742 r197ef43 36 36 #define LIBC_THREAD_H_ 37 37 38 #include <kernel/proc/uarg.h>39 38 #include <libarch/thread.h> 40 39 #include <sys/types.h> … … 42 41 typedef uint64_t thread_id_t; 43 42 44 extern void __thread_entry(void);45 extern void __thread_main(uspace_arg_t *);46 47 43 extern int thread_create(void (*)(void *), void *, const char *, thread_id_t *); 48 extern void thread_exit(int) __attribute__ 44 extern void thread_exit(int) __attribute__((noreturn)); 49 45 extern void thread_detach(thread_id_t); 50 46 extern int thread_join(thread_id_t); -
uspace/lib/c/include/tls.h
r6aef742 r197ef43 57 57 extern void tls_free_variant_1(tcb_t *, size_t); 58 58 #endif 59 59 60 #ifdef CONFIG_TLS_VARIANT_2 60 61 extern tcb_t *tls_alloc_variant_2(void **, size_t); -
uspace/lib/c/include/unistd.h
r6aef742 r197ef43 41 41 42 42 #ifndef NULL 43 #define NULL 43 #define NULL ((void *) 0) 44 44 #endif 45 45 … … 74 74 extern int chdir(const char *); 75 75 76 extern void _exit(int) __attribute__((noreturn));76 extern void exit(int) __attribute__((noreturn)); 77 77 extern int usleep(useconds_t); 78 78 extern unsigned int sleep(unsigned int); -
uspace/lib/c/include/vfs/vfs.h
r6aef742 r197ef43 57 57 extern int unmount(const char *); 58 58 59 extern void __stdio_init(int filc, fdi_node_t *filv[]);60 extern void __stdio_done(void);61 62 59 extern int open_node(fdi_node_t *, int); 63 60 extern int fd_phone(int); -
uspace/srv/bd/ata_bd/ata_bd.c
r6aef742 r197ef43 265 265 sysarg_t method; 266 266 devmap_handle_t dh; 267 int flags;267 unsigned int flags; 268 268 int retval; 269 269 uint64_t ba; -
uspace/srv/bd/file_bd/file_bd.c
r6aef742 r197ef43 177 177 sysarg_t method; 178 178 size_t comm_size; 179 int flags;179 unsigned int flags; 180 180 int retval; 181 181 uint64_t ba; -
uspace/srv/bd/gxe_bd/gxe_bd.c
r6aef742 r197ef43 160 160 sysarg_t method; 161 161 devmap_handle_t dh; 162 int flags;162 unsigned int flags; 163 163 int retval; 164 164 uint64_t ba; -
uspace/srv/bd/part/guid_part/guid_part.c
r6aef742 r197ef43 315 315 sysarg_t method; 316 316 devmap_handle_t dh; 317 int flags;317 unsigned int flags; 318 318 int retval; 319 319 aoff64_t ba; -
uspace/srv/bd/part/mbr_part/mbr_part.c
r6aef742 r197ef43 393 393 sysarg_t method; 394 394 devmap_handle_t dh; 395 int flags;395 unsigned int flags; 396 396 int retval; 397 397 uint64_t ba; -
uspace/srv/bd/rd/rd.c
r6aef742 r197ef43 102 102 * Now we wait for the client to send us its communication as_area. 103 103 */ 104 int flags;104 unsigned int flags; 105 105 if (async_share_out_receive(&callid, &comm_size, &flags)) { 106 106 fs_va = as_get_mappable_page(comm_size);
Note:
See TracChangeset
for help on using the changeset viewer.