diff options
author | Avi Kivity <avi@redhat.com> | 2009-05-03 22:25:16 +0300 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-05-08 16:11:38 -0500 |
commit | 4e12cd946f9e7a6e3d35bcce0bc7bfe38cec4eb7 (patch) | |
tree | 1b3d29a0a137dac44efe97ac1e89e2d4ca8676c3 /hw/vga_int.h | |
parent | fbb7b4e0804d2168f24142eebf7552adde1968dc (diff) | |
download | qemu-4e12cd946f9e7a6e3d35bcce0bc7bfe38cec4eb7.zip qemu-4e12cd946f9e7a6e3d35bcce0bc7bfe38cec4eb7.tar.gz qemu-4e12cd946f9e7a6e3d35bcce0bc7bfe38cec4eb7.tar.bz2 |
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/vga_int.h')
-rw-r--r-- | hw/vga_int.h | 170 |
1 files changed, 84 insertions, 86 deletions
diff --git a/hw/vga_int.h b/hw/vga_int.h index 1971aa6..3202cde 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -94,94 +94,92 @@ union vga_retrace { struct vga_precise_retrace precise; }; -struct VGAState; -typedef uint8_t (* vga_retrace_fn)(struct VGAState *s); -typedef void (* vga_update_retrace_info_fn)(struct VGAState *s); - -#define VGA_STATE_COMMON \ - uint8_t *vram_ptr; \ - ram_addr_t vram_offset; \ - unsigned int vram_size; \ - uint32_t lfb_addr; \ - uint32_t lfb_end; \ - uint32_t map_addr; \ - uint32_t map_end; \ - uint32_t lfb_vram_mapped; /* whether 0xa0000 is mapped as ram */ \ - unsigned long bios_offset; \ - unsigned int bios_size; \ - int it_shift; \ - PCIDevice *pci_dev; \ - uint32_t latch; \ - uint8_t sr_index; \ - uint8_t sr[256]; \ - uint8_t gr_index; \ - uint8_t gr[256]; \ - uint8_t ar_index; \ - uint8_t ar[21]; \ - int ar_flip_flop; \ - uint8_t cr_index; \ - uint8_t cr[256]; /* CRT registers */ \ - uint8_t msr; /* Misc Output Register */ \ - uint8_t fcr; /* Feature Control Register */ \ - uint8_t st00; /* status 0 */ \ - uint8_t st01; /* status 1 */ \ - uint8_t dac_state; \ - uint8_t dac_sub_index; \ - uint8_t dac_read_index; \ - uint8_t dac_write_index; \ - uint8_t dac_cache[3]; /* used when writing */ \ - int dac_8bit; \ - uint8_t palette[768]; \ - int32_t bank_offset; \ - int vga_io_memory; \ - int (*get_bpp)(struct VGAState *s); \ - void (*get_offsets)(struct VGAState *s, \ - uint32_t *pline_offset, \ - uint32_t *pstart_addr, \ - uint32_t *pline_compare); \ - void (*get_resolution)(struct VGAState *s, \ - int *pwidth, \ - int *pheight); \ - VGA_STATE_COMMON_BOCHS_VBE \ - /* display refresh support */ \ - DisplayState *ds; \ - uint32_t font_offsets[2]; \ - int graphic_mode; \ - uint8_t shift_control; \ - uint8_t double_scan; \ - uint32_t line_offset; \ - uint32_t line_compare; \ - uint32_t start_addr; \ - uint32_t plane_updated; \ - uint32_t last_line_offset; \ - uint8_t last_cw, last_ch; \ - uint32_t last_width, last_height; /* in chars or pixels */ \ - uint32_t last_scr_width, last_scr_height; /* in pixels */ \ - uint32_t last_depth; /* in bits */ \ - uint8_t cursor_start, cursor_end; \ - uint32_t cursor_offset; \ - unsigned int (*rgb_to_pixel)(unsigned int r, \ - unsigned int g, unsigned b); \ - vga_hw_update_ptr update; \ - vga_hw_invalidate_ptr invalidate; \ - vga_hw_screen_dump_ptr screen_dump; \ - vga_hw_text_update_ptr text_update; \ - /* hardware mouse cursor support */ \ - uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; \ - void (*cursor_invalidate)(struct VGAState *s); \ - void (*cursor_draw_line)(struct VGAState *s, uint8_t *d, int y); \ - /* tell for each page if it has been updated since the last time */ \ - uint32_t last_palette[256]; \ - uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */ \ - /* retrace */ \ - vga_retrace_fn retrace; \ - vga_update_retrace_info_fn update_retrace_info; \ +struct VGACommonState; +typedef uint8_t (* vga_retrace_fn)(struct VGACommonState *s); +typedef void (* vga_update_retrace_info_fn)(struct VGACommonState *s); + +typedef struct VGACommonState { + uint8_t *vram_ptr; + ram_addr_t vram_offset; + unsigned int vram_size; + uint32_t lfb_addr; + uint32_t lfb_end; + uint32_t map_addr; + uint32_t map_end; + uint32_t lfb_vram_mapped; /* whether 0xa0000 is mapped as ram */ + unsigned long bios_offset; + unsigned int bios_size; + int it_shift; + PCIDevice *pci_dev; + uint32_t latch; + uint8_t sr_index; + uint8_t sr[256]; + uint8_t gr_index; + uint8_t gr[256]; + uint8_t ar_index; + uint8_t ar[21]; + int ar_flip_flop; + uint8_t cr_index; + uint8_t cr[256]; /* CRT registers */ + uint8_t msr; /* Misc Output Register */ + uint8_t fcr; /* Feature Control Register */ + uint8_t st00; /* status 0 */ + uint8_t st01; /* status 1 */ + uint8_t dac_state; + uint8_t dac_sub_index; + uint8_t dac_read_index; + uint8_t dac_write_index; + uint8_t dac_cache[3]; /* used when writing */ + int dac_8bit; + uint8_t palette[768]; + int32_t bank_offset; + int vga_io_memory; + int (*get_bpp)(struct VGACommonState *s); + void (*get_offsets)(struct VGACommonState *s, + uint32_t *pline_offset, + uint32_t *pstart_addr, + uint32_t *pline_compare); + void (*get_resolution)(struct VGACommonState *s, + int *pwidth, + int *pheight); + VGA_STATE_COMMON_BOCHS_VBE + /* display refresh support */ + DisplayState *ds; + uint32_t font_offsets[2]; + int graphic_mode; + uint8_t shift_control; + uint8_t double_scan; + uint32_t line_offset; + uint32_t line_compare; + uint32_t start_addr; + uint32_t plane_updated; + uint32_t last_line_offset; + uint8_t last_cw, last_ch; + uint32_t last_width, last_height; /* in chars or pixels */ + uint32_t last_scr_width, last_scr_height; /* in pixels */ + uint32_t last_depth; /* in bits */ + uint8_t cursor_start, cursor_end; + uint32_t cursor_offset; + unsigned int (*rgb_to_pixel)(unsigned int r, + unsigned int g, unsigned b); + vga_hw_update_ptr update; + vga_hw_invalidate_ptr invalidate; + vga_hw_screen_dump_ptr screen_dump; + vga_hw_text_update_ptr text_update; + /* hardware mouse cursor support */ + uint32_t invalidated_y_table[VGA_MAX_HEIGHT / 32]; + void (*cursor_invalidate)(struct VGACommonState *s); + void (*cursor_draw_line)(struct VGACommonState *s, uint8_t *d, int y); + /* tell for each page if it has been updated since the last time */ + uint32_t last_palette[256]; + uint32_t last_ch_attr[CH_ATTR_SIZE]; /* XXX: make it dynamic */ + /* retrace */ + vga_retrace_fn retrace; + vga_update_retrace_info_fn update_retrace_info; union vga_retrace retrace_info; +} VGACommonState; - -typedef struct VGAState { - VGA_STATE_COMMON -} VGAState; +typedef VGACommonState VGAState; static inline int c6_to_8(int v) { |