Lines Matching +full:dac +full:- +full:mode +full:- +full:mask
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
129 uint8_t gc_mode_rm; /* read mode */
130 uint8_t gc_mode_wm; /* write mode */
132 uint8_t gc_misc_gm; /* graphics mode */
159 * DAC
175 return (((sc->vga_seq.seq_clock_mode & SEQ_CM_SO) != 0) || in vga_in_reset()
176 ((sc->vga_seq.seq_reset & SEQ_RESET_ASYNC) == 0) || in vga_in_reset()
177 ((sc->vga_seq.seq_reset & SEQ_RESET_SYNC) == 0) || in vga_in_reset()
178 ((sc->vga_crtc.crtc_mode_ctrl & CRTC_MC_TE) == 0)); in vga_in_reset()
189 //old_width = sc->gc_width; in vga_check_size()
190 //old_height = sc->gc_height; in vga_check_size()
191 old_width = sc->gc_image->width; in vga_check_size()
192 old_height = sc->gc_image->height; in vga_check_size()
200 sc->gc_width = (sc->vga_crtc.crtc_horiz_disp_end + 1) * in vga_check_size()
201 sc->vga_seq.seq_cm_dots; in vga_check_size()
203 sc->gc_height = (sc->vga_crtc.crtc_vert_disp_end | in vga_check_size()
204 (((sc->vga_crtc.crtc_overflow & CRTC_OF_VDE8) >> CRTC_OF_VDE8_SHIFT) << 8) | in vga_check_size()
205 (((sc->vga_crtc.crtc_overflow & CRTC_OF_VDE9) >> CRTC_OF_VDE9_SHIFT) << 9)) + 1; in vga_check_size()
207 if (old_width != sc->gc_width || old_height != sc->gc_height) in vga_check_size()
208 bhyvegc_resize(gc, sc->gc_width, sc->gc_height); in vga_check_size()
219 offset = (y * sc->gc_width / 8) + (x / 8); in vga_get_pixel()
220 bit = 7 - (x % 8); in vga_get_pixel()
222 data = (((sc->vga_ram[offset + 0 * 64*KB] >> bit) & 0x1) << 0) | in vga_get_pixel()
223 (((sc->vga_ram[offset + 1 * 64*KB] >> bit) & 0x1) << 1) | in vga_get_pixel()
224 (((sc->vga_ram[offset + 2 * 64*KB] >> bit) & 0x1) << 2) | in vga_get_pixel()
225 (((sc->vga_ram[offset + 3 * 64*KB] >> bit) & 0x1) << 3); in vga_get_pixel()
227 data &= sc->vga_atc.atc_color_plane_enb; in vga_get_pixel()
229 if (sc->vga_atc.atc_mode & ATC_MC_IPS) { in vga_get_pixel()
230 idx = sc->vga_atc.atc_palette[data] & 0x0f; in vga_get_pixel()
231 idx |= sc->vga_atc.atc_color_select_45; in vga_get_pixel()
233 idx = sc->vga_atc.atc_palette[data]; in vga_get_pixel()
235 idx |= sc->vga_atc.atc_color_select_67; in vga_get_pixel()
237 return (sc->vga_dac.dac_palette_rgb[idx]); in vga_get_pixel()
245 for (y = 0; y < sc->gc_height; y++) { in vga_render_graphics()
246 for (x = 0; x < sc->gc_width; x++) { in vga_render_graphics()
249 offset = y * sc->gc_width + x; in vga_render_graphics()
250 sc->gc_image->data[offset] = vga_get_pixel(sc, x, y); in vga_render_graphics()
262 dots = sc->vga_seq.seq_cm_dots; in vga_get_text_pixel()
264 offset = 2 * sc->vga_crtc.crtc_start_addr; in vga_get_text_pixel()
265 offset += (y / 16 * sc->gc_width / dots) * 2 + (x / dots) * 2; in vga_get_text_pixel()
267 bit = 7 - (x % dots > 7 ? 7 : x % dots); in vga_get_text_pixel()
269 ch = sc->vga_ram[offset + 0 * 64*KB]; in vga_get_text_pixel()
270 attr = sc->vga_ram[offset + 1 * 64*KB]; in vga_get_text_pixel()
272 if (sc->vga_crtc.crtc_cursor_on && in vga_get_text_pixel()
273 (offset == (sc->vga_crtc.crtc_cursor_loc * 2)) && in vga_get_text_pixel()
274 ((y % 16) >= (sc->vga_crtc.crtc_cursor_start & CRTC_CS_CS)) && in vga_get_text_pixel()
275 ((y % 16) <= (sc->vga_crtc.crtc_cursor_end & CRTC_CE_CE))) { in vga_get_text_pixel()
276 idx = sc->vga_atc.atc_palette[attr & 0xf]; in vga_get_text_pixel()
277 return (sc->vga_dac.dac_palette_rgb[idx]); in vga_get_text_pixel()
280 if ((sc->vga_seq.seq_mm & SEQ_MM_EM) && in vga_get_text_pixel()
281 sc->vga_seq.seq_cmap_pri_off != sc->vga_seq.seq_cmap_sec_off) { in vga_get_text_pixel()
283 font_offset = sc->vga_seq.seq_cmap_pri_off + in vga_get_text_pixel()
286 font_offset = sc->vga_seq.seq_cmap_sec_off + in vga_get_text_pixel()
293 font = sc->vga_ram[font_offset + 2 * 64*KB]; in vga_get_text_pixel()
296 idx = sc->vga_atc.atc_palette[attr & 0xf]; in vga_get_text_pixel()
298 idx = sc->vga_atc.atc_palette[attr >> 4]; in vga_get_text_pixel()
300 return (sc->vga_dac.dac_palette_rgb[idx]); in vga_get_text_pixel()
308 for (y = 0; y < sc->gc_height; y++) { in vga_render_text()
309 for (x = 0; x < sc->gc_width; x++) { in vga_render_text()
312 offset = y * sc->gc_width + x; in vga_render_text()
313 sc->gc_image->data[offset] = vga_get_text_pixel(sc, x, y); in vga_render_text()
326 memset(sc->gc_image->data, 0, in vga_render()
327 sc->gc_image->width * sc->gc_image->height * in vga_render()
332 if (sc->vga_gc.gc_misc_gm && (sc->vga_atc.atc_mode & ATC_MC_GA)) in vga_render()
346 switch (sc->vga_gc.gc_misc_mm) { in vga_mem_rd_handler()
349 * extended mode: base 0xa0000 size 128k in vga_mem_rd_handler()
351 offset -=0xa0000; in vga_mem_rd_handler()
352 offset &= (128 * KB - 1); in vga_mem_rd_handler()
356 * EGA/VGA mode: base 0xa0000 size 64k in vga_mem_rd_handler()
358 offset -=0xa0000; in vga_mem_rd_handler()
359 offset &= (64 * KB - 1); in vga_mem_rd_handler()
363 * monochrome text mode: base 0xb0000 size 32kb in vga_mem_rd_handler()
368 * color text mode and CGA: base 0xb8000 size 32kb in vga_mem_rd_handler()
370 offset -=0xb8000; in vga_mem_rd_handler()
371 offset &= (32 * KB - 1); in vga_mem_rd_handler()
376 sc->vga_gc.gc_latch0 = sc->vga_ram[offset + 0*64*KB]; in vga_mem_rd_handler()
377 sc->vga_gc.gc_latch1 = sc->vga_ram[offset + 1*64*KB]; in vga_mem_rd_handler()
378 sc->vga_gc.gc_latch2 = sc->vga_ram[offset + 2*64*KB]; in vga_mem_rd_handler()
379 sc->vga_gc.gc_latch3 = sc->vga_ram[offset + 3*64*KB]; in vga_mem_rd_handler()
381 if (sc->vga_gc.gc_mode_rm) { in vga_mem_rd_handler()
382 /* read mode 1 */ in vga_mem_rd_handler()
386 map_sel = sc->vga_gc.gc_read_map_sel; in vga_mem_rd_handler()
387 if (sc->vga_gc.gc_mode_oe) { in vga_mem_rd_handler()
392 /* read mode 0: return the byte from the selected plane. */ in vga_mem_rd_handler()
395 return (sc->vga_ram[offset]); in vga_mem_rd_handler()
406 uint8_t mask; in vga_mem_wr_handler() local
410 switch (sc->vga_gc.gc_misc_mm) { in vga_mem_wr_handler()
413 * extended mode: base 0xa0000 size 128kb in vga_mem_wr_handler()
415 offset -=0xa0000; in vga_mem_wr_handler()
416 offset &= (128 * KB - 1); in vga_mem_wr_handler()
420 * EGA/VGA mode: base 0xa0000 size 64kb in vga_mem_wr_handler()
422 offset -=0xa0000; in vga_mem_wr_handler()
423 offset &= (64 * KB - 1); in vga_mem_wr_handler()
427 * monochrome text mode: base 0xb0000 size 32kb in vga_mem_wr_handler()
432 * color text mode and CGA: base 0xb8000 size 32kb in vga_mem_wr_handler()
434 offset -=0xb8000; in vga_mem_wr_handler()
435 offset &= (32 * KB - 1); in vga_mem_wr_handler()
439 set_reset = sc->vga_gc.gc_set_reset; in vga_mem_wr_handler()
440 enb_set_reset = sc->vga_gc.gc_enb_set_reset; in vga_mem_wr_handler()
442 c0 = sc->vga_gc.gc_latch0; in vga_mem_wr_handler()
443 c1 = sc->vga_gc.gc_latch1; in vga_mem_wr_handler()
444 c2 = sc->vga_gc.gc_latch2; in vga_mem_wr_handler()
445 c3 = sc->vga_gc.gc_latch3; in vga_mem_wr_handler()
447 switch (sc->vga_gc.gc_mode_wm) { in vga_mem_wr_handler()
449 /* write mode 0 */ in vga_mem_wr_handler()
450 mask = sc->vga_gc.gc_bit_mask; in vga_mem_wr_handler()
452 val = (val >> sc->vga_gc.gc_rotate) | in vga_mem_wr_handler()
453 (val << (8 - sc->vga_gc.gc_rotate)); in vga_mem_wr_handler()
455 switch (sc->vga_gc.gc_op) { in vga_mem_wr_handler()
457 m0 = (set_reset & 1) ? mask : 0x00; in vga_mem_wr_handler()
458 m1 = (set_reset & 2) ? mask : 0x00; in vga_mem_wr_handler()
459 m2 = (set_reset & 4) ? mask : 0x00; in vga_mem_wr_handler()
460 m3 = (set_reset & 8) ? mask : 0x00; in vga_mem_wr_handler()
462 c0 = (enb_set_reset & 1) ? (c0 & ~mask) : (val & mask); in vga_mem_wr_handler()
463 c1 = (enb_set_reset & 2) ? (c1 & ~mask) : (val & mask); in vga_mem_wr_handler()
464 c2 = (enb_set_reset & 4) ? (c2 & ~mask) : (val & mask); in vga_mem_wr_handler()
465 c3 = (enb_set_reset & 8) ? (c3 & ~mask) : (val & mask); in vga_mem_wr_handler()
473 m0 = set_reset & 1 ? 0xff : ~mask; in vga_mem_wr_handler()
474 m1 = set_reset & 2 ? 0xff : ~mask; in vga_mem_wr_handler()
475 m2 = set_reset & 4 ? 0xff : ~mask; in vga_mem_wr_handler()
476 m3 = set_reset & 8 ? 0xff : ~mask; in vga_mem_wr_handler()
484 m0 = set_reset & 1 ? mask : 0x00; in vga_mem_wr_handler()
485 m1 = set_reset & 2 ? mask : 0x00; in vga_mem_wr_handler()
486 m2 = set_reset & 4 ? mask : 0x00; in vga_mem_wr_handler()
487 m3 = set_reset & 8 ? mask : 0x00; in vga_mem_wr_handler()
495 m0 = set_reset & 1 ? mask : 0x00; in vga_mem_wr_handler()
496 m1 = set_reset & 2 ? mask : 0x00; in vga_mem_wr_handler()
497 m2 = set_reset & 4 ? mask : 0x00; in vga_mem_wr_handler()
498 m3 = set_reset & 8 ? mask : 0x00; in vga_mem_wr_handler()
508 /* write mode 1 */ in vga_mem_wr_handler()
511 /* write mode 2 */ in vga_mem_wr_handler()
512 mask = sc->vga_gc.gc_bit_mask; in vga_mem_wr_handler()
514 switch (sc->vga_gc.gc_op) { in vga_mem_wr_handler()
516 m0 = (val & 1 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
517 m1 = (val & 2 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
518 m2 = (val & 4 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
519 m3 = (val & 8 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
521 c0 &= ~mask; in vga_mem_wr_handler()
522 c1 &= ~mask; in vga_mem_wr_handler()
523 c2 &= ~mask; in vga_mem_wr_handler()
524 c3 &= ~mask; in vga_mem_wr_handler()
532 m0 = (val & 1 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
533 m1 = (val & 2 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
534 m2 = (val & 4 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
535 m3 = (val & 8 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
543 m0 = (val & 1 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
544 m1 = (val & 2 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
545 m2 = (val & 4 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
546 m3 = (val & 8 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
554 m0 = (val & 1 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
555 m1 = (val & 2 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
556 m2 = (val & 4 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
557 m3 = (val & 8 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
567 /* write mode 3 */ in vga_mem_wr_handler()
568 mask = sc->vga_gc.gc_bit_mask & val; in vga_mem_wr_handler()
570 val = (val >> sc->vga_gc.gc_rotate) | in vga_mem_wr_handler()
571 (val << (8 - sc->vga_gc.gc_rotate)); in vga_mem_wr_handler()
573 switch (sc->vga_gc.gc_op) { in vga_mem_wr_handler()
575 m0 = (set_reset & 1 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
576 m1 = (set_reset & 2 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
577 m2 = (set_reset & 4 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
578 m3 = (set_reset & 8 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
580 c0 &= ~mask; in vga_mem_wr_handler()
581 c1 &= ~mask; in vga_mem_wr_handler()
582 c2 &= ~mask; in vga_mem_wr_handler()
583 c3 &= ~mask; in vga_mem_wr_handler()
591 m0 = (set_reset & 1 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
592 m1 = (set_reset & 2 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
593 m2 = (set_reset & 4 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
594 m3 = (set_reset & 8 ? 0xff : 0x00) | ~mask; in vga_mem_wr_handler()
602 m0 = (set_reset & 1 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
603 m1 = (set_reset & 2 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
604 m2 = (set_reset & 4 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
605 m3 = (set_reset & 8 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
613 m0 = (set_reset & 1 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
614 m1 = (set_reset & 2 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
615 m2 = (set_reset & 4 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
616 m3 = (set_reset & 8 ? 0xff : 0x00) & mask; in vga_mem_wr_handler()
627 if (sc->vga_gc.gc_mode_oe) { in vga_mem_wr_handler()
630 if (sc->vga_seq.seq_map_mask & 2) in vga_mem_wr_handler()
631 sc->vga_ram[offset + 1*64*KB] = c1; in vga_mem_wr_handler()
632 if (sc->vga_seq.seq_map_mask & 8) in vga_mem_wr_handler()
633 sc->vga_ram[offset + 3*64*KB] = c3; in vga_mem_wr_handler()
635 if (sc->vga_seq.seq_map_mask & 1) in vga_mem_wr_handler()
636 sc->vga_ram[offset + 0*64*KB] = c0; in vga_mem_wr_handler()
637 if (sc->vga_seq.seq_map_mask & 4) in vga_mem_wr_handler()
638 sc->vga_ram[offset + 2*64*KB] = c2; in vga_mem_wr_handler()
641 if (sc->vga_seq.seq_map_mask & 1) in vga_mem_wr_handler()
642 sc->vga_ram[offset + 0*64*KB] = c0; in vga_mem_wr_handler()
643 if (sc->vga_seq.seq_map_mask & 2) in vga_mem_wr_handler()
644 sc->vga_ram[offset + 1*64*KB] = c1; in vga_mem_wr_handler()
645 if (sc->vga_seq.seq_map_mask & 4) in vga_mem_wr_handler()
646 sc->vga_ram[offset + 2*64*KB] = c2; in vga_mem_wr_handler()
647 if (sc->vga_seq.seq_map_mask & 8) in vga_mem_wr_handler()
648 sc->vga_ram[offset + 3*64*KB] = c3; in vga_mem_wr_handler()
722 *val = sc->vga_crtc.crtc_index; in vga_port_in_handler()
726 switch (sc->vga_crtc.crtc_index) { in vga_port_in_handler()
728 *val = sc->vga_crtc.crtc_horiz_total; in vga_port_in_handler()
731 *val = sc->vga_crtc.crtc_horiz_disp_end; in vga_port_in_handler()
734 *val = sc->vga_crtc.crtc_start_horiz_blank; in vga_port_in_handler()
737 *val = sc->vga_crtc.crtc_end_horiz_blank; in vga_port_in_handler()
740 *val = sc->vga_crtc.crtc_start_horiz_retrace; in vga_port_in_handler()
743 *val = sc->vga_crtc.crtc_end_horiz_retrace; in vga_port_in_handler()
746 *val = sc->vga_crtc.crtc_vert_total; in vga_port_in_handler()
749 *val = sc->vga_crtc.crtc_overflow; in vga_port_in_handler()
752 *val = sc->vga_crtc.crtc_present_row_scan; in vga_port_in_handler()
755 *val = sc->vga_crtc.crtc_max_scan_line; in vga_port_in_handler()
758 *val = sc->vga_crtc.crtc_cursor_start; in vga_port_in_handler()
761 *val = sc->vga_crtc.crtc_cursor_end; in vga_port_in_handler()
764 *val = sc->vga_crtc.crtc_start_addr_high; in vga_port_in_handler()
767 *val = sc->vga_crtc.crtc_start_addr_low; in vga_port_in_handler()
770 *val = sc->vga_crtc.crtc_cursor_loc_high; in vga_port_in_handler()
773 *val = sc->vga_crtc.crtc_cursor_loc_low; in vga_port_in_handler()
776 *val = sc->vga_crtc.crtc_vert_retrace_start; in vga_port_in_handler()
779 *val = sc->vga_crtc.crtc_vert_retrace_end; in vga_port_in_handler()
782 *val = sc->vga_crtc.crtc_vert_disp_end; in vga_port_in_handler()
785 *val = sc->vga_crtc.crtc_offset; in vga_port_in_handler()
788 *val = sc->vga_crtc.crtc_underline_loc; in vga_port_in_handler()
791 *val = sc->vga_crtc.crtc_start_vert_blank; in vga_port_in_handler()
794 *val = sc->vga_crtc.crtc_end_vert_blank; in vga_port_in_handler()
797 *val = sc->vga_crtc.crtc_mode_ctrl; in vga_port_in_handler()
800 *val = sc->vga_crtc.crtc_line_compare; in vga_port_in_handler()
803 //printf("XXX VGA CRTC: inb 0x%04x at index %d\n", port, sc->vga_crtc.crtc_index); in vga_port_in_handler()
809 *val = sc->vga_atc.atc_index; in vga_port_in_handler()
812 switch (sc->vga_atc.atc_index) { in vga_port_in_handler()
814 *val = sc->vga_atc.atc_palette[sc->vga_atc.atc_index]; in vga_port_in_handler()
817 *val = sc->vga_atc.atc_mode; in vga_port_in_handler()
820 *val = sc->vga_atc.atc_overscan_color; in vga_port_in_handler()
823 *val = sc->vga_atc.atc_color_plane_enb; in vga_port_in_handler()
826 *val = sc->vga_atc.atc_horiz_pixel_panning; in vga_port_in_handler()
829 *val = sc->vga_atc.atc_color_select; in vga_port_in_handler()
832 //printf("XXX VGA ATC inb 0x%04x at index %d\n", port , sc->vga_atc.atc_index); in vga_port_in_handler()
838 *val = sc->vga_seq.seq_index; in vga_port_in_handler()
841 switch (sc->vga_seq.seq_index) { in vga_port_in_handler()
843 *val = sc->vga_seq.seq_reset; in vga_port_in_handler()
846 *val = sc->vga_seq.seq_clock_mode; in vga_port_in_handler()
849 *val = sc->vga_seq.seq_map_mask; in vga_port_in_handler()
852 *val = sc->vga_seq.seq_cmap_sel; in vga_port_in_handler()
855 *val = sc->vga_seq.seq_mm; in vga_port_in_handler()
858 //printf("XXX VGA SEQ: inb 0x%04x at index %d\n", port, sc->vga_seq.seq_index); in vga_port_in_handler()
864 *val = sc->vga_dac.dac_palette[3 * sc->vga_dac.dac_rd_index + in vga_port_in_handler()
865 sc->vga_dac.dac_rd_subindex]; in vga_port_in_handler()
866 sc->vga_dac.dac_rd_subindex++; in vga_port_in_handler()
867 if (sc->vga_dac.dac_rd_subindex == 3) { in vga_port_in_handler()
868 sc->vga_dac.dac_rd_index++; in vga_port_in_handler()
869 sc->vga_dac.dac_rd_subindex = 0; in vga_port_in_handler()
873 *val = sc->vga_gc.gc_index; in vga_port_in_handler()
876 switch (sc->vga_gc.gc_index) { in vga_port_in_handler()
878 *val = sc->vga_gc.gc_set_reset; in vga_port_in_handler()
881 *val = sc->vga_gc.gc_enb_set_reset; in vga_port_in_handler()
884 *val = sc->vga_gc.gc_color_compare; in vga_port_in_handler()
887 *val = sc->vga_gc.gc_rotate; in vga_port_in_handler()
890 *val = sc->vga_gc.gc_read_map_sel; in vga_port_in_handler()
893 *val = sc->vga_gc.gc_mode; in vga_port_in_handler()
896 *val = sc->vga_gc.gc_misc; in vga_port_in_handler()
899 *val = sc->vga_gc.gc_color_dont_care; in vga_port_in_handler()
902 *val = sc->vga_gc.gc_bit_mask; in vga_port_in_handler()
905 //printf("XXX VGA GC: inb 0x%04x at index %d\n", port, sc->vga_crtc.crtc_index); in vga_port_in_handler()
911 *val = sc->vga_misc; in vga_port_in_handler()
918 sc->vga_atc.atc_flipflop = 0; in vga_port_in_handler()
919 sc->vga_sts1 = GEN_IS1_VR | GEN_IS1_DE; in vga_port_in_handler()
920 //sc->vga_sts1 ^= (GEN_IS1_VR | GEN_IS1_DE); in vga_port_in_handler()
921 *val = sc->vga_sts1; in vga_port_in_handler()
934 return (-1); in vga_port_in_handler()
949 sc->vga_crtc.crtc_index = val; in vga_port_out_handler()
953 switch (sc->vga_crtc.crtc_index) { in vga_port_out_handler()
955 sc->vga_crtc.crtc_horiz_total = val; in vga_port_out_handler()
958 sc->vga_crtc.crtc_horiz_disp_end = val; in vga_port_out_handler()
961 sc->vga_crtc.crtc_start_horiz_blank = val; in vga_port_out_handler()
964 sc->vga_crtc.crtc_end_horiz_blank = val; in vga_port_out_handler()
967 sc->vga_crtc.crtc_start_horiz_retrace = val; in vga_port_out_handler()
970 sc->vga_crtc.crtc_end_horiz_retrace = val; in vga_port_out_handler()
973 sc->vga_crtc.crtc_vert_total = val; in vga_port_out_handler()
976 sc->vga_crtc.crtc_overflow = val; in vga_port_out_handler()
979 sc->vga_crtc.crtc_present_row_scan = val; in vga_port_out_handler()
982 sc->vga_crtc.crtc_max_scan_line = val; in vga_port_out_handler()
985 sc->vga_crtc.crtc_cursor_start = val; in vga_port_out_handler()
986 sc->vga_crtc.crtc_cursor_on = (val & CRTC_CS_CO) == 0; in vga_port_out_handler()
989 sc->vga_crtc.crtc_cursor_end = val; in vga_port_out_handler()
992 sc->vga_crtc.crtc_start_addr_high = val; in vga_port_out_handler()
993 sc->vga_crtc.crtc_start_addr &= 0x00ff; in vga_port_out_handler()
994 sc->vga_crtc.crtc_start_addr |= (val << 8); in vga_port_out_handler()
997 sc->vga_crtc.crtc_start_addr_low = val; in vga_port_out_handler()
998 sc->vga_crtc.crtc_start_addr &= 0xff00; in vga_port_out_handler()
999 sc->vga_crtc.crtc_start_addr |= (val & 0xff); in vga_port_out_handler()
1002 sc->vga_crtc.crtc_cursor_loc_high = val; in vga_port_out_handler()
1003 sc->vga_crtc.crtc_cursor_loc &= 0x00ff; in vga_port_out_handler()
1004 sc->vga_crtc.crtc_cursor_loc |= (val << 8); in vga_port_out_handler()
1007 sc->vga_crtc.crtc_cursor_loc_low = val; in vga_port_out_handler()
1008 sc->vga_crtc.crtc_cursor_loc &= 0xff00; in vga_port_out_handler()
1009 sc->vga_crtc.crtc_cursor_loc |= (val & 0xff); in vga_port_out_handler()
1012 sc->vga_crtc.crtc_vert_retrace_start = val; in vga_port_out_handler()
1015 sc->vga_crtc.crtc_vert_retrace_end = val; in vga_port_out_handler()
1018 sc->vga_crtc.crtc_vert_disp_end = val; in vga_port_out_handler()
1021 sc->vga_crtc.crtc_offset = val; in vga_port_out_handler()
1024 sc->vga_crtc.crtc_underline_loc = val; in vga_port_out_handler()
1027 sc->vga_crtc.crtc_start_vert_blank = val; in vga_port_out_handler()
1030 sc->vga_crtc.crtc_end_vert_blank = val; in vga_port_out_handler()
1033 sc->vga_crtc.crtc_mode_ctrl = val; in vga_port_out_handler()
1036 sc->vga_crtc.crtc_line_compare = val; in vga_port_out_handler()
1039 //printf("XXX VGA CRTC: outb 0x%04x, 0x%02x at index %d\n", port, val, sc->vga_crtc.crtc_index); in vga_port_out_handler()
1045 if (sc->vga_atc.atc_flipflop == 0) { in vga_port_out_handler()
1046 if (sc->vga_atc.atc_index & 0x20) in vga_port_out_handler()
1048 sc->vga_atc.atc_index = val & ATC_IDX_MASK; in vga_port_out_handler()
1050 switch (sc->vga_atc.atc_index) { in vga_port_out_handler()
1052 sc->vga_atc.atc_palette[sc->vga_atc.atc_index] = val & 0x3f; in vga_port_out_handler()
1055 sc->vga_atc.atc_mode = val; in vga_port_out_handler()
1058 sc->vga_atc.atc_overscan_color = val; in vga_port_out_handler()
1061 sc->vga_atc.atc_color_plane_enb = val; in vga_port_out_handler()
1064 sc->vga_atc.atc_horiz_pixel_panning = val; in vga_port_out_handler()
1067 sc->vga_atc.atc_color_select = val; in vga_port_out_handler()
1068 sc->vga_atc.atc_color_select_45 = in vga_port_out_handler()
1070 sc->vga_atc.atc_color_select_67 = in vga_port_out_handler()
1074 //printf("XXX VGA ATC: outb 0x%04x, 0x%02x at index %d\n", port, val, sc->vga_atc.atc_index); in vga_port_out_handler()
1079 sc->vga_atc.atc_flipflop ^= 1; in vga_port_out_handler()
1084 sc->vga_seq.seq_index = val & 0x1f; in vga_port_out_handler()
1087 switch (sc->vga_seq.seq_index) { in vga_port_out_handler()
1089 sc->vga_seq.seq_reset = val; in vga_port_out_handler()
1092 sc->vga_seq.seq_clock_mode = val; in vga_port_out_handler()
1093 sc->vga_seq.seq_cm_dots = (val & SEQ_CM_89) ? 8 : 9; in vga_port_out_handler()
1096 sc->vga_seq.seq_map_mask = val; in vga_port_out_handler()
1099 sc->vga_seq.seq_cmap_sel = val; in vga_port_out_handler()
1101 …sc->vga_seq.seq_cmap_pri_off = ((((val & SEQ_CMS_SA) >> SEQ_CMS_SA_SHIFT) * 2) + ((val & SEQ_CMS_S… in vga_port_out_handler()
1102 …sc->vga_seq.seq_cmap_sec_off = ((((val & SEQ_CMS_SB) >> SEQ_CMS_SB_SHIFT) * 2) + ((val & SEQ_CMS_S… in vga_port_out_handler()
1105 sc->vga_seq.seq_mm = val; in vga_port_out_handler()
1107 //assert((sc->vga_seq.seq_mm & SEQ_MM_C4) == 0); in vga_port_out_handler()
1110 //printf("XXX VGA SEQ: outb 0x%04x, 0x%02x at index %d\n", port, val, sc->vga_seq.seq_index); in vga_port_out_handler()
1118 sc->vga_dac.dac_rd_index = val; in vga_port_out_handler()
1119 sc->vga_dac.dac_rd_subindex = 0; in vga_port_out_handler()
1122 sc->vga_dac.dac_wr_index = val; in vga_port_out_handler()
1123 sc->vga_dac.dac_wr_subindex = 0; in vga_port_out_handler()
1126 sc->vga_dac.dac_palette[3 * sc->vga_dac.dac_wr_index + in vga_port_out_handler()
1127 sc->vga_dac.dac_wr_subindex] = val; in vga_port_out_handler()
1128 sc->vga_dac.dac_wr_subindex++; in vga_port_out_handler()
1129 if (sc->vga_dac.dac_wr_subindex == 3) { in vga_port_out_handler()
1130 sc->vga_dac.dac_palette_rgb[sc->vga_dac.dac_wr_index] = in vga_port_out_handler()
1131 ((((sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 0] << 2) | in vga_port_out_handler()
1132 ((sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 0] & 0x1) << 1) | in vga_port_out_handler()
1133 (sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 0] & 0x1)) << 16) | in vga_port_out_handler()
1134 (((sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 1] << 2) | in vga_port_out_handler()
1135 ((sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 1] & 0x1) << 1) | in vga_port_out_handler()
1136 (sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 1] & 0x1)) << 8) | in vga_port_out_handler()
1137 (((sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 2] << 2) | in vga_port_out_handler()
1138 ((sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 2] & 0x1) << 1) | in vga_port_out_handler()
1139 (sc->vga_dac.dac_palette[3*sc->vga_dac.dac_wr_index + 2] & 0x1)) << 0)); in vga_port_out_handler()
1141 sc->vga_dac.dac_wr_index++; in vga_port_out_handler()
1142 sc->vga_dac.dac_wr_subindex = 0; in vga_port_out_handler()
1146 sc->vga_gc.gc_index = val; in vga_port_out_handler()
1149 switch (sc->vga_gc.gc_index) { in vga_port_out_handler()
1151 sc->vga_gc.gc_set_reset = val; in vga_port_out_handler()
1154 sc->vga_gc.gc_enb_set_reset = val; in vga_port_out_handler()
1157 sc->vga_gc.gc_color_compare = val; in vga_port_out_handler()
1160 sc->vga_gc.gc_rotate = val; in vga_port_out_handler()
1161 sc->vga_gc.gc_op = (val >> 3) & 0x3; in vga_port_out_handler()
1164 sc->vga_gc.gc_read_map_sel = val; in vga_port_out_handler()
1167 sc->vga_gc.gc_mode = val; in vga_port_out_handler()
1168 sc->vga_gc.gc_mode_c4 = (val & GC_MODE_C4) != 0; in vga_port_out_handler()
1169 assert(!sc->vga_gc.gc_mode_c4); in vga_port_out_handler()
1170 sc->vga_gc.gc_mode_oe = (val & GC_MODE_OE) != 0; in vga_port_out_handler()
1171 sc->vga_gc.gc_mode_rm = (val >> 3) & 0x1; in vga_port_out_handler()
1172 sc->vga_gc.gc_mode_wm = val & 0x3; in vga_port_out_handler()
1174 if (sc->gc_image) in vga_port_out_handler()
1175 sc->gc_image->vgamode = 1; in vga_port_out_handler()
1178 sc->vga_gc.gc_misc = val; in vga_port_out_handler()
1179 sc->vga_gc.gc_misc_gm = val & GC_MISC_GM; in vga_port_out_handler()
1180 sc->vga_gc.gc_misc_mm = (val & GC_MISC_MM) >> in vga_port_out_handler()
1184 sc->vga_gc.gc_color_dont_care = val; in vga_port_out_handler()
1187 sc->vga_gc.gc_bit_mask = val; in vga_port_out_handler()
1190 //printf("XXX VGA GC: outb 0x%04x, 0x%02x at index %d\n", port, val, sc->vga_gc.gc_index); in vga_port_out_handler()
1197 sc->vga_misc = val; in vga_port_out_handler()
1208 return (-1); in vga_port_out_handler()
1259 return (-1); in vga_port_handler()
1287 sc->gc_image = console_get_image(); in vga_init()
1293 sc->mr.name = "VGA memory"; in vga_init()
1294 sc->mr.flags = MEM_F_RW; in vga_init()
1295 sc->mr.base = 640 * KB; in vga_init()
1296 sc->mr.size = 128 * KB; in vga_init()
1297 sc->mr.handler = vga_mem_handler; in vga_init()
1298 sc->mr.arg1 = sc; in vga_init()
1299 error = register_mem_fallback(&sc->mr); in vga_init()
1302 sc->vga_ram = malloc(256 * KB); in vga_init()
1303 memset(sc->vga_ram, 0, 256 * KB); in vga_init()
1314 memcpy(sc->vga_dac.dac_palette, palette, 16 * 3 * sizeof (uint8_t)); in vga_init()
1316 sc->vga_dac.dac_palette_rgb[i] = in vga_init()
1317 ((((sc->vga_dac.dac_palette[3*i + 0] << 2) | in vga_init()
1318 ((sc->vga_dac.dac_palette[3*i + 0] & 0x1) << 1) | in vga_init()
1319 (sc->vga_dac.dac_palette[3*i + 0] & 0x1)) << 16) | in vga_init()
1320 (((sc->vga_dac.dac_palette[3*i + 1] << 2) | in vga_init()
1321 ((sc->vga_dac.dac_palette[3*i + 1] & 0x1) << 1) | in vga_init()
1322 (sc->vga_dac.dac_palette[3*i + 1] & 0x1)) << 8) | in vga_init()
1323 (((sc->vga_dac.dac_palette[3*i + 2] << 2) | in vga_init()
1324 ((sc->vga_dac.dac_palette[3*i + 2] & 0x1) << 1) | in vga_init()
1325 (sc->vga_dac.dac_palette[3*i + 2] & 0x1)) << 0)); in vga_init()