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:
parent
ebdee3ef35
commit
4ff3f10852
@ -243,5 +243,4 @@ platform_switch_to_text_mode(void)
|
|||||||
{
|
{
|
||||||
kSystemTable->ConOut->Reset(kSystemTable->ConOut, false);
|
kSystemTable->ConOut->Reset(kSystemTable->ConOut, false);
|
||||||
kSystemTable->ConOut->SetMode(kSystemTable->ConOut, sScreenMode);
|
kSystemTable->ConOut->SetMode(kSystemTable->ConOut, sScreenMode);
|
||||||
gKernelArgs.frame_buffer.enabled = false;
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <boot/platform.h>
|
#include <boot/platform.h>
|
||||||
#include <boot/platform/generic/video.h>
|
#include <boot/platform/generic/video.h>
|
||||||
#include <boot/stage2.h>
|
#include <boot/stage2.h>
|
||||||
|
#include <boot/stdio.h>
|
||||||
|
|
||||||
#include "efi_platform.h"
|
#include "efi_platform.h"
|
||||||
|
|
||||||
@ -38,24 +39,39 @@ platform_init_video(void)
|
|||||||
UINTN bestArea = 0;
|
UINTN bestArea = 0;
|
||||||
UINTN bestDepth = 0;
|
UINTN bestDepth = 0;
|
||||||
|
|
||||||
|
dprintf("looking for best graphics mode...\n");
|
||||||
|
|
||||||
for (UINTN mode = 0; mode < sGraphicsOutput->Mode->MaxMode; ++mode) {
|
for (UINTN mode = 0; mode < sGraphicsOutput->Mode->MaxMode; ++mode) {
|
||||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
|
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
|
||||||
UINTN size, depth;
|
UINTN size, depth;
|
||||||
sGraphicsOutput->QueryMode(sGraphicsOutput, mode, &size, &info);
|
sGraphicsOutput->QueryMode(sGraphicsOutput, mode, &size, &info);
|
||||||
UINTN area = info->HorizontalResolution * info->VerticalResolution;
|
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)
|
if (info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor)
|
||||||
depth = 32;
|
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
|
else if (info->PixelFormat == PixelBitMask
|
||||||
&& info->PixelInformation.RedMask == 0xFF0000
|
&& info->PixelInformation.RedMask == 0xFF0000
|
||||||
&& info->PixelInformation.GreenMask == 0x00FF00
|
&& info->PixelInformation.GreenMask == 0x00FF00
|
||||||
&& info->PixelInformation.BlueMask == 0x0000FF
|
&& info->PixelInformation.BlueMask == 0x0000FF
|
||||||
&& info->PixelInformation.ReservedMask == 0)
|
&& info->PixelInformation.ReservedMask == 0)
|
||||||
depth = 24;
|
depth = 24;
|
||||||
else
|
else {
|
||||||
|
dprintf(" pixel format: %x unsupported\n",
|
||||||
|
info->PixelFormat);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
dprintf(" depth: %lu\n", depth);
|
||||||
|
|
||||||
area *= depth;
|
area *= depth;
|
||||||
|
dprintf(" area (w/depth): %lu\n", area);
|
||||||
if (area >= bestArea) {
|
if (area >= bestArea) {
|
||||||
|
dprintf("selected new best mode: %lu\n", mode);
|
||||||
bestArea = area;
|
bestArea = area;
|
||||||
bestDepth = depth;
|
bestDepth = depth;
|
||||||
sGraphicsMode = mode;
|
sGraphicsMode = mode;
|
||||||
@ -64,9 +80,11 @@ platform_init_video(void)
|
|||||||
|
|
||||||
if (bestArea == 0 || bestDepth == 0) {
|
if (bestArea == 0 || bestDepth == 0) {
|
||||||
sGraphicsOutput = NULL;
|
sGraphicsOutput = NULL;
|
||||||
|
gKernelArgs.frame_buffer.enabled = false;
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gKernelArgs.frame_buffer.enabled = true;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,11 +92,10 @@ platform_init_video(void)
|
|||||||
extern "C" void
|
extern "C" void
|
||||||
platform_switch_to_logo(void)
|
platform_switch_to_logo(void)
|
||||||
{
|
{
|
||||||
if (sGraphicsOutput == NULL || gKernelArgs.frame_buffer.enabled)
|
if (sGraphicsOutput == NULL || !gKernelArgs.frame_buffer.enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sGraphicsOutput->SetMode(sGraphicsOutput, sGraphicsMode);
|
sGraphicsOutput->SetMode(sGraphicsOutput, sGraphicsMode);
|
||||||
gKernelArgs.frame_buffer.enabled = true;
|
|
||||||
gKernelArgs.frame_buffer.physical_buffer.start =
|
gKernelArgs.frame_buffer.physical_buffer.start =
|
||||||
sGraphicsOutput->Mode->FrameBufferBase;
|
sGraphicsOutput->Mode->FrameBufferBase;
|
||||||
gKernelArgs.frame_buffer.physical_buffer.size =
|
gKernelArgs.frame_buffer.physical_buffer.size =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user