Use the same function signature for cirrus, bochsvga, geodelx, and
stdvga init code.
Have each hardware type explicitly call stdvga_init when needed.
To unify bochsvga_init() signature, store the device BDF passed into
the optionrom init code in a global variable (VgaBDF).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-static inline u32 pci_config_readl(u8 bus, u8 devfn, u16 addr)
+static inline u32 pci_config_readl(u16 bdf, u16 addr)
- u16 bdf = (bus << 16) | devfn;
/* Called only during POST */
int
/* Called only during POST */
int
-bochsvga_init(u8 bus, u8 devfn)
- 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);
/* 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);
SET_BDA(vbe_flag, 0x1);
dispi_write(VBE_DISPI_INDEX_ID, VBE_DISPI_ID5);
- 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;
else
lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
outw(val, VBE_DISPI_IOPORT_DATA);
}
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);
int bochsvga_enabled(void);
u16 bochsvga_total_mem(void);
int bochsvga_list_modes(u16 seg, u16 ptr);
* init
****************************************************************/
* init
****************************************************************/
+ int ret = stdvga_init();
+ if (ret)
+ return ret;
+
dprintf(1, "cirrus init\n");
if (! cirrus_check())
dprintf(1, "cirrus init\n");
if (! cirrus_check())
dprintf(1, "cirrus init 2\n");
// memory setup
dprintf(1, "cirrus init 2\n");
// memory setup
// reset bitblt
outw(0x0431, VGAREG_GRDC_ADDRESS);
outw(0x0031, VGAREG_GRDC_ADDRESS);
// reset bitblt
outw(0x0431, VGAREG_GRDC_ADDRESS);
outw(0x0031, VGAREG_GRDC_ADDRESS);
#include "types.h" // u8
int clext_set_mode(int mode, int flags);
#include "types.h" // u8
int clext_set_mode(int mode, int flags);
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
+#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 "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
#include "stdvga.h" // VGAREG_VGA_CRTC_ADDRESS
+ int ret = stdvga_init();
+ if (ret)
+ return ret;
dprintf(1,"GEODELX_INIT\n");
dprintf(1,"GEODELX_INIT\n");
outb(v | v2, VGAREG_WRITE_MISC_OUTPUT);
}
outb(v | v2, VGAREG_WRITE_MISC_OUTPUT);
}
stdvga_init(void)
{
// switch to color mode and enable CPU access 480 lines
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);
// more than 64k 3C4/04
outb(0x04, VGAREG_SEQU_ADDRESS);
outb(0x02, VGAREG_SEQU_DATA);
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_restore_state(u16 seg, struct saveVideoHardware *info);
int stdvga_set_mode(int mode, int flags);
void stdvga_enable_video_addressing(u8 disable);
SET_BDA(video_msr, 0x09);
}
SET_BDA(video_msr, 0x09);
}
void VISIBLE16
vga_post(struct bregs *regs)
{
debug_enter(regs, DEBUG_VGA_POST);
void VISIBLE16
vga_post(struct bregs *regs)
{
debug_enter(regs, DEBUG_VGA_POST);
+ 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;
+ }
- bochsvga_init(regs->ah, regs->al);
extern void entry_10(void);
SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10));
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
// XXX - clear screen and display info
// Fixup checksum
extern u8 _rom_header_size, _rom_header_checksum;
SET_VGA(_rom_header_checksum, 0);
// Fixup checksum
extern u8 _rom_header_size, _rom_header_checksum;
SET_VGA(_rom_header_checksum, 0);
extern u8 vgafont16alt[];
// vgabios.c
extern u8 vgafont16alt[];
// vgabios.c
#define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
struct carattr {
u8 car, attr, use_attr;
#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 "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)
static inline int vgahw_set_mode(int mode, int flags) {
if (CONFIG_VGA_CIRRUS)
return stdvga_set_mode(mode, flags);
}
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();
+}
+