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
RtlInitializeContext(_Reserved_ HANDLE ProcessHandle,_Out_ PCONTEXT ThreadContext,_In_opt_ PVOID ThreadStartParam,_In_ PTHREAD_START_ROUTINE ThreadStartAddress,_In_ PINITIAL_TEB StackBase)23 RtlInitializeContext(
24 _Reserved_ HANDLE ProcessHandle,
25 _Out_ PCONTEXT ThreadContext,
26 _In_opt_ PVOID ThreadStartParam,
27 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
28 _In_ PINITIAL_TEB StackBase)
29 {
30 /* Initialize everything to 0 */
31 RtlZeroMemory(ThreadContext, sizeof(*ThreadContext));
32
33 /* Initialize StartAddress and Stack */
34 ThreadContext->Rip = (ULONG64)ThreadStartAddress;
35 ThreadContext->Rsp = (ULONG64)StackBase - 6 * sizeof(PVOID);
36
37 /* Align stack by 16 and substract 8 (unaligned on function entry) */
38 ThreadContext->Rsp &= ~15;
39 ThreadContext->Rsp -= 8;
40
41 /* Enable Interrupts */
42 ThreadContext->EFlags = EFLAGS_INTERRUPT_MASK;
43
44 /* Set start parameter */
45 ThreadContext->Rcx = (ULONG64)ThreadStartParam;
46
47 /* Set the Selectors */
48 if ((LONG64)ThreadStartAddress < 0)
49 {
50 /* Initialize kernel mode segments */
51 ThreadContext->SegCs = KGDT64_R0_CODE;
52 ThreadContext->SegDs = KGDT64_R3_DATA;
53 ThreadContext->SegEs = KGDT64_R3_DATA;
54 ThreadContext->SegFs = KGDT64_R3_CMTEB;
55 ThreadContext->SegGs = KGDT64_R3_DATA;
56 ThreadContext->SegSs = KGDT64_R0_DATA;
57 }
58 else
59 {
60 /* Initialize user mode segments */
61 ThreadContext->SegCs = KGDT64_R3_CODE | RPL_MASK;
62 ThreadContext->SegDs = KGDT64_R3_DATA | RPL_MASK;
63 ThreadContext->SegEs = KGDT64_R3_DATA | RPL_MASK;
64 ThreadContext->SegFs = KGDT64_R3_CMTEB | RPL_MASK;
65 ThreadContext->SegGs = KGDT64_R3_DATA | RPL_MASK;
66 ThreadContext->SegSs = KGDT64_R3_DATA | RPL_MASK;
67 }
68
69 ThreadContext->MxCsr = INITIAL_MXCSR;
70
71 /* Only the basic Context is initialized */
72 ThreadContext->ContextFlags = CONTEXT_CONTROL |
73 CONTEXT_INTEGER |
74 CONTEXT_SEGMENTS |
75 CONTEXT_FLOATING_POINT;
76
77 return;
78 }
79
80 NTSTATUS
81 NTAPI
RtlQueueApcWow64Thread(_In_ HANDLE ThreadHandle,_In_ PKNORMAL_ROUTINE ApcRoutine,_In_opt_ PVOID NormalContext,_In_opt_ PVOID SystemArgument1,_In_opt_ PVOID SystemArgument2)82 RtlQueueApcWow64Thread(
83 _In_ HANDLE ThreadHandle,
84 _In_ PKNORMAL_ROUTINE ApcRoutine,
85 _In_opt_ PVOID NormalContext,
86 _In_opt_ PVOID SystemArgument1,
87 _In_opt_ PVOID SystemArgument2)
88 {
89 UNIMPLEMENTED;
90 return STATUS_NOT_IMPLEMENTED;
91 }
92
93