ReactOS  0.4.15-dev-1392-g3014417
init.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <mm/ARM3/miarm.h>
#include <fltkernel.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define IS_PAGE_ALIGNED(addr)   IS_ALIGNED(addr, PAGE_SIZE)
 

Functions

VOID NTAPI MiInitializeSessionSpaceLayout (VOID)
 
VOID NTAPI MiMapPPEs (PVOID StartAddress, PVOID EndAddress)
 
VOID NTAPI MiMapPDEs (PVOID StartAddress, PVOID EndAddress)
 
VOID NTAPI MiMapPTEs (PVOID StartAddress, PVOID EndAddress)
 
VOID NTAPI MiInitializePageTable (VOID)
 
VOID NTAPI MiBuildNonPagedPool (VOID)
 
VOID NTAPI MiBuildSystemPteSpace (VOID)
 
static VOID MiSetupPfnForPageTable (PFN_NUMBER PageFrameIndex, PMMPTE PointerPte)
 
static VOID MiBuildPfnDatabaseFromPageTables (VOID)
 
static VOID MiAddDescriptorToDatabase (PFN_NUMBER BasePage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType)
 
VOID NTAPI MiBuildPfnDatabase (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI MiInitMachineDependent (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 

Variables

PMMPTE MmDebugPte
 
MMPTE ValidKernelPde = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPTE ValidKernelPte = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPTE ValidKernelPdeLocal = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPTE ValidKernelPteLocal = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPDE DemandZeroPde = {{MM_EXECUTE_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS}}
 
MMPTE DemandZeroPte = {{MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS}}
 
MMPTE PrototypePte
 
MMPTE MmDecommittedPte = {{MM_DECOMMIT << MM_PTE_SOFTWARE_PROTECTION_BITS}}
 
PVOID MiSessionViewEnd
 
PVOID MiSystemPteSpaceStart
 
PVOID MiSystemPteSpaceEnd
 
ULONG64 MxPfnSizeInBytes
 
BOOLEAN MiIncludeType [LoaderMaximum]
 
PFN_NUMBER MxFreePageBase
 
ULONG64 MxFreePageCount = 0
 
BOOLEAN MiPfnsInitialized = FALSE
 

Macro Definition Documentation

◆ IS_PAGE_ALIGNED

#define IS_PAGE_ALIGNED (   addr)    IS_ALIGNED(addr, PAGE_SIZE)

Definition at line 23 of file init.c.

Function Documentation

◆ MiAddDescriptorToDatabase()

static VOID MiAddDescriptorToDatabase ( PFN_NUMBER  BasePage,
PFN_NUMBER  PageCount,
TYPE_OF_MEMORY  MemoryType 
)
static

Definition at line 545 of file init.c.

549 {
550  PMMPFN Pfn;
551 
552  ASSERT(!MiIsMemoryTypeInvisible(MemoryType));
553 
554  /* Check if the memory is free */
555  if (MiIsMemoryTypeFree(MemoryType))
556  {
557  /* Get the last pfn of this descriptor. Note we loop backwards */
558  Pfn = &MmPfnDatabase[BasePage + PageCount - 1];
559 
560  /* Loop all pages */
561  while (PageCount--)
562  {
563  /* Add it to the free list */
564  Pfn->u3.e1.CacheAttribute = MiNonCached; // FIXME: Windows ASSERTs MiChached, but why not MiNotMapped?
565  MiInsertPageInFreeList(BasePage + PageCount);
566 
567  /* Go to the previous page */
568  Pfn--;
569  }
570  }
571  else if (MemoryType == LoaderXIPRom)
572  {
573  Pfn = &MmPfnDatabase[BasePage];
574  while (PageCount--)
575  {
576  /* Make it a pseudo-I/O ROM mapping */
577  Pfn->PteAddress = 0;
578  Pfn->u1.Flink = 0;
579  Pfn->u2.ShareCount = 0;
580  Pfn->u3.e1.PageLocation = 0;
582  Pfn->u3.e1.Rom = 1;
583  Pfn->u3.e1.PrototypePte = 1;
584  Pfn->u3.e2.ReferenceCount = 0;
585  Pfn->u4.InPageError = 0;
586  Pfn->u4.PteFrame = 0;
587 
588  /* Advance one */
589  Pfn++;
590  }
591  }
592  else if (MemoryType == LoaderBad)
593  {
594  // FIXME: later
595  ASSERT(FALSE);
596  }
597  else
598  {
599  /* For now skip it */
600  Pfn = &MmPfnDatabase[BasePage];
601  while (PageCount--)
602  {
603  /* Make an active PFN */
605 
606  /* Advance one */
607  Pfn++;
608  }
609  }
610 }
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:604
PFN_NUMBER Flink
Definition: mm.h:315
USHORT PageLocation
Definition: mm.h:303
PMMPFN MmPfnDatabase
Definition: freelist.c:24
USHORT PrototypePte
Definition: mm.h:301
union _MMPFN::@1784 u1
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:679
MMPFNENTRY e1
Definition: mm.h:335
USHORT CacheAttribute
Definition: mm.h:305
#define FALSE
Definition: types.h:117
ULONG_PTR ShareCount
Definition: mm.h:328
Definition: arc.h:130
struct _MMPFN::@1786::@1792 e2
union _MMPFN::@1785 u2
#define ASSERT(a)
Definition: mode.c:45
Definition: mm.h:311
ULONG_PTR PteFrame
Definition: mm.h:356
USHORT Rom
Definition: mm.h:306
PMMPTE PteAddress
Definition: mm.h:324
union _MMPFN::@1789 u4
union _MMPFN::@1786 u3
FORCEINLINE BOOLEAN MiIsMemoryTypeFree(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:669
ULONG_PTR InPageError
Definition: mm.h:357

Referenced by MiBuildPfnDatabase().

◆ MiBuildNonPagedPool()

VOID NTAPI MiBuildNonPagedPool ( VOID  )

Definition at line 286 of file init.c.

287 {
288  /* Check if this is a machine with less than 256MB of RAM, and no overide */
291  {
292  /* Force the non paged pool to be 2MB so we can reduce RAM usage */
293  MmSizeOfNonPagedPoolInBytes = 2 * 1024 * 1024;
294  }
295 
296  /* Check if the user gave a ridicuously large nonpaged pool RAM size */
298  (MmNumberOfPhysicalPages * 7 / 8))
299  {
300  /* More than 7/8ths of RAM was dedicated to nonpaged pool, ignore! */
302  }
303 
304  /* Check if no registry setting was set, or if the setting was too low */
306  {
307  /* Start with the minimum (256 KB) and add 32 KB for each MB above 4 */
311  }
312 
313  /* Check if the registy setting or our dynamic calculation was too high */
315  {
316  /* Set it to the maximum */
318  }
319 
320  /* Check if a percentage cap was set through the registry */
322  {
323  /* Don't feel like supporting this right now */
325  }
326 
327  /* Page-align the nonpaged pool size */
329 
330  /* Now, check if there was a registry size for the maximum size */
332  {
333  /* Start with the default (1MB) and add 400 KB for each MB above 4 */
337  }
338 
339  /* Don't let the maximum go too high */
341  {
342  /* Set it to the upper limit */
344  }
345 
346  /* Convert nonpaged pool size from bytes to pages */
348 
349  /* Non paged pool starts after the PFN database */
351 
352  /* Calculate the nonpaged pool expansion start region */
356 
357  /* And this is where the none paged pool ends */
360 
361  /* Map PPEs and PDEs for non paged pool (including expansion) */
364 
365  /* Map the nonpaged pool PTEs (without expansion) */
367 
368  /* Initialize the ARM3 nonpaged pool */
371 
372 }
signed char * PCHAR
Definition: retypes.h:7
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define MI_MAX_NONPAGED_POOL_SIZE
Definition: mm.h:60
#define MM_HAL_VA_START
Definition: ketypes.h:256
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:145
SIZE_T MmMinimumNonPagedPoolSize
Definition: mminit.c:39
ULONG MmMaximumNonPagedPoolPercent
Definition: init.c:20
ULONG MmMaxAdditionNonPagedPoolPerMb
Definition: mminit.c:42
PVOID MmNonPagedPoolExpansionStart
Definition: init.c:25
VOID NTAPI MiMapPTEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:172
PMMPFN MmPfnDatabase
Definition: freelist.c:24
PVOID MmNonPagedPoolEnd
Definition: mminit.c:99
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:45
#define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING
Definition: mm.h:54
PFN_NUMBER MmMaximumNonPagedPoolInPages
Definition: mminit.c:30
ULONG MmMinAdditionNonPagedPoolPerMb
Definition: mminit.c:40
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PVOID MmNonPagedPoolStart
Definition: init.c:24
SIZE_T MmDefaultMaximumNonPagedPool
Definition: mminit.c:41
#define IS_PAGE_ALIGNED(addr)
Definition: init.c:23
ULONG MmMaximumNonPagedPoolInBytes
Definition: init.c:22
VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID)
Definition: pool.c:184
ULONG MmNumberOfPhysicalPages
Definition: init.c:48
#define MI_MAX_INIT_NONPAGED_POOL_SIZE
Definition: mm.h:59
ULONG MxPfnAllocation
Definition: init.c:43
#define UNIMPLEMENTED
Definition: debug.h:115
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:118
VOID NTAPI MiInitializeNonPagedPool(VOID)
Definition: pool.c:276
ULONG MmSizeOfNonPagedPoolInBytes
Definition: init.c:21

Referenced by MiInitMachineDependent().

◆ MiBuildPfnDatabase()

VOID NTAPI MiBuildPfnDatabase ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 615 of file init.c.

616 {
617  PLIST_ENTRY ListEntry;
619  PFN_NUMBER BasePage, PageCount;
620  KIRQL OldIrql;
621 
622  /* Lock the PFN Database */
624 
625  /* Map the PDEs and PPEs for the pfn database (ignore holes) */
626 #if (_MI_PAGING_LEVELS >= 3)
628 #endif
630 
631  /* First initialize the color tables */
633 
634  /* Loop the memory descriptors */
635  for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
636  ListEntry != &LoaderBlock->MemoryDescriptorListHead;
637  ListEntry = ListEntry->Flink)
638  {
639  /* Get the descriptor */
640  Descriptor = CONTAINING_RECORD(ListEntry,
642  ListEntry);
643 
644  /* Skip invisible memory */
645  if (MiIsMemoryTypeInvisible(Descriptor->MemoryType)) continue;
646 
647  /* If this is the free descriptor, use the copy instead */
649 
650  /* Get the range for this descriptor */
651  BasePage = Descriptor->BasePage;
652  PageCount = Descriptor->PageCount;
653 
654  /* Map the pages for the database */
655  MiMapPTEs(&MmPfnDatabase[BasePage],
656  (PUCHAR)(&MmPfnDatabase[BasePage + PageCount]) - 1);
657 
658  /* If this was the free descriptor, skip the next step */
659  if (Descriptor == &MxOldFreeDescriptor) continue;
660 
661  /* Add this descriptor to the database */
662  MiAddDescriptorToDatabase(BasePage, PageCount, Descriptor->MemoryType);
663  }
664 
665  /* At this point the whole pfn database is mapped. We are about to add the
666  pages from the free descriptor to the database, so from now on we cannot
667  use it anymore. */
668 
669  /* Now add the free descriptor */
670  BasePage = MxFreeDescriptor->BasePage;
671  PageCount = MxFreeDescriptor->PageCount;
672  MiAddDescriptorToDatabase(BasePage, PageCount, LoaderFree);
673 
674  /* And finally the memory we used */
675  BasePage = MxOldFreeDescriptor.BasePage;
676  PageCount = MxFreeDescriptor->BasePage - BasePage;
677  MiAddDescriptorToDatabase(BasePage, PageCount, LoaderMemoryData);
678 
679  /* Reset the descriptor back so we can create the correct memory blocks */
681 
682  /* Now process the page tables */
684 
685  /* PFNs are initialized now! */
687 
688  /* Release PFN database */
690 }
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:145
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:339
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
BOOLEAN MiPfnsInitialized
Definition: init.c:56
FORCEINLINE KIRQL MiAcquirePfnLock(VOID)
Definition: mm.h:900
VOID NTAPI MiMapPTEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:172
PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor
Definition: init.c:46
FORCEINLINE VOID MiReleasePfnLock(_In_ KIRQL OldIrql)
Definition: mm.h:907
PMMPFN MmPfnDatabase
Definition: freelist.c:24
UCHAR KIRQL
Definition: env_spec_w32.h:591
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:679
ULONG PFN_NUMBER
Definition: ke.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:119
static VOID MiAddDescriptorToDatabase(PFN_NUMBER BasePage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType)
Definition: init.c:545
ULONG MxPfnAllocation
Definition: init.c:43
VOID NTAPI MiInitializeColorTables(VOID)
Definition: mminit.c:562
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:118
MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor
Definition: init.c:47
static VOID MiBuildPfnDatabaseFromPageTables(VOID)
Definition: init.c:444

