-#include "vgatables.h"
-#include "vbe.h"
-#include "bochsvga.h"
-#include "util.h"
-#include "config.h" // CONFIG_
+#include "vgabios.h" // struct vbe_modeinfo
+#include "vbe.h" // VBE_MODE_VESA_DEFINED
+#include "bochsvga.h" // bochsvga_set_mode
+#include "util.h" // dprintf
+#include "config.h" // CONFIG_*
#include "biosvar.h" // SET_BDA
+#include "stdvga.h" // VGAREG_SEQU_ADDRESS
static struct mode
{
u32 pci_lfb_addr VAR16;
-static inline u32 pci_config_readl(u8 bus, u8 devfn, u16 addr)
+static inline u32 pci_config_readl(u16 bdf, u16 addr)
{
int status;
u32 val;
- u16 bdf = (bus << 16) | devfn;
addr &= ~3;
/* Called only during POST */
int
-bochsvga_init(u8 bus, u8 devfn)
+bochsvga_init(void)
{
- u32 lfb_addr;
-
- if (!CONFIG_VGA_BOCHS)
- return -1;
+ int ret = stdvga_init();
+ if (ret)
+ return ret;
/* Sanity checks */
dispi_write(VBE_DISPI_INDEX_ID, VBE_DISPI_ID0);
SET_BDA(vbe_flag, 0x1);
dispi_write(VBE_DISPI_INDEX_ID, VBE_DISPI_ID5);
+ u32 lfb_addr;
if (CONFIG_VGA_PCI)
- lfb_addr = pci_config_readl(bus, devfn, 0x10) & ~0xf;
+ lfb_addr = pci_config_readl(GET_GLOBAL(VgaBDF), 0x10) & ~0xf;
else
lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
dispi_write(VBE_DISPI_INDEX_ENABLE, flags);
}
-void
-bochsvga_set_mode(u16 mode, struct vbe_modeinfo *info)
+int
+bochsvga_set_mode(int mode, int flags)
{
+ if (!(mode & VBE_MODE_VESA_DEFINED)) {
+ dprintf(1, "set VGA mode %x\n", mode);
+
+ bochsvga_hires_enable(0);
+ return stdvga_set_mode(mode, flags);
+ }
+
+ struct vbe_modeinfo modeinfo, *info = &modeinfo;
+ int ret = bochsvga_mode_info(mode, &modeinfo);
+ if (ret) {
+ dprintf(1, "VBE mode %x not found\n", mode);
+ return VBE_RETURN_STATUS_FAILED;
+ }
+ bochsvga_hires_enable(1);
+
if (info->depth == 4)
- vga_set_mode(0x6a, 0);
+ stdvga_set_mode(0x6a, 0);
if (info->depth == 8)
// XXX load_dac_palette(3);
;
}
SET_BDA(vbe_mode, mode);
+
+ if (flags & MF_LINEARFB) {
+ /* Linear frame buffer */
+ /* XXX: ??? */
+ }
+ if (!(mode & MF_NOCLEARMEM)) {
+ bochsvga_clear_scr();
+ }
+
+ return 0;
}
void