- Timestamp:
- 2012-08-24T14:07:52Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 041ab64
- Parents:
- bd29f9c9 (diff), db81577 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel
- Files:
-
- 1 added
- 12 edited
-
arch/mips32/Makefile.inc (modified) (2 diffs)
-
arch/mips64/Makefile.inc (modified) (2 diffs)
-
generic/include/interrupt.h (modified) (1 diff)
-
generic/include/ipc/ipc.h (modified) (3 diffs)
-
generic/include/ipc/sysipc.h (modified) (1 diff)
-
generic/include/print.h (modified) (1 diff)
-
generic/include/printf/verify.h (added)
-
generic/include/proc/task.h (modified) (1 diff)
-
generic/src/ipc/ipc.c (modified) (5 diffs)
-
generic/src/ipc/sysipc.c (modified) (1 diff)
-
generic/src/lib/str.c (modified) (3 diffs)
-
generic/src/proc/task.c (modified) (1 diff)
-
generic/src/syscall/syscall.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/Makefile.inc
rbd29f9c9 rbeb9336 29 29 BFD_ARCH = mips 30 30 BFD = binary 31 GCC_CFLAGS += -m no-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=3231 GCC_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=32 32 32 33 33 BITS = 32 … … 48 48 BFD_NAME = elf32-tradlittlemips 49 49 ENDIANESS = LE 50 GCC_CFLAGS += -mhard-float51 50 endif 52 51 -
kernel/arch/mips64/Makefile.inc
rbd29f9c9 rbeb9336 29 29 BFD_ARCH = mips:4000 30 30 BFD = binary 31 GCC_CFLAGS += -m no-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=6431 GCC_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mips3 -mabi=64 32 32 AFLAGS = -64 33 33 … … 40 40 BFD_NAME = elf64-tradlittlemips 41 41 ENDIANESS = LE 42 GCC_CFLAGS += -mhard-float43 42 endif 44 43 -
kernel/generic/include/interrupt.h
rbd29f9c9 rbeb9336 59 59 extern exc_table_t exc_table[]; 60 60 61 extern void fault_from_uspace(istate_t *, const char *, ...); 61 extern void fault_from_uspace(istate_t *, const char *, ...) 62 PRINTF_ATTRIBUTE(2, 3); 62 63 extern void fault_if_from_uspace(istate_t *, const char *, ...) 63 64 PRINTF_ATTRIBUTE(2, 3); -
kernel/generic/include/ipc/ipc.h
rbd29f9c9 rbeb9336 77 77 waitq_t wq; 78 78 79 /** Linkage for the list of task's synchronous answerboxes. */80 link_t sync_box_link;81 82 79 /** Phones connected to this answerbox. */ 83 80 list_t connected_phones; … … 116 113 struct task *sender; 117 114 118 /*119 * The caller box is different from sender->answerbox120 * for synchronous calls.121 */122 answerbox_t *callerbox;123 124 115 /** Private data to internal IPC. */ 125 116 sysarg_t priv; … … 147 138 148 139 extern int ipc_call(phone_t *, call_t *); 149 extern int ipc_call_sync(phone_t *, call_t *);150 140 extern call_t *ipc_wait_for_call(answerbox_t *, uint32_t, unsigned int); 151 141 extern int ipc_forward(call_t *, phone_t *, answerbox_t *, unsigned int); -
kernel/generic/include/ipc/sysipc.h
rbd29f9c9 rbeb9336 40 40 #include <typedefs.h> 41 41 42 extern sysarg_t sys_ipc_call_sync_fast(sysarg_t, sysarg_t, sysarg_t,43 sysarg_t, sysarg_t, ipc_data_t *);44 extern sysarg_t sys_ipc_call_sync_slow(sysarg_t, ipc_data_t *, ipc_data_t *);45 42 extern sysarg_t sys_ipc_call_async_fast(sysarg_t, sysarg_t, sysarg_t, 46 43 sysarg_t, sysarg_t, sysarg_t); -
kernel/generic/include/print.h
rbd29f9c9 rbeb9336 38 38 #include <typedefs.h> 39 39 #include <stdarg.h> 40 41 #ifndef NVERIFY_PRINTF 42 43 #define PRINTF_ATTRIBUTE(start, end) \ 44 __attribute__((format(gnu_printf, start, end))) 45 46 #else /* NVERIFY_PRINTF */ 47 48 #define PRINTF_ATTRIBUTE(start, end) 49 50 #endif /* NVERIFY_PRINTF */ 40 #include <printf/verify.h> 51 41 52 42 #define EOF (-1) -
kernel/generic/include/proc/task.h
rbd29f9c9 rbeb9336 94 94 phone_t phones[IPC_MAX_PHONES]; 95 95 stats_ipc_t ipc_info; /**< IPC statistics */ 96 list_t sync_boxes; /**< List of synchronous answerboxes. */97 96 event_t events[EVENT_TASK_END - EVENT_END]; 98 97 -
kernel/generic/src/ipc/ipc.c
rbd29f9c9 rbeb9336 71 71 { 72 72 memsetb(call, sizeof(*call), 0); 73 call->callerbox = &TASK->answerbox;74 73 call->sender = TASK; 75 74 call->buffer = NULL; … … 120 119 irq_spinlock_initialize(&box->irq_lock, "ipc.box.irqlock"); 121 120 waitq_initialize(&box->wq); 122 link_initialize(&box->sync_box_link);123 121 list_initialize(&box->connected_phones); 124 122 list_initialize(&box->calls); … … 163 161 } 164 162 165 /** Helper function to facilitate synchronous calls.166 *167 * @param phone Destination kernel phone structure.168 * @param request Call structure with request.169 *170 * @return EOK on success or EINTR if the sleep was interrupted.171 *172 */173 int ipc_call_sync(phone_t *phone, call_t *request)174 {175 answerbox_t *sync_box = slab_alloc(ipc_answerbox_slab, 0);176 ipc_answerbox_init(sync_box, TASK);177 178 /*179 * Put the answerbox on the TASK's list of synchronous answerboxes so180 * that it can be cleaned up if the call is interrupted.181 */182 irq_spinlock_lock(&TASK->lock, true);183 list_append(&sync_box->sync_box_link, &TASK->sync_boxes);184 irq_spinlock_unlock(&TASK->lock, true);185 186 /* We will receive data in a special box. */187 request->callerbox = sync_box;188 189 ipc_call(phone, request);190 if (!ipc_wait_for_call(sync_box, SYNCH_NO_TIMEOUT,191 SYNCH_FLAGS_INTERRUPTIBLE)) {192 /* The answerbox and the call will be freed by ipc_cleanup(). */193 return EINTR;194 }195 196 /*197 * The answer arrived without interruption so we can remove the198 * answerbox from the TASK's list of synchronous answerboxes.199 */200 irq_spinlock_lock(&TASK->lock, true);201 list_remove(&sync_box->sync_box_link);202 irq_spinlock_unlock(&TASK->lock, true);203 204 slab_free(ipc_answerbox_slab, sync_box);205 return EOK;206 }207 208 163 /** Answer a message which was not dispatched and is not listed in any queue. 209 164 * … … 214 169 static void _ipc_answer_free_call(call_t *call, bool selflocked) 215 170 { 216 answerbox_t *callerbox = call->callerbox;171 answerbox_t *callerbox = &call->sender->answerbox; 217 172 bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox)); 218 173 … … 606 561 ipc_cleanup_call_list(&TASK->answerbox.calls); 607 562 irq_spinlock_unlock(&TASK->answerbox.lock, true); 608 609 /* Wait for all answers to interrupted synchronous calls to arrive */610 ipl_t ipl = interrupts_disable();611 while (!list_empty(&TASK->sync_boxes)) {612 answerbox_t *box = list_get_instance(613 list_first(&TASK->sync_boxes), answerbox_t, sync_box_link);614 615 list_remove(&box->sync_box_link);616 call_t *call = ipc_wait_for_call(box, SYNCH_NO_TIMEOUT,617 SYNCH_FLAGS_NONE);618 ipc_call_free(call);619 slab_free(ipc_answerbox_slab, box);620 }621 interrupts_restore(ipl);622 563 623 564 /* Wait for all answers to asynchronous calls to arrive */ -
kernel/generic/src/ipc/sysipc.c
rbd29f9c9 rbeb9336 612 612 break; 613 613 } 614 615 return 0;616 }617 618 /** Make a fast call over IPC, wait for reply and return to user.619 *620 * This function can handle only three arguments of payload, but is faster than621 * the generic function (i.e. sys_ipc_call_sync_slow()).622 *623 * @param phoneid Phone handle for the call.624 * @param imethod Interface and method of the call.625 * @param arg1 Service-defined payload argument.626 * @param arg2 Service-defined payload argument.627 * @param arg3 Service-defined payload argument.628 * @param data Address of user-space structure where the reply call will629 * be stored.630 *631 * @return 0 on success.632 * @return ENOENT if there is no such phone handle.633 *634 */635 sysarg_t sys_ipc_call_sync_fast(sysarg_t phoneid, sysarg_t imethod,636 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, ipc_data_t *data)637 {638 phone_t *phone;639 if (phone_get(phoneid, &phone) != EOK)640 return ENOENT;641 642 call_t *call = ipc_call_alloc(0);643 IPC_SET_IMETHOD(call->data, imethod);644 IPC_SET_ARG1(call->data, arg1);645 IPC_SET_ARG2(call->data, arg2);646 IPC_SET_ARG3(call->data, arg3);647 648 /*649 * To achieve deterministic behavior, zero out arguments that are beyond650 * the limits of the fast version.651 */652 IPC_SET_ARG4(call->data, 0);653 IPC_SET_ARG5(call->data, 0);654 655 int res = request_preprocess(call, phone);656 int rc;657 658 if (!res) {659 #ifdef CONFIG_UDEBUG660 udebug_stoppable_begin();661 #endif662 rc = ipc_call_sync(phone, call);663 #ifdef CONFIG_UDEBUG664 udebug_stoppable_end();665 #endif666 667 if (rc != EOK) {668 /* The call will be freed by ipc_cleanup(). */669 return rc;670 }671 672 process_answer(call);673 } else674 IPC_SET_RETVAL(call->data, res);675 676 rc = STRUCT_TO_USPACE(&data->args, &call->data.args);677 ipc_call_free(call);678 if (rc != 0)679 return rc;680 681 return 0;682 }683 684 /** Make a synchronous IPC call allowing to transmit the entire payload.685 *686 * @param phoneid Phone handle for the call.687 * @param request User-space address of call data with the request.688 * @param reply User-space address of call data where to store the689 * answer.690 *691 * @return Zero on success or an error code.692 *693 */694 sysarg_t sys_ipc_call_sync_slow(sysarg_t phoneid, ipc_data_t *request,695 ipc_data_t *reply)696 {697 phone_t *phone;698 if (phone_get(phoneid, &phone) != EOK)699 return ENOENT;700 701 call_t *call = ipc_call_alloc(0);702 int rc = copy_from_uspace(&call->data.args, &request->args,703 sizeof(call->data.args));704 if (rc != 0) {705 ipc_call_free(call);706 return (sysarg_t) rc;707 }708 709 int res = request_preprocess(call, phone);710 711 if (!res) {712 #ifdef CONFIG_UDEBUG713 udebug_stoppable_begin();714 #endif715 rc = ipc_call_sync(phone, call);716 #ifdef CONFIG_UDEBUG717 udebug_stoppable_end();718 #endif719 720 if (rc != EOK) {721 /* The call will be freed by ipc_cleanup(). */722 return rc;723 }724 725 process_answer(call);726 } else727 IPC_SET_RETVAL(call->data, res);728 729 rc = STRUCT_TO_USPACE(&reply->args, &call->data.args);730 ipc_call_free(call);731 if (rc != 0)732 return rc;733 614 734 615 return 0; -
kernel/generic/src/lib/str.c
rbd29f9c9 rbeb9336 459 459 * and both strings consist of the same sequence of characters. 460 460 * 461 * A string is smaller than another string iff it is shorter or 462 * has a character with lower value at the first position where 463 * the strings differ. 461 * A string S1 is less than another string S2 if it has a character with 462 * lower value at the first character position where the strings differ. 463 * If the strings differ in length, the shorter one is treated as if 464 * padded by characters with a value of zero. 464 465 * 465 466 * @param s1 First string to compare. 466 467 * @param s2 Second string to compare. 467 468 * 468 * @return 0 if the strings are equal, -1 if first is smaller,469 * 1 if second smaller.469 * @return 0 if the strings are equal, -1 if the first is less than the second, 470 * 1 if the second is less than the first. 470 471 * 471 472 */ … … 503 504 * up to max_len characters. 504 505 * 505 * A string is smaller than another string iff it is shorter or 506 * has a character with lower value at the first position where 507 * the strings differ, considering only first max_len characters. 506 * A string S1 is less than another string S2 if it has a character with 507 * lower value at the first character position where the strings differ. 508 * If the strings differ in length, the shorter one is treated as if 509 * padded by characters with a value of zero. Only the first max_len 510 * characters are considered. 508 511 * 509 512 * @param s1 First string to compare. … … 511 514 * @param max_len Maximum number of characters to consider. 512 515 * 513 * @return 0 if the strings are equal, -1 if first is smaller,514 * 1 if second smaller.516 * @return 0 if the strings are equal, -1 if the first is less than the second, 517 * 1 if the second is less than the first. 515 518 * 516 519 */ -
kernel/generic/src/proc/task.c
rbd29f9c9 rbeb9336 156 156 157 157 list_initialize(&task->threads); 158 list_initialize(&task->sync_boxes);159 158 160 159 ipc_answerbox_init(&task->answerbox, task); -
kernel/generic/src/syscall/syscall.c
rbd29f9c9 rbeb9336 151 151 152 152 /* IPC related syscalls. */ 153 (syshandler_t) sys_ipc_call_sync_fast,154 (syshandler_t) sys_ipc_call_sync_slow,155 153 (syshandler_t) sys_ipc_call_async_fast, 156 154 (syshandler_t) sys_ipc_call_async_slow,
Note:
See TracChangeset
for help on using the changeset viewer.