Referenced by MiInitMachineDependent().

◆ MiBuildPfnDatabaseFromPageTables()

static VOID MiBuildPfnDatabaseFromPageTables ( VOID  )
static

Definition at line 444 of file init.c.

445 {
446  PVOID Address = NULL;
447  PFN_NUMBER PageFrameIndex;
448  PMMPDE PointerPde;
449  PMMPTE PointerPte;
450  ULONG k, l;
451  PMMPFN Pfn;
452 #if (_MI_PAGING_LEVELS >= 3)
453  PMMPDE PointerPpe;
454  ULONG j;
455 #endif
456 #if (_MI_PAGING_LEVELS == 4)
457  PMMPDE PointerPxe;
458  ULONG i;
459 #endif
460 
461  /* Manual setup of the top level page directory */
462 #if (_MI_PAGING_LEVELS == 4)
463  PageFrameIndex = PFN_FROM_PTE(MiAddressToPte(PXE_BASE));
464 #elif (_MI_PAGING_LEVELS == 3)
465  PageFrameIndex = PFN_FROM_PTE(MiAddressToPte(PPE_BASE));
466 #else
467  PageFrameIndex = PFN_FROM_PTE(MiAddressToPte(PDE_BASE));
468 #endif
469  Pfn = MiGetPfnEntry(PageFrameIndex);
471  Pfn->u1.WsIndex = 0;
472  Pfn->u2.ShareCount = 1;
473  Pfn->PteAddress = NULL;
475  Pfn->u3.e2.ReferenceCount = 1;
476  Pfn->u4.PteFrame = 0;
477 
478 #if (_MI_PAGING_LEVELS == 4)
479  /* Loop all PXEs in the PML4 */
480  PointerPxe = MiAddressToPxe(Address);
481  for (i = 0; i < PXE_PER_PAGE; i++, PointerPxe++)
482  {
483  /* Skip invalid PXEs */
484  if (!PointerPxe->u.Hard.Valid) continue;
485 
486  /* Handle the PFN */
487  PageFrameIndex = PFN_FROM_PXE(PointerPxe);
488  MiSetupPfnForPageTable(PageFrameIndex, PointerPxe);
489 
490  /* Get starting VA for this PXE */
491  Address = MiPxeToAddress(PointerPxe);
492 #endif
493 #if (_MI_PAGING_LEVELS >= 3)
494  /* Loop all PPEs in this PDP */
495  PointerPpe = MiAddressToPpe(Address);
496  for (j = 0; j < PPE_PER_PAGE; j++, PointerPpe++)
497  {
498  /* Skip invalid PPEs */
499  if (!PointerPpe->u.Hard.Valid) continue;
500 
501  /* Handle the PFN */
502  PageFrameIndex = PFN_FROM_PPE(PointerPpe);
503  MiSetupPfnForPageTable(PageFrameIndex, PointerPpe);
504 
505  /* Get starting VA for this PPE */
506  Address = MiPpeToAddress(PointerPpe);
507 #endif
508  /* Loop all PDEs in this PD */
509  PointerPde = MiAddressToPde(Address);
510  for (k = 0; k < PDE_PER_PAGE; k++, PointerPde++)
511  {
512  /* Skip invalid PDEs */
513  if (!PointerPde->u.Hard.Valid) continue;
514 
515  /* Handle the PFN */
516  PageFrameIndex = PFN_FROM_PDE(PointerPde);
517  MiSetupPfnForPageTable(PageFrameIndex, PointerPde);
518 
519  /* Get starting VA for this PDE */
520  Address = MiPdeToAddress(PointerPde);
521 
522  /* Loop all PTEs in this PT */
523  PointerPte = MiAddressToPte(Address);
524  for (l = 0; l < PTE_PER_PAGE; l++, PointerPte++)
525  {
526  /* Skip invalid PTEs */
527  if (!PointerPte->u.Hard.Valid) continue;
528 
529  /* Handle the PFN */
530  PageFrameIndex = PFN_FROM_PTE(PointerPte);
531  MiSetupPfnForPageTable(PageFrameIndex, PointerPte);
532  }
533  }
534 #if (_MI_PAGING_LEVELS >= 3)
535  }
536 #endif
537 #if (_MI_PAGING_LEVELS == 4)
538  }
539 #endif
540 }
#define PDE_PER_PAGE
Definition: mm.h:21
#define PXE_PER_PAGE
#define PFN_FROM_PDE(v)
Definition: mm.h:93
#define MiAddressToPde(x)
Definition: mmx86.c:20
union _MMPTE::@2312 u
FORCEINLINE PMMPTE MiAddressToPpe(PVOID Address)
Definition: mm.h:154
#define PPE_PER_PAGE
Definition: mm.h:22
USHORT PageLocation
Definition: mm.h:303
union _MMPFN::@1784 u1
MMPFNENTRY e1
Definition: mm.h:335
USHORT CacheAttribute
Definition: mm.h:305
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:9
ULONG_PTR ShareCount
Definition: mm.h:328
#define PDE_BASE
Definition: winldr.c:21
static WCHAR Address[46]
Definition: ping.c:68
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
r l[0]
Definition: byte_order.h:167
struct _MMPFN::@1786::@1792 e2
union _MMPFN::@1785 u2
FORCEINLINE PMMPTE MiAddressToPxe(PVOID Address)
Definition: mm.h:164
#define ASSERT(a)
Definition: mode.c:45
ULONG64 Valid
Definition: mmtypes.h:150
#define PTE_PER_PAGE
Definition: mm.h:20
#define PPE_BASE
Definition: mm.h:311
FORCEINLINE PVOID MiPxeToAddress(PMMPTE PointerPxe)
Definition: mm.h:228
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
static VOID MiSetupPfnForPageTable(PFN_NUMBER PageFrameIndex, PMMPTE PointerPte)
Definition: init.c:409
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define PXE_BASE
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG_PTR PteFrame
Definition: mm.h:356
FORCEINLINE PVOID MiPdeToAddress(PMMPTE PointerPde)
Definition: mm.h:210
PMMPTE PteAddress
Definition: mm.h:324
#define NULL
Definition: types.h:112
union _MMPFN::@1789 u4
ULONG WsIndex
Definition: mm.h:316
union _MMPFN::@1786 u3
FORCEINLINE PVOID MiPpeToAddress(PMMPTE PointerPpe)
Definition: mm.h:219
unsigned int ULONG
Definition: retypes.h:1
#define PFN_FROM_PXE(v)
Definition: mm.h:95
#define PFN_FROM_PTE(v)
Definition: mm.h:92
int k
Definition: mpi.c:3369
#define PFN_FROM_PPE(v)
Definition: mm.h:94

