Date: Mon, 4 Apr 2005 02:50:05 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 74439 for review Message-ID: <200504040250.j342o5l8095807@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=74439 Change 74439 by davidxu@davidxu_celeron on 2005/04/04 02:49:40 Change cpu_set_kse_upcall() to more general prototype. Affected files ... .. //depot/projects/davidxu_thread/src/sys/alpha/alpha/vm_machdep.c#4 edit .. //depot/projects/davidxu_thread/src/sys/amd64/amd64/vm_machdep.c#4 edit .. //depot/projects/davidxu_thread/src/sys/arm/arm/vm_machdep.c#5 edit .. //depot/projects/davidxu_thread/src/sys/i386/i386/vm_machdep.c#4 edit .. //depot/projects/davidxu_thread/src/sys/ia64/ia64/vm_machdep.c#4 edit .. //depot/projects/davidxu_thread/src/sys/kern/kern_kse.c#5 edit .. //depot/projects/davidxu_thread/src/sys/powerpc/powerpc/vm_machdep.c#4 edit .. //depot/projects/davidxu_thread/src/sys/sparc64/sparc64/vm_machdep.c#4 edit .. //depot/projects/davidxu_thread/src/sys/sys/proc.h#11 edit Differences ... ==== //depot/projects/davidxu_thread/src/sys/alpha/alpha/vm_machdep.c#4 (text+ko) ==== @@ -322,15 +322,16 @@ } void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { struct pcb *pcb; struct trapframe *tf; - uint64_t stack; + uint64_t sp; pcb = td->td_pcb; tf = td->td_frame; - stack = ((uint64_t)ku->ku_stack.ss_sp + ku->ku_stack.ss_size) & ~15; + sp = ((uint64_t)stack->ss_sp + stack->ss_size) & ~15; bzero(tf->tf_regs, FRAME_SIZE * sizeof(tf->tf_regs[0])); bzero(&pcb->pcb_fp, sizeof(pcb->pcb_fp)); @@ -338,15 +339,15 @@ pcb->pcb_fp.fpr_cr = FPCR_DYN_NORMAL | FPCR_INVD | FPCR_DZED | FPCR_OVFD | FPCR_INED | FPCR_UNFD; if (td != curthread) { - pcb->pcb_hw.apcb_usp = stack; + pcb->pcb_hw.apcb_usp = sp; pcb->pcb_hw.apcb_unique = 0; } else { - alpha_pal_wrusp(stack); + alpha_pal_wrusp(sp); alpha_pal_wrunique(0); } tf->tf_regs[FRAME_PS] = ALPHA_PSL_USERSET; - tf->tf_regs[FRAME_PC] = (u_long)ku->ku_func; - tf->tf_regs[FRAME_A0] = (u_long)ku->ku_mailbox; + tf->tf_regs[FRAME_PC] = (u_long)entry; + tf->tf_regs[FRAME_A0] = (u_long)arg; tf->tf_regs[FRAME_T12] = tf->tf_regs[FRAME_PC]; /* aka. PV */ tf->tf_regs[FRAME_FLAGS] = 0; /* full restore */ } ==== //depot/projects/davidxu_thread/src/sys/amd64/amd64/vm_machdep.c#4 (text+ko) ==== @@ -302,7 +302,8 @@ * in thread_userret() itself can be done as well. */ void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { /* @@ -320,16 +321,16 @@ */ td->td_frame->tf_rbp = 0; td->td_frame->tf_rsp = - ((register_t)ku->ku_stack.ss_sp + ku->ku_stack.ss_size) & ~0x0f; + ((register_t)stack->ss_sp + stack->ss_size) & ~0x0f; td->td_frame->tf_rsp -= 8; td->td_frame->tf_rbp = 0; - td->td_frame->tf_rip = (register_t)ku->ku_func; + td->td_frame->tf_rip = (register_t)entry; /* * Pass the address of the mailbox for this kse to the uts * function as a parameter on the stack. */ - td->td_frame->tf_rdi = (register_t)ku->ku_mailbox; + td->td_frame->tf_rdi = (register_t)arg; } #ifdef SMP ==== //depot/projects/davidxu_thread/src/sys/arm/arm/vm_machdep.c#5 (text+ko) ==== @@ -271,14 +271,15 @@ * in thread_userret() itself can be done as well. */ void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { struct trapframe *tf = td->td_frame; - tf->tf_usr_sp = ((int)ku->ku_stack.ss_sp + ku->ku_stack.ss_size + tf->tf_usr_sp = ((int)stack->ss_sp + stack->ss_size - sizeof(struct trapframe)) & ~7; - tf->tf_pc = (int)ku->ku_func; - tf->tf_r0 = (int)ku->ku_mailbox; + tf->tf_pc = (int)entry; + tf->tf_r0 = (int)arg; tf->tf_spsr = PSR_USR32_MODE; } ==== //depot/projects/davidxu_thread/src/sys/i386/i386/vm_machdep.c#4 (text+ko) ==== @@ -431,7 +431,8 @@ * in thread_userret() itself can be done as well. */ void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { /* @@ -449,15 +450,15 @@ */ td->td_frame->tf_ebp = 0; td->td_frame->tf_esp = - (int)ku->ku_stack.ss_sp + ku->ku_stack.ss_size - 16; - td->td_frame->tf_eip = (int)ku->ku_func; + (int)stack->ss_sp + stack->ss_size - 16; + td->td_frame->tf_eip = (int)entry; /* * Pass the address of the mailbox for this kse to the uts * function as a parameter on the stack. */ suword((void *)(td->td_frame->tf_esp + sizeof(void *)), - (int)ku->ku_mailbox); + (int)arg); } /* ==== //depot/projects/davidxu_thread/src/sys/ia64/ia64/vm_machdep.c#4 (text+ko) ==== @@ -161,11 +161,12 @@ } void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { struct ia64_fdesc *fd; struct trapframe *tf; - uint64_t ndirty, stack; + uint64_t ndirty, sp; tf = td->td_frame; ndirty = tf->tf_special.ndirty + (tf->tf_special.bspstore & 0x1ffUL); @@ -173,13 +174,13 @@ KASSERT((ndirty & ~PAGE_MASK) == 0, ("Whoa there! We have more than 8KB of dirty registers!")); - fd = ku->ku_func; - stack = (uint64_t)ku->ku_stack.ss_sp; + fd = (struct ia64_fdesc *)entry; + sp = (uint64_t)stack->ss_sp; bzero(&tf->tf_special, sizeof(tf->tf_special)); tf->tf_special.iip = fuword(&fd->func); tf->tf_special.gp = fuword(&fd->gp); - tf->tf_special.sp = (stack + ku->ku_stack.ss_size - 16) & ~15; + tf->tf_special.sp = (sp + stack->ss_size - 16) & ~15; tf->tf_special.rsc = 0xf; tf->tf_special.fpsr = IA64_FPSR_DEFAULT; tf->tf_special.psr = IA64_PSR_IC | IA64_PSR_I | IA64_PSR_IT | @@ -188,19 +189,19 @@ if (tf->tf_flags & FRAME_SYSCALL) { tf->tf_special.cfm = (3UL<<62) | (1UL<<7) | 1UL; - tf->tf_special.bspstore = stack + 8; - suword((caddr_t)stack, (uint64_t)ku->ku_mailbox); + tf->tf_special.bspstore = sp + 8; + suword((caddr_t)sp, (uint64_t)arg); } else { tf->tf_special.cfm = (1UL<<63) | (1UL<<7) | 1UL; - tf->tf_special.bspstore = stack; + tf->tf_special.bspstore = sp; tf->tf_special.ndirty = 8; - stack = td->td_kstack + ndirty - 8; - if ((stack & 0x1ff) == 0x1f8) { - *(uint64_t*)stack = 0; + sp = td->td_kstack + ndirty - 8; + if ((sp & 0x1ff) == 0x1f8) { + *(uint64_t*)sp = 0; tf->tf_special.ndirty += 8; - stack -= 8; + sp -= 8; } - *(uint64_t*)stack = (uint64_t)ku->ku_mailbox; + *(uint64_t*)sp = (uint64_t)arg; } } ==== //depot/projects/davidxu_thread/src/sys/kern/kern_kse.c#5 (text+ko) ==== @@ -780,7 +780,8 @@ * to the new thread, so we should clear single step * flag here. */ - cpu_set_upcall_kse(newtd, newku); + cpu_set_upcall_kse(newtd, newku->ku_func, + newku->ku_mailbox, &newku->ku_stack); if (p->p_flag & P_TRACED) ptrace_clear_single_step(newtd); } @@ -1371,7 +1372,8 @@ * Set user context to the UTS */ if (!(ku->ku_mflags & KMF_NOUPCALL)) { - cpu_set_upcall_kse(td, ku); + cpu_set_upcall_kse(td, ku->ku_func, ku->ku_mailbox, + &ku->ku_stack); if (p->p_flag & P_TRACED) ptrace_clear_single_step(td); error = suword32(&ku->ku_mailbox->km_lwp, ==== //depot/projects/davidxu_thread/src/sys/powerpc/powerpc/vm_machdep.c#4 (text+ko) ==== @@ -325,23 +325,24 @@ } void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { struct trapframe *tf; uint32_t sp; tf = td->td_frame; /* align stack and alloc space for frame ptr and saved LR */ - sp = ((uint32_t)ku->ku_stack.ss_sp + ku->ku_stack.ss_size + sp = ((uint32_t)stack->ss_sp + stack->ss_size - 2*sizeof(u_int32_t)) & ~0x1f; bzero(tf, sizeof(struct trapframe)); tf->fixreg[1] = (register_t)sp; - tf->fixreg[3] = (register_t)ku->ku_mailbox; - tf->srr0 = (register_t)ku->ku_func; + tf->fixreg[3] = (register_t)arg; + tf->srr0 = (register_t)entry; tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT; td->td_pcb->pcb_flags = 0; - td->td_retval[0] = (register_t)ku->ku_func; + td->td_retval[0] = (register_t)entry; td->td_retval[1] = 0; } ==== //depot/projects/davidxu_thread/src/sys/sparc64/sparc64/vm_machdep.c#4 (text+ko) ==== @@ -173,16 +173,17 @@ } void -cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) +cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg, + stack_t *stack) { struct trapframe *tf; uint64_t sp; tf = td->td_frame; - sp = (uint64_t)ku->ku_stack.ss_sp + ku->ku_stack.ss_size; - tf->tf_out[0] = (uint64_t)ku->ku_mailbox; + sp = (uint64_t)stack->ss_sp + stack->ss_size; + tf->tf_out[0] = (uint64_t)arg; tf->tf_out[6] = sp - SPOFF - sizeof(struct frame); - tf->tf_tpc = (uint64_t)ku->ku_func; + tf->tf_tpc = (uint64_t)entry; tf->tf_tnpc = tf->tf_tpc + 4; td->td_retval[0] = tf->tf_out[0]; ==== //depot/projects/davidxu_thread/src/sys/sys/proc.h#11 (text+ko) ==== @@ -890,7 +890,7 @@ void kse_GC(void); void kseinit(void); void cpu_set_upcall(struct thread *td, struct thread *td0); -void cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku); +void cpu_set_upcall_kse(struct thread *, void (*)(void *), void *, stack_t *); void cpu_thread_clean(struct thread *); void cpu_thread_exit(struct thread *); void cpu_thread_setup(struct thread *td);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504040250.j342o5l8095807>