aboutsummaryrefslogtreecommitdiff
path: root/stand/efi/loader/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/efi/loader/main.c')
-rw-r--r--stand/efi/loader/main.c75
1 files changed, 21 insertions, 54 deletions
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 436676368447..2e51f15f0b5f 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -69,6 +69,8 @@
#include "actypes.h"
#include "actbl.h"
+#include <acpi_detect.h>
+
#include "loader_efi.h"
struct arch_switch archsw = { /* MI/MD interface boundary */
@@ -83,8 +85,6 @@ struct arch_switch archsw = { /* MI/MD interface boundary */
.arch_zfs_probe = efi_zfs_probe,
};
-EFI_GUID acpi = ACPI_TABLE_GUID;
-EFI_GUID acpi20 = ACPI_20_TABLE_GUID;
EFI_GUID devid = DEVICE_PATH_PROTOCOL;
EFI_GUID imgid = LOADED_IMAGE_PROTOCOL;
EFI_GUID mps = MPS_TABLE_GUID;
@@ -120,11 +120,6 @@ UINT16 boot_current;
*/
EFI_LOADED_IMAGE *boot_img;
-/*
- * RSDP base table.
- */
-ACPI_TABLE_RSDP *rsdp;
-
static bool
has_keyboard(void)
{
@@ -315,9 +310,9 @@ probe_md_currdev(void)
static bool
try_as_currdev(pdinfo_t *hd, pdinfo_t *pp)
{
+#ifdef EFI_ZFS_BOOT
uint64_t guid;
-#ifdef EFI_ZFS_BOOT
/*
* If there's a zpool on this device, try it as a ZFS
* filesystem, which has somewhat different setup than all
@@ -505,8 +500,7 @@ match_boot_info(char *boot_info, size_t bisz)
* a drop to the OK boot loader prompt is possible.
*/
static int
-find_currdev(bool do_bootmgr, bool is_last,
- char *boot_info, size_t boot_info_sz)
+find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz)
{
pdinfo_t *dp, *pp;
EFI_DEVICE_PATH *devpath, *copy;
@@ -864,7 +858,7 @@ static int
check_acpi_spcr(void)
{
ACPI_TABLE_SPCR *spcr;
- int br, db, io, rs, rw, sb, xo, pv, pd;
+ int br, db, io, rs, rw, xo, pv, pd;
uintmax_t mm;
const char *dt, *pa;
char *val = NULL;
@@ -896,7 +890,6 @@ check_acpi_spcr(void)
/* Uart settings */
pa = acpi_uart_parity(spcr->Parity);
- sb = spcr->StopBits;
db = 8;
/*
@@ -1121,6 +1114,8 @@ read_loader_env(const char *name, char *def_fn, bool once)
printf(" Reading loader env vars from %s\n", fn);
parse_loader_efi_config(boot_img->DeviceHandle, fn);
}
+
+ free(freeme);
}
caddr_t
@@ -1130,39 +1125,6 @@ ptov(uintptr_t x)
}
static void
-acpi_detect(void)
-{
- char buf[24];
- int revision;
-
- feature_enable(FEATURE_EARLY_ACPI);
- if ((rsdp = efi_get_table(&acpi20)) == NULL)
- if ((rsdp = efi_get_table(&acpi)) == NULL)
- return;
-
- sprintf(buf, "0x%016"PRIxPTR, (uintptr_t)rsdp);
- setenv("acpi.rsdp", buf, 1);
- revision = rsdp->Revision;
- if (revision == 0)
- revision = 1;
- sprintf(buf, "%d", revision);
- setenv("acpi.revision", buf, 1);
- strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
- buf[sizeof(rsdp->OemId)] = '\0';
- setenv("acpi.oem", buf, 1);
- sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
- setenv("acpi.rsdt", buf, 1);
- if (revision >= 2) {
- /* XXX extended checksum? */
- sprintf(buf, "0x%016llx",
- (unsigned long long)rsdp->XsdtPhysicalAddress);
- setenv("acpi.xsdt", buf, 1);
- sprintf(buf, "%d", rsdp->Length);
- setenv("acpi.xsdt_length", buf, 1);
- }
-}
-
-static void
efi_smbios_detect(void)
{
VOID *smbios_v2_ptr = NULL;
@@ -1201,12 +1163,12 @@ EFI_STATUS
main(int argc, CHAR16 *argv[])
{
int howto, i, uhowto;
- bool has_kbd, is_last;
+ bool has_kbd;
char *s;
EFI_DEVICE_PATH *imgpath;
CHAR16 *text;
EFI_STATUS rv;
- size_t sz, bosz = 0, bisz = 0;
+ size_t sz, bisz = 0;
UINT16 boot_order[100];
char boot_info[4096];
char buf[32];
@@ -1404,17 +1366,13 @@ main(int argc, CHAR16 *argv[])
printf(" %04x%s", boot_order[i],
boot_order[i] == boot_current ? "[*]" : "");
printf("\n");
- is_last = boot_order[(sz / sizeof(boot_order[0])) - 1] == boot_current;
- bosz = sz;
} else if (uefi_boot_mgr) {
/*
* u-boot doesn't set BootOrder, but otherwise participates in the
* boot manager protocol. So we fake it here and don't consider it
* a failure.
*/
- bosz = sizeof(boot_order[0]);
boot_order[0] = boot_current;
- is_last = true;
}
}
@@ -1463,7 +1421,7 @@ main(int argc, CHAR16 *argv[])
* the boot protocol and also allow an escape hatch for users wishing
* 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 &&
!interactive_interrupt("Failed to find bootable partition"))
return (EFI_NOT_FOUND);
@@ -1858,6 +1816,8 @@ command_chain(int argc, char *argv[])
EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL;
EFI_HANDLE loaderhandle;
EFI_LOADED_IMAGE *loaded_image;
+ UINTN ExitDataSize;
+ CHAR16 *ExitData = NULL;
EFI_STATUS status;
struct stat st;
struct devdesc *dev;
@@ -1973,9 +1933,16 @@ command_chain(int argc, char *argv[])
}
dev_cleanup();
- status = BS->StartImage(loaderhandle, NULL, NULL);
+
+ status = BS->StartImage(loaderhandle, &ExitDataSize, &ExitData);
if (status != EFI_SUCCESS) {
- command_errmsg = "StartImage failed";
+ printf("StartImage failed (%lu)", EFI_ERROR_CODE(status));
+ if (ExitData != NULL) {
+ printf(": %S", ExitData);
+ BS->FreePool(ExitData);
+ }
+ putchar('\n');
+ command_errmsg = "";
free(loaded_image->LoadOptions);
loaded_image->LoadOptions = NULL;
status = BS->UnloadImage(loaded_image);