* [PATCH v2] efi: Set text-mode console resolution to maximum supported
@ 2022-05-06 12:06 Glenn Washburn
2022-05-06 13:01 ` Gerd Hoffmann
0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2022-05-06 12:06 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>
---
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 *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, 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)
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] efi: Set text-mode console resolution to maximum supported
2022-05-06 12:06 [PATCH v2] efi: Set text-mode console resolution to maximum supported Glenn Washburn
@ 2022-05-06 13:01 ` Gerd Hoffmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2022-05-06 13:01 UTC (permalink / raw)
To: The development of GNU GRUB; +Cc: Daniel Kiper, Glenn Washburn
Hi,
> v2: Fix to query each mode instead of just the current mode
Oh, right, that is another one ...
> + /* 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))
... but I meant that this condition always evaluates to true because you
never update columns_max and rows_max ...
> + mode_max = i;
... so mode_max is o->mode->max_mode - 1 at this point no matter what.
take care,
Gerd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-06 13:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-06 12:06 [PATCH v2] efi: Set text-mode console resolution to maximum supported Glenn Washburn
2022-05-06 13:01 ` 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.