Referenced by MiBuildPfnDatabase().

◆ MiBuildSystemPteSpace()

VOID NTAPI MiBuildSystemPteSpace ( VOID  )

Definition at line 377 of file init.c.

378 {
379  PMMPTE PointerPte;
380  SIZE_T NonPagedSystemSize;
381 
382  /* Use the default number of system PTEs */
384  NonPagedSystemSize = (MmNumberOfSystemPtes + 1) * PAGE_SIZE;
385 
386  /* Put system PTEs at the start of the system VA space */
388  MiSystemPteSpaceEnd = (PUCHAR)MiSystemPteSpaceStart + NonPagedSystemSize;
389 
390  /* Map the PPEs and PDEs for the system PTEs */
393 
394  /* Initialize the system PTE space */
397 
398  /* Reserve system PTEs for zeroing PTEs and clear them */
402 
403  /* Set the counter to maximum */
405 }
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:145
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
union _MMPTE::@2312 u
PVOID MiSystemPteSpaceStart
Definition: init.c:48
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG MmNumberOfSystemPtes
Definition: init.c:42
#define MiAddressToPte(x)
Definition: mmx86.c:19
PVOID MmNonPagedSystemStart
Definition: init.c:23
#define MI_NUMBER_SYSTEM_PTES
Definition: mm.h:79
VOID NTAPI MiInitializeSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE PoolType)
Definition: syspte.c:399
PVOID MiSystemPteSpaceEnd
Definition: init.c:49
#define PAGE_SIZE
Definition: env_spec_w32.h:49
ULONG_PTR SIZE_T
Definition: typedefs.h:80
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
PMMPTE MiFirstReservedZeroingPte
Definition: hypermap.c:21
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:118
#define MI_ZERO_PTES
Definition: mm.h:82

