[BOOT:MM] Finish MmMdpHasPrecedence()
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user