Let there be GOP

This commit is contained in:
mintsuki 2021-03-04 10:13:02 +01:00
parent c478e57adb
commit f26b6045a7
3 changed files with 38 additions and 4 deletions

View File

@ -3,17 +3,50 @@
#include <efi.h>
#include <lib/blib.h>
#include <drivers/gop.h>
#include <lib/print.h>
// 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

View File

@ -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;

View File

@ -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