Referenced by MiInitMachineDependent().

◆ MiInitializePageTable()

VOID NTAPI MiInitializePageTable ( VOID  )

Definition at line 200 of file init.c.

201 {
202  ULONG64 PxePhysicalAddress;
203  MMPTE TmplPte, *PointerPxe;
204  PFN_NUMBER PxePfn;
205 
206  /* Get current directory base */
207  PxePfn = ((PMMPTE)PXE_SELFMAP)->u.Hard.PageFrameNumber;
208  PxePhysicalAddress = PxePfn << PAGE_SHIFT;
209  ASSERT(PxePhysicalAddress == __readcr3());
210 
211  /* Set directory base for the system process */
212  PsGetCurrentProcess()->Pcb.DirectoryTableBase[0] = PxePhysicalAddress;
213 
214  /* Enable global pages */
216  ASSERT(__readcr4() & CR4_PGE);
217 
218  /* Loop the user mode PXEs */
219  for (PointerPxe = MiAddressToPxe(0);
220  PointerPxe <= MiAddressToPxe(MmHighestUserAddress);
221  PointerPxe++)
222  {
223  /* Zero the PXE, clear all mappings */
224  PointerPxe->u.Long = 0;
225  }
226 
227  /* Flush the TLB */
229 
230  /* Set up a template PTE */
231  TmplPte.u.Long = 0;
232  TmplPte.u.Flush.Valid = 1;
233  TmplPte.u.Flush.Write = 1;
234  HyperTemplatePte = TmplPte;
235 
236  /* Create PDPTs (72 KB) for shared system address space,
237  * skip page tables TODO: use global pages. */
238 
239  /* Loop the PXEs */
240  for (PointerPxe = MiAddressToPxe((PVOID)HYPER_SPACE);
242  PointerPxe++)
243  {
244  /* Is the PXE already valid? */
245  if (!PointerPxe->u.Hard.Valid)
246  {
247  /* It's not Initialize it */
248  TmplPte.u.Flush.PageFrameNumber = MxGetNextPage(1);
249  *PointerPxe = TmplPte;
250 
251  /* Zero the page. The PXE is the PTE for the PDPT. */
252  RtlZeroMemory(MiPteToAddress(PointerPxe), PAGE_SIZE);
253  }
254  }
255 
256  /* Map PPEs for paged pool */
258 
259  /* Setup 1 PPE for hyper space */
261 
262  /* Setup PPEs for system space view */
264 
265  /* Setup the mapping PDEs */
267 
268  /* Setup the mapping PTEs */
272 
273  /* Setup debug mapping PTE */
277 
278  /* Setup PDE and PTEs for VAD bitmap and working set list */
281 }
ULONG64 Valid
Definition: mmtypes.h:66
signed char * PCHAR
Definition: retypes.h:7
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1728
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:145
union _MMPTE::@2312 u
#define MI_VAD_BITMAP
Definition: mm.h:50
HARDWARE_PTE Flush
Definition: mmtypes.h:216
PVOID MmPagedPoolEnd
Definition: init.c:26
PMMPTE MmLastReservedMappingPte
Definition: hypermap.c:20
VOID NTAPI MiMapPTEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:172
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1747
#define CR4_PGE
Definition: ketypes.h:91
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:9
ULONG MmSystemViewSize
Definition: init.c:39
PMMPTE MmFirstReservedMappingPte
Definition: hypermap.c:20
PVOID MiSystemViewStart
Definition: init.c:38
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define MI_HYPERSPACE_PTES
Definition: mm.h:81
#define PXE_SELFMAP
MMPTE HyperTemplatePte
Definition: hypermap.c:22
#define MI_DEBUG_MAPPING
Definition: mm.h:20
FORCEINLINE PMMPTE MiAddressToPxe(PVOID Address)
Definition: mm.h:164
#define ASSERT(a)
Definition: mode.c:45
#define MI_WORKING_SET_LIST
Definition: mm.h:51
#define MI_MAPPING_RANGE_END
Definition: mm.h:48
ULONG64 Valid
Definition: mmtypes.h:150
struct _MMPTE * PMMPTE
#define HYPER_SPACE_END
Definition: mm.h:15
unsigned __int64 ULONG64
Definition: imports.h:198
ULONG64 PageFrameNumber
Definition: mmtypes.h:78
PVOID MmHighestUserAddress
Definition: init.c:51
#define MI_MAPPING_RANGE_START
Definition: mm.h:47
#define PAGE_SIZE
Definition: env_spec_w32.h:49
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1754
ULONG_PTR Long
Definition: mmtypes.h:215
PVOID MmPagedPoolStart
Definition: miarm.h:581
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
ULONG64 Write
Definition: mmtypes.h:67
#define HYPER_SPACE
Definition: mm.h:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:118
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
PMMPTE MmDebugPte
Definition: mmdbg.c:31
#define MI_HIGHEST_SYSTEM_ADDRESS
Definition: mm.h:31
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:325

