mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
Discover and set the best video mode supported by the UEFI graphics driver
This commit is contained in:
5
Makefile
5
Makefile
@@ -144,6 +144,11 @@ $(BUILD_D)/fs.img: $(BUILD_D)/kernel.efi
|
|||||||
rm $(TEMPFILE)
|
rm $(TEMPFILE)
|
||||||
mv $@.tmp $@
|
mv $@.tmp $@
|
||||||
|
|
||||||
|
$(BUILD_D)/fs.iso: $(BUILD_D)/fs.img
|
||||||
|
mkdir -p $(BUILD_D)/iso
|
||||||
|
cp $< $(BUILD_D)/iso/
|
||||||
|
xorriso -as mkisofs -R -f -e fs.img -no-emul-boot -o $@ $(BUILD_D)/iso
|
||||||
|
|
||||||
qemu: $(BUILD_D)/fs.img
|
qemu: $(BUILD_D)/fs.img
|
||||||
"$(QEMU)" $(QEMUOPTS)
|
"$(QEMU)" $(QEMUOPTS)
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,46 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
|
|||||||
|
|
||||||
InitializeLib(ImageHandle, SystemTable);
|
InitializeLib(ImageHandle, SystemTable);
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
Print(L"Popcorn OS " GIT_VERSION L" booting...\n");
|
||||||
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
|
|
||||||
status = ST->ConOut->OutputString(ST->ConOut, L"Hello from UEFI\n\r");
|
Print(L"Setting console display mode... ");
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
check_status(status, L"OutputString");
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *gfx_out_proto;
|
||||||
|
EFI_GUID gfx_out_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||||
|
status = SystemTable->BootServices->LocateProtocol(&gfx_out_guid, NULL, (void**)&gfx_out_proto);
|
||||||
|
check_status(status, "LocateProtocol gfx");
|
||||||
|
|
||||||
|
const uint32_t modes = gfx_out_proto->Mode->MaxMode;
|
||||||
|
uint32_t res =
|
||||||
|
gfx_out_proto->Mode->Info->HorizontalResolution *
|
||||||
|
gfx_out_proto->Mode->Info->VerticalResolution;
|
||||||
|
uint32_t best = (uint32_t)-1;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < modes; ++i) {
|
||||||
|
UINTN size = 0;
|
||||||
|
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = NULL;
|
||||||
|
status = gfx_out_proto->QueryMode(gfx_out_proto, i, &size, &info);
|
||||||
|
check_status(status, "QueryMode");
|
||||||
|
|
||||||
|
const uint32_t new_res =
|
||||||
|
info->HorizontalResolution *
|
||||||
|
info->VerticalResolution;
|
||||||
|
|
||||||
|
if (new_res > res) {
|
||||||
|
best = i;
|
||||||
|
res = new_res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (best != (uint32_t)-1) {
|
||||||
|
status = gfx_out_proto->SetMode(gfx_out_proto, best);
|
||||||
|
check_status(status, "SetMode");
|
||||||
|
Print(L"*");
|
||||||
|
}
|
||||||
|
Print(L"%ux%u\n",
|
||||||
|
gfx_out_proto->Mode->Info->HorizontalResolution,
|
||||||
|
gfx_out_proto->Mode->Info->VerticalResolution);
|
||||||
|
|
||||||
|
|
||||||
Print(L" SystemTable: %x\n", SystemTable);
|
Print(L" SystemTable: %x\n", SystemTable);
|
||||||
if (SystemTable)
|
if (SystemTable)
|
||||||
|
|||||||
Reference in New Issue
Block a user