mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OpenDuet: Prevent DEBUG ASSERT in normal situation when updating GCD memory map
This commit is contained in:
parent
0db6e7a427
commit
79dfd36be5
@ -357,17 +357,45 @@ UpdateMemoryMap (
|
||||
MemorySpaceMap[Index].BaseAddress,
|
||||
MemorySpaceMap[Index].Length
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = gDS->AddMemorySpace (
|
||||
(Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE
|
||||
? EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory,
|
||||
MemorySpaceMap[Index].BaseAddress,
|
||||
MemorySpaceMap[Index].Length,
|
||||
Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// This loop's purpose is to free reserved memory above 4GB. DxeCore
|
||||
// itself is also found (below 4GB) and gives Access Denied here
|
||||
// because it is associated with an image handle.
|
||||
// TODO: Is it is possible to work round issue in first REF (note: that
|
||||
// line dates to original EDK II DuetPkg) while still allowing DxeCore
|
||||
// memory to be mapped as System rather than Reserved in the first place
|
||||
// (see second REF)? (If it's not mapped correctly in the first place
|
||||
// and it's associated with an image handle, it can't be remapped later
|
||||
// using gDS calls.)
|
||||
// REF: https://github.com/acidanthera/OpenCorePkg/blob/master/Legacy/BootPlatform/DxeIpl/HobGeneration.c#L201
|
||||
// REF: https://github.com/acidanthera/audk/blob/master/MdeModulePkg/Core/Dxe/Gcd/Gcd.c#L2577-L2587
|
||||
//
|
||||
DEBUG ((
|
||||
EFI_D_INFO,
|
||||
"UpdateMemoryMap: Remove %016lx %016lx - %r\n",
|
||||
MemorySpaceMap[Index].BaseAddress,
|
||||
MemorySpaceMap[Index].Length,
|
||||
Status
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = gDS->AddMemorySpace (
|
||||
(Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE
|
||||
? EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory,
|
||||
MemorySpaceMap[Index].BaseAddress,
|
||||
MemorySpaceMap[Index].Length,
|
||||
Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
DEBUG ((
|
||||
EFI_D_INFO,
|
||||
"UpdateMemoryMap: Remap %016lx %016lx - %r\n",
|
||||
MemorySpaceMap[Index].BaseAddress,
|
||||
MemorySpaceMap[Index].Length,
|
||||
Status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user