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.
This commit is contained in:
Jessica Hamilton 2016-12-19 20:16:52 +13:00
parent ebdee3ef35
commit 4ff3f10852
2 changed files with 20 additions and 4 deletions

View File

@ -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;
}

View File

@ -8,6 +8,7 @@
#include <boot/platform.h>
#include <boot/platform/generic/video.h>
#include <boot/stage2.h>
#include <boot/stdio.h>
#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 =