Date: Fri, 4 Apr 2003 21:13:48 -0800 (PST) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 28172 for review Message-ID: <200304050513.h355Dmfe014040@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28172 Change 28172 by peter@peter_overcee on 2003/04/04 21:13:22 make cpu_switch assemble. Still needs regparm work. needs to do rest of saved registers. Needs PCB_E* renamed to PCB_R* Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/swtch.s#11 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/swtch.s#11 (text+ko) ==== @@ -54,28 +54,29 @@ * about its state. This is only a slight optimization and is probably * not worth it anymore. Note that we need to clear the pm_active bits so * we do need the old proc if it still exists. - * 0(%esp) = ret - * 4(%esp) = oldtd - * 8(%esp) = newtd + * 0(%rsp) = ret + * 8(%rsp) = oldtd + * 16(%rsp) = newtd */ ENTRY(cpu_throw) + xorq %rsi, %rsi movl PCPU(CPUID), %esi - movl 4(%esp),%ecx /* Old thread */ - testl %ecx,%ecx /* no thread? */ + movq 8(%rsp),%rcx /* Old thread */ + testq %rcx,%rcx /* no thread? */ jz 1f /* release bit from old pm_active */ - movl TD_PROC(%ecx), %eax /* thread->td_proc */ - movl P_VMSPACE(%eax), %ebx /* proc->p_vmspace */ - btrl %esi, VM_PMAP+PM_ACTIVE(%ebx) /* clear old */ + movq TD_PROC(%rcx), %rax /* thread->td_proc */ + movq P_VMSPACE(%rax), %rbx /* proc->p_vmspace */ + btrq %rsi, VM_PMAP+PM_ACTIVE(%rbx) /* clear old */ 1: - movl 8(%esp),%ecx /* New thread */ - movl TD_PCB(%ecx),%edx - movl PCB_CR3(%edx),%eax - movl %eax,%cr3 /* new address space */ + movq 16(%rsp),%rcx /* New thread */ + movq TD_PCB(%rcx),%rdx + movq PCB_CR3(%rdx),%rax + movq %rax,%cr3 /* new address space */ /* set bit in new pm_active */ - movl TD_PROC(%ecx),%eax - movl P_VMSPACE(%eax), %ebx - btsl %esi, VM_PMAP+PM_ACTIVE(%ebx) /* set new */ + movq TD_PROC(%rcx),%rax + movq P_VMSPACE(%rax), %rbx + btsq %rsi, VM_PMAP+PM_ACTIVE(%rbx) /* set new */ jmp sw1 /* @@ -83,65 +84,66 @@ * * Save the current thread state, then select the next thread to run * and load its state. - * 0(%esp) = ret - * 4(%esp) = oldtd - * 8(%esp) = newtd + * 0(%rsp) = ret + * 8(%rsp) = oldtd + * 16(%rsp) = newtd */ ENTRY(cpu_switch) /* Switch to new thread. First, save context. */ - movl 4(%esp),%ecx + movq 8(%rsp),%rcx #ifdef INVARIANTS - testl %ecx,%ecx /* no thread? */ + testq %rcx,%rcx /* no thread? */ jz badsw2 /* no, panic */ #endif - movl TD_PCB(%ecx),%edx + movq TD_PCB(%rcx),%rdx - movl (%esp),%eax /* Hardware registers */ - movl %eax,PCB_EIP(%edx) - movl %ebx,PCB_EBX(%edx) - movl %esp,PCB_ESP(%edx) - movl %ebp,PCB_EBP(%edx) - movl %esi,PCB_ESI(%edx) - movl %edi,PCB_EDI(%edx) - movl %gs,PCB_GS(%edx) - pushfl /* PSL */ - popl PCB_PSL(%edx) + movq (%rsp),%rax /* Hardware registers */ + movq %rax,PCB_EIP(%rdx) + movq %rbx,PCB_EBX(%rdx) + movq %rsp,PCB_ESP(%rdx) + movq %rbp,PCB_EBP(%rdx) + movq %rsi,PCB_ESI(%rdx) + movq %rdi,PCB_EDI(%rdx) +#XXX movq %gs,PCB_GS(%rdx) + pushfq /* PSL */ + popq PCB_PSL(%rdx) /* have we used fp, and need a save? */ - cmpl %ecx,PCPU(FPCURTHREAD) + cmpq %rcx,PCPU(FPCURTHREAD) jne 1f - addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */ - pushl %edx + addq $PCB_SAVEFPU,%rdx /* h/w bugs make saving complicated */ + pushq %rdx call npxsave /* do it in a big C function */ - popl %eax + popq %rax 1: /* Save is done. Now fire up new thread. Leave old vmspace. */ - movl %ecx,%edi - movl 8(%esp),%ecx /* New thread */ + movq %rcx,%rdi + movq 16(%rsp),%rcx /* New thread */ #ifdef INVARIANTS - testl %ecx,%ecx /* no thread? */ + testq %rcx,%rcx /* no thread? */ jz badsw3 /* no, panic */ #endif - movl TD_PCB(%ecx),%edx + movq TD_PCB(%rcx),%rdx + xorq %rsi, %rsi movl PCPU(CPUID), %esi /* switch address space */ - movl PCB_CR3(%edx),%eax - movl %eax,%cr3 /* new address space */ + movq PCB_CR3(%rdx),%rax + movq %rax,%cr3 /* new address space */ /* Release bit from old pmap->pm_active */ - movl TD_PROC(%edi), %eax /* oldproc */ - movl P_VMSPACE(%eax), %ebx - btrl %esi, VM_PMAP+PM_ACTIVE(%ebx) /* clear old */ + movq TD_PROC(%rdi), %rax /* oldproc */ + movq P_VMSPACE(%rax), %rbx + btrq %rsi, VM_PMAP+PM_ACTIVE(%rbx) /* clear old */ /* Set bit in new pmap->pm_active */ - movl TD_PROC(%ecx),%eax /* newproc */ - movl P_VMSPACE(%eax), %ebx - btsl %esi, VM_PMAP+PM_ACTIVE(%ebx) /* set new */ + movq TD_PROC(%rcx),%rax /* newproc */ + movq P_VMSPACE(%rax), %rbx + btsq %rsi, VM_PMAP+PM_ACTIVE(%rbx) /* set new */ sw1: /* @@ -149,41 +151,83 @@ * to load up the rest of the next context. */ /* Restore context. */ - movl PCB_EBX(%edx),%ebx - movl PCB_ESP(%edx),%esp - movl PCB_EBP(%edx),%ebp - movl PCB_ESI(%edx),%esi - movl PCB_EDI(%edx),%edi - movl PCB_EIP(%edx),%eax - movl %eax,(%esp) - pushl PCB_PSL(%edx) - popfl + movq PCB_EBX(%rdx),%rbx + movq PCB_ESP(%rdx),%rsp + movq PCB_EBP(%rdx),%rbp + movq PCB_ESI(%rdx),%rsi + movq PCB_EDI(%rdx),%rdi + movq PCB_EIP(%rdx),%rax + movq %rax,(%rsp) + pushq PCB_PSL(%rdx) + popfq - movl %edx, PCPU(CURPCB) - movl %ecx, PCPU(CURTHREAD) /* into next thread */ + movq %rdx, PCPU(CURPCB) + movq %rcx, PCPU(CURTHREAD) /* into next thread */ .globl cpu_switch_load_gs cpu_switch_load_gs: - movl PCB_GS(%edx),%gs +#XXX movq PCB_GS(%rdx),%gs ret #ifdef INVARIANTS badsw1: - pushal - pushl $sw0_1 + pushq %rax + pushq %rcx + pushq %rdx + pushq %rbx + pushq %rbp + pushq %rsi + pushq %rdi + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + pushq $sw0_1 call panic sw0_1: .asciz "cpu_throw: no newthread supplied" badsw2: - pushal - pushl $sw0_2 + pushq %rax + pushq %rcx + pushq %rdx + pushq %rbx + pushq %rbp + pushq %rsi + pushq %rdi + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + pushq $sw0_2 call panic sw0_2: .asciz "cpu_switch: no curthread supplied" badsw3: - pushal - pushl $sw0_3 + pushq %rax + pushq %rcx + pushq %rdx + pushq %rbx + pushq %rbp + pushq %rsi + pushq %rdi + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + pushq $sw0_3 call panic sw0_3: .asciz "cpu_switch: no newthread supplied" #endif @@ -194,23 +238,23 @@ */ ENTRY(savectx) /* Fetch PCB. */ - movl 4(%esp),%ecx + movq 8(%rsp),%rcx /* Save caller's return address. Child won't execute this routine. */ - movl (%esp),%eax - movl %eax,PCB_EIP(%ecx) + movq (%rsp),%rax + movq %rax,PCB_EIP(%rcx) - movl %cr3,%eax - movl %eax,PCB_CR3(%ecx) + movq %cr3,%rax + movq %rax,PCB_CR3(%rcx) - movl %ebx,PCB_EBX(%ecx) - movl %esp,PCB_ESP(%ecx) - movl %ebp,PCB_EBP(%ecx) - movl %esi,PCB_ESI(%ecx) - movl %edi,PCB_EDI(%ecx) - movl %gs,PCB_GS(%ecx) - pushfl - popl PCB_PSL(%ecx) + movq %rbx,PCB_EBX(%rcx) + movq %rsp,PCB_ESP(%rcx) + movq %rbp,PCB_EBP(%rcx) + movq %rsi,PCB_ESI(%rcx) + movq %rdi,PCB_EDI(%rcx) +#XXX movq %gs,PCB_GS(%rcx) + pushfq + popq PCB_PSL(%rcx) /* * If fpcurthread == NULL, then the npx h/w state is irrelevant and the @@ -224,29 +268,29 @@ * have to handle h/w bugs for reloading. We used to lose the * parent's npx state for forks by forgetting to reload. */ - pushfl + pushfq cli - movl PCPU(FPCURTHREAD),%eax - testl %eax,%eax + movq PCPU(FPCURTHREAD),%rax + testq %rax,%rax je 1f - pushl %ecx - movl TD_PCB(%eax),%eax - leal PCB_SAVEFPU(%eax),%eax - pushl %eax - pushl %eax + pushq %rcx + movq TD_PCB(%rax),%rax + leaq PCB_SAVEFPU(%rax),%rax + pushq %rax + pushq %rax call npxsave - addl $4,%esp - popl %eax - popl %ecx + addq $8,%rsp + popq %rax + popq %rcx - pushl $PCB_SAVEFPU_SIZE - leal PCB_SAVEFPU(%ecx),%ecx - pushl %ecx - pushl %eax + pushq $PCB_SAVEFPU_SIZE + leaq PCB_SAVEFPU(%rcx),%rcx + pushq %rcx + pushq %rax call bcopy - addl $12,%esp + addq $24,%rsp 1: - popfl + popfq ret
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304050513.h355Dmfe014040>