Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/loader/main.c
| Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | |||||
| * | * | ||||
| * We always fail if we can't find the right thing. However, as | * We always fail if we can't find the right thing. However, as | ||||
| * a concession to buggy UEFI implementations, like u-boot, if | * a concession to buggy UEFI implementations, like u-boot, if | ||||
| * we have determined that the host is violating the UEFI boot | * we have determined that the host is violating the UEFI boot | ||||
| * manager protocol, we'll signal the rest of the program that | * manager protocol, we'll signal the rest of the program that | ||||
| * a drop to the OK boot loader prompt is possible. | * a drop to the OK boot loader prompt is possible. | ||||
| */ | */ | ||||
| static int | static int | ||||
| find_currdev(bool do_bootmgr, bool is_last, | find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz) | ||||
| char *boot_info, size_t boot_info_sz) | |||||
| { | { | ||||
| pdinfo_t *dp, *pp; | pdinfo_t *dp, *pp; | ||||
| EFI_DEVICE_PATH *devpath, *copy; | EFI_DEVICE_PATH *devpath, *copy; | ||||
| EFI_HANDLE h; | EFI_HANDLE h; | ||||
| CHAR16 *text; | CHAR16 *text; | ||||
| struct devsw *dev; | struct devsw *dev; | ||||
| int unit; | int unit; | ||||
| uint64_t extra; | uint64_t extra; | ||||
| ▲ Show 20 Lines • Show All 679 Lines • ▼ Show 20 Lines | efi_smbios_detect(void) | ||||
| if (smbios_v2_ptr != NULL) | if (smbios_v2_ptr != NULL) | ||||
| (void)smbios_detect(smbios_v2_ptr); | (void)smbios_detect(smbios_v2_ptr); | ||||
| } | } | ||||
| EFI_STATUS | EFI_STATUS | ||||
| main(int argc, CHAR16 *argv[]) | main(int argc, CHAR16 *argv[]) | ||||
| { | { | ||||
| int howto, i, uhowto; | int howto, i, uhowto; | ||||
| bool has_kbd, is_last; | bool has_kbd; | ||||
| char *s; | char *s; | ||||
| EFI_DEVICE_PATH *imgpath; | EFI_DEVICE_PATH *imgpath; | ||||
| CHAR16 *text; | CHAR16 *text; | ||||
| EFI_STATUS rv; | EFI_STATUS rv; | ||||
| size_t sz, bisz = 0; | size_t sz, bisz = 0; | ||||
| UINT16 boot_order[100]; | UINT16 boot_order[100]; | ||||
| char boot_info[4096]; | char boot_info[4096]; | ||||
| char buf[32]; | char buf[32]; | ||||
| ▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | if (getenv("uefi_ignore_boot_mgr") != NULL) { | ||||
| sz = sizeof(boot_order); | sz = sizeof(boot_order); | ||||
| rv = efi_global_getenv("BootOrder", &boot_order, &sz); | rv = efi_global_getenv("BootOrder", &boot_order, &sz); | ||||
| if (rv == EFI_SUCCESS) { | if (rv == EFI_SUCCESS) { | ||||
| printf(" BootOrder:"); | printf(" BootOrder:"); | ||||
| for (i = 0; i < sz / sizeof(boot_order[0]); i++) | for (i = 0; i < sz / sizeof(boot_order[0]); i++) | ||||
| printf(" %04x%s", boot_order[i], | printf(" %04x%s", boot_order[i], | ||||
| boot_order[i] == boot_current ? "[*]" : ""); | boot_order[i] == boot_current ? "[*]" : ""); | ||||
| printf("\n"); | printf("\n"); | ||||
| is_last = boot_order[(sz / sizeof(boot_order[0])) - 1] == boot_current; | |||||
| } else if (uefi_boot_mgr) { | } else if (uefi_boot_mgr) { | ||||
| /* | /* | ||||
| * u-boot doesn't set BootOrder, but otherwise participates in the | * u-boot doesn't set BootOrder, but otherwise participates in the | ||||
| * boot manager protocol. So we fake it here and don't consider it | * boot manager protocol. So we fake it here and don't consider it | ||||
| * a failure. | * a failure. | ||||
| */ | */ | ||||
| boot_order[0] = boot_current; | boot_order[0] = boot_current; | ||||
| is_last = true; | |||||
| } | } | ||||
| } | } | ||||
| /* | /* | ||||
| * Next, find the boot info structure the UEFI boot manager is | * Next, find the boot info structure the UEFI boot manager is | ||||
| * supposed to setup. We need this so we can walk through it to | * supposed to setup. We need this so we can walk through it to | ||||
| * find where we are in the booting process and what to try to | * find where we are in the booting process and what to try to | ||||
| * boot next. | * boot next. | ||||
| Show All 32 Lines | #endif | ||||
| /* | /* | ||||
| * Try and find a good currdev based on the image that was booted. | * Try and find a good currdev based on the image that was booted. | ||||
| * It might be desirable here to have a short pause to allow falling | * It might be desirable here to have a short pause to allow falling | ||||
| * through to the boot loader instead of returning instantly to follow | * through to the boot loader instead of returning instantly to follow | ||||
| * the boot protocol and also allow an escape hatch for users wishing | * the boot protocol and also allow an escape hatch for users wishing | ||||
| * to try something different. | * to try something different. | ||||
| */ | */ | ||||
| if (find_currdev(uefi_boot_mgr, is_last, boot_info, bisz) != 0) | if (find_currdev(uefi_boot_mgr, boot_info, bisz) != 0) | ||||
| if (uefi_boot_mgr && | if (uefi_boot_mgr && | ||||
| !interactive_interrupt("Failed to find bootable partition")) | !interactive_interrupt("Failed to find bootable partition")) | ||||
| return (EFI_NOT_FOUND); | return (EFI_NOT_FOUND); | ||||
| autoload_font(false); /* Set up the font list for console. */ | autoload_font(false); /* Set up the font list for console. */ | ||||
| efi_init_environment(); | efi_init_environment(); | ||||
| interact(); /* doesn't return */ | interact(); /* doesn't return */ | ||||
| ▲ Show 20 Lines • Show All 547 Lines • Show Last 20 Lines | |||||