]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/x86_64/cswitch.s
xnu-4903.270.47.tar.gz
[apple/xnu.git] / osfmk / x86_64 / cswitch.s
index 6abb9a22c25e2e9121ec663ed4718da382cdf4b2..cb72f459e30f897538cb9abbfde84d929f6e18c5 100644 (file)
 /*
  */
 
-#include <platforms.h>
 
 #include <i386/asm.h>
 #include <i386/proc_reg.h>
 #include <assym.s>
 
-#ifdef SYMMETRY
-#include <sqt/asm_macros.h>
-#endif
-
-#if    AT386
-#include <i386/mp.h>
-#endif /* AT386 */
-
 Entry(Load_context)
        movq    TH_KERNEL_STACK(%rdi),%rcx      /* get kernel stack */
-       leaq    -IKS_SIZE-IEL_SIZE(%rcx),%rdx
+       leaq    -IKS_SIZE(%rcx),%rdx
        addq    EXT(kernel_stack_size)(%rip),%rdx /* point to stack top */
        movq    %rcx,%gs:CPU_ACTIVE_STACK       /* store stack address */
        movq    %rdx,%gs:CPU_KERNEL_STACK       /* store stack top */
 
        movq    %rdx,%rsp
-       movq    %rdx,%rbp
+       xorl    %ebp, %ebp
 
-       xorq    %rdi,%rdi                       /* return zero (no old thread) */
+       xorl    %edi,%edi                       /* return zero (no old thread) */
        call    EXT(thread_continue)
 
 
@@ -110,7 +101,7 @@ Entry(Switch_context)
        /* new thread in %rdx */
        movq    %rdx,%gs:CPU_ACTIVE_THREAD      /* new thread is active */
        movq    TH_KERNEL_STACK(%rdx),%rdx      /* get its kernel stack */
-       lea     -IKS_SIZE-IEL_SIZE(%rdx),%rcx
+       lea     -IKS_SIZE(%rdx),%rcx
        add     EXT(kernel_stack_size)(%rip),%rcx /* point to stack top */
 
        movq    %rdx,%gs:CPU_ACTIVE_STACK       /* set current stack */
@@ -127,7 +118,7 @@ Entry(Switch_context)
 
 
 Entry(Thread_continue)
-       movq    %rax, %rdi                      /* load thread argument */
+       movq    %rax, %rdi                      /* this is the old thread from Switch_context */
        xorq    %rbp,%rbp                       /* zero frame pointer */
        call    *%rbx                           /* call real continuation */
 
@@ -161,6 +152,9 @@ Entry(Shutdown_context)
 
        movq    %gs:CPU_INT_STACK_TOP,%rsp      /* switch to interrupt stack */
 
+       movq    %rsp, %gs:CPU_ACTIVE_STACK
+       movq    EXT(kernel_stack_size)(%rip),%rcx /* point to stack top */
+       subq    %rcx, %gs:CPU_ACTIVE_STACK
        movq    %rdx,%rdi                       /* processor arg to routine */
        call    *%rsi                           /* call routine to run */
        hlt                                     /* (should never return) */