From 1d619ca266205cf73b4b1b89f7e997de702e80c8 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Sun, 26 Oct 2008 14:45:13 +0000 Subject: [PATCH] - Fix function definitions to match header changes - Don't use x86 fiber assembly for amd64, just stub it out completely - Use AMD64 definitions in BasepInitializeContext, and add a broken KGDT_64_R3_TEB svn path=/branches/ros-amd64-bringup/; revision=36990 --- reactos/dll/win32/kernel32/misc/utils.c | 10 +- reactos/dll/win32/kernel32/process/proc.c | 6 +- .../dll/win32/kernel32/thread/amd64/fiber.S | 109 +----------------- reactos/include/ndk/amd64/ketypes.h | 1 + 4 files changed, 10 insertions(+), 116 deletions(-) diff --git a/reactos/dll/win32/kernel32/misc/utils.c b/reactos/dll/win32/kernel32/misc/utils.c index 49c52e6d1ef..0a61194a821 100644 --- a/reactos/dll/win32/kernel32/misc/utils.c +++ b/reactos/dll/win32/kernel32/misc/utils.c @@ -386,11 +386,11 @@ BasepInitializeContext(IN PCONTEXT Context, /* The other registers are undefined */ /* Setup the Segments */ - Context->SegFs = KGDT_R3_TEB | RPL_MASK; - Context->SegEs = KGDT_R3_DATA | RPL_MASK; - Context->SegDs = KGDT_R3_DATA | RPL_MASK; - Context->SegCs = KGDT_R3_CODE | RPL_MASK; - Context->SegSs = KGDT_R3_DATA | RPL_MASK; + Context->SegFs = KGDT_64_R3_TEB | RPL_MASK; + Context->SegEs = KGDT_64_DATA | RPL_MASK; + Context->SegDs = KGDT_64_DATA | RPL_MASK; + Context->SegCs = KGDT_64_R3_CODE | RPL_MASK; + Context->SegSs = KGDT_64_DATA | RPL_MASK; Context->SegGs = 0; /* Set the EFLAGS */ diff --git a/reactos/dll/win32/kernel32/process/proc.c b/reactos/dll/win32/kernel32/process/proc.c index 7fe90e6844a..f86cf80f537 100644 --- a/reactos/dll/win32/kernel32/process/proc.c +++ b/reactos/dll/win32/kernel32/process/proc.c @@ -33,8 +33,8 @@ RegisterWaitForInputIdle(WaitForInputIdleType lpfnRegisterWaitForInputIdle); */ BOOL STDCALL GetProcessAffinityMask (HANDLE hProcess, - LPDWORD lpProcessAffinityMask, - LPDWORD lpSystemAffinityMask) + PDWORD_PTR lpProcessAffinityMask, + PDWORD_PTR lpSystemAffinityMask) { PROCESS_BASIC_INFORMATION ProcessInfo; SYSTEM_BASIC_INFORMATION SystemInfo; @@ -73,7 +73,7 @@ GetProcessAffinityMask (HANDLE hProcess, */ BOOL STDCALL SetProcessAffinityMask (HANDLE hProcess, - DWORD dwProcessAffinityMask) + DWORD_PTR dwProcessAffinityMask) { NTSTATUS Status; diff --git a/reactos/dll/win32/kernel32/thread/amd64/fiber.S b/reactos/dll/win32/kernel32/thread/amd64/fiber.S index 233174bcf78..ed500c6c468 100644 --- a/reactos/dll/win32/kernel32/thread/amd64/fiber.S +++ b/reactos/dll/win32/kernel32/thread/amd64/fiber.S @@ -9,116 +9,9 @@ #include -#define CONTEXT_FULL 0x10007 -#define CONTEXT_FLOATING_POINT 0xF - .globl _SwitchToFiber .intel_syntax noprefix _SwitchToFiber: - /* Get the TEB */ - mov edx, fs:[KGDT_R3_TEB] - - /* Get the Fiber */ - mov eax, [edx+TEB_FIBER_DATA] - - /* Save the non-volatile registers */ - mov [eax+FIBER_CONTEXT_EBX], ebx - mov [eax+FIBER_CONTEXT_ESI], esi - mov [eax+FIBER_CONTEXT_EDI], edi - mov [eax+FIBER_CONTEXT_EBP], ebp - - /* Check if we're to save FPU State */ - cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL + CONTEXT_FLOATING_POINT - jnz NoFpuStateSave - - /* Save the FPU State (Status and Control)*/ - fstsw [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD] - fstcw [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] - - /* Check if the CPU supports SIMD MXCSR State Save */ - cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 0 - jnz NoFpuStateSave - stmxcsr [eax+FIBER_CONTEXT_DR6] - -NoFpuStateSave: - - /* Save stack since we're not touching it anymore */ - mov [eax+FIBER_CONTEXT_ESP], esp - - /* Transfer some data from the TEB */ - mov ecx, [edx+TEB_FLS_DATA] - mov [eax+FIBER_FLS_DATA], ecx - mov ecx, [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER] - mov [eax+FIBER_ACTIVATION_CONTEXT_STACK], ecx - - /* Transfer some data related to the Stack */ - mov ecx, [edx+TEB_EXCEPTION_LIST] - mov [eax+FIBER_EXCEPTION_LIST], ecx - mov ecx, [edx+TEB_STACK_LIMIT] - mov [eax+FIBER_STACK_LIMIT], ecx - mov ecx, [edx+TEB_GUARANTEED_STACK_BYTES] - mov [eax+FIBER_GUARANTEED_STACK_BYTES], ecx - - /* Switch to the new fiber */ - mov ecx, [esp+4] - mov [edx+TEB_FIBER_DATA], ecx - - /* Switch Fiber Data */ - mov esi, [ecx+FIBER_EXCEPTION_LIST] - mov [edx+TEB_EXCEPTION_LIST], esi - mov esi, [ecx+FIBER_STACK_BASE] - mov [edx+TEB_STACK_BASE], esi - mov esi, [ecx+FIBER_STACK_LIMIT] - mov [edx+TEB_STACK_LIMIT], esi - mov esi, [ecx+FIBER_DEALLOCATION_STACK] - mov [edx+TEB_DEALLOCATION_STACK], esi - mov esi, [ecx+FIBER_GUARANTEED_STACK_BYTES] - mov [edx+TEB_GUARANTEED_STACK_BYTES], esi - mov esi, [ecx+FIBER_ACTIVATION_CONTEXT_STACK] - mov [edx+TEB_ACTIVATION_CONTEXT_STACK_POINTER], esi - - /* Restore FPU State */ - cmp dword ptr [eax+FIBER_CONTEXT_FLAGS], CONTEXT_FULL + CONTEXT_FLOATING_POINT - jnz NoFpuStateRestore - - /* Check if the Status Word Changed */ - mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD] - cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_STATUS_WORD] - jnz StatusWordChanged - - /* Check if the Control Word Changed */ - mov esi, [eax+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] - cmp si, word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] - jz ControlWordEqual - -StatusWordChanged: - - /* Load the new one */ - mov word ptr [ecx+FIBER_CONTEXT_FLOAT_SAVE_TAG_WORD], 0xFFFF - fldenv [ecx+FIBER_CONTEXT_FLOAT_SAVE_CONTROL_WORD] - -ControlWordEqual: - - /* Load the new one */ - cmp byte ptr ds:[PROCESSOR_FEATURE_FXSR], 0 - jnz NoFpuStateRestore - ldmxcsr [ecx+FIBER_CONTEXT_DR6] - -NoFpuStateRestore: - - /* Restore non-volatile registers */ - mov esi, [ecx+FIBER_CONTEXT_ESI] - mov edi, [ecx+FIBER_CONTEXT_EDI] - mov ebx, [ecx+FIBER_CONTEXT_EBX] - mov ebp, [ecx+FIBER_CONTEXT_EBP] - mov esp, [ecx+FIBER_CONTEXT_ESP] - - /* Restore FLS Data */ - mov eax, [ecx+FIBER_FLS_DATA] - mov [edx+TEB_FLS_DATA], eax - - /* Return */ + /* FIXME: TODO */ ret 4 - -/* EOF */ diff --git a/reactos/include/ndk/amd64/ketypes.h b/reactos/include/ndk/amd64/ketypes.h index 583669c97a3..69db15dec5e 100644 --- a/reactos/include/ndk/amd64/ketypes.h +++ b/reactos/include/ndk/amd64/ketypes.h @@ -64,6 +64,7 @@ Author: #define KGDT_64_R3_CODE 0x0030 // 33 #define KGDT_TSS 0x0040 #define KGDT_32_R3_TEB 0x0050 // 53 +#define KGDT_64_R3_TEB 0x0000 // FIXME //