efi: Set text-mode console resolution to maximum supported
PATCH v2 1/1 efi: Set text-mode console resolution to maximum supported
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.
---
v2: Fix to query each mode instead of just the current mode
--- grub-core/term/efi/console.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
grub-core/term/efi/console.c +14 -0
@@ -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 )
Signature · 1 line
2.34.1
Hi,
Quoted 1 line
v2: Fix to query each mode instead of just the current mode
Oh, right, that is another one ...
grub-core/term/efi/console.c grub_prepare_for_text_output (struct grub_term_output *term) · line 167
Quoted 6 lines
grub-core/term/efi/console.c +6
-0+/* 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 ...
Quoted 1 line
+
mode_max= i;
... so mode_max is o->mode->max_mode - 1 at this point no matter what.
take care,
Gerd