Extract Cirrus framebuffer address from PCI config space.
Enable VBE code for Cirrus cards.
Also, rework bochsvga code to use direct PCI accesses instead of calling into the BIOS.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- Makefile | 2 +- vgasrc/bochsvga.c | 26 ++++---------------------- vgasrc/clext.c | 10 +++++++++- 3 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/Makefile b/Makefile index 79f9b54..c97ed8f 100644 --- a/Makefile +++ b/Makefile @@ -169,7 +169,7 @@ $(OUT)bios.bin.elf $(OUT)bios.bin: $(OUT)rom.o tools/checkrom.py ################ VGA build rules
# VGA src files -SRCVGA=src/output.c src/util.c vgasrc/vgabios.c vgasrc/vgafb.c \ +SRCVGA=src/output.c src/util.c src/pci.c vgasrc/vgabios.c vgasrc/vgafb.c \ vgasrc/vgatables.c vgasrc/vgafonts.c vgasrc/vbe.c \ vgasrc/stdvga.c vgasrc/clext.c vgasrc/bochsvga.c vgasrc/geodevga.c
diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index d9858c2..b7b1b05 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -5,6 +5,8 @@ #include "config.h" // CONFIG_* #include "biosvar.h" // SET_BDA #include "stdvga.h" // VGAREG_SEQU_ADDRESS +#include "pci.h" // pci_config_readl +#include "pci_regs.h" // PCI_BASE_ADDRESS_0
static struct bochsvga_mode { @@ -76,27 +78,6 @@ static struct bochsvga_mode { 0x18c, { MM_DIRECT, 2560, 1600, 32 } }, };
-static inline u32 pci_config_readl(u16 bdf, u16 addr) -{ - int status; - u32 val; - - addr &= ~3; - - asm volatile( - "int $0x1a\n" - "cli\n" - "cld" - : "=a"(status), "=c"(val) - : "a"(0xb10a), "b"(bdf), "D"(addr) - : "cc", "memory"); - - if ((status >> 16)) - return (u32)-1; - - return val; -} - static u16 dispi_get_max_xres(void) { u16 en; @@ -145,7 +126,8 @@ bochsvga_init(void)
u32 lfb_addr; if (CONFIG_VGA_PCI) - lfb_addr = pci_config_readl(GET_GLOBAL(VgaBDF), 0x10) & ~0xf; + lfb_addr = (pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_0) + & PCI_BASE_ADDRESS_MEM_MASK); else lfb_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
diff --git a/vgasrc/clext.c b/vgasrc/clext.c index 9bd424e..413add5 100644 --- a/vgasrc/clext.c +++ b/vgasrc/clext.c @@ -12,6 +12,8 @@ #include "bregs.h" // struct bregs #include "vbe.h" // struct vbe_info #include "stdvga.h" // VGAREG_SEQU_ADDRESS +#include "pci.h" // pci_config_readl +#include "pci_regs.h" // PCI_BASE_ADDRESS_0
/**************************************************************** @@ -421,7 +423,7 @@ cirrus_clear_vram(u16 param) int clext_set_mode(int mode, int flags) { - dprintf(1, "cirrus mode %d\n", mode); + dprintf(1, "cirrus mode %x\n", mode); SET_BDA(vbe_mode, 0); struct cirrus_mode_s *table_g = cirrus_get_modeentry(mode); if (table_g) { @@ -771,6 +773,12 @@ clext_init(void) return -1; dprintf(1, "cirrus init 2\n");
+ SET_VGA(VBE_enabled, 1); + u32 lfb_addr = 0; + if (CONFIG_VGA_PCI) + lfb_addr = (pci_config_readl(GET_GLOBAL(VgaBDF), PCI_BASE_ADDRESS_0) + & PCI_BASE_ADDRESS_MEM_MASK); + SET_VGA(VBE_framebuffer, lfb_addr); u16 totalmem = cirrus_get_memsize(); SET_VGA(VBE_total_memory, totalmem * 64 * 1024); SET_VGA(VBE_win_granularity, 16);