1 // VGA bios implementation
3 // Copyright (C) 2009 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.
10 // * review correctness of converted asm by comparing with RBIL
11 // * refactor redundant code into sub-functions
12 // * See if there is a method to the in/out stuff that can be encapsulated.
13 // * remove "biosfn" prefixes
14 // * verify all funcs static
16 // * convert vbe/clext code
18 #include "bregs.h" // struct bregs
19 #include "biosvar.h" // GET_BDA
20 #include "util.h" // memset
21 #include "vgatables.h" // find_vga_entry
25 #define CONFIG_CIRRUS 0
28 #define DEBUG_VGA_POST 1
29 #define DEBUG_VGA_10 3
31 #define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
34 call16_vgaint(u32 eax, u32 ebx)
46 biosfn_perform_gray_scale_summing(u16 start, u16 count)
48 vgahw_screen_disable();
50 for (i = start; i < start+count; i++) {
52 vgahw_get_dac_regs(GET_SEG(SS), rgb, i, 1);
54 // intensity = ( 0.3 * Red ) + ( 0.59 * Green ) + ( 0.11 * Blue )
55 u16 intensity = ((77 * rgb[0] + 151 * rgb[1] + 28 * rgb[2]) + 0x80) >> 8;
59 vgahw_set_dac_regs(GET_SEG(SS), rgb, i, 1);
61 vgahw_screen_enable();
65 biosfn_set_cursor_shape(u8 CH, u8 CL)
70 u16 curs = (CH << 8) + CL;
71 SET_BDA(cursor_type, curs);
73 u8 modeset_ctl = GET_BDA(modeset_ctl);
74 u16 cheight = GET_BDA(char_height);
75 if ((modeset_ctl & 0x01) && (cheight > 8) && (CL < 8) && (CH < 0x20)) {
77 CH = ((CH + 1) * cheight / 8) - 1;
79 CH = ((CL + 1) * cheight / 8) - 2;
80 CL = ((CL + 1) * cheight / 8) - 1;
82 vgahw_set_cursor_shape(CH, CL);
86 biosfn_get_cursor_shape(u8 page)
90 // FIXME should handle VGA 14/16 lines
91 return GET_BDA(cursor_type);
95 set_cursor_pos(struct cursorpos cp)
97 // Should not happen...
102 SET_BDA(cursor_pos[cp.page], (cp.y << 8) | cp.x);
104 // Set the hardware cursor
105 u8 current = GET_BDA(video_page);
106 if (cp.page != current)
109 // Get the dimensions
110 u16 nbcols = GET_BDA(video_cols);
111 u16 nbrows = GET_BDA(video_rows) + 1;
113 // Calculate the address knowing nbcols nbrows and page num
114 u16 address = (SCREEN_IO_START(nbcols, nbrows, cp.page)
115 + cp.x + cp.y * nbcols);
117 vgahw_set_cursor_pos(address);
121 get_cursor_pos(u8 page)
124 // special case - use current page
125 page = GET_BDA(video_page);
127 struct cursorpos cp = { 0, 0, 0xfe };
130 // FIXME should handle VGA 14/16 lines
131 u16 xy = GET_BDA(cursor_pos[page]);
132 struct cursorpos cp = {xy, xy>>8, page};
137 biosfn_set_active_page(u8 page)
143 struct vgamode_s *vmode_g = find_vga_entry(GET_BDA(video_mode));
147 // Get pos curs pos for the right page
148 struct cursorpos cp = get_cursor_pos(page);
151 if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
152 // Get the dimensions
153 u16 nbcols = GET_BDA(video_cols);
154 u16 nbrows = GET_BDA(video_rows) + 1;
156 // Calculate the address knowing nbcols nbrows and page num
157 address = SCREEN_MEM_START(nbcols, nbrows, page);
158 SET_BDA(video_pagestart, address);
161 address = SCREEN_IO_START(nbcols, nbrows, page);
163 struct VideoParam_s *vparam_g = GET_GLOBAL(vmode_g->vparam);
164 address = page * GET_GLOBAL(vparam_g->slength);
167 vgahw_set_active_page(address);
169 // And change the BIOS page
170 SET_BDA(video_page, page);
172 dprintf(1, "Set active page %02x address %04x\n", page, address);
174 // Display the cursor, now the page is active
178 static struct cursorpos
179 check_scroll(struct cursorpos cp)
181 // Get the dimensions
182 u16 nbrows = GET_BDA(video_rows) + 1;
183 u16 nbcols = GET_BDA(video_cols);
185 // Do we need to wrap ?
186 if (cp.x == nbcols) {
190 // Do we need to scroll ?
191 if (cp.y == nbrows) {
193 struct vgamode_s *vmode_g = find_vga_entry(GET_BDA(video_mode));
197 if (GET_GLOBAL(vmode_g->memmodel) & TEXT)
198 biosfn_scroll(0x01, 0x07, 0, 0, nbrows - 1, nbcols - 1, cp.page,
201 biosfn_scroll(0x01, 0x00, 0, 0, nbrows - 1, nbcols - 1, cp.page,
210 biosfn_write_teletype(u8 page, struct carattr ca)
212 // Get the cursor pos for the page
213 struct cursorpos cp = get_cursor_pos(page);
235 struct carattr dummyca = {' ', ca.attr, ca.use_attr};
236 vgafb_write_char(cp, dummyca);
238 cp = check_scroll(cp);
243 vgafb_write_char(cp, ca);
247 cp = check_scroll(cp);
249 // Set the cursor for the page
254 biosfn_write_string(struct cursorpos cp, u8 flag, u8 attr, u16 count,
255 u16 seg, u8 *offset_far)
257 // Read curs info for the page
258 struct cursorpos oldcp = get_cursor_pos(cp.page);
260 // if row=0xff special case : use current cursor position
266 while (count-- != 0) {
267 u8 car = GET_FARVAR(seg, *offset_far);
269 if ((flag & 0x02) != 0) {
270 attr = GET_FARVAR(seg, *offset_far);
274 struct carattr ca = {car, attr, 1};
275 biosfn_write_teletype(cp.page, ca);
279 if ((flag & 0x01) == 0)
280 set_cursor_pos(oldcp);
284 set_scan_lines(u8 lines)
286 vgahw_set_scan_lines(lines);
288 biosfn_set_cursor_shape(0x06, 0x07);
290 biosfn_set_cursor_shape(lines - 4, lines - 3);
291 SET_BDA(char_height, lines);
292 u16 vde = vgahw_get_vde();
293 u8 rows = vde / lines;
294 SET_BDA(video_rows, rows - 1);
295 u16 cols = GET_BDA(video_cols);
296 SET_BDA(video_pagesize, rows * cols * 2);
300 biosfn_save_bda_state(u16 seg, struct saveBDAstate *info)
302 SET_FARVAR(seg, info->video_mode, GET_BDA(video_mode));
303 SET_FARVAR(seg, info->video_cols, GET_BDA(video_cols));
304 SET_FARVAR(seg, info->video_pagesize, GET_BDA(video_pagesize));
305 SET_FARVAR(seg, info->crtc_address, GET_BDA(crtc_address));
306 SET_FARVAR(seg, info->video_rows, GET_BDA(video_rows));
307 SET_FARVAR(seg, info->char_height, GET_BDA(char_height));
308 SET_FARVAR(seg, info->video_ctl, GET_BDA(video_ctl));
309 SET_FARVAR(seg, info->video_switches, GET_BDA(video_switches));
310 SET_FARVAR(seg, info->modeset_ctl, GET_BDA(modeset_ctl));
311 SET_FARVAR(seg, info->cursor_type, GET_BDA(cursor_type));
314 SET_FARVAR(seg, info->cursor_pos[i], GET_BDA(cursor_pos[i]));
315 SET_FARVAR(seg, info->video_pagestart, GET_BDA(video_pagestart));
316 SET_FARVAR(seg, info->video_page, GET_BDA(video_page));
318 SET_FARVAR(seg, *(u32*)&info->font0_off, GET_IVT(0x1f).segoff);
319 SET_FARVAR(seg, *(u32*)&info->font1_off, GET_IVT(0x43).segoff);
323 biosfn_restore_bda_state(u16 seg, struct saveBDAstate *info)
325 SET_BDA(video_mode, GET_FARVAR(seg, info->video_mode));
326 SET_BDA(video_cols, GET_FARVAR(seg, info->video_cols));
327 SET_BDA(video_pagesize, GET_FARVAR(seg, info->video_pagesize));
328 SET_BDA(crtc_address, GET_FARVAR(seg, info->crtc_address));
329 SET_BDA(video_rows, GET_FARVAR(seg, info->video_rows));
330 SET_BDA(char_height, GET_FARVAR(seg, info->char_height));
331 SET_BDA(video_ctl, GET_FARVAR(seg, info->video_ctl));
332 SET_BDA(video_switches, GET_FARVAR(seg, info->video_switches));
333 SET_BDA(modeset_ctl, GET_FARVAR(seg, info->modeset_ctl));
334 SET_BDA(cursor_type, GET_FARVAR(seg, info->cursor_type));
336 for (i = 0; i < 8; i++)
337 SET_BDA(cursor_pos[i], GET_FARVAR(seg, info->cursor_pos[i]));
338 SET_BDA(video_pagestart, GET_FARVAR(seg, info->video_pagestart));
339 SET_BDA(video_page, GET_FARVAR(seg, info->video_page));
341 SET_IVT(0x1f, GET_FARVAR(seg, info->font0_seg)
342 , GET_FARVAR(seg, info->font0_off));
343 SET_IVT(0x43, GET_FARVAR(seg, info->font1_seg)
344 , GET_FARVAR(seg, info->font1_off));
348 /****************************************************************
350 ****************************************************************/
354 handle_1000(struct bregs *regs)
356 u8 noclearmem = regs->al & 0x80;
357 u8 mode = regs->al & 0x7f;
368 cirrus_set_video_mode(mode);
371 if (vbe_has_vbe_display())
372 dispi_set_enable(VBE_DISPI_DISABLED);
374 // find the entry in the video modes
375 struct vgamode_s *vmode_g = find_vga_entry(mode);
376 dprintf(1, "mode search %02x found %p\n", mode, vmode_g);
380 // Read the bios mode set control
381 u8 modeset_ctl = GET_BDA(modeset_ctl);
383 // Then we know the number of lines
386 // if palette loading (bit 3 of modeset ctl = 0)
387 if ((modeset_ctl & 0x08) == 0) { // Set the PEL mask
388 vgahw_set_pel_mask(GET_GLOBAL(vmode_g->pelmask));
390 // From which palette
391 u8 *palette_g = GET_GLOBAL(vmode_g->dac);
392 u16 palsize = GET_GLOBAL(vmode_g->dacsize) / 3;
394 // Always 256*3 values
395 vgahw_set_dac_regs(get_global_seg(), palette_g, 0, palsize);
397 for (i = palsize; i < 0x0100; i++) {
398 static u8 rgb[3] VAR16;
399 vgahw_set_dac_regs(get_global_seg(), rgb, i, 1);
402 if ((modeset_ctl & 0x02) == 0x02)
403 biosfn_perform_gray_scale_summing(0x00, 0x100);
406 struct VideoParam_s *vparam_g = GET_GLOBAL(vmode_g->vparam);
407 vgahw_set_mode(vparam_g);
409 if (noclearmem == 0x00)
410 clear_screen(vmode_g);
412 // Set CRTC address VGA or MDA
413 u16 crtc_addr = VGAREG_VGA_CRTC_ADDRESS;
414 if (GET_GLOBAL(vmode_g->memmodel) == MTEXT)
415 crtc_addr = VGAREG_MDA_CRTC_ADDRESS;
418 u16 cheight = GET_GLOBAL(vparam_g->cheight);
419 SET_BDA(video_mode, mode);
420 SET_BDA(video_cols, GET_GLOBAL(vparam_g->twidth));
421 SET_BDA(video_pagesize, GET_GLOBAL(vparam_g->slength));
422 SET_BDA(crtc_address, crtc_addr);
423 SET_BDA(video_rows, GET_GLOBAL(vparam_g->theightm1));
424 SET_BDA(char_height, cheight);
425 SET_BDA(video_ctl, (0x60 | noclearmem));
426 SET_BDA(video_switches, 0xF9);
427 SET_BDA(modeset_ctl, GET_BDA(modeset_ctl) & 0x7f);
429 // FIXME We nearly have the good tables. to be reworked
430 SET_BDA(dcc_index, 0x08); // 8 is VGA should be ok for now
431 SET_BDA(video_savetable_ptr, (u32)video_save_pointer_table);
432 SET_BDA(video_savetable_seg, get_global_seg());
435 SET_BDA(video_msr, 0x00); // Unavailable on vanilla vga, but...
436 SET_BDA(video_pal, 0x00); // Unavailable on vanilla vga, but...
439 if (GET_GLOBAL(vmode_g->memmodel) & TEXT)
440 biosfn_set_cursor_shape(0x06, 0x07);
441 // Set cursor pos for page 0..7
443 for (i = 0; i < 8; i++) {
444 struct cursorpos cp = {0, 0, i};
449 biosfn_set_active_page(0x00);
451 // Write the fonts in memory
452 if (GET_GLOBAL(vmode_g->memmodel) & TEXT) {
453 call16_vgaint(0x1104, 0);
454 call16_vgaint(0x1103, 0);
456 // Set the ints 0x1F and 0x43
457 SET_IVT(0x1f, get_global_seg(), (u32)&vgafont8[128 * 8]);
461 SET_IVT(0x43, get_global_seg(), (u32)vgafont8);
464 SET_IVT(0x43, get_global_seg(), (u32)vgafont14);
467 SET_IVT(0x43, get_global_seg(), (u32)vgafont16);
473 handle_1001(struct bregs *regs)
475 biosfn_set_cursor_shape(regs->ch, regs->cl);
479 handle_1002(struct bregs *regs)
481 struct cursorpos cp = {regs->dl, regs->dh, regs->bh};
486 handle_1003(struct bregs *regs)
488 regs->cx = biosfn_get_cursor_shape(regs->bh);
489 struct cursorpos cp = get_cursor_pos(regs->bh);
494 // Read light pen pos (unimplemented)
496 handle_1004(struct bregs *regs)
499 regs->ax = regs->bx = regs->cx = regs->dx = 0;
503 handle_1005(struct bregs *regs)
505 biosfn_set_active_page(regs->al);
509 handle_1006(struct bregs *regs)
511 biosfn_scroll(regs->al, regs->bh, regs->ch, regs->cl, regs->dh, regs->dl
516 handle_1007(struct bregs *regs)
518 biosfn_scroll(regs->al, regs->bh, regs->ch, regs->cl, regs->dh, regs->dl
519 , 0xFF, SCROLL_DOWN);
523 handle_1008(struct bregs *regs)
525 struct carattr ca = vgafb_read_char(get_cursor_pos(regs->bh));
531 write_chars(u8 page, struct carattr ca, u16 count)
533 struct cursorpos cp = get_cursor_pos(page);
535 vgafb_write_char(cp, ca);
541 handle_1009(struct bregs *regs)
543 struct carattr ca = {regs->al, regs->bl, 1};
544 write_chars(regs->bh, ca, regs->cx);
548 handle_100a(struct bregs *regs)
550 struct carattr ca = {regs->al, regs->bl, 0};
551 write_chars(regs->bh, ca, regs->cx);
556 handle_100b00(struct bregs *regs)
558 vgahw_set_border_color(regs->bl);
562 handle_100b01(struct bregs *regs)
564 vgahw_set_palette(regs->bl);
568 handle_100bXX(struct bregs *regs)
574 handle_100b(struct bregs *regs)
577 case 0x00: handle_100b00(regs); break;
578 case 0x01: handle_100b01(regs); break;
579 default: handle_100bXX(regs); break;
585 handle_100c(struct bregs *regs)
588 biosfn_write_pixel(regs->bh, regs->al, regs->cx, regs->dx);
592 handle_100d(struct bregs *regs)
595 biosfn_read_pixel(regs->bh, regs->cx, regs->dx, ®s->ax);
599 handle_100e(struct bregs *regs)
601 // Ralf Brown Interrupt list is WRONG on bh(page)
602 // We do output only on the current page !
603 struct carattr ca = {regs->al, regs->bl, 0};
604 biosfn_write_teletype(0xff, ca);
608 handle_100f(struct bregs *regs)
610 regs->bh = GET_BDA(video_page);
611 regs->al = GET_BDA(video_mode) | (GET_BDA(video_ctl) & 0x80);
612 regs->ah = GET_BDA(video_cols);
617 handle_101000(struct bregs *regs)
621 vgahw_set_single_palette_reg(regs->bl, regs->bh);
625 handle_101001(struct bregs *regs)
627 vgahw_set_overscan_border_color(regs->bh);
631 handle_101002(struct bregs *regs)
633 vgahw_set_all_palette_reg(regs->es, (u8*)(regs->dx + 0));
637 handle_101003(struct bregs *regs)
639 vgahw_toggle_intensity(regs->bl);
643 handle_101007(struct bregs *regs)
647 regs->bh = vgahw_get_single_palette_reg(regs->bl);
651 handle_101008(struct bregs *regs)
653 regs->bh = vgahw_get_overscan_border_color(regs);
657 handle_101009(struct bregs *regs)
659 vgahw_get_all_palette_reg(regs->es, (u8*)(regs->dx + 0));
663 handle_101010(struct bregs *regs)
665 u8 rgb[3] = {regs->dh, regs->ch, regs->cl};
666 vgahw_set_dac_regs(GET_SEG(SS), rgb, regs->bx, 1);
670 handle_101012(struct bregs *regs)
672 vgahw_set_dac_regs(regs->es, (u8*)(regs->dx + 0), regs->bx, regs->cx);
676 handle_101013(struct bregs *regs)
678 vgahw_select_video_dac_color_page(regs->bl, regs->bh);
682 handle_101015(struct bregs *regs)
685 vgahw_get_dac_regs(GET_SEG(SS), rgb, regs->bx, 1);
692 handle_101017(struct bregs *regs)
694 vgahw_get_dac_regs(regs->es, (u8*)(regs->dx + 0), regs->bx, regs->cx);
698 handle_101018(struct bregs *regs)
700 vgahw_set_pel_mask(regs->bl);
704 handle_101019(struct bregs *regs)
706 regs->bl = vgahw_get_pel_mask();
710 handle_10101a(struct bregs *regs)
712 vgahw_read_video_dac_state(®s->bl, ®s->bh);
716 handle_10101b(struct bregs *regs)
718 biosfn_perform_gray_scale_summing(regs->bx, regs->cx);
722 handle_1010XX(struct bregs *regs)
728 handle_1010(struct bregs *regs)
731 case 0x00: handle_101000(regs); break;
732 case 0x01: handle_101001(regs); break;
733 case 0x02: handle_101002(regs); break;
734 case 0x03: handle_101003(regs); break;
735 case 0x07: handle_101007(regs); break;
736 case 0x08: handle_101008(regs); break;
737 case 0x09: handle_101009(regs); break;
738 case 0x10: handle_101010(regs); break;
739 case 0x12: handle_101012(regs); break;
740 case 0x13: handle_101013(regs); break;
741 case 0x15: handle_101015(regs); break;
742 case 0x17: handle_101017(regs); break;
743 case 0x18: handle_101018(regs); break;
744 case 0x19: handle_101019(regs); break;
745 case 0x1a: handle_10101a(regs); break;
746 case 0x1b: handle_10101b(regs); break;
747 default: handle_1010XX(regs); break;
753 handle_101100(struct bregs *regs)
755 vgafb_load_font(regs->es, (void*)(regs->bp+0), regs->cx
756 , regs->dx, regs->bl, regs->bh);
760 handle_101101(struct bregs *regs)
762 vgafb_load_font(get_global_seg(), vgafont14, 0x100, 0, regs->bl, 14);
766 handle_101102(struct bregs *regs)
768 vgafb_load_font(get_global_seg(), vgafont8, 0x100, 0, regs->bl, 8);
772 handle_101103(struct bregs *regs)
774 vgahw_set_text_block_specifier(regs->bl);
778 handle_101104(struct bregs *regs)
780 vgafb_load_font(get_global_seg(), vgafont16, 0x100, 0, regs->bl, 16);
784 handle_101110(struct bregs *regs)
786 vgafb_load_font(regs->es, (void*)(regs->bp+0), regs->cx
787 , regs->dx, regs->bl, regs->bh);
788 set_scan_lines(regs->bh);
792 handle_101111(struct bregs *regs)
794 vgafb_load_font(get_global_seg(), vgafont14, 0x100, 0, regs->bl, 14);
799 handle_101112(struct bregs *regs)
801 vgafb_load_font(get_global_seg(), vgafont8, 0x100, 0, regs->bl, 8);
806 handle_101114(struct bregs *regs)
808 vgafb_load_font(get_global_seg(), vgafont16, 0x100, 0, regs->bl, 16);
813 handle_101130(struct bregs *regs)
817 u32 segoff = GET_IVT(0x1f).segoff;
818 regs->es = segoff >> 16;
823 u32 segoff = GET_IVT(0x43).segoff;
824 regs->es = segoff >> 16;
829 regs->es = get_global_seg();
830 regs->bp = (u32)vgafont14;
833 regs->es = get_global_seg();
834 regs->bp = (u32)vgafont8;
837 regs->es = get_global_seg();
838 regs->bp = (u32)vgafont8 + 128 * 8;
841 regs->es = get_global_seg();
842 regs->bp = (u32)vgafont14alt;
845 regs->es = get_global_seg();
846 regs->bp = (u32)vgafont16;
849 regs->es = get_global_seg();
850 regs->bp = (u32)vgafont16alt;
853 dprintf(1, "Get font info BH(%02x) was discarded\n", regs->bh);
856 // Set byte/char of on screen font
857 regs->cx = GET_BDA(char_height) & 0xff;
859 // Set Highest char row
860 regs->dx = GET_BDA(video_rows);
864 handle_1011XX(struct bregs *regs)
870 handle_1011(struct bregs *regs)
873 case 0x00: handle_101100(regs); break;
874 case 0x01: handle_101101(regs); break;
875 case 0x02: handle_101102(regs); break;
876 case 0x03: handle_101103(regs); break;
877 case 0x04: handle_101104(regs); break;
878 case 0x10: handle_101110(regs); break;
879 case 0x11: handle_101111(regs); break;
880 case 0x12: handle_101112(regs); break;
881 case 0x14: handle_101114(regs); break;
882 case 0x30: handle_101130(regs); break;
883 default: handle_1011XX(regs); break;
889 handle_101210(struct bregs *regs)
891 u16 crtc_addr = GET_BDA(crtc_address);
892 if (crtc_addr == VGAREG_MDA_CRTC_ADDRESS)
896 regs->cx = GET_BDA(video_switches) & 0x0f;
900 handle_101230(struct bregs *regs)
902 u8 mctl = GET_BDA(modeset_ctl);
903 u8 vswt = GET_BDA(video_switches);
907 mctl = (mctl & ~0x10) | 0x80;
908 vswt = (vswt & ~0x0f) | 0x08;
913 vswt = (vswt & ~0x0f) | 0x09;
917 mctl = (mctl & ~0x80) | 0x10;
918 vswt = (vswt & ~0x0f) | 0x09;
921 dprintf(1, "Select vert res (%02x) was discarded\n", regs->al);
924 SET_BDA(modeset_ctl, mctl);
925 SET_BDA(video_switches, vswt);
930 handle_101231(struct bregs *regs)
932 u8 v = (regs->al & 0x01) << 3;
933 u8 mctl = GET_BDA(video_ctl) & ~0x08;
934 SET_BDA(video_ctl, mctl | v);
939 handle_101232(struct bregs *regs)
941 vgahw_enable_video_addressing(regs->al);
946 handle_101233(struct bregs *regs)
948 u8 v = ((regs->al << 1) & 0x02) ^ 0x02;
949 u8 v2 = GET_BDA(modeset_ctl) & ~0x02;
950 SET_BDA(modeset_ctl, v | v2);
955 handle_101234(struct bregs *regs)
957 u8 v = (regs->al & 0x01) ^ 0x01;
958 u8 v2 = GET_BDA(modeset_ctl) & ~0x01;
959 SET_BDA(modeset_ctl, v | v2);
964 handle_101235(struct bregs *regs)
971 handle_101236(struct bregs *regs)
978 handle_1012XX(struct bregs *regs)
984 handle_1012(struct bregs *regs)
987 case 0x10: handle_101210(regs); break;
988 case 0x30: handle_101230(regs); break;
989 case 0x31: handle_101231(regs); break;
990 case 0x32: handle_101232(regs); break;
991 case 0x33: handle_101233(regs); break;
992 case 0x34: handle_101234(regs); break;
993 case 0x35: handle_101235(regs); break;
994 case 0x36: handle_101236(regs); break;
995 default: handle_1012XX(regs); break;
998 // XXX - cirrus has 1280, 1281, 1282, 1285, 129a, 12a0, 12a1, 12a2, 12ae
1003 handle_1013(struct bregs *regs)
1006 struct cursorpos cp = {regs->dl, regs->dh, regs->bh};
1007 biosfn_write_string(cp, regs->al, regs->bl, regs->cx
1008 , regs->es, (void*)(regs->bp + 0));
1013 handle_101a00(struct bregs *regs)
1015 regs->bx = GET_BDA(dcc_index);
1020 handle_101a01(struct bregs *regs)
1022 SET_BDA(dcc_index, regs->bl);
1023 dprintf(1, "Alternate Display code (%02x) was discarded\n", regs->bh);
1028 handle_101aXX(struct bregs *regs)
1034 handle_101a(struct bregs *regs)
1037 case 0x00: handle_101a00(regs); break;
1038 case 0x01: handle_101a01(regs); break;
1039 default: handle_101aXX(regs); break;
1045 u16 static_functionality_off;
1046 u16 static_functionality_seg;
1066 handle_101b(struct bregs *regs)
1069 struct funcInfo *info = (void*)(regs->di+0);
1070 memset_far(seg, info, 0, sizeof(*info));
1071 // Address of static functionality table
1072 SET_FARVAR(seg, info->static_functionality_off, (u32)static_functionality);
1073 SET_FARVAR(seg, info->static_functionality_seg, get_global_seg());
1075 // Hard coded copy from BIOS area. Should it be cleaner ?
1076 memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49, 30);
1077 memcpy_far(seg, info->bda_0x84, SEG_BDA, (void*)0x84, 3);
1079 SET_FARVAR(seg, info->dcc_index, GET_BDA(dcc_index));
1080 SET_FARVAR(seg, info->colors, 16);
1081 SET_FARVAR(seg, info->pages, 8);
1082 SET_FARVAR(seg, info->scan_lines, 2);
1083 SET_FARVAR(seg, info->video_mem, 3);
1089 handle_101c00(struct bregs *regs)
1091 u16 flags = regs->cx;
1094 size += sizeof(struct saveVideoHardware);
1096 size += sizeof(struct saveBDAstate);
1098 size += sizeof(struct saveDACcolors);
1104 handle_101c01(struct bregs *regs)
1106 u16 flags = regs->cx;
1108 void *data = (void*)(regs->bx+0);
1110 vgahw_save_state(seg, data);
1111 data += sizeof(struct saveVideoHardware);
1114 biosfn_save_bda_state(seg, data);
1115 data += sizeof(struct saveBDAstate);
1118 vgahw_save_dac_state(seg, data);
1123 handle_101c02(struct bregs *regs)
1125 u16 flags = regs->cx;
1127 void *data = (void*)(regs->bx+0);
1129 vgahw_restore_state(seg, data);
1130 data += sizeof(struct saveVideoHardware);
1133 biosfn_restore_bda_state(seg, data);
1134 data += sizeof(struct saveBDAstate);
1137 vgahw_restore_dac_state(seg, data);
1142 handle_101cXX(struct bregs *regs)
1148 handle_101c(struct bregs *regs)
1151 case 0x00: handle_101c00(regs); break;
1152 case 0x01: handle_101c01(regs); break;
1153 case 0x02: handle_101c02(regs); break;
1154 default: handle_101cXX(regs); break;
1160 handle_104f00(struct bregs *regs)
1162 // XXX - vbe_biosfn_return_controller_information(&AX,ES,DI);
1163 // XXX - OR cirrus_vesa_00h
1167 handle_104f01(struct bregs *regs)
1169 // XXX - vbe_biosfn_return_mode_information(&AX,CX,ES,DI);
1170 // XXX - OR cirrus_vesa_01h
1174 handle_104f02(struct bregs *regs)
1176 // XXX - vbe_biosfn_set_mode(&AX,BX,ES,DI);
1177 // XXX - OR cirrus_vesa_02h
1181 handle_104f03(struct bregs *regs)
1183 // XXX - vbe_biosfn_return_current_mode
1184 // XXX - OR cirrus_vesa_03h
1188 handle_104f04(struct bregs *regs)
1190 // XXX - vbe_biosfn_save_restore_state(&AX, CX, DX, ES, &BX);
1194 handle_104f05(struct bregs *regs)
1196 // XXX - vbe_biosfn_display_window_control
1197 // XXX - OR cirrus_vesa_05h
1201 handle_104f06(struct bregs *regs)
1203 // XXX - vbe_biosfn_set_get_logical_scan_line_length
1204 // XXX - OR cirrus_vesa_06h
1208 handle_104f07(struct bregs *regs)
1210 // XXX - vbe_biosfn_set_get_display_start
1211 // XXX - OR cirrus_vesa_07h
1215 handle_104f08(struct bregs *regs)
1217 // XXX - vbe_biosfn_set_get_dac_palette_format
1221 handle_104f0a(struct bregs *regs)
1223 // XXX - vbe_biosfn_return_protected_mode_interface
1227 handle_104fXX(struct bregs *regs)
1234 handle_104f(struct bregs *regs)
1236 if (! CONFIG_VBE || !vbe_has_vbe_display()) {
1237 handle_104fXX(regs);
1242 case 0x00: handle_104f00(regs); break;
1243 case 0x01: handle_104f01(regs); break;
1244 case 0x02: handle_104f02(regs); break;
1245 case 0x03: handle_104f03(regs); break;
1246 case 0x04: handle_104f04(regs); break;
1247 case 0x05: handle_104f05(regs); break;
1248 case 0x06: handle_104f06(regs); break;
1249 case 0x07: handle_104f07(regs); break;
1250 case 0x08: handle_104f08(regs); break;
1251 case 0x0a: handle_104f0a(regs); break;
1252 default: handle_104fXX(regs); break;
1258 handle_10XX(struct bregs *regs)
1263 // INT 10h Video Support Service Entry Point
1265 handle_10(struct bregs *regs)
1267 debug_enter(regs, DEBUG_VGA_10);
1269 case 0x00: handle_1000(regs); break;
1270 case 0x01: handle_1001(regs); break;
1271 case 0x02: handle_1002(regs); break;
1272 case 0x03: handle_1003(regs); break;
1273 case 0x04: handle_1004(regs); break;
1274 case 0x05: handle_1005(regs); break;
1275 case 0x06: handle_1006(regs); break;
1276 case 0x07: handle_1007(regs); break;
1277 case 0x08: handle_1008(regs); break;
1278 case 0x09: handle_1009(regs); break;
1279 case 0x0a: handle_100a(regs); break;
1280 case 0x0b: handle_100b(regs); break;
1281 case 0x0c: handle_100c(regs); break;
1282 case 0x0d: handle_100d(regs); break;
1283 case 0x0e: handle_100e(regs); break;
1284 case 0x0f: handle_100f(regs); break;
1285 case 0x10: handle_1010(regs); break;
1286 case 0x11: handle_1011(regs); break;
1287 case 0x12: handle_1012(regs); break;
1288 case 0x13: handle_1013(regs); break;
1289 case 0x1a: handle_101a(regs); break;
1290 case 0x1b: handle_101b(regs); break;
1291 case 0x1c: handle_101c(regs); break;
1292 case 0x4f: handle_104f(regs); break;
1293 default: handle_10XX(regs); break;
1298 /****************************************************************
1300 ****************************************************************/
1305 // init detected hardware BIOS Area
1306 // set 80x25 color (not clear from RBIL but usual)
1307 u16 eqf = GET_BDA(equipment_list_flags);
1308 SET_BDA(equipment_list_flags, (eqf & 0xffcf) | 0x20);
1310 // Just for the first int10 find its children
1312 // the default char height
1313 SET_BDA(char_height, 0x10);
1316 SET_BDA(video_ctl, 0x60);
1318 // Set the basic screen we have
1319 SET_BDA(video_switches, 0xf9);
1321 // Set the basic modeset options
1322 SET_BDA(modeset_ctl, 0x51);
1324 // Set the default MSR
1325 SET_BDA(video_msr, 0x09);
1329 vga_post(struct bregs *regs)
1331 debug_enter(regs, DEBUG_VGA_POST);
1340 extern void entry_10(void);
1341 SET_IVT(0x10, get_global_seg(), (u32)entry_10);
1346 // XXX - clear screen and display info
1349 SET_VGA(video_save_pointer_table[0], (u32)video_param_table);
1350 SET_VGA(video_save_pointer_table[1], get_global_seg());
1353 extern u8 _rom_header_size, _rom_header_checksum;
1354 SET_VGA(_rom_header_checksum, 0);
1355 u8 sum = -checksum_far(get_global_seg(), 0, _rom_header_size * 512);
1356 SET_VGA(_rom_header_checksum, sum);