4 Commits

Author SHA1 Message Date
d263f17831 Refactor panic calls in memory manager
All checks were successful
Builds / ExectOS (i686, debug) (push) Successful in 27s
Builds / ExectOS (amd64, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 39s
Builds / ExectOS (i686, release) (push) Successful in 38s
2026-03-13 19:44:29 +01:00
6175413db2 Merge branch 'master' into memmgr
Some checks failed
Builds / ExectOS (amd64, release) (push) Failing after 27s
Builds / ExectOS (i686, debug) (push) Failing after 26s
Builds / ExectOS (i686, release) (push) Failing after 31s
Builds / ExectOS (amd64, debug) (push) Failing after 35s
2026-03-13 19:43:01 +01:00
428928c7e1 Simplify panic interface by using C++ overloading
All checks were successful
Builds / ExectOS (amd64, debug) (push) Successful in 27s
Builds / ExectOS (i686, release) (push) Successful in 27s
Builds / ExectOS (amd64, release) (push) Successful in 42s
Builds / ExectOS (i686, debug) (push) Successful in 40s
2026-03-13 19:42:03 +01:00
7d2b41a044 Calculate virtual address per page when initializing PFN entries
All checks were successful
Builds / ExectOS (amd64, release) (push) Successful in 23s
Builds / ExectOS (amd64, debug) (push) Successful in 39s
Builds / ExectOS (i686, debug) (push) Successful in 37s
Builds / ExectOS (i686, release) (push) Successful in 24s
2026-03-13 19:35:29 +01:00
3 changed files with 38 additions and 30 deletions

View File

@@ -20,11 +20,11 @@ namespace KE
public: public:
STATIC XTAPI VOID HaltSystem(VOID); STATIC XTAPI VOID HaltSystem(VOID);
STATIC XTAPI VOID Panic(IN ULONG Code); STATIC XTAPI VOID Panic(IN ULONG Code);
STATIC XTAPI VOID PanicEx(IN ULONG Code, STATIC XTAPI VOID Panic(IN ULONG Code,
IN ULONG_PTR Parameter1, IN ULONG_PTR Parameter1,
IN ULONG_PTR Parameter2, IN ULONG_PTR Parameter2,
IN ULONG_PTR Parameter3, IN ULONG_PTR Parameter3,
IN ULONG_PTR Parameter4); IN ULONG_PTR Parameter4);
}; };
} }

View File

