Skip to content

Commit a5fda55

Browse files
committed
Manually attempt to allocate all conventional memory early
Doing this instead of permanently raising TPL, which can cause issues in other more unpredicatable ways.
1 parent 48a0b70 commit a5fda55

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/csmwrap.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,22 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
9898
gBS = SystemTable->BootServices;
9999
gRT = SystemTable->RuntimeServices;
100100

101+
printf("%s", banner);
102+
103+
for (uintptr_t i = 0; i < 0x100000; i += EFI_PAGE_SIZE) {
104+
uintptr_t j = i;
105+
if (gBS->AllocatePages(AllocateAddress, EfiLoaderData, 1, &j) != EFI_SUCCESS) {
106+
if (i < 0xa0000) {
107+
printf("warning: Early AllocatePages() failed for address %p\n", i);
108+
}
109+
}
110+
}
111+
101112
if (gRT->GetTime(&gTimeAtBoot, NULL) != EFI_SUCCESS) {
102113
printf("Failed to query current time\n");
103114
return -1;
104115
}
105116

106-
printf("%s", banner);
107-
108-
gBS->RaiseTPL(TPL_NOTIFY);
109117
gBS->SetWatchdogTimer(0, 0, 0, NULL);
110118

111119
if (unlock_bios_region()) {

0 commit comments

Comments
 (0)