1 // VGA bios implementation
3 // Copyright (C) 2009-2013 Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2001-2008 the LGPL VGABios developers Team
6 // This file may be distributed under the terms of the GNU LGPLv3 license.
8 #include "biosvar.h" // GET_BDA
9 #include "bregs.h" // struct bregs
10 #include "clext.h" // clext_1012
11 #include "config.h" // CONFIG_*
12 #include "output.h" // dprintf
13 #include "std/vbe.h" // VBE_RETURN_STATUS_FAILED
14 #include "stdvga.h" // stdvga_set_cursor_shape
15 #include "string.h" // memset_far
16 #include "vgabios.h" // calc_page_size
17 #include "vgahw.h" // vgahw_set_mode
20 /****************************************************************
22 ****************************************************************/
24 // Return the bits per pixel in system memory for a given mode.
26 vga_bpp(struct vgamode_s *vmode_g)
28 switch (GET_GLOBAL(vmode_g->memmodel)) {
34 u8 depth = GET_GLOBAL(vmode_g->depth);
36 return ALIGN(depth, 8);
41 calc_page_size(u8 memmodel, u16 width, u16 height)
45 return ALIGN(width * height * 2, 2*1024);
49 return ALIGN(width * height / 8, 8*1024);
53 // Determine cursor shape (taking into account possible cursor scaling)
55 get_cursor_shape(void)
57 u16 cursor_type = GET_BDA(cursor_type);
58 u8 emulate_cursor = (GET_BDA(video_ctl) & 1) == 0;
61 u8 start = (cursor_type >> 8) & 0x3f;
62 u8 end = cursor_type & 0x1f;
63 u16 cheight = GET_BDA(char_height);
64 if (cheight <= 8 || end >= 8 || start >= 0x20)
66 if (end != (start + 1))
67 start = ((start + 1) * cheight / 8) - 1;
69 start = ((end + 1) * cheight / 8) - 2;
70 end = ((end + 1) * cheight / 8) - 1;
71 return (start << 8) | end;
75 set_cursor_shape(u16 cursor_type)
77 vgafb_set_swcursor(0);
78 SET_BDA(cursor_type, cursor_type);
79 if (CONFIG_VGA_STDVGA_PORTS)
80 stdvga_set_cursor_shape(get_cursor_shape());
84 set_cursor_pos(struct cursorpos cp)
86 u8 page = cp.page, x = cp.x, y = cp.y;
88 // Should not happen...
92 vgafb_set_swcursor(0);
95 SET_BDA(cursor_pos[page], (y << 8) | x);
97 if (!CONFIG_VGA_STDVGA_PORTS)
100 // Set the hardware cursor
101 u8 current = GET_BDA(video_page);
102 if (cp.page != current)
105 // Calculate the memory address
106 stdvga_set_cursor_pos((int)text_address(cp));
110 get_cursor_pos(u8 page)
113 // special case - use current page
114 page = GET_BDA(video_page);
116 struct cursorpos cp = { 0, 0, 0xfe };
119 u16 xy = GET_BDA(cursor_pos[page]);
120 struct cursorpos cp = {xy, xy>>8, page};
125 set_active_page(u8 page)
131 struct vgamode_s *vmode_g = get_current_mode();
135 vgafb_set_swcursor(0);
137 // Calculate memory address of start of page
138 struct cursorpos cp = {0, 0, page};
139 int address = (int)text_address(cp);
140 vgahw_set_displaystart(vmode_g, address);
142 // And change the BIOS page
143 SET_BDA(video_pagestart, address);
144 SET_BDA(video_page, page);
146 dprintf(1, "Set active page %02x address %04x\n", page, address);
148 // Display the cursor, now the page is active
149 set_cursor_pos(get_cursor_pos(page));
153 set_scan_lines(u8 lines)
155 stdvga_set_scan_lines(lines);
156 SET_BDA(char_height, lines);
157 u16 vde = stdvga_get_vde();
158 u8 rows = vde / lines;
159 SET_BDA(video_rows, rows - 1);
160 u16 cols = GET_BDA(video_cols);
161 SET_BDA(video_pagesize, calc_page_size(MM_TEXT, cols, rows));
163 set_cursor_shape(0x0607);
165 set_cursor_shape(((lines - 3) << 8) | (lines - 2));
169 /****************************************************************
171 ****************************************************************/
173 // Write a character to the screen and calculate new cursor position.
175 write_char(struct cursorpos *pcp, struct carattr ca)
177 vgafb_write_char(*pcp, ca);
179 // Do we need to wrap ?
180 if (pcp->x == GET_BDA(video_cols)) {
186 // Write a character to the screen at a given position. Implement
187 // special characters and scroll the screen if necessary.
189 write_teletype(struct cursorpos *pcp, struct carattr ca)
210 // Do we need to scroll ?
211 u16 nbrows = GET_BDA(video_rows);
212 if (pcp->y > nbrows) {
215 struct cursorpos dest = {0, 0, pcp->page};
216 struct cursorpos src = {0, 1, pcp->page};
217 struct cursorpos size = {GET_BDA(video_cols), nbrows};
218 vgafb_move_chars(dest, src, size);
220 struct cursorpos clr = {0, nbrows, pcp->page};
221 struct carattr attr = {' ', 0, 0};
222 struct cursorpos clrsize = {GET_BDA(video_cols), 1};
223 vgafb_clear_chars(clr, attr, clrsize);
228 /****************************************************************
229 * Save and restore bda state
230 ****************************************************************/
232 struct saveBDAstate {
236 struct segoff_s font0;
237 struct segoff_s font1;
241 bda_save_restore(int cmd, u16 seg, void *data)
245 struct saveBDAstate *info = data;
247 memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49
248 , sizeof(info->bda_0x49));
249 memcpy_far(seg, info->bda_0x84, SEG_BDA, (void*)0x84
250 , sizeof(info->bda_0x84));
251 SET_FARVAR(seg, info->vbe_mode, GET_BDA_EXT(vbe_mode));
252 SET_FARVAR(seg, info->font0, GET_IVT(0x1f));
253 SET_FARVAR(seg, info->font1, GET_IVT(0x43));
255 if (cmd & SR_RESTORE) {
256 memcpy_far(SEG_BDA, (void*)0x49, seg, info->bda_0x49
257 , sizeof(info->bda_0x49));
258 memcpy_far(SEG_BDA, (void*)0x84, seg, info->bda_0x84
259 , sizeof(info->bda_0x84));
260 u16 vbe_mode = GET_FARVAR(seg, info->vbe_mode);
261 SET_BDA_EXT(vbe_mode, vbe_mode);
262 struct vgamode_s *vmode_g = vgahw_find_mode(vbe_mode & ~MF_VBEFLAGS);
263 SET_BDA_EXT(vgamode_offset, (u32)vmode_g);
264 SET_IVT(0x1f, GET_FARVAR(seg, info->font0));
265 SET_IVT(0x43, GET_FARVAR(seg, info->font1));
267 return sizeof(*info);
271 /****************************************************************
273 ****************************************************************/
276 get_current_mode(void)
278 return (void*)(GET_BDA_EXT(vgamode_offset)+0);
281 // Setup BDA after a mode switch.
283 vga_set_mode(int mode, int flags)
285 dprintf(1, "set VGA mode %x\n", mode);
286 struct vgamode_s *vmode_g = vgahw_find_mode(mode);
288 return VBE_RETURN_STATUS_FAILED;
290 vgafb_set_swcursor(0);
292 int ret = vgahw_set_mode(vmode_g, flags);
297 int width = GET_GLOBAL(vmode_g->width);
298 int height = GET_GLOBAL(vmode_g->height);
299 u8 memmodel = GET_GLOBAL(vmode_g->memmodel);
300 int cheight = GET_GLOBAL(vmode_g->cheight);
302 SET_BDA(video_mode, mode);
304 SET_BDA(video_mode, 0xff);
305 SET_BDA_EXT(vbe_mode, mode | (flags & MF_VBEFLAGS));
306 SET_BDA_EXT(vgamode_offset, (u32)vmode_g);
307 if (memmodel == MM_TEXT) {
308 SET_BDA(video_cols, width);
309 SET_BDA(video_rows, height-1);
310 SET_BDA(cursor_type, 0x0607);
312 int cwidth = GET_GLOBAL(vmode_g->cwidth);
313 SET_BDA(video_cols, width / cwidth);
314 SET_BDA(video_rows, (height / cheight) - 1);
315 SET_BDA(cursor_type, vga_emulate_text() ? 0x0607 : 0x0000);
317 SET_BDA(video_pagesize, calc_page_size(memmodel, width, height));
318 SET_BDA(crtc_address, CONFIG_VGA_STDVGA_PORTS ? stdvga_get_crtc() : 0);
319 SET_BDA(char_height, cheight);
320 SET_BDA(video_ctl, 0x60 | (flags & MF_NOCLEARMEM ? 0x80 : 0x00));
321 SET_BDA(video_switches, 0xF9);
322 SET_BDA(modeset_ctl, GET_BDA(modeset_ctl) & 0x7f);
325 SET_BDA(cursor_pos[i], 0x0000);
326 SET_BDA(video_pagestart, 0x0000);
327 SET_BDA(video_page, 0x00);
329 // Set the ints 0x1F and 0x43
330 SET_IVT(0x1f, SEGOFF(get_global_seg(), (u32)&vgafont8[128 * 8]));
334 SET_IVT(0x43, SEGOFF(get_global_seg(), (u32)vgafont8));
337 SET_IVT(0x43, SEGOFF(get_global_seg(), (u32)vgafont14));
340 SET_IVT(0x43, SEGOFF(get_global_seg(), (u32)vgafont16));
348 /****************************************************************
350 ****************************************************************/
353 handle_1000(struct bregs *regs)
355 int mode = regs->al & 0x7f;
365 int flags = MF_LEGACY | (GET_BDA(modeset_ctl) & (MF_NOPALETTE|MF_GRAYSUM));
367 flags |= MF_NOCLEARMEM;
369 vga_set_mode(mode, flags);
373 handle_1001(struct bregs *regs)
375 set_cursor_shape(regs->cx);
379 handle_1002(struct bregs *regs)
381 struct cursorpos cp = {regs->dl, regs->dh, regs->bh};
386 handle_1003(struct bregs *regs)
388 regs->cx = GET_BDA(cursor_type);
389 struct cursorpos cp = get_cursor_pos(regs->bh);
394 // Read light pen pos (unimplemented)
396 handle_1004(struct bregs *regs)
399 regs->ax = regs->bx = regs->cx = regs->dx = 0;
403 handle_1005(struct bregs *regs)
405 set_active_page(regs->al);
409 verify_scroll(struct bregs *regs, int dir)
411 u8 ulx = regs->cl, uly = regs->ch, lrx = regs->dl, lry = regs->dh;
412 u16 nbrows = GET_BDA(video_rows) + 1;
415 u16 nbcols = GET_BDA(video_cols);
418 int wincols = lrx - ulx + 1, winrows = lry - uly + 1;
419 if (wincols <= 0 || winrows <= 0)
422 u8 page = GET_BDA(video_page);
423 int clearlines = regs->al, movelines = winrows - clearlines;
424 if (!clearlines || movelines <= 0) {
426 struct cursorpos clr = {ulx, uly, page};
427 struct carattr attr = {' ', regs->bh, 1};
428 struct cursorpos clrsize = {wincols, winrows};
429 vgafb_clear_chars(clr, attr, clrsize);
435 struct cursorpos dest = {ulx, uly, page};
436 struct cursorpos src = {ulx, uly + clearlines, page};
437 struct cursorpos size = {wincols, movelines};
438 vgafb_move_chars(dest, src, size);
440 struct cursorpos clr = {ulx, uly + movelines, page};
441 struct carattr attr = {' ', regs->bh, 1};
442 struct cursorpos clrsize = {wincols, clearlines};
443 vgafb_clear_chars(clr, attr, clrsize);
446 struct cursorpos dest = {ulx, uly + clearlines, page};
447 struct cursorpos src = {ulx, uly, page};
448 struct cursorpos size = {wincols, movelines};
449 vgafb_move_chars(dest, src, size);
451 struct cursorpos clr = {ulx, uly, page};
452 struct carattr attr = {' ', regs->bh, 1};
453 struct cursorpos clrsize = {wincols, clearlines};
454 vgafb_clear_chars(clr, attr, clrsize);
459 handle_1006(struct bregs *regs)
461 verify_scroll(regs, 1);
465 handle_1007(struct bregs *regs)
467 verify_scroll(regs, -1);
471 handle_1008(struct bregs *regs)
473 struct carattr ca = vgafb_read_char(get_cursor_pos(regs->bh));
479 handle_1009(struct bregs *regs)
481 struct carattr ca = {regs->al, regs->bl, 1};
482 struct cursorpos cp = get_cursor_pos(regs->bh);
483 int count = regs->cx;
489 handle_100a(struct bregs *regs)
491 struct carattr ca = {regs->al, regs->bl, 0};
492 struct cursorpos cp = get_cursor_pos(regs->bh);
493 int count = regs->cx;
500 handle_100b00(struct bregs *regs)
502 stdvga_set_border_color(regs->bl);
506 handle_100b01(struct bregs *regs)
508 stdvga_set_palette(regs->bl);
512 handle_100bXX(struct bregs *regs)
518 handle_100b(struct bregs *regs)
520 if (!CONFIG_VGA_STDVGA_PORTS) {
525 case 0x00: handle_100b00(regs); break;
526 case 0x01: handle_100b01(regs); break;
527 default: handle_100bXX(regs); break;
533 handle_100c(struct bregs *regs)
535 // XXX - page (regs->bh) is unused
536 vgafb_write_pixel(regs->al, regs->cx, regs->dx);
540 handle_100d(struct bregs *regs)
542 // XXX - page (regs->bh) is unused
543 regs->al = vgafb_read_pixel(regs->cx, regs->dx);
547 handle_100e(struct bregs *regs)
549 // Ralf Brown Interrupt list is WRONG on bh(page)
550 // We do output only on the current page !
551 struct carattr ca = {regs->al, regs->bl, 0};
552 struct cursorpos cp = get_cursor_pos(0xff);
553 write_teletype(&cp, ca);
558 handle_100f(struct bregs *regs)
560 regs->bh = GET_BDA(video_page);
561 regs->al = GET_BDA(video_mode) | (GET_BDA(video_ctl) & 0x80);
562 regs->ah = GET_BDA(video_cols);
567 handle_101000(struct bregs *regs)
571 stdvga_attr_write(regs->bl, regs->bh);
575 handle_101001(struct bregs *regs)
577 stdvga_set_overscan_border_color(regs->bh);
581 handle_101002(struct bregs *regs)
583 stdvga_set_all_palette_reg(regs->es, (u8*)(regs->dx + 0));
587 handle_101003(struct bregs *regs)
589 stdvga_toggle_intensity(regs->bl);
593 handle_101007(struct bregs *regs)
597 regs->bh = stdvga_attr_read(regs->bl);
601 handle_101008(struct bregs *regs)
603 regs->bh = stdvga_get_overscan_border_color();
607 handle_101009(struct bregs *regs)
609 stdvga_get_all_palette_reg(regs->es, (u8*)(regs->dx + 0));
613 handle_101010(struct bregs *regs)
615 u8 rgb[3] = {regs->dh, regs->ch, regs->cl};
616 stdvga_dac_write(GET_SEG(SS), rgb, regs->bx, 1);
620 handle_101012(struct bregs *regs)
622 stdvga_dac_write(regs->es, (u8*)(regs->dx + 0), regs->bx, regs->cx);
626 handle_101013(struct bregs *regs)
628 stdvga_select_video_dac_color_page(regs->bl, regs->bh);
632 handle_101015(struct bregs *regs)
635 stdvga_dac_read(GET_SEG(SS), rgb, regs->bx, 1);
642 handle_101017(struct bregs *regs)
644 stdvga_dac_read(regs->es, (u8*)(regs->dx + 0), regs->bx, regs->cx);
648 handle_101018(struct bregs *regs)
650 stdvga_pelmask_write(regs->bl);
654 handle_101019(struct bregs *regs)
656 regs->bl = stdvga_pelmask_read();
660 handle_10101a(struct bregs *regs)
662 stdvga_read_video_dac_state(®s->bl, ®s->bh);
666 handle_10101b(struct bregs *regs)
668 stdvga_perform_gray_scale_summing(regs->bx, regs->cx);
672 handle_1010XX(struct bregs *regs)
678 handle_1010(struct bregs *regs)
680 if (!CONFIG_VGA_STDVGA_PORTS) {
685 case 0x00: handle_101000(regs); break;
686 case 0x01: handle_101001(regs); break;
687 case 0x02: handle_101002(regs); break;
688 case 0x03: handle_101003(regs); break;
689 case 0x07: handle_101007(regs); break;
690 case 0x08: handle_101008(regs); break;
691 case 0x09: handle_101009(regs); break;
692 case 0x10: handle_101010(regs); break;
693 case 0x12: handle_101012(regs); break;
694 case 0x13: handle_101013(regs); break;
695 case 0x15: handle_101015(regs); break;
696 case 0x17: handle_101017(regs); break;
697 case 0x18: handle_101018(regs); break;
698 case 0x19: handle_101019(regs); break;
699 case 0x1a: handle_10101a(regs); break;
700 case 0x1b: handle_10101b(regs); break;
701 default: handle_1010XX(regs); break;
707 handle_101100(struct bregs *regs)
709 stdvga_load_font(regs->es, (void*)(regs->bp+0), regs->cx
710 , regs->dx, regs->bl, regs->bh);
714 handle_101101(struct bregs *regs)
716 stdvga_load_font(get_global_seg(), vgafont14, 0x100, 0, regs->bl, 14);
720 handle_101102(struct bregs *regs)
722 stdvga_load_font(get_global_seg(), vgafont8, 0x100, 0, regs->bl, 8);
726 handle_101103(struct bregs *regs)
728 stdvga_set_text_block_specifier(regs->bl);
732 handle_101104(struct bregs *regs)
734 stdvga_load_font(get_global_seg(), vgafont16, 0x100, 0, regs->bl, 16);
738 handle_101110(struct bregs *regs)
740 stdvga_load_font(regs->es, (void*)(regs->bp+0), regs->cx
741 , regs->dx, regs->bl, regs->bh);
742 set_scan_lines(regs->bh);
746 handle_101111(struct bregs *regs)
748 stdvga_load_font(get_global_seg(), vgafont14, 0x100, 0, regs->bl, 14);
753 handle_101112(struct bregs *regs)
755 stdvga_load_font(get_global_seg(), vgafont8, 0x100, 0, regs->bl, 8);
760 handle_101114(struct bregs *regs)
762 stdvga_load_font(get_global_seg(), vgafont16, 0x100, 0, regs->bl, 16);
767 handle_101120(struct bregs *regs)
769 SET_IVT(0x1f, SEGOFF(regs->es, regs->bp));
773 load_gfx_font(u16 seg, u16 off, u8 height, u8 bl, u8 dl)
777 SET_IVT(0x43, SEGOFF(seg, off));
793 SET_BDA(video_rows, rows - 1);
794 SET_BDA(char_height, height);
798 handle_101121(struct bregs *regs)
800 load_gfx_font(regs->es, regs->bp, regs->cx, regs->bl, regs->dl);
804 handle_101122(struct bregs *regs)
806 load_gfx_font(get_global_seg(), (u32)vgafont14, 14, regs->bl, regs->dl);
810 handle_101123(struct bregs *regs)
812 load_gfx_font(get_global_seg(), (u32)vgafont8, 8, regs->bl, regs->dl);
816 handle_101124(struct bregs *regs)
818 load_gfx_font(get_global_seg(), (u32)vgafont16, 16, regs->bl, regs->dl);
822 handle_101130(struct bregs *regs)
826 struct segoff_s so = GET_IVT(0x1f);
828 regs->bp = so.offset;
832 struct segoff_s so = GET_IVT(0x43);
834 regs->bp = so.offset;
838 regs->es = get_global_seg();
839 regs->bp = (u32)vgafont14;
842 regs->es = get_global_seg();
843 regs->bp = (u32)vgafont8;
846 regs->es = get_global_seg();
847 regs->bp = (u32)vgafont8 + 128 * 8;
850 regs->es = get_global_seg();
851 regs->bp = (u32)vgafont14alt;
854 regs->es = get_global_seg();
855 regs->bp = (u32)vgafont16;
858 regs->es = get_global_seg();
859 regs->bp = (u32)vgafont16alt;
862 dprintf(1, "Get font info BH(%02x) was discarded\n", regs->bh);
865 // Set byte/char of on screen font
866 regs->cx = GET_BDA(char_height) & 0xff;
868 // Set Highest char row
869 regs->dl = GET_BDA(video_rows);
873 handle_1011XX(struct bregs *regs)
879 handle_1011(struct bregs *regs)
881 if (CONFIG_VGA_STDVGA_PORTS) {
883 case 0x00: handle_101100(regs); return;
884 case 0x01: handle_101101(regs); return;
885 case 0x02: handle_101102(regs); return;
886 case 0x03: handle_101103(regs); return;
887 case 0x04: handle_101104(regs); return;
888 case 0x10: handle_101110(regs); return;
889 case 0x11: handle_101111(regs); return;
890 case 0x12: handle_101112(regs); return;
891 case 0x14: handle_101114(regs); return;
895 case 0x30: handle_101130(regs); break;
896 case 0x20: handle_101120(regs); break;
897 case 0x21: handle_101121(regs); break;
898 case 0x22: handle_101122(regs); break;
899 case 0x23: handle_101123(regs); break;
900 case 0x24: handle_101124(regs); break;
901 default: handle_1011XX(regs); break;
907 handle_101210(struct bregs *regs)
909 u16 crtc_addr = GET_BDA(crtc_address);
910 if (crtc_addr == VGAREG_MDA_CRTC_ADDRESS)
914 regs->cx = GET_BDA(video_switches) & 0x0f;
918 handle_101230(struct bregs *regs)
920 u8 mctl = GET_BDA(modeset_ctl);
921 u8 vswt = GET_BDA(video_switches);
925 mctl = (mctl & ~0x10) | 0x80;
926 vswt = (vswt & ~0x0f) | 0x08;
931 vswt = (vswt & ~0x0f) | 0x09;
935 mctl = (mctl & ~0x80) | 0x10;
936 vswt = (vswt & ~0x0f) | 0x09;
939 dprintf(1, "Select vert res (%02x) was discarded\n", regs->al);
942 SET_BDA(modeset_ctl, mctl);
943 SET_BDA(video_switches, vswt);
948 handle_101231(struct bregs *regs)
950 u8 v = (regs->al & 0x01) << 3;
951 u8 mctl = GET_BDA(video_ctl) & ~0x08;
952 SET_BDA(video_ctl, mctl | v);
957 handle_101232(struct bregs *regs)
959 if (CONFIG_VGA_STDVGA_PORTS) {
960 stdvga_enable_video_addressing(regs->al);
966 handle_101233(struct bregs *regs)
968 u8 v = ((regs->al << 1) & 0x02) ^ 0x02;
969 u8 v2 = GET_BDA(modeset_ctl) & ~0x02;
970 SET_BDA(modeset_ctl, v | v2);
975 handle_101234(struct bregs *regs)
977 SET_BDA(video_ctl, (GET_BDA(video_ctl) & ~0x01) | (regs->al & 0x01));
982 handle_101235(struct bregs *regs)
989 handle_101236(struct bregs *regs)
996 handle_1012XX(struct bregs *regs)
1002 handle_1012(struct bregs *regs)
1004 if (CONFIG_VGA_CIRRUS && regs->bl >= 0x80) {
1010 case 0x10: handle_101210(regs); break;
1011 case 0x30: handle_101230(regs); break;
1012 case 0x31: handle_101231(regs); break;
1013 case 0x32: handle_101232(regs); break;
1014 case 0x33: handle_101233(regs); break;
1015 case 0x34: handle_101234(regs); break;
1016 case 0x35: handle_101235(regs); break;
1017 case 0x36: handle_101236(regs); break;
1018 default: handle_1012XX(regs); break;
1024 static void noinline
1025 handle_1013(struct bregs *regs)
1027 struct cursorpos cp;
1028 if (regs->dh == 0xff)
1029 // if row=0xff special case : use current cursor position
1030 cp = get_cursor_pos(regs->bh);
1032 cp = (struct cursorpos) {regs->dl, regs->dh, regs->bh};
1034 u16 count = regs->cx;
1035 u8 *offset_far = (void*)(regs->bp + 0);
1038 u8 car = GET_FARVAR(regs->es, *offset_far);
1041 attr = GET_FARVAR(regs->es, *offset_far);
1045 struct carattr ca = {car, attr, 1};
1046 write_teletype(&cp, ca);
1055 handle_101a00(struct bregs *regs)
1057 regs->bx = GET_BDA(dcc_index);
1062 handle_101a01(struct bregs *regs)
1064 SET_BDA(dcc_index, regs->bl);
1065 dprintf(1, "Alternate Display code (%02x) was discarded\n", regs->bh);
1070 handle_101aXX(struct bregs *regs)
1076 handle_101a(struct bregs *regs)
1079 case 0x00: handle_101a00(regs); break;
1080 case 0x01: handle_101a01(regs); break;
1081 default: handle_101aXX(regs); break;
1086 struct video_func_static static_functionality VAR16 = {
1087 .modes = 0x00, // Filled in by stdvga_build_video_param()
1088 .scanlines = 0x07, // 200, 350, 400 scan lines
1089 .cblocks = 0x02, // mamimum number of visible charsets in text mode
1090 .active_cblocks = 0x08, // total number of charset blocks in text mode
1091 .misc_flags = 0x0ce7,
1095 handle_101b(struct bregs *regs)
1098 struct video_func_info *info = (void*)(regs->di+0);
1099 memset_far(seg, info, 0, sizeof(*info));
1100 // Address of static functionality table
1101 SET_FARVAR(seg, info->static_functionality
1102 , SEGOFF(get_global_seg(), (u32)&static_functionality));
1104 // Hard coded copy from BIOS area. Should it be cleaner ?
1105 memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49
1106 , sizeof(info->bda_0x49));
1107 memcpy_far(seg, info->bda_0x84, SEG_BDA, (void*)0x84
1108 , sizeof(info->bda_0x84));
1110 SET_FARVAR(seg, info->dcc_index, GET_BDA(dcc_index));
1111 SET_FARVAR(seg, info->colors, 16);
1112 SET_FARVAR(seg, info->pages, 8);
1113 SET_FARVAR(seg, info->scan_lines, 2);
1114 SET_FARVAR(seg, info->video_mem, 3);
1120 handle_101c(struct bregs *regs)
1123 void *data = (void*)(regs->bx+0);
1124 u16 states = regs->cx;
1126 if (states & ~0x07 || cmd > 2)
1128 int ret = vgahw_save_restore(states | (cmd<<8), seg, data);
1132 regs->bx = ret / 64;
1139 handle_10XX(struct bregs *regs)
1144 // INT 10h Video Support Service Entry Point
1146 handle_10(struct bregs *regs)
1148 debug_enter(regs, DEBUG_VGA_10);
1150 case 0x00: handle_1000(regs); break;
1151 case 0x01: handle_1001(regs); break;
1152 case 0x02: handle_1002(regs); break;
1153 case 0x03: handle_1003(regs); break;
1154 case 0x04: handle_1004(regs); break;
1155 case 0x05: handle_1005(regs); break;
1156 case 0x06: handle_1006(regs); break;
1157 case 0x07: handle_1007(regs); break;
1158 case 0x08: handle_1008(regs); break;
1159 case 0x09: handle_1009(regs); break;
1160 case 0x0a: handle_100a(regs); break;
1161 case 0x0b: handle_100b(regs); break;
1162 case 0x0c: handle_100c(regs); break;
1163 case 0x0d: handle_100d(regs); break;
1164 case 0x0e: handle_100e(regs); break;
1165 case 0x0f: handle_100f(regs); break;
1166 case 0x10: handle_1010(regs); break;
1167 case 0x11: handle_1011(regs); break;
1168 case 0x12: handle_1012(regs); break;
1169 case 0x13: handle_1013(regs); break;
1170 case 0x1a: handle_101a(regs); break;
1171 case 0x1b: handle_101b(regs); break;
1172 case 0x1c: handle_101c(regs); break;
1173 case 0x4f: handle_104f(regs); break;
1174 default: handle_10XX(regs); break;