Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpsctx.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Kernel 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: ntoskrnl/ps/i386/pxctx.c 00005 * PURPOSE: Process Manager: Set/Get Context for i386 00006 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <ntoskrnl.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 /* FUNCTIONS ******************************************************************/ 00016 00017 VOID 00018 NTAPI 00019 PspGetContext(IN PKTRAP_FRAME TrapFrame, 00020 IN PVOID NonVolatileContext, 00021 IN OUT PCONTEXT Context) 00022 { 00023 PAGED_CODE(); 00024 00025 /* Convert the trap frame to a context */ 00026 KeTrapFrameToContext(TrapFrame, NULL, Context); 00027 } 00028 00029 VOID 00030 NTAPI 00031 PspSetContext(OUT PKTRAP_FRAME TrapFrame, 00032 OUT PVOID NonVolatileContext, 00033 IN PCONTEXT Context, 00034 IN KPROCESSOR_MODE Mode) 00035 { 00036 PAGED_CODE(); 00037 00038 /* Convert the context to a trap frame structure */ 00039 KeContextToTrapFrame(Context, NULL, TrapFrame, Context->ContextFlags, Mode); 00040 } 00041 00042 VOID 00043 NTAPI 00044 PspGetOrSetContextKernelRoutine(IN PKAPC Apc, 00045 IN OUT PKNORMAL_ROUTINE* NormalRoutine, 00046 IN OUT PVOID* NormalContext, 00047 IN OUT PVOID* SystemArgument1, 00048 IN OUT PVOID* SystemArgument2) 00049 { 00050 PGET_SET_CTX_CONTEXT GetSetContext; 00051 PKEVENT Event; 00052 PCONTEXT Context; 00053 PETHREAD Thread; 00054 KPROCESSOR_MODE Mode; 00055 PKTRAP_FRAME TrapFrame = NULL; 00056 PAGED_CODE(); 00057 00058 /* Get the Context Structure */ 00059 GetSetContext = CONTAINING_RECORD(Apc, GET_SET_CTX_CONTEXT, Apc); 00060 Context = &GetSetContext->Context; 00061 Event = &GetSetContext->Event; 00062 Mode = GetSetContext->Mode; 00063 Thread = Apc->SystemArgument2; 00064 00065 /* If this is a kernel-mode request, grab the saved trap frame */ 00066 if (Mode == KernelMode) TrapFrame = Thread->Tcb.TrapFrame; 00067 00068 /* If we don't have one, grab it from the stack */ 00069 if (!TrapFrame) 00070 { 00071 /* Trap frame is right under our initial stack */ 00072 TrapFrame = KeGetTrapFrame(&Thread->Tcb); 00073 } 00074 00075 /* Check if it's a set or get */ 00076 if (Apc->SystemArgument1) 00077 { 00078 /* Get the Context */ 00079 PspSetContext(TrapFrame, NULL, Context, Mode); 00080 } 00081 else 00082 { 00083 /* Set the Context */ 00084 PspGetContext(TrapFrame, NULL, Context); 00085 } 00086 00087 /* Notify the Native API that we are done */ 00088 KeSetEvent(Event, IO_NO_INCREMENT, FALSE); 00089 } 00090 00091 /* EOF */ Generated on Sat May 26 2012 04:36:32 for ReactOS by
1.7.6.1
|