Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/loader/framebuffer.c
Show All 34 Lines | |||||
#include <stand.h> | #include <stand.h> | ||||
#include <efi.h> | #include <efi.h> | ||||
#include <efilib.h> | #include <efilib.h> | ||||
#include <efiuga.h> | #include <efiuga.h> | ||||
#include <efipciio.h> | #include <efipciio.h> | ||||
#include <machine/metadata.h> | #include <machine/metadata.h> | ||||
#include "bootstrap.h" | |||||
#include "framebuffer.h" | #include "framebuffer.h" | ||||
static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; | EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; | ||||
static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; | static EFI_GUID pciio_guid = EFI_PCI_IO_PROTOCOL_GUID; | ||||
static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; | static EFI_GUID uga_guid = EFI_UGA_DRAW_PROTOCOL_GUID; | ||||
static struct named_resolution { | static struct named_resolution { | ||||
const char *name; | const char *name; | ||||
const char *alias; | const char *alias; | ||||
unsigned int width; | unsigned int width; | ||||
unsigned int height; | unsigned int height; | ||||
▲ Show 20 Lines • Show All 527 Lines • ▼ Show 20 Lines | gop_autoresize(EFI_GRAPHICS_OUTPUT *gop) | ||||
if (maxdim != 0) { | if (maxdim != 0) { | ||||
status = gop->SetMode(gop, best_mode); | status = gop->SetMode(gop, best_mode); | ||||
if (EFI_ERROR(status)) { | if (EFI_ERROR(status)) { | ||||
snprintf(command_errbuf, sizeof(command_errbuf), | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"gop_autoresize: Unable to set mode to %u (error=%lu)", | "gop_autoresize: Unable to set mode to %u (error=%lu)", | ||||
mode, EFI_ERROR_CODE(status)); | mode, EFI_ERROR_CODE(status)); | ||||
return (CMD_ERROR); | return (CMD_ERROR); | ||||
} | } | ||||
(void) efi_cons_update_mode(); | (void) cons_update_mode(true); | ||||
} | } | ||||
return (CMD_OK); | return (CMD_OK); | ||||
} | } | ||||
static int | static int | ||||
text_autoresize() | text_autoresize() | ||||
{ | { | ||||
SIMPLE_TEXT_OUTPUT_INTERFACE *conout; | SIMPLE_TEXT_OUTPUT_INTERFACE *conout; | ||||
EFI_STATUS status; | EFI_STATUS status; | ||||
UINTN i, max_dim, best_mode, cols, rows; | UINTN i, max_dim, best_mode, cols, rows; | ||||
conout = ST->ConOut; | conout = ST->ConOut; | ||||
max_dim = best_mode = 0; | max_dim = best_mode = 0; | ||||
for (i = 0; i < conout->Mode->MaxMode; i++) { | for (i = 0; i < conout->Mode->MaxMode; i++) { | ||||
status = conout->QueryMode(conout, i, &cols, &rows); | status = conout->QueryMode(conout, i, &cols, &rows); | ||||
if (EFI_ERROR(status)) | if (EFI_ERROR(status)) | ||||
continue; | continue; | ||||
if (cols * rows > max_dim) { | if (cols * rows > max_dim) { | ||||
max_dim = cols * rows; | max_dim = cols * rows; | ||||
best_mode = i; | best_mode = i; | ||||
} | } | ||||
} | } | ||||
if (max_dim > 0) | if (max_dim > 0) | ||||
conout->SetMode(conout, best_mode); | conout->SetMode(conout, best_mode); | ||||
(void) efi_cons_update_mode(); | (void) cons_update_mode(true); | ||||
return (CMD_OK); | return (CMD_OK); | ||||
} | } | ||||
static int | static int | ||||
uga_autoresize(EFI_UGA_DRAW_PROTOCOL *uga) | uga_autoresize(EFI_UGA_DRAW_PROTOCOL *uga) | ||||
{ | { | ||||
return (text_autoresize()); | return (text_autoresize()); | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | if (!strcmp(argv[1], "set")) { | ||||
} | } | ||||
status = gop->SetMode(gop, mode); | status = gop->SetMode(gop, mode); | ||||
if (EFI_ERROR(status)) { | if (EFI_ERROR(status)) { | ||||
snprintf(command_errbuf, sizeof(command_errbuf), | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"%s: Unable to set mode to %u (error=%lu)", | "%s: Unable to set mode to %u (error=%lu)", | ||||
argv[0], mode, EFI_ERROR_CODE(status)); | argv[0], mode, EFI_ERROR_CODE(status)); | ||||
return (CMD_ERROR); | return (CMD_ERROR); | ||||
} | } | ||||
(void) efi_cons_update_mode(); | (void) cons_update_mode(true); | ||||
} else if (!strcmp(argv[1], "get")) { | } else if (strcmp(argv[1], "off") == 0) { | ||||
(void) cons_update_mode(false); | |||||
} else if (strcmp(argv[1], "get") == 0) { | |||||
if (argc != 2) | if (argc != 2) | ||||
goto usage; | goto usage; | ||||
efifb_from_gop(&efifb, gop->Mode, gop->Mode->Info); | efifb_from_gop(&efifb, gop->Mode, gop->Mode->Info); | ||||
print_efifb(gop->Mode->Mode, &efifb, 1); | print_efifb(gop->Mode->Mode, &efifb, 1); | ||||
printf("\n"); | printf("\n"); | ||||
} else if (!strcmp(argv[1], "list")) { | } else if (!strcmp(argv[1], "list")) { | ||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; | EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; | ||||
UINTN infosz; | UINTN infosz; | ||||
Show All 11 Lines | for (mode = 0; mode < gop->Mode->MaxMode; mode++) { | ||||
break; | break; | ||||
} | } | ||||
pager_close(); | pager_close(); | ||||
} | } | ||||
return (CMD_OK); | return (CMD_OK); | ||||
usage: | usage: | ||||
snprintf(command_errbuf, sizeof(command_errbuf), | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"usage: %s [list | get | set <mode>]", argv[0]); | "usage: %s [list | get | set <mode> | off]", argv[0]); | ||||
return (CMD_ERROR); | return (CMD_ERROR); | ||||
} | } | ||||
COMMAND_SET(uga, "uga", "universal graphics adapter", command_uga); | COMMAND_SET(uga, "uga", "universal graphics adapter", command_uga); | ||||
static int | static int | ||||
command_uga(int argc, char *argv[]) | command_uga(int argc, char *argv[]) | ||||
{ | { | ||||
Show All 29 Lines |