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

miscc.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1996 Intel Corporation 00004 Copyright (c) 1990 Microsoft Corporation 00005 00006 Module Name: 00007 00008 miscc.c 00009 00010 Abstract: 00011 00012 This module implements the functions that get the memory stack 00013 and backing store limits. 00014 00015 Author: 00016 00017 William K. Cheung (wcheung) 09-Aug-1996 00018 00019 Environment: 00020 00021 Any mode. 00022 00023 Revision History: 00024 00025 --*/ 00026 00027 #include "ntrtlp.h" 00028 00029 VOID 00030 RtlpFlushRSE ( 00031 OUT PULONGLONG BackingStore, 00032 OUT PULONGLONG RNat 00033 ); 00034 00035 00036 VOID 00037 RtlpCaptureRnats ( 00038 IN OUT PCONTEXT ContextRecord 00039 ) 00040 00041 /*++ 00042 00043 Routine Description: 00044 00045 This function captures Nat bits of all the stacked registers in 00046 the RSE frame specified in the context record. 00047 --*/ 00048 { 00049 SHORT BsFrameSize; // in 8-byte units 00050 SHORT TempFrameSize; // in 8-byte units 00051 SHORT RNatSaveIndex; 00052 ULONGLONG Rnat; 00053 ULONGLONG Bsp; 00054 ULONGLONG TopRnatAddress; 00055 00056 RtlpFlushRSE(&Bsp, &Rnat); 00057 00058 BsFrameSize = (SHORT)ContextRecord->StIFS & PFS_SIZE_MASK; 00059 RNatSaveIndex = (SHORT)(ContextRecord->RsBSP >> 3) & NAT_BITS_PER_RNAT_REG; 00060 TempFrameSize = RNatSaveIndex + BsFrameSize - NAT_BITS_PER_RNAT_REG; 00061 while (TempFrameSize >= 0) { 00062 BsFrameSize++; 00063 TempFrameSize -= NAT_BITS_PER_RNAT_REG; 00064 } 00065 TopRnatAddress = (ContextRecord->RsBSP + BsFrameSize * 8) | RNAT_ALIGNMENT; 00066 if (TopRnatAddress < Bsp) { 00067 ContextRecord->RsRNAT = *(PULONGLONG)TopRnatAddress; 00068 } else { 00069 ContextRecord->RsRNAT = Rnat; 00070 } 00071 } 00072 00073 00074 VOID 00075 Rtlp64GetBStoreLimits ( 00076 OUT PULONGLONG LowBStoreLimit, 00077 OUT PULONGLONG HighBStoreLimit 00078 ) 00079 00080 /*++ 00081 00082 Routine Description: 00083 00084 This function returns the current backing store limits based on the 00085 current processor mode. 00086 00087 Arguments: 00088 00089 LowBStoreLimit - Supplies a pointer to a variable that is to receive 00090 the low limit of the backing store. 00091 00092 HighBStoreLimit - Supplies a pointer to a variable that is to receive 00093 the high limit of the backing store. 00094 00095 Return Value: 00096 00097 None. 00098 00099 --*/ 00100 00101 { 00102 #if defined(NTOS_KERNEL_RUNTIME) 00103 00104 // 00105 // Kernel Mode 00106 // 00107 00108 *LowBStoreLimit = (ULONGLONG)(PCR->InitialBStore); 00109 *HighBStoreLimit = (ULONGLONG)(PCR->BStoreLimit); 00110 00111 #else 00112 00113 // 00114 // User Mode 00115 // 00116 00117 PTEB CurrentTeb = NtCurrentTeb(); 00118 00119 *HighBStoreLimit = (ULONGLONG)CurrentTeb->BStoreLimit; 00120 *LowBStoreLimit = (ULONGLONG)CurrentTeb->NtTib.StackBase; 00121 00122 #endif // defined(NTOS_KERNEL_RUNTIME) 00123 } 00124 00125 VOID 00126 RtlpGetStackLimits ( 00127 OUT PULONG_PTR LowStackLimit, 00128 OUT PULONG_PTR HighStackLimit 00129 ) 00130 00131 /*++ 00132 00133 Routine Description: 00134 00135 This function returns the current memory stack limits based on the 00136 current processor mode. 00137 00138 Arguments: 00139 00140 LowStackLimit - Supplies a pointer to a variable that is to receive 00141 the low limit of the memory stack. 00142 00143 HighStackLimit - Supplies a pointer to a variable that is to receive 00144 the high limit of the memory stack. 00145 00146 Return Value: 00147 00148 None. 00149 00150 --*/ 00151 00152 { 00153 00154 #if defined(NTOS_KERNEL_RUNTIME) 00155 00156 // 00157 // Kernel Mode 00158 // 00159 00160 *HighStackLimit = (ULONG_PTR)PCR->InitialStack; 00161 *LowStackLimit = (ULONG_PTR)PCR->StackLimit; 00162 00163 #else 00164 00165 // 00166 // User Mode 00167 // 00168 00169 PTEB CurrentTeb = NtCurrentTeb(); 00170 00171 *HighStackLimit = (ULONG_PTR)CurrentTeb->NtTib.StackBase; 00172 *LowStackLimit = (ULONG_PTR)CurrentTeb->NtTib.StackLimit; 00173 00174 #endif // defined(NTOS_KERNEL_RUNTIME) 00175 } 00176 00177 VOID 00178 Rtlp64GetStackLimits ( 00179 OUT PULONGLONG LowStackLimit, 00180 OUT PULONGLONG HighStackLimit 00181 ) 00182 00183 /*++ 00184 00185 Routine Description: 00186 00187 This function returns the current memory stack limits based on the 00188 current processor mode. 00189 00190 Arguments: 00191 00192 LowStackLimit - Supplies a pointer to a variable that is to receive 00193 the low limit of the memory stack. 00194 00195 HighStackLimit - Supplies a pointer to a variable that is to receive 00196 the high limit of the memory stack. 00197 00198 Return Value: 00199 00200 None. 00201 00202 --*/ 00203 00204 { 00205 00206 #if defined(NTOS_KERNEL_RUNTIME) 00207 00208 // 00209 // Kernel Mode 00210 // 00211 00212 *HighStackLimit = (ULONG_PTR)PCR->InitialStack; 00213 *LowStackLimit = (ULONG_PTR)PCR->StackLimit; 00214 00215 #else 00216 00217 // 00218 // User Mode 00219 // 00220 00221 PTEB CurrentTeb = NtCurrentTeb(); 00222 00223 *HighStackLimit = (ULONGLONG)CurrentTeb->NtTib.StackBase; 00224 *LowStackLimit = (ULONGLONG)CurrentTeb->NtTib.StackLimit; 00225 00226 #endif // defined(NTOS_KERNEL_RUNTIME) 00227 }

Generated on Sat May 15 19:40:49 2004 for test by doxygen 1.3.7