Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/loader/bootinfo.c
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
#include "geliboot.h" | #include "geliboot.h" | ||||
#endif | #endif | ||||
int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, | int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, | ||||
bool exit_bs); | bool exit_bs); | ||||
extern EFI_SYSTEM_TABLE *ST; | extern EFI_SYSTEM_TABLE *ST; | ||||
int boot_services_gone; | |||||
static int | static int | ||||
bi_getboothowto(char *kargs) | bi_getboothowto(char *kargs) | ||||
{ | { | ||||
const char *sw, *tmp; | const char *sw, *tmp; | ||||
char *opts; | char *opts; | ||||
char *console; | char *console; | ||||
int howto, speed, port; | int howto, speed, port; | ||||
char buf[50]; | char buf[50]; | ||||
▲ Show 20 Lines • Show All 315 Lines • ▼ Show 20 Lines | for (;;) { | ||||
efihdr = (struct efi_map_header *)(uintptr_t)addr; | efihdr = (struct efi_map_header *)(uintptr_t)addr; | ||||
mm = (void *)((uint8_t *)efihdr + efisz); | mm = (void *)((uint8_t *)efihdr + efisz); | ||||
sz = (EFI_PAGE_SIZE * pages) - efisz; | sz = (EFI_PAGE_SIZE * pages) - efisz; | ||||
} | } | ||||
if (!exit_bs) | if (!exit_bs) | ||||
break; | break; | ||||
status = BS->ExitBootServices(IH, efi_mapkey); | status = BS->ExitBootServices(IH, efi_mapkey); | ||||
if (!EFI_ERROR(status)) | if (!EFI_ERROR(status)) { | ||||
boot_services_gone = 1; | |||||
dasebek_gmail.com: I looked at the UEFI specification, and it says that some boot services may actually be gone… | |||||
break; | break; | ||||
} | |||||
} | } | ||||
if (retry == 0) { | if (retry == 0) { | ||||
BS->FreePages(addr, pages); | BS->FreePages(addr, pages); | ||||
printf("ExitBootServices error %lu\n", EFI_ERROR_CODE(status)); | printf("ExitBootServices error %lu\n", EFI_ERROR_CODE(status)); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |
I looked at the UEFI specification, and it says that some boot services may actually be gone even if ExitBootServices() does not return success.
I looked at:
So it seems like GetMemoryMap() is the only boot service function that can be expected to work after ExitBootServices() is called and fails.
My laptop freezes, whenever printf() or panic() is called after ExitBootServices() because printing to screen apparently uses boot services. On my laptop, ExitBootServices() succeeds the first time it is called. I wonder if eliminating all calls to boot service functions other than GetMemoryMap() after the first unsuccessful call to ExitBootServices() would fix boot freeze problems on some computers.