From 4ff3f10852745c4d47370c01ba2f4e1d59e38056 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Mon, 19 Dec 2016 20:16:52 +1300 Subject: [PATCH] UEFI: improve setting up of the framebuffer. * Even if we get dropped into the boot menu, we still want to have the framebuffer enabled, else we never switch back into graphics mode. --- src/system/boot/platform/efi/console.cpp | 1 - src/system/boot/platform/efi/video.cpp | 23 ++++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/system/boot/platform/efi/console.cpp b/src/system/boot/platform/efi/console.cpp index 35500e731a..ebfd21f441 100644 --- a/src/system/boot/platform/efi/console.cpp +++ b/src/system/boot/platform/efi/console.cpp @@ -243,5 +243,4 @@ platform_switch_to_text_mode(void) { kSystemTable->ConOut->Reset(kSystemTable->ConOut, false); kSystemTable->ConOut->SetMode(kSystemTable->ConOut, sScreenMode); - gKernelArgs.frame_buffer.enabled = false; } diff --git a/src/system/boot/platform/efi/video.cpp b/src/system/boot/platform/efi/video.cpp index 9c21c01f72..1e78a79e91 100644 --- a/src/system/boot/platform/efi/video.cpp +++ b/src/system/boot/platform/efi/video.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "efi_platform.h" @@ -38,24 +39,39 @@ platform_init_video(void) UINTN bestArea = 0; UINTN bestDepth = 0; + dprintf("looking for best graphics mode...\n"); + for (UINTN mode = 0; mode < sGraphicsOutput->Mode->MaxMode; ++mode) { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; UINTN size, depth; sGraphicsOutput->QueryMode(sGraphicsOutput, mode, &size, &info); UINTN area = info->HorizontalResolution * info->VerticalResolution; + dprintf(" mode: %lu\n", mode); + dprintf(" width: %u\n", info->HorizontalResolution); + dprintf(" height: %u\n", info->VerticalResolution); + dprintf(" area: %lu\n", area); if (info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor) depth = 32; + else if (info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) + // seen this in the wild, but acts like RGB, go figure... + depth = 32; else if (info->PixelFormat == PixelBitMask && info->PixelInformation.RedMask == 0xFF0000 && info->PixelInformation.GreenMask == 0x00FF00 && info->PixelInformation.BlueMask == 0x0000FF && info->PixelInformation.ReservedMask == 0) depth = 24; - else + else { + dprintf(" pixel format: %x unsupported\n", + info->PixelFormat); continue; + } + dprintf(" depth: %lu\n", depth); area *= depth; + dprintf(" area (w/depth): %lu\n", area); if (area >= bestArea) { + dprintf("selected new best mode: %lu\n", mode); bestArea = area; bestDepth = depth; sGraphicsMode = mode; @@ -64,9 +80,11 @@ platform_init_video(void) if (bestArea == 0 || bestDepth == 0) { sGraphicsOutput = NULL; + gKernelArgs.frame_buffer.enabled = false; return B_ERROR; } + gKernelArgs.frame_buffer.enabled = true; return B_OK; } @@ -74,11 +92,10 @@ platform_init_video(void) extern "C" void platform_switch_to_logo(void) { - if (sGraphicsOutput == NULL || gKernelArgs.frame_buffer.enabled) + if (sGraphicsOutput == NULL || !gKernelArgs.frame_buffer.enabled) return; sGraphicsOutput->SetMode(sGraphicsOutput, sGraphicsMode); - gKernelArgs.frame_buffer.enabled = true; gKernelArgs.frame_buffer.physical_buffer.start = sGraphicsOutput->Mode->FrameBufferBase; gKernelArgs.frame_buffer.physical_buffer.size =