Refactor hardware memory mapping to use page map routine callbacks
Some checks failed
Builds / ExectOS (i686, release) (push) Failing after 21s
Builds / ExectOS (i686, debug) (push) Failing after 23s
Builds / ExectOS (amd64, debug) (push) Successful in 41s
Builds / ExectOS (amd64, release) (push) Successful in 39s

This commit is contained in:
Aiken Harris 2025-08-17 00:47:56 +02:00
parent 57193eecc0
commit 1e11acee72
Signed by: harraiken
GPG Key ID: C40F06CB7493C1F5

View File

@ -190,7 +190,7 @@ MmMapHardwareMemory(IN PHYSICAL_ADDRESS PhysicalAddress,
ReturnAddress = (PVOID)(ULONG_PTR)ReturnAddress + MM_PAGE_SIZE; ReturnAddress = (PVOID)(ULONG_PTR)ReturnAddress + MM_PAGE_SIZE;
/* Check if PTE is valid */ /* Check if PTE is valid */
if(PtePointer->Valid) if(MmpPageMapRoutines->PteValid(PtePointer))
{ {
/* PTE is not available, go to the next one */ /* PTE is not available, go to the next one */
BaseAddress = ReturnAddress; BaseAddress = ReturnAddress;
@ -219,9 +219,7 @@ MmMapHardwareMemory(IN PHYSICAL_ADDRESS PhysicalAddress,
PtePointer = (PHARDWARE_PTE)MmpGetPteAddress(BaseAddress); PtePointer = (PHARDWARE_PTE)MmpGetPteAddress(BaseAddress);
/* Fill the PTE */ /* Fill the PTE */
PtePointer->PageFrameNumber = (PFN_NUMBER)(PhysicalAddress.QuadPart >> MM_PAGE_SHIFT); MmpPageMapRoutines->SetPte(PtePointer, (PFN_NUMBER)(PhysicalAddress.QuadPart >> MM_PAGE_SHIFT), TRUE);
PtePointer->Valid = 1;
PtePointer->Writable = 1;
/* Advance to the next address */ /* Advance to the next address */
PhysicalAddress.QuadPart += MM_PAGE_SIZE; PhysicalAddress.QuadPart += MM_PAGE_SIZE;
@ -268,8 +266,7 @@ MmMarkHardwareMemoryWriteThrough(IN PVOID VirtualAddress,
for(Page = 0; Page < PageCount; Page++) for(Page = 0; Page < PageCount; Page++)
{ {
/* Mark pages as CD/WT */ /* Mark pages as CD/WT */
PtePointer->CacheDisable = 1; MmpPageMapRoutines->SetPteCaching(PtePointer, TRUE, TRUE);
PtePointer->WriteThrough = 1;
PtePointer++; PtePointer++;
} }
} }
@ -302,9 +299,7 @@ MmRemapHardwareMemory(IN PVOID VirtualAddress,
PtePointer = (PHARDWARE_PTE)MmpGetPteAddress(VirtualAddress); PtePointer = (PHARDWARE_PTE)MmpGetPteAddress(VirtualAddress);
/* Remap the PTE */ /* Remap the PTE */
PtePointer->PageFrameNumber = (PFN_NUMBER)(PhysicalAddress.QuadPart >> MM_PAGE_SHIFT); MmpPageMapRoutines->SetPte(PtePointer, (PFN_NUMBER)(PhysicalAddress.QuadPart >> MM_PAGE_SHIFT), TRUE);
PtePointer->Valid = 1;
PtePointer->Writable = 1;
/* Check if TLB needs to be flushed */ /* Check if TLB needs to be flushed */
if(FlushTlb) if(FlushTlb)
@ -356,11 +351,7 @@ MmUnmapHardwareMemory(IN PVOID VirtualAddress,
for(Page = 0; Page < PageCount; Page++) for(Page = 0; Page < PageCount; Page++)
{ {
/* Unmap the PTE and get the next one */ /* Unmap the PTE and get the next one */
PtePointer->CacheDisable = 0; MmpPageMapRoutines->ClearPte(PtePointer);
PtePointer->Valid = 0;
PtePointer->Writable = 0;
PtePointer->WriteThrough = 0;
PtePointer->PageFrameNumber = 0;
PtePointer++; PtePointer++;
} }