[BOOT:MM] Finish MmMdpHasPrecedence()
This commit is contained in:
parent
4c32340803
commit
471beb8130
@ -135,21 +135,27 @@ typedef struct {
|
||||
//
|
||||
#define MEMORY_ATTRIBUTE_RUNTIME 0x1000000
|
||||
|
||||
typedef enum {
|
||||
MEMORY_TYPE_BOOT_APPLICATION = 0xD0000002,
|
||||
MEMORY_TYPE_FREE = 0xF0000001,
|
||||
MEMORY_TYPE_UNUSABLE = 0xF0000002,
|
||||
MEMORY_TYPE_RESERVED = 0xF0000003,
|
||||
MEMORY_TYPE_BOOT_SERVICES = 0xF0000004,
|
||||
MEMORY_TYPE_RUNTIME_SERVICES_CODE = 0xF0000006,
|
||||
MEMORY_TYPE_PERSISTENT = 0xF0000007,
|
||||
MEMORY_TYPE_ACPI_RECLAIM = 0xF0000008,
|
||||
MEMORY_TYPE_ACPI_NVS = 0xF0000009,
|
||||
MEMORY_TYPE_MMIO = 0xF000000A,
|
||||
MEMORY_TYPE_MMIO_PORT_SPACE = 0xF000000B,
|
||||
MEMORY_TYPE_PAL_CODE = 0xF000000C,
|
||||
MEMORY_TYPE_RUNTIME_SERVICES_DATA = 0xF000000E
|
||||
} MEMORY_TYPE;
|
||||
#define MEMORY_CLASS_APPLICATION 0xD
|
||||
#define MEMORY_CLASS_LIBRARY 0xE
|
||||
#define MEMORY_CLASS_SYSTEM 0xF
|
||||
|
||||
#define MEMORY_TYPE_BOOT_APPLICATION 0xD0000002
|
||||
#define MEMORY_TYPE_BOOT_APPLICATION_2 0xD0000013
|
||||
#define MEMORY_TYPE_FREE 0xF0000001
|
||||
#define MEMORY_TYPE_UNUSABLE 0xF0000002
|
||||
#define MEMORY_TYPE_RESERVED 0xF0000003
|
||||
#define MEMORY_TYPE_BOOT_SERVICES 0xF0000004
|
||||
#define MEMORY_TYPE_FREE_ZEROED 0xF0000005
|
||||
#define MEMORY_TYPE_RUNTIME_SERVICES_CODE 0xF0000006
|
||||
#define MEMORY_TYPE_PERSISTENT 0xF0000007
|
||||
#define MEMORY_TYPE_ACPI_RECLAIM 0xF0000008
|
||||
#define MEMORY_TYPE_ACPI_NVS 0xF0000009
|
||||
#define MEMORY_TYPE_MMIO 0xF000000A
|
||||
#define MEMORY_TYPE_MMIO_PORT_SPACE 0xF000000B
|
||||
#define MEMORY_TYPE_PAL_CODE 0xF000000C
|
||||
#define MEMORY_TYPE_RUNTIME_SERVICES_DATA 0xF000000E
|
||||
|
||||
typedef ULONG MEMORY_TYPE;
|
||||
|
||||
typedef struct {
|
||||
LIST_ENTRY ListEntry;
|
||||
|
@ -27,10 +27,27 @@ ULONG MmGlobalMemoryDescriptorCount, MmGlobalMemoryDescriptorsUsed;
|
||||
PMEMORY_DESCRIPTOR MmDynamicMemoryDescriptors;
|
||||
ULONG MmDynamicMemoryDescriptorCount, MmDynamicMemoryDescriptorsUsed;
|
||||
|
||||
MEMORY_TYPE MmPlatformMemoryTypePrecedence[] = {
|
||||
MEMORY_TYPE_RESERVED,
|
||||
MEMORY_TYPE_UNUSABLE,
|
||||
MEMORY_TYPE_MMIO,
|
||||
MEMORY_TYPE_MMIO_PORT_SPACE,
|
||||
MEMORY_TYPE_PAL_CODE,
|
||||
MEMORY_TYPE_RUNTIME_SERVICES_CODE,
|
||||
MEMORY_TYPE_RUNTIME_SERVICES_DATA,
|
||||
MEMORY_TYPE_ACPI_NVS,
|
||||
MEMORY_TYPE_ACPI_RECLAIM,
|
||||
MEMORY_TYPE_PERSISTENT,
|
||||
MEMORY_TYPE_BOOT_APPLICATION_2,
|
||||
MEMORY_TYPE_BOOT_SERVICES,
|
||||
MEMORY_TYPE_FREE,
|
||||
MEMORY_TYPE_FREE_ZEROED
|
||||
};
|
||||
|
||||
BOOLEAN
|
||||
MmMdpHasPrecedence (
|
||||
IN MEMORY_TYPE A,
|
||||
IN MEMORY_TYPE B
|
||||
IN MEMORY_TYPE TypeA,
|
||||
IN MEMORY_TYPE TypeB
|
||||
)
|
||||
|
||||
/*++
|
||||
@ -41,52 +58,71 @@ Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
A - memory type A.
|
||||
TypeA - memory type A.
|
||||
|
||||
B - memory type B.
|
||||
TypeB - memory type B.
|
||||
|
||||
Return Value:
|
||||
|
||||
TRUE if A has precedence over B, or if neither has precedence.
|
||||
FALSE if B has precedence over A.
|
||||
TRUE if TypeA has precedence over TypeB, or if neither has precedence.
|
||||
FALSE if TypeB has precedence over TypeA.
|
||||
|
||||
--*/
|
||||
|
||||
{
|
||||
ULONG ClassA, ClassB;
|
||||
ULONG IndexA, IndexB;
|
||||
|
||||
ClassA = A >> 28;
|
||||
ClassB = B >> 28;
|
||||
|
||||
if (B == MEMORY_TYPE_FREE) {
|
||||
if (TypeB == MEMORY_TYPE_FREE_ZEROED) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (A == MEMORY_TYPE_FREE) {
|
||||
} else if (TypeA == MEMORY_TYPE_FREE_ZEROED) {
|
||||
return FALSE;
|
||||
} else if (TypeB == MEMORY_TYPE_FREE) {
|
||||
return TRUE;
|
||||
} else if (TypeA == MEMORY_TYPE_FREE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ClassA > 0x0F) {
|
||||
ClassA = TypeA >> 28;
|
||||
ClassB = TypeB >> 28;
|
||||
if (ClassA != MEMORY_CLASS_APPLICATION
|
||||
&& ClassA != MEMORY_CLASS_LIBRARY
|
||||
&& ClassA != MEMORY_CLASS_SYSTEM) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (ClassB > 0x0F) {
|
||||
} else if (ClassB != MEMORY_CLASS_APPLICATION
|
||||
&& ClassB != MEMORY_CLASS_LIBRARY
|
||||
&& ClassB != MEMORY_CLASS_SYSTEM) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ClassA != 0x0F) {
|
||||
return (ClassB != 0x0F && (ClassA == 0x0D || ClassB != 0x0D)) ? TRUE:FALSE;
|
||||
}
|
||||
|
||||
if (ClassB != 0x0F) {
|
||||
if (ClassA != MEMORY_CLASS_SYSTEM) {
|
||||
return (ClassB != MEMORY_CLASS_SYSTEM
|
||||
&& (ClassA == MEMORY_CLASS_APPLICATION
|
||||
|| ClassB != MEMORY_CLASS_APPLICATION)) ? TRUE:FALSE;
|
||||
} else if (ClassB != MEMORY_CLASS_SYSTEM) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Implement the rest of this routine.
|
||||
//
|
||||
ConsolePrint(L"MmMdpHasPrecedence() is incomplete\r\n");
|
||||
for (IndexA = 0;
|
||||
IndexA < sizeof(MmPlatformMemoryTypePrecedence) / sizeof(MmPlatformMemoryTypePrecedence[0]);
|
||||
IndexA++) {
|
||||
if (TypeA == MmPlatformMemoryTypePrecedence[IndexA]) {
|
||||
goto CheckTypeBPrecedence;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
CheckTypeBPrecedence:
|
||||
for (IndexB = 0;
|
||||
IndexB < sizeof(MmPlatformMemoryTypePrecedence) / sizeof(MmPlatformMemoryTypePrecedence[0]);
|
||||
IndexB++) {
|
||||
if (TypeB == MmPlatformMemoryTypePrecedence[IndexB]) {
|
||||
return IndexA <= IndexB ? TRUE:FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
|
Loading…
Reference in New Issue
Block a user