diff options
author | 2007-10-16 04:57:37 +0000 | |
---|---|---|
committer | 2007-10-16 04:57:37 +0000 | |
commit | b73bc8bfcd0bf22a9a81cdb6b840caefa1b4d10f (patch) | |
tree | 5eb2ee8b78d6881d02e29b7460fe95f3c97569a4 | |
parent | Fix the mtx_wantipl != IPL_NONE comparison in the ``have to spin'' (diff) | |
download | wireguard-openbsd-b73bc8bfcd0bf22a9a81cdb6b840caefa1b4d10f.tar.xz wireguard-openbsd-b73bc8bfcd0bf22a9a81cdb6b840caefa1b4d10f.zip |
Do not expose the end of the proc_trampoline bowels to C code anymore, and
get rid of the ``switchframe'' struct definition. As a bonus, this makes
cpu_fork() simpler and unwastes 8 bytes of u area.
-rw-r--r-- | sys/arch/m88k/include/cpu.h | 10 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/eh_common.S | 64 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/vm_machdep.c | 23 |
3 files changed, 36 insertions, 61 deletions
diff --git a/sys/arch/m88k/include/cpu.h b/sys/arch/m88k/include/cpu.h index 8804f92ba41..87bd3869160 100644 --- a/sys/arch/m88k/include/cpu.h +++ b/sys/arch/m88k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.24 2007/10/13 12:54:43 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.25 2007/10/16 04:57:37 miod Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * Copyright (c) 1992, 1993 @@ -236,14 +236,6 @@ do { \ void signotify(struct proc *); -/* - * switchframe - should be double word aligned. - */ -struct switchframe { - u_int sf_pc; /* pc */ - void *sf_proc; /* proc pointer */ -}; - int badaddr(vaddr_t addr, int size); #endif /* _KERNEL */ diff --git a/sys/arch/m88k/m88k/eh_common.S b/sys/arch/m88k/m88k/eh_common.S index 83c915f7de5..83ca5f7e866 100644 --- a/sys/arch/m88k/m88k/eh_common.S +++ b/sys/arch/m88k/m88k/eh_common.S @@ -1,4 +1,4 @@ -/* $OpenBSD: eh_common.S,v 1.25 2007/10/13 12:54:03 miod Exp $ */ +/* $OpenBSD: eh_common.S,v 1.26 2007/10/16 04:57:39 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -2318,36 +2318,10 @@ ASLOCAL(save_frame) space SIZEOF_EF #endif /* M88110 */ -/* - * void proc_trampoline(void (*func)(void *), void *proc) - * - * When a process setup by cpu_fork() resumes, it will find itself in - * proc_trampoline, with r31 pointing to a ksigframe. proc_trampoline will - * load func and proc values from ksigframe, call the function, and on return - * pop off the ksigframe. Then, it will load pc from the switchframe and - * jump there (the pc will usually be proc_do_uret). - */ - -ENTRY(proc_trampoline) -#ifdef MULTIPROCESSOR - bsr _C_LABEL(proc_trampoline_mp) -#endif - - bsr.n _C_LABEL(setipl) /* setipl(IPL_NONE) */ - or r2, r0, r0 - - ld r1, r31, 0 /* load func */ - ld r2, r31, 4 /* load proc pointer */ - jsr.n r1 - addu r31, r31, 8 /* release ksigframe */ - ld r1, r31, 0 /* load pc */ - ld r2, r31, 4 /* & proc pointer from switch frame */ - jsr.n r1 - addu r31, r31, 8 + text #define FPTR r14 - ASLOCAL(check_ast) /* * Regs r1-r30 are free. r31 is pointing at the word @@ -2413,17 +2387,39 @@ ASLOCAL(no_softint) #endif /* - * void proc_do_uret(struct proc *p) + * void proc_trampoline(void (*func)(void *), void *proc) * - * This is called as proc_do_uret(proc) from proc_trampoline(). This function - * loads FPTR with a pointer to the trap frame for the given proc and continues - * near the end of check_ast, bypassing soft interrupts and AST checks, to - * load all the registers and do an RTE. + * When a process setup by cpu_fork() resumes, it will find itself in + * proc_trampoline, with r31 pointing to a ksigframe. proc_trampoline will + * load func and proc values from ksigframe, call the function, and on return + * pop off the ksigframe. Then, it will return to userland. */ -ENTRY(proc_do_uret) +ENTRY(proc_trampoline) +#ifdef MULTIPROCESSOR + bsr _C_LABEL(proc_trampoline_mp) +#endif + + bsr.n _C_LABEL(setipl) /* setipl(IPL_NONE) */ + or r2, r0, r0 + + ld r1, r31, 0 /* load func */ + ld r2, r31, 4 /* load arg */ + jsr.n r1 + addu r31, r31, 8 /* release ksigframe */ + +/* + * Load FPTR with a pointer to the trap frame for the current proc and + * continue near the end of check_ast, bypassing soft interrupts and AST + * checks, to load all the registers and do an RTE. + */ + + ldcr r3, CPU + ld r2, r3, CI_CURPROC + ld FPTR, r2, P_ADDR /* p->p_addr */ addu FPTR, FPTR, PCB_USER_STATE /* p->p_addr.u_pcb.user_state */ + /* FALLTHROUGH */ ASLOCAL(no_ast) diff --git a/sys/arch/m88k/m88k/vm_machdep.c b/sys/arch/m88k/m88k/vm_machdep.c index 4ca1ece2c3a..6d1c3fa1d79 100644 --- a/sys/arch/m88k/m88k/vm_machdep.c +++ b/sys/arch/m88k/m88k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.17 2007/10/13 07:18:01 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.18 2007/10/16 04:57:39 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. @@ -60,7 +60,6 @@ #include <machine/cpu.h> #include <machine/trap.h> -extern void proc_do_uret(struct proc *); extern void savectx(struct pcb *); extern void switch_exit(struct proc *); @@ -82,10 +81,9 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) void (*func)(void *); void *arg; { - struct switchframe *p2sf; struct ksigframe { void (*func)(void *); - void *proc; + void *arg; } *ksfp; extern void proc_trampoline(void); @@ -103,31 +101,20 @@ cpu_fork(p1, p2, stack, stacksize, func, arg) p2->p_md.md_tf = (struct trapframe *)USER_REGS(p2); /* - * Create a switch frame for proc 2 - */ - p2sf = (struct switchframe *)((char *)p2->p_addr + USPACE - 8) - 1; - - p2sf->sf_pc = (u_int)proc_do_uret; - p2sf->sf_proc = p2; - p2->p_addr->u_pcb.kernel_state.pcb_sp = (u_int)p2sf; - - /* * If specified, give the child a different stack. */ if (stack != NULL) USER_REGS(p2)->r[31] = (u_int)stack + stacksize; - ksfp = (struct ksigframe *)p2->p_addr->u_pcb.kernel_state.pcb_sp - 1; - + ksfp = (struct ksigframe *)((char *)p2->p_addr + USPACE) - 1; ksfp->func = func; - ksfp->proc = arg; + ksfp->arg = arg; /* * When this process resumes, r31 will be ksfp and * the process will be at the beginning of proc_trampoline(). * proc_trampoline will execute the function func, pop off - * ksfp frame, and call the function in the switchframe - * now exposed. + * ksfp frame, and resume to userland. */ p2->p_addr->u_pcb.kernel_state.pcb_sp = (u_int)ksfp; |