vgabios: Add cirrus linear framebuffer detection; enable VBE in cirrus.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 14 Jan 2012 21:59:21 +0000 (16:59 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 14 Jan 2012 22:20:07 +0000 (17:20 -0500)
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
vgasrc/bochsvga.c
vgasrc/clext.c

index 79f9b546bbbadd504d3a584150cf477cd3def04a..c97ed8f891e2f7a10bd0056e9f8dc3d65ed32246 100644 (file)
--- 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
 
index d9858c2061be9b5c8ee7348408228583152a2247..b7b1b05835de6476ff6b9d0abed641b3c6a14602 100644 (file)
@@ -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;
 
index 9bd424ef6790ce52712577b6786dd7eec6c248fd..413add53586fffe3d2b321423923e9a6f22a2bfc 100644 (file)
@@ -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);