The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=52ec89a93c796ca3f3f3da2eec867804fcdd1a4d
commit 52ec89a93c796ca3f3f3da2eec867804fcdd1a4d Author: Toomas Soome <tso...@freebsd.org> AuthorDate: 2021-01-17 13:07:27 +0000 Commit: Toomas Soome <tso...@freebsd.org> CommitDate: 2021-01-17 13:33:48 +0000 loader.efi: commands gop, uga and autoresize should use cached data We are setting up pointers for gop or uga protocol in efi_find_framebuffer(), reuse those pointers. --- stand/efi/loader/framebuffer.c | 47 +++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index 0b23a42b1cdc..509c41844dcb 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -43,11 +43,14 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "framebuffer.h" -EFI_GUID conout_guid = EFI_CONSOLE_OUT_DEVICE_GUID; +static EFI_GUID conout_guid = EFI_CONSOLE_OUT_DEVICE_GUID; EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; +static EFI_GRAPHICS_OUTPUT *gop; +static EFI_UGA_DRAW_PROTOCOL *uga; + static struct named_resolution { const char *name; const char *alias; @@ -305,7 +308,7 @@ efifb_uga_locate_framebuffer(EFI_PCI_IO_PROTOCOL *pciio, uint64_t *addrp, } static int -efifb_from_uga(struct efi_fb *efifb, EFI_UGA_DRAW_PROTOCOL *uga) +efifb_from_uga(struct efi_fb *efifb) { EFI_PCI_IO_PROTOCOL *pciio; char *ev, *p; @@ -470,8 +473,6 @@ efi_find_framebuffer(teken_gfx_t *gfx_state) EFI_HANDLE h, *hlist; UINTN nhandles, i, hsize; struct efi_fb efifb; - EFI_GRAPHICS_OUTPUT *gop; - EFI_UGA_DRAW_PROTOCOL *uga; EFI_STATUS status; int rv; @@ -530,7 +531,7 @@ efi_find_framebuffer(teken_gfx_t *gfx_state) break; case FB_UGA: - rv = efifb_from_uga(&efifb, uga); + rv = efifb_from_uga(&efifb); break; default: @@ -624,7 +625,7 @@ efi_get_max_resolution(int *width, int *height) } static int -gop_autoresize(EFI_GRAPHICS_OUTPUT *gop) +gop_autoresize(void) { struct efi_fb efifb; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; @@ -690,7 +691,7 @@ text_autoresize() } static int -uga_autoresize(EFI_UGA_DRAW_PROTOCOL *uga) +uga_autoresize(void) { return (text_autoresize()); @@ -701,25 +702,18 @@ COMMAND_SET(efi_autoresize, "efi-autoresizecons", "EFI Auto-resize Console", com static int command_autoresize(int argc, char *argv[]) { - EFI_GRAPHICS_OUTPUT *gop; - EFI_UGA_DRAW_PROTOCOL *uga; char *textmode; - EFI_STATUS status; textmode = getenv("hw.vga.textmode"); /* If it's set and non-zero, we'll select a console mode instead */ if (textmode != NULL && strcmp(textmode, "0") != 0) return (text_autoresize()); - gop = NULL; - uga = NULL; - status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); - if (EFI_ERROR(status) == 0) - return (gop_autoresize(gop)); + if (gop != NULL) + return (gop_autoresize()); - status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); - if (EFI_ERROR(status) == 0) - return (uga_autoresize(uga)); + if (uga != NULL) + return (uga_autoresize()); snprintf(command_errbuf, sizeof(command_errbuf), "%s: Neither Graphics Output Protocol nor Universal Graphics Adapter present", @@ -740,15 +734,12 @@ static int command_gop(int argc, char *argv[]) { struct efi_fb efifb; - EFI_GRAPHICS_OUTPUT *gop; EFI_STATUS status; u_int mode; - status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); - if (EFI_ERROR(status)) { + if (gop == NULL) { snprintf(command_errbuf, sizeof(command_errbuf), - "%s: Graphics Output Protocol not present (error=%lu)", - argv[0], EFI_ERROR_CODE(status)); + "%s: Graphics Output Protocol not present", argv[0]); return (CMD_ERROR); } @@ -813,21 +804,17 @@ static int command_uga(int argc, char *argv[]) { struct efi_fb efifb; - EFI_UGA_DRAW_PROTOCOL *uga; - EFI_STATUS status; - status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); - if (EFI_ERROR(status)) { + if (uga == NULL) { snprintf(command_errbuf, sizeof(command_errbuf), - "%s: UGA Protocol not present (error=%lu)", - argv[0], EFI_ERROR_CODE(status)); + "%s: UGA Protocol not present", argv[0]); return (CMD_ERROR); } if (argc != 1) goto usage; - if (efifb_from_uga(&efifb, uga) != CMD_OK) { + if (efifb_from_uga(&efifb) != CMD_OK) { snprintf(command_errbuf, sizeof(command_errbuf), "%s: Unable to get UGA information", argv[0]); return (CMD_ERROR); _______________________________________________ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"