Changeset 0f250f9 in mainline
- Timestamp:
- 2006-03-17T18:07:56Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 69f293e
- Parents:
- 6c6a19e6
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/src/userspace.c
r6c6a19e6 r0f250f9 31 31 #include <arch/types.h> 32 32 #include <arch.h> 33 #include <proc/ thread.h>33 #include <proc/uarg.h> 34 34 #include <mm/as.h> 35 35 … … 40 40 * 41 41 */ 42 void userspace(uspace_arg_t * uarg)42 void userspace(uspace_arg_t *kernel_uarg) 43 43 { 44 44 ipl_t ipl; … … 52 52 "pushq %3\n" 53 53 "pushq %4\n" 54 "movq %5, %%rax\n" 54 55 "iretq\n" 55 56 : : 56 57 "i" (gdtselector(UDATA_DES) | PL_USER), 57 "r" ( uarg->uspace_stack+THREAD_STACK_SIZE),58 "r" (kernel_uarg->uspace_stack+THREAD_STACK_SIZE), 58 59 "r" (ipl), 59 60 "i" (gdtselector(UTEXT_DES) | PL_USER), 60 "r" (uarg->uspace_entry)); 61 "r" (kernel_uarg->uspace_entry), 62 "r" (kernel_uarg->uspace_uarg) 63 : "rax" 64 ); 61 65 62 66 /* Unreachable */ 63 for(;;); 67 for(;;) 68 ; 64 69 } -
arch/ia32/src/userspace.c
r6c6a19e6 r0f250f9 31 31 #include <arch/types.h> 32 32 #include <arch.h> 33 #include <proc/ thread.h>33 #include <proc/uarg.h> 34 34 #include <mm/as.h> 35 35 … … 40 40 * 41 41 */ 42 void userspace(uspace_arg_t * uarg)42 void userspace(uspace_arg_t *kernel_uarg) 43 43 { 44 44 ipl_t ipl; … … 47 47 48 48 __asm__ volatile ( 49 /* CLNT */ 49 /* 50 * Clear nested task flag. 51 */ 50 52 "pushfl\n" 51 53 "pop %%eax\n" 52 "and $0xffffbfff, %%eax\n"54 "and $0xffffbfff, %%eax\n" 53 55 "push %%eax\n" 54 56 "popfl\n" … … 59 61 "pushl %3\n" 60 62 "pushl %4\n" 63 "movl %5, %%eax\n" 61 64 "iret" 62 65 : 63 : "i" (selector(UDATA_DES) | PL_USER), "r" (uarg->uspace_stack+THREAD_STACK_SIZE), 64 "r" (ipl), "i" (selector(UTEXT_DES) | PL_USER), "r" (uarg->uspace_entry) 66 : "i" (selector(UDATA_DES) | PL_USER), "r" (kernel_uarg->uspace_stack+THREAD_STACK_SIZE), 67 "r" (ipl), "i" (selector(UTEXT_DES) | PL_USER), "r" (kernel_uarg->uspace_entry), 68 "r" (kernel_uarg->uspace_uarg) 65 69 : "eax"); 66 70 -
arch/ia64/include/asm.h
r6c6a19e6 r0f250f9 259 259 extern void asm_delay_loop(__u32 t); 260 260 261 extern void switch_to_userspace(__address entry, __address sp, __address bsp, __ u64 ipsr, __u64 rsc);261 extern void switch_to_userspace(__address entry, __address sp, __address bsp, __address uspace_uarg, __u64 ipsr, __u64 rsc); 262 262 263 263 #endif -
arch/ia64/include/faddr.h
r6c6a19e6 r0f250f9 32 32 #include <arch/types.h> 33 33 34 static __address FADDR(void (* fptr)(void));35 36 34 /** 37 35 * … … 42 40 * 43 41 */ 44 inline __address FADDR(void (* fptr)(void)) {42 static inline __address FADDR(void (* fptr)()) { 45 43 __address faddr; 46 47 /*Deprecated assembler version*/48 /*49 __asm__(50 "ld8 %0 = [%1]\n\t"51 : "=r" (faddr)52 : "r" (fptr)53 );54 */55 44 56 45 faddr = *((__address *)(fptr));; -
arch/ia64/src/asm.S
r6c6a19e6 r0f250f9 55 55 * @param in1 Userspace stack pointer address. 56 56 * @param in2 Userspace register stack pointer address. 57 * @param in3 Value to be stored in IPSR. 58 * @param in4 Value to be stored in RSC. 57 * @param in3 Userspace address of thread uspace_arg_t structure. 58 * @param in4 Value to be stored in IPSR. 59 * @param in5 Value to be stored in RSC. 59 60 */ 60 61 .global switch_to_userspace 61 62 switch_to_userspace: 62 alloc loc0 = ar.pfs, 5, 3, 0, 063 alloc loc0 = ar.pfs, 6, 3, 0, 0 63 64 rsm (PSR_IC_MASK | PSR_I_MASK) /* disable interruption collection and interrupts */ 64 65 srlz.d ;; 65 66 srlz.i ;; 66 67 67 mov cr.ipsr = in 368 mov cr.ipsr = in4 68 69 mov cr.iip = in0 69 70 mov r12 = in1 … … 85 86 86 87 mov ar.bspstore = in2 ;; 87 mov ar.rsc = in4 ;; 88 mov ar.rsc = in5 ;; 89 90 mov r8 = in3 88 91 89 92 rfi ;; -
arch/ia64/src/ia64.c
r6c6a19e6 r0f250f9 42 42 #include <userspace.h> 43 43 #include <console/console.h> 44 #include <proc/ thread.h>44 #include <proc/uarg.h> 45 45 46 46 void arch_pre_mm_init(void) … … 74 74 75 75 /** Enter userspace and never return. */ 76 void userspace(uspace_arg_t * uarg)76 void userspace(uspace_arg_t *kernel_uarg) 77 77 { 78 78 psr_t psr; … … 92 92 rsc.mode = 3; /* eager mode */ 93 93 94 switch_to_userspace(uarg->uspace_entry, uarg->uspace_stack+PAGE_SIZE-ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT), uarg->uspace_stack, psr.value, rsc.value); 94 switch_to_userspace((__address) kernel_uarg->uspace_entry, 95 ((__address) kernel_uarg->uspace_stack)+PAGE_SIZE-ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT), 96 (__address) kernel_uarg->uspace_stack, 97 (__address) kernel_uarg->uspace_uarg, 98 psr.value, rsc.value); 95 99 96 100 while (1) { -
arch/mips32/include/asm.h
r6c6a19e6 r0f250f9 58 58 extern void cpu_halt(void); 59 59 extern void asm_delay_loop(__u32 t); 60 extern void userspace_asm(__address ustack );60 extern void userspace_asm(__address ustack, __address uspace_uarg); 61 61 62 62 #endif -
arch/mips32/src/mips32.c
r6c6a19e6 r0f250f9 38 38 #include <memstr.h> 39 39 #include <proc/thread.h> 40 #include <proc/uarg.h> 40 41 #include <print.h> 41 42 … … 121 122 __address supervisor_sp __attribute__ ((section (".text"))); 122 123 123 void userspace(uspace_arg_t * uarg)124 void userspace(uspace_arg_t *kernel_uarg) 124 125 { 125 126 /* EXL=1, UM=1, IE=1 */ … … 127 128 cp0_status_um_bit | 128 129 cp0_status_ie_enabled_bit)); 129 cp0_epc_write( uarg->uspace_entry);130 userspace_asm( uarg->uspace_stack+PAGE_SIZE);130 cp0_epc_write((__address) kernel_uarg->uspace_entry); 131 userspace_asm(((__address) kernel_uarg->uspace_stack+PAGE_SIZE), (__address) kernel_uarg->uspace_uarg); 131 132 while (1) 132 133 ; -
arch/mips32/src/start.S
r6c6a19e6 r0f250f9 227 227 userspace_asm: 228 228 add $sp, $a0, 0 229 eret 230 nop 231 229 add $v0, $a1, 0 230 eret 231 nop 232 -
generic/include/proc/thread.h
r6c6a19e6 r0f250f9 41 41 #include <adt/list.h> 42 42 #include <mm/slab.h> 43 #include <proc/uarg.h> 43 44 44 45 #define THREAD_STACK_SIZE STACK_SIZE … … 118 119 }; 119 120 120 /** Structure passed to uinit kernel thread as argument. */121 typedef struct uspace_arg {122 __address uspace_entry;123 __address uspace_stack;124 } uspace_arg_t;125 126 121 /** Thread list lock. 127 122 * … … 150 145 151 146 /** Thread syscall prototypes. */ 152 __native sys_thread_create( __address function, void *arg, void *stack, char *name);153 __native sys_thread_exit(int status);147 __native sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name); 148 __native sys_thread_exit(int uspace_status); 154 149 155 150 #endif -
generic/src/main/uinit.c
r6c6a19e6 r0f250f9 44 44 uarg.uspace_entry = ((uspace_arg_t *) arg)->uspace_entry; 45 45 uarg.uspace_stack = ((uspace_arg_t *) arg)->uspace_stack; 46 uarg.uspace_uarg = ((uspace_arg_t *) arg)->uspace_uarg; 47 uarg.uspace_thread_function = NULL; 48 uarg.uspace_thread_arg = NULL; 46 49 47 50 free((uspace_arg_t *) arg); -
generic/src/proc/task.c
r6c6a19e6 r0f250f9 30 30 #include <proc/thread.h> 31 31 #include <proc/task.h> 32 #include <proc/uarg.h> 32 33 #include <mm/as.h> 33 34 #include <mm/slab.h> 34 35 35 #include <synch/spinlock.h> 36 36 #include <arch.h> … … 40 40 #include <memstr.h> 41 41 #include <print.h> 42 43 42 #include <elf.h> 44 43 … … 116 115 thread_t *t; 117 116 task_t *task; 118 uspace_arg_t * uarg;117 uspace_arg_t *kernel_uarg; 119 118 120 119 as = as_create(0); … … 126 125 } 127 126 128 uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); 129 uarg->uspace_entry = (__address) ((elf_header_t *) program_addr)->e_entry; 130 uarg->uspace_stack = USTACK_ADDRESS; 127 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); 128 kernel_uarg->uspace_entry = (void *) ((elf_header_t *) program_addr)->e_entry; 129 kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS; 130 kernel_uarg->uspace_thread_function = NULL; 131 kernel_uarg->uspace_thread_arg = NULL; 132 kernel_uarg->uspace_uarg = NULL; 131 133 132 134 task = task_create(as, name); 133 t = thread_create(uinit, uarg, task, 0, "uinit");135 t = thread_create(uinit, kernel_uarg, task, 0, "uinit"); 134 136 135 137 /* -
generic/src/proc/thread.c
r6c6a19e6 r0f250f9 30 30 #include <proc/thread.h> 31 31 #include <proc/task.h> 32 #include <proc/uarg.h> 32 33 #include <mm/frame.h> 33 34 #include <mm/page.h> … … 430 431 * 431 432 */ 432 __native sys_thread_create( __address function, void *arg, void *stack, char *name)433 __native sys_thread_create(uspace_arg_t *uspace_uarg, char *uspace_name) 433 434 { 434 435 thread_t *t; 435 436 char namebuf[THREAD_NAME_BUFLEN]; 436 uspace_arg_t * uarg;437 uspace_arg_t *kernel_uarg; /* TODO: store kernel_uarg in thread_t */ 437 438 __u32 tid; 438 439 439 copy_from_uspace(namebuf, name, THREAD_NAME_BUFLEN); 440 uarg = (uspace_arg_t *) malloc(sizeof(uarg), 0); 441 442 uarg->uspace_entry = function; 443 uarg->uspace_stack = (__address) stack; 444 445 if ((t = thread_create(uinit, uarg, TASK, 0, namebuf))) { 440 copy_from_uspace(namebuf, uspace_name, THREAD_NAME_BUFLEN); 441 442 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); 443 copy_from_uspace(kernel_uarg, uspace_uarg, sizeof(uspace_arg_t)); 444 445 if ((t = thread_create(uinit, kernel_uarg, TASK, 0, namebuf))) { 446 446 tid = t->tid; 447 447 thread_ready(t); 448 448 return (__native) tid; 449 449 } else { 450 free(namebuf);450 free(kernel_uarg); 451 451 } 452 452 … … 457 457 * 458 458 */ 459 __native sys_thread_exit(int status)459 __native sys_thread_exit(int uspace_status) 460 460 { 461 461 thread_exit();
Note:
See TracChangeset
for help on using the changeset viewer.