From owner-svn-src-all@freebsd.org Sat Aug 26 18:29:44 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E5D9EDD7DCB; Sat, 26 Aug 2017 18:29:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BFB8B746CB; Sat, 26 Aug 2017 18:29:44 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7QIThm7099500; Sat, 26 Aug 2017 18:29:43 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7QIThDc099496; Sat, 26 Aug 2017 18:29:43 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708261829.v7QIThDc099496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 26 Aug 2017 18:29:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322932 - head/sys/boot/efi/boot1 X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/boot/efi/boot1 X-SVN-Commit-Revision: 322932 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2017 18:29:45 -0000 Author: imp Date: Sat Aug 26 18:29:43 2017 New Revision: 322932 URL: https://svnweb.freebsd.org/changeset/base/322932 Log: Use the loader.efi conventions for the various EFI tables. Sponsored by: Netflix Modified: head/sys/boot/efi/boot1/boot1.c head/sys/boot/efi/boot1/boot_module.h head/sys/boot/efi/boot1/ufs_module.c head/sys/boot/efi/boot1/zfs_module.c Modified: head/sys/boot/efi/boot1/boot1.c ============================================================================== --- head/sys/boot/efi/boot1/boot1.c Sat Aug 26 18:29:37 2017 (r322931) +++ head/sys/boot/efi/boot1/boot1.c Sat Aug 26 18:29:43 2017 (r322932) @@ -47,9 +47,10 @@ static const boot_module_t *boot_modules[] = /* 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; +EFI_HANDLE IH; +EFI_SYSTEM_TABLE *ST; +EFI_BOOT_SERVICES *BS; +EFI_RUNTIME_SERVICES *RS; static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; @@ -66,7 +67,7 @@ Malloc(size_t len, const char *file __unused, int line { void *out; - if (bs->AllocatePool(EfiLoaderData, len, &out) == EFI_SUCCESS) + if (BS->AllocatePool(EfiLoaderData, len, &out) == EFI_SUCCESS) return (out); return (NULL); @@ -76,7 +77,7 @@ void Free(void *buf, const char *file __unused, int line __unused) { if (buf != NULL) - (void)bs->FreePool(buf); + (void)BS->FreePool(buf); } /* @@ -398,14 +399,14 @@ try_boot(void) 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)); @@ -431,7 +432,7 @@ try_boot(void) 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)); @@ -465,7 +466,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B 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); @@ -477,7 +478,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B 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); @@ -494,7 +495,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B /* 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", @@ -511,7 +512,7 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B status = boot_modules[i]->probe(devinfo); if (status == EFI_SUCCESS) return (EFI_SUCCESS); - (void)bs->FreePool(devinfo); + (void)BS->FreePool(devinfo); } return (EFI_UNSUPPORTED); @@ -565,12 +566,13 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) UINTN i, max_dim, best_mode, cols, rows, hsize, nhandles; /* Basic initialization*/ - systab = Xsystab; - image = Ximage; - bs = Xsystab->BootServices; + ST = Xsystab; + IH = Ximage; + BS = ST->BootServices; + RS = ST->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, @@ -578,7 +580,7 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) /* * 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++) { @@ -607,24 +609,24 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) /* 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", @@ -641,10 +643,10 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) 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", @@ -709,9 +711,9 @@ putchar(int c) 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); } Modified: head/sys/boot/efi/boot1/boot_module.h ============================================================================== --- head/sys/boot/efi/boot1/boot_module.h Sat Aug 26 18:29:37 2017 (r322931) +++ head/sys/boot/efi/boot1/boot_module.h Sat Aug 26 18:29:43 2017 (r322932) @@ -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 @@ extern const boot_module_t zfs_module; /* Functions available to modules. */ extern void add_device(dev_info_t **devinfop, dev_info_t *devinfo); extern int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); - -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); Modified: head/sys/boot/efi/boot1/ufs_module.c ============================================================================== --- head/sys/boot/efi/boot1/ufs_module.c Sat Aug 26 18:29:37 2017 (r322931) +++ head/sys/boot/efi/boot1/ufs_module.c Sat Aug 26 18:29:43 2017 (r322932) @@ -118,7 +118,7 @@ load(const char *filepath, dev_info_t *dev, void **buf 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)); @@ -129,7 +129,7 @@ load(const char *filepath, dev_info_t *dev, void **buf 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); } Modified: head/sys/boot/efi/boot1/zfs_module.c ============================================================================== --- head/sys/boot/efi/boot1/zfs_module.c Sat Aug 26 18:29:37 2017 (r322931) +++ head/sys/boot/efi/boot1/zfs_module.c Sat Aug 26 18:29:43 2017 (r322932) @@ -118,7 +118,7 @@ probe(dev_info_t *dev) 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)); @@ -127,7 +127,7 @@ probe(dev_info_t *dev) memcpy(tdev, dev, sizeof(*dev)); if (vdev_probe(vdev_read, tdev, &spa) != 0) { - (void)bs->FreePool(tdev); + (void)BS->FreePool(tdev); return (EFI_UNSUPPORTED); } @@ -180,7 +180,7 @@ load(const char *filepath, dev_info_t *devinfo, void * 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 %jd for pool '%s' for '%s' " "(%lu)\n", (intmax_t)st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); @@ -190,7 +190,7 @@ load(const char *filepath, dev_info_t *devinfo, void * 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); }