All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi: Set text-mode console resolution to maximum supported
@ 2022-05-06  9:46 Glenn Washburn
  2022-05-06 10:39 ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Glenn Washburn @ 2022-05-06  9:46 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

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 <development@efficientek.com>
---
 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..06da5548f 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 *term)
       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, o->mode->mode,
+                                       &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)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-12 12:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-06  9:46 [PATCH] efi: Set text-mode console resolution to maximum supported Glenn Washburn
2022-05-06 10:39 ` Gerd Hoffmann
2022-05-07  0:59   ` Glenn Washburn
2022-05-10 11:57     ` Gerd Hoffmann
2022-05-12  1:43       ` Glenn Washburn
2022-05-12 12:59         ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.