[NTOS]: Define MI_MAKE_PROTOTYPE_PTE macro to make a real prototype PTE from a PTE. Define counter-part MiProtoPteToPte to recover the true PTE from a given Prototype PTE.

[NTOS]: Define MI_PTE_LOOKUP_NEEDED instead of using 0xFFFF. The name was found in checked build assertion strings.
[NTOS]: Add MM_VIEW (used for System-mapped Section Views) and MM_SESSSION (used to define the system/session view mappings) structure definitions.

svn path=/trunk/; revision=48977
This commit is contained in:
Sir Richard 2010-10-04 18:34:41 +00:00
parent ee353ad690
commit 566335dd79
2 changed files with 63 additions and 1 deletions

View file

@ -26,7 +26,7 @@ MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1,
MMPDE DemandZeroPde = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)};
/* Template PTE for prototype page */
MMPTE PrototypePte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | PTE_PROTOTYPE | 0xFFFFF000};
MMPTE PrototypePte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << PAGE_SHIFT)};
/* PRIVATE FUNCTIONS **********************************************************/

View file

@ -233,6 +233,18 @@ extern const ULONG MmProtectToPteMask[32];
#define MI_GET_NEXT_COLOR(x) (MI_GET_PAGE_COLOR(++MmSystemPageColor))
#define MI_GET_NEXT_PROCESS_COLOR(x) (MI_GET_PAGE_COLOR(++(x)->NextPageColor))
//
// Decodes a Prototype PTE into the underlying PTE
//
#define MiProtoPteToPte(x) \
(PMMPTE)((ULONG_PTR)MmPagedPoolStart + \
((x)->u.Proto.ProtoAddressHigh | (x)->u.Proto.ProtoAddressLow))
//
// Prototype PTEs that don't yet have a pagefile association
//
#define MI_PTE_LOOKUP_NEEDED 0xFFFFF
//
// FIXFIX: These should go in ex.h after the pool merge
//
@ -359,6 +371,25 @@ typedef struct _MI_LARGE_PAGE_RANGES
PFN_NUMBER LastFrame;
} MI_LARGE_PAGE_RANGES, *PMI_LARGE_PAGE_RANGES;
typedef struct _MMVIEW
{
ULONG_PTR Entry;
PCONTROL_AREA ControlArea;
} MMVIEW, *PMMVIEW;
typedef struct _MMSESSION
{
KGUARDED_MUTEX SystemSpaceViewLock;
PKGUARDED_MUTEX SystemSpaceViewLockPointer;
PCHAR SystemSpaceViewStart;
PMMVIEW SystemSpaceViewTable;
ULONG SystemSpaceHashSize;
ULONG SystemSpaceHashEntries;
ULONG SystemSpaceHashKey;
ULONG BitmapFailures;
PRTL_BITMAP SystemSpaceBitMap;
} MMSESSION, *PMMSESSION;
extern MMPTE HyperTemplatePte;
extern MMPDE ValidKernelPde;
extern MMPTE ValidKernelPte;
@ -564,6 +595,31 @@ MI_MAKE_HARDWARE_PTE_USER(IN PMMPTE NewPte,
NewPte->u.Long |= MmProtectToPteMask[ProtectionMask];
}
//
// Builds a Prototype PTE for the address of the PTE
//
FORCEINLINE
VOID
MI_MAKE_PROTOTYPE_PTE(IN PMMPTE NewPte,
IN PMMPTE PointerPte)
{
ULONG_PTR Offset;
/* Mark this as a prototype */
NewPte->u.Long = 0;
NewPte->u.Proto.Prototype = 1;
/*
* Prototype PTEs are only valid in paged pool by design, this little trick
* lets us only use 28 bits for the adress of the PTE
*/
Offset = (ULONG_PTR)PointerPte - (ULONG_PTR)MmPagedPoolStart;
/* 7 bits go in the "low", and the other 21 bits go in the "high" */
NewPte->u.Proto.ProtoAddressLow = Offset & 0x7F;
NewPte->u.Proto.ProtoAddressHigh = Offset & 0xFFFFF80;
}
//
// Returns if the page is physically resident (ie: a large page)
// FIXFIX: CISC/x86 only?
@ -1107,6 +1163,12 @@ MiGetNextNode(
IN PMMADDRESS_NODE Node
);
BOOLEAN
NTAPI
MiInitializeSystemSpaceMap(
IN PVOID InputSession OPTIONAL
);
//
// MiRemoveZeroPage will use inline code to zero out the page manually if only
// free pages are available. In some scenarios, we don't/can't run that piece of