ReactOS  0.4.14-dev-815-ge410a12
init.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
#include <mm/ARM3/miarm.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define IS_ALIGNED(addr, align)   (((ULONG64)(addr) & (align - 1)) == 0)
 
#define IS_PAGE_ALIGNED(addr)   IS_ALIGNED(addr, PAGE_SIZE)
 

Functions

VOID NTAPI INIT_FUNCTION 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 INIT_FUNCTION MiInitializePageTable (VOID)
 
VOID NTAPI INIT_FUNCTION MiBuildNonPagedPool (VOID)
 
VOID NTAPI INIT_FUNCTION MiBuildSystemPteSpace (VOID)
 
static VOID MiSetupPfnForPageTable (PFN_NUMBER PageFrameIndex, PMMPTE PointerPte)
 
VOID NTAPI MiBuildPfnDatabaseFromPageTables (VOID)
 
VOID NTAPI INIT_FUNCTION MiAddDescriptorToDatabase (PFN_NUMBER BasePage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType)
 
VOID NTAPI INIT_FUNCTION MiBuildPfnDatabase (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI INIT_FUNCTION MiInitMachineDependent (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 

Variables

PMMPTE MmDebugPte
 
MMPTE ValidKernelPde = {{PTE_VALID|PTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPTE ValidKernelPte = {{PTE_VALID|PTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPTE ValidKernelPdeLocal = {{PTE_VALID|PTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPTE ValidKernelPteLocal = {{PTE_VALID|PTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}
 
MMPDE DemandZeroPde = {{MM_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_ALIGNED

#define IS_ALIGNED (   addr,
  align 
)    (((ULONG64)(addr) & (align - 1)) == 0)

Definition at line 22 of file init.c.

◆ IS_PAGE_ALIGNED

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

Definition at line 23 of file init.c.

Function Documentation

◆ MiAddDescriptorToDatabase()

VOID NTAPI INIT_FUNCTION MiAddDescriptorToDatabase ( PFN_NUMBER  BasePage,
PFN_NUMBER  PageCount,
TYPE_OF_MEMORY  MemoryType 
)

Definition at line 529 of file init.c.

533 {
534  PMMPFN Pfn;
535 
536  ASSERT(!MiIsMemoryTypeInvisible(MemoryType));
537 
538  /* Check if the memory is free */
539  if (MiIsMemoryTypeFree(MemoryType))
540  {
541  /* Get the last pfn of this descriptor. Note we loop backwards */
542  Pfn = &MmPfnDatabase[BasePage + PageCount - 1];
543 
544  /* Loop all pages */
545  while (PageCount--)
546  {
547  /* Add it to the free list */
549  MiInsertPageInFreeList(BasePage + PageCount);
550 
551  /* Go to the previous page */
552  Pfn--;
553  }
554  }
555  else if (MemoryType == LoaderXIPRom)
556  {
557  Pfn = &MmPfnDatabase[BasePage];
558  while (PageCount--)
559  {
560  /* Make it a pseudo-I/O ROM mapping */
561  Pfn->PteAddress = 0;
562  Pfn->u1.Flink = 0;
563  Pfn->u2.ShareCount = 0;
564  Pfn->u3.e1.PageLocation = 0;
566  Pfn->u3.e1.Rom = 1;
567  Pfn->u3.e1.PrototypePte = 1;
568  Pfn->u3.e2.ReferenceCount = 0;
569  Pfn->u4.InPageError = 0;
570  Pfn->u4.PteFrame = 0;
571 
572  /* Advance one */
573  Pfn++;
574  }
575  }
576  else if (MemoryType == LoaderBad)
577  {
578  // FIXME: later
579  ASSERT(FALSE);
580  }
581  else
582  {
583  /* For now skip it */
584  DbgPrint("Skipping BasePage=0x%lx, PageCount=0x%lx, MemoryType=%lx\n",
585  BasePage, PageCount, MemoryType);
586  Pfn = &MmPfnDatabase[BasePage];
587  while (PageCount--)
588  {
589  /* Make an active PFN */
591 
592  /* Advance one */
593  Pfn++;
594  }
595  }
596 }
VOID NTAPI MiInsertPageInFreeList(IN PFN_NUMBER PageFrameIndex)
Definition: pfnlist.c:604
#define DbgPrint
Definition: loader.c:25
PFN_NUMBER Flink
Definition: mm.h:309
union _MMPFN::@1747 u4
struct _MMPFN::@1744::@1750 e2
USHORT PageLocation
Definition: mm.h:297
PMMPFN MmPfnDatabase
Definition: freelist.c:24
USHORT PrototypePte
Definition: mm.h:295
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:688
MMPFNENTRY e1
Definition: mm.h:329
USHORT CacheAttribute
Definition: mm.h:299
ULONG_PTR ShareCount
Definition: mm.h:322
Definition: arc.h:130
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _MMPFN::@1742 u1
Definition: mm.h:305
union _MMPFN::@1743 u2
ULONG_PTR PteFrame
Definition: mm.h:350
USHORT Rom
Definition: mm.h:300
PMMPTE PteAddress
Definition: mm.h:318
FORCEINLINE BOOLEAN MiIsMemoryTypeFree(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:678
union _MMPFN::@1744 u3
ULONG_PTR InPageError
Definition: mm.h:351

Referenced by MiBuildPfnDatabase().

◆ MiBuildNonPagedPool()

VOID NTAPI INIT_FUNCTION MiBuildNonPagedPool ( VOID  )

Definition at line 272 of file init.c.

273 {
274  /* Check if this is a machine with less than 256MB of RAM, and no overide */
277  {
278  /* Force the non paged pool to be 2MB so we can reduce RAM usage */
279  MmSizeOfNonPagedPoolInBytes = 2 * 1024 * 1024;
280  }
281 
282  /* Check if the user gave a ridicuously large nonpaged pool RAM size */
284  (MmNumberOfPhysicalPages * 7 / 8))
285  {
286  /* More than 7/8ths of RAM was dedicated to nonpaged pool, ignore! */
288  }
289 
290  /* Check if no registry setting was set, or if the setting was too low */
292  {
293  /* Start with the minimum (256 KB) and add 32 KB for each MB above 4 */
297  }
298 
299  /* Check if the registy setting or our dynamic calculation was too high */
301  {
302  /* Set it to the maximum */
304  }
305 
306  /* Check if a percentage cap was set through the registry */
308  {
309  /* Don't feel like supporting this right now */
311  }
312 
313  /* Page-align the nonpaged pool size */
315 
316  /* Now, check if there was a registry size for the maximum size */
318  {
319  /* Start with the default (1MB) and add 400 KB for each MB above 4 */
323  }
324 
325  /* Don't let the maximum go too high */
327  {
328  /* Set it to the upper limit */
330  }
331 
332  /* Convert nonpaged pool size from bytes to pages */
334 
335  /* Non paged pool starts after the PFN database */
337 
338  /* Calculate the nonpaged pool expansion start region */
342 
343  /* And this is where the none paged pool ends */
346 
347  /* Map PPEs and PDEs for non paged pool (including expansion) */
350 
351  /* Map the nonpaged pool PTEs (without expansion) */
353 
354  /* Initialize the ARM3 nonpaged pool */
357 
358 }
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:57
#define MM_HAL_VA_START
Definition: ketypes.h:256
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:131
INIT_FUNCTION VOID NTAPI MiInitializeNonPagedPool(VOID)
Definition: pool.c:276
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:158
PMMPFN MmPfnDatabase
Definition: freelist.c:24
PVOID MmNonPagedPoolEnd
Definition: mminit.c:99
#define PCHAR
Definition: match.c:90
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING
Definition: mm.h:51
INIT_FUNCTION VOID NTAPI MiInitializeNonPagedPoolThresholds(VOID)
Definition: pool.c:184
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
ULONG MmNumberOfPhysicalPages
Definition: init.c:48
#define MI_MAX_INIT_NONPAGED_POOL_SIZE
Definition: mm.h:56
ULONG MxPfnAllocation
Definition: init.c:43
#define UNIMPLEMENTED
Definition: debug.h:114
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:104
ULONG MmSizeOfNonPagedPoolInBytes
Definition: init.c:21

Referenced by MiInitMachineDependent().

◆ MiBuildPfnDatabase()

VOID NTAPI INIT_FUNCTION MiBuildPfnDatabase ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 601 of file init.c.

602 {
603  PLIST_ENTRY ListEntry;
605  PFN_NUMBER BasePage, PageCount;
606 
607  /* Map the PDEs and PPEs for the pfn database (ignore holes) */
608 #if (_MI_PAGING_LEVELS >= 3)
610 #endif
612 
613  /* First initialize the color tables */
615 
616  /* Loop the memory descriptors */
617  for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink;
618  ListEntry != &LoaderBlock->MemoryDescriptorListHead;
619  ListEntry = ListEntry->Flink)
620  {
621  /* Get the descriptor */
622  Descriptor = CONTAINING_RECORD(ListEntry,
624  ListEntry);
625 
626  /* Skip invisible memory */
627  if (MiIsMemoryTypeInvisible(Descriptor->MemoryType)) continue;
628 
629  /* If this is the free descriptor, use the copy instead */
631 
632  /* Get the range for this descriptor */
633  BasePage = Descriptor->BasePage;
634  PageCount = Descriptor->PageCount;
635 
636  /* Map the pages for the database */
637  MiMapPTEs(&MmPfnDatabase[BasePage],
638  (PUCHAR)(&MmPfnDatabase[BasePage + PageCount]) - 1);
639 
640  /* If this was the free descriptor, skip the next step */
641  if (Descriptor == &MxOldFreeDescriptor) continue;
642 
643  /* Add this descriptor to the database */
644  MiAddDescriptorToDatabase(BasePage, PageCount, Descriptor->MemoryType);
645  }
646 
647  /* At this point the whole pfn database is mapped. We are about to add the
648  pages from the free descriptor to the database, so from now on we cannot
649  use it anymore. */
650 
651  /* Now add the free descriptor */
652  BasePage = MxFreeDescriptor->BasePage;
653  PageCount = MxFreeDescriptor->PageCount;
654  MiAddDescriptorToDatabase(BasePage, PageCount, LoaderFree);
655 
656  /* And finally the memory we used */
657  BasePage = MxOldFreeDescriptor.BasePage;
658  PageCount = MxFreeDescriptor->BasePage - BasePage;
659  MiAddDescriptorToDatabase(BasePage, PageCount, LoaderMemoryData);
660 
661  /* Reset the descriptor back so we can create the correct memory blocks */
663 }
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:131
unsigned char * PUCHAR
Definition: retypes.h:3
VOID NTAPI MiMapPTEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:158
PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor
Definition: init.c:46
PMMPFN MmPfnDatabase
Definition: freelist.c:24
FORCEINLINE BOOLEAN MiIsMemoryTypeInvisible(TYPE_OF_MEMORY MemoryType)
Definition: miarm.h:688
ULONG PFN_NUMBER
Definition: ke.h:8
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:119
VOID NTAPI INIT_FUNCTION MiAddDescriptorToDatabase(PFN_NUMBER BasePage, PFN_NUMBER PageCount, TYPE_OF_MEMORY MemoryType)
Definition: init.c:529
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
ULONG MxPfnAllocation
Definition: init.c:43
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:104
MEMORY_ALLOCATION_DESCRIPTOR MxOldFreeDescriptor
Definition: init.c:47
INIT_FUNCTION VOID NTAPI MiInitializeColorTables(VOID)
Definition: mminit.c:562
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by MiInitMachineDependent().

◆ MiBuildPfnDatabaseFromPageTables()

VOID NTAPI MiBuildPfnDatabaseFromPageTables ( VOID  )

Definition at line 428 of file init.c.

429 {
430  PVOID Address = NULL;
431  PFN_NUMBER PageFrameIndex;
432  PMMPDE PointerPde;
433  PMMPTE PointerPte;
434  ULONG k, l;
435  PMMPFN Pfn;
436 #if (_MI_PAGING_LEVELS >= 3)
437  PMMPDE PointerPpe;
438  ULONG j;
439 #endif
440 #if (_MI_PAGING_LEVELS == 4)
441  PMMPDE PointerPxe;
442  ULONG i;
443 #endif
444 
445  /* Manual setup of the top level page directory */
446 #if (_MI_PAGING_LEVELS == 4)
447  PageFrameIndex = PFN_FROM_PTE(MiAddressToPte(PXE_BASE));
448 #elif (_MI_PAGING_LEVELS == 3)
449  PageFrameIndex = PFN_FROM_PTE(MiAddressToPte(PPE_BASE));
450 #else
451  PageFrameIndex = PFN_FROM_PTE(MiAddressToPte(PDE_BASE));
452 #endif
453  Pfn = MiGetPfnEntry(PageFrameIndex);
455  Pfn->u1.WsIndex = 0;
456  Pfn->u2.ShareCount = 1;
457  Pfn->PteAddress = NULL;
459  Pfn->u3.e2.ReferenceCount = 1;
460  Pfn->u4.PteFrame = 0;
461 
462 #if (_MI_PAGING_LEVELS == 4)
463  /* Loop all PXEs in the PML4 */
464  PointerPxe = MiAddressToPxe(Address);
465  for (i = 0; i < PXE_PER_PAGE; i++, PointerPxe++)
466  {
467  /* Skip invalid PXEs */
468  if (!PointerPxe->u.Hard.Valid) continue;
469 
470  /* Handle the PFN */
471  PageFrameIndex = PFN_FROM_PXE(PointerPxe);
472  MiSetupPfnForPageTable(PageFrameIndex, PointerPxe);
473 
474  /* Get starting VA for this PXE */
475  Address = MiPxeToAddress(PointerPxe);
476 #endif
477 #if (_MI_PAGING_LEVELS >= 3)
478  /* Loop all PPEs in this PDP */
479  PointerPpe = MiAddressToPpe(Address);
480  for (j = 0; j < PPE_PER_PAGE; j++, PointerPpe++)
481  {
482  /* Skip invalid PPEs */
483  if (!PointerPpe->u.Hard.Valid) continue;
484 
485  /* Handle the PFN */
486  PageFrameIndex = PFN_FROM_PPE(PointerPpe);
487  MiSetupPfnForPageTable(PageFrameIndex, PointerPpe);
488 
489  /* Get starting VA for this PPE */
490  Address = MiPpeToAddress(PointerPpe);
491 #endif
492  /* Loop all PDEs in this PD */
493  PointerPde = MiAddressToPde(Address);
494  for (k = 0; k < PDE_PER_PAGE; k++, PointerPde++)
495  {
496  /* Skip invalid PDEs */
497  if (!PointerPde->u.Hard.Valid) continue;
498 
499  /* Handle the PFN */
500  PageFrameIndex = PFN_FROM_PDE(PointerPde);
501  MiSetupPfnForPageTable(PageFrameIndex, PointerPde);
502 
503  /* Get starting VA for this PDE */
504  Address = MiPdeToAddress(PointerPde);
505 
506  /* Loop all PTEs in this PT */
507  PointerPte = MiAddressToPte(Address);
508  for (l = 0; l < PTE_PER_PAGE; l++, PointerPte++)
509  {
510  /* Skip invalid PTEs */
511  if (!PointerPte->u.Hard.Valid) continue;
512 
513  /* Handle the PFN */
514  PageFrameIndex = PFN_FROM_PTE(PointerPte);
515  MiSetupPfnForPageTable(PageFrameIndex, PointerPte);
516  }
517  }
518 #if (_MI_PAGING_LEVELS >= 3)
519  }
520 #endif
521 #if (_MI_PAGING_LEVELS == 4)
522  }
523 #endif
524 }
#define PDE_PER_PAGE
Definition: mm.h:21
#define PXE_PER_PAGE
#define PFN_FROM_PDE(v)
Definition: mm.h:90
#define MiAddressToPde(x)
Definition: mmx86.c:20
PVOID FORCEINLINE MiPpeToAddress(PMMPTE PointerPpe)
Definition: mm.h:216
PVOID FORCEINLINE MiPxeToAddress(PMMPTE PointerPxe)
Definition: mm.h:225
PMMPTE FORCEINLINE MiAddressToPpe(PVOID Address)
Definition: mm.h:151
union _MMPFN::@1747 u4
#define PPE_PER_PAGE
Definition: mm.h:22
struct _MMPFN::@1744::@1750 e2
USHORT PageLocation
Definition: mm.h:297
MMPFNENTRY e1
Definition: mm.h:329
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
USHORT CacheAttribute
Definition: mm.h:299
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:8
ULONG_PTR ShareCount
Definition: mm.h:322
#define PDE_BASE
Definition: winldr.c:21
smooth NULL
Definition: ftsmooth.c:416
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
PVOID FORCEINLINE MiPdeToAddress(PMMPTE PointerPde)
Definition: mm.h:207
ULONG64 Valid
Definition: mmtypes.h:150
#define PTE_PER_PAGE
Definition: mm.h:20
#define PPE_BASE
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _MMPFN::@1742 u1
union _MMPTE::@2251 u
Definition: mm.h:305
PMMPTE FORCEINLINE MiAddressToPxe(PVOID Address)
Definition: mm.h:161
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:940
union _MMPFN::@1743 u2
static VOID MiSetupPfnForPageTable(PFN_NUMBER PageFrameIndex, PMMPTE PointerPte)
Definition: init.c:394
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define PXE_BASE
ULONG_PTR PteFrame
Definition: mm.h:350
PMMPTE PteAddress
Definition: mm.h:318
ULONG WsIndex
Definition: mm.h:310
unsigned int ULONG
Definition: retypes.h:1
#define PFN_FROM_PXE(v)
Definition: mm.h:92
union _MMPFN::@1744 u3
#define PFN_FROM_PTE(v)
Definition: mm.h:89
int k
Definition: mpi.c:3369
#define PFN_FROM_PPE(v)
Definition: mm.h:91

Referenced by MiInitMachineDependent().

◆ MiBuildSystemPteSpace()

VOID NTAPI INIT_FUNCTION MiBuildSystemPteSpace ( VOID  )

Definition at line 363 of file init.c.

364 {
365  PMMPTE PointerPte;
366  SIZE_T NonPagedSystemSize;
367 
368  /* Use the default number of system PTEs */
370  NonPagedSystemSize = (MmNumberOfSystemPtes + 1) * PAGE_SIZE;
371 
372  /* Put system PTEs at the start of the system VA space */
374  MiSystemPteSpaceEnd = (PUCHAR)MiSystemPteSpaceStart + NonPagedSystemSize;
375 
376  /* Map the PPEs and PDEs for the system PTEs */
379 
380  /* Initialize the system PTE space */
383 
384  /* Reserve system PTEs for zeroing PTEs and clear them */
387 
388  /* Set the counter to maximum */
390 }
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:131
PMMPTE NTAPI MiReserveSystemPtes(IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE SystemPtePoolType)
Definition: syspte.c:246
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:76
union _MMPTE::@2251 u
PVOID MiSystemPteSpaceEnd
Definition: init.c:49
#define PAGE_SIZE
Definition: env_spec_w32.h:49
INIT_FUNCTION VOID NTAPI MiInitializeSystemPtes(IN PMMPTE StartingPte, IN ULONG NumberOfPtes, IN MMSYSTEM_PTE_POOL_TYPE PoolType)
Definition: syspte.c:399
ULONG_PTR SIZE_T
Definition: typedefs.h:78
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
PMMPTE MiFirstReservedZeroingPte
Definition: hypermap.c:21
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:104
#define MI_ZERO_PTES
Definition: mm.h:79

Referenced by MiInitMachineDependent().

◆ MiInitializePageTable()

VOID NTAPI INIT_FUNCTION MiInitializePageTable ( VOID  )

Definition at line 186 of file init.c.

187 {
188  ULONG64 PxePhysicalAddress;
189  MMPTE TmplPte, *PointerPxe;
190  PFN_NUMBER PxePfn;
191 
192  /* Get current directory base */
193  PxePfn = ((PMMPTE)PXE_SELFMAP)->u.Hard.PageFrameNumber;
194  PxePhysicalAddress = PxePfn << PAGE_SHIFT;
195  ASSERT(PxePhysicalAddress == __readcr3());
196 
197  /* Set directory base for the system process */
198  PsGetCurrentProcess()->Pcb.DirectoryTableBase[0] = PxePhysicalAddress;
199 
200  /* Enable global pages */
202  ASSERT(__readcr4() & CR4_PGE);
203 
204  /* Loop the user mode PXEs */
205  for (PointerPxe = MiAddressToPxe(0);
206  PointerPxe <= MiAddressToPxe(MmHighestUserAddress);
207  PointerPxe++)
208  {
209  /* Zero the PXE, clear all mappings */
210  PointerPxe->u.Long = 0;
211  }
212 
213  /* Flush the TLB */
215 
216  /* Set up a template PTE */
217  TmplPte.u.Long = 0;
218  TmplPte.u.Flush.Valid = 1;
219  TmplPte.u.Flush.Write = 1;
220  HyperTemplatePte = TmplPte;
221 
222  /* Create PDPTs (72 KB) for shared system address space,
223  * skip page tables TODO: use global pages. */
224 
225  /* Loop the PXEs */
226  for (PointerPxe = MiAddressToPxe((PVOID)HYPER_SPACE);
228  PointerPxe++)
229  {
230  /* Is the PXE already valid? */
231  if (!PointerPxe->u.Hard.Valid)
232  {
233  /* It's not Initialize it */
234  TmplPte.u.Flush.PageFrameNumber = MxGetNextPage(1);
235  *PointerPxe = TmplPte;
236 
237  /* Zero the page. The PXE is the PTE for the PDPT. */
238  RtlZeroMemory(MiPteToAddress(PointerPxe), PAGE_SIZE);
239  }
240  }
241 
242  /* Map PPEs for paged pool */
244 
245  /* Setup 1 PPE for hyper space */
247 
248  /* Setup PPEs for system space view */
250 
251  /* Setup the mapping PDEs */
253 
254  /* Setup the mapping PTEs */
258 
259  /* Setup debug mapping PTE */
263 
264  /* Setup PDE and PTEs for VAD bitmap and working set list */
267 }
ULONG64 Valid
Definition: mmtypes.h:66
signed char * PCHAR
Definition: retypes.h:7
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1680
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
VOID NTAPI MiMapPDEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:131
#define MI_VAD_BITMAP
Definition: mm.h:47
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:158
__INTRIN_INLINE unsigned long __readcr3(void)
Definition: intrin_x86.h:1706
INIT_FUNCTION PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
#define CR4_PGE
Definition: ketypes.h:91
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG PFN_NUMBER
Definition: ke.h:8
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:78
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
#define PXE_SELFMAP
MMPTE HyperTemplatePte
Definition: hypermap.c:22
#define MI_DEBUG_MAPPING
Definition: mm.h:20
#define MI_WORKING_SET_LIST
Definition: mm.h:48
#define MI_MAPPING_RANGE_END
Definition: mm.h:45
ULONG64 Valid
Definition: mmtypes.h:150
struct _MMPTE * PMMPTE
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#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:44
union _MMPTE::@2251 u
PMMPTE FORCEINLINE MiAddressToPxe(PVOID Address)
Definition: mm.h:161
#define PAGE_SIZE
Definition: env_spec_w32.h:49
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1713
ULONG_PTR Long
Definition: mmtypes.h:215
PVOID MmPagedPoolStart
Definition: miarm.h:589
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
ULONG64 Write
Definition: mmtypes.h:67
#define HYPER_SPACE
Definition: mm.h:14
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG64 PageFrameNumber
Definition: mmtypes.h:171
VOID NTAPI MiMapPPEs(PVOID StartAddress, PVOID EndAddress)
Definition: init.c:104
PMMPTE MmDebugPte
Definition: mmdbg.c:33
#define MI_HIGHEST_SYSTEM_ADDRESS
Definition: mm.h:31
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:322

Referenced by MiInitMachineDependent().

◆ MiInitializeSessionSpaceLayout()

VOID NTAPI INIT_FUNCTION MiInitializeSessionSpaceLayout ( VOID  )

Definition at line 63 of file init.c.

64 {
70 
71  /* Set up session space */
73 
74  /* This is where we will load Win32k.sys and the video driver */
77 
78  /* The view starts right below the session working set (itself below
79  * the image area) */
83 
84  /* Session pool follows */
88 
89  /* And it all begins here */
91 
92  /* System view space ends at session space, so now that we know where
93  * this is, we can compute the base address of system view space itself. */
96 
97  /* Sanity checks */
100 }
#define MI_SESSION_SIZE
Definition: mm.h:63
PVOID MiSessionPoolStart
Definition: init.c:32
ULONG MmSessionSize
Definition: init.c:34
PVOID MiSessionImageStart
Definition: init.c:29
ULONG MmSessionImageSize
Definition: init.c:37
PVOID MmSessionBase
Definition: init.c:33
ULONG MmSystemViewSize
Definition: init.c:39
ULONG MmSessionViewSize
Definition: init.c:35
PVOID MiSystemViewStart
Definition: init.c:38
void * PVOID
Definition: retypes.h:9
#define PCHAR
Definition: match.c:90
PVOID MiSessionViewEnd
Definition: init.c:47
PVOID MiSessionSpaceEnd
Definition: init.c:27
#define MI_SESSION_IMAGE_SIZE
Definition: mm.h:61
PVOID MiSessionImageEnd
Definition: init.c:28
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG MmSessionPoolSize
Definition: init.c:36
PVOID MiSessionViewStart
Definition: init.c:30
#define IS_PAGE_ALIGNED(addr)
Definition: init.c:23
#define MI_SESSION_VIEW_END
Definition: mm.h:24
#define MI_SYSTEM_VIEW_SIZE
Definition: mm.h:58
#define MI_SESSION_SPACE_END
Definition: mm.h:25
PVOID MiSessionPoolEnd
Definition: init.c:31
#define MI_SESSION_VIEW_SIZE
Definition: mm.h:59
#define MI_SESSION_POOL_SIZE
Definition: mm.h:60

Referenced by MmArmInitSystem().

◆ MiInitMachineDependent()

NTSTATUS NTAPI INIT_FUNCTION MiInitMachineDependent ( IN PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 668 of file init.c.

669 {
670  KIRQL OldIrql;
671 
672  ASSERT(MxPfnAllocation != 0);
673 
674  /* Set some hardcoded addresses */
679 
680 
681 // PrototypePte.u.Proto.Valid = 1
682 // PrototypePte.u.ReadOnly
683 // PrototypePte.u.Prototype
684 // PrototypePte.u.Protection = MM_READWRITE;
685 // PrototypePte.u.ProtoAddress
687 
688 
690 
692 
694 
695  /* Need to be at DISPATCH_LEVEL for MiInsertPageInFreeList */
697 
698  /* Map the PFN database pages */
699  MiBuildPfnDatabase(LoaderBlock);
700 
701  /* Now process the page tables */
703 
704  /* PFNs are initialized now! */
706 
707  //KeLowerIrql(OldIrql);
708 
709  /* Need to be at DISPATCH_LEVEL for InitializePool */
710  //KeRaiseIrql(DISPATCH_LEVEL, &OldIrql);
711 
712  /* Initialize the nonpaged pool */
714 
716 
717  /* Initialize the balancer */
719 
720  /* Make sure we have everything we need */
731 
732  return STATUS_SUCCESS;
733 }
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
#define MM_SYSTEM_SPACE_START
Definition: mm.h:19
INIT_FUNCTION VOID NTAPI InitializePool(IN POOL_TYPE PoolType, IN ULONG Threshold)
Definition: expool.c:1009
MMPTE PrototypePte
Definition: init.c:40
#define MI_PFN_DATABASE
Definition: mm.h:28
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define MiAddressToPde(x)
Definition: mmx86.c:20
ULONG MmNumberOfSystemPtes
Definition: init.c:42
PVOID MmNonPagedPoolExpansionStart
Definition: init.c:25
#define MI_PTE_LOOKUP_NEEDED
Definition: miarm.h:255
BOOLEAN MiPfnsInitialized
Definition: init.c:56
VOID NTAPI INIT_FUNCTION MiInitializePageTable(VOID)
Definition: init.c:186
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
PMMPFN MmPfnDatabase
Definition: freelist.c:24
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define MiAddressToPte(x)
Definition: mmx86.c:19
PVOID MmNonPagedSystemStart
Definition: init.c:23
void * PVOID
Definition: retypes.h:9
VOID NTAPI MiBuildPfnDatabaseFromPageTables(VOID)
Definition: init.c:428
#define MI_WORKING_SET_LIST
Definition: mm.h:48
VOID NTAPI INIT_FUNCTION MiBuildNonPagedPool(VOID)
Definition: init.c:272
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define HYPER_SPACE_END
Definition: mm.h:15
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
ULONG64 PageFileHigh
Definition: mmtypes.h:93
union _MMPTE::@2251 u
PMMWSL MmWorkingSetList
Definition: procsup.c:21
PVOID MmNonPagedPoolStart
Definition: init.c:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
INIT_FUNCTION VOID NTAPI MmInitializeBalancer(ULONG NrAvailablePages, ULONG NrSystemPages)
Definition: balance.c:53
ULONG MmMaximumNonPagedPoolInBytes
Definition: init.c:22
MMPTE_SOFTWARE Soft
Definition: mmtypes.h:219
ULONG MxPfnAllocation
Definition: init.c:43
PVOID MmHyperSpaceEnd
Definition: init.c:56
unsigned int ULONG
Definition: retypes.h:1
ULONG MmSizeOfNonPagedPoolInBytes
Definition: init.c:21
return STATUS_SUCCESS
Definition: btrfs.c:2938
VOID NTAPI INIT_FUNCTION MiBuildPfnDatabase(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: init.c:601
VOID NTAPI INIT_FUNCTION MiBuildSystemPteSpace(VOID)
Definition: init.c:363

Referenced by MmArmInitSystem().

◆ MiMapPDEs()

VOID NTAPI MiMapPDEs ( PVOID  StartAddress,
PVOID  EndAddress 
)

Definition at line 131 of file init.c.

134 {
135  PMMPDE PointerPde;
136  MMPDE TmplPde = ValidKernelPde;
137 
138  /* Loop the PDEs */
139  for (PointerPde = MiAddressToPde(StartAddress);
140  PointerPde <= MiAddressToPde(EndAddress);
141  PointerPde++)
142  {
143  /* Check if its already mapped */
144  if (!PointerPde->u.Hard.Valid)
145  {
146  /* No, map it! */
147  TmplPde.u.Hard.PageFrameNumber = MxGetNextPage(1);
148  MI_WRITE_VALID_PTE(PointerPde, TmplPde);
149 
150  /* Zero out the page table */
151  RtlZeroMemory(MiPteToAddress(PointerPde), PAGE_SIZE);
152  }
153  }
154 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
INIT_FUNCTION PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:951
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
ULONG64 Valid
Definition: mmtypes.h:150
union _MMPTE::@2251 u
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE ValidKernelPde
Definition: init.c:28
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG64 PageFrameNumber
Definition: mmtypes.h:171

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

◆ MiMapPPEs()

VOID NTAPI MiMapPPEs ( PVOID  StartAddress,
PVOID  EndAddress 
)

Definition at line 104 of file init.c.

107 {
108  PMMPDE PointerPpe;
109  MMPDE TmplPde = ValidKernelPde;
110 
111  /* Loop the PPEs */
112  for (PointerPpe = MiAddressToPpe(StartAddress);
113  PointerPpe <= MiAddressToPpe(EndAddress);
114  PointerPpe++)
115  {
116  /* Check if its already mapped */
117  if (!PointerPpe->u.Hard.Valid)
118  {
119  /* No, map it! */
120  TmplPde.u.Hard.PageFrameNumber = MxGetNextPage(1);
121  MI_WRITE_VALID_PTE(PointerPpe, TmplPde);
122 
123  /* Zero out the page table */
124  RtlZeroMemory(MiPteToAddress(PointerPpe), PAGE_SIZE);
125  }
126  }
127 }
PMMPTE FORCEINLINE MiAddressToPpe(PVOID Address)
Definition: mm.h:151
INIT_FUNCTION PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:951
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
ULONG64 Valid
Definition: mmtypes.h:150
union _MMPTE::@2251 u
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE ValidKernelPde
Definition: init.c:28
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG64 PageFrameNumber
Definition: mmtypes.h:171

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

◆ MiMapPTEs()

VOID NTAPI MiMapPTEs ( PVOID  StartAddress,
PVOID  EndAddress 
)

Definition at line 158 of file init.c.

161 {
162  PMMPTE PointerPte;
163  MMPTE TmplPte = ValidKernelPte;
164 
165  /* Loop the PTEs */
166  for (PointerPte = MiAddressToPte(StartAddress);
167  PointerPte <= MiAddressToPte(EndAddress);
168  PointerPte++)
169  {
170  /* Check if its already mapped */
171  if (!PointerPte->u.Hard.Valid)
172  {
173  /* No, map it! */
174  TmplPte.u.Hard.PageFrameNumber = MxGetNextPage(1);
175  MI_WRITE_VALID_PTE(PointerPte, TmplPte);
176 
177  /* Zero out the page (FIXME: not always neccessary) */
178  RtlZeroMemory(MiPteToAddress(PointerPte), PAGE_SIZE);
179  }
180  }
181 }
INIT_FUNCTION PFN_NUMBER NTAPI MxGetNextPage(IN PFN_NUMBER PageCount)
Definition: mminit.c:483
#define MiAddressToPte(x)
Definition: mmx86.c:19
FORCEINLINE VOID MI_WRITE_VALID_PTE(IN PMMPTE PointerPte, IN MMPTE TempPte)
Definition: miarm.h:951
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
ULONG64 Valid
Definition: mmtypes.h:150
MMPTE ValidKernelPte
Definition: init.c:29
union _MMPTE::@2251 u
#define PAGE_SIZE
Definition: env_spec_w32.h:49
MMPTE_HARDWARE Hard
Definition: mmtypes.h:217
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG64 PageFrameNumber
Definition: mmtypes.h:171

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

◆ MiSetupPfnForPageTable()

static VOID MiSetupPfnForPageTable ( PFN_NUMBER  PageFrameIndex,
PMMPTE  PointerPte 
)
static

Definition at line 394 of file init.c.

397 {
398  PMMPFN Pfn;
399  PMMPDE PointerPde;
400 
401  /* Get the pfn entry for this page */
402  Pfn = MiGetPfnEntry(PageFrameIndex);
403 
404  /* Check if it's valid memory */
405  if ((PageFrameIndex <= MmHighestPhysicalPage) &&
406  (MmIsAddressValid(Pfn)) &&
407  (Pfn->u3.e1.PageLocation == ActiveAndValid))
408  {
409  /* Setup the PFN entry */
410  Pfn->u1.WsIndex = 0;
411  Pfn->u2.ShareCount++;
412  Pfn->PteAddress = PointerPte;
413  Pfn->OriginalPte = *PointerPte;
416  Pfn->u3.e2.ReferenceCount = 1;
417  Pfn->u4.PteFrame = PFN_FROM_PTE(MiAddressToPte(PointerPte));
418  }
419 
420  /* Increase the shared count of the PFN entry for the PDE */
421  PointerPde = MiAddressToPde(MiPteToAddress(PointerPte));
422  Pfn = MiGetPfnEntry(PFN_FROM_PTE(PointerPde));
423  Pfn->u2.ShareCount++;
424 }
#define MiAddressToPde(x)
Definition: mmx86.c:20
union _MMPFN::@1747 u4
struct _MMPFN::@1744::@1750 e2
USHORT PageLocation
Definition: mm.h:297
MMPFNENTRY e1
Definition: mm.h:329
USHORT CacheAttribute
Definition: mm.h:299
#define MiAddressToPte(x)
Definition: mmx86.c:19
ULONG_PTR ShareCount
Definition: mm.h:322
PVOID FORCEINLINE MiPteToAddress(PMMPTE PointerPte)
Definition: mm.h:198
ULONG MmHighestPhysicalPage
Definition: init.c:48
BOOLEAN NTAPI MmIsAddressValid(IN PVOID VirtualAddress)
Definition: mmsup.c:174
union _MMPFN::@1742 u1
Definition: mm.h:305
FORCEINLINE PMMPFN MiGetPfnEntry(IN PFN_NUMBER Pfn)
Definition: mm.h:940
union _MMPFN::@1743 u2
ULONG_PTR PteFrame
Definition: mm.h:350
PMMPTE PteAddress
Definition: mm.h:318
MMPTE OriginalPte
Definition: mm.h:339
ULONG WsIndex
Definition: mm.h:310
union _MMPFN::@1744 u3
#define PFN_FROM_PTE(v)
Definition: mm.h:89

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 MiInitMachineDependent().

◆ 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:255
#define MM_PTE_SOFTWARE_PROTECTION_BITS
Definition: mm.h:72
#define MM_READWRITE
Definition: inbv.c:10

Definition at line 40 of file init.c.

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

◆ ValidKernelPde

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

◆ ValidKernelPdeLocal

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

◆ ValidKernelPte

◆ ValidKernelPteLocal

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