[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] efi: Set text-mode console resolution to maximum supported

From: Glenn Washburn
Subject: [PATCH v2] efi: Set text-mode console resolution to maximum supported
Date: Fri, 6 May 2022 07:06:58 -0500

On some buggy EFI firmwares, GRUB is started with the console resolution
set to the maximum but the output console EFI object has the mode set as
0, which is the minimum supported mode of 80x25 characters. This causes
strange behavior at the GRUB shell where output can fill the screen, but
the prompt is at line 80 in the middle of the screen.

When initializing the EFI console, find the largest console resolution
supported by area and set that as the current output mode. This works around
the buggy firmware and provides a GRUB shell that displays correctly.

Signed-off-by: Glenn Washburn <>
v2: Fix to query each mode instead of just the current mode
 grub-core/term/efi/console.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index a3622e4fe..a98b84aac 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -141,6 +141,10 @@ grub_console_setcursor (struct grub_term_output *term 
__attribute__ ((unused)),
 static grub_err_t
 grub_prepare_for_text_output (struct grub_term_output *term)
+  grub_efi_simple_text_output_interface_t *o;
+  grub_efi_uintn_t columns, columns_max, rows, rows_max;
+  grub_efi_int32_t i, mode_max;
   if (grub_efi_is_finished)
     return GRUB_ERR_BAD_DEVICE;
@@ -155,6 +159,16 @@ grub_prepare_for_text_output (struct grub_term_output 
       return GRUB_ERR_BAD_DEVICE;
+  /* Set text-mode resolution to maximum supported */
+  o = grub_efi_system_table->con_out;
+  for (i=0, columns_max=0, rows_max=0, mode_max=0; i < o->mode->max_mode; i++)
+    if (GRUB_EFI_SUCCESS == efi_call_4 (o->query_mode, o, i,
+                                       &columns, &rows)
+       && (columns_max * rows_max) < (columns * rows))
+      mode_max = i;
+  efi_call_2 (o->set_mode, o, mode_max);
   if (cursor_mode != GRUB_CURSOR_MODE_UNDEFINED)
     grub_console_setcursor (term, cursor_mode);
   if (text_colorstate != GRUB_TERM_COLOR_UNDEFINED)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]