// Simple framebuffer vgabios for use with coreboot native vga init. // // Copyright (C) 2014 Kevin O'Connor // // This file may be distributed under the terms of the GNU LGPLv3 license. #include "biosvar.h" // GET_BDA #include "cbvga.h" // cbvga_setup #include "output.h" // dprintf #include "stdvga.h" // SEG_CTEXT #include "string.h" // memset16_far #include "util.h" // find_cb_table #include "vgabios.h" // VGAREG_* static int CBmode VAR16; static struct vgamode_s CBmodeinfo VAR16; static u32 CBlinelength VAR16; struct vgamode_s *cbvga_find_mode(int mode) { if (mode == GET_GLOBAL(CBmode)) return &CBmodeinfo; return NULL; } void cbvga_list_modes(u16 seg, u16 *dest, u16 *last) { if (destphysical_address); u8 bpp = GET_FARVAR(0, cbfb->bits_per_pixel); u32 xlines = GET_FARVAR(0, cbfb->x_resolution); u32 ylines = GET_FARVAR(0, cbfb->y_resolution); u32 linelength = GET_FARVAR(0, cbfb->bytes_per_line); dprintf(1, "Found FB @ %llx %dx%d with %d bpp (%d stride)\n" , addr, xlines, ylines, bpp, linelength); if (!addr || addr > 0xffffffff || (bpp != 15 && bpp != 16 && bpp != 24 && bpp != 32)) { dprintf(1, "Unable to use FB\n"); return -1; } SET_VGA(CBmode, 0x140); SET_VGA(VBE_framebuffer, addr); SET_VGA(VBE_total_memory, linelength * ylines); SET_VGA(CBlinelength, linelength); SET_VGA(CBmodeinfo.memmodel, MM_DIRECT); SET_VGA(CBmodeinfo.width, xlines); SET_VGA(CBmodeinfo.height, ylines); SET_VGA(CBmodeinfo.depth, bpp); SET_VGA(CBmodeinfo.cwidth, 8); SET_VGA(CBmodeinfo.cheight, 16); // Setup BDA and clear screen. vga_set_mode(GET_GLOBAL(CBmode), 0); return 0; }