Referenced by MiInitMachineDependent().

◆ MiInitializeSessionSpaceLayout()

VOID NTAPI MiInitializeSessionSpaceLayout ( VOID  )

Definition at line 63 of file init.c.

64 {
65  /* This is the entire size */
67 
68  /* Start with session space end */
70 
71  /* The highest range is the session image range */
76 
77  /* Session working set is below the session image range */
79 
80  /* Session view is below the session working set */
85 
86  /* Session pool is below session view */
91 
92  /* And it all begins here */
94 
95  /* System view space ends at session space, so now that we know where
96  * this is, we can compute the base address of system view space itself. */
100 
101  /* Sanity checks */
105 
106  /* Compute the PTE addresses for all the addresses we carved out */
111 
112  /* Initialize the pointer to the session space structure */
114 }
#define Add2Ptr(PTR, INC)
#define MI_SESSION_SIZE
Definition: mm.h:66
PVOID MiSessionPoolStart
Definition: init.c:32
ULONG MmSessionSize
Definition: init.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
PVOID MiSessionImageStart
Definition: init.c:29
PMMPTE MiSessionLastPte
Definition: mminit.c:146
PMM_SESSION_SPACE MmSessionSpace
Definition: session.c:21
PVOID MiSessionSpaceWs
Definition: mminit.c:130
ULONG MmSessionImageSize
Definition: init.c:37
PVOID MmSessionBase
Definition: init.c:33
#define MI_SESSION_WORKING_SET_SIZE
Definition: mm.h:65
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG MmSystemViewSize
Definition: init.c:39
ULONG MmSessionViewSize
Definition: init.c:35
PVOID MiSystemViewStart
Definition: init.c:38
void * PVOID
Definition: retypes.h:9
PVOID MiSessionViewEnd
Definition: init.c:47
#define ASSERT(a)
Definition: mode.c:45
PVOID MiSessionSpaceEnd
Definition: init.c:27
#define MI_SESSION_IMAGE_SIZE
Definition: mm.h:64
PVOID MiSessionImageEnd
Definition: init.c:28
PMMPTE MiSessionImagePteStart
Definition: mminit.c:143
ULONG MmSessionPoolSize
Definition: init.c:36
PVOID MiSessionViewStart
Definition: init.c:30
#define IS_PAGE_ALIGNED(addr)
Definition: init.c:23
struct _MM_SESSION_SPACE * PMM_SESSION_SPACE
#define MI_SYSTEM_VIEW_SIZE
Definition: mm.h:61
#define MI_SESSION_SPACE_END
Definition: mm.h:25
PVOID MiSessionPoolEnd
Definition: init.c:31
#define MI_SESSION_VIEW_SIZE
Definition: mm.h:62
#define MI_SESSION_POOL_SIZE
Definition: mm.h:63
PMMPTE MiSessionBasePte
Definition: mminit.c:145
PMMPTE MiSessionImagePteEnd
Definition: mminit.c:144

