Mercurial > unleashed > prev-conversion
changeset 18799:44db128cd592
8925 boot1.efi: link with libefi
author | Toomas Soome <tsoome@me.com> |
---|---|
date | Tue, 12 Dec 2017 13:47:20 +0200 |
parents | f656a72baba3 |
children | dbe85db2066a |
files | usr/src/boot/sys/boot/efi/Makefile usr/src/boot/sys/boot/efi/boot1/Makefile usr/src/boot/sys/boot/efi/boot1/boot1.c usr/src/boot/sys/boot/efi/boot1/boot_module.h usr/src/boot/sys/boot/efi/boot1/ufs_module.c usr/src/boot/sys/boot/efi/boot1/zfs_module.c |
diffstat | 6 files changed, 44 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/boot/sys/boot/efi/Makefile Tue Dec 12 13:08:57 2017 +0200 +++ b/usr/src/boot/sys/boot/efi/Makefile Tue Dec 12 13:47:20 2017 +0200 @@ -17,7 +17,7 @@ include $(SRC)/Makefile.master -SUBDIRS = boot1 libefi loader +SUBDIRS = libefi boot1 loader #.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" #.if ${MK_FDT} != "no" @@ -33,6 +33,10 @@ clobber := TARGET = clobber install := TARGET = install +# boot1 and loader both link against libefi +boot1: libefi +loader: libefi + $(SUBDIRS): FRC @cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
--- a/usr/src/boot/sys/boot/efi/boot1/Makefile Tue Dec 12 13:08:57 2017 +0200 +++ b/usr/src/boot/sys/boot/efi/boot1/Makefile Tue Dec 12 13:47:20 2017 +0200 @@ -66,6 +66,7 @@ install: all $(ROOTBOOTFILES) +LIBEFI= ../libefi/libefi.a # # Add libstand for the runtime functions used by the compiler - for example # __aeabi_* (arm) or __divdi3 (i386). @@ -73,8 +74,10 @@ # LIBSTAND= ../../libstand/$(MACH64)/libstand.a LIBZFSBOOT= ../../zfs/$(MACH64)/libzfsboot.a -DPADD= ${LIBSTAND} ${LIBZFSBOOT} -LDADD= -L../../zfs/$(MACH64) -lzfsboot -L../../libstand/$(MACH64) -lstand +DPADD= $(LIBEFI) $(LIBZFSBOOT) $(LIBSTAND) +LDADD= -L../libefi -lefi +LDADD += -L../../zfs/$(MACH64) -lzfsboot +LDADD += -L../../libstand/$(MACH64) -lstand DPADD += ${LDSCRIPT}
--- a/usr/src/boot/sys/boot/efi/boot1/boot1.c Tue Dec 12 13:08:57 2017 +0200 +++ b/usr/src/boot/sys/boot/efi/boot1/boot1.c Tue Dec 12 13:47:20 2017 +0200 @@ -52,10 +52,6 @@ /* The initial number of handles used to query EFI for partitions. */ #define NUM_HANDLES_INIT 24 -EFI_SYSTEM_TABLE *systab; -EFI_BOOT_SERVICES *bs; -static EFI_HANDLE *image; - static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; @@ -71,7 +67,7 @@ { void *out; - if (bs->AllocatePool(EfiLoaderData, len, &out) == EFI_SUCCESS) + if (BS->AllocatePool(EfiLoaderData, len, &out) == EFI_SUCCESS) return (out); return (NULL); @@ -81,7 +77,7 @@ Free(void *buf, const char *file __unused, int line __unused) { if (buf != NULL) - (void)bs->FreePool(buf); + (void)BS->FreePool(buf); } /* @@ -403,14 +399,14 @@ buf = NULL; } - if ((status = bs->LoadImage(TRUE, image, devpath_last(dev->devpath), + if ((status = BS->LoadImage(TRUE, IH, devpath_last(dev->devpath), loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) { printf("Failed to load image provided by %s, size: %zu, (%lu)\n", mod->name, loadersize, EFI_ERROR_CODE(status)); goto errout; } - if ((status = bs->HandleProtocol(loaderhandle, &LoadedImageGUID, + if ((status = BS->HandleProtocol(loaderhandle, &LoadedImageGUID, (VOID**)&loaded_image)) != EFI_SUCCESS) { printf("Failed to query LoadedImage provided by %s (%lu)\n", mod->name, EFI_ERROR_CODE(status)); @@ -436,7 +432,7 @@ DSTALL(1000000); DPRINTF(".\n"); - if ((status = bs->StartImage(loaderhandle, NULL, NULL)) != + if ((status = BS->StartImage(loaderhandle, NULL, NULL)) != EFI_SUCCESS) { printf("Failed to start image provided by %s (%lu)\n", mod->name, EFI_ERROR_CODE(status)); @@ -470,7 +466,7 @@ UINTN i; /* Figure out if we're dealing with an actual partition. */ - status = bs->HandleProtocol(h, &DevicePathGUID, (void **)&devpath); + status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath); if (status == EFI_UNSUPPORTED) return (status); @@ -482,7 +478,7 @@ DPRINTF("probing: %s\n", devpath_str(devpath)); - status = bs->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio); + status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio); if (status == EFI_UNSUPPORTED) return (status); @@ -499,7 +495,7 @@ /* Run through each module, see if it can load this partition */ for (i = 0; i < NUM_BOOT_MODULES; i++) { - if ((status = bs->AllocatePool(EfiLoaderData, + if ((status = BS->AllocatePool(EfiLoaderData, sizeof(*devinfo), (void **)&devinfo)) != EFI_SUCCESS) { DPRINTF("\nFailed to allocate devinfo (%lu)\n", @@ -516,7 +512,7 @@ status = boot_modules[i]->probe(devinfo); if (status == EFI_SUCCESS) return (EFI_SUCCESS); - (void)bs->FreePool(devinfo); + (void)BS->FreePool(devinfo); } return (EFI_UNSUPPORTED); @@ -569,12 +565,13 @@ UINTN i, max_dim, best_mode, cols, rows, hsize, nhandles; /* Basic initialization*/ - systab = Xsystab; - image = Ximage; - bs = Xsystab->BootServices; + ST = Xsystab; + IH = Ximage; + BS = Xsystab->BootServices; + RS = Xsystab->RuntimeServices; /* Set up the console, so printf works. */ - status = bs->LocateProtocol(&ConsoleControlGUID, NULL, + status = BS->LocateProtocol(&ConsoleControlGUID, NULL, (VOID **)&ConsoleControl); if (status == EFI_SUCCESS) (void)ConsoleControl->SetMode(ConsoleControl, @@ -582,7 +579,7 @@ /* * Reset the console and find the best text mode. */ - conout = systab->ConOut; + conout = ST->ConOut; conout->Reset(conout, TRUE); max_dim = best_mode = 0; for (i = 0; ; i++) { @@ -611,24 +608,24 @@ /* Get all the device handles */ hsize = (UINTN)NUM_HANDLES_INIT * sizeof(EFI_HANDLE); - if ((status = bs->AllocatePool(EfiLoaderData, hsize, (void **)&handles)) + if ((status = BS->AllocatePool(EfiLoaderData, hsize, (void **)&handles)) != EFI_SUCCESS) panic("Failed to allocate %d handles (%lu)", NUM_HANDLES_INIT, EFI_ERROR_CODE(status)); - status = bs->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, + status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, &hsize, handles); switch (status) { case EFI_SUCCESS: break; case EFI_BUFFER_TOO_SMALL: - (void)bs->FreePool(handles); - if ((status = bs->AllocatePool(EfiLoaderData, hsize, + (void)BS->FreePool(handles); + if ((status = BS->AllocatePool(EfiLoaderData, hsize, (void **)&handles)) != EFI_SUCCESS) { panic("Failed to allocate %zu handles (%lu)", hsize / sizeof(*handles), EFI_ERROR_CODE(status)); } - status = bs->LocateHandle(ByProtocol, &BlockIoProtocolGUID, + status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, &hsize, handles); if (status != EFI_SUCCESS) panic("Failed to get device handles (%lu)\n", @@ -645,10 +642,10 @@ DPRINTF("\n"); /* Determine the devpath of our image so we can prefer it. */ - status = bs->HandleProtocol(image, &LoadedImageGUID, (VOID**)&img); + status = BS->HandleProtocol(IH, &LoadedImageGUID, (VOID**)&img); imgpath = NULL; if (status == EFI_SUCCESS) { - status = bs->HandleProtocol(img->DeviceHandle, &DevicePathGUID, + status = BS->HandleProtocol(img->DeviceHandle, &DevicePathGUID, (void **)&imgpath); if (status != EFI_SUCCESS) DPRINTF("Failed to get image DevicePath (%lu)\n", @@ -713,11 +710,11 @@ if (c == '\n') { buf[0] = '\r'; buf[1] = 0; - systab->ConOut->OutputString(systab->ConOut, buf); + ST->ConOut->OutputString(ST->ConOut, buf); } buf[0] = c; buf[1] = 0; - systab->ConOut->OutputString(systab->ConOut, buf); + ST->ConOut->OutputString(ST->ConOut, buf); } int @@ -727,10 +724,10 @@ EFI_STATUS status; UINTN junk; - status = systab->ConIn->ReadKeyStroke(systab->ConIn, &key); + status = ST->ConIn->ReadKeyStroke(ST->ConIn, &key); if (status == EFI_NOT_READY) { - bs->WaitForEvent(1, &systab->ConIn->WaitForKey, &junk); - status = systab->ConIn->ReadKeyStroke(systab->ConIn, &key); + BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &junk); + status = ST->ConIn->ReadKeyStroke(ST->ConIn, &key); } return (key.UnicodeChar); }
--- a/usr/src/boot/sys/boot/efi/boot1/boot_module.h Tue Dec 12 13:08:57 2017 +0200 +++ b/usr/src/boot/sys/boot/efi/boot1/boot_module.h Tue Dec 12 13:47:20 2017 +0200 @@ -37,7 +37,7 @@ #ifdef EFI_DEBUG #define DPRINTF(fmt, args...) printf(fmt, ##args) -#define DSTALL(d) bs->Stall(d) +#define DSTALL(d) BS->Stall(d) #else #define DPRINTF(fmt, ...) {} #define DSTALL(d) {} @@ -106,9 +106,6 @@ /* Functions available to modules. */ extern void add_device(dev_info_t **devinfop, dev_info_t *devinfo); -extern EFI_SYSTEM_TABLE *systab; -extern EFI_BOOT_SERVICES *bs; - extern int devpath_strlcat(char *buf, size_t size, EFI_DEVICE_PATH *devpath); extern char *devpath_str(EFI_DEVICE_PATH *devpath); #endif
--- a/usr/src/boot/sys/boot/efi/boot1/ufs_module.c Tue Dec 12 13:08:57 2017 +0200 +++ b/usr/src/boot/sys/boot/efi/boot1/ufs_module.c Tue Dec 12 13:47:20 2017 +0200 @@ -116,7 +116,7 @@ return (EFI_INVALID_PARAMETER); } - if ((status = bs->AllocatePool(EfiLoaderData, size, &buf)) != + if ((status = BS->AllocatePool(EfiLoaderData, size, &buf)) != EFI_SUCCESS) { printf("Failed to allocate read buffer %zu for '%s' (%lu)\n", size, filepath, EFI_ERROR_CODE(status)); @@ -127,7 +127,7 @@ if ((size_t)read != size) { printf("Failed to read '%s' (%zd != %zu)\n", filepath, read, size); - (void)bs->FreePool(buf); + (void)BS->FreePool(buf); return (EFI_INVALID_PARAMETER); }
--- a/usr/src/boot/sys/boot/efi/boot1/zfs_module.c Tue Dec 12 13:08:57 2017 +0200 +++ b/usr/src/boot/sys/boot/efi/boot1/zfs_module.c Tue Dec 12 13:47:20 2017 +0200 @@ -116,7 +116,7 @@ EFI_STATUS status; /* ZFS consumes the dev on success so we need a copy. */ - if ((status = bs->AllocatePool(EfiLoaderData, sizeof(*dev), + if ((status = BS->AllocatePool(EfiLoaderData, sizeof(*dev), (void**)&tdev)) != EFI_SUCCESS) { DPRINTF("Failed to allocate tdev (%lu)\n", EFI_ERROR_CODE(status)); @@ -125,7 +125,7 @@ memcpy(tdev, dev, sizeof(*dev)); if (vdev_probe(vdev_read, tdev, &spa) != 0) { - (void)bs->FreePool(tdev); + (void)BS->FreePool(tdev); return (EFI_UNSUPPORTED); } @@ -178,7 +178,7 @@ return (EFI_INVALID_PARAMETER); } - if ((status = bs->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf)) + if ((status = BS->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf)) != EFI_SUCCESS) { printf("Failed to allocate load buffer %zd for pool '%s' for '%s' " "(%lu)\n", st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); @@ -188,7 +188,7 @@ if ((err = dnode_read(spa, &dn, 0, buf, st.st_size)) != 0) { printf("Failed to read node from %s (%d)\n", spa->spa_name, err); - (void)bs->FreePool(buf); + (void)BS->FreePool(buf); return (EFI_INVALID_PARAMETER); }