1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS Run-Time Library 4 * PURPOSE: AMD64 stubs 5 * FILE: lib/rtl/amd64/stubs.c 6 * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) 7 */ 8 9 /* INCLUDES *****************************************************************/ 10 11 #include <rtl.h> 12 #define NDEBUG 13 #include <debug.h> 14 #include "amd64/ketypes.h" 15 16 /* PUBLIC FUNCTIONS **********************************************************/ 17 18 /* 19 * @unimplemented 20 */ 21 VOID 22 NTAPI 23 RtlInitializeContext(IN HANDLE ProcessHandle, 24 OUT PCONTEXT ThreadContext, 25 IN PVOID ThreadStartParam OPTIONAL, 26 IN PTHREAD_START_ROUTINE ThreadStartAddress, 27 IN PINITIAL_TEB StackBase) 28 { 29 30 ThreadContext->Rax = 0; 31 ThreadContext->Rbx = 0; 32 ThreadContext->Rcx = (ULONG64)ThreadStartParam; 33 ThreadContext->Rdx = 0; 34 ThreadContext->Rsi = 0; 35 ThreadContext->Rdi = 0; 36 ThreadContext->Rbp = 0; 37 ThreadContext->R8 = 0; 38 ThreadContext->R9 = 0; 39 ThreadContext->R10 = 0; 40 ThreadContext->R11 = 0; 41 ThreadContext->R12 = 0; 42 43 /* Set the Selectors */ 44 if ((LONG64)ThreadStartAddress < 0) 45 { 46 /* Initialize kernel mode segments */ 47 ThreadContext->SegCs = KGDT64_R0_CODE; 48 ThreadContext->SegDs = KGDT64_R3_DATA; 49 ThreadContext->SegEs = KGDT64_R3_DATA; 50 ThreadContext->SegFs = KGDT64_R3_CMTEB; 51 ThreadContext->SegGs = KGDT64_R3_DATA; 52 ThreadContext->SegSs = KGDT64_R0_DATA; 53 } 54 else 55 { 56 /* Initialize user mode segments */ 57 ThreadContext->SegCs = KGDT64_R3_CODE | RPL_MASK; 58 ThreadContext->SegDs = KGDT64_R3_DATA | RPL_MASK; 59 ThreadContext->SegEs = KGDT64_R3_DATA | RPL_MASK; 60 ThreadContext->SegFs = KGDT64_R3_CMTEB | RPL_MASK; 61 ThreadContext->SegGs = KGDT64_R3_DATA | RPL_MASK; 62 ThreadContext->SegSs = KGDT64_R3_DATA | RPL_MASK; 63 } 64 65 /* Enable Interrupts */ 66 ThreadContext->EFlags = EFLAGS_INTERRUPT_MASK; 67 68 /* Settings passed */ 69 ThreadContext->Rip = (ULONG64)ThreadStartAddress; 70 ThreadContext->Rsp = (ULONG64)StackBase - 6 * sizeof(PVOID); 71 72 /* Align stack by 16 and substract 8 (unaligned on function entry) */ 73 ThreadContext->Rsp &= ~15; 74 ThreadContext->Rsp -= 8; 75 76 /* Only the basic Context is initialized */ 77 ThreadContext->ContextFlags = CONTEXT_CONTROL | 78 CONTEXT_INTEGER | 79 CONTEXT_SEGMENTS; 80 81 return; 82 } 83 84 /* 85 * @unimplemented 86 */ 87 PVOID 88 NTAPI 89 RtlpGetExceptionAddress(VOID) 90 { 91 UNIMPLEMENTED; 92 return NULL; 93 } 94 95 /* 96 * @unimplemented 97 */ 98 BOOLEAN 99 NTAPI 100 RtlDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, 101 IN PCONTEXT Context) 102 { 103 UNIMPLEMENTED; 104 return FALSE; 105 } 106 107 NTSYSAPI 108 VOID 109 RtlRestoreContext( 110 PCONTEXT ContextRecord, 111 PEXCEPTION_RECORD ExceptionRecord) 112 { 113 UNIMPLEMENTED; 114 } 115 116 NTSTATUS 117 NTAPI 118 RtlQueueApcWow64Thread( 119 _In_ HANDLE ThreadHandle, 120 _In_ PKNORMAL_ROUTINE ApcRoutine, 121 _In_opt_ PVOID NormalContext, 122 _In_opt_ PVOID SystemArgument1, 123 _In_opt_ PVOID SystemArgument2) 124 { 125 UNIMPLEMENTED; 126 return STATUS_NOT_IMPLEMENTED; 127 } 128 129