- Timestamp:
- 2012-06-13T13:17:46Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1d4024cf, 375e501
- Parents:
- faba839
- Location:
- kernel
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/userspace.c
rfaba839 r2902e1bb 55 55 asm volatile ( 56 56 "pushq %[udata_des]\n" 57 "pushq %[stack_ size]\n"57 "pushq %[stack_top]\n" 58 58 "pushq %[ipl]\n" 59 59 "pushq %[utext_des]\n" … … 65 65 "iretq\n" 66 66 :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 67 [stack_size] "r" (kernel_uarg->uspace_stack + STACK_SIZE), 67 [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack + 68 kernel_uarg->uspace_stack_size), 68 69 [ipl] "r" (ipl), 69 70 [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER), … … 74 75 75 76 /* Unreachable */ 76 while (1) 77 ; 77 while (1); 78 78 } 79 79 -
kernel/arch/arm32/src/userspace.c
rfaba839 r2902e1bb 92 92 93 93 /* set user stack */ 94 ustate.sp = ((uint32_t)kernel_uarg->uspace_stack) + STACK_SIZE; 94 ustate.sp = ((uint32_t) kernel_uarg->uspace_stack) + 95 kernel_uarg->uspace_stack_size; 95 96 96 97 /* set where uspace execution starts */ -
kernel/arch/ia32/src/userspace.c
rfaba839 r2902e1bb 63 63 64 64 "pushl %[udata_des]\n" 65 "pushl %[stack_ size]\n"65 "pushl %[stack_top]\n" 66 66 "pushl %[ipl]\n" 67 67 "pushl %[utext_des]\n" … … 75 75 : 76 76 : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 77 [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + STACK_SIZE), 77 [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack + 78 kernel_uarg->uspace_stack_size), 78 79 [ipl] "r" (ipl), 79 80 [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER), -
kernel/arch/ia64/src/ia64.c
rfaba839 r2902e1bb 232 232 * 233 233 * When calculating stack addresses, mind the stack split between the 234 * memory stack and the RSE stack. Each occuppies STACK_SIZE / 2 bytes. 234 * memory stack and the RSE stack. Each occuppies 235 * uspace_stack_size / 2 bytes. 235 236 */ 236 237 switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry, 237 ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2 - 238 ((uintptr_t) kernel_uarg->uspace_stack) + 239 kernel_uarg->uspace_stack_size / 2 - 238 240 ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT), 239 ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE / 2, 241 ((uintptr_t) kernel_uarg->uspace_stack) + 242 kernel_uarg->uspace_stack_size / 2, 240 243 (uintptr_t) kernel_uarg->uspace_uarg, psr.value, rsc.value); 241 242 while (1) 243 ; 244 245 while (1); 244 246 } 245 247 -
kernel/arch/mips32/src/mips32.c
rfaba839 r2902e1bb 211 211 cp0_status_um_bit | cp0_status_ie_enabled_bit)); 212 212 cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry); 213 userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE), 213 userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + 214 kernel_uarg->uspace_stack_size), 214 215 (uintptr_t) kernel_uarg->uspace_uarg, 215 216 (uintptr_t) kernel_uarg->uspace_entry); -
kernel/arch/mips64/src/mips64.c
rfaba839 r2902e1bb 188 188 cp0_status_um_bit | cp0_status_ie_enabled_bit)); 189 189 cp0_epc_write((uintptr_t) kernel_uarg->uspace_entry); 190 userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE), 190 userspace_asm(((uintptr_t) kernel_uarg->uspace_stack + 191 kernel_uarg->uspace_stack_size), 191 192 (uintptr_t) kernel_uarg->uspace_uarg, 192 193 (uintptr_t) kernel_uarg->uspace_entry); -
kernel/arch/ppc32/src/ppc32.c
rfaba839 r2902e1bb 269 269 { 270 270 userspace_asm((uintptr_t) kernel_uarg->uspace_uarg, 271 (uintptr_t) kernel_uarg->uspace_stack + STACK_SIZE - SP_DELTA, 271 (uintptr_t) kernel_uarg->uspace_stack + 272 kernel_uarg->uspace_stack_size - SP_DELTA, 272 273 (uintptr_t) kernel_uarg->uspace_entry); 273 274 -
kernel/arch/sparc64/src/sun4u/sparc64.c
rfaba839 r2902e1bb 156 156 (void) interrupts_disable(); 157 157 switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry, 158 ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE 159 - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS), 158 ((uintptr_t) kernel_uarg->uspace_stack) + 159 kernel_uarg->uspace_stack_size - 160 (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS), 160 161 (uintptr_t) kernel_uarg->uspace_uarg); 161 162 for (;;) 163 ; 164 /* not reached */ 162 163 /* Not reached */ 164 while (1); 165 165 } 166 166 -
kernel/arch/sparc64/src/sun4v/sparc64.c
rfaba839 r2902e1bb 154 154 (void) interrupts_disable(); 155 155 switch_to_userspace((uintptr_t) kernel_uarg->uspace_entry, 156 ((uintptr_t) kernel_uarg->uspace_stack) + STACK_SIZE 157 - (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS), 156 ((uintptr_t) kernel_uarg->uspace_stack) + 157 kernel_uarg->uspace_stack_size - 158 (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS), 158 159 (uintptr_t) kernel_uarg->uspace_uarg); 159 160 for (;;) 161 ; 162 /* not reached */ 160 161 /* Not reached */ 162 while (1); 163 163 } 164 164 -
kernel/generic/src/main/uinit.c
rfaba839 r2902e1bb 56 56 void uinit(void *arg) 57 57 { 58 uspace_arg_t uarg;59 60 58 /* 61 59 * So far, we don't have a use for joining userspace threads so we … … 72 70 #endif 73 71 74 uarg.uspace_entry = ((uspace_arg_t *) arg)->uspace_entry; 75 uarg.uspace_stack = ((uspace_arg_t *) arg)->uspace_stack; 76 uarg.uspace_uarg = ((uspace_arg_t *) arg)->uspace_uarg; 77 uarg.uspace_thread_function = NULL; 78 uarg.uspace_thread_arg = NULL; 72 uspace_arg_t *uarg = (uspace_arg_t *) arg; 73 uspace_arg_t local_uarg; 79 74 80 free((uspace_arg_t *) arg); 75 local_uarg.uspace_entry = uarg->uspace_entry; 76 local_uarg.uspace_stack = uarg->uspace_stack; 77 local_uarg.uspace_stack_size = uarg->uspace_stack_size; 78 local_uarg.uspace_uarg = uarg->uspace_uarg; 79 local_uarg.uspace_thread_function = NULL; 80 local_uarg.uspace_thread_arg = NULL; 81 81 82 userspace(&uarg); 82 free(uarg); 83 84 userspace(&local_uarg); 83 85 } 84 86 -
kernel/generic/src/proc/program.c
rfaba839 r2902e1bb 71 71 int program_create(as_t *as, uintptr_t entry_addr, char *name, program_t *prg) 72 72 { 73 uspace_arg_t *kernel_uarg;74 75 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);76 kernel_uarg->uspace_entry = (void *) entry_addr;77 kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS;78 kernel_uarg->uspace_thread_function = NULL;79 kernel_uarg->uspace_thread_arg = NULL;80 kernel_uarg->uspace_uarg = NULL;81 82 73 prg->loader_status = EE_OK; 83 74 prg->task = task_create(as, name); … … 92 83 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, 93 84 STACK_SIZE, AS_AREA_ATTR_NONE, &anon_backend, NULL, &virt, 0); 94 if (!area) 85 if (!area) { 86 task_destroy(prg->task); 95 87 return ENOMEM; 88 } 89 90 uspace_arg_t *kernel_uarg = (uspace_arg_t *) 91 malloc(sizeof(uspace_arg_t), 0); 92 93 kernel_uarg->uspace_entry = (void *) entry_addr; 94 kernel_uarg->uspace_stack = (void *) virt; 95 kernel_uarg->uspace_stack_size = STACK_SIZE; 96 kernel_uarg->uspace_thread_function = NULL; 97 kernel_uarg->uspace_thread_arg = NULL; 98 kernel_uarg->uspace_uarg = NULL; 96 99 97 100 /* … … 100 103 prg->main_thread = thread_create(uinit, kernel_uarg, prg->task, 101 104 THREAD_FLAG_USPACE, "uinit", false); 102 if (!prg->main_thread) 105 if (!prg->main_thread) { 106 free(kernel_uarg); 107 as_area_destroy(as, virt); 108 task_destroy(prg->task); 103 109 return ELIMIT; 110 } 104 111 105 112 return EOK; -
kernel/generic/src/proc/thread.c
rfaba839 r2902e1bb 854 854 * In case of failure, kernel_uarg will be deallocated in this function. 855 855 * In case of success, kernel_uarg will be freed in uinit(). 856 *857 856 */ 858 857 uspace_arg_t *kernel_uarg =
Note:
See TracChangeset
for help on using the changeset viewer.