ReactOS  r75907
psctx.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: ntoskrnl/ps/amd64/psctx.c
5  * PURPOSE: Process Manager: Set/Get Context for i386
6  * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7  * Timo Kreuzer (timo.kreuzer@reactos.org)
8  */
9 
10 /* INCLUDES *******************************************************************/
11 
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* FUNCTIONS ******************************************************************/
17 
18 VOID
19 NTAPI
21  IN PVOID NonVolatileContext,
23 {
24  PAGED_CODE();
25 
26  /* Convert the trap frame to a context */
27  KeTrapFrameToContext(TrapFrame, NULL, Context);
28 }
29 
30 VOID
31 NTAPI
33  OUT PVOID NonVolatileContext,
36 {
37  PAGED_CODE();
38 
39  /* Convert the context to a trap frame structure */
40  KeContextToTrapFrame(Context, NULL, TrapFrame, Context->ContextFlags, Mode);
41 }
42 
43 VOID
44 NTAPI
46  IN OUT PKNORMAL_ROUTINE* NormalRoutine,
47  IN OUT PVOID* NormalContext,
50 {
51  PGET_SET_CTX_CONTEXT GetSetContext;
52  PKEVENT Event;
56  PKTRAP_FRAME TrapFrame = NULL;
57  PAGED_CODE();
58 
59  /* Get the Context Structure */
60  GetSetContext = CONTAINING_RECORD(Apc, GET_SET_CTX_CONTEXT, Apc);
61  Context = &GetSetContext->Context;
62  Event = &GetSetContext->Event;
63  Mode = GetSetContext->Mode;
64  Thread = Apc->SystemArgument2;
65 
66  /* If this is a kernel-mode request, grab the saved trap frame */
67  if (Mode == KernelMode) TrapFrame = Thread->TrapFrame;
68 
69  /* If we don't have one, grab it from the stack */
70  if (!TrapFrame)
71  {
72  DPRINT1("FIXME!!!!\n");
73  /* Trap frame is right under our initial stack */
74 // TrapFrame = (PKTRAP_FRAME)((ULONG_PTR)Thread->InitialStack -
75 // ROUND_UP(sizeof(KTRAP_FRAME), KTRAP_FRAME_ALIGN) -
76 // sizeof(FX_SAVE_AREA));
77  }
78 
79  /* Check if it's a set or get */
80  if (Apc->SystemArgument1)
81  {
82  /* Get the Context */
83  PspSetContext(TrapFrame, NULL, Context, Mode);
84  }
85  else
86  {
87  /* Set the Context */
88  PspGetContext(TrapFrame, NULL, Context);
89  }
90 
91  /* Notify the Native API that we are done */
93 }
94 
95 /* EOF */
VOID NTAPI KeContextToTrapFrame(PCONTEXT Context, PKEXCEPTION_FRAME ExeptionFrame, PKTRAP_FRAME TrapFrame, ULONG ContextFlags, KPROCESSOR_MODE PreviousMode)
DWORD *typedef PVOID
Definition: winlogon.h:52
#define IN
Definition: typedefs.h:39
_In_ ULONG Mode
Definition: hubbusif.h:303
PKTRAP_FRAME TrapFrame
Definition: ketypes.h:1181
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
VOID NTAPI PspGetContext(IN PKTRAP_FRAME TrapFrame, IN PVOID NonVolatileContext, IN OUT PCONTEXT Context)
Definition: psctx.c:20
ACPI_EFI_EVENT Event
Definition: acefiex.h:633
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
VOID NTAPI PspGetOrSetContextKernelRoutine(IN PKAPC Apc, IN OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
Definition: psctx.c:45
smooth NULL
Definition: ftsmooth.c:513
VOID NTAPI KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame, IN OUT PCONTEXT Context)
Definition: context.c:146
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:660
KPROCESSOR_MODE Mode
Definition: ps.h:80
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:632
#define PAGED_CODE()
Definition: video.h:57
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
Definition: ketypes.h:520
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:660
KEVENT Event
Definition: ps.h:79
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI PspSetContext(OUT PKTRAP_FRAME TrapFrame, OUT PVOID NonVolatileContext, IN PCONTEXT Context, IN KPROCESSOR_MODE Mode)
Definition: psctx.c:32
#define OUT
Definition: typedefs.h:40
struct tagContext Context
Definition: acpixf.h:1014
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
CONTEXT Context
Definition: ps.h:81