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;
outw(val, VBE_DISPI_IOPORT_DATA);
}
-int bochsvga_init(u8 bus, u8 devfn);
+int bochsvga_init(void);
int bochsvga_enabled(void);
u16 bochsvga_total_mem(void);
int bochsvga_list_modes(u16 seg, u16 ptr);
* init
****************************************************************/
-void
+int
clext_init(void)
{
+ int ret = stdvga_init();
+ if (ret)
+ return ret;
+
dprintf(1, "cirrus init\n");
if (! cirrus_check())
- return;
+ return -1;
dprintf(1, "cirrus init 2\n");
// memory setup
// reset bitblt
outw(0x0431, VGAREG_GRDC_ADDRESS);
outw(0x0031, VGAREG_GRDC_ADDRESS);
+
+ return 0;
}
#include "types.h" // u8
int clext_set_mode(int mode, int flags);
-void clext_init(void);
+int clext_init(void);
#endif // clext.h
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "geodelx.h"
+#include "geodelx.h" // geodelx_init
#include "ioport.h" // outb
#include "farptr.h" // SET_FARVAR
#include "biosvar.h" // GET_BDA
#include "vgabios.h" // VGAREG_*
#include "util.h" // memset
-#include "config.h"
-#include "types.h"
-#include "bregs.h"
#include "stdvga.h" // VGAREG_VGA_CRTC_ADDRESS
int geodelx_init(void)
{
- int ret;
+ int ret = stdvga_init();
+ if (ret)
+ return ret;
dprintf(1,"GEODELX_INIT\n");
outb(v | v2, VGAREG_WRITE_MISC_OUTPUT);
}
-void
+int
stdvga_init(void)
{
// switch to color mode and enable CPU access 480 lines
// more than 64k 3C4/04
outb(0x04, VGAREG_SEQU_ADDRESS);
outb(0x02, VGAREG_SEQU_DATA);
+
+ return 0;
}
void stdvga_restore_state(u16 seg, struct saveVideoHardware *info);
int stdvga_set_mode(int mode, int flags);
void stdvga_enable_video_addressing(u8 disable);
-void stdvga_init(void);
+int stdvga_init(void);
#endif // stdvga.h
SET_BDA(video_msr, 0x09);
}
+u16 VgaBDF VAR16;
+
void VISIBLE16
vga_post(struct bregs *regs)
{
debug_enter(regs, DEBUG_VGA_POST);
- stdvga_init();
+ SET_VGA(VgaBDF, regs->ax);
- if (CONFIG_VGA_GEODELX)
- geodelx_init();
+ int ret = vgahw_init();
+ if (ret) {
+ dprintf(1, "Failed to initialize VGA hardware. Exiting.\n");
+ return;
+ }
init_bios_area();
- bochsvga_init(regs->ah, regs->al);
+ build_video_param();
extern void entry_10(void);
SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10));
- if (CONFIG_VGA_CIRRUS)
- clext_init();
-
// XXX - clear screen and display info
- build_video_param();
-
// Fixup checksum
extern u8 _rom_header_size, _rom_header_checksum;
SET_VGA(_rom_header_checksum, 0);
extern u8 vgafont16alt[];
// vgabios.c
+extern u16 VgaBDF;
#define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
struct carattr {
u8 car, attr, use_attr;
#include "clext.h" // clext_set_mode
#include "bochsvga.h" // bochsvga_set_mode
#include "stdvga.h" // stdvga_set_mode
+#include "geodelx.h" // geodelx_init
static inline int vgahw_set_mode(int mode, int flags) {
if (CONFIG_VGA_CIRRUS)
return stdvga_set_mode(mode, flags);
}
+static inline int vgahw_init(void) {
+ if (CONFIG_VGA_CIRRUS)
+ return clext_init();
+ if (CONFIG_VGA_BOCHS)
+ return bochsvga_init();
+ if (CONFIG_VGA_GEODELX)
+ return geodelx_init();
+ return stdvga_init();
+}
+
#endif // vgahw.h