test: mips/debugsup.c File Reference

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

# debugsup.c File Reference

`#include "mi.h"`

Go to the source code of this file.

## Functions

PVOID | MmDbgReadCheck (IN PVOID VirtualAddress)
PVOID | MmDbgWriteCheck (IN PVOID VirtualAddress)
PVOID64 | MmDbgReadCheck64 (IN PVOID64 VirtualAddress)
PVOID64 | MmDbgWriteCheck64 (IN PVOID64 VirtualAddress)
PVOID | MmDbgTranslatePhysicalAddress (IN PHYSICAL_ADDRESS PhysicalAddress)

## Function Documentation

PVOID MmDbgReadCheck | ( | IN PVOID | VirtualAddress | ) |

Definition at line 25 of file mips/debugsup.c.

References KSEG0_BASE, KSEG2_BASE, MmIsAddressValid(), and NULL.

    00031                    :
    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 }

PVOID64 MmDbgReadCheck64 | ( | IN PVOID64 | VirtualAddress | ) |

Definition at line 141 of file mips/debugsup.c.

References NULL.

    00147                    :
    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 }

PVOID MmDbgTranslatePhysicalAddress | ( | IN PHYSICAL_ADDRESS | PhysicalAddress | ) |

Definition at line 245 of file mips/debugsup.c.

References BYTE_OFFSET, KiFlushSingleTb(), MI_PFN_ELEMENT, MiGetVirtualAddressMappedByPte, MM_COLOR_MASK, MM_NUMBER_OF_COLORS, MmDebugPte, MmHighestPhysicalPage, MmIsAddressValid(), MmLowestPhysicalPage, NULL, PAGE_SHIFT, PTE_SHIFT, TRUE, _MMPTE::u, _MMPFN::u3, and ValidKernelPte.

    00251                    :
    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 }
    }

PVOID MmDbgWriteCheck | ( | IN PVOID | VirtualAddress | ) |

Definition at line 74 of file mips/debugsup.c.

References KSEG0_BASE, KSEG2_BASE, MiGetPteAddress, MmIsAddressValid(), NULL, and _MMPTE::u.

    00080                    :
    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 }

PVOID64 MmDbgWriteCheck64 | ( | IN PVOID64 | VirtualAddress | ) |

Definition at line 187 of file mips/debugsup.c.

References MiGetPteAddress64, NULL, and _MMPTE::u.

    00193                    :
    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 }