summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoonas Lahtinen <joonas.lahtinen@linux.intel.com>2013-12-10 09:23:29 +0000
committerKay Sievers <kay@vrfy.org>2013-12-15 17:59:23 +0100
commit443063b6cefa091c16fe757f5052e1ef2196e786 (patch)
tree9e806c0d267834513c2749941f50309dfec21112
parente75af25fdab9a52e2059d7c950567e7ddbd09022 (diff)
make console_text_mode into more generic function
Convert console_text_mode function into console_mode function which is able to switch back and forth between graphics and text mode. Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: Darren Hart <dvhart@linux.intel.com> Reviewed-by: Mikko Ylinen <mikko.ylinen@intel.com>
-rw-r--r--src/efi/gummiboot.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/efi/gummiboot.c b/src/efi/gummiboot.c
index 5ff640e..bc3793b 100644
--- a/src/efi/gummiboot.c
+++ b/src/efi/gummiboot.c
@@ -54,6 +54,11 @@ enum loader_type {
LOADER_LINUX
};
+enum console_mode {
+ CONSOLE_TEXT,
+ CONSOLE_GRAPHICS,
+};
+
typedef struct {
CHAR16 *file;
CHAR16 *title_show;
@@ -736,7 +741,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
}
-static EFI_STATUS console_text_mode(VOID) {
+static EFI_STATUS console_mode(enum console_mode request) {
#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
{ 0xf42f7782, 0x12e, 0x4c12, { 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 } };
@@ -773,12 +778,33 @@ static EFI_STATUS console_text_mode(VOID) {
EFI_GUID ConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL;
+ EFI_CONSOLE_CONTROL_SCREEN_MODE new;
+ EFI_CONSOLE_CONTROL_SCREEN_MODE current;
+ BOOLEAN uga_exists;
+ BOOLEAN stdin_locked;
EFI_STATUS err;
err = LibLocateProtocol(&ConsoleControlProtocolGuid, (VOID **)&ConsoleControl);
if (EFI_ERROR(err))
return err;
- return uefi_call_wrapper(ConsoleControl->SetMode, 2, ConsoleControl, EfiConsoleControlScreenText);
+
+ /* be extra cautious about not causing mode switch */
+ err = uefi_call_wrapper(ConsoleControl->GetMode, 4, ConsoleControl, &current, &uga_exists, &stdin_locked);
+ if (err == EFI_SUCCESS) {
+ switch (request) {
+ case CONSOLE_GRAPHICS:
+ new = EfiConsoleControlScreenGraphics;
+ break;
+ case CONSOLE_TEXT:
+ new = EfiConsoleControlScreenText;
+ break;
+ }
+
+ if (new == current)
+ return EFI_SUCCESS;
+ }
+
+ return uefi_call_wrapper(ConsoleControl->SetMode, 2, ConsoleControl, new);
}
static BOOLEAN menu_run(Config *config, ConfigEntry **chosen_entry, CHAR16 *loaded_image_path) {
@@ -805,7 +831,7 @@ static BOOLEAN menu_run(Config *config, ConfigEntry **chosen_entry, CHAR16 *load
BOOLEAN run = TRUE;
BOOLEAN wait = FALSE;
- console_text_mode();
+ console_mode(CONSOLE_TEXT);
uefi_call_wrapper(ST->ConIn->Reset, 2, ST->ConIn, FALSE);
uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, FALSE);
uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK);