mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 21:36:11 +00:00
{KERNEL32]
- move BaseFiberStartup to fiber.S - add FPO debug info for MSVC builds - remove excessive END directives (fixes msvc build) - add a stub for amd64 svn path=/trunk/; revision=52810
This commit is contained in:
parent
09a15b8b05
commit
1476736018
3 changed files with 46 additions and 31 deletions
|
@ -1,19 +1,27 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: lib/kernel32/thread/i386/fiber.S
|
* FILE: dll/win32//kernel32/client/amd64/fiber.S
|
||||||
* PURPOSE: Fiber context switch code for the x86 architecture
|
* PURPOSE: Fiber context switch code for the amd64 architecture
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
* PROGRAMMER:
|
||||||
* KJK::Hyperion <noog@libero.it>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <asm.inc>
|
#include <asm.inc>
|
||||||
|
|
||||||
|
PUBLIC BaseFiberStartup
|
||||||
|
.PROC BaseFiberStartup
|
||||||
|
UNIMPLEMENTED BaseFiberStartup
|
||||||
|
/* FIXME: TODO */
|
||||||
|
ret
|
||||||
|
|
||||||
|
.ENDP BaseFiberStartup
|
||||||
|
|
||||||
|
|
||||||
PUBLIC SwitchToFiber
|
PUBLIC SwitchToFiber
|
||||||
|
|
||||||
SwitchToFiber:
|
SwitchToFiber:
|
||||||
|
UNIMPLEMENTED BaseFiberStartup
|
||||||
/* FIXME: TODO */
|
/* FIXME: TODO */
|
||||||
ret 4
|
ret
|
||||||
|
|
||||||
END
|
END
|
||||||
|
|
|
@ -10,16 +10,32 @@
|
||||||
#include <asm.inc>
|
#include <asm.inc>
|
||||||
#include <ks386.inc>
|
#include <ks386.inc>
|
||||||
|
|
||||||
|
EXTERN _BaseThreadStartup@8:PROC
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
|
PUBLIC _BaseFiberStartup@0
|
||||||
|
.PROC BaseFiberStartup@0
|
||||||
|
/* Frame pointer is zeroed */
|
||||||
|
FPO 0, 0, 0, 0, 0, FRAME_FPO
|
||||||
|
|
||||||
|
/* Get the fiber data */
|
||||||
|
mov eax, fs:[TEB_FIBER_DATA]
|
||||||
|
|
||||||
|
push dword ptr [eax+FIBER_CONTEXT_EBX] /* Parameter */
|
||||||
|
push dword ptr [eax+FIBER_CONTEXT_EAX] /* Start Address */
|
||||||
|
call _BaseThreadStartup@8
|
||||||
|
.ENDP BaseFiberStartup@0
|
||||||
|
|
||||||
|
|
||||||
PUBLIC _SwitchToFiber@4
|
PUBLIC _SwitchToFiber@4
|
||||||
_SwitchToFiber@4:
|
_SwitchToFiber@4:
|
||||||
/* Get the TEB */
|
/* Get the TEB */
|
||||||
mov edx, fs:[TEB_SELF]
|
mov edx, fs:[TEB_SELF]
|
||||||
|
|
||||||
/* Get the Fiber */
|
/* Get the Fiber */
|
||||||
mov eax, [edx+TEB_FIBER_DATA]
|
mov eax, [edx+TEB_FIBER_DATA]
|
||||||
|
|
||||||
/* Save the non-volatile registers */
|
/* Save the non-volatile registers */
|
||||||
mov [eax+FIBER_CONTEXT_EBX], ebx
|
mov [eax+FIBER_CONTEXT_EBX], ebx
|
||||||
mov [eax+FIBER_CONTEXT_ESI], esi
|
mov [eax+FIBER_CONTEXT_ESI], esi
|
||||||
|
@ -29,27 +45,27 @@ _SwitchToFiber@4:
|
||||||
/* Check if we're to save FPU State */
|
/* Check if we're to save FPU State */
|
||||||
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT
|
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT
|
||||||
jnz NoFpuStateSave
|
jnz NoFpuStateSave
|
||||||
|
|
||||||
/* Save the FPU State (Status and Control)*/
|
/* Save the FPU State (Status and Control)*/
|
||||||
fstsw [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
fstsw [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||||
fnstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
fnstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||||
|
|
||||||
/* Check if the CPU supports SIMD MXCSR State Save */
|
/* Check if the CPU supports SIMD MXCSR State Save */
|
||||||
cmp byte ptr ds:[PF_XMMI_INSTRUCTIONS_AVAILABLE], 1
|
cmp byte ptr ds:[PF_XMMI_INSTRUCTIONS_AVAILABLE], 1
|
||||||
jnz NoFpuStateSave
|
jnz NoFpuStateSave
|
||||||
stmxcsr [eax+FIBER_CONTEXT_DR6]
|
stmxcsr [eax+FIBER_CONTEXT_DR6]
|
||||||
|
|
||||||
NoFpuStateSave:
|
NoFpuStateSave:
|
||||||
|
|
||||||
/* Save stack since we're not touching it anymore */
|
/* Save stack since we're not touching it anymore */
|
||||||
mov [eax+FIBER_CONTEXT_ESP], esp
|
mov [eax+FIBER_CONTEXT_ESP], esp
|
||||||
|
|
||||||
/* Transfer some data from the TEB */
|
/* Transfer some data from the TEB */
|
||||||
mov ecx, [edx+TEB_FLS_DATA]
|
mov ecx, [edx+TEB_FLS_DATA]
|
||||||
mov [eax+FIBER_FLS_DATA], ecx
|
mov [eax+FIBER_FLS_DATA], ecx
|
||||||
mov ecx, [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER]
|
mov ecx, [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER]
|
||||||
mov [eax+FIBER_ACTIVATION_CONTEXT_STACK], ecx
|
mov [eax+FIBER_ACTIVATION_CONTEXT_STACK], ecx
|
||||||
|
|
||||||
/* Transfer some data related to the Stack */
|
/* Transfer some data related to the Stack */
|
||||||
mov ecx, [edx+TEB_EXCEPTION_LIST]
|
mov ecx, [edx+TEB_EXCEPTION_LIST]
|
||||||
mov [eax+FIBER_EXCEPTION_LIST], ecx
|
mov [eax+FIBER_EXCEPTION_LIST], ecx
|
||||||
|
@ -57,11 +73,11 @@ NoFpuStateSave:
|
||||||
mov [eax+FIBER_STACK_LIMIT], ecx
|
mov [eax+FIBER_STACK_LIMIT], ecx
|
||||||
mov ecx, [edx+TEB_GUARANTEED_STACK_BYTES]
|
mov ecx, [edx+TEB_GUARANTEED_STACK_BYTES]
|
||||||
mov [eax+FIBER_GUARANTEED_STACK_BYTES], ecx
|
mov [eax+FIBER_GUARANTEED_STACK_BYTES], ecx
|
||||||
|
|
||||||
/* Switch to the new fiber */
|
/* Switch to the new fiber */
|
||||||
mov ecx, [esp+4]
|
mov ecx, [esp+4]
|
||||||
mov [edx+TEB_FIBER_DATA], ecx
|
mov [edx+TEB_FIBER_DATA], ecx
|
||||||
|
|
||||||
/* Switch Fiber Data */
|
/* Switch Fiber Data */
|
||||||
mov esi, [ecx+FIBER_EXCEPTION_LIST]
|
mov esi, [ecx+FIBER_EXCEPTION_LIST]
|
||||||
mov [edx+TEB_EXCEPTION_LIST], esi
|
mov [edx+TEB_EXCEPTION_LIST], esi
|
||||||
|
@ -75,34 +91,34 @@ NoFpuStateSave:
|
||||||
mov [edx+TEB_GUARANTEED_STACK_BYTES], esi
|
mov [edx+TEB_GUARANTEED_STACK_BYTES], esi
|
||||||
mov esi, [ecx+FIBER_ACTIVATION_CONTEXT_STACK]
|
mov esi, [ecx+FIBER_ACTIVATION_CONTEXT_STACK]
|
||||||
mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi
|
mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi
|
||||||
|
|
||||||
/* Restore FPU State */
|
/* Restore FPU State */
|
||||||
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT
|
cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL OR CONTEXT_FLOATING_POINT
|
||||||
jnz NoFpuStateRestore
|
jnz NoFpuStateRestore
|
||||||
|
|
||||||
/* Check if the Status Word Changed */
|
/* Check if the Status Word Changed */
|
||||||
mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||||
cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD]
|
||||||
jnz StatusWordChanged
|
jnz StatusWordChanged
|
||||||
|
|
||||||
/* Check if the Control Word Changed */
|
/* Check if the Control Word Changed */
|
||||||
mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||||
cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||||
jz ControlWordEqual
|
jz ControlWordEqual
|
||||||
|
|
||||||
StatusWordChanged:
|
StatusWordChanged:
|
||||||
|
|
||||||
/* Load the new one */
|
/* Load the new one */
|
||||||
mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], HEX(0FFFF)
|
mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], HEX(0FFFF)
|
||||||
fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD]
|
||||||
|
|
||||||
ControlWordEqual:
|
ControlWordEqual:
|
||||||
|
|
||||||
/* Load the new one */
|
/* Load the new one */
|
||||||
cmp byte ptr ds:[PF_XMMI_INSTRUCTIONS_AVAILABLE], 1
|
cmp byte ptr ds:[PF_XMMI_INSTRUCTIONS_AVAILABLE], 1
|
||||||
jnz NoFpuStateRestore
|
jnz NoFpuStateRestore
|
||||||
ldmxcsr [ecx+FIBER_CONTEXT_DR6]
|
ldmxcsr [ecx+FIBER_CONTEXT_DR6]
|
||||||
|
|
||||||
NoFpuStateRestore:
|
NoFpuStateRestore:
|
||||||
|
|
||||||
/* Restore non-volatile registers */
|
/* Restore non-volatile registers */
|
||||||
|
@ -111,7 +127,7 @@ NoFpuStateRestore:
|
||||||
mov ebx, [ecx+FIBER_CONTEXT_EBX]
|
mov ebx, [ecx+FIBER_CONTEXT_EBX]
|
||||||
mov ebp, [ecx+FIBER_CONTEXT_EBP]
|
mov ebp, [ecx+FIBER_CONTEXT_EBP]
|
||||||
mov esp, [ecx+FIBER_CONTEXT_ESP]
|
mov esp, [ecx+FIBER_CONTEXT_ESP]
|
||||||
|
|
||||||
/* Restore FLS Data */
|
/* Restore FLS Data */
|
||||||
mov eax, [ecx+FIBER_FLS_DATA]
|
mov eax, [ecx+FIBER_FLS_DATA]
|
||||||
mov [edx+TEB_FLS_DATA], eax
|
mov [edx+TEB_FLS_DATA], eax
|
||||||
|
|
|
@ -24,7 +24,7 @@ _BaseThreadStartupThunk@0:
|
||||||
push eax /* lpStartAddress */
|
push eax /* lpStartAddress */
|
||||||
push 0 /* Return EIP */
|
push 0 /* Return EIP */
|
||||||
jmp _BaseThreadStartup@8
|
jmp _BaseThreadStartup@8
|
||||||
END
|
|
||||||
|
|
||||||
PUBLIC _BaseProcessStartThunk@0
|
PUBLIC _BaseProcessStartThunk@0
|
||||||
_BaseProcessStartThunk@0:
|
_BaseProcessStartThunk@0:
|
||||||
|
@ -35,16 +35,7 @@ _BaseProcessStartThunk@0:
|
||||||
push 0 /* Return EIP */
|
push 0 /* Return EIP */
|
||||||
jmp _BaseProcessStartup@4
|
jmp _BaseProcessStartup@4
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
PUBLIC _BaseFiberStartup@0
|
|
||||||
_BaseFiberStartup@0:
|
|
||||||
/* Get the fiber data */
|
|
||||||
mov eax, fs:[TEB_FIBER_DATA]
|
|
||||||
|
|
||||||
push dword ptr [eax+FIBER_CONTEXT_EBX] /* Parameter */
|
|
||||||
push dword ptr [eax+FIBER_CONTEXT_EAX] /* Start Address */
|
|
||||||
call _BaseThreadStartup@8
|
|
||||||
END
|
END
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue