Hi,
Next round, this time introducing a CONFIG_VGA_QEMU and doing the hardware detection for qemu-emulated hardware only. Also clarifies Kconfig (cirrus is for emulated hardware only) as side effect.
cheers, Gerd
Gerd Hoffmann (3): vga: move code to vgahw.c vga: add pci hardware detection vga: add isa hardware detection
Makefile | 2 +- vgasrc/Kconfig | 12 +-- vgasrc/bochsvga.c | 8 ++ vgasrc/bochsvga.h | 1 + vgasrc/clext.c | 6 ++ vgasrc/clext.h | 1 + vgasrc/vgabios.c | 2 +- vgasrc/vgahw.c | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++ vgasrc/vgahw.h | 151 +++++++++------------------------------- 9 files changed, 253 insertions(+), 129 deletions(-) create mode 100644 vgasrc/vgahw.c
Create vgahw.c, move code from vgahw.h there, soon we will add more bits there which will make inlining less useful.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- Makefile | 2 +- vgasrc/vgahw.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vgasrc/vgahw.h | 134 ++++++------------------------------------------------- 3 files changed, 152 insertions(+), 120 deletions(-) create mode 100644 vgasrc/vgahw.c
diff --git a/Makefile b/Makefile index 0343ce5..1dcfaeb 100644 --- a/Makefile +++ b/Makefile @@ -184,7 +184,7 @@ $(OUT)bios.bin.elf $(OUT)bios.bin: $(OUT)rom.o tools/checkrom.py SRCVGA=src/output.c src/util.c src/pci.c \ vgasrc/vgabios.c vgasrc/vgafb.c vgasrc/vgafonts.c vgasrc/vbe.c \ vgasrc/stdvga.c vgasrc/stdvgamodes.c vgasrc/stdvgaio.c \ - vgasrc/clext.c vgasrc/bochsvga.c vgasrc/geodevga.c + vgasrc/vgahw.c vgasrc/clext.c vgasrc/bochsvga.c vgasrc/geodevga.c
CFLAGS16VGA = $(CFLAGS16INC) -g -Isrc
diff --git a/vgasrc/vgahw.c b/vgasrc/vgahw.c new file mode 100644 index 0000000..65afeb1 --- /dev/null +++ b/vgasrc/vgahw.c @@ -0,0 +1,136 @@ +#include "vgahw.h" + +struct vgamode_s *vgahw_find_mode(int mode) +{ + if (CONFIG_VGA_CIRRUS) + return clext_find_mode(mode); + if (CONFIG_VGA_BOCHS) + return bochsvga_find_mode(mode); + return stdvga_find_mode(mode); +} + +int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) +{ + if (CONFIG_VGA_CIRRUS) + return clext_set_mode(vmode_g, flags); + if (CONFIG_VGA_BOCHS) + return bochsvga_set_mode(vmode_g, flags); + return stdvga_set_mode(vmode_g, flags); +} + +void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) +{ + if (CONFIG_VGA_CIRRUS) + clext_list_modes(seg, dest, last); + else if (CONFIG_VGA_BOCHS) + bochsvga_list_modes(seg, dest, last); + else + stdvga_list_modes(seg, dest, last); +} + +int vgahw_init(void) +{ + if (CONFIG_VGA_CIRRUS) + return clext_init(); + if (CONFIG_VGA_BOCHS) + return bochsvga_init(); + if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX) + return geodevga_init(); + return stdvga_init(); +} + +int vgahw_get_window(struct vgamode_s *vmode_g, int window) +{ + if (CONFIG_VGA_CIRRUS) + return clext_get_window(vmode_g, window); + if (CONFIG_VGA_BOCHS) + return bochsvga_get_window(vmode_g, window); + return stdvga_get_window(vmode_g, window); +} + +int vgahw_set_window(struct vgamode_s *vmode_g, int window, int val) +{ + if (CONFIG_VGA_CIRRUS) + return clext_set_window(vmode_g, window, val); + if (CONFIG_VGA_BOCHS) + return bochsvga_set_window(vmode_g, window, val); + return stdvga_set_window(vmode_g, window, val); +} + +int vgahw_get_linelength(struct vgamode_s *vmode_g) +{ + if (CONFIG_VGA_CIRRUS) + return clext_get_linelength(vmode_g); + if (CONFIG_VGA_BOCHS) + return bochsvga_get_linelength(vmode_g); + return stdvga_get_linelength(vmode_g); +} + +int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) +{ + if (CONFIG_VGA_CIRRUS) + return clext_set_linelength(vmode_g, val); + if (CONFIG_VGA_BOCHS) + return bochsvga_set_linelength(vmode_g, val); + return stdvga_set_linelength(vmode_g, val); +} + +int vgahw_get_displaystart(struct vgamode_s *vmode_g) +{ + if (CONFIG_VGA_CIRRUS) + return clext_get_displaystart(vmode_g); + if (CONFIG_VGA_BOCHS) + return bochsvga_get_displaystart(vmode_g); + return stdvga_get_displaystart(vmode_g); +} + +int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) +{ + if (CONFIG_VGA_CIRRUS) + return clext_set_displaystart(vmode_g, val); + if (CONFIG_VGA_BOCHS) + return bochsvga_set_displaystart(vmode_g, val); + return stdvga_set_displaystart(vmode_g, val); +} + +int vgahw_get_dacformat(struct vgamode_s *vmode_g) +{ + if (CONFIG_VGA_BOCHS) + return bochsvga_get_dacformat(vmode_g); + return stdvga_get_dacformat(vmode_g); +} + +int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) +{ + if (CONFIG_VGA_BOCHS) + return bochsvga_set_dacformat(vmode_g, val); + return stdvga_set_dacformat(vmode_g, val); +} + +int vgahw_size_state(int states) +{ + if (CONFIG_VGA_CIRRUS) + return clext_size_state(states); + if (CONFIG_VGA_BOCHS) + return bochsvga_size_state(states); + return stdvga_size_state(states); +} + +int vgahw_save_state(u16 seg, void *data, int states) +{ + if (CONFIG_VGA_CIRRUS) + return clext_save_state(seg, data, states); + if (CONFIG_VGA_BOCHS) + return bochsvga_save_state(seg, data, states); + return stdvga_save_state(seg, data, states); +} + +int vgahw_restore_state(u16 seg, void *data, int states) +{ + if (CONFIG_VGA_CIRRUS) + return clext_restore_state(seg, data, states); + if (CONFIG_VGA_BOCHS) + return bochsvga_restore_state(seg, data, states); + return stdvga_restore_state(seg, data, states); +} + diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h index 044cd32..4643d38 100644 --- a/vgasrc/vgahw.h +++ b/vgasrc/vgahw.h @@ -9,124 +9,20 @@ #include "stdvga.h" // stdvga_set_mode #include "geodevga.h" // geodevga_init
-static inline struct vgamode_s *vgahw_find_mode(int mode) { - if (CONFIG_VGA_CIRRUS) - return clext_find_mode(mode); - if (CONFIG_VGA_BOCHS) - return bochsvga_find_mode(mode); - return stdvga_find_mode(mode); -} - -static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) { - if (CONFIG_VGA_CIRRUS) - return clext_set_mode(vmode_g, flags); - if (CONFIG_VGA_BOCHS) - return bochsvga_set_mode(vmode_g, flags); - return stdvga_set_mode(vmode_g, flags); -} - -static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) { - if (CONFIG_VGA_CIRRUS) - clext_list_modes(seg, dest, last); - else if (CONFIG_VGA_BOCHS) - bochsvga_list_modes(seg, dest, last); - else - stdvga_list_modes(seg, dest, last); -} - -static inline int vgahw_init(void) { - if (CONFIG_VGA_CIRRUS) - return clext_init(); - if (CONFIG_VGA_BOCHS) - return bochsvga_init(); - if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX) - return geodevga_init(); - return stdvga_init(); -} - -static inline int vgahw_get_window(struct vgamode_s *vmode_g, int window) { - if (CONFIG_VGA_CIRRUS) - return clext_get_window(vmode_g, window); - if (CONFIG_VGA_BOCHS) - return bochsvga_get_window(vmode_g, window); - return stdvga_get_window(vmode_g, window); -} - -static inline int vgahw_set_window(struct vgamode_s *vmode_g, int window - , int val) { - if (CONFIG_VGA_CIRRUS) - return clext_set_window(vmode_g, window, val); - if (CONFIG_VGA_BOCHS) - return bochsvga_set_window(vmode_g, window, val); - return stdvga_set_window(vmode_g, window, val); -} - -static inline int vgahw_get_linelength(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_CIRRUS) - return clext_get_linelength(vmode_g); - if (CONFIG_VGA_BOCHS) - return bochsvga_get_linelength(vmode_g); - return stdvga_get_linelength(vmode_g); -} - -static inline int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) { - if (CONFIG_VGA_CIRRUS) - return clext_set_linelength(vmode_g, val); - if (CONFIG_VGA_BOCHS) - return bochsvga_set_linelength(vmode_g, val); - return stdvga_set_linelength(vmode_g, val); -} - -static inline int vgahw_get_displaystart(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_CIRRUS) - return clext_get_displaystart(vmode_g); - if (CONFIG_VGA_BOCHS) - return bochsvga_get_displaystart(vmode_g); - return stdvga_get_displaystart(vmode_g); -} - -static inline int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) { - if (CONFIG_VGA_CIRRUS) - return clext_set_displaystart(vmode_g, val); - if (CONFIG_VGA_BOCHS) - return bochsvga_set_displaystart(vmode_g, val); - return stdvga_set_displaystart(vmode_g, val); -} - -static inline int vgahw_get_dacformat(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_BOCHS) - return bochsvga_get_dacformat(vmode_g); - return stdvga_get_dacformat(vmode_g); -} - -static inline int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) { - if (CONFIG_VGA_BOCHS) - return bochsvga_set_dacformat(vmode_g, val); - return stdvga_set_dacformat(vmode_g, val); -} - -static inline int vgahw_size_state(int states) { - if (CONFIG_VGA_CIRRUS) - return clext_size_state(states); - if (CONFIG_VGA_BOCHS) - return bochsvga_size_state(states); - return stdvga_size_state(states); -} - -static inline int vgahw_save_state(u16 seg, void *data, int states) { - if (CONFIG_VGA_CIRRUS) - return clext_save_state(seg, data, states); - if (CONFIG_VGA_BOCHS) - return bochsvga_save_state(seg, data, states); - return stdvga_save_state(seg, data, states); -} - -static inline int vgahw_restore_state(u16 seg, void *data, int states) { - if (CONFIG_VGA_CIRRUS) - return clext_restore_state(seg, data, states); - if (CONFIG_VGA_BOCHS) - return bochsvga_restore_state(seg, data, states); - return stdvga_restore_state(seg, data, states); -} +struct vgamode_s *vgahw_find_mode(int mode); +int vgahw_set_mode(struct vgamode_s *vmode_g, int flags); +void vgahw_list_modes(u16 seg, u16 *dest, u16 *last); +int vgahw_init(void); +int vgahw_get_window(struct vgamode_s *vmode_g, int window); +int vgahw_set_window(struct vgamode_s *vmode_g, int window, int val); +int vgahw_get_linelength(struct vgamode_s *vmode_g); +int vgahw_set_linelength(struct vgamode_s *vmode_g, int val); +int vgahw_get_displaystart(struct vgamode_s *vmode_g); +int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val); +int vgahw_get_dacformat(struct vgamode_s *vmode_g); +int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val); +int vgahw_size_state(int states); +int vgahw_save_state(u16 seg, void *data, int states); +int vgahw_restore_state(u16 seg, void *data, int states);
#endif // vgahw.h
Add support for pci hardware detection (using pci id lookup), so we can create a unified rom with support for different pieces of hardware.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- vgasrc/Kconfig | 12 ++---- vgasrc/vgabios.c | 2 +- vgasrc/vgahw.c | 114 +++++++++++++++++++++++++++++++++++++++--------------- vgasrc/vgahw.h | 17 ++++++++ 4 files changed, 105 insertions(+), 40 deletions(-)
diff --git a/vgasrc/Kconfig b/vgasrc/Kconfig index 881e9ec..e011238 100644 --- a/vgasrc/Kconfig +++ b/vgasrc/Kconfig @@ -15,15 +15,11 @@ menu "VGA ROM" help Build basic VGA BIOS support.
- config VGA_CIRRUS - bool "QEMU Cirrus CLGD 54xx VGA BIOS" + config VGA_QEMU + bool "QEMU VGA BIOS" help - Build support for Cirrus VGA emulation. - - config VGA_BOCHS - bool "Bochs DISPI interface VGA BIOS" - help - Build support for Bochs DISPI interface. + Build VGA BIOS for QEMU. This builds a unified BIOS, + supporting both bochs vga interface and cirrus vga emulation.
config VGA_GEODEGX2 bool "GeodeGX2 interface VGA BIOS" diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c index 7b6c50a..a1cf11a 100644 --- a/vgasrc/vgabios.c +++ b/vgasrc/vgabios.c @@ -1001,7 +1001,7 @@ handle_1012XX(struct bregs *regs) static void handle_1012(struct bregs *regs) { - if (CONFIG_VGA_CIRRUS && regs->bl >= 0x80) { + if (HAVE_VGA_CIRRUS && regs->bl >= 0x80) { clext_1012(regs); return; } diff --git a/vgasrc/vgahw.c b/vgasrc/vgahw.c index 65afeb1..03d8757 100644 --- a/vgasrc/vgahw.c +++ b/vgasrc/vgahw.c @@ -1,28 +1,57 @@ #include "vgahw.h" +#include "config.h" // CONFIG_* +#include "util.h" // dprintf +#include "biosvar.h" // GET_GLOBAL +#include "pci.h" // pci_config_readw +#include "pci_regs.h" // PCI_VENDOR_ID +#include "vgabios.h" // VgaBDF + +enum qemu_vga_type qemu_vga_type VAR16; + +struct qemu_pci_table { + u16 vid; + u16 did; + char *name; + enum qemu_vga_type type; +}; + +static struct qemu_pci_table hwtab[] VAR16 = { + { + .vid = 0x1013, + .did = 0x00b8, + .name = "cirrus", + .type = VGA_TYPE_CIRRUS, + },{ + .vid = 0x1234, + .did = 0x1111, + .name = "std", + .type = VGA_TYPE_BOCHS, + } +};
struct vgamode_s *vgahw_find_mode(int mode) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_find_mode(mode); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_find_mode(mode); return stdvga_find_mode(mode); }
int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_set_mode(vmode_g, flags); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_set_mode(vmode_g, flags); return stdvga_set_mode(vmode_g, flags); }
void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) clext_list_modes(seg, dest, last); - else if (CONFIG_VGA_BOCHS) + else if (HAVE_VGA_BOCHS) bochsvga_list_modes(seg, dest, last); else stdvga_list_modes(seg, dest, last); @@ -30,10 +59,34 @@ void vgahw_list_modes(u16 seg, u16 *dest, u16 *last)
int vgahw_init(void) { - if (CONFIG_VGA_CIRRUS) - return clext_init(); - if (CONFIG_VGA_BOCHS) - return bochsvga_init(); + if (CONFIG_VGA_QEMU) { + if (CONFIG_VGA_PCI) { + u16 bdf = GET_GLOBAL(VgaBDF); + u16 vid = pci_config_readw(bdf, PCI_VENDOR_ID); + u16 did = pci_config_readw(bdf, PCI_DEVICE_ID); + int i; + + for (i = 0; i < ARRAY_SIZE(hwtab); i++) { + if (GET_GLOBAL(hwtab[i].vid) == vid && + GET_GLOBAL(hwtab[i].did) == did) { + dprintf(1, "vgahw: detected qemu %s vga [pci %04x:%04x]\n", + GET_GLOBAL(hwtab[i].name), vid, did); + SET_VGA(qemu_vga_type, GET_GLOBAL(hwtab[i].type)); + break; + } + } + } + + if (GET_GLOBAL(qemu_vga_type) == VGA_TYPE_UNDEFINED) { + SET_VGA(qemu_vga_type, VGA_TYPE_STDVGA); + dprintf(1, "vgahw: no known hardware found, using stdvga\n"); + } + if (HAVE_VGA_CIRRUS) + return clext_init(); + if (HAVE_VGA_BOCHS) + return bochsvga_init(); + } + if (CONFIG_VGA_GEODEGX2 || CONFIG_VGA_GEODELX) return geodevga_init(); return stdvga_init(); @@ -41,96 +94,95 @@ int vgahw_init(void)
int vgahw_get_window(struct vgamode_s *vmode_g, int window) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_get_window(vmode_g, window); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_get_window(vmode_g, window); return stdvga_get_window(vmode_g, window); }
int vgahw_set_window(struct vgamode_s *vmode_g, int window, int val) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_set_window(vmode_g, window, val); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_set_window(vmode_g, window, val); return stdvga_set_window(vmode_g, window, val); }
int vgahw_get_linelength(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_get_linelength(vmode_g); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_get_linelength(vmode_g); return stdvga_get_linelength(vmode_g); }
int vgahw_set_linelength(struct vgamode_s *vmode_g, int val) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_set_linelength(vmode_g, val); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_set_linelength(vmode_g, val); return stdvga_set_linelength(vmode_g, val); }
int vgahw_get_displaystart(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_get_displaystart(vmode_g); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_get_displaystart(vmode_g); return stdvga_get_displaystart(vmode_g); }
int vgahw_set_displaystart(struct vgamode_s *vmode_g, int val) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_set_displaystart(vmode_g, val); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_set_displaystart(vmode_g, val); return stdvga_set_displaystart(vmode_g, val); }
int vgahw_get_dacformat(struct vgamode_s *vmode_g) { - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_get_dacformat(vmode_g); return stdvga_get_dacformat(vmode_g); }
int vgahw_set_dacformat(struct vgamode_s *vmode_g, int val) { - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_set_dacformat(vmode_g, val); return stdvga_set_dacformat(vmode_g, val); }
int vgahw_size_state(int states) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_size_state(states); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_size_state(states); return stdvga_size_state(states); }
int vgahw_save_state(u16 seg, void *data, int states) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_save_state(seg, data, states); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_save_state(seg, data, states); return stdvga_save_state(seg, data, states); }
int vgahw_restore_state(u16 seg, void *data, int states) { - if (CONFIG_VGA_CIRRUS) + if (HAVE_VGA_CIRRUS) return clext_restore_state(seg, data, states); - if (CONFIG_VGA_BOCHS) + if (HAVE_VGA_BOCHS) return bochsvga_restore_state(seg, data, states); return stdvga_restore_state(seg, data, states); } - diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h index 4643d38..186f7b5 100644 --- a/vgasrc/vgahw.h +++ b/vgasrc/vgahw.h @@ -9,6 +9,23 @@ #include "stdvga.h" // stdvga_set_mode #include "geodevga.h" // geodevga_init
+enum qemu_vga_type { + VGA_TYPE_UNDEFINED = 0, + VGA_TYPE_STDVGA, + VGA_TYPE_CIRRUS, + VGA_TYPE_BOCHS, +}; + +extern enum qemu_vga_type qemu_vga_type; + +#if CONFIG_VGA_QEMU +# define HAVE_VGA_CIRRUS (GET_GLOBAL(qemu_vga_type) == VGA_TYPE_CIRRUS) +# define HAVE_VGA_BOCHS (GET_GLOBAL(qemu_vga_type) == VGA_TYPE_BOCHS) +#else +# define HAVE_VGA_CIRRUS (0) +# define HAVE_VGA_BOCHS (0) +#endif + struct vgamode_s *vgahw_find_mode(int mode); int vgahw_set_mode(struct vgamode_s *vmode_g, int flags); void vgahw_list_modes(u16 seg, u16 *dest, u16 *last);
Try to find isa vga cards in case pci probe found nothing.
Signed-off-by: Gerd Hoffmann kraxel@redhat.com --- vgasrc/bochsvga.c | 8 ++++++++ vgasrc/bochsvga.h | 1 + vgasrc/clext.c | 6 ++++++ vgasrc/clext.h | 1 + vgasrc/vgahw.c | 11 +++++++++++ 5 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/vgasrc/bochsvga.c b/vgasrc/bochsvga.c index 2a8aeb1..f44588f 100644 --- a/vgasrc/bochsvga.c +++ b/vgasrc/bochsvga.c @@ -391,3 +391,11 @@ bochsvga_init(void)
return 0; } + +int +bochsvga_isa_probe(void) +{ + dispi_write(VBE_DISPI_INDEX_ID, VBE_DISPI_ID0); + return dispi_read(VBE_DISPI_INDEX_ID) == VBE_DISPI_ID0; +} + diff --git a/vgasrc/bochsvga.h b/vgasrc/bochsvga.h index 1c98203..f946e9f 100644 --- a/vgasrc/bochsvga.h +++ b/vgasrc/bochsvga.h @@ -67,5 +67,6 @@ int bochsvga_save_state(u16 seg, void *data, int states); int bochsvga_restore_state(u16 seg, void *data, int states); int bochsvga_set_mode(struct vgamode_s *vmode_g, int flags); int bochsvga_init(void); +int bochsvga_isa_probe(void);
#endif // bochsvga.h diff --git a/vgasrc/clext.c b/vgasrc/clext.c index 7d1a604..ad6f471 100644 --- a/vgasrc/clext.c +++ b/vgasrc/clext.c @@ -637,3 +637,9 @@ clext_init(void)
return 0; } + +int +clext_isa_probe(void) +{ + return cirrus_check(); +} diff --git a/vgasrc/clext.h b/vgasrc/clext.h index 78dba01..185e1d5 100644 --- a/vgasrc/clext.h +++ b/vgasrc/clext.h @@ -18,5 +18,6 @@ int clext_set_mode(struct vgamode_s *vmode_g, int flags); struct bregs; void clext_1012(struct bregs *regs); int clext_init(void); +int clext_isa_probe(void);
#endif // clext.h diff --git a/vgasrc/vgahw.c b/vgasrc/vgahw.c index 03d8757..a91a47c 100644 --- a/vgasrc/vgahw.c +++ b/vgasrc/vgahw.c @@ -78,9 +78,20 @@ int vgahw_init(void) }
if (GET_GLOBAL(qemu_vga_type) == VGA_TYPE_UNDEFINED) { + if (clext_isa_probe()) { + SET_VGA(qemu_vga_type, VGA_TYPE_CIRRUS); + dprintf(1, "vgahw: detected qemu cirrus vga [isa]\n"); + } else if (bochsvga_isa_probe()) { + SET_VGA(qemu_vga_type, VGA_TYPE_BOCHS); + dprintf(1, "vgahw: detected qemu bochs vga [isa]\n"); + } + } + + if (GET_GLOBAL(qemu_vga_type) == VGA_TYPE_UNDEFINED) { SET_VGA(qemu_vga_type, VGA_TYPE_STDVGA); dprintf(1, "vgahw: no known hardware found, using stdvga\n"); } + if (HAVE_VGA_CIRRUS) return clext_init(); if (HAVE_VGA_BOCHS)
On Wed, Feb 08, 2012 at 05:38:56PM +0100, Gerd Hoffmann wrote:
Hi,
Next round, this time introducing a CONFIG_VGA_QEMU and doing the hardware detection for qemu-emulated hardware only. Also clarifies Kconfig (cirrus is for emulated hardware only) as side effect.
What's the advantage of modifying the code versus just having a simple build script?
-Kevin
#!/bin/sh # Script to build the vgaroms that qemu uses
mkdir -p out/
CFG=$PWD/out/config-cirrus cat > $CFG <<EOF CONFIG_BUILD_VGABIOS=y CONFIG_VGA_CIRRUS=y EOF make KCONFIG_CONFIG=$CFG oldnoconfig make KCONFIG_CONFIG=$CFG out/vgabios.bin cp out/vgabios.bin out/vgabios-cirrus.bin
CFG=$PWD/out/config-bochsvga cat > $CFG <<EOF CONFIG_BUILD_VGABIOS=y CONFIG_VGA_BOCHS=y EOF make KCONFIG_CONFIG=$CFG oldnoconfig make KCONFIG_CONFIG=$CFG out/vgabios.bin cp out/vgabios.bin out/vgabios-stdvga.bin cp out/vgabios.bin out/vgabios-vmware.bin cp out/vgabios.bin out/vgabios-qxl.bin
On 02/09/12 02:06, Kevin O'Connor wrote:
On Wed, Feb 08, 2012 at 05:38:56PM +0100, Gerd Hoffmann wrote:
Hi,
Next round, this time introducing a CONFIG_VGA_QEMU and doing the hardware detection for qemu-emulated hardware only. Also clarifies Kconfig (cirrus is for emulated hardware only) as side effect.
What's the advantage of modifying the code versus just having a simple build script?
There is no real advantage, just a matter of taste. I'd prefer to have it this way, but I can do it with some build scriptease in qemu too ...
cheers, Gerd