Page MenuHomeFreeBSD

D14788.diff
No OneTemporary

D14788.diff

Index: head/stand/efi/boot1/boot1.c
===================================================================
--- head/stand/efi/boot1/boot1.c
+++ head/stand/efi/boot1/boot1.c
@@ -391,7 +391,7 @@
EFI_STATUS status;
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL;
SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL;
- UINTN i, max_dim, best_mode, cols, rows, hsize, nhandles;
+ UINTN i, hsize, nhandles;
CHAR16 *text;
UINT16 boot_current;
size_t sz;
@@ -410,22 +410,11 @@
(void)ConsoleControl->SetMode(ConsoleControl,
EfiConsoleControlScreenText);
/*
- * Reset the console and find the best text mode.
+ * Reset the console enable the cursor. Later we'll choose a better
+ * console size through GOP/UGA.
*/
conout = ST->ConOut;
conout->Reset(conout, TRUE);
- 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);
conout->EnableCursor(conout, TRUE);
conout->ClearScreen(conout);
Index: head/stand/efi/loader/framebuffer.c
===================================================================
--- head/stand/efi/loader/framebuffer.c
+++ head/stand/efi/loader/framebuffer.c
@@ -462,6 +462,72 @@
}
}
+static int
+gop_autoresize(EFI_GRAPHICS_OUTPUT *gop)
+{
+ struct efi_fb efifb;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
+ EFI_STATUS status;
+ UINTN infosz;
+ UINT32 best_mode, currdim, maxdim, mode;
+
+ best_mode = maxdim = 0;
+ for (mode = 0; mode < gop->Mode->MaxMode; mode++) {
+ status = gop->QueryMode(gop, mode, &infosz, &info);
+ if (EFI_ERROR(status))
+ continue;
+ efifb_from_gop(&efifb, gop->Mode, info);
+ currdim = info->HorizontalResolution * info->VerticalResolution;
+ /* XXX TODO: Allow tunable or something for max resolution */
+ if (currdim > maxdim) {
+ maxdim = currdim;
+ best_mode = mode;
+ }
+ }
+
+ status = gop->SetMode(gop, best_mode);
+ if (EFI_ERROR(status)) {
+ snprintf(command_errbuf, sizeof(command_errbuf),
+ "gop_autoresize: Unable to set mode to %u (error=%lu)",
+ mode, EFI_ERROR_CODE(status));
+ return (CMD_ERROR);
+ }
+ return (CMD_OK);
+}
+
+static int
+uga_autoresize(EFI_UGA_DRAW_PROTOCOL *gop)
+{
+
+ return (CMD_OK);
+}
+
+COMMAND_SET(efi_autoresize, "efi-autoresizecons", "EFI Auto-resize Console", command_autoresize);
+
+static int
+command_autoresize(int argc, char *argv[])
+{
+ EFI_GRAPHICS_OUTPUT *gop;
+ EFI_UGA_DRAW_PROTOCOL *uga;
+ EFI_STATUS status;
+ u_int mode;
+
+ gop = NULL;
+ uga = NULL;
+ status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop);
+ if (EFI_ERROR(status) == 0)
+ return (gop_autoresize(gop));
+
+ status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga);
+ if (EFI_ERROR(status) == 0)
+ return (uga_autoresize(uga));
+
+ snprintf(command_errbuf, sizeof(command_errbuf),
+ "%s: Neither Graphics Output Protocol nor Universal Graphics Adapter present",
+ argv[0]);
+ return (CMD_ERROR);
+}
+
COMMAND_SET(gop, "gop", "graphics output protocol", command_gop);
static int
Index: head/stand/lua/core.lua
===================================================================
--- head/stand/lua/core.lua
+++ head/stand/lua/core.lua
@@ -274,6 +274,12 @@
return single_user ~= nil and single_user:lower() == "yes"
end
+function core.isUEFIBoot()
+ local efiver = loader.getenv("efi-version")
+
+ return efiver ~= nil
+end
+
function core.isZFSBoot()
local c = loader.getenv("currdev")
Index: head/stand/lua/loader.lua
===================================================================
--- head/stand/lua/loader.lua
+++ head/stand/lua/loader.lua
@@ -50,6 +50,9 @@
end
config.load()
+if core.isUEFIBoot() then
+ loader.perform("efi-autoresizecons")
+end
-- Our console may have been setup for a different color scheme before we get
-- here, so make sure we set the default.
if color.isEnabled() then

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 20, 7:10 PM (20 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31858879
Default Alt Text
D14788.diff (3 KB)

Event Timeline