From 5d85dde27b4769604fc108b89328607e70e767ed Mon Sep 17 00:00:00 2001 From: Ahmad Khalifa Date: Sun, 4 Jan 2026 15:15:02 +0200 Subject: [PATCH] loader.efi: probe for UGA if GOP isn't found Probe for UGA instead of returning early if we can't find GOP. Reviewed by: tsoome PR: 291935 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54431 --- stand/efi/loader/framebuffer.c | 80 +++++++++++++++++----------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index 08834aa7106..dc0047de111 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -590,46 +590,8 @@ efi_find_framebuffer(teken_gfx_t *gfx_state) if (EFI_ERROR(status)) free(hlist); } - if (EFI_ERROR(status)) - return (efi_status_to_errno(status)); - nhandles = hsize / sizeof(*hlist); - - /* - * Search for ConOut protocol, if not found, use first handle. - */ - gop_handle = NULL; - for (i = 0; i < nhandles; i++) { - EFI_GRAPHICS_OUTPUT_PROTOCOL *tgop; - void *dummy; - - status = OpenProtocolByHandle(hlist[i], &gop_guid, (void **)&tgop); - if (status != EFI_SUCCESS) - continue; - - if (tgop->Mode->Info->PixelFormat == PixelBltOnly || - tgop->Mode->Info->PixelFormat >= PixelFormatMax) - continue; - - status = OpenProtocolByHandle(hlist[i], &conout_guid, &dummy); - if (status == EFI_SUCCESS) { - gop_handle = hlist[i]; - gop = tgop; - break; - } else if (gop_handle == NULL) { - gop_handle = hlist[i]; - gop = tgop; - } - } - - free(hlist); - - if (gop_handle != NULL) { - gfx_state->tg_fb_type = FB_GOP; - gfx_state->tg_private = gop; - if (edid_info == NULL) - edid_info = efifb_gop_get_edid(gop_handle); - } else { + if (EFI_ERROR(status)) { status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga); if (status == EFI_SUCCESS) { gfx_state->tg_fb_type = FB_UGA; @@ -637,6 +599,46 @@ efi_find_framebuffer(teken_gfx_t *gfx_state) } else { return (efi_status_to_errno(status)); } + } else { + nhandles = hsize / sizeof(*hlist); + + /* + * Search for ConOut protocol, if not found, use first handle. + */ + gop_handle = NULL; + for (i = 0; i < nhandles; i++) { + EFI_GRAPHICS_OUTPUT_PROTOCOL *tgop; + void *dummy; + + status = OpenProtocolByHandle(hlist[i], &gop_guid, + (void **)&tgop); + if (status != EFI_SUCCESS) + continue; + + if (tgop->Mode->Info->PixelFormat == PixelBltOnly || + tgop->Mode->Info->PixelFormat >= PixelFormatMax) + continue; + + status = OpenProtocolByHandle(hlist[i], &conout_guid, + &dummy); + if (status == EFI_SUCCESS) { + gop_handle = hlist[i]; + gop = tgop; + break; + } else if (gop_handle == NULL) { + gop_handle = hlist[i]; + gop = tgop; + } + } + + free(hlist); + if (gop_handle == NULL) + return (ENXIO); + + gfx_state->tg_fb_type = FB_GOP; + gfx_state->tg_private = gop; + if (edid_info == NULL) + edid_info = efifb_gop_get_edid(gop_handle); } switch (gfx_state->tg_fb_type) {