diff --git a/stage23/drivers/gop.c b/stage23/drivers/gop.c index 1acaca9f..c81156c8 100644 --- a/stage23/drivers/gop.c +++ b/stage23/drivers/gop.c @@ -3,17 +3,50 @@ #include #include #include +#include + +// Most of this code taken from https://wiki.osdev.org/GOP bool init_gop(struct fb_info *ret, uint16_t target_width, uint16_t target_height, uint16_t target_bpp) { (void)ret; (void)target_width; (void)target_height; (void)target_bpp; + EFI_STATUS status; + EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; uefi_call_wrapper(gBS->LocateProtocol, 3, &gop_guid, NULL, (void **)&gop); - for (;;); + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *mode_info; + UINTN mode_info_size, native_mode, modes_count; + + status = uefi_call_wrapper(gop->QueryMode, 4, gop, + gop->Mode == NULL ? 0 : gop->Mode->Mode, + &mode_info_size, &mode_info); + + if (status == EFI_NOT_STARTED) { + status = uefi_call_wrapper(gop->SetMode, 2, gop, 0); + } + + if (EFI_ERROR(status)) { + panic("GOP initialisation failed"); + } + + ret->memory_model = 0x06; + ret->framebuffer_addr = gop->Mode->FrameBufferBase; + ret->framebuffer_pitch = (gop->Mode->Info->PixelsPerScanLine * 4); + ret->framebuffer_width = gop->Mode->Info->HorizontalResolution; + ret->framebuffer_height = gop->Mode->Info->VerticalResolution; + ret->framebuffer_bpp = 32; + ret->red_mask_size = 8; + ret->red_mask_shift = 16; + ret->green_mask_size = 8; + ret->green_mask_shift = 8; + ret->blue_mask_size = 8; + ret->blue_mask_shift = 0; + + return true; } #endif diff --git a/stage23/lib/gterm.c b/stage23/lib/gterm.c index c5798fae..c6c2d266 100644 --- a/stage23/lib/gterm.c +++ b/stage23/lib/gterm.c @@ -24,7 +24,7 @@ static uint16_t gterm_bpp; extern symbol _binary_font_bin_start; -static uint8_t *vga_font = (void *)_binary_font_bin_start; +static uint8_t *vga_font; static uint32_t ansi_colours[8]; @@ -372,6 +372,8 @@ bool gterm_init(int *_rows, int *_cols, uint32_t *_colours, int _margin, int _ma mtrr_set_range((uint64_t)(size_t)gterm_framebuffer, (uint64_t)gterm_pitch * gterm_height, MTRR_MEMORY_TYPE_WC); + vga_font = (void *)_binary_font_bin_start; + char *menu_font = config_get_value(NULL, 0, "MENU_FONT"); if (menu_font != NULL) { struct file_handle f; diff --git a/test/limine.cfg b/test/limine.cfg index 28804a14..57f4e628 100644 --- a/test/limine.cfg +++ b/test/limine.cfg @@ -1,9 +1,8 @@ DEFAULT_ENTRY=2 -TIMEOUT=3 +TIMEOUT=no GRAPHICS=yes MENU_RESOLUTION=1024x768 MENU_FONT=boot:///boot/font.bin -E9_OUTPUT=yes THEME_COLOURS=60000000;aa0000;00aaff;aa5500;0000aa;aa00aa;9076de;aaaaaa THEME_MARGIN=64