Referenced by MmArmInitSystem().

◆ MiInitMachineDependent()

NTSTATUS NTAPI MiInitMachineDependent ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 695 of file init.c.

696 {
698  ULONG Flags;
699 
700  ASSERT(MxPfnAllocation != 0);
701 
702  /* Set some hardcoded addresses */
707 
708 
709 // PrototypePte.u.Proto.Valid = 1
710 // PrototypePte.u.ReadOnly
711 // PrototypePte.u.Prototype
712 // PrototypePte.u.Protection = MM_READWRITE;
713 // PrototypePte.u.ProtoAddress
715 
716 
718 
720 
722 
723  /* Map the PFN database pages */
724  MiBuildPfnDatabase(LoaderBlock);
725 
726  /* Initialize the nonpaged pool */
728 
729  /* Initialize the bogus address space */
730  Flags = 0;
732  if (!NT_SUCCESS(Status))
733  {
734  DPRINT1("MmInitializeProcessAddressSpace(9 failed: 0x%lx\n", Status);
735  return Status;
736  }
737 
738  /* Initialize the balancer */
740 
741  /* Make sure we have everything we need */
752 
753  return STATUS_SUCCESS;
754 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
VOID NTAPI MiBuildNonPagedPool(VOID)
Definition: init.c:286
#define MM_SYSTEM_SPACE_START
Definition: mm.h:19
MMPTE PrototypePte
Definition: init.c:40
#define MI_PFN_DATABASE
Definition: mm.h:28
VOID NTAPI InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold)
Definition: expool.c:1009
#define MiAddressToPde(x)
Definition: mmx86.c:20
VOID NTAPI MiInitializePageTable(VOID)
Definition: init.c:200
union _MMPTE::@2312 u
ULONG MmNumberOfSystemPtes
Definition: init.c:42
LONG NTSTATUS
Definition: precomp.h:26
PVOID MmNonPagedPoolExpansionStart
Definition: init.c:25
#define MI_PTE_LOOKUP_NEEDED
Definition: miarm.h:247
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
PMMPFN MmPfnDatabase
Definition: freelist.c:24
#define MiAddressToPte(x)
Definition: mmx86.c:19
PVOID MmNonPagedSystemStart
Definition: init.c:23
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:45
#define MI_WORKING_SET_LIST
Definition: mm.h:51
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI MmInitializeProcessAddressSpace(IN PEPROCESS Process, IN PEPROCESS Clone OPTIONAL, IN PVOID Section OPTIONAL, IN OUT PULONG Flags, IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
VOID NTAPI MiBuildSystemPteSpace(VOID)
Definition: init.c:377
VOID NTAPI MiBuildPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:615
#define HYPER_SPACE_END
Definition: mm.h:15
ULONG64 PageFileHigh
Definition: mmtypes.h:93
PMMWSL MmWorkingSetList
Definition: procsup.c:21
PVOID MmNonPagedPoolStart
Definition: init.c:24
VOID NTAPI MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages)
Definition: balance.c:46
ULONG MmMaximumNonPagedPoolInBytes
Definition: init.c:22
MMPTE_SOFTWARE Soft
Definition: mmtypes.h:219
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
ULONG MxPfnAllocation
Definition: init.c:43
PVOID MmHyperSpaceEnd
Definition: init.c:56
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG MmSizeOfNonPagedPoolInBytes
Definition: init.c:21

