148 |
148 |
static uint16_t expand2[256];
|
149 |
149 |
static uint8_t expand4to8[16];
|
150 |
150 |
|
151 |
|
typedef VGACommonState VGAState;
|
152 |
|
|
153 |
151 |
static void vga_screen_dump(void *opaque, const char *filename);
|
154 |
152 |
static char *screen_dump_filename;
|
155 |
153 |
static DisplayChangeListener *screen_dump_dcl;
|
156 |
154 |
|
157 |
|
static void vga_dumb_update_retrace_info(VGAState *s)
|
|
155 |
static void vga_dumb_update_retrace_info(VGACommonState *s)
|
158 |
156 |
{
|
159 |
157 |
(void) s;
|
160 |
158 |
}
|
161 |
159 |
|
162 |
|
static void vga_precise_update_retrace_info(VGAState *s)
|
|
160 |
static void vga_precise_update_retrace_info(VGACommonState *s)
|
163 |
161 |
{
|
164 |
162 |
int htotal_chars;
|
165 |
163 |
int hretr_start_char;
|
... | ... | |
250 |
248 |
#endif
|
251 |
249 |
}
|
252 |
250 |
|
253 |
|
static uint8_t vga_precise_retrace(VGAState *s)
|
|
251 |
static uint8_t vga_precise_retrace(VGACommonState *s)
|
254 |
252 |
{
|
255 |
253 |
struct vga_precise_retrace *r = &s->retrace_info.precise;
|
256 |
254 |
uint8_t val = s->st01 & ~(ST01_V_RETRACE | ST01_DISP_ENABLE);
|
... | ... | |
279 |
277 |
}
|
280 |
278 |
}
|
281 |
279 |
|
282 |
|
static uint8_t vga_dumb_retrace(VGAState *s)
|
|
280 |
static uint8_t vga_dumb_retrace(VGACommonState *s)
|
283 |
281 |
{
|
284 |
282 |
return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE);
|
285 |
283 |
}
|
... | ... | |
512 |
510 |
#ifdef CONFIG_BOCHS_VBE
|
513 |
511 |
static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
|
514 |
512 |
{
|
515 |
|
VGAState *s = opaque;
|
|
513 |
VGACommonState *s = opaque;
|
516 |
514 |
uint32_t val;
|
517 |
515 |
val = s->vbe_index;
|
518 |
516 |
return val;
|
... | ... | |
520 |
518 |
|
521 |
519 |
static uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
|
522 |
520 |
{
|
523 |
|
VGAState *s = opaque;
|
|
521 |
VGACommonState *s = opaque;
|
524 |
522 |
uint32_t val;
|
525 |
523 |
|
526 |
524 |
if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
|
... | ... | |
554 |
552 |
|
555 |
553 |
static void vbe_ioport_write_index(void *opaque, uint32_t addr, uint32_t val)
|
556 |
554 |
{
|
557 |
|
VGAState *s = opaque;
|
|
555 |
VGACommonState *s = opaque;
|
558 |
556 |
s->vbe_index = val;
|
559 |
557 |
}
|
560 |
558 |
|
561 |
559 |
static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val)
|
562 |
560 |
{
|
563 |
|
VGAState *s = opaque;
|
|
561 |
VGACommonState *s = opaque;
|
564 |
562 |
|
565 |
563 |
if (s->vbe_index <= VBE_DISPI_INDEX_NB) {
|
566 |
564 |
#ifdef DEBUG_BOCHS_VBE
|
... | ... | |
706 |
704 |
/* called for accesses between 0xa0000 and 0xc0000 */
|
707 |
705 |
uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr)
|
708 |
706 |
{
|
709 |
|
VGAState *s = opaque;
|
|
707 |
VGACommonState *s = opaque;
|
710 |
708 |
int memory_map_mode, plane;
|
711 |
709 |
uint32_t ret;
|
712 |
710 |
|
... | ... | |
793 |
791 |
/* called for accesses between 0xa0000 and 0xc0000 */
|
794 |
792 |
void vga_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
|
795 |
793 |
{
|
796 |
|
VGAState *s = opaque;
|
|
794 |
VGACommonState *s = opaque;
|
797 |
795 |
int memory_map_mode, plane, write_mode, b, func_select, mask;
|
798 |
796 |
uint32_t write_mask, bit_mask, set_mask;
|
799 |
797 |
|
... | ... | |
957 |
955 |
typedef void vga_draw_glyph9_func(uint8_t *d, int linesize,
|
958 |
956 |
const uint8_t *font_ptr, int h,
|
959 |
957 |
uint32_t fgcol, uint32_t bgcol, int dup9);
|
960 |
|
typedef void vga_draw_line_func(VGAState *s1, uint8_t *d,
|
|
958 |
typedef void vga_draw_line_func(VGACommonState *s1, uint8_t *d,
|
961 |
959 |
const uint8_t *s, int width);
|
962 |
960 |
|
963 |
961 |
#define DEPTH 8
|
... | ... | |
1042 |
1040 |
}
|
1043 |
1041 |
|
1044 |
1042 |
/* return true if the palette was modified */
|
1045 |
|
static int update_palette16(VGAState *s)
|
|
1043 |
static int update_palette16(VGACommonState *s)
|
1046 |
1044 |
{
|
1047 |
1045 |
int full_update, i;
|
1048 |
1046 |
uint32_t v, col, *palette;
|
... | ... | |
1068 |
1066 |
}
|
1069 |
1067 |
|
1070 |
1068 |
/* return true if the palette was modified */
|
1071 |
|
static int update_palette256(VGAState *s)
|
|
1069 |
static int update_palette256(VGACommonState *s)
|
1072 |
1070 |
{
|
1073 |
1071 |
int full_update, i;
|
1074 |
1072 |
uint32_t v, col, *palette;
|
... | ... | |
1095 |
1093 |
return full_update;
|
1096 |
1094 |
}
|
1097 |
1095 |
|
1098 |
|
static void vga_get_offsets(VGAState *s,
|
|
1096 |
static void vga_get_offsets(VGACommonState *s,
|
1099 |
1097 |
uint32_t *pline_offset,
|
1100 |
1098 |
uint32_t *pstart_addr,
|
1101 |
1099 |
uint32_t *pline_compare)
|
... | ... | |
1127 |
1125 |
}
|
1128 |
1126 |
|
1129 |
1127 |
/* update start_addr and line_offset. Return TRUE if modified */
|
1130 |
|
static int update_basic_params(VGAState *s)
|
|
1128 |
static int update_basic_params(VGACommonState *s)
|
1131 |
1129 |
{
|
1132 |
1130 |
int full_update;
|
1133 |
1131 |
uint32_t start_addr, line_offset, line_compare;
|
... | ... | |
1216 |
1214 |
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
1217 |
1215 |
};
|
1218 |
1216 |
|
1219 |
|
static void vga_get_text_resolution(VGAState *s, int *pwidth, int *pheight,
|
|
1217 |
static void vga_get_text_resolution(VGACommonState *s, int *pwidth, int *pheight,
|
1220 |
1218 |
int *pcwidth, int *pcheight)
|
1221 |
1219 |
{
|
1222 |
1220 |
int width, cwidth, height, cheight;
|
... | ... | |
1265 |
1263 |
* - underline
|
1266 |
1264 |
* - flashing
|
1267 |
1265 |
*/
|
1268 |
|
static void vga_draw_text(VGAState *s, int full_update)
|
|
1266 |
static void vga_draw_text(VGACommonState *s, int full_update)
|
1269 |
1267 |
{
|
1270 |
1268 |
int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;
|
1271 |
1269 |
int cx_min, cx_max, linesize, x_incr;
|
... | ... | |
1520 |
1518 |
vga_draw_line32_16bgr,
|
1521 |
1519 |
};
|
1522 |
1520 |
|
1523 |
|
static int vga_get_bpp(VGAState *s)
|
|
1521 |
static int vga_get_bpp(VGACommonState *s)
|
1524 |
1522 |
{
|
1525 |
1523 |
int ret;
|
1526 |
1524 |
#ifdef CONFIG_BOCHS_VBE
|
... | ... | |
1534 |
1532 |
return ret;
|
1535 |
1533 |
}
|
1536 |
1534 |
|
1537 |
|
static void vga_get_resolution(VGAState *s, int *pwidth, int *pheight)
|
|
1535 |
static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight)
|
1538 |
1536 |
{
|
1539 |
1537 |
int width, height;
|
1540 |
1538 |
|
... | ... | |
1555 |
1553 |
*pheight = height;
|
1556 |
1554 |
}
|
1557 |
1555 |
|
1558 |
|
void vga_invalidate_scanlines(VGAState *s, int y1, int y2)
|
|
1556 |
void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2)
|
1559 |
1557 |
{
|
1560 |
1558 |
int y;
|
1561 |
1559 |
if (y1 >= VGA_MAX_HEIGHT)
|
... | ... | |
1567 |
1565 |
}
|
1568 |
1566 |
}
|
1569 |
1567 |
|
1570 |
|
static void vga_sync_dirty_bitmap(VGAState *s)
|
|
1568 |
static void vga_sync_dirty_bitmap(VGACommonState *s)
|
1571 |
1569 |
{
|
1572 |
1570 |
if (s->map_addr)
|
1573 |
1571 |
cpu_physical_sync_dirty_bitmap(s->map_addr, s->map_end);
|
... | ... | |
1581 |
1579 |
/*
|
1582 |
1580 |
* graphic modes
|
1583 |
1581 |
*/
|
1584 |
|
static void vga_draw_graphic(VGAState *s, int full_update)
|
|
1582 |
static void vga_draw_graphic(VGACommonState *s, int full_update)
|
1585 |
1583 |
{
|
1586 |
1584 |
int y1, y, update, linesize, y_start, double_scan, mask, depth;
|
1587 |
1585 |
int width, height, shift_control, line_offset, bwidth, bits;
|
... | ... | |
1798 |
1796 |
memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);
|
1799 |
1797 |
}
|
1800 |
1798 |
|
1801 |
|
static void vga_draw_blank(VGAState *s, int full_update)
|
|
1799 |
static void vga_draw_blank(VGACommonState *s, int full_update)
|
1802 |
1800 |
{
|
1803 |
1801 |
int i, w, val;
|
1804 |
1802 |
uint8_t *d;
|
... | ... | |
1830 |
1828 |
|
1831 |
1829 |
static void vga_update_display(void *opaque)
|
1832 |
1830 |
{
|
1833 |
|
VGAState *s = opaque;
|
|
1831 |
VGACommonState *s = opaque;
|
1834 |
1832 |
int full_update, graphic_mode;
|
1835 |
1833 |
|
1836 |
1834 |
if (ds_get_bits_per_pixel(s->ds) == 0) {
|
... | ... | |
1865 |
1863 |
/* force a full display refresh */
|
1866 |
1864 |
static void vga_invalidate_display(void *opaque)
|
1867 |
1865 |
{
|
1868 |
|
VGAState *s = opaque;
|
|
1866 |
VGACommonState *s = opaque;
|
1869 |
1867 |
|
1870 |
1868 |
s->full_update = 1;
|
1871 |
1869 |
}
|
... | ... | |
1939 |
1937 |
|
1940 |
1938 |
static void vga_reset(void *opaque)
|
1941 |
1939 |
{
|
1942 |
|
VGAState *s = opaque;
|
|
1940 |
VGACommonState *s = opaque;
|
1943 |
1941 |
vga_common_reset(s);
|
1944 |
1942 |
}
|
1945 |
1943 |
|
... | ... | |
1951 |
1949 |
* instead of doing a full vga_update_display() */
|
1952 |
1950 |
static void vga_update_text(void *opaque, console_ch_t *chardata)
|
1953 |
1951 |
{
|
1954 |
|
VGAState *s = opaque;
|
|
1952 |
VGACommonState *s = opaque;
|
1955 |
1953 |
int graphic_mode, i, cursor_offset, cursor_visible;
|
1956 |
1954 |
int cw, cheight, width, height, size, c_min, c_max;
|
1957 |
1955 |
uint32_t *src;
|
... | ... | |
2265 |
2263 |
}
|
2266 |
2264 |
|
2267 |
2265 |
/* used by both ISA and PCI */
|
2268 |
|
void vga_init(VGAState *s)
|
|
2266 |
void vga_init(VGACommonState *s)
|
2269 |
2267 |
{
|
2270 |
2268 |
int vga_io_memory;
|
2271 |
2269 |
|
... | ... | |
2389 |
2387 |
available */
|
2390 |
2388 |
static void vga_screen_dump(void *opaque, const char *filename)
|
2391 |
2389 |
{
|
2392 |
|
VGAState *s = opaque;
|
|
2390 |
VGACommonState *s = opaque;
|
2393 |
2391 |
|
2394 |
2392 |
if (!screen_dump_dcl)
|
2395 |
2393 |
screen_dump_dcl = vga_screen_dump_init(s->ds);
|