efi: Call console-control to enter text mode
Change-Id: Ife1df3415bc5a31801bcb3d925f1b7c3a105f51b Reviewed-on: https://review.haiku-os.org/c/haiku/+/2250 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
8eafd6cd04
commit
9adc70887e
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2020 Haiku, Inc. All rights reserved
|
||||||
|
// Released under the terms of the MIT License
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <efi/types.h>
|
||||||
|
|
||||||
|
#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
|
||||||
|
{0xf42f7782, 0x012e, 0x4c12, \
|
||||||
|
{0x99, 0x56, 0x49, 0xf9, 0x43, 0x04, 0xf7, 0x21}}
|
||||||
|
|
||||||
|
extern efi_guid ConsoleControlProtocol;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
EfiConsoleControlScreenText,
|
||||||
|
EfiConsoleControlScreenGraphics,
|
||||||
|
EfiConsoleControlScreenMax
|
||||||
|
} efi_console_control_screen_mode;
|
||||||
|
|
||||||
|
typedef struct efi_console_control_protocol {
|
||||||
|
uint64_t Revision;
|
||||||
|
|
||||||
|
efi_status (*GetMode) (struct efi_console_control_protocol* self,
|
||||||
|
efi_console_control_screen_mode* mode,
|
||||||
|
bool* gopUgaExists,
|
||||||
|
bool* stdInLocked) EFIAPI;
|
||||||
|
|
||||||
|
efi_status (*SetMode) (struct efi_console_control_protocol* self,
|
||||||
|
efi_console_control_screen_mode mode) EFIAPI;
|
||||||
|
|
||||||
|
efi_status (*LockStdIn) (struct efi_console_control_protocol* self,
|
||||||
|
uint16_t* password);
|
||||||
|
|
||||||
|
} efi_console_control_protocol;
|
||||||
@@ -14,11 +14,22 @@
|
|||||||
|
|
||||||
#include <boot/stage2.h>
|
#include <boot/stage2.h>
|
||||||
#include <boot/platform.h>
|
#include <boot/platform.h>
|
||||||
|
#include <efi/protocol/console-control.h>
|
||||||
#include <util/kernel_cpp.h>
|
#include <util/kernel_cpp.h>
|
||||||
|
|
||||||
#include "efi_platform.h"
|
#include "efi_platform.h"
|
||||||
|
|
||||||
|
|
||||||
|
// This likely won't work without moving things around.
|
||||||
|
// Too early (pre-console init)
|
||||||
|
//#define TRACE_CONSOLE
|
||||||
|
#ifdef TRACE_CONSOLE
|
||||||
|
# define TRACE(x...) dprintf(x)
|
||||||
|
#else
|
||||||
|
# define TRACE(x...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
class Console : public ConsoleNode {
|
class Console : public ConsoleNode {
|
||||||
public:
|
public:
|
||||||
Console();
|
Console();
|
||||||
@@ -202,9 +213,43 @@ static void update_screen_size(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
console_control(bool graphics)
|
||||||
|
{
|
||||||
|
TRACE("Checking for EFI Console Control...\n");
|
||||||
|
efi_guid consoleControlProtocolGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
|
||||||
|
efi_console_control_protocol* consoleControl = NULL;
|
||||||
|
|
||||||
|
efi_status status = kSystemTable->BootServices->LocateProtocol(
|
||||||
|
&consoleControlProtocolGUID, NULL, (void**)&consoleControl);
|
||||||
|
|
||||||
|
// Some EFI implementations boot up in an EFI graphics mode (Apple)
|
||||||
|
// If this protocol doesn't exist, we can assume we're already in text mode.
|
||||||
|
if (status != EFI_SUCCESS || consoleControl == NULL) {
|
||||||
|
TRACE("EFI Console Control not found. Skipping.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Located EFI Console Control. Setting EFI %s mode...\n",
|
||||||
|
graphics ? "graphics" : "text");
|
||||||
|
|
||||||
|
if (graphics) {
|
||||||
|
status = consoleControl->SetMode(consoleControl,
|
||||||
|
EfiConsoleControlScreenGraphics);
|
||||||
|
} else {
|
||||||
|
status = consoleControl->SetMode(consoleControl,
|
||||||
|
EfiConsoleControlScreenText);
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Setting EFI %s mode was%s successful.\n",
|
||||||
|
graphics ? "graphics" : "text", (status == EFI_SUCCESS) ? "" : " not");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
console_init(void)
|
console_init(void)
|
||||||
{
|
{
|
||||||
|
console_control(true);
|
||||||
update_screen_size();
|
update_screen_size();
|
||||||
console_hide_cursor();
|
console_hide_cursor();
|
||||||
console_clear_screen();
|
console_clear_screen();
|
||||||
@@ -243,6 +288,7 @@ console_check_boot_keys(void)
|
|||||||
extern "C" void
|
extern "C" void
|
||||||
platform_switch_to_text_mode(void)
|
platform_switch_to_text_mode(void)
|
||||||
{
|
{
|
||||||
|
console_control(false);
|
||||||
kSystemTable->ConOut->Reset(kSystemTable->ConOut, false);
|
kSystemTable->ConOut->Reset(kSystemTable->ConOut, false);
|
||||||
kSystemTable->ConOut->SetMode(kSystemTable->ConOut, sScreenMode);
|
kSystemTable->ConOut->SetMode(kSystemTable->ConOut, sScreenMode);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user