Referenced by MmArmInitSystem().

◆ MiMapPDEs()

VOID NTAPI MiMapPDEs ( PVOID  StartAddress,
PVOID  EndAddress 
)

Definition at line 145 of file init.c.

148 {
149  PMMPDE PointerPde;
150  MMPDE TmplPde = ValidKernelPde;
151 
152  /* Loop the PDEs */
153  for (PointerPde = MiAddressToPde(StartAddress);
154  PointerPde <= MiAddressToPde(EndAddress);
155  PointerPde++)
156  {
157  /* Check if its already mapped */
158  if (!PointerPde->u.Hard.Valid)
159  {
160  /* No, map it! */
161  TmplPde.u.Hard.PageFrameNumber = MxGetNextPage(1);
162  MI_WRITE_VALID_PTE(PointerPde, TmplPde);
163 
164  /* Zero out the page table */
165  RtlZeroMemory(MiPteToAddress(PointerPde), PAGE_SIZE);
166  }
167  }
168 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
union _MMPTE::@2312 u
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
ULONG64 Valid
Definition: mmtypes.h:150
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE ValidKernelPde
Definition: init.c:28
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201

Referenced by MiBuildNonPagedPool(), MiBuildPfnDatabase(), MiBuildSystemPteSpace(), and MiInitializePageTable().

◆ MiMapPPEs()

VOID NTAPI MiMapPPEs ( PVOID  StartAddress,
PVOID  EndAddress 
)

Definition at line 118 of file init.c.

121 {
122  PMMPDE PointerPpe;
123  MMPDE TmplPde = ValidKernelPde;
124 
125  /* Loop the PPEs */
126  for (PointerPpe = MiAddressToPpe(StartAddress);
127  PointerPpe <= MiAddressToPpe(EndAddress);
128  PointerPpe++)
129  {
130  /* Check if its already mapped */
131  if (!PointerPpe->u.Hard.Valid)
132  {
133  /* No, map it! */
134  TmplPde.u.Hard.PageFrameNumber = MxGetNextPage(1);
135  MI_WRITE_VALID_PTE(PointerPpe, TmplPde);
136 
137  /* Zero out the page table */
138  RtlZeroMemory(MiPteToAddress(PointerPpe), PAGE_SIZE);
139  }
140  }
141 }
union _MMPTE::@2312 u
FORCEINLINE PMMPTE MiAddressToPpe(PVOID Address)
Definition: mm.h:154
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
ULONG64 Valid
Definition: mmtypes.h:150
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE ValidKernelPde
Definition: init.c:28
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201

Referenced by MiBuildNonPagedPool(), MiBuildPfnDatabase(), MiBuildSystemPteSpace(), and MiInitializePageTable().

◆ MiMapPTEs()

VOID NTAPI MiMapPTEs ( PVOID  StartAddress,
PVOID  EndAddress 
)

Definition at line 172 of file init.c.

175 {
176  PMMPTE PointerPte;
177  MMPTE TmplPte = ValidKernelPte;
178 
179  /* Loop the PTEs */
180  for (PointerPte = MiAddressToPte(StartAddress);
181  PointerPte <= MiAddressToPte(EndAddress);
182  PointerPte++)
183  {
184  /* Check if its already mapped */
185  if (!PointerPte->u.Hard.Valid)
186  {
187  /* No, map it! */
188  TmplPte.u.Hard.PageFrameNumber = MxGetNextPage(1);
189  MI_WRITE_VALID_PTE(PointerPte, TmplPte);
190 
191  /* Zero out the page (FIXME: not always neccessary) */
192  RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE);
193  }
194  }
195 }
union _MMPTE::@2312 u
#define MiAddressToPte(x)
Definition: mmx86.c:19
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:942
ULONG64 Valid
Definition: mmtypes.h:150
MMPTE ValidKernelPte
Definition: init.c:29
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201

