From: Kevin O'Connor Date: Sun, 1 Jan 2012 00:42:21 +0000 (-0500) Subject: vgabios: Unify X_init() functions. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=seabios.git;a=commitdiff_plain;h=161d201affa5dd23a39a0de9a0743b857448c4b6 vgabios: Unify X_init() functions. 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 --- diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index c64919f..70ac449 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -83,11 +83,10 @@ 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; @@ -136,12 +135,11 @@ static u16 dispi_get_max_bpp(void) /* 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); @@ -153,8 +151,9 @@ bochsvga_init(u8 bus, u8 devfn) 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; diff --git a/vgasrc/bochsvga.h b/vgasrc/bochsvga.h index af60503..32554d5 100644 --- a/vgasrc/bochsvga.h +++ b/vgasrc/bochsvga.h @@ -52,7 +52,7 @@ static inline void dispi_write(u16 reg, u16 val) 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); diff --git a/vgasrc/clext.c b/vgasrc/clext.c index f468002..afab582 100644 --- a/vgasrc/clext.c +++ b/vgasrc/clext.c @@ -932,12 +932,16 @@ cirrus_vesa(struct bregs *regs) * 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 @@ -949,4 +953,6 @@ clext_init(void) // reset bitblt outw(0x0431, VGAREG_GRDC_ADDRESS); outw(0x0031, VGAREG_GRDC_ADDRESS); + + return 0; } diff --git a/vgasrc/clext.h b/vgasrc/clext.h index 537cbea..6fd0a58 100644 --- a/vgasrc/clext.h +++ b/vgasrc/clext.h @@ -4,6 +4,6 @@ #include "types.h" // u8 int clext_set_mode(int mode, int flags); -void clext_init(void); +int clext_init(void); #endif // clext.h diff --git a/vgasrc/geodelx.c b/vgasrc/geodelx.c index 4a5f873..8b03444 100644 --- a/vgasrc/geodelx.c +++ b/vgasrc/geodelx.c @@ -6,15 +6,12 @@ // // 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 @@ -342,7 +339,9 @@ static u8 lx_crtc_13[] VAR16 = { int geodelx_init(void) { - int ret; + int ret = stdvga_init(); + if (ret) + return ret; dprintf(1,"GEODELX_INIT\n"); diff --git a/vgasrc/stdvga.c b/vgasrc/stdvga.c index e55f8fa..c7331e4 100644 --- a/vgasrc/stdvga.c +++ b/vgasrc/stdvga.c @@ -649,7 +649,7 @@ stdvga_enable_video_addressing(u8 disable) outb(v | v2, VGAREG_WRITE_MISC_OUTPUT); } -void +int stdvga_init(void) { // switch to color mode and enable CPU access 480 lines @@ -657,4 +657,6 @@ stdvga_init(void) // more than 64k 3C4/04 outb(0x04, VGAREG_SEQU_ADDRESS); outb(0x02, VGAREG_SEQU_DATA); + + return 0; } diff --git a/vgasrc/stdvga.h b/vgasrc/stdvga.h index c260ae0..0685584 100644 --- a/vgasrc/stdvga.h +++ b/vgasrc/stdvga.h @@ -138,6 +138,6 @@ void stdvga_save_state(u16 seg, struct saveVideoHardware *info); 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 diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 9e8863a..7d558c1 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -1187,30 +1187,30 @@ init_bios_area(void) 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); diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h index c973d5f..176f71c 100644 --- a/vgasrc/vgabios.h +++ b/vgasrc/vgabios.h @@ -48,6 +48,7 @@ extern u8 vgafont14alt[]; 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; diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h index 57e41c3..d34b0e7 100644 --- a/vgasrc/vgahw.h +++ b/vgasrc/vgahw.h @@ -7,6 +7,7 @@ #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) @@ -16,4 +17,14 @@ static inline int vgahw_set_mode(int mode, int 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(); +} + #endif // vgahw.h