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