Referenced by MiBuildNonPagedPool(), MiBuildPfnDatabase(), and MiInitializePageTable().

◆ MiSetupPfnForPageTable()

static VOID MiSetupPfnForPageTable ( PFN_NUMBER  PageFrameIndex,
PMMPTE  PointerPte 
)
static

Definition at line 409 of file init.c.

412 {
413  PMMPFN Pfn;
414  PMMPDE PointerPde;
415 
416  /* Get the pfn entry for this page */
417  Pfn = MiGetPfnEntry(PageFrameIndex);
418 
419  /* Check if it's valid memory */
420  if ((PageFrameIndex <= MmHighestPhysicalPage) &&
421  (MmIsAddressValid(Pfn)) &&
422  (Pfn->u3.e1.PageLocation == ActiveAndValid))
423  {
424  /* Setup the PFN entry */
425  Pfn->u1.WsIndex = 0;
426  Pfn->u2.ShareCount++;
427  Pfn->PteAddress = PointerPte;
428  Pfn->OriginalPte = *PointerPte;
431  Pfn->u3.e2.ReferenceCount = 1;
432  Pfn->u4.PteFrame = PFN_FROM_PTE(MiAddressToPte(PointerPte));
433  }
434 
435  /* Increase the shared count of the PFN entry for the PDE */
436  PointerPde = MiAddressToPde(MiPteToAddress(PointerPte));
437  Pfn = MiGetPfnEntry(PFN_FROM_PTE(PointerPde));
438  Pfn->u2.ShareCount++;
439 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
USHORT PageLocation
Definition: mm.h:303
union _MMPFN::@1784 u1
MMPFNENTRY e1
Definition: mm.h:335
USHORT CacheAttribute
Definition: mm.h:305
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG_PTR ShareCount
Definition: mm.h:328
struct _MMPFN::@1786::@1792 e2
union _MMPFN::@1785 u2
ULONG MmHighestPhysicalPage
Definition: init.c:48
BOOLEAN NTAPI MmIsAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:174
Definition: mm.h:311
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:939
ULONG_PTR PteFrame
Definition: mm.h:356
PMMPTE PteAddress
Definition: mm.h:324
MMPTE OriginalPte
Definition: mm.h:345
union _MMPFN::@1789 u4
ULONG WsIndex
Definition: mm.h:316
union _MMPFN::@1786 u3
FORCEINLINE PVOID MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:201
#define PFN_FROM_PTE(v)
Definition: mm.h:92

Referenced by MiBuildPfnDatabaseFromPageTables().

Variable Documentation

◆ DemandZeroPde

Definition at line 36 of file init.c.

Referenced by MmArmAccessFault().

◆ DemandZeroPte

◆ MiIncludeType

BOOLEAN MiIncludeType[LoaderMaximum]

Definition at line 52 of file init.c.

◆ MiPfnsInitialized

BOOLEAN MiPfnsInitialized = FALSE

Definition at line 56 of file init.c.

Referenced by MiBuildPfnDatabase().

◆ MiSessionViewEnd

PVOID MiSessionViewEnd

Definition at line 47 of file init.c.

Referenced by MiInitializeSessionSpaceLayout().

◆ MiSystemPteSpaceEnd

PVOID MiSystemPteSpaceEnd

Definition at line 49 of file init.c.

Referenced by MiBuildSystemPteSpace().

◆ MiSystemPteSpaceStart

PVOID MiSystemPteSpaceStart

Definition at line 48 of file init.c.

Referenced by MiBuildSystemPteSpace().

◆ MmDebugPte

◆ MmDecommittedPte

◆ MxFreePageBase

PFN_NUMBER MxFreePageBase

Definition at line 53 of file init.c.

◆ MxFreePageCount

ULONG64 MxFreePageCount = 0

Definition at line 54 of file init.c.

◆ MxPfnSizeInBytes

ULONG64 MxPfnSizeInBytes

Definition at line 51 of file init.c.

◆ PrototypePte

MMPTE PrototypePte
Initial value:
PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << 32)}}
#define MI_PTE_LOOKUP_NEEDED
Definition: miarm.h:247
#define MM_PTE_SOFTWARE_PROTECTION_BITS
Definition: mm.h:75
#define MM_EXECUTE_READWRITE
Definition: miarm.h:45

Definition at line 40 of file init.c.

Referenced by MiDeletePte(), MiDeleteVirtualAddresses(), MiInitMachineDependent(), MiSetProtectionOnSection(), and MmArmAccessFault().

◆ ValidKernelPde

MMPTE ValidKernelPde = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}

◆ ValidKernelPdeLocal

MMPTE ValidKernelPdeLocal = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}

◆ ValidKernelPte

◆ ValidKernelPteLocal

MMPTE ValidKernelPteLocal = {{PTE_VALID|PTE_EXECUTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}