@@ -43,7 +43,7 @@ XTAPI
VOID VOID
KE::Crash::Panic(IN ULONG Code) KE::Crash::Panic(IN ULONG Code)
{ {
PanicEx(Code, 0, 0, 0, 0); Panic(Code, 0, 0, 0, 0);
} }
/** /**
@@ -70,11 +70,11 @@ KE::Crash::Panic(IN ULONG Code)
*/ */
XTAPI XTAPI
VOID VOID
KE::Crash::PanicEx(IN ULONG Code, KE::Crash::Panic(IN ULONG Code,
IN ULONG_PTR Parameter1, IN ULONG_PTR Parameter1,
IN ULONG_PTR Parameter2, IN ULONG_PTR Parameter2,
IN ULONG_PTR Parameter3, IN ULONG_PTR Parameter3,
IN ULONG_PTR Parameter4) IN ULONG_PTR Parameter4)
{ {
KD::DebugIo::KdPrint(L"Fatal System Error: 0x%08lx\nKernel Panic!\n\n", Code); KD::DebugIo::KdPrint(L"Fatal System Error: 0x%08lx\nKernel Panic!\n\n", Code);
HaltSystem(); HaltSystem();

View File

@@ -173,11 +173,11 @@ MM::Pfn::DecrementReferenceCount(IN PMMPFN PageFrameNumber,
if(PageFrameNumber->u2.ShareCount) if(PageFrameNumber->u2.ShareCount)
{ {
/* This indicates a bug; crash the system */ /* This indicates a bug; crash the system */
KE::Crash::PanicEx(0x4E, KE::Crash::Panic(0x4E,
0x07, 0x07,
PageFrameIndex, PageFrameIndex,
PageFrameNumber->u2.ShareCount, PageFrameNumber->u2.ShareCount,
0); 0);
} }
/* Check if the PTE is marked as being ready for removal */ /* Check if the PTE is marked as being ready for removal */
@@ -256,11 +256,11 @@ MM::Pfn::DecrementShareCount(IN PMMPFN PageFrameNumber,
(PageFrameNumber->u3.e1.PageLocation != StandbyPageList)) (PageFrameNumber->u3.e1.PageLocation != StandbyPageList))
{ {
/* This indicates a bug; crash the system */ /* This indicates a bug; crash the system */
KE::Crash::PanicEx(0x4E, KE::Crash::Panic(0x4E,
0x99, 0x99,
PageFrameIndex, PageFrameIndex,
PageFrameNumber->u3.e1.PageLocation, PageFrameNumber->u3.e1.PageLocation,
0); 0);
} }
/* Decrement the PFN share count */ /* Decrement the PFN share count */
@@ -591,7 +591,7 @@ MM::Pfn::LinkPage(IN PMMPFNLIST ListHead,
MM::Paging::GetPteSoftwareTransition(&PageFrame->OriginalPte)) MM::Paging::GetPteSoftwareTransition(&PageFrame->OriginalPte))
{ {
/* Crash system due to corrupted PFN/PTE state */ /* Crash system due to corrupted PFN/PTE state */
KE::Crash::PanicEx(0x71, 0x8888, 0, 0, 0); KE::Crash::Panic(0x71, 0x8888, 0, 0, 0);
} }
} }
@@ -806,11 +806,11 @@ MM::Pfn::LinkPfn(IN PFN_NUMBER PageFrameIndex,
if(Status != STATUS_SUCCESS) if(Status != STATUS_SUCCESS)
{ {
/* Could not make the page table resident, crash system */ /* Could not make the page table resident, crash system */
KE::Crash::PanicEx(0x1, KE::Crash::Panic(0x1,
(ULONG_PTR)0x61940, (ULONG_PTR)0x61940,
(ULONG_PTR)PointerPte, (ULONG_PTR)PointerPte,
MM::Paging::GetPageFrameNumber(PointerPte), MM::Paging::GetPageFrameNumber(PointerPte),
(ULONG_PTR)MM::Paging::GetPteVirtualAddress(PointerPte)); (ULONG_PTR)MM::Paging::GetPteVirtualAddress(PointerPte));
} }
} }
@@ -1034,7 +1034,7 @@ MM::Pfn::ProcessMemoryDescriptor(IN PFN_NUMBER BasePage,
IN PFN_NUMBER PageCount, IN PFN_NUMBER PageCount,
IN LOADER_MEMORY_TYPE MemoryType) IN LOADER_MEMORY_TYPE MemoryType)
{ {
PVOID VirtualRangeStart, VirtualRangeEnd; PVOID VirtualAddress, VirtualRangeStart, VirtualRangeEnd;
PFN_NUMBER PageNumber; PFN_NUMBER PageNumber;
PMMPDE PointerPde; PMMPDE PointerPde;
PMMPFN Pfn; PMMPFN Pfn;
@@ -1087,8 +1087,12 @@ MM::Pfn::ProcessMemoryDescriptor(IN PFN_NUMBER BasePage,
/* Ensure that the page is not already in-use */ /* Ensure that the page is not already in-use */
if(Pfn->u3.e2.ReferenceCount == 0) if(Pfn->u3.e2.ReferenceCount == 0)
{ {
/* Calculate the virtual address for this page */
VirtualAddress = (PVOID)(KSEG0_BASE + ((BasePage + PageNumber) << MM_PAGE_SHIFT));
PointerPde = MM::Paging::GetPdeAddress(VirtualAddress);
/* Initialize the PFN entry to represent a ROM page */ /* Initialize the PFN entry to represent a ROM page */
Pfn->PteAddress = MM::Paging::GetPteAddress(VirtualRangeStart); Pfn->PteAddress = MM::Paging::GetPteAddress(VirtualAddress);
Pfn->u1.Flink = 0; Pfn->u1.Flink = 0;
Pfn->u2.ShareCount = 0; Pfn->u2.ShareCount = 0;
Pfn->u3.e1.CacheAttribute = PfnCached; Pfn->u3.e1.CacheAttribute = PfnCached;
@@ -1117,8 +1121,12 @@ MM::Pfn::ProcessMemoryDescriptor(IN PFN_NUMBER BasePage,
/* Ensure that the page is not already in-use */ /* Ensure that the page is not already in-use */
if(Pfn->u3.e2.ReferenceCount == 0) if(Pfn->u3.e2.ReferenceCount == 0)
{ {
/* Calculate the virtual address for this page */
VirtualAddress = (PVOID)(KSEG0_BASE + ((BasePage + PageNumber) << MM_PAGE_SHIFT));
PointerPde = MM::Paging::GetPdeAddress(VirtualAddress);
/* Initialize the PFN entry to represent an in-use page and prevent it from being allocated */ /* Initialize the PFN entry to represent an in-use page and prevent it from being allocated */
Pfn->PteAddress = MM::Paging::GetPteAddress(VirtualRangeStart); Pfn->PteAddress = MM::Paging::GetPteAddress(VirtualAddress);
Pfn->u2.ShareCount++; Pfn->u2.ShareCount++;
Pfn->u3.e1.CacheAttribute = PfnCached; Pfn->u3.e1.CacheAttribute = PfnCached;
Pfn->u3.e1.PageLocation = ActiveAndValid; Pfn->u3.e1.PageLocation = ActiveAndValid;