summaryrefslogtreecommitdiff
path: root/hw/vmware_vga.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-05-03 22:25:16 +0300
committerAnthony Liguori <aliguori@us.ibm.com>2009-05-08 16:11:38 -0500
commit4e12cd946f9e7a6e3d35bcce0bc7bfe38cec4eb7 (patch)
tree1b3d29a0a137dac44efe97ac1e89e2d4ca8676c3 /hw/vmware_vga.c
parentfbb7b4e0804d2168f24142eebf7552adde1968dc (diff)
vga: Replace VGA_COMMON with a structure
All VGA devices share a common field subset; currently they do so by a macro which defines the common fields inline their state structures, relying on the the common state being placed at offset 0 in the structure. This makes refactoring the code difficult and requires a lot of error prone casts. Replace the macro by a new VGACommonState structure, and the casts by regular field access and container_of() for upcasts. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/vmware_vga.c')
-rw-r--r--hw/vmware_vga.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index 26cf789817..ec82f53239 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -38,7 +38,7 @@
struct vmsvga_state_s {
#ifdef EMBED_STDVGA
- VGA_STATE_COMMON
+ VGACommonState vga;
#endif
int width;
@@ -326,23 +326,23 @@ static inline void vmsvga_update_rect(struct vmsvga_state_s *s,
bypl = s->bypp * s->width;
width = s->bypp * w;
start = s->bypp * x + bypl * y;
- src = s->vram_ptr + start;
- dst = ds_get_data(s->ds) + start;
+ src = s->vga.vram_ptr + start;
+ dst = ds_get_data(s->vga.ds) + start;
for (; line > 0; line --, src += bypl, dst += bypl)
memcpy(dst, src, width);
#endif
- dpy_update(s->ds, x, y, w, h);
+ dpy_update(s->vga.ds, x, y, w, h);
}
static inline void vmsvga_update_screen(struct vmsvga_state_s *s)
{
#ifndef DIRECT_VRAM
- memcpy(ds_get_data(s->ds), s->vram_ptr, s->bypp * s->width * s->height);
+ memcpy(ds_get_data(s->vga.ds), s->vga.vram_ptr, s->bypp * s->width * s->height);
#endif
- dpy_update(s->ds, 0, 0, s->width, s->height);
+ dpy_update(s->vga.ds, 0, 0, s->width, s->height);
}
#ifdef DIRECT_VRAM
@@ -383,7 +383,7 @@ static inline void vmsvga_copy_rect(struct vmsvga_state_s *s,
# ifdef DIRECT_VRAM
uint8_t *vram = ds_get_data(s->ds);
# else
- uint8_t *vram = s->vram_ptr;
+ uint8_t *vram = s->vga.vram_ptr;
# endif
int bypl = s->bypp * s->width;
int width = s->bypp * w;
@@ -420,7 +420,7 @@ static inline void vmsvga_fill_rect(struct vmsvga_state_s *s,
# ifdef DIRECT_VRAM
uint8_t *vram = ds_get_data(s->ds);
# else
- uint8_t *vram = s->vram_ptr;
+ uint8_t *vram = s->vga.vram_ptr;
# endif
int bypp = s->bypp;
int bypl = bypp * s->width;
@@ -485,8 +485,8 @@ static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
for (i = SVGA_BITMAP_SIZE(c->width, c->height) - 1; i >= 0; i --)
c->mask[i] = ~c->mask[i];
- if (s->ds->cursor_define)
- s->ds->cursor_define(c->width, c->height, c->bpp, c->hot_x, c->hot_y,
+ if (s->vga.ds->cursor_define)
+ s->vga.ds->cursor_define(c->width, c->height, c->bpp, c->hot_x, c->hot_y,
(uint8_t *) c->image, (uint8_t *) c->mask);
}
#endif
@@ -689,7 +689,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
return 0x0;
case SVGA_REG_VRAM_SIZE:
- return s->vram_size - SVGA_FIFO_SIZE;
+ return s->vga.vram_size - SVGA_FIFO_SIZE;
case SVGA_REG_FB_SIZE:
return s->fb_size;
@@ -703,14 +703,14 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address)
caps |= SVGA_CAP_RECT_FILL;
#endif
#ifdef HW_MOUSE_ACCEL
- if (s->ds->mouse_set)
+ if (s->vga.ds->mouse_set)
caps |= SVGA_CAP_CURSOR | SVGA_CAP_CURSOR_BYPASS_2 |
SVGA_CAP_CURSOR_BYPASS;
#endif
return caps;
case SVGA_REG_MEM_START:
- return s->vram_base + s->vram_size - SVGA_FIFO_SIZE;
+ return s->vram_base + s->vga.vram_size - SVGA_FIFO_SIZE;
case SVGA_REG_MEM_SIZE:
return SVGA_FIFO_SIZE;
@@ -775,7 +775,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
s->height = -1;
s->invalidated = 1;
#ifdef EMBED_STDVGA
- s->invalidate(opaque);
+ s->vga.invalidate(&s->vga);
#endif
if (s->enable)
s->fb_size = ((s->depth + 7) >> 3) * s->new_width * s->new_height;
@@ -801,7 +801,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
case SVGA_REG_CONFIG_DONE:
if (value) {
- s->fifo = (uint32_t *) &s->vram_ptr[s->vram_size - SVGA_FIFO_SIZE];
+ s->fifo = (uint32_t *) &s->vga.vram_ptr[s->vga.vram_size - SVGA_FIFO_SIZE];
/* Check range and alignment. */
if ((CMD(min) | CMD(max) |
CMD(next_cmd) | CMD(stop)) & 3)
@@ -847,8 +847,8 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value)
s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW);
s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE);
#ifdef HW_MOUSE_ACCEL
- if (s->ds->mouse_set && value <= SVGA_CURSOR_ON_SHOW)
- s->ds->mouse_set(s->cursor.x, s->cursor.y, s->cursor.on);
+ if (s->vga.ds->mouse_set && value <= SVGA_CURSOR_ON_SHOW)
+ s->vga.ds->mouse_set(s->cursor.x, s->cursor.y, s->cursor.on);
#endif
break;
@@ -885,7 +885,7 @@ static inline void vmsvga_size(struct vmsvga_state_s *s)
if (s->new_width != s->width || s->new_height != s->height) {
s->width = s->new_width;
s->height = s->new_height;
- qemu_console_resize(s->ds, s->width, s->height);
+ qemu_console_resize(s->vga.ds, s->width, s->height);
s->invalidated = 1;
}
}
@@ -895,7 +895,7 @@ static void vmsvga_update_display(void *opaque)
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
if (!s->enable) {
#ifdef EMBED_STDVGA
- s->update(opaque);
+ s->vga.update(&s->vga);
#endif
return;
}
@@ -963,7 +963,7 @@ static void vmsvga_invalidate_display(void *opaque)
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
if (!s->enable) {
#ifdef EMBED_STDVGA
- s->invalidate(opaque);
+ s->vga.invalidate(&s->vga);
#endif
return;
}
@@ -978,14 +978,14 @@ static void vmsvga_screen_dump(void *opaque, const char *filename)
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
if (!s->enable) {
#ifdef EMBED_STDVGA
- s->screen_dump(opaque, filename);
+ s->vga.screen_dump(&s->vga, filename);
#endif
return;
}
if (s->depth == 32) {
DisplaySurface *ds = qemu_create_displaysurface_from(s->width,
- s->height, 32, ds_get_linesize(s->ds), s->vram_ptr);
+ s->height, 32, ds_get_linesize(s->vga.ds), s->vga.vram_ptr);
ppm_save(filename, ds);
qemu_free(ds);
}
@@ -995,8 +995,8 @@ static void vmsvga_text_update(void *opaque, console_ch_t *chardata)
{
struct vmsvga_state_s *s = (struct vmsvga_state_s *) opaque;
- if (s->text_update)
- s->text_update(opaque, chardata);
+ if (s->vga.text_update)
+ s->vga.text_update(&s->vga, chardata);
}
#ifdef DIRECT_VRAM
@@ -1116,7 +1116,7 @@ static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f)
s->invalidated = 1;
if (s->config)
- s->fifo = (uint32_t *) &s->vram_ptr[s->vram_size - SVGA_FIFO_SIZE];
+ s->fifo = (uint32_t *) &s->vga.vram_ptr[s->vga.vram_size - SVGA_FIFO_SIZE];
return 0;
}
@@ -1137,15 +1137,15 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)
s->vram_ptr = qemu_get_ram_ptr(s->vram_offset);
#endif
- s->ds = graphic_console_init(vmsvga_update_display,
- vmsvga_invalidate_display,
- vmsvga_screen_dump,
- vmsvga_text_update, s);
+ s->vga.ds = graphic_console_init(vmsvga_update_display,
+ vmsvga_invalidate_display,
+ vmsvga_screen_dump,
+ vmsvga_text_update, &s->vga);
#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);
+ vga_ram_size, s->vga.vram_offset);
#endif
}
@@ -1204,9 +1204,9 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num,
iomemtype = cpu_register_io_memory(0, vmsvga_vram_read,
vmsvga_vram_write, s);
#else
- iomemtype = s->vram_offset | IO_MEM_RAM;
+ iomemtype = s->vga.vram_offset | IO_MEM_RAM;
#endif
- cpu_register_physical_memory(s->vram_base, s->vram_size,
+ cpu_register_physical_memory(s->vram_base, s->vga.vram_size,
iomemtype);
}