Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

psctx386.c File Reference

#include "psp.h"

Go to the source code of this file.

Defines

#define PSPALIGN_DOWN(address, amt)   ((ULONG)(address) & ~(( amt ) - 1))
#define PSPALIGN_UP(address, amt)   (PSPALIGN_DOWN( (address + (amt) - 1), (amt) ))

Functions

VOID PspGetContext (IN PKTRAP_FRAME TrapFrame, IN PKNONVOLATILE_CONTEXT_POINTERS NonVolatileContext, IN OUT PCONTEXT Context)
VOID PspSetContext (OUT PKTRAP_FRAME TrapFrame, OUT PKNONVOLATILE_CONTEXT_POINTERS NonVolatileContext, IN PCONTEXT Context, KPROCESSOR_MODE Mode)
VOID PspGetSetContextSpecialApc (IN PKAPC Apc, IN PKNORMAL_ROUTINE *NormalRoutine, IN PVOID *NormalContext, IN PVOID *SystemArgument1, IN PVOID *SystemArgument2)


Define Documentation

#define PSPALIGN_DOWN address,
amt   )     ((ULONG)(address) & ~(( amt ) - 1))
 

Definition at line 34 of file psctx386.c.

#define PSPALIGN_UP address,
amt   )     (PSPALIGN_DOWN( (address + (amt) - 1), (amt) ))
 

Definition at line 36 of file psctx386.c.

Referenced by PspGetSetContextSpecialApc().


Function Documentation

VOID PspGetContext IN PKTRAP_FRAME  TrapFrame,
IN PKNONVOLATILE_CONTEXT_POINTERS  NonVolatileContext,
IN OUT PCONTEXT  Context
 

Definition at line 46 of file psctx386.c.

References ASSERT, KeContextFromKframes(), KernelMode, NULL, and PAGED_CODE.

00054 : 00055 00056 This function moves the contents of the specified trap and NonVolatile 00057 context into the specified context record. It's primary user will 00058 be NtGetContextThread. 00059 00060 N.B. - NonVolatileContext is IGNORED on the 386. 00061 00062 Arguments: 00063 00064 TrapFrame - Supplies the contents of a trap frame that should be 00065 restored copied into the proper location in the context 00066 record. 00067 00068 Context - Returns the threads current context. 00069 00070 Return Value: 00071 00072 None. 00073 00074 --*/ 00075 00076 { 00077 UNREFERENCED_PARAMETER( NonVolatileContext ); 00078 00079 PAGED_CODE(); 00080 00081 ASSERT(((TrapFrame->SegCs & MODE_MASK) != KernelMode) || 00082 (TrapFrame->EFlags & EFLAGS_V86_MASK)); 00083 00084 KeContextFromKframes(TrapFrame, NULL, Context); 00085 }

VOID PspGetSetContextSpecialApc IN PKAPC  Apc,
IN PKNORMAL_ROUTINE NormalRoutine,
IN PVOID *  NormalContext,
IN PVOID *  SystemArgument1,
IN PVOID *  SystemArgument2
 

Definition at line 131 of file psctx386.c.

References _GETSETCONTEXT::Context, FALSE, _KTHREAD::InitialStack, KeSetEvent(), _GETSETCONTEXT::Mode, NULL, _GETSETCONTEXT::OperationComplete, PAGED_CODE, PGETSETCONTEXT, PSPALIGN_UP, PspGetContext(), PspSetContext(), and _ETHREAD::Tcb.

Referenced by NtGetContextThread(), and NtSetContextThread().

00141 : 00142 00143 This function either captures the usermode state of the current 00144 thread, or sets the usermode state of the current thread. The 00145 operation type is determined by the value of SystemArgument1. A 00146 NULL value is used for get context, and a non-NULL value is used 00147 for set context. 00148 00149 Arguments: 00150 00151 Apc - Supplies a pointer to the APC control object that caused entry 00152 into this routine. 00153 00154 NormalRoutine - Supplies a pointer to a pointer to the normal routine 00155 function that was specifed when the APC was initialized. 00156 00157 NormalContext - Supplies a pointer to a pointer to an arbitrary data 00158 structure that was specified when the APC was initialized. 00159 00160 SystemArgument1, SystemArgument2 - Supplies a set of two pointer to two 00161 arguments that contain untyped data. 00162 00163 Return Value: 00164 00165 None. 00166 00167 --*/ 00168 00169 { 00170 PGETSETCONTEXT Ctx; 00171 PKTRAP_FRAME TrapFrame; 00172 PETHREAD Thread; 00173 00174 PAGED_CODE(); 00175 00176 UNREFERENCED_PARAMETER( NormalRoutine ); 00177 UNREFERENCED_PARAMETER( NormalContext ); 00178 UNREFERENCED_PARAMETER( SystemArgument1 ); 00179 UNREFERENCED_PARAMETER( SystemArgument2 ); 00180 00181 Ctx = CONTAINING_RECORD(Apc,GETSETCONTEXT,Apc); 00182 Thread = Apc->SystemArgument2; 00183 00184 TrapFrame = (PKTRAP_FRAME)((PUCHAR)Thread->Tcb.InitialStack - 00185 PSPALIGN_UP(sizeof(KTRAP_FRAME),KTRAP_FRAME_ALIGN) - 00186 sizeof(FX_SAVE_AREA)); 00187 00188 if ( Apc->SystemArgument1 ) { 00189 00190 // 00191 // Set Context 00192 // 00193 00194 PspSetContext(TrapFrame,NULL,&Ctx->Context,Ctx->Mode); 00195 00196 } else { 00197 00198 // 00199 // Get Context 00200 // 00201 00202 PspGetContext(TrapFrame,NULL,&Ctx->Context); 00203 } 00204 00205 KeSetEvent(&Ctx->OperationComplete,0,FALSE); 00206 00207 } }

VOID PspSetContext OUT PKTRAP_FRAME  TrapFrame,
OUT PKNONVOLATILE_CONTEXT_POINTERS  NonVolatileContext,
IN PCONTEXT  Context,
KPROCESSOR_MODE  Mode
 

Definition at line 88 of file psctx386.c.

00097 : 00098 00099 This function moves the contents of the specified context record 00100 into the specified trap frame, and modifies the thread's non volatile 00101 context by storing through the thread's nonvolatile context pointers. 00102 00103 N.B. - NonVolatileContext is IGNORED on the 386. 00104 00105 Arguments: 00106 00107 TrapFrame - Returns selected pieces of the context record. 00108 00109 Context - Supplies a context record to be copied in the trap and 00110 nonvolatile context. 00111 00112 Mode - Supplies the mode to be used when sanitizing the psr, epsr and fsr 00113 00114 Return Value: 00115 00116 None. 00117 00118 --*/ 00119 00120 { 00121 UNREFERENCED_PARAMETER( NonVolatileContext ); 00122 ASSERT(((TrapFrame->SegCs & MODE_MASK) != KernelMode) || 00123 (TrapFrame->EFlags & EFLAGS_V86_MASK)); 00124 00125 PAGED_CODE(); 00126 00127 KeContextToKframes(TrapFrame, NULL, Context, Context->ContextFlags, Mode); 00128 }


Generated on Sat May 15 19:45:22 2004 for test by doxygen 1.3.7