On Mon, Jan 16, 2012 at 06:56:42PM -0500, Kevin O'Connor wrote:
On Tue, Jan 17, 2012 at 12:06:54AM +0100, Nils wrote:
Second i used vgaroms/vgabios.bin as the vgabios name. The vgabios gets run but i get no display output and SeaBIOS reboots over and over. (see attachment v475-2.log)
Yeah - it will break if it gets run via "vgaroms/" - I'll change the vgabios code to check for this.
The patch below (on top of previous patches) should catch this case. With this, it should be possible to run the geode rom even if it is set in "vgaroms/".
-Kevin
commit 8cf8f8e6ce971b16ee25309df7ebf32f7a04dc14 Author: Kevin O'Connor kevin@koconnor.net Date: Mon Jan 16 19:05:27 2012 -0500
vgabios: Check that the PCI BDF passed in is valid before using.
Signed-off-by: Kevin O'Connor kevin@koconnor.net
diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index 82629b9..cbd0b41 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -123,12 +123,11 @@ bochsvga_init(void)
dispi_write(VBE_DISPI_INDEX_ID, VBE_DISPI_ID5);
- u32 lfb_addr; - if (CONFIG_VGA_PCI) - lfb_addr = (pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_0) + u32 lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS; + int bdf = GET_GLOBAL(VgaBDF); + if (CONFIG_VGA_PCI && bdf >= 0) + lfb_addr = (pci_config_readl(bdf, PCI_BASE_ADDRESS_0) & PCI_BASE_ADDRESS_MEM_MASK); - else - lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
SET_VGA(VBE_framebuffer, lfb_addr); u16 totalmem = dispi_read(VBE_DISPI_INDEX_VIDEO_MEMORY_64K); diff --git a/vgasrc/clext.c b/vgasrc/clext.c index f08294a..5468db3 100644 --- a/vgasrc/clext.c +++ b/vgasrc/clext.c @@ -737,8 +737,9 @@ clext_init(void) dprintf(1, "cirrus init 2\n");
u32 lfb_addr = 0; - if (CONFIG_VGA_PCI) - lfb_addr = (pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_0) + int bdf = GET_GLOBAL(VgaBDF); + if (CONFIG_VGA_PCI && bdf >= 0) + lfb_addr = (pci_config_readl(bdf, PCI_BASE_ADDRESS_0) & PCI_BASE_ADDRESS_MEM_MASK); SET_VGA(VBE_framebuffer, lfb_addr); u16 totalmem = cirrus_get_memsize(); diff --git a/vgasrc/geodevga.c b/vgasrc/geodevga.c index ce754a5..5c6caf0 100644 --- a/vgasrc/geodevga.c +++ b/vgasrc/geodevga.c @@ -363,6 +363,9 @@ int geodevga_init(void) stdvga_override_crtc(i, crtc); }
+ if (GET_GLOBAL(VgaBDF) < 0) + // Device should be at 00:01.1 + SET_VGA(VgaBDF, pci_to_bdf(0, 1, 1)); ret |= vp_setup(); ret |= dc_setup();
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 449f3c4..5ce7c0c 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -20,6 +20,8 @@ #include "stdvga.h" // stdvga_set_cursor_shape #include "clext.h" // clext_1012 #include "vgahw.h" // vgahw_set_mode +#include "pci.h" // pci_config_readw +#include "pci_regs.h" // PCI_VENDOR_ID
// XXX #define DEBUG_VGA_POST 1 @@ -1226,14 +1228,19 @@ init_bios_area(void) SET_BDA(video_msr, 0x09); }
-u16 VgaBDF VAR16; +int VgaBDF VAR16 = -1;
void VISIBLE16 vga_post(struct bregs *regs) { debug_enter(regs, DEBUG_VGA_POST);
- SET_VGA(VgaBDF, regs->ax); + if (CONFIG_VGA_PCI) { + u16 bdf = regs->ax; + if (pci_config_readw(bdf, PCI_VENDOR_ID) == CONFIG_VGA_VID + && pci_config_readw(bdf, PCI_DEVICE_ID) == CONFIG_VGA_DID) + SET_VGA(VgaBDF, bdf); + }
int ret = vgahw_init(); if (ret) { diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h index 403e7ce..6895a39 100644 --- a/vgasrc/vgabios.h +++ b/vgasrc/vgabios.h @@ -73,7 +73,7 @@ extern u8 vgafont14alt[]; extern u8 vgafont16alt[];
// vgabios.c -extern u16 VgaBDF; +extern int VgaBDF; #define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val)) struct carattr { u8 car, attr, use_attr;