From e452d56991c7dce655511c5529f4cf1a6fe98e42 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Thu, 11 Oct 2018 12:45:42 +0200 Subject: [PATCH] MM : Moved all remaining LIST_ENTRY_* macro's to where they're used (as preparation for further simplification) --- import/OpenXDK/include/xboxkrnl/xboxkrnl.h | 11 ----------- src/CxbxKrnl/EmuKrnlHal.cpp | 11 +++++++++-- src/CxbxKrnl/PhysicalMemory.cpp | 6 ++++++ src/CxbxKrnl/VMManager.cpp | 4 ++++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h index f7b9e748a..584510d5e 100644 --- a/import/OpenXDK/include/xboxkrnl/xboxkrnl.h +++ b/import/OpenXDK/include/xboxkrnl/xboxkrnl.h @@ -354,17 +354,6 @@ typedef struct _LIST_ENTRY } LIST_ENTRY, *PLIST_ENTRY; -// See the links below for the details about the kernel structure LIST_ENTRY and the related functions -// https://www.codeproject.com/Articles/800404/Understanding-LIST-ENTRY-Lists-and-Its-Importance -// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/singly-and-doubly-linked-lists - -#define LIST_ENTRY_DEFINE_HEAD(ListHead) xboxkrnl::LIST_ENTRY (ListHead) = { &(ListHead), &(ListHead) } - -#define LIST_ENTRY_INITIALIZE(ListEntry) ((ListEntry)->Flink = (ListEntry)->Blink = nullptr) - -#define LIST_ENTRY_ACCESS_RECORD(address, type, field) \ -((type*)((UCHAR*)(address) - (ULONG)(&((type*)0)->field))) - // ****************************************************************** // * SLIST_ENTRY // ****************************************************************** diff --git a/src/CxbxKrnl/EmuKrnlHal.cpp b/src/CxbxKrnl/EmuKrnlHal.cpp index e8630df27..1ecc61c5e 100644 --- a/src/CxbxKrnl/EmuKrnlHal.cpp +++ b/src/CxbxKrnl/EmuKrnlHal.cpp @@ -62,6 +62,14 @@ namespace xboxkrnl #include #include +// See the links below for the details about the kernel structure LIST_ENTRY and the related functions +// https://www.codeproject.com/Articles/800404/Understanding-LIST-ENTRY-Lists-and-Its-Importance +// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/singly-and-doubly-linked-lists +#define LIST_ENTRY_DEFINE_HEAD(ListHead) xboxkrnl::LIST_ENTRY (ListHead) = { &(ListHead), &(ListHead) } +#define LIST_ENTRY_ACCESS_RECORD(address, type, field) \ +((type*)((UCHAR*)(address) - (ULONG)(&((type*)0)->field))) + + volatile DWORD HalInterruptRequestRegister = APC_LEVEL | DISPATCH_LEVEL; HalSystemInterrupt HalSystemInterrupts[MAX_BUS_INTERRUPT_LEVEL + 1]; @@ -72,7 +80,6 @@ uint32_t ResetOrShutdownDataValue = 0; // global list of routines executed during a reboot LIST_ENTRY_DEFINE_HEAD(ShutdownRoutineList); - // ****************************************************************** // * Declaring this in a header causes errors with xboxkrnl // * namespace, so we must declare it within any file that uses it @@ -510,7 +517,7 @@ XBSYSAPI EXPORTNUM(49) xboxkrnl::VOID DECLSPEC_NORETURN NTAPI xboxkrnl::HalRetur { OldIrql = KeRaiseIrqlToDpcLevel(); - ListEntry = RemoveHeadList(&ShutdownRoutineList) + ListEntry = RemoveHeadList(&ShutdownRoutineList); KfLowerIrql(OldIrql); diff --git a/src/CxbxKrnl/PhysicalMemory.cpp b/src/CxbxKrnl/PhysicalMemory.cpp index 6e9032cf4..b25360678 100644 --- a/src/CxbxKrnl/PhysicalMemory.cpp +++ b/src/CxbxKrnl/PhysicalMemory.cpp @@ -42,6 +42,12 @@ #include "EmuKrnl.h" // For InitializeListHead(), etc. #include +// See the links below for the details about the kernel structure LIST_ENTRY and the related functions +// https://www.codeproject.com/Articles/800404/Understanding-LIST-ENTRY-Lists-and-Its-Importance +// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/singly-and-doubly-linked-lists +#define LIST_ENTRY_INITIALIZE(ListEntry) ((ListEntry)->Flink = (ListEntry)->Blink = nullptr) +#define LIST_ENTRY_ACCESS_RECORD(address, type, field) \ +((type*)((UCHAR*)(address) - (ULONG)(&((type*)0)->field))) void PhysicalMemory::InitializePageDirectory() { diff --git a/src/CxbxKrnl/VMManager.cpp b/src/CxbxKrnl/VMManager.cpp index aa5babc63..b016ea60a 100644 --- a/src/CxbxKrnl/VMManager.cpp +++ b/src/CxbxKrnl/VMManager.cpp @@ -48,6 +48,10 @@ #include "EmuKrnl.h" // For InitializeListHead(), etc. #include +// See the links below for the details about the kernel structure LIST_ENTRY and the related functions +// https://www.codeproject.com/Articles/800404/Understanding-LIST-ENTRY-Lists-and-Its-Importance +// https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/singly-and-doubly-linked-lists +#define LIST_ENTRY_INITIALIZE(ListEntry) ((ListEntry)->Flink = (ListEntry)->Blink = nullptr) VMManager g_VMManager;