3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/thread/i386/fiber.S
6 * PURPOSE: Fiber context switch code for the x86 architecture
7 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
10 * 28/05/2003 - created
16 .globl _SwitchToFiber@4
20 "(KERNEL32:" __FILE__ ") Saving and restoring the floating point context \
21 currently unimplemented\n\0"
25 movl %fs:0x18, %ecx /* Teb = NtCurrentTeb() */
27 /* get the current fiber */
28 movl 0x10(%ecx), %eax /* Fiber = Teb->Tib.Fib.FiberData */
30 /* store the volatile context of the current fiber */
32 movl %edx, 0x4(%eax) /* Fiber->ExceptionList = Teb->ExceptionList */
34 movl %edx, 0x8(%eax) /* Fiber->StackBase = Teb->StackBase */
36 movl %edx, 0xC(%eax) /* Fiber->StackLimit = Teb->StackLimit */
37 movl 0xE0C(%ecx), %edx
38 movl %edx, 0x10(%eax) /* Fiber->StackBottom = Teb->DeallocationStack */
40 movl %edx, 0x18(%eax) /* Fiber->Eip = [esp + 0] */
43 movl %edx, 0x1C(%eax) /* Fiber->Esp = esp + 8 */
44 movl %ebp, 0x20(%eax) /* Fiber->Ebp = ebp */
45 movl %ebx, 0x24(%eax) /* Fiber->Ebx = ebx */
46 movl %esi, 0x28(%eax) /* Fiber->Esi = edi */
47 movl %edi, 0x2C(%eax) /* Fiber->Edi = esi */
52 /* save the floating point context */
60 /* switch to the specified fiber */
61 movl 0x4(%esp), %eax /* Fiber = lpFiber */
62 movl %eax, 0x10(%ecx) /* Teb->Tib.FiberData = Fiber */
64 /* restore the volatile context of the specified fiber */
66 movl %edx, 0x0(%ecx) /* Teb->ExceptionList = Fiber->ExceptionList */
68 movl %edx, 0x4(%ecx) /* Teb->StackBase = Fiber->StackBase */
70 movl %edx, 0x8(%ecx) /* Teb->StackLimit = Fiber->StackLimit */
72 movl %edx, 0xE0C(%ecx) /* Teb->StackBottom = Fiber->DeallocationStack */
73 movl 0x18(%eax), %edx /* edx = Fiber->Eip */
74 movl 0x1C(%eax), %esp /* esp = Fiber->Esp */
75 movl 0x20(%eax), %ebp /* ebp = Fiber->Ebp */
76 movl 0x24(%eax), %ebx /* ebx = Fiber->Ebx */
77 movl 0x28(%eax), %esi /* esi = Fiber->Esi */
78 movl 0x2C(%eax), %edi /* edi = Fiber->Edi */
83 /* restore the floating point context */
91 /* jump to the saved program counter */