* [Qemu-devel] [PATCH 00/23] VGA cleanup
@ 2009-08-31 14:07 Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 01/23] vga: remove useless cast from void * Juan Quintela
` (23 more replies)
0 siblings, 24 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
This patch:
- cleans the differences between VGAState/VGACommon state
- moves vga pci, isa, isa-mm out of vga.c (cirrus and blizzar uses
VGA common state).
- Cleans all the cirrus_hook_* stuff is something that don't look like a hook :)
I would want this bits morged/reviewed before going the rest of the cleanup:
Todo:
- vga_ioport_read/write and cirrus_vga_ioport_read/write are almost identical
after this series of changes. Creating read/write() callbacks for
sr/gr/cr/palette. Should put us there. The cirrus ones were the difficult ones,
the vga ones are trivial.
- CONFIG_VBE_BOCHS code. This code is only used by vga std (pci + isa). Neither
cirrus/blizzard/isa-mm uses it. It should be moved out of vga.c, vga-std.c?, and
then used by vga-isa and vga-pci?
- vmware_vga: it uses vga as embeded, but it don't save its state, I am not sure
if it wants/need VBE_BOCHS, .... I haven't looked at vmware_vga too much, just
to vga and cirrus_vga.
Comments?
Later, Juan.
Juan Quintela (23):
vga: remove useless cast from void *
cirrus_vga: prefix vga_ioport_{read,write} with cirrus
vga: export vga_ioport_{read,write}
vga: split vga_{load,save} into pci and common parts
vga: split pci bits into vga-pci.c
vga: split isa bits inco vga-isa.c
vga: export vga_mem_{read,write}
vga: split vga-isa-mm.o
vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere
cirrus_vga: Add a VGACommonState local var to
cirrus_vga_ioport_{read,write}
vga: change tabs to spaces
cirrus_vga: make cirrus_read_hidden_dac() return its result
vga and cirrus_vga: substitute switch for equivalent assigntment
vga: Rename last VGAState occurrences to VGACommonState
cirrus_vga: rename cirrus_hook_read_sr() cirrus_vga_read_sr()
cirrus_vga: rename cirrus_hook_write_sr() cirrus_vga_write_sr()
cirrus_vga: rename cirrus_hook_read_palette()
cirrus_vga_read_palette()
cirrus_vga: rename cirrus_hook_write_palette()
cirrus_vga_write_palette()
cirrus_vga: rename cirrus_hook_read_gr() cirrus_vga_read_gr()
cirrus_vga: rename cirrus_hook_write_gr() cirrus_vga_write_gr()
cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr()
cirrus_vga: rename cirrus_hook_write_cr() cirrus_vga_write_cr()
cirrus_vga: CIRRUS_HOOK_* is not used anymore
Makefile.target | 9 +-
hw/cirrus_vga.c | 532 +++++++++++++++++++++++-----------------------------
hw/vga-isa-mm.c | 130 +++++++++++++
hw/vga-isa.c | 50 +++++
hw/vga-pci.c | 164 ++++++++++++++++
hw/vga.c | 357 ++++++------------------------------
hw/vga_int.h | 10 +-
hw/vga_template.h | 20 +-
hw/vmware_vga.c | 1 +
9 files changed, 662 insertions(+), 611 deletions(-)
create mode 100644 hw/vga-isa-mm.c
create mode 100644 hw/vga-isa.c
create mode 100644 hw/vga-pci.c
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 01/23] vga: remove useless cast from void *
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 02/23] cirrus_vga: prefix vga_ioport_{read, write} with cirrus Juan Quintela
` (22 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/vga.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index 6b5070a..7bfd8e9 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -1835,7 +1835,7 @@ static void vga_draw_blank(VGAState *s, int full_update)
static void vga_update_display(void *opaque)
{
- VGAState *s = (VGAState *)opaque;
+ VGAState *s = opaque;
int full_update, graphic_mode;
if (ds_get_bits_per_pixel(s->ds) == 0) {
@@ -1870,7 +1870,7 @@ static void vga_update_display(void *opaque)
/* force a full display refresh */
static void vga_invalidate_display(void *opaque)
{
- VGAState *s = (VGAState *)opaque;
+ VGAState *s = opaque;
s->full_update = 1;
}
@@ -1944,7 +1944,7 @@ void vga_common_reset(VGACommonState *s)
static void vga_reset(void *opaque)
{
- VGAState *s = (VGAState *) opaque;
+ VGAState *s = opaque;
vga_common_reset(s);
}
@@ -1956,7 +1956,7 @@ static void vga_reset(void *opaque)
* instead of doing a full vga_update_display() */
static void vga_update_text(void *opaque, console_ch_t *chardata)
{
- VGAState *s = (VGAState *) opaque;
+ VGAState *s = opaque;
int graphic_mode, i, cursor_offset, cursor_visible;
int cw, cheight, width, height, size, c_min, c_max;
uint32_t *src;
@@ -2628,7 +2628,7 @@ static DisplayChangeListener* vga_screen_dump_init(DisplayState *ds)
available */
static void vga_screen_dump(void *opaque, const char *filename)
{
- VGAState *s = (VGAState *)opaque;
+ VGAState *s = opaque;
if (!screen_dump_dcl)
screen_dump_dcl = vga_screen_dump_init(s->ds);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 02/23] cirrus_vga: prefix vga_ioport_{read, write} with cirrus
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 01/23] vga: remove useless cast from void * Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 03/23] vga: export vga_ioport_{read,write} Juan Quintela
` (21 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 991d1da..5f57107 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2656,7 +2656,7 @@ static void cirrus_update_memory_access(CirrusVGAState *s)
/* I/O ports */
-static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
+static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
{
CirrusVGAState *s = opaque;
int val, index;
@@ -2762,7 +2762,7 @@ static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
return val;
}
-static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
CirrusVGAState *s = opaque;
int index;
@@ -2926,7 +2926,7 @@ static uint32_t cirrus_mmio_readb(void *opaque, target_phys_addr_t addr)
if (addr >= 0x100) {
return cirrus_mmio_blt_read(s, addr - 0x100);
} else {
- return vga_ioport_read(s, addr + 0x3c0);
+ return cirrus_vga_ioport_read(s, addr + 0x3c0);
}
}
@@ -2970,7 +2970,7 @@ static void cirrus_mmio_writeb(void *opaque, target_phys_addr_t addr,
if (addr >= 0x100) {
cirrus_mmio_blt_write(s, addr - 0x100, val);
} else {
- vga_ioport_write(s, addr + 0x3c0, val);
+ cirrus_vga_ioport_write(s, addr + 0x3c0, val);
}
}
@@ -3198,19 +3198,19 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci)
s->bustype = CIRRUS_BUSTYPE_ISA;
}
- register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
+ register_ioport_write(0x3c0, 16, 1, cirrus_vga_ioport_write, s);
- register_ioport_write(0x3b4, 2, 1, vga_ioport_write, s);
- register_ioport_write(0x3d4, 2, 1, vga_ioport_write, s);
- register_ioport_write(0x3ba, 1, 1, vga_ioport_write, s);
- register_ioport_write(0x3da, 1, 1, vga_ioport_write, s);
+ register_ioport_write(0x3b4, 2, 1, cirrus_vga_ioport_write, s);
+ register_ioport_write(0x3d4, 2, 1, cirrus_vga_ioport_write, s);
+ register_ioport_write(0x3ba, 1, 1, cirrus_vga_ioport_write, s);
+ register_ioport_write(0x3da, 1, 1, cirrus_vga_ioport_write, s);
- register_ioport_read(0x3c0, 16, 1, vga_ioport_read, s);
+ register_ioport_read(0x3c0, 16, 1, cirrus_vga_ioport_read, s);
- register_ioport_read(0x3b4, 2, 1, vga_ioport_read, s);
- register_ioport_read(0x3d4, 2, 1, vga_ioport_read, s);
- register_ioport_read(0x3ba, 1, 1, vga_ioport_read, s);
- register_ioport_read(0x3da, 1, 1, vga_ioport_read, s);
+ register_ioport_read(0x3b4, 2, 1, cirrus_vga_ioport_read, s);
+ register_ioport_read(0x3d4, 2, 1, cirrus_vga_ioport_read, s);
+ register_ioport_read(0x3ba, 1, 1, cirrus_vga_ioport_read, s);
+ register_ioport_read(0x3da, 1, 1, cirrus_vga_ioport_read, s);
s->vga.vga_io_memory = cpu_register_io_memory(cirrus_vga_mem_read,
cirrus_vga_mem_write, s);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 03/23] vga: export vga_ioport_{read,write}
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 01/23] vga: remove useless cast from void * Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 02/23] cirrus_vga: prefix vga_ioport_{read, write} with cirrus Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 04/23] vga: split vga_{load, save} into pci and common parts Juan Quintela
` (20 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/vga.c | 8 ++++----
hw/vga_int.h | 2 ++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index 7bfd8e9..d1de04e 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -285,9 +285,9 @@ static uint8_t vga_dumb_retrace(VGAState *s)
return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE);
}
-static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
+uint32_t vga_ioport_read(void *opaque, uint32_t addr)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int val, index;
/* check port range access depending on color/monochrome mode */
@@ -378,9 +378,9 @@ static uint32_t vga_ioport_read(void *opaque, uint32_t addr)
return val;
}
-static void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
+void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int index;
/* check port range access depending on color/monochrome mode */
diff --git a/hw/vga_int.h b/hw/vga_int.h
index eb837ff..b44790d 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -194,6 +194,8 @@ void vga_common_reset(VGACommonState *s);
void vga_dirty_log_start(VGACommonState *s);
+uint32_t vga_ioport_read(void *opaque, uint32_t addr);
+void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val);
uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val);
void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 04/23] vga: split vga_{load, save} into pci and common parts
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (2 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 03/23] vga: export vga_ioport_{read,write} Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 05/23] vga: split pci bits into vga-pci.c Juan Quintela
` (19 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Once there adjust VGAState <-> VGACommonState
Export vga_common_save/vga_common_load (nreeded by wmvare_vga
Remove vga.pci_dev field, it is not needed anymore
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/vga.c | 52 ++++++++++++++++++++++++++++++++++------------------
hw/vga_int.h | 3 ++-
hw/vmware_vga.c | 1 +
3 files changed, 37 insertions(+), 19 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index d1de04e..2b7091c 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2126,14 +2126,11 @@ static CPUWriteMemoryFunc * const vga_mem_write[3] = {
vga_mem_writel,
};
-static void vga_save(QEMUFile *f, void *opaque)
+void vga_common_save(QEMUFile *f, void *opaque)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int i;
- if (s->pci_dev)
- pci_device_save(s->pci_dev, f);
-
qemu_put_be32s(f, &s->latch);
qemu_put_8s(f, &s->sr_index);
qemu_put_buffer(f, s->sr, 8);
@@ -2170,20 +2167,14 @@ static void vga_save(QEMUFile *f, void *opaque)
#endif
}
-static int vga_load(QEMUFile *f, void *opaque, int version_id)
+int vga_common_load(QEMUFile *f, void *opaque, int version_id)
{
- VGAState *s = opaque;
- int is_vbe, i, ret;
+ VGACommonState *s = opaque;
+ int is_vbe, i;
if (version_id > 2)
return -EINVAL;
- if (s->pci_dev && version_id >= 2) {
- ret = pci_device_load(s->pci_dev, f);
- if (ret < 0)
- return ret;
- }
-
qemu_get_be32s(f, &s->latch);
qemu_get_8s(f, &s->sr_index);
qemu_get_buffer(f, s->sr, 8);
@@ -2229,9 +2220,33 @@ static int vga_load(QEMUFile *f, void *opaque, int version_id)
typedef struct PCIVGAState {
PCIDevice dev;
- VGAState vga;
+ VGACommonState vga;
} PCIVGAState;
+static void pci_vga_save(QEMUFile *f, void *opaque)
+{
+ PCIVGAState *s = opaque;
+
+ pci_device_save(&s->dev, f);
+ vga_common_save(f, &s->vga);
+}
+
+static int pci_vga_load(QEMUFile *f, void *opaque, int version_id)
+{
+ PCIVGAState *s = opaque;
+ int ret;
+
+ if (version_id > 2)
+ return -EINVAL;
+
+ if (version_id >= 2) {
+ ret = pci_device_load(&s->dev, f);
+ if (ret < 0)
+ return ret;
+ }
+ return vga_common_load(f, &s->vga, version_id);
+}
+
void vga_dirty_log_start(VGAState *s)
{
if (kvm_enabled() && s->map_addr)
@@ -2315,7 +2330,6 @@ void vga_init(VGAState *s)
int vga_io_memory;
qemu_register_reset(vga_reset, s);
- register_savevm("vga", 0, 2, vga_save, vga_load, s);
register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s);
@@ -2428,7 +2442,7 @@ static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s);
vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
- register_savevm("vga", 0, 2, vga_save, vga_load, s);
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
s->bank_offset = 0;
@@ -2444,6 +2458,7 @@ int isa_vga_init(void)
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
s->ds = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
@@ -2497,7 +2512,8 @@ static int pci_vga_initfn(PCIDevice *dev)
// vga + console init
vga_common_init(s, VGA_RAM_SIZE);
vga_init(s);
- s->pci_dev = &d->dev;
+ register_savevm("vga", 0, 2, pci_vga_save, pci_vga_load, d);
+
s->ds = graphic_console_init(s->update, s->invalidate,
s->screen_dump, s->text_update, s);
diff --git a/hw/vga_int.h b/hw/vga_int.h
index b44790d..54b3d5a 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -110,7 +110,6 @@ typedef struct VGACommonState {
uint32_t bios_offset;
uint32_t bios_size;
int it_shift;
- PCIDevice *pci_dev;
uint32_t latch;
uint8_t sr_index;
uint8_t sr[256];
@@ -194,6 +193,8 @@ void vga_common_reset(VGACommonState *s);
void vga_dirty_log_start(VGACommonState *s);
+void vga_common_save(QEMUFile *f, void *opaque);
+int vga_common_load(QEMUFile *f, void *opaque, int version_id);
uint32_t vga_ioport_read(void *opaque, uint32_t addr);
void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val);
uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr);
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index c6bce5a..a273f35 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -1131,6 +1131,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
#ifdef EMBED_STDVGA
vga_common_init(&s->vga, vga_ram_size);
vga_init(&s->vga);
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, &s->vga);
#else
s->vram_size = vga_ram_size;
s->vram_offset = qemu_ram_alloc(vga_ram_size);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 05/23] vga: split pci bits into vga-pci.c
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (3 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 04/23] vga: split vga_{load, save} into pci and common parts Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 06/23] vga: split isa bits inco vga-isa.c Juan Quintela
` (18 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Adjust all the VGAState in VGACommonState
Compile vga-pci.o only for targets that use it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
Makefile.target | 9 ++-
hw/vga-pci.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/vga.c | 134 ---------------------------------------------
3 files changed, 170 insertions(+), 137 deletions(-)
create mode 100644 hw/vga-pci.c
diff --git a/Makefile.target b/Makefile.target
index f7d1919..a74c3f2 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -183,7 +183,8 @@ obj-y += e1000.o
obj-y += wdt_i6300esb.o
# Hardware support
-obj-i386-y = ide/core.o ide/isa.o ide/pci.o pckbd.o vga.o $(sound-obj-y) dma.o isa-bus.o
+obj-i386-y = ide/core.o ide/isa.o ide/pci.o pckbd.o $(sound-obj-y) dma.o isa-bus.o
+obj-i386-y += vga.o vga-pci.o
obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
@@ -191,7 +192,7 @@ obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
# shared objects
obj-ppc-y = ppc.o ide/core.o ide/isa.o ide/pci.o ide/macio.o
-obj-ppc-y += vga.o $(sound-obj-y) dma.o isa-bus.o openpic.o
+obj-ppc-y += vga.o vga-pci.o $(sound-obj-y) dma.o isa-bus.o openpic.o
# PREP target
obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
obj-ppc-y += prep_pci.o ppc_prep.o
@@ -211,6 +212,7 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o
obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
+obj-mips-y += vga-pci.o
obj-mips-y += g364fb.o jazz_led.o dp8393x.o
obj-mips-y += ide/core.o ide/isa.o ide/pci.o
obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
@@ -244,7 +246,8 @@ obj-cris-y += etraxfs_ser.o
obj-cris-y += pflash_cfi02.o
ifeq ($(TARGET_ARCH), sparc64)
-obj-sparc-y = sun4u.o ide/core.o ide/pci.o isa-bus.o pckbd.o vga.o apb_pci.o
+obj-sparc-y = sun4u.o ide/core.o ide/pci.o isa-bus.o pckbd.o apb_pci.o
+obj-sparc-y += vga.o vga-pci.o
obj-sparc-y += fdc.o mc146818rtc.o serial.o
obj-sparc-y += cirrus_vga.o parallel.o
else
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
new file mode 100644
index 0000000..6038cec
--- /dev/null
+++ b/hw/vga-pci.c
@@ -0,0 +1,164 @@
+/*
+ * QEMU PCI VGA Emulator.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "console.h"
+#include "pc.h"
+#include "pci.h"
+#include "vga_int.h"
+#include "pixel_ops.h"
+#include "qemu-timer.h"
+#include "kvm.h"
+
+typedef struct PCIVGAState {
+ PCIDevice dev;
+ VGACommonState vga;
+} PCIVGAState;
+
+static void pci_vga_save(QEMUFile *f, void *opaque)
+{
+ PCIVGAState *s = opaque;
+
+ pci_device_save(&s->dev, f);
+ vga_common_save(f, &s->vga);
+}
+
+static int pci_vga_load(QEMUFile *f, void *opaque, int version_id)
+{
+ PCIVGAState *s = opaque;
+ int ret;
+
+ if (version_id > 2)
+ return -EINVAL;
+
+ if (version_id >= 2) {
+ ret = pci_device_load(&s->dev, f);
+ if (ret < 0)
+ return ret;
+ }
+ return vga_common_load(f, &s->vga, version_id);
+}
+
+void vga_dirty_log_start(VGACommonState *s)
+{
+ if (kvm_enabled() && s->map_addr)
+ kvm_log_start(s->map_addr, s->map_end - s->map_addr);
+
+ if (kvm_enabled() && s->lfb_vram_mapped) {
+ kvm_log_start(isa_mem_base + 0xa0000, 0x8000);
+ kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
+ }
+}
+
+static void vga_map(PCIDevice *pci_dev, int region_num,
+ uint32_t addr, uint32_t size, int type)
+{
+ PCIVGAState *d = (PCIVGAState *)pci_dev;
+ VGACommonState *s = &d->vga;
+ if (region_num == PCI_ROM_SLOT) {
+ cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
+ } else {
+ cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
+ s->map_addr = addr;
+ s->map_end = addr + s->vram_size;
+ vga_dirty_log_start(s);
+ }
+}
+
+static void pci_vga_write_config(PCIDevice *d,
+ uint32_t address, uint32_t val, int len)
+{
+ PCIVGAState *pvs = container_of(d, PCIVGAState, dev);
+ VGACommonState *s = &pvs->vga;
+
+ pci_default_write_config(d, address, val, len);
+ if (s->map_addr && pvs->dev.io_regions[0].addr == -1)
+ s->map_addr = 0;
+}
+
+static int pci_vga_initfn(PCIDevice *dev)
+{
+ PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
+ VGACommonState *s = &d->vga;
+ uint8_t *pci_conf = d->dev.config;
+
+ // vga + console init
+ vga_common_init(s, VGA_RAM_SIZE);
+ vga_init(s);
+ register_savevm("vga", 0, 2, pci_vga_save, pci_vga_load, d);
+
+ s->ds = graphic_console_init(s->update, s->invalidate,
+ s->screen_dump, s->text_update, s);
+
+ // dummy VGA (same as Bochs ID)
+ pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_QEMU);
+ pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_QEMU_VGA);
+ pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);
+ pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
+
+ /* XXX: VGA_RAM_SIZE must be a power of two */
+ pci_register_bar(&d->dev, 0, VGA_RAM_SIZE,
+ PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
+
+ if (s->bios_size) {
+ unsigned int bios_total_size;
+ /* must be a power of two */
+ bios_total_size = 1;
+ while (bios_total_size < s->bios_size)
+ bios_total_size <<= 1;
+ pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size,
+ PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
+ }
+ return 0;
+}
+
+int pci_vga_init(PCIBus *bus,
+ unsigned long vga_bios_offset, int vga_bios_size)
+{
+ PCIDevice *dev;
+
+ dev = pci_create("VGA", NULL);
+ qdev_prop_set_uint32(&dev->qdev, "bios-offset", vga_bios_offset);
+ qdev_prop_set_uint32(&dev->qdev, "bios-size", vga_bios_offset);
+ qdev_init(&dev->qdev);
+
+ return 0;
+}
+
+static PCIDeviceInfo vga_info = {
+ .qdev.name = "VGA",
+ .qdev.size = sizeof(PCIVGAState),
+ .init = pci_vga_initfn,
+ .config_write = pci_vga_write_config,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_HEX32("bios-offset", PCIVGAState, vga.bios_offset, 0),
+ DEFINE_PROP_HEX32("bios-size", PCIVGAState, vga.bios_size, 0),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
+static void vga_register(void)
+{
+ pci_qdev_register(&vga_info);
+}
+device_init(vga_register);
diff --git a/hw/vga.c b/hw/vga.c
index 2b7091c..edd11fc 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -28,7 +28,6 @@
#include "vga_int.h"
#include "pixel_ops.h"
#include "qemu-timer.h"
-#include "kvm.h"
//#define DEBUG_VGA
//#define DEBUG_VGA_MEM
@@ -2218,61 +2217,6 @@ int vga_common_load(QEMUFile *f, void *opaque, int version_id)
return 0;
}
-typedef struct PCIVGAState {
- PCIDevice dev;
- VGACommonState vga;
-} PCIVGAState;
-
-static void pci_vga_save(QEMUFile *f, void *opaque)
-{
- PCIVGAState *s = opaque;
-
- pci_device_save(&s->dev, f);
- vga_common_save(f, &s->vga);
-}
-
-static int pci_vga_load(QEMUFile *f, void *opaque, int version_id)
-{
- PCIVGAState *s = opaque;
- int ret;
-
- if (version_id > 2)
- return -EINVAL;
-
- if (version_id >= 2) {
- ret = pci_device_load(&s->dev, f);
- if (ret < 0)
- return ret;
- }
- return vga_common_load(f, &s->vga, version_id);
-}
-
-void vga_dirty_log_start(VGAState *s)
-{
- if (kvm_enabled() && s->map_addr)
- kvm_log_start(s->map_addr, s->map_end - s->map_addr);
-
- if (kvm_enabled() && s->lfb_vram_mapped) {
- kvm_log_start(isa_mem_base + 0xa0000, 0x8000);
- kvm_log_start(isa_mem_base + 0xa8000, 0x8000);
- }
-}
-
-static void vga_map(PCIDevice *pci_dev, int region_num,
- uint32_t addr, uint32_t size, int type)
-{
- PCIVGAState *d = (PCIVGAState *)pci_dev;
- VGAState *s = &d->vga;
- if (region_num == PCI_ROM_SLOT) {
- cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
- } else {
- cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
- s->map_addr = addr;
- s->map_end = addr + s->vram_size;
- vga_dirty_log_start(s);
- }
-}
-
void vga_common_init(VGACommonState *s, int vga_ram_size)
{
int i, j, v, b;
@@ -2492,84 +2436,6 @@ int isa_vga_mm_init(target_phys_addr_t vram_base,
return 0;
}
-static void pci_vga_write_config(PCIDevice *d,
- uint32_t address, uint32_t val, int len)
-{
- PCIVGAState *pvs = container_of(d, PCIVGAState, dev);
- VGAState *s = &pvs->vga;
-
- pci_default_write_config(d, address, val, len);
- if (s->map_addr && pvs->dev.io_regions[0].addr == -1)
- s->map_addr = 0;
-}
-
-static int pci_vga_initfn(PCIDevice *dev)
-{
- PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
- VGAState *s = &d->vga;
- uint8_t *pci_conf = d->dev.config;
-
- // vga + console init
- vga_common_init(s, VGA_RAM_SIZE);
- vga_init(s);
- register_savevm("vga", 0, 2, pci_vga_save, pci_vga_load, d);
-
- s->ds = graphic_console_init(s->update, s->invalidate,
- s->screen_dump, s->text_update, s);
-
- // dummy VGA (same as Bochs ID)
- pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_QEMU);
- pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_QEMU_VGA);
- pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_VGA);
- pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
-
- /* XXX: VGA_RAM_SIZE must be a power of two */
- pci_register_bar(&d->dev, 0, VGA_RAM_SIZE,
- PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
-
- if (s->bios_size) {
- unsigned int bios_total_size;
- /* must be a power of two */
- bios_total_size = 1;
- while (bios_total_size < s->bios_size)
- bios_total_size <<= 1;
- pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size,
- PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
- }
- return 0;
-}
-
-int pci_vga_init(PCIBus *bus,
- unsigned long vga_bios_offset, int vga_bios_size)
-{
- PCIDevice *dev;
-
- dev = pci_create("VGA", NULL);
- qdev_prop_set_uint32(&dev->qdev, "bios-offset", vga_bios_offset);
- qdev_prop_set_uint32(&dev->qdev, "bios-size", vga_bios_offset);
- qdev_init(&dev->qdev);
-
- return 0;
-}
-
-static PCIDeviceInfo vga_info = {
- .qdev.name = "VGA",
- .qdev.size = sizeof(PCIVGAState),
- .init = pci_vga_initfn,
- .config_write = pci_vga_write_config,
- .qdev.props = (Property[]) {
- DEFINE_PROP_HEX32("bios-offset", PCIVGAState, vga.bios_offset, 0),
- DEFINE_PROP_HEX32("bios-size", PCIVGAState, vga.bios_size, 0),
- DEFINE_PROP_END_OF_LIST(),
- }
-};
-
-static void vga_register(void)
-{
- pci_qdev_register(&vga_info);
-}
-device_init(vga_register);
-
/********************************************************/
/* vga screen dump */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 06/23] vga: split isa bits inco vga-isa.c
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (4 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 05/23] vga: split pci bits into vga-pci.c Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 07/23] vga: export vga_mem_{read,write} Juan Quintela
` (17 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Adjust all the VGAState in VGACommonState
Compile vga-isa.o in the targets that use it
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
Makefile.target | 4 ++--
hw/vga-isa.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
hw/vga.c | 21 ---------------------
3 files changed, 52 insertions(+), 23 deletions(-)
create mode 100644 hw/vga-isa.c
diff --git a/Makefile.target b/Makefile.target
index a74c3f2..07017a5 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -184,7 +184,7 @@ obj-y += wdt_i6300esb.o
# Hardware support
obj-i386-y = ide/core.o ide/isa.o ide/pci.o pckbd.o $(sound-obj-y) dma.o isa-bus.o
-obj-i386-y += vga.o vga-pci.o
+obj-i386-y += vga.o vga-pci.o vga-isa.o
obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
@@ -212,7 +212,7 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o
obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
-obj-mips-y += vga-pci.o
+obj-mips-y += vga-pci.o vga-isa.o
obj-mips-y += g364fb.o jazz_led.o dp8393x.o
obj-mips-y += ide/core.o ide/isa.o ide/pci.o
obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
diff --git a/hw/vga-isa.c b/hw/vga-isa.c
new file mode 100644
index 0000000..7fa31d3
--- /dev/null
+++ b/hw/vga-isa.c
@@ -0,0 +1,50 @@
+/*
+ * QEMU ISA VGA Emulator.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "console.h"
+#include "pc.h"
+#include "vga_int.h"
+#include "pixel_ops.h"
+#include "qemu-timer.h"
+
+int isa_vga_init(void)
+{
+ VGACommonState *s;
+
+ s = qemu_mallocz(sizeof(*s));
+
+ vga_common_init(s, VGA_RAM_SIZE);
+ vga_init(s);
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
+
+ s->ds = graphic_console_init(s->update, s->invalidate,
+ s->screen_dump, s->text_update, s);
+
+#ifdef CONFIG_BOCHS_VBE
+ /* XXX: use optimized standard vga accesses */
+ cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
+ VGA_RAM_SIZE, s->vram_offset);
+#endif
+ return 0;
+}
diff --git a/hw/vga.c b/hw/vga.c
index edd11fc..8b926b0 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2394,27 +2394,6 @@ static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
qemu_register_coalesced_mmio(vram_base + 0x000a0000, 0x20000);
}
-int isa_vga_init(void)
-{
- VGAState *s;
-
- s = qemu_mallocz(sizeof(VGAState));
-
- vga_common_init(s, VGA_RAM_SIZE);
- vga_init(s);
- register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
-
- s->ds = graphic_console_init(s->update, s->invalidate,
- s->screen_dump, s->text_update, s);
-
-#ifdef CONFIG_BOCHS_VBE
- /* XXX: use optimized standard vga accesses */
- cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
- VGA_RAM_SIZE, s->vram_offset);
-#endif
- return 0;
-}
-
int isa_vga_mm_init(target_phys_addr_t vram_base,
target_phys_addr_t ctrl_base, int it_shift)
{
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 07/23] vga: export vga_mem_{read,write}
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (5 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 06/23] vga: split isa bits inco vga-isa.c Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 08/23] vga: split vga-isa-mm.o Juan Quintela
` (16 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/vga.c | 4 ++--
hw/vga_int.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index 8b926b0..06ae2ae 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2113,13 +2113,13 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
dpy_update(s->ds, 0, 0, s->last_width, height);
}
-static CPUReadMemoryFunc * const vga_mem_read[3] = {
+CPUReadMemoryFunc * const vga_mem_read[3] = {
vga_mem_readb,
vga_mem_readw,
vga_mem_readl,
};
-static CPUWriteMemoryFunc * const vga_mem_write[3] = {
+CPUWriteMemoryFunc * const vga_mem_write[3] = {
vga_mem_writeb,
vga_mem_writew,
vga_mem_writel,
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 54b3d5a..ed88595 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -220,3 +220,5 @@ extern const uint8_t gr_mask[16];
#define VGA_RAM_SIZE (8192 * 1024)
+extern CPUReadMemoryFunc * const vga_mem_read[3];
+extern CPUWriteMemoryFunc * const vga_mem_write[3];
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 08/23] vga: split vga-isa-mm.o
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (6 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 07/23] vga: export vga_mem_{read,write} Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 09/23] vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere Juan Quintela
` (15 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
It is only used in mips softmmu, compile only there.
it_shift field was only used for vga_isa_mm, move it from VGACommonState
to ISAVGAMMstate.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
Makefile.target | 2 +-
hw/vga-isa-mm.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/vga.c | 96 ----------------------------------------
hw/vga_int.h | 1 -
4 files changed, 131 insertions(+), 98 deletions(-)
create mode 100644 hw/vga-isa-mm.c
diff --git a/Makefile.target b/Makefile.target
index 07017a5..69094d1 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -212,7 +212,7 @@ obj-ppc-$(CONFIG_FDT) += device_tree.o
obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
-obj-mips-y += vga-pci.o vga-isa.o
+obj-mips-y += vga-pci.o vga-isa.o vga-isa-mm.o
obj-mips-y += g364fb.o jazz_led.o dp8393x.o
obj-mips-y += ide/core.o ide/isa.o ide/pci.o
obj-mips-y += gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c
new file mode 100644
index 0000000..f8fc940
--- /dev/null
+++ b/hw/vga-isa-mm.c
@@ -0,0 +1,130 @@
+/*
+ * QEMU ISA MM VGA Emulator.
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw.h"
+#include "console.h"
+#include "pc.h"
+#include "vga_int.h"
+#include "pixel_ops.h"
+#include "qemu-timer.h"
+
+typedef struct ISAVGAMMState {
+ VGACommonState vga;
+ int it_shift;
+} ISAVGAMMState;
+
+/* Memory mapped interface */
+static uint32_t vga_mm_readb (void *opaque, target_phys_addr_t addr)
+{
+ ISAVGAMMState *s = opaque;
+
+ return vga_ioport_read(&s->vga, addr >> s->it_shift) & 0xff;
+}
+
+static void vga_mm_writeb (void *opaque,
+ target_phys_addr_t addr, uint32_t value)
+{
+ ISAVGAMMState *s = opaque;
+
+ vga_ioport_write(&s->vga, addr >> s->it_shift, value & 0xff);
+}
+
+static uint32_t vga_mm_readw (void *opaque, target_phys_addr_t addr)
+{
+ ISAVGAMMState *s = opaque;
+
+ return vga_ioport_read(&s->vga, addr >> s->it_shift) & 0xffff;
+}
+
+static void vga_mm_writew (void *opaque,
+ target_phys_addr_t addr, uint32_t value)
+{
+ ISAVGAMMState *s = opaque;
+
+ vga_ioport_write(&s->vga, addr >> s->it_shift, value & 0xffff);
+}
+
+static uint32_t vga_mm_readl (void *opaque, target_phys_addr_t addr)
+{
+ ISAVGAMMState *s = opaque;
+
+ return vga_ioport_read(&s->vga, addr >> s->it_shift);
+}
+
+static void vga_mm_writel (void *opaque,
+ target_phys_addr_t addr, uint32_t value)
+{
+ ISAVGAMMState *s = opaque;
+
+ vga_ioport_write(&s->vga, addr >> s->it_shift, value);
+}
+
+static CPUReadMemoryFunc * const vga_mm_read_ctrl[] = {
+ &vga_mm_readb,
+ &vga_mm_readw,
+ &vga_mm_readl,
+};
+
+static CPUWriteMemoryFunc * const vga_mm_write_ctrl[] = {
+ &vga_mm_writeb,
+ &vga_mm_writew,
+ &vga_mm_writel,
+};
+
+static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base,
+ target_phys_addr_t ctrl_base, int it_shift)
+{
+ int s_ioport_ctrl, vga_io_memory;
+
+ s->it_shift = it_shift;
+ s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s);
+ vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
+
+ register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
+
+ cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
+ s->vga.bank_offset = 0;
+ cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory);
+ qemu_register_coalesced_mmio(vram_base + 0x000a0000, 0x20000);
+}
+
+int isa_vga_mm_init(target_phys_addr_t vram_base,
+ target_phys_addr_t ctrl_base, int it_shift)
+{
+ ISAVGAMMState *s;
+
+ s = qemu_mallocz(sizeof(*s));
+
+ vga_common_init(&s->vga, VGA_RAM_SIZE);
+ vga_mm_init(s, vram_base, ctrl_base, it_shift);
+
+ s->vga.ds = graphic_console_init(s->vga.update, s->vga.invalidate,
+ s->vga.screen_dump, s->vga.text_update, s);
+
+#ifdef CONFIG_BOCHS_VBE
+ /* XXX: use optimized standard vga accesses */
+ cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
+ VGA_RAM_SIZE, s->vga.vram_offset);
+#endif
+ return 0;
+}
diff --git a/hw/vga.c b/hw/vga.c
index 06ae2ae..8cd1117 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2319,102 +2319,6 @@ void vga_init(VGAState *s)
qemu_register_coalesced_mmio(isa_mem_base + 0x000a0000, 0x20000);
}
-/* Memory mapped interface */
-static uint32_t vga_mm_readb (void *opaque, target_phys_addr_t addr)
-{
- VGAState *s = opaque;
-
- return vga_ioport_read(s, addr >> s->it_shift) & 0xff;
-}
-
-static void vga_mm_writeb (void *opaque,
- target_phys_addr_t addr, uint32_t value)
-{
- VGAState *s = opaque;
-
- vga_ioport_write(s, addr >> s->it_shift, value & 0xff);
-}
-
-static uint32_t vga_mm_readw (void *opaque, target_phys_addr_t addr)
-{
- VGAState *s = opaque;
-
- return vga_ioport_read(s, addr >> s->it_shift) & 0xffff;
-}
-
-static void vga_mm_writew (void *opaque,
- target_phys_addr_t addr, uint32_t value)
-{
- VGAState *s = opaque;
-
- vga_ioport_write(s, addr >> s->it_shift, value & 0xffff);
-}
-
-static uint32_t vga_mm_readl (void *opaque, target_phys_addr_t addr)
-{
- VGAState *s = opaque;
-
- return vga_ioport_read(s, addr >> s->it_shift);
-}
-
-static void vga_mm_writel (void *opaque,
- target_phys_addr_t addr, uint32_t value)
-{
- VGAState *s = opaque;
-
- vga_ioport_write(s, addr >> s->it_shift, value);
-}
-
-static CPUReadMemoryFunc * const vga_mm_read_ctrl[] = {
- &vga_mm_readb,
- &vga_mm_readw,
- &vga_mm_readl,
-};
-
-static CPUWriteMemoryFunc * const vga_mm_write_ctrl[] = {
- &vga_mm_writeb,
- &vga_mm_writew,
- &vga_mm_writel,
-};
-
-static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base,
- target_phys_addr_t ctrl_base, int it_shift)
-{
- int s_ioport_ctrl, vga_io_memory;
-
- s->it_shift = it_shift;
- s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s);
- vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s);
-
- register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s);
-
- cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl);
- s->bank_offset = 0;
- cpu_register_physical_memory(vram_base + 0x000a0000, 0x20000, vga_io_memory);
- qemu_register_coalesced_mmio(vram_base + 0x000a0000, 0x20000);
-}
-
-int isa_vga_mm_init(target_phys_addr_t vram_base,
- target_phys_addr_t ctrl_base, int it_shift)
-{
- VGAState *s;
-
- s = qemu_mallocz(sizeof(VGAState));
-
- vga_common_init(s, VGA_RAM_SIZE);
- vga_mm_init(s, vram_base, ctrl_base, it_shift);
-
- s->ds = graphic_console_init(s->update, s->invalidate,
- s->screen_dump, s->text_update, s);
-
-#ifdef CONFIG_BOCHS_VBE
- /* XXX: use optimized standard vga accesses */
- cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
- VGA_RAM_SIZE, s->vram_offset);
-#endif
- return 0;
-}
-
/********************************************************/
/* vga screen dump */
diff --git a/hw/vga_int.h b/hw/vga_int.h
index ed88595..9ff205d 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -109,7 +109,6 @@ typedef struct VGACommonState {
uint32_t lfb_vram_mapped; /* whether 0xa0000 is mapped as ram */
uint32_t bios_offset;
uint32_t bios_size;
- int it_shift;
uint32_t latch;
uint8_t sr_index;
uint8_t sr[256];
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 09/23] vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (7 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 08/23] vga: split vga-isa-mm.o Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 10/23] cirrus_vga: Add a VGACommonState local var to cirrus_vga_ioport_{read, write} Juan Quintela
` (14 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 11 +++--------
hw/vga.c | 20 ++++++++++++++------
hw/vga_int.h | 2 ++
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 5f57107..7e63399 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2661,10 +2661,7 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
CirrusVGAState *s = opaque;
int val, index;
- /* check port range access depending on color/monochrome mode */
- if ((addr >= 0x3b0 && addr <= 0x3bf && (s->vga.msr & MSR_COLOR_EMULATION))
- || (addr >= 0x3d0 && addr <= 0x3df
- && !(s->vga.msr & MSR_COLOR_EMULATION))) {
+ if (vga_ioport_invalid(&s->vga, addr)) {
val = 0xff;
} else {
switch (addr) {
@@ -2768,11 +2765,9 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
int index;
/* check port range access depending on color/monochrome mode */
- if ((addr >= 0x3b0 && addr <= 0x3bf && (s->vga.msr & MSR_COLOR_EMULATION))
- || (addr >= 0x3d0 && addr <= 0x3df
- && !(s->vga.msr & MSR_COLOR_EMULATION)))
+ if (vga_ioport_invalid(&s->vga, addr)) {
return;
-
+ }
#ifdef DEBUG_VGA
printf("VGA: write addr=0x%04x data=0x%02x\n", addr, val);
#endif
diff --git a/hw/vga.c b/hw/vga.c
index 8cd1117..b4c31ce 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -284,14 +284,23 @@ static uint8_t vga_dumb_retrace(VGAState *s)
return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE);
}
+int vga_ioport_invalid(VGACommonState *s, uint32_t addr)
+{
+ if (s->msr & MSR_COLOR_EMULATION) {
+ /* Color */
+ return (addr >= 0x3b0 && addr <= 0x3bf);
+ } else {
+ /* Monochrome */
+ return (addr >= 0x3d0 && addr <= 0x3df);
+ }
+}
+
uint32_t vga_ioport_read(void *opaque, uint32_t addr)
{
VGACommonState *s = opaque;
int val, index;
- /* check port range access depending on color/monochrome mode */
- if ((addr >= 0x3b0 && addr <= 0x3bf && (s->msr & MSR_COLOR_EMULATION)) ||
- (addr >= 0x3d0 && addr <= 0x3df && !(s->msr & MSR_COLOR_EMULATION))) {
+ if (vga_ioport_invalid(s, addr)) {
val = 0xff;
} else {
switch(addr) {
@@ -383,10 +392,9 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
int index;
/* check port range access depending on color/monochrome mode */
- if ((addr >= 0x3b0 && addr <= 0x3bf && (s->msr & MSR_COLOR_EMULATION)) ||
- (addr >= 0x3d0 && addr <= 0x3df && !(s->msr & MSR_COLOR_EMULATION)))
+ if (vga_ioport_invalid(s, addr)) {
return;
-
+ }
#ifdef DEBUG_VGA
printf("VGA: write addr=0x%04x data=0x%02x\n", addr, val);
#endif
diff --git a/hw/vga_int.h b/hw/vga_int.h
index 9ff205d..c162c07 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -214,6 +214,8 @@ void vga_draw_cursor_line_32(uint8_t *d1, const uint8_t *src1,
unsigned int color0, unsigned int color1,
unsigned int color_xor);
+int vga_ioport_invalid(VGACommonState *s, uint32_t addr);
+
extern const uint8_t sr_mask[8];
extern const uint8_t gr_mask[16];
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 10/23] cirrus_vga: Add a VGACommonState local var to cirrus_vga_ioport_{read, write}
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (8 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 09/23] vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 11/23] vga: change tabs to spaces Juan Quintela
` (13 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 162 ++++++++++++++++++++++++++++---------------------------
1 files changed, 82 insertions(+), 80 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 7e63399..b8a3ea2 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2658,95 +2658,96 @@ static void cirrus_update_memory_access(CirrusVGAState *s)
static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
{
- CirrusVGAState *s = opaque;
+ CirrusVGAState *c = opaque;
+ VGACommonState *s = &c->vga;
int val, index;
- if (vga_ioport_invalid(&s->vga, addr)) {
+ if (vga_ioport_invalid(s, addr)) {
val = 0xff;
} else {
switch (addr) {
case 0x3c0:
- if (s->vga.ar_flip_flop == 0) {
- val = s->vga.ar_index;
+ if (s->ar_flip_flop == 0) {
+ val = s->ar_index;
} else {
val = 0;
}
break;
case 0x3c1:
- index = s->vga.ar_index & 0x1f;
+ index = s->ar_index & 0x1f;
if (index < 21)
- val = s->vga.ar[index];
+ val = s->ar[index];
else
val = 0;
break;
case 0x3c2:
- val = s->vga.st00;
+ val = s->st00;
break;
case 0x3c4:
- val = s->vga.sr_index;
+ val = s->sr_index;
break;
case 0x3c5:
- if (cirrus_hook_read_sr(s, s->vga.sr_index, &val))
+ if (cirrus_hook_read_sr(c, s->sr_index, &val))
break;
- val = s->vga.sr[s->vga.sr_index];
+ val = s->sr[s->sr_index];
#ifdef DEBUG_VGA_REG
- printf("vga: read SR%x = 0x%02x\n", s->vga.sr_index, val);
+ printf("vga: read SR%x = 0x%02x\n", s->sr_index, val);
#endif
break;
case 0x3c6:
- cirrus_read_hidden_dac(s, &val);
+ cirrus_read_hidden_dac(c, &val);
break;
case 0x3c7:
- val = s->vga.dac_state;
+ val = s->dac_state;
break;
case 0x3c8:
- val = s->vga.dac_write_index;
- s->cirrus_hidden_dac_lockindex = 0;
+ val = s->dac_write_index;
+ c->cirrus_hidden_dac_lockindex = 0;
break;
case 0x3c9:
- if (cirrus_hook_read_palette(s, &val))
+ if (cirrus_hook_read_palette(c, &val))
break;
- val = s->vga.palette[s->vga.dac_read_index * 3 + s->vga.dac_sub_index];
- if (++s->vga.dac_sub_index == 3) {
- s->vga.dac_sub_index = 0;
- s->vga.dac_read_index++;
+ val = s->palette[s->dac_read_index * 3 + s->dac_sub_index];
+ if (++s->dac_sub_index == 3) {
+ s->dac_sub_index = 0;
+ s->dac_read_index++;
}
break;
case 0x3ca:
- val = s->vga.fcr;
+ val = s->fcr;
break;
case 0x3cc:
- val = s->vga.msr;
+ val = s->msr;
break;
case 0x3ce:
- val = s->vga.gr_index;
+ val = s->gr_index;
break;
case 0x3cf:
- if (cirrus_hook_read_gr(s, s->vga.gr_index, &val))
+ if (cirrus_hook_read_gr(c, s->gr_index, &val))
break;
- val = s->vga.gr[s->vga.gr_index];
+ val = s->gr[s->gr_index];
#ifdef DEBUG_VGA_REG
- printf("vga: read GR%x = 0x%02x\n", s->vga.gr_index, val);
+ printf("vga: read GR%x = 0x%02x\n", s->gr_index, val);
#endif
break;
case 0x3b4:
case 0x3d4:
- val = s->vga.cr_index;
+ val = s->cr_index;
break;
case 0x3b5:
case 0x3d5:
- if (cirrus_hook_read_cr(s, s->vga.cr_index, &val))
+ if (cirrus_hook_read_cr(c, s->cr_index, &val))
break;
- val = s->vga.cr[s->vga.cr_index];
+ val = s->cr[s->cr_index];
#ifdef DEBUG_VGA_REG
- printf("vga: read CR%x = 0x%02x\n", s->vga.cr_index, val);
+ printf("vga: read CR%x = 0x%02x\n", s->cr_index, val);
#endif
break;
case 0x3ba:
case 0x3da:
/* just toggle to fool polling */
- val = s->vga.st01 = s->vga.retrace(&s->vga);
- s->vga.ar_flip_flop = 0;
+ val = s->st01 = s->retrace(s);
+ s->ar_flip_flop = 0;
break;
default:
val = 0x00;
@@ -2761,11 +2762,12 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
{
- CirrusVGAState *s = opaque;
+ CirrusVGAState *c = opaque;
+ VGACommonState *s = &c->vga;
int index;
/* check port range access depending on color/monochrome mode */
- if (vga_ioport_invalid(&s->vga, addr)) {
+ if (vga_ioport_invalid(s, addr)) {
return;
}
#ifdef DEBUG_VGA
@@ -2774,120 +2776,120 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
switch (addr) {
case 0x3c0:
- if (s->vga.ar_flip_flop == 0) {
+ if (s->ar_flip_flop == 0) {
val &= 0x3f;
- s->vga.ar_index = val;
+ s->ar_index = val;
} else {
- index = s->vga.ar_index & 0x1f;
+ index = s->ar_index & 0x1f;
switch (index) {
case 0x00 ... 0x0f:
- s->vga.ar[index] = val & 0x3f;
+ s->ar[index] = val & 0x3f;
break;
case 0x10:
- s->vga.ar[index] = val & ~0x10;
+ s->ar[index] = val & ~0x10;
break;
case 0x11:
- s->vga.ar[index] = val;
+ s->ar[index] = val;
break;
case 0x12:
- s->vga.ar[index] = val & ~0xc0;
+ s->ar[index] = val & ~0xc0;
break;
case 0x13:
- s->vga.ar[index] = val & ~0xf0;
+ s->ar[index] = val & ~0xf0;
break;
case 0x14:
- s->vga.ar[index] = val & ~0xf0;
+ s->ar[index] = val & ~0xf0;
break;
default:
break;
}
}
- s->vga.ar_flip_flop ^= 1;
+ s->ar_flip_flop ^= 1;
break;
case 0x3c2:
- s->vga.msr = val & ~0x10;
- s->vga.update_retrace_info(&s->vga);
+ s->msr = val & ~0x10;
+ s->update_retrace_info(s);
break;
case 0x3c4:
- s->vga.sr_index = val;
+ s->sr_index = val;
break;
case 0x3c5:
- if (cirrus_hook_write_sr(s, s->vga.sr_index, val))
+ if (cirrus_hook_write_sr(c, s->sr_index, val))
break;
#ifdef DEBUG_VGA_REG
- printf("vga: write SR%x = 0x%02x\n", s->vga.sr_index, val);
+ printf("vga: write SR%x = 0x%02x\n", s->sr_index, val);
#endif
- s->vga.sr[s->vga.sr_index] = val & sr_mask[s->vga.sr_index];
- if (s->vga.sr_index == 1) s->vga.update_retrace_info(&s->vga);
+ s->sr[s->sr_index] = val & sr_mask[s->sr_index];
+ if (s->sr_index == 1) s->update_retrace_info(s);
break;
case 0x3c6:
- cirrus_write_hidden_dac(s, val);
+ cirrus_write_hidden_dac(c, val);
break;
case 0x3c7:
- s->vga.dac_read_index = val;
- s->vga.dac_sub_index = 0;
- s->vga.dac_state = 3;
+ s->dac_read_index = val;
+ s->dac_sub_index = 0;
+ s->dac_state = 3;
break;
case 0x3c8:
- s->vga.dac_write_index = val;
- s->vga.dac_sub_index = 0;
- s->vga.dac_state = 0;
+ s->dac_write_index = val;
+ s->dac_sub_index = 0;
+ s->dac_state = 0;
break;
case 0x3c9:
- if (cirrus_hook_write_palette(s, val))
+ if (cirrus_hook_write_palette(c, val))
break;
- s->vga.dac_cache[s->vga.dac_sub_index] = val;
- if (++s->vga.dac_sub_index == 3) {
- memcpy(&s->vga.palette[s->vga.dac_write_index * 3], s->vga.dac_cache, 3);
- s->vga.dac_sub_index = 0;
- s->vga.dac_write_index++;
+ s->dac_cache[s->dac_sub_index] = val;
+ if (++s->dac_sub_index == 3) {
+ memcpy(&s->palette[s->dac_write_index * 3], s->dac_cache, 3);
+ s->dac_sub_index = 0;
+ s->dac_write_index++;
}
break;
case 0x3ce:
- s->vga.gr_index = val;
+ s->gr_index = val;
break;
case 0x3cf:
- if (cirrus_hook_write_gr(s, s->vga.gr_index, val))
+ if (cirrus_hook_write_gr(c, s->gr_index, val))
break;
#ifdef DEBUG_VGA_REG
- printf("vga: write GR%x = 0x%02x\n", s->vga.gr_index, val);
+ printf("vga: write GR%x = 0x%02x\n", s->gr_index, val);
#endif
- s->vga.gr[s->vga.gr_index] = val & gr_mask[s->vga.gr_index];
+ s->gr[s->gr_index] = val & gr_mask[s->gr_index];
break;
case 0x3b4:
case 0x3d4:
- s->vga.cr_index = val;
+ s->cr_index = val;
break;
case 0x3b5:
case 0x3d5:
- if (cirrus_hook_write_cr(s, s->vga.cr_index, val))
+ if (cirrus_hook_write_cr(c, s->cr_index, val))
break;
#ifdef DEBUG_VGA_REG
- printf("vga: write CR%x = 0x%02x\n", s->vga.cr_index, val);
+ printf("vga: write CR%x = 0x%02x\n", s->cr_index, val);
#endif
/* handle CR0-7 protection */
- if ((s->vga.cr[0x11] & 0x80) && s->vga.cr_index <= 7) {
+ if ((s->cr[0x11] & 0x80) && s->cr_index <= 7) {
/* can always write bit 4 of CR7 */
- if (s->vga.cr_index == 7)
- s->vga.cr[7] = (s->vga.cr[7] & ~0x10) | (val & 0x10);
+ if (s->cr_index == 7)
+ s->cr[7] = (s->cr[7] & ~0x10) | (val & 0x10);
return;
}
- switch (s->vga.cr_index) {
+ switch (s->cr_index) {
case 0x01: /* horizontal display end */
case 0x07:
case 0x09:
case 0x0c:
case 0x0d:
case 0x12: /* vertical display end */
- s->vga.cr[s->vga.cr_index] = val;
+ s->cr[s->cr_index] = val;
break;
default:
- s->vga.cr[s->vga.cr_index] = val;
+ s->cr[s->cr_index] = val;
break;
}
- switch(s->vga.cr_index) {
+ switch(s->cr_index) {
case 0x00:
case 0x04:
case 0x05:
@@ -2895,13 +2897,13 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
case 0x07:
case 0x11:
case 0x17:
- s->vga.update_retrace_info(&s->vga);
+ s->update_retrace_info(s);
break;
}
break;
case 0x3ba:
case 0x3da:
- s->vga.fcr = val & 0x10;
+ s->fcr = val & 0x10;
break;
}
}
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 11/23] vga: change tabs to spaces
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (9 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 10/23] cirrus_vga: Add a VGACommonState local var to cirrus_vga_ioport_{read, write} Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 12/23] cirrus_vga: make cirrus_read_hidden_dac() return its result Juan Quintela
` (12 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/vga.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index b4c31ce..0d4e558 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -333,9 +333,9 @@ uint32_t vga_ioport_read(void *opaque, uint32_t addr)
case 0x3c7:
val = s->dac_state;
break;
- case 0x3c8:
- val = s->dac_write_index;
- break;
+ case 0x3c8:
+ val = s->dac_write_index;
+ break;
case 0x3c9:
val = s->palette[s->dac_read_index * 3 + s->dac_sub_index];
if (++s->dac_sub_index == 3) {
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 12/23] cirrus_vga: make cirrus_read_hidden_dac() return its result
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (10 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 11/23] vga: change tabs to spaces Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 13/23] vga and cirrus_vga: substitute switch for equivalent assigntment Juan Quintela
` (11 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index b8a3ea2..b2b6e85 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1399,13 +1399,13 @@ cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)
*
***************************************/
-static void cirrus_read_hidden_dac(CirrusVGAState * s, int *reg_value)
+static int cirrus_read_hidden_dac(CirrusVGAState * s)
{
- *reg_value = 0xff;
if (++s->cirrus_hidden_dac_lockindex == 5) {
- *reg_value = s->cirrus_hidden_dac_data;
- s->cirrus_hidden_dac_lockindex = 0;
+ s->cirrus_hidden_dac_lockindex = 0;
+ return s->cirrus_hidden_dac_data;
}
+ return 0xff;
}
static void cirrus_write_hidden_dac(CirrusVGAState * s, int reg_value)
@@ -2695,7 +2695,7 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
#endif
break;
case 0x3c6:
- cirrus_read_hidden_dac(c, &val);
+ val = cirrus_read_hidden_dac(c);
break;
case 0x3c7:
val = s->dac_state;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 13/23] vga and cirrus_vga: substitute switch for equivalent assigntment
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (11 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 12/23] cirrus_vga: make cirrus_read_hidden_dac() return its result Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 14/23] vga: Rename last VGAState occurrences to VGACommonState Juan Quintela
` (10 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 15 +--------------
hw/vga.c | 14 +-------------
2 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index b2b6e85..f247304 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2874,20 +2874,7 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->cr[7] = (s->cr[7] & ~0x10) | (val & 0x10);
return;
}
- switch (s->cr_index) {
- case 0x01: /* horizontal display end */
- case 0x07:
- case 0x09:
- case 0x0c:
- case 0x0d:
- case 0x12: /* vertical display end */
- s->cr[s->cr_index] = val;
- break;
-
- default:
- s->cr[s->cr_index] = val;
- break;
- }
+ s->cr[s->cr_index] = val;
switch(s->cr_index) {
case 0x00:
diff --git a/hw/vga.c b/hw/vga.c
index 0d4e558..ff97aa7 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -488,19 +488,7 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->cr[7] = (s->cr[7] & ~0x10) | (val & 0x10);
return;
}
- switch(s->cr_index) {
- case 0x01: /* horizontal display end */
- case 0x07:
- case 0x09:
- case 0x0c:
- case 0x0d:
- case 0x12: /* vertical display end */
- s->cr[s->cr_index] = val;
- break;
- default:
- s->cr[s->cr_index] = val;
- break;
- }
+ s->cr[s->cr_index] = val;
switch(s->cr_index) {
case 0x00:
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 14/23] vga: Rename last VGAState occurrences to VGACommonState
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (12 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 13/23] vga and cirrus_vga: substitute switch for equivalent assigntment Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 15/23] cirrus_vga: rename cirrus_hook_read_sr() cirrus_vga_read_sr() Juan Quintela
` (9 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/vga.c | 60 +++++++++++++++++++++++++---------------------------
hw/vga_template.h | 20 ++++++++--------
2 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/hw/vga.c b/hw/vga.c
index ff97aa7..5b16cc3 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -148,18 +148,16 @@ static uint32_t expand4[256];
static uint16_t expand2[256];
static uint8_t expand4to8[16];
-typedef VGACommonState VGAState;
-
static void vga_screen_dump(void *opaque, const char *filename);
static char *screen_dump_filename;
static DisplayChangeListener *screen_dump_dcl;
-static void vga_dumb_update_retrace_info(VGAState *s)
+static void vga_dumb_update_retrace_info(VGACommonState *s)
{
(void) s;
}
-static void vga_precise_update_retrace_info(VGAState *s)
+static void vga_precise_update_retrace_info(VGACommonState *s)
{
int htotal_chars;
int hretr_start_char;
@@ -250,7 +248,7 @@ static void vga_precise_update_retrace_info(VGAState *s)
#endif
}
-static uint8_t vga_precise_retrace(VGAState *s)
+static uint8_t vga_precise_retrace(VGACommonState *s)
{
struct vga_precise_retrace *r = &s->retrace_info.precise;
uint8_t val = s->st01 & ~(ST01_V_RETRACE | ST01_DISP_ENABLE);
@@ -279,7 +277,7 @@ static uint8_t vga_precise_retrace(VGAState *s)
}
}
-static uint8_t vga_dumb_retrace(VGAState *s)
+static uint8_t vga_dumb_retrace(VGACommonState *s)
{
return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE);
}
@@ -512,7 +510,7 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
#ifdef CONFIG_BOCHS_VBE
static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
uint32_t val;
val = s->vbe_index;
return val;
@@ -520,7 +518,7 @@ static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
static uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
uint32_t val;
if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
@@ -554,13 +552,13 @@ static uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
static void vbe_ioport_write_index(void *opaque, uint32_t addr, uint32_t val)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
s->vbe_index = val;
}
static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
#ifdef DEBUG_BOCHS_VBE
@@ -706,7 +704,7 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
/* called for accesses between 0xa0000 and 0xc0000 */
uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int memory_map_mode, plane;
uint32_t ret;
@@ -793,7 +791,7 @@ static uint32_t vga_mem_readl(void *opaque, target_phys_addr_t addr)
/* called for accesses between 0xa0000 and 0xc0000 */
void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int memory_map_mode, plane, write_mode, b, func_select, mask;
uint32_t write_mask, bit_mask, set_mask;
@@ -957,7 +955,7 @@ typedef void vga_draw_glyph8_func(uint8_t *d, int linesize,
typedef void vga_draw_glyph9_func(uint8_t *d, int linesize,
const uint8_t *font_ptr, int h,
uint32_t fgcol, uint32_t bgcol, int dup9);
-typedef void vga_draw_line_func(VGAState *s1, uint8_t *d,
+typedef void vga_draw_line_func(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width);
#define DEPTH 8
@@ -1042,7 +1040,7 @@ static unsigned int rgb_to_pixel32bgr_dup(unsigned int r, unsigned int g, unsign
}
/* return true if the palette was modified */
-static int update_palette16(VGAState *s)
+static int update_palette16(VGACommonState *s)
{
int full_update, i;
uint32_t v, col, *palette;
@@ -1068,7 +1066,7 @@ static int update_palette16(VGAState *s)
}
/* return true if the palette was modified */
-static int update_palette256(VGAState *s)
+static int update_palette256(VGACommonState *s)
{
int full_update, i;
uint32_t v, col, *palette;
@@ -1095,7 +1093,7 @@ static int update_palette256(VGAState *s)
return full_update;
}
-static void vga_get_offsets(VGAState *s,
+static void vga_get_offsets(VGACommonState *s,
uint32_t *pline_offset,
uint32_t *pstart_addr,
uint32_t *pline_compare)
@@ -1127,7 +1125,7 @@ static void vga_get_offsets(VGAState *s,
}
/* update start_addr and line_offset. Return TRUE if modified */
-static int update_basic_params(VGAState *s)
+static int update_basic_params(VGACommonState *s)
{
int full_update;
uint32_t start_addr, line_offset, line_compare;
@@ -1216,7 +1214,7 @@ static const uint8_t cursor_glyph[32 * 4] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
-static void vga_get_text_resolution(VGAState *s, int *pwidth, int *pheight,
+static void vga_get_text_resolution(VGACommonState *s, int *pwidth, int *pheight,
int *pcwidth, int *pcheight)
{
int width, cwidth, height, cheight;
@@ -1265,7 +1263,7 @@ static rgb_to_pixel_dup_func *rgb_to_pixel_dup_table[NB_DEPTHS] = {
* - underline
* - flashing
*/
-static void vga_draw_text(VGAState *s, int full_update)
+static void vga_draw_text(VGACommonState *s, int full_update)
{
int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;
int cx_min, cx_max, linesize, x_incr;
@@ -1520,7 +1518,7 @@ static vga_draw_line_func *vga_draw_line_table[NB_DEPTHS * VGA_DRAW_LINE_NB] = {
vga_draw_line32_16bgr,
};
-static int vga_get_bpp(VGAState *s)
+static int vga_get_bpp(VGACommonState *s)
{
int ret;
#ifdef CONFIG_BOCHS_VBE
@@ -1534,7 +1532,7 @@ static int vga_get_bpp(VGAState *s)
return ret;
}
-static void vga_get_resolution(VGAState *s, int *pwidth, int *pheight)
+static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight)
{
int width, height;
@@ -1555,7 +1553,7 @@ static void vga_get_resolution(VGAState *s, int *pwidth, int *pheight)
*pheight = height;
}
-void vga_invalidate_scanlines(VGAState *s, int y1, int y2)
+void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2)
{
int y;
if (y1 >= VGA_MAX_HEIGHT)
@@ -1567,7 +1565,7 @@ void vga_invalidate_scanlines(VGAState *s, int y1, int y2)
}
}
-static void vga_sync_dirty_bitmap(VGAState *s)
+static void vga_sync_dirty_bitmap(VGACommonState *s)
{
if (s->map_addr)
cpu_physical_sync_dirty_bitmap(s->map_addr, s->map_end);
@@ -1581,7 +1579,7 @@ static void vga_sync_dirty_bitmap(VGAState *s)
/*
* graphic modes
*/
-static void vga_draw_graphic(VGAState *s, int full_update)
+static void vga_draw_graphic(VGACommonState *s, int full_update)
{
int y1, y, update, linesize, y_start, double_scan, mask, depth;
int width, height, shift_control, line_offset, bwidth, bits;
@@ -1798,7 +1796,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);
}
-static void vga_draw_blank(VGAState *s, int full_update)
+static void vga_draw_blank(VGACommonState *s, int full_update)
{
int i, w, val;
uint8_t *d;
@@ -1830,7 +1828,7 @@ static void vga_draw_blank(VGAState *s, int full_update)
static void vga_update_display(void *opaque)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int full_update, graphic_mode;
if (ds_get_bits_per_pixel(s->ds) == 0) {
@@ -1865,7 +1863,7 @@ static void vga_update_display(void *opaque)
/* force a full display refresh */
static void vga_invalidate_display(void *opaque)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
s->full_update = 1;
}
@@ -1939,7 +1937,7 @@ void vga_common_reset(VGACommonState *s)
static void vga_reset(void *opaque)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
vga_common_reset(s);
}
@@ -1951,7 +1949,7 @@ static void vga_reset(void *opaque)
* instead of doing a full vga_update_display() */
static void vga_update_text(void *opaque, console_ch_t *chardata)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
int graphic_mode, i, cursor_offset, cursor_visible;
int cw, cheight, width, height, size, c_min, c_max;
uint32_t *src;
@@ -2265,7 +2263,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)
}
/* used by both ISA and PCI */
-void vga_init(VGAState *s)
+void vga_init(VGACommonState *s)
{
int vga_io_memory;
@@ -2389,7 +2387,7 @@ static DisplayChangeListener* vga_screen_dump_init(DisplayState *ds)
available */
static void vga_screen_dump(void *opaque, const char *filename)
{
- VGAState *s = opaque;
+ VGACommonState *s = opaque;
if (!screen_dump_dcl)
screen_dump_dcl = vga_screen_dump_init(s->ds);
diff --git a/hw/vga_template.h b/hw/vga_template.h
index 8f32a77..681425f 100644
--- a/hw/vga_template.h
+++ b/hw/vga_template.h
@@ -154,7 +154,7 @@ static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize,
/*
* 4 color mode
*/
-static void glue(vga_draw_line2_, DEPTH)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line2_, DEPTH)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
uint32_t plane_mask, *palette, data, v;
@@ -196,7 +196,7 @@ static void glue(vga_draw_line2_, DEPTH)(VGAState *s1, uint8_t *d,
/*
* 4 color mode, dup2 horizontal
*/
-static void glue(vga_draw_line2d2_, DEPTH)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line2d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
uint32_t plane_mask, *palette, data, v;
@@ -229,7 +229,7 @@ static void glue(vga_draw_line2d2_, DEPTH)(VGAState *s1, uint8_t *d,
/*
* 16 color mode
*/
-static void glue(vga_draw_line4_, DEPTH)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line4_, DEPTH)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
uint32_t plane_mask, data, v, *palette;
@@ -261,7 +261,7 @@ static void glue(vga_draw_line4_, DEPTH)(VGAState *s1, uint8_t *d,
/*
* 16 color mode, dup2 horizontal
*/
-static void glue(vga_draw_line4d2_, DEPTH)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line4d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
uint32_t plane_mask, data, v, *palette;
@@ -295,7 +295,7 @@ static void glue(vga_draw_line4d2_, DEPTH)(VGAState *s1, uint8_t *d,
*
* XXX: add plane_mask support (never used in standard VGA modes)
*/
-static void glue(vga_draw_line8d2_, DEPTH)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line8d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
uint32_t *palette;
@@ -318,7 +318,7 @@ static void glue(vga_draw_line8d2_, DEPTH)(VGAState *s1, uint8_t *d,
*
* XXX: add plane_mask support (never used in standard VGA modes)
*/
-static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line8_, DEPTH)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
uint32_t *palette;
@@ -414,7 +414,7 @@ void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1,
/*
* 15 bit color
*/
-static void glue(vga_draw_line15_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line15_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
#if DEPTH == 15 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
@@ -439,7 +439,7 @@ static void glue(vga_draw_line15_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
/*
* 16 bit color
*/
-static void glue(vga_draw_line16_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line16_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
@@ -464,7 +464,7 @@ static void glue(vga_draw_line16_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
/*
* 24 bit color
*/
-static void glue(vga_draw_line24_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line24_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
int w;
@@ -490,7 +490,7 @@ static void glue(vga_draw_line24_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
/*
* 32 bit color
*/
-static void glue(vga_draw_line32_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
+static void glue(vga_draw_line32_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
const uint8_t *s, int width)
{
#if DEPTH == 32 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) && !defined(BGR_FORMAT)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 15/23] cirrus_vga: rename cirrus_hook_read_sr() cirrus_vga_read_sr()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (13 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 14/23] vga: Rename last VGAState occurrences to VGACommonState Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 16/23] cirrus_vga: rename cirrus_hook_write_sr() cirrus_vga_write_sr() Juan Quintela
` (8 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
And make it a real function
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 32 ++++++++++++--------------------
1 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index f247304..d83171a 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1236,19 +1236,17 @@ static void cirrus_update_bank_ptr(CirrusVGAState * s, unsigned bank_index)
*
***************************************/
-static int
-cirrus_hook_read_sr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
+static int cirrus_vga_read_sr(CirrusVGAState * s)
{
- switch (reg_index) {
+ switch (s->vga.sr_index) {
case 0x00: // Standard VGA
case 0x01: // Standard VGA
case 0x02: // Standard VGA
case 0x03: // Standard VGA
case 0x04: // Standard VGA
- return CIRRUS_HOOK_NOT_HANDLED;
+ return s->vga.sr[s->vga.sr_index];
case 0x06: // Unlock Cirrus extensions
- *reg_value = s->vga.sr[reg_index];
- break;
+ return s->vga.sr[s->vga.sr_index];
case 0x10:
case 0x30:
case 0x50:
@@ -1257,8 +1255,7 @@ cirrus_hook_read_sr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
case 0xb0:
case 0xd0:
case 0xf0: // Graphics Cursor X
- *reg_value = s->vga.sr[0x10];
- break;
+ return s->vga.sr[0x10];
case 0x11:
case 0x31:
case 0x51:
@@ -1267,8 +1264,7 @@ cirrus_hook_read_sr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
case 0xb1:
case 0xd1:
case 0xf1: // Graphics Cursor Y
- *reg_value = s->vga.sr[0x11];
- break;
+ return s->vga.sr[0x11];
case 0x05: // ???
case 0x07: // Extended Sequencer Mode
case 0x08: // EEPROM Control
@@ -1294,19 +1290,16 @@ cirrus_hook_read_sr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
case 0x1e: // VCLK 3 Denominator & Post
case 0x1f: // BIOS Write Enable and MCLK select
#ifdef DEBUG_CIRRUS
- printf("cirrus: handled inport sr_index %02x\n", reg_index);
+ printf("cirrus: handled inport sr_index %02x\n", s->vga.sr_index);
#endif
- *reg_value = s->vga.sr[reg_index];
- break;
+ return s->vga.sr[s->vga.sr_index];
default:
#ifdef DEBUG_CIRRUS
- printf("cirrus: inport sr_index %02x\n", reg_index);
+ printf("cirrus: inport sr_index %02x\n", s->vga.sr_index);
#endif
- *reg_value = 0xff;
+ return 0xff;
break;
}
-
- return CIRRUS_HOOK_HANDLED;
}
static int
@@ -2687,9 +2680,8 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
val = s->sr_index;
break;
case 0x3c5:
- if (cirrus_hook_read_sr(c, s->sr_index, &val))
- break;
- val = s->sr[s->sr_index];
+ val = cirrus_vga_read_sr(c);
+ break;
#ifdef DEBUG_VGA_REG
printf("vga: read SR%x = 0x%02x\n", s->sr_index, val);
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 16/23] cirrus_vga: rename cirrus_hook_write_sr() cirrus_vga_write_sr()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (14 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 15/23] cirrus_vga: rename cirrus_hook_read_sr() cirrus_vga_read_sr() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 17/23] cirrus_vga: rename cirrus_hook_read_palette() cirrus_vga_read_palette() Juan Quintela
` (7 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 45 ++++++++++++++++++++++-----------------------
1 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index d83171a..b369849 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1302,22 +1302,24 @@ static int cirrus_vga_read_sr(CirrusVGAState * s)
}
}
-static int
-cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)
+static void cirrus_vga_write_sr(CirrusVGAState * s, uint32_t val)
{
- switch (reg_index) {
+ switch (s->vga.sr_index) {
case 0x00: // Standard VGA
case 0x01: // Standard VGA
case 0x02: // Standard VGA
case 0x03: // Standard VGA
case 0x04: // Standard VGA
- return CIRRUS_HOOK_NOT_HANDLED;
+ s->vga.sr[s->vga.sr_index] = val & sr_mask[s->vga.sr_index];
+ if (s->vga.sr_index == 1)
+ s->vga.update_retrace_info(&s->vga);
+ break;
case 0x06: // Unlock Cirrus extensions
- reg_value &= 0x17;
- if (reg_value == 0x12) {
- s->vga.sr[reg_index] = 0x12;
+ val &= 0x17;
+ if (val == 0x12) {
+ s->vga.sr[s->vga.sr_index] = 0x12;
} else {
- s->vga.sr[reg_index] = 0x0f;
+ s->vga.sr[s->vga.sr_index] = 0x0f;
}
break;
case 0x10:
@@ -1328,8 +1330,8 @@ cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)
case 0xb0:
case 0xd0:
case 0xf0: // Graphics Cursor X
- s->vga.sr[0x10] = reg_value;
- s->hw_cursor_x = (reg_value << 3) | (reg_index >> 5);
+ s->vga.sr[0x10] = val;
+ s->hw_cursor_x = (val << 3) | (s->vga.sr_index >> 5);
break;
case 0x11:
case 0x31:
@@ -1339,8 +1341,8 @@ cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)
case 0xb1:
case 0xd1:
case 0xf1: // Graphics Cursor Y
- s->vga.sr[0x11] = reg_value;
- s->hw_cursor_y = (reg_value << 3) | (reg_index >> 5);
+ s->vga.sr[0x11] = val;
+ s->hw_cursor_y = (val << 3) | (s->vga.sr_index >> 5);
break;
case 0x07: // Extended Sequencer Mode
cirrus_update_memory_access(s);
@@ -1365,25 +1367,24 @@ cirrus_hook_write_sr(CirrusVGAState * s, unsigned reg_index, int reg_value)
case 0x1d: // VCLK 2 Denominator & Post
case 0x1e: // VCLK 3 Denominator & Post
case 0x1f: // BIOS Write Enable and MCLK select
- s->vga.sr[reg_index] = reg_value;
+ s->vga.sr[s->vga.sr_index] = val;
#ifdef DEBUG_CIRRUS
printf("cirrus: handled outport sr_index %02x, sr_value %02x\n",
- reg_index, reg_value);
+ s->vga.sr_index, val);
#endif
break;
case 0x17: // Configuration Readback and Extended Control
- s->vga.sr[reg_index] = (s->vga.sr[reg_index] & 0x38) | (reg_value & 0xc7);
+ s->vga.sr[s->vga.sr_index] = (s->vga.sr[s->vga.sr_index] & 0x38)
+ | (val & 0xc7);
cirrus_update_memory_access(s);
break;
default:
#ifdef DEBUG_CIRRUS
- printf("cirrus: outport sr_index %02x, sr_value %02x\n", reg_index,
- reg_value);
+ printf("cirrus: outport sr_index %02x, sr_value %02x\n",
+ s->vga.sr_index, val);
#endif
break;
}
-
- return CIRRUS_HOOK_HANDLED;
}
/***************************************
@@ -2806,13 +2807,11 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->sr_index = val;
break;
case 0x3c5:
- if (cirrus_hook_write_sr(c, s->sr_index, val))
- break;
#ifdef DEBUG_VGA_REG
printf("vga: write SR%x = 0x%02x\n", s->sr_index, val);
#endif
- s->sr[s->sr_index] = val & sr_mask[s->sr_index];
- if (s->sr_index == 1) s->update_retrace_info(s);
+ cirrus_vga_write_sr(c, val);
+ break;
break;
case 0x3c6:
cirrus_write_hidden_dac(c, val);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 17/23] cirrus_vga: rename cirrus_hook_read_palette() cirrus_vga_read_palette()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (15 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 16/23] cirrus_vga: rename cirrus_hook_write_sr() cirrus_vga_write_sr() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 18/23] cirrus_vga: rename cirrus_hook_write_palette() cirrus_vga_write_palette() Juan Quintela
` (6 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Simplify the logic to do everything inside the function
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 27 ++++++++++++---------------
1 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index b369849..4c75569 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1419,18 +1419,21 @@ static void cirrus_write_hidden_dac(CirrusVGAState * s, int reg_value)
*
***************************************/
-static int cirrus_hook_read_palette(CirrusVGAState * s, int *reg_value)
+static int cirrus_vga_read_palette(CirrusVGAState * s)
{
- if (!(s->vga.sr[0x12] & CIRRUS_CURSOR_HIDDENPEL))
- return CIRRUS_HOOK_NOT_HANDLED;
- *reg_value =
- s->cirrus_hidden_palette[(s->vga.dac_read_index & 0x0f) * 3 +
- s->vga.dac_sub_index];
+ int val;
+
+ if ((s->vga.sr[0x12] & CIRRUS_CURSOR_HIDDENPEL)) {
+ val = s->cirrus_hidden_palette[(s->vga.dac_read_index & 0x0f) * 3 +
+ s->vga.dac_sub_index];
+ } else {
+ val = s->vga.palette[s->vga.dac_read_index * 3 + s->vga.dac_sub_index];
+ }
if (++s->vga.dac_sub_index == 3) {
s->vga.dac_sub_index = 0;
s->vga.dac_read_index++;
}
- return CIRRUS_HOOK_HANDLED;
+ return val;
}
static int cirrus_hook_write_palette(CirrusVGAState * s, int reg_value)
@@ -2698,14 +2701,8 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
c->cirrus_hidden_dac_lockindex = 0;
break;
case 0x3c9:
- if (cirrus_hook_read_palette(c, &val))
- break;
- val = s->palette[s->dac_read_index * 3 + s->dac_sub_index];
- if (++s->dac_sub_index == 3) {
- s->dac_sub_index = 0;
- s->dac_read_index++;
- }
- break;
+ val = cirrus_vga_read_palette(c);
+ break;
case 0x3ca:
val = s->fcr;
break;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 18/23] cirrus_vga: rename cirrus_hook_write_palette() cirrus_vga_write_palette()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (16 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 17/23] cirrus_vga: rename cirrus_hook_read_palette() cirrus_vga_read_palette() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 19/23] cirrus_vga: rename cirrus_hook_read_gr() cirrus_vga_read_gr() Juan Quintela
` (5 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Simplify the logic to do everything inside the function
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 24 +++++++++---------------
1 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 4c75569..d3dd2ad 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1436,19 +1436,20 @@ static int cirrus_vga_read_palette(CirrusVGAState * s)
return val;
}
-static int cirrus_hook_write_palette(CirrusVGAState * s, int reg_value)
+static void cirrus_vga_write_palette(CirrusVGAState * s, int reg_value)
{
- if (!(s->vga.sr[0x12] & CIRRUS_CURSOR_HIDDENPEL))
- return CIRRUS_HOOK_NOT_HANDLED;
s->vga.dac_cache[s->vga.dac_sub_index] = reg_value;
if (++s->vga.dac_sub_index == 3) {
- memcpy(&s->cirrus_hidden_palette[(s->vga.dac_write_index & 0x0f) * 3],
- s->vga.dac_cache, 3);
+ if ((s->vga.sr[0x12] & CIRRUS_CURSOR_HIDDENPEL)) {
+ memcpy(&s->cirrus_hidden_palette[(s->vga.dac_write_index & 0x0f) * 3],
+ s->vga.dac_cache, 3);
+ } else {
+ memcpy(&s->vga.palette[s->vga.dac_write_index * 3], s->vga.dac_cache, 3);
+ }
/* XXX update cursor */
s->vga.dac_sub_index = 0;
s->vga.dac_write_index++;
}
- return CIRRUS_HOOK_HANDLED;
}
/***************************************
@@ -2824,15 +2825,8 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->dac_state = 0;
break;
case 0x3c9:
- if (cirrus_hook_write_palette(c, val))
- break;
- s->dac_cache[s->dac_sub_index] = val;
- if (++s->dac_sub_index == 3) {
- memcpy(&s->palette[s->dac_write_index * 3], s->dac_cache, 3);
- s->dac_sub_index = 0;
- s->dac_write_index++;
- }
- break;
+ cirrus_vga_write_palette(c, val);
+ break;
case 0x3ce:
s->gr_index = val;
break;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 19/23] cirrus_vga: rename cirrus_hook_read_gr() cirrus_vga_read_gr()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (17 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 18/23] cirrus_vga: rename cirrus_hook_write_palette() cirrus_vga_write_palette() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 20/23] cirrus_vga: rename cirrus_hook_write_gr() cirrus_vga_write_gr() Juan Quintela
` (4 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Simplify the logic to do everything inside the function.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 83 +++++++++++++++++++++++++-----------------------------
1 files changed, 38 insertions(+), 45 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index d3dd2ad..d059949 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1458,38 +1458,33 @@ static void cirrus_vga_write_palette(CirrusVGAState * s, int reg_value)
*
***************************************/
-static int
-cirrus_hook_read_gr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
+static int cirrus_vga_read_gr(CirrusVGAState * s, unsigned reg_index)
{
switch (reg_index) {
case 0x00: // Standard VGA, BGCOLOR 0x000000ff
- *reg_value = s->cirrus_shadow_gr0;
- return CIRRUS_HOOK_HANDLED;
+ return s->cirrus_shadow_gr0;
case 0x01: // Standard VGA, FGCOLOR 0x000000ff
- *reg_value = s->cirrus_shadow_gr1;
- return CIRRUS_HOOK_HANDLED;
+ return s->cirrus_shadow_gr1;
case 0x02: // Standard VGA
case 0x03: // Standard VGA
case 0x04: // Standard VGA
case 0x06: // Standard VGA
case 0x07: // Standard VGA
case 0x08: // Standard VGA
- return CIRRUS_HOOK_NOT_HANDLED;
+ return s->vga.gr[s->vga.gr_index];
case 0x05: // Standard VGA, Cirrus extended mode
default:
break;
}
if (reg_index < 0x3a) {
- *reg_value = s->vga.gr[reg_index];
+ return s->vga.gr[reg_index];
} else {
#ifdef DEBUG_CIRRUS
printf("cirrus: inport gr_index %02x\n", reg_index);
#endif
- *reg_value = 0xff;
+ return 0xff;
}
-
- return CIRRUS_HOOK_HANDLED;
}
static int
@@ -1716,97 +1711,97 @@ static uint8_t cirrus_mmio_blt_read(CirrusVGAState * s, unsigned address)
switch (address) {
case (CIRRUS_MMIO_BLTBGCOLOR + 0):
- cirrus_hook_read_gr(s, 0x00, &value);
+ value = cirrus_vga_read_gr(s, 0x00);
break;
case (CIRRUS_MMIO_BLTBGCOLOR + 1):
- cirrus_hook_read_gr(s, 0x10, &value);
+ value = cirrus_vga_read_gr(s, 0x10);
break;
case (CIRRUS_MMIO_BLTBGCOLOR + 2):
- cirrus_hook_read_gr(s, 0x12, &value);
+ value = cirrus_vga_read_gr(s, 0x12);
break;
case (CIRRUS_MMIO_BLTBGCOLOR + 3):
- cirrus_hook_read_gr(s, 0x14, &value);
+ value = cirrus_vga_read_gr(s, 0x14);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 0):
- cirrus_hook_read_gr(s, 0x01, &value);
+ value = cirrus_vga_read_gr(s, 0x01);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 1):
- cirrus_hook_read_gr(s, 0x11, &value);
+ value = cirrus_vga_read_gr(s, 0x11);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 2):
- cirrus_hook_read_gr(s, 0x13, &value);
+ value = cirrus_vga_read_gr(s, 0x13);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 3):
- cirrus_hook_read_gr(s, 0x15, &value);
+ value = cirrus_vga_read_gr(s, 0x15);
break;
case (CIRRUS_MMIO_BLTWIDTH + 0):
- cirrus_hook_read_gr(s, 0x20, &value);
+ value = cirrus_vga_read_gr(s, 0x20);
break;
case (CIRRUS_MMIO_BLTWIDTH + 1):
- cirrus_hook_read_gr(s, 0x21, &value);
+ value = cirrus_vga_read_gr(s, 0x21);
break;
case (CIRRUS_MMIO_BLTHEIGHT + 0):
- cirrus_hook_read_gr(s, 0x22, &value);
+ value = cirrus_vga_read_gr(s, 0x22);
break;
case (CIRRUS_MMIO_BLTHEIGHT + 1):
- cirrus_hook_read_gr(s, 0x23, &value);
+ value = cirrus_vga_read_gr(s, 0x23);
break;
case (CIRRUS_MMIO_BLTDESTPITCH + 0):
- cirrus_hook_read_gr(s, 0x24, &value);
+ value = cirrus_vga_read_gr(s, 0x24);
break;
case (CIRRUS_MMIO_BLTDESTPITCH + 1):
- cirrus_hook_read_gr(s, 0x25, &value);
+ value = cirrus_vga_read_gr(s, 0x25);
break;
case (CIRRUS_MMIO_BLTSRCPITCH + 0):
- cirrus_hook_read_gr(s, 0x26, &value);
+ value = cirrus_vga_read_gr(s, 0x26);
break;
case (CIRRUS_MMIO_BLTSRCPITCH + 1):
- cirrus_hook_read_gr(s, 0x27, &value);
+ value = cirrus_vga_read_gr(s, 0x27);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 0):
- cirrus_hook_read_gr(s, 0x28, &value);
+ value = cirrus_vga_read_gr(s, 0x28);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 1):
- cirrus_hook_read_gr(s, 0x29, &value);
+ value = cirrus_vga_read_gr(s, 0x29);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 2):
- cirrus_hook_read_gr(s, 0x2a, &value);
+ value = cirrus_vga_read_gr(s, 0x2a);
break;
case (CIRRUS_MMIO_BLTSRCADDR + 0):
- cirrus_hook_read_gr(s, 0x2c, &value);
+ value = cirrus_vga_read_gr(s, 0x2c);
break;
case (CIRRUS_MMIO_BLTSRCADDR + 1):
- cirrus_hook_read_gr(s, 0x2d, &value);
+ value = cirrus_vga_read_gr(s, 0x2d);
break;
case (CIRRUS_MMIO_BLTSRCADDR + 2):
- cirrus_hook_read_gr(s, 0x2e, &value);
+ value = cirrus_vga_read_gr(s, 0x2e);
break;
case CIRRUS_MMIO_BLTWRITEMASK:
- cirrus_hook_read_gr(s, 0x2f, &value);
+ value = cirrus_vga_read_gr(s, 0x2f);
break;
case CIRRUS_MMIO_BLTMODE:
- cirrus_hook_read_gr(s, 0x30, &value);
+ value = cirrus_vga_read_gr(s, 0x30);
break;
case CIRRUS_MMIO_BLTROP:
- cirrus_hook_read_gr(s, 0x32, &value);
+ value = cirrus_vga_read_gr(s, 0x32);
break;
case CIRRUS_MMIO_BLTMODEEXT:
- cirrus_hook_read_gr(s, 0x33, &value);
+ value = cirrus_vga_read_gr(s, 0x33);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 0):
- cirrus_hook_read_gr(s, 0x34, &value);
+ value = cirrus_vga_read_gr(s, 0x34);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 1):
- cirrus_hook_read_gr(s, 0x35, &value);
+ value = cirrus_vga_read_gr(s, 0x35);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 0):
- cirrus_hook_read_gr(s, 0x38, &value);
+ value = cirrus_vga_read_gr(s, 0x38);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 1):
- cirrus_hook_read_gr(s, 0x39, &value);
+ value = cirrus_vga_read_gr(s, 0x39);
break;
case CIRRUS_MMIO_BLTSTATUS:
- cirrus_hook_read_gr(s, 0x31, &value);
+ value = cirrus_vga_read_gr(s, 0x31);
break;
default:
#ifdef DEBUG_CIRRUS
@@ -2714,9 +2709,7 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
val = s->gr_index;
break;
case 0x3cf:
- if (cirrus_hook_read_gr(c, s->gr_index, &val))
- break;
- val = s->gr[s->gr_index];
+ val = cirrus_vga_read_gr(c, s->gr_index);
#ifdef DEBUG_VGA_REG
printf("vga: read GR%x = 0x%02x\n", s->gr_index, val);
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 20/23] cirrus_vga: rename cirrus_hook_write_gr() cirrus_vga_write_gr()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (18 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 19/23] cirrus_vga: rename cirrus_hook_read_gr() cirrus_vga_read_gr() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 21/23] cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr() Juan Quintela
` (3 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Simplify the logic to do everything inside the function.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 79 ++++++++++++++++++++++++++----------------------------
1 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index d059949..759da4a 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1487,8 +1487,8 @@ static int cirrus_vga_read_gr(CirrusVGAState * s, unsigned reg_index)
}
}
-static int
-cirrus_hook_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
+static void
+cirrus_vga_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
{
#if defined(DEBUG_BITBLT) && 0
printf("gr%02x: %02x\n", reg_index, reg_value);
@@ -1496,17 +1496,18 @@ cirrus_hook_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
switch (reg_index) {
case 0x00: // Standard VGA, BGCOLOR 0x000000ff
s->cirrus_shadow_gr0 = reg_value;
- return CIRRUS_HOOK_NOT_HANDLED;
+ break;
case 0x01: // Standard VGA, FGCOLOR 0x000000ff
s->cirrus_shadow_gr1 = reg_value;
- return CIRRUS_HOOK_NOT_HANDLED;
+ break;
case 0x02: // Standard VGA
case 0x03: // Standard VGA
case 0x04: // Standard VGA
case 0x06: // Standard VGA
case 0x07: // Standard VGA
case 0x08: // Standard VGA
- return CIRRUS_HOOK_NOT_HANDLED;
+ s->vga.gr[reg_index] = reg_value & gr_mask[reg_index];
+ break;
case 0x05: // Standard VGA, Cirrus extended mode
s->vga.gr[reg_index] = reg_value & 0x7f;
cirrus_update_memory_access(s);
@@ -1574,8 +1575,6 @@ cirrus_hook_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
#endif
break;
}
-
- return CIRRUS_HOOK_HANDLED;
}
/***************************************
@@ -1818,100 +1817,100 @@ static void cirrus_mmio_blt_write(CirrusVGAState * s, unsigned address,
{
switch (address) {
case (CIRRUS_MMIO_BLTBGCOLOR + 0):
- cirrus_hook_write_gr(s, 0x00, value);
+ cirrus_vga_write_gr(s, 0x00, value);
break;
case (CIRRUS_MMIO_BLTBGCOLOR + 1):
- cirrus_hook_write_gr(s, 0x10, value);
+ cirrus_vga_write_gr(s, 0x10, value);
break;
case (CIRRUS_MMIO_BLTBGCOLOR + 2):
- cirrus_hook_write_gr(s, 0x12, value);
+ cirrus_vga_write_gr(s, 0x12, value);
break;
case (CIRRUS_MMIO_BLTBGCOLOR + 3):
- cirrus_hook_write_gr(s, 0x14, value);
+ cirrus_vga_write_gr(s, 0x14, value);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 0):
- cirrus_hook_write_gr(s, 0x01, value);
+ cirrus_vga_write_gr(s, 0x01, value);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 1):
- cirrus_hook_write_gr(s, 0x11, value);
+ cirrus_vga_write_gr(s, 0x11, value);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 2):
- cirrus_hook_write_gr(s, 0x13, value);
+ cirrus_vga_write_gr(s, 0x13, value);
break;
case (CIRRUS_MMIO_BLTFGCOLOR + 3):
- cirrus_hook_write_gr(s, 0x15, value);
+ cirrus_vga_write_gr(s, 0x15, value);
break;
case (CIRRUS_MMIO_BLTWIDTH + 0):
- cirrus_hook_write_gr(s, 0x20, value);
+ cirrus_vga_write_gr(s, 0x20, value);
break;
case (CIRRUS_MMIO_BLTWIDTH + 1):
- cirrus_hook_write_gr(s, 0x21, value);
+ cirrus_vga_write_gr(s, 0x21, value);
break;
case (CIRRUS_MMIO_BLTHEIGHT + 0):
- cirrus_hook_write_gr(s, 0x22, value);
+ cirrus_vga_write_gr(s, 0x22, value);
break;
case (CIRRUS_MMIO_BLTHEIGHT + 1):
- cirrus_hook_write_gr(s, 0x23, value);
+ cirrus_vga_write_gr(s, 0x23, value);
break;
case (CIRRUS_MMIO_BLTDESTPITCH + 0):
- cirrus_hook_write_gr(s, 0x24, value);
+ cirrus_vga_write_gr(s, 0x24, value);
break;
case (CIRRUS_MMIO_BLTDESTPITCH + 1):
- cirrus_hook_write_gr(s, 0x25, value);
+ cirrus_vga_write_gr(s, 0x25, value);
break;
case (CIRRUS_MMIO_BLTSRCPITCH + 0):
- cirrus_hook_write_gr(s, 0x26, value);
+ cirrus_vga_write_gr(s, 0x26, value);
break;
case (CIRRUS_MMIO_BLTSRCPITCH + 1):
- cirrus_hook_write_gr(s, 0x27, value);
+ cirrus_vga_write_gr(s, 0x27, value);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 0):
- cirrus_hook_write_gr(s, 0x28, value);
+ cirrus_vga_write_gr(s, 0x28, value);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 1):
- cirrus_hook_write_gr(s, 0x29, value);
+ cirrus_vga_write_gr(s, 0x29, value);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 2):
- cirrus_hook_write_gr(s, 0x2a, value);
+ cirrus_vga_write_gr(s, 0x2a, value);
break;
case (CIRRUS_MMIO_BLTDESTADDR + 3):
/* ignored */
break;
case (CIRRUS_MMIO_BLTSRCADDR + 0):
- cirrus_hook_write_gr(s, 0x2c, value);
+ cirrus_vga_write_gr(s, 0x2c, value);
break;
case (CIRRUS_MMIO_BLTSRCADDR + 1):
- cirrus_hook_write_gr(s, 0x2d, value);
+ cirrus_vga_write_gr(s, 0x2d, value);
break;
case (CIRRUS_MMIO_BLTSRCADDR + 2):
- cirrus_hook_write_gr(s, 0x2e, value);
+ cirrus_vga_write_gr(s, 0x2e, value);
break;
case CIRRUS_MMIO_BLTWRITEMASK:
- cirrus_hook_write_gr(s, 0x2f, value);
+ cirrus_vga_write_gr(s, 0x2f, value);
break;
case CIRRUS_MMIO_BLTMODE:
- cirrus_hook_write_gr(s, 0x30, value);
+ cirrus_vga_write_gr(s, 0x30, value);
break;
case CIRRUS_MMIO_BLTROP:
- cirrus_hook_write_gr(s, 0x32, value);
+ cirrus_vga_write_gr(s, 0x32, value);
break;
case CIRRUS_MMIO_BLTMODEEXT:
- cirrus_hook_write_gr(s, 0x33, value);
+ cirrus_vga_write_gr(s, 0x33, value);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 0):
- cirrus_hook_write_gr(s, 0x34, value);
+ cirrus_vga_write_gr(s, 0x34, value);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLOR + 1):
- cirrus_hook_write_gr(s, 0x35, value);
+ cirrus_vga_write_gr(s, 0x35, value);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 0):
- cirrus_hook_write_gr(s, 0x38, value);
+ cirrus_vga_write_gr(s, 0x38, value);
break;
case (CIRRUS_MMIO_BLTTRANSPARENTCOLORMASK + 1):
- cirrus_hook_write_gr(s, 0x39, value);
+ cirrus_vga_write_gr(s, 0x39, value);
break;
case CIRRUS_MMIO_BLTSTATUS:
- cirrus_hook_write_gr(s, 0x31, value);
+ cirrus_vga_write_gr(s, 0x31, value);
break;
default:
#ifdef DEBUG_CIRRUS
@@ -2824,12 +2823,10 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->gr_index = val;
break;
case 0x3cf:
- if (cirrus_hook_write_gr(c, s->gr_index, val))
- break;
#ifdef DEBUG_VGA_REG
printf("vga: write GR%x = 0x%02x\n", s->gr_index, val);
#endif
- s->gr[s->gr_index] = val & gr_mask[s->gr_index];
+ cirrus_vga_write_gr(c, s->gr_index, val);
break;
case 0x3b4:
case 0x3d4:
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 21/23] cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (19 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 20/23] cirrus_vga: rename cirrus_hook_write_gr() cirrus_vga_write_gr() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 22/23] cirrus_vga: rename cirrus_hook_write_cr() cirrus_vga_write_cr() Juan Quintela
` (2 subsequent siblings)
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Simplify the logic to do everything inside the function. Return 0xff if index is out of range independetly of DEBUG_CIRRUS
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 22 +++++++---------------
1 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 759da4a..86ab127 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1583,8 +1583,7 @@ cirrus_vga_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
*
***************************************/
-static int
-cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
+static int cirrus_vga_read_cr(CirrusVGAState * s, unsigned reg_index)
{
switch (reg_index) {
case 0x00: // Standard VGA
@@ -1612,10 +1611,9 @@ cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
case 0x16: // Standard VGA
case 0x17: // Standard VGA
case 0x18: // Standard VGA
- return CIRRUS_HOOK_NOT_HANDLED;
+ return s->vga.cr[s->vga.cr_index];
case 0x24: // Attribute Controller Toggle Readback (R)
- *reg_value = (s->vga.ar_flip_flop << 7);
- break;
+ return (s->vga.ar_flip_flop << 7);
case 0x19: // Interlace End
case 0x1a: // Miscellaneous Control
case 0x1b: // Extended Display Control
@@ -1624,20 +1622,16 @@ cirrus_hook_read_cr(CirrusVGAState * s, unsigned reg_index, int *reg_value)
case 0x22: // Graphics Data Latches Readback (R)
case 0x25: // Part Status
case 0x27: // Part ID (R)
- *reg_value = s->vga.cr[reg_index];
- break;
+ return s->vga.cr[s->vga.cr_index];
case 0x26: // Attribute Controller Index Readback (R)
- *reg_value = s->vga.ar_index & 0x3f;
+ return s->vga.ar_index & 0x3f;
break;
default:
#ifdef DEBUG_CIRRUS
printf("cirrus: inport cr_index %02x\n", reg_index);
- *reg_value = 0xff;
#endif
- break;
+ return 0xff;
}
-
- return CIRRUS_HOOK_HANDLED;
}
static int
@@ -2719,9 +2713,7 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
break;
case 0x3b5:
case 0x3d5:
- if (cirrus_hook_read_cr(c, s->cr_index, &val))
- break;
- val = s->cr[s->cr_index];
+ val = cirrus_vga_read_cr(c, s->cr_index);
#ifdef DEBUG_VGA_REG
printf("vga: read CR%x = 0x%02x\n", s->cr_index, val);
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 22/23] cirrus_vga: rename cirrus_hook_write_cr() cirrus_vga_write_cr()
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (20 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 21/23] cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 23/23] cirrus_vga: CIRRUS_HOOK_* is not used anymore Juan Quintela
2009-09-16 12:43 ` [Qemu-devel] [PATCH 00/23] VGA cleanup Pierre Riteau
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Simplify the logic to do everything inside the function.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 59 +++++++++++++++++++++++++-----------------------------
1 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 86ab127..0ef8452 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1634,10 +1634,9 @@ static int cirrus_vga_read_cr(CirrusVGAState * s, unsigned reg_index)
}
}
-static int
-cirrus_hook_write_cr(CirrusVGAState * s, unsigned reg_index, int reg_value)
+static void cirrus_vga_write_cr(CirrusVGAState * s, int reg_value)
{
- switch (reg_index) {
+ switch (s->vga.cr_index) {
case 0x00: // Standard VGA
case 0x01: // Standard VGA
case 0x02: // Standard VGA
@@ -1663,16 +1662,35 @@ cirrus_hook_write_cr(CirrusVGAState * s, unsigned reg_index, int reg_value)
case 0x16: // Standard VGA
case 0x17: // Standard VGA
case 0x18: // Standard VGA
- return CIRRUS_HOOK_NOT_HANDLED;
+ /* handle CR0-7 protection */
+ if ((s->vga.cr[0x11] & 0x80) && s->vga.cr_index <= 7) {
+ /* can always write bit 4 of CR7 */
+ if (s->vga.cr_index == 7)
+ s->vga.cr[7] = (s->vga.cr[7] & ~0x10) | (reg_value & 0x10);
+ return;
+ }
+ s->vga.cr[s->vga.cr_index] = reg_value;
+ switch(s->vga.cr_index) {
+ case 0x00:
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ case 0x11:
+ case 0x17:
+ s->vga.update_retrace_info(&s->vga);
+ break;
+ }
+ break;
case 0x19: // Interlace End
case 0x1a: // Miscellaneous Control
case 0x1b: // Extended Display Control
case 0x1c: // Sync Adjust and Genlock
case 0x1d: // Overlay Extended Control
- s->vga.cr[reg_index] = reg_value;
+ s->vga.cr[s->vga.cr_index] = reg_value;
#ifdef DEBUG_CIRRUS
printf("cirrus: handled outport cr_index %02x, cr_value %02x\n",
- reg_index, reg_value);
+ s->vga.cr_index, reg_value);
#endif
break;
case 0x22: // Graphics Data Latches Readback (R)
@@ -1683,13 +1701,11 @@ cirrus_hook_write_cr(CirrusVGAState * s, unsigned reg_index, int reg_value)
case 0x25: // Part Status
default:
#ifdef DEBUG_CIRRUS
- printf("cirrus: outport cr_index %02x, cr_value %02x\n", reg_index,
- reg_value);
+ printf("cirrus: outport cr_index %02x, cr_value %02x\n",
+ s->vga.cr_index, reg_value);
#endif
break;
}
-
- return CIRRUS_HOOK_HANDLED;
}
/***************************************
@@ -2826,31 +2842,10 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
break;
case 0x3b5:
case 0x3d5:
- if (cirrus_hook_write_cr(c, s->cr_index, val))
- break;
#ifdef DEBUG_VGA_REG
printf("vga: write CR%x = 0x%02x\n", s->cr_index, val);
#endif
- /* handle CR0-7 protection */
- if ((s->cr[0x11] & 0x80) && s->cr_index <= 7) {
- /* can always write bit 4 of CR7 */
- if (s->cr_index == 7)
- s->cr[7] = (s->cr[7] & ~0x10) | (val & 0x10);
- return;
- }
- s->cr[s->cr_index] = val;
-
- switch(s->cr_index) {
- case 0x00:
- case 0x04:
- case 0x05:
- case 0x06:
- case 0x07:
- case 0x11:
- case 0x17:
- s->update_retrace_info(s);
- break;
- }
+ cirrus_vga_write_cr(c, val);
break;
case 0x3ba:
case 0x3da:
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 23/23] cirrus_vga: CIRRUS_HOOK_* is not used anymore
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (21 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 22/23] cirrus_vga: rename cirrus_hook_write_cr() cirrus_vga_write_cr() Juan Quintela
@ 2009-08-31 14:07 ` Juan Quintela
2009-09-16 12:43 ` [Qemu-devel] [PATCH 00/23] VGA cleanup Pierre Riteau
23 siblings, 0 replies; 29+ messages in thread
From: Juan Quintela @ 2009-08-31 14:07 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 0ef8452..5cdb11f 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -208,11 +208,6 @@
#define CIRRUS_PNPMMIO_SIZE 0x1000
-
-/* I/O and memory hook */
-#define CIRRUS_HOOK_NOT_HANDLED 0
-#define CIRRUS_HOOK_HANDLED 1
-
#define ABS(a) ((signed)(a) > 0 ? a : -a)
#define BLTUNSAFE(s) \
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 00/23] VGA cleanup
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
` (22 preceding siblings ...)
2009-08-31 14:07 ` [Qemu-devel] [PATCH 23/23] cirrus_vga: CIRRUS_HOOK_* is not used anymore Juan Quintela
@ 2009-09-16 12:43 ` Pierre Riteau
2009-09-16 12:52 ` [Qemu-devel] " Juan Quintela
23 siblings, 1 reply; 29+ messages in thread
From: Pierre Riteau @ 2009-09-16 12:43 UTC (permalink / raw)
To: Juan Quintela; +Cc: aliguori, qemu-devel
On 31 août 2009, at 16:07, Juan Quintela wrote:
> This patch:
> - cleans the differences between VGAState/VGACommon state
> - moves vga pci, isa, isa-mm out of vga.c (cirrus and blizzar uses
> VGA common state).
> - Cleans all the cirrus_hook_* stuff is something that don't look
> like a hook :)
>
> I would want this bits morged/reviewed before going the rest of the
> cleanup:
>
> Todo:
> - vga_ioport_read/write and cirrus_vga_ioport_read/write are almost
> identical
> after this series of changes. Creating read/write() callbacks for
> sr/gr/cr/palette. Should put us there. The cirrus ones were the
> difficult ones,
> the vga ones are trivial.
> - CONFIG_VBE_BOCHS code. This code is only used by vga std (pci +
> isa). Neither
> cirrus/blizzard/isa-mm uses it. It should be moved out of vga.c,
> vga-std.c?, and
> then used by vga-isa and vga-pci?
> - vmware_vga: it uses vga as embeded, but it don't save its state, I
> am not sure
> if it wants/need VBE_BOCHS, .... I haven't looked at vmware_vga
> too much, just
> to vga and cirrus_vga.
>
> Comments?
>
> Later, Juan.
This patchset introduced a bug. I noticed today that I can't boot an
installation disk of ubuntu-9.04-server-i386.
After entering the install program ("Install Ubuntu Server"), I just
get a black background with gray vertical lines.
More specifically, from oldest to newest commit:
86948bb104f419db9af6b621b85703e8f0d3234c works
f705db9df04c6491f242a5a4585dfe72b708f197 throws a warning about an
uninitialized variable (had to disable werror) but works
22286bc6468adac10b2eb7e603f1a8ba524bfb03 throws a warning about an
uninitialized variable (had to disable werror) and doesn't work
b863d51490b7c6e339c9565eda786cadc1218d48 compiles without warning and
doesn't work
So 22286bc6468adac10b2eb7e603f1a8ba524bfb03 must be the problematic
commit.
--
Pierre Riteau -- http://perso.univ-rennes1.fr/pierre.riteau/
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] Re: [PATCH 00/23] VGA cleanup
2009-09-16 12:43 ` [Qemu-devel] [PATCH 00/23] VGA cleanup Pierre Riteau
@ 2009-09-16 12:52 ` Juan Quintela
2009-09-16 13:17 ` Pierre Riteau
0 siblings, 1 reply; 29+ messages in thread
From: Juan Quintela @ 2009-09-16 12:52 UTC (permalink / raw)
To: Pierre Riteau; +Cc: aliguori, qemu-devel
Pierre Riteau <Pierre.Riteau@irisa.fr> wrote:
> On 31 août 2009, at 16:07, Juan Quintela wrote:
>
>> This patch:
>> - cleans the differences between VGAState/VGACommon state
>> - moves vga pci, isa, isa-mm out of vga.c (cirrus and blizzar uses
>> VGA common state).
>> - Cleans all the cirrus_hook_* stuff is something that don't look
>> like a hook :)
>>
>> I would want this bits morged/reviewed before going the rest of the
>> cleanup:
>>
>> Todo:
>> - vga_ioport_read/write and cirrus_vga_ioport_read/write are almost
>> identical
>> after this series of changes. Creating read/write() callbacks for
>> sr/gr/cr/palette. Should put us there. The cirrus ones were the
>> difficult ones,
>> the vga ones are trivial.
>> - CONFIG_VBE_BOCHS code. This code is only used by vga std (pci +
>> isa). Neither
>> cirrus/blizzard/isa-mm uses it. It should be moved out of vga.c,
>> vga-std.c?, and
>> then used by vga-isa and vga-pci?
>> - vmware_vga: it uses vga as embeded, but it don't save its state, I
>> am not sure
>> if it wants/need VBE_BOCHS, .... I haven't looked at vmware_vga
>> too much, just
>> to vga and cirrus_vga.
>>
>> Comments?
>>
>> Later, Juan.
>
>
> This patchset introduced a bug. I noticed today that I can't boot an
> installation disk of ubuntu-9.04-server-i386.
> After entering the install program ("Install Ubuntu Server"), I just
> get a black background with gray vertical lines.
>
> More specifically, from oldest to newest commit:
> 86948bb104f419db9af6b621b85703e8f0d3234c works
> f705db9df04c6491f242a5a4585dfe72b708f197 throws a warning about an
> uninitialized variable (had to disable werror) but works
could you post the error message? I didn't have that problem.
> 22286bc6468adac10b2eb7e603f1a8ba524bfb03 throws a warning about an
> uninitialized variable (had to disable werror) and doesn't work
> b863d51490b7c6e339c9565eda786cadc1218d48 compiles without warning and
> doesn't work
Weird, it did worked for me. Could you post what command line did you
use? I tested with fedora + win XP.
> So 22286bc6468adac10b2eb7e603f1a8ba524bfb03 must be the problematic
> commit.
Thanks, will take a look.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] Re: [PATCH 00/23] VGA cleanup
2009-09-16 12:52 ` [Qemu-devel] " Juan Quintela
@ 2009-09-16 13:17 ` Pierre Riteau
2009-09-16 13:45 ` Juan Quintela
0 siblings, 1 reply; 29+ messages in thread
From: Pierre Riteau @ 2009-09-16 13:17 UTC (permalink / raw)
To: Juan Quintela; +Cc: aliguori, qemu-devel
On 16 sept. 2009, at 14:52, Juan Quintela wrote:
> Pierre Riteau <Pierre.Riteau@irisa.fr> wrote:
>> On 31 août 2009, at 16:07, Juan Quintela wrote:
>>
>>> This patch:
>>> - cleans the differences between VGAState/VGACommon state
>>> - moves vga pci, isa, isa-mm out of vga.c (cirrus and blizzar uses
>>> VGA common state).
>>> - Cleans all the cirrus_hook_* stuff is something that don't look
>>> like a hook :)
>>>
>>> I would want this bits morged/reviewed before going the rest of the
>>> cleanup:
>>>
>>> Todo:
>>> - vga_ioport_read/write and cirrus_vga_ioport_read/write are almost
>>> identical
>>> after this series of changes. Creating read/write() callbacks for
>>> sr/gr/cr/palette. Should put us there. The cirrus ones were the
>>> difficult ones,
>>> the vga ones are trivial.
>>> - CONFIG_VBE_BOCHS code. This code is only used by vga std (pci +
>>> isa). Neither
>>> cirrus/blizzard/isa-mm uses it. It should be moved out of vga.c,
>>> vga-std.c?, and
>>> then used by vga-isa and vga-pci?
>>> - vmware_vga: it uses vga as embeded, but it don't save its state, I
>>> am not sure
>>> if it wants/need VBE_BOCHS, .... I haven't looked at vmware_vga
>>> too much, just
>>> to vga and cirrus_vga.
>>>
>>> Comments?
>>>
>>> Later, Juan.
>>
>>
>> This patchset introduced a bug. I noticed today that I can't boot an
>> installation disk of ubuntu-9.04-server-i386.
>> After entering the install program ("Install Ubuntu Server"), I just
>> get a black background with gray vertical lines.
>>
>> More specifically, from oldest to newest commit:
>> 86948bb104f419db9af6b621b85703e8f0d3234c works
>> f705db9df04c6491f242a5a4585dfe72b708f197 throws a warning about an
>> uninitialized variable (had to disable werror) but works
>
> could you post the error message? I didn't have that problem.
/mnt/qemu/hw/cirrus_vga.c: In function 'cirrus_vga_ioport_read':
/mnt/qemu/hw/cirrus_vga.c:2656: warning: 'val' may be used
uninitialized in this function
I'm using ./configure --target-list=i386-softmmu --disable-werror, gcc
is version 4.3.2 (from Debian Lenny).
>
>> 22286bc6468adac10b2eb7e603f1a8ba524bfb03 throws a warning about an
>> uninitialized variable (had to disable werror) and doesn't work
>> b863d51490b7c6e339c9565eda786cadc1218d48 compiles without warning and
>> doesn't work
>
> Weird, it did worked for me. Could you post what command line did you
> use? I tested with fedora + win XP.
qemu -cdrom ~/ubuntu-9.04-server-i386.iso -boot d
>
>> So 22286bc6468adac10b2eb7e603f1a8ba524bfb03 must be the problematic
>> commit.
>
> Thanks, will take a look.
--
Pierre Riteau -- http://perso.univ-rennes1.fr/pierre.riteau/
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] Re: [PATCH 00/23] VGA cleanup
2009-09-16 13:17 ` Pierre Riteau
@ 2009-09-16 13:45 ` Juan Quintela
2009-09-16 14:21 ` Pierre Riteau
0 siblings, 1 reply; 29+ messages in thread
From: Juan Quintela @ 2009-09-16 13:45 UTC (permalink / raw)
To: Pierre Riteau; +Cc: aliguori, qemu-devel
Pierre Riteau <Pierre.Riteau@irisa.fr> wrote:
>>> This patchset introduced a bug. I noticed today that I can't boot an
>>> installation disk of ubuntu-9.04-server-i386.
>>> After entering the install program ("Install Ubuntu Server"), I just
>>> get a black background with gray vertical lines.
>>>
>>> More specifically, from oldest to newest commit:
>>> 86948bb104f419db9af6b621b85703e8f0d3234c works
>>> f705db9df04c6491f242a5a4585dfe72b708f197 throws a warning about an
>>> uninitialized variable (had to disable werror) but works
>>
>> could you post the error message? I didn't have that problem.
>
> /mnt/qemu/hw/cirrus_vga.c: In function 'cirrus_vga_ioport_read':
> /mnt/qemu/hw/cirrus_vga.c:2656: warning: 'val' may be used
> uninitialized in this function
This is fixed on a later, patch, sorry :(
> I'm using ./configure --target-list=i386-softmmu --disable-werror, gcc
> is version 4.3.2 (from Debian Lenny).
>
>>
>>> 22286bc6468adac10b2eb7e603f1a8ba524bfb03 throws a warning about an
>>> uninitialized variable (had to disable werror) and doesn't work
>>> b863d51490b7c6e339c9565eda786cadc1218d48 compiles without warning and
>>> doesn't work
>>
>> Weird, it did worked for me. Could you post what command line did you
>> use? I tested with fedora + win XP.
>
> qemu -cdrom ~/ubuntu-9.04-server-i386.iso -boot d
>
>>
>>> So 22286bc6468adac10b2eb7e603f1a8ba524bfb03 must be the problematic
>>> commit.
>>
>> Thanks, will take a look.
could you check this patch?
(still not sure why it worked for fedora + xp for me)
>From 97869744f37ccd2846e3edcc1ad9f582d9bea1c6 Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela@redhat.com>
Date: Wed, 16 Sep 2009 15:44:49 +0200
Subject: [PATCH] cirrus_vga: also assign gr0/1 when writting shadow_gr0/1
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/cirrus_vga.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 004ae7d..9dfe76a 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -1490,9 +1490,11 @@ cirrus_vga_write_gr(CirrusVGAState * s, unsigned reg_index, int reg_value)
#endif
switch (reg_index) {
case 0x00: // Standard VGA, BGCOLOR 0x000000ff
+ s->vga.gr[reg_index] = reg_value & gr_mask[reg_index];
s->cirrus_shadow_gr0 = reg_value;
break;
case 0x01: // Standard VGA, FGCOLOR 0x000000ff
+ s->vga.gr[reg_index] = reg_value & gr_mask[reg_index];
s->cirrus_shadow_gr1 = reg_value;
break;
case 0x02: // Standard VGA
--
1.6.2.5
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] Re: [PATCH 00/23] VGA cleanup
2009-09-16 13:45 ` Juan Quintela
@ 2009-09-16 14:21 ` Pierre Riteau
0 siblings, 0 replies; 29+ messages in thread
From: Pierre Riteau @ 2009-09-16 14:21 UTC (permalink / raw)
To: Juan Quintela; +Cc: aliguori, qemu-devel
On 16 sept. 2009, at 15:45, Juan Quintela wrote:
> Pierre Riteau <Pierre.Riteau@irisa.fr> wrote:
>>>> This patchset introduced a bug. I noticed today that I can't boot
>>>> an
>>>> installation disk of ubuntu-9.04-server-i386.
>>>> After entering the install program ("Install Ubuntu Server"), I
>>>> just
>>>> get a black background with gray vertical lines.
>>>>
>>>> More specifically, from oldest to newest commit:
>>>> 86948bb104f419db9af6b621b85703e8f0d3234c works
>>>> f705db9df04c6491f242a5a4585dfe72b708f197 throws a warning about an
>>>> uninitialized variable (had to disable werror) but works
>>>
>>> could you post the error message? I didn't have that problem.
>>
>> /mnt/qemu/hw/cirrus_vga.c: In function 'cirrus_vga_ioport_read':
>> /mnt/qemu/hw/cirrus_vga.c:2656: warning: 'val' may be used
>> uninitialized in this function
>
> This is fixed on a later, patch, sorry :(
>
>> I'm using ./configure --target-list=i386-softmmu --disable-werror,
>> gcc
>> is version 4.3.2 (from Debian Lenny).
>>
>>>
>>>> 22286bc6468adac10b2eb7e603f1a8ba524bfb03 throws a warning about an
>>>> uninitialized variable (had to disable werror) and doesn't work
>>>> b863d51490b7c6e339c9565eda786cadc1218d48 compiles without warning
>>>> and
>>>> doesn't work
>>>
>>> Weird, it did worked for me. Could you post what command line did
>>> you
>>> use? I tested with fedora + win XP.
>>
>> qemu -cdrom ~/ubuntu-9.04-server-i386.iso -boot d
>>
>>>
>>>> So 22286bc6468adac10b2eb7e603f1a8ba524bfb03 must be the problematic
>>>> commit.
>>>
>>> Thanks, will take a look.
>
> could you check this patch?
> (still not sure why it worked for fedora + xp for me)
>
> From 97869744f37ccd2846e3edcc1ad9f582d9bea1c6 Mon Sep 17 00:00:00 2001
> From: Juan Quintela <quintela@redhat.com>
> Date: Wed, 16 Sep 2009 15:44:49 +0200
> Subject: [PATCH] cirrus_vga: also assign gr0/1 when writting
> shadow_gr0/1
>
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
> hw/cirrus_vga.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
> index 004ae7d..9dfe76a 100644
> --- a/hw/cirrus_vga.c
> +++ b/hw/cirrus_vga.c
> @@ -1490,9 +1490,11 @@ cirrus_vga_write_gr(CirrusVGAState * s,
> unsigned reg_index, int reg_value)
> #endif
> switch (reg_index) {
> case 0x00: // Standard VGA, BGCOLOR 0x000000ff
> + s->vga.gr[reg_index] = reg_value & gr_mask[reg_index];
> s->cirrus_shadow_gr0 = reg_value;
> break;
> case 0x01: // Standard VGA, FGCOLOR 0x000000ff
> + s->vga.gr[reg_index] = reg_value & gr_mask[reg_index];
> s->cirrus_shadow_gr1 = reg_value;
> break;
> case 0x02: // Standard VGA
> --
> 1.6.2.5
>
>
>
It works now! Thanks.
--
Pierre Riteau -- http://perso.univ-rennes1.fr/pierre.riteau/
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2009-09-16 14:21 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-31 14:07 [Qemu-devel] [PATCH 00/23] VGA cleanup Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 01/23] vga: remove useless cast from void * Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 02/23] cirrus_vga: prefix vga_ioport_{read, write} with cirrus Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 03/23] vga: export vga_ioport_{read,write} Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 04/23] vga: split vga_{load, save} into pci and common parts Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 05/23] vga: split pci bits into vga-pci.c Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 06/23] vga: split isa bits inco vga-isa.c Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 07/23] vga: export vga_mem_{read,write} Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 08/23] vga: split vga-isa-mm.o Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 09/23] vga and cirrus_vga: create vga_ioport_invalid() and use it everywhere Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 10/23] cirrus_vga: Add a VGACommonState local var to cirrus_vga_ioport_{read, write} Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 11/23] vga: change tabs to spaces Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 12/23] cirrus_vga: make cirrus_read_hidden_dac() return its result Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 13/23] vga and cirrus_vga: substitute switch for equivalent assigntment Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 14/23] vga: Rename last VGAState occurrences to VGACommonState Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 15/23] cirrus_vga: rename cirrus_hook_read_sr() cirrus_vga_read_sr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 16/23] cirrus_vga: rename cirrus_hook_write_sr() cirrus_vga_write_sr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 17/23] cirrus_vga: rename cirrus_hook_read_palette() cirrus_vga_read_palette() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 18/23] cirrus_vga: rename cirrus_hook_write_palette() cirrus_vga_write_palette() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 19/23] cirrus_vga: rename cirrus_hook_read_gr() cirrus_vga_read_gr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 20/23] cirrus_vga: rename cirrus_hook_write_gr() cirrus_vga_write_gr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 21/23] cirrus_vga: rename cirrus_hook_read_cr() cirrus_vga_read_cr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 22/23] cirrus_vga: rename cirrus_hook_write_cr() cirrus_vga_write_cr() Juan Quintela
2009-08-31 14:07 ` [Qemu-devel] [PATCH 23/23] cirrus_vga: CIRRUS_HOOK_* is not used anymore Juan Quintela
2009-09-16 12:43 ` [Qemu-devel] [PATCH 00/23] VGA cleanup Pierre Riteau
2009-09-16 12:52 ` [Qemu-devel] " Juan Quintela
2009-09-16 13:17 ` Pierre Riteau
2009-09-16 13:45 ` Juan Quintela
2009-09-16 14:21 ` Pierre Riteau
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.