[haiku-commits] Change in haiku[master]: efi: Call console-control to enter text mode

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 17 Feb 2020 22:36:59 +0000

From Alex von Gluck IV <kallisti5@xxxxxxxxxxx>:

Alex von Gluck IV has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2250 ;)


Change subject: efi: Call console-control to enter text mode
......................................................................

efi: Call console-control to enter text mode

Change-Id: Ife1df3415bc5a31801bcb3d925f1b7c3a105f51b
---
A headers/private/kernel/platform/efi/protocol/console-control.h
M src/system/boot/platform/efi/console.cpp
2 files changed, 68 insertions(+), 0 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/50/2250/1

diff --git a/headers/private/kernel/platform/efi/protocol/console-control.h 
b/headers/private/kernel/platform/efi/protocol/console-control.h
new file mode 100644
index 0000000..4ff16c1
--- /dev/null
+++ b/headers/private/kernel/platform/efi/protocol/console-control.h
@@ -0,0 +1,33 @@
+// 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;
diff --git a/src/system/boot/platform/efi/console.cpp 
b/src/system/boot/platform/efi/console.cpp
index be04d3b..2c20286 100644
--- a/src/system/boot/platform/efi/console.cpp
+++ b/src/system/boot/platform/efi/console.cpp
@@ -14,6 +14,7 @@

 #include <boot/stage2.h>
 #include <boot/platform.h>
+#include <efi/protocol/console-control.h>
 #include <util/kernel_cpp.h>

 #include "efi_platform.h"
@@ -202,9 +203,43 @@
 }


+static void
+console_control(bool graphics)
+{
+       dprintf("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) {
+               dprintf("EFI Console Control not found. Skipping.\n");
+               return;
+       }
+
+       dprintf("Located EFI Console Control. Setting EFI %s mode...\n",
+               graphics ? "graphics" : "text");
+
+       if (graphics) {
+               status = consoleControl->SetMode(consoleControl,
+                       EfiConsoleControlScreenText);
+       } else {
+               status = consoleControl->SetMode(consoleControl,
+                       EfiConsoleControlScreenGraphics);
+       }
+
+       dprintf("Setting EFI %s mode was%s successful.\n",
+               graphics ? "graphics" : "text", (status == EFI_SUCCESS) ? "" : 
" not");
+}
+
+
 status_t
 console_init(void)
 {
+       console_control(false);
        update_screen_size();
        console_hide_cursor();
        console_clear_screen();

--
To view, visit https://review.haiku-os.org/c/haiku/+/2250
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ife1df3415bc5a31801bcb3d925f1b7c3a105f51b
Gerrit-Change-Number: 2250
Gerrit-PatchSet: 1
Gerrit-Owner: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: efi: Call console-control to enter text mode - Gerrit