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>
################ 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
#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
{
{ 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;
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;
#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
/****************************************************************
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) {
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);