Adjust indentation for .globl directives.
[pintos-anon] / src / threads / switch.S
index a7c27fb03eb8fc3cb73ccee19f07ef21438d61ea..c077e46d590202ef5156ab0d9084d1ea28e6afe2 100644 (file)
@@ -1,10 +1,7 @@
-#### 0(%esp) - old registers
-#### 16(%esp) - return address
-#### 20(%esp) - current thread
-#### 24(%esp) - new thread
+#include "switch.h"
 
-        .globl thread_switch 
-thread_switch:
+.globl switch_threads 
+switch_threads:
        # Save caller's register state.
        # Note that the SVR4 ABI allows us to destroy %eax, %ecx, %edx.
        # This stack frame must match the one set up by thread_create().
@@ -14,18 +11,18 @@ thread_switch:
        pushl %edi
 
        # Get offsetof (struct thread, stack).
-       .globl thread_stack_ofs
+.globl thread_stack_ofs
        mov thread_stack_ofs, %edx
 
        # Save current stack pointer to old thread's stack, if any.
-       movl 20(%esp), %eax
+       movl SWITCH_CUR(%esp), %eax
        test %eax, %eax
        jz 1f
        movl %esp, (%eax,%edx,1)
 1:
 
        # Restore stack pointer from new thread's stack.
-       movl 24(%esp), %ecx
+       movl SWITCH_NEXT(%esp), %ecx
        movl (%ecx,%edx,1), %esp
 
        # Restore caller's register state.
@@ -34,3 +31,17 @@ thread_switch:
        popl %ebp
        popl %ebx
         ret
+
+.globl switch_entry
+switch_entry:
+       # Discard thread_switch() arguments.
+       addl $8, %esp
+
+       # Call schedule_tail(prev).
+       pushl %eax
+.globl schedule_tail
+       call schedule_tail
+       addl $4, %esp
+
+       # Start thread proper.
+       ret