efi loader: Choose a console mode instead if hw.vga.textmode is set

Not all systems use efifb; pull hw.vga.textmode and choose a good console
mode instead if it's set to something non-zero. This is basically a revival
of the code that used to live in boot1, but instead rebased onto this
different way of doing mode selection in loader.efi.

Interestingly enough, the regression that was previously introduced where
GOP would not reflect the console setting does not seem to exist when
console mode selection is done here. I've not done any investigation as to
why this is the case. Nevertheless, boot1.efi is still not the best place to
do mode selection.
This commit is contained in:
Kyle Evans 2018-03-24 01:53:43 +00:00
parent d57241d2e7
commit 1c1692795a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=331474

View File

@ -587,6 +587,29 @@ gop_autoresize(EFI_GRAPHICS_OUTPUT *gop)
return (CMD_OK);
}
static int
text_autoresize()
{
SIMPLE_TEXT_OUTPUT_INTERFACE *conout;
EFI_STATUS status;
UINTN i, max_dim, best_mode, cols, rows;
conout = ST->ConOut;
max_dim = best_mode = 0;
for (i = 0; i < conout->Mode->MaxMode; i++) {
status = conout->QueryMode(conout, i, &cols, &rows);
if (EFI_ERROR(status))
continue;
if (cols * rows > max_dim) {
max_dim = cols * rows;
best_mode = i;
}
}
if (max_dim > 0)
conout->SetMode(conout, best_mode);
return (CMD_OK);
}
static int
uga_autoresize(EFI_UGA_DRAW_PROTOCOL *gop)
{
@ -601,9 +624,15 @@ command_autoresize(int argc, char *argv[])
{
EFI_GRAPHICS_OUTPUT *gop;
EFI_UGA_DRAW_PROTOCOL *uga;
char *textmode;
EFI_STATUS status;
u_int mode;
textmode = getenv("hw.vga.textmode");
/* If it's set and non-zero, we'll select a console mode instead */
if (textmode != NULL && strcmp(textmode, "0") != 0)
return (text_autoresize());
gop = NULL;
uga = NULL;
status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop);