Skip to content

Instantly share code, notes, and snippets.

@hdante
Created November 26, 2017 06:06
Show Gist options
  • Save hdante/df79dab520717c9d92dcaf3008841a2f to your computer and use it in GitHub Desktop.
Save hdante/df79dab520717c9d92dcaf3008841a2f to your computer and use it in GitHub Desktop.
systemd-boot small font HiDPI workaround
#include <efi.h>
#include <efilib.h>
#define SHELL_INTERFACE_PROTOCOL \
{ \
0x47c7b223, 0xc42a, 0x11d2, { 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, \
0x3b } \
}
typedef struct _EFI_SHELL_ARG_INFO {
UINT32 Attributes;
} EFI_SHELL_ARG_INFO;
typedef struct _EFI_SHELL_INTERFACE {
//
// Handle back to original image handle & image info
//
EFI_HANDLE ImageHandle;
EFI_LOADED_IMAGE_PROTOCOL *Info;
//
// Parsed arg list
//
CHAR16 **Argv;
UINTN Argc;
//
// Storage for file redirection args after parsing
//
CHAR16 **RedirArgv;
UINTN RedirArgc;
//
// A file style handle for console io
//
EFI_FILE_HANDLE StdIn;
EFI_FILE_HANDLE StdOut;
EFI_FILE_HANDLE StdErr;
EFI_SHELL_ARG_INFO *ArgInfo;
BOOLEAN EchoOn;
} EFI_SHELL_INTERFACE;
EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
EFI_STATUS Status;
EFI_INPUT_KEY Key;
InitializeLib(ImageHandle, SystemTable);
/* Change screen to mode 2 */
// uefi_call_wrapper(SystemTable->ConOut->SetMode, 2, SystemTable->ConOut,
// (UINTN)2);
Print(L"Hello, world!\n");
EFI_SHELL_INTERFACE Interface = {ImageHandle};
EFI_GUID ShellInterfaceProtocol = SHELL_INTERFACE_PROTOCOL;
Print(L"Installing shell interface protocol.\n");
/* This call switches the screen resolution in my machine
* (Toshiba P50t), as if calling ST->ConOut->SetMode(2) (see commented
* code above). The default mode 0 is 80x25 and the screen resolution is
* 4k (visible area is 640x475 in the middle of the screen, text is
* very small). Mode 2 is 100x31 filling the whole display area, so the
* screen resolution is 800x600, making the text much larger. */
Status = LibInstallProtocolInterfaces(&ImageHandle,
&ShellInterfaceProtocol, &Interface, NULL);
if (Status != EFI_SUCCESS)
Print(L"Install error.\n");
else
Print(L"Installed.\n");
Print(L"Press any key to continue.");
Pause();
uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key);
Print(L"\n");
return EFI_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment