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

debugsup.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 debugsup.c 00008 00009 Abstract: 00010 00011 This module contains routines which provide support for the 00012 kernel debugger. 00013 00014 Author: 00015 00016 Lou Perazzoli (loup) 02-Aug-90 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #include "mi.h" 00023 00024 PVOID 00025 MmDbgReadCheck ( 00026 IN PVOID VirtualAddress 00027 ) 00028 00029 /*++ 00030 00031 Routine Description: 00032 00033 MIPS implementation specific: 00034 00035 This routine returns the virtual address which is valid (mapped) 00036 for read access. 00037 00038 If the address is valid and readable and not within KSEG0 or KSEG1 00039 the physical address within KSEG0 is returned. If the adddress 00040 is within KSEG0 or KSEG1 then the called address is returned. 00041 00042 Arguments: 00043 00044 VirtualAddress - Supplies the virtual address to check. 00045 00046 Return Value: 00047 00048 Returns NULL if the address is not valid or readable, otherwise 00049 returns the physical address of the corresponding virtual address. 00050 00051 Environment: 00052 00053 Kernel mode IRQL at DISPATCH_LEVEL or greater. 00054 00055 --*/ 00056 00057 { 00058 if ((VirtualAddress >= (PVOID)KSEG0_BASE) && 00059 (VirtualAddress < (PVOID)KSEG2_BASE)) { 00060 return VirtualAddress; 00061 } 00062 00063 if (!MmIsAddressValid (VirtualAddress)) { 00064 if (KiProbeEntryTb(VirtualAddress)) { 00065 return VirtualAddress; 00066 } 00067 return NULL; 00068 } 00069 00070 return VirtualAddress; 00071 } 00072 00073 PVOID 00074 MmDbgWriteCheck ( 00075 IN PVOID VirtualAddress 00076 ) 00077 00078 /*++ 00079 00080 Routine Description: 00081 00082 MIPS implementation specific: 00083 00084 This routine returns the phyiscal address for a virtual address 00085 which is valid (mapped) for write access. 00086 00087 If the address is valid and writable and not within KSEG0 or KSEG1 00088 the physical address within KSEG0 is returned. If the adddress 00089 is within KSEG0 or KSEG1 then the called address is returned. 00090 00091 NOTE: The physical address is must only be used while the interrupt 00092 level on ALL processors is above DISPATCH_LEVEL, otherwise the 00093 binding between the virtual address and the physical address can 00094 change due to paging. 00095 00096 Arguments: 00097 00098 VirtualAddress - Supplies the virtual address to check. 00099 00100 Return Value: 00101 00102 Returns NULL if the address is not valid or readable, otherwise 00103 returns the physical address of the corresponding virtual address. 00104 00105 Environment: 00106 00107 Kernel mode IRQL at DISPATCH_LEVEL or greater. 00108 00109 --*/ 00110 00111 { 00112 PMMPTE PointerPte; 00113 00114 if ((VirtualAddress >= (PVOID)KSEG0_BASE) && 00115 (VirtualAddress < (PVOID)KSEG2_BASE)) { 00116 return VirtualAddress; 00117 } 00118 00119 if (!MmIsAddressValid (VirtualAddress)) { 00120 00121 // 00122 // need to check write 00123 // 00124 00125 if (KiProbeEntryTb(VirtualAddress)) { 00126 return VirtualAddress; 00127 } 00128 return NULL; 00129 } 00130 00131 PointerPte = MiGetPteAddress (VirtualAddress); 00132 00133 if ((ULONG) VirtualAddress < KSEG0_BASE && PointerPte->u.Hard.Dirty == 0) { 00134 return NULL; 00135 } 00136 00137 return VirtualAddress; 00138 } 00139 00140 PVOID64 00141 MmDbgReadCheck64 ( 00142 IN PVOID64 VirtualAddress 00143 ) 00144 00145 /*++ 00146 00147 Routine Description: 00148 00149 MIPS implementation specific: 00150 00151 This routine returns the virtual address which is valid (mapped) 00152 for read access. 00153 00154 If the address is valid and readable and not within KSEG0 or KSEG1 00155 the physical address within KSEG0 is returned. If the adddress 00156 is within KSEG0 or KSEG1 then the called address is returned. 00157 00158 Arguments: 00159 00160 VirtualAddress - Supplies the virtual address to check. 00161 00162 Return Value: 00163 00164 Returns NULL if the address is not valid or readable, otherwise 00165 returns the physical address of the corresponding virtual address. 00166 00167 Environment: 00168 00169 Kernel mode IRQL at DISPATCH_LEVEL or greater. 00170 00171 --*/ 00172 00173 { 00174 00175 #ifdef VLM_SUPPORT 00176 if (!MmIsAddressValid64 (VirtualAddress)) { 00177 return NULL; 00178 } 00179 00180 return VirtualAddress; 00181 #else 00182 return NULL; 00183 #endif 00184 } 00185 00186 PVOID64 00187 MmDbgWriteCheck64 ( 00188 IN PVOID64 VirtualAddress 00189 ) 00190 00191 /*++ 00192 00193 Routine Description: 00194 00195 MIPS implementation specific: 00196 00197 This routine returns the phyiscal address for a virtual address 00198 which is valid (mapped) for write access. 00199 00200 If the address is valid and writable and not within KSEG0 or KSEG1 00201 the physical address within KSEG0 is returned. If the adddress 00202 is within KSEG0 or KSEG1 then the called address is returned. 00203 00204 NOTE: The physical address is must only be used while the interrupt 00205 level on ALL processors is above DISPATCH_LEVEL, otherwise the 00206 binding between the virtual address and the physical address can 00207 change due to paging. 00208 00209 Arguments: 00210 00211 VirtualAddress - Supplies the virtual address to check. 00212 00213 Return Value: 00214 00215 Returns NULL if the address is not valid or readable, otherwise 00216 returns the physical address of the corresponding virtual address. 00217 00218 Environment: 00219 00220 Kernel mode IRQL at DISPATCH_LEVEL or greater. 00221 00222 --*/ 00223 00224 { 00225 #ifdef VLM_SUPPORT 00226 PMMPTE PointerPte; 00227 00228 if (!MmIsAddressValid64 (VirtualAddress)) { 00229 return NULL; 00230 } 00231 00232 PointerPte = MiGetPteAddress64 (VirtualAddress); 00233 00234 if (PointerPte->u.Hard.Dirty == 0) { 00235 return NULL; 00236 } 00237 00238 return VirtualAddress; 00239 #else 00240 return NULL; 00241 #endif 00242 } 00243 00244 PVOID 00245 MmDbgTranslatePhysicalAddress ( 00246 IN PHYSICAL_ADDRESS PhysicalAddress 00247 ) 00248 00249 /*++ 00250 00251 Routine Description: 00252 00253 MIPS implementation specific: 00254 00255 This routine maps the specified physical address and returns 00256 the virtual address which maps the physical address. 00257 00258 The next call to MmDbgTranslatePhyiscalAddress removes the 00259 previous phyiscal address translation, hence on a single 00260 physical address can be examined at a time (can't cross page 00261 boundaries). 00262 00263 Arguments: 00264 00265 PhysicalAddress - Supplies the phyiscal address to map and translate. 00266 00267 Return Value: 00268 00269 The virtual address which corresponds to the phyiscal address. 00270 00271 NULL if the physical address was bogus. 00272 00273 Environment: 00274 00275 Kernel mode IRQL at DISPATCH_LEVEL or greater. 00276 00277 --*/ 00278 00279 { 00280 PVOID BaseAddress; 00281 PMMPTE BasePte; 00282 PMMPFN Pfn1; 00283 ULONG Page; 00284 00285 BasePte = MmDebugPte + (MM_NUMBER_OF_COLORS - 1); 00286 BasePte = (PMMPTE)((ULONG)BasePte & ~(MM_COLOR_MASK << PTE_SHIFT)); 00287 00288 Page = (ULONG)(PhysicalAddress.QuadPart >> PAGE_SHIFT); 00289 00290 if ((Page > (LONGLONG)MmHighestPhysicalPage) || 00291 (Page < (LONGLONG)MmLowestPhysicalPage)) { 00292 return NULL; 00293 } 00294 00295 Pfn1 = MI_PFN_ELEMENT (Page); 00296 00297 if (!MmIsAddressValid (Pfn1)) { 00298 return NULL; 00299 } 00300 00301 BasePte = BasePte + Pfn1->u3.e1.PageColor; 00302 00303 BaseAddress = MiGetVirtualAddressMappedByPte (BasePte); 00304 00305 KiFlushSingleTb (TRUE, BaseAddress); 00306 00307 *BasePte = ValidKernelPte; 00308 BasePte->u.Hard.PageFrameNumber = Page; 00309 return (PVOID)((ULONG)BaseAddress + BYTE_OFFSET(PhysicalAddress.LowPart)); 00310 }

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