5 void x86emu_dump_xregs(void);
12 * This is derived from a number of PC system BIOS'es. The intent here is to
13 * provide very primitive video support, before an EGA/VGA BIOS installs its
14 * own interrupt vector. Here, "Ignored" calls should remain so. "Not
15 * Implemented" denotes functionality that can be implemented should the need
16 * arise. What are "Not Implemented" throughout are video memory accesses.
17 * Also, very little input validity checking is done here.
22 if (verbose
&& X86_AH
!= 0x0e) {
23 printf("int%x\n", current
->num
);
30 /* Enter: AL = video mode number */
32 /* Implemented (except for clearing the screen) */
35 u16 ioport
, int1d
, regvals
, tmp
;
36 u8 mode
, cgamode
, cgacolour
;
39 * Ignore all mode numbers but 0x00-0x13. Some systems also ignore
40 * 0x0B and 0x0C, but don't do that here.
46 * You didn't think that was really the mode set, did you? There
47 * are only so many slots in the video parameter table...
51 switch (MEM_RB(0x0410) & 0x30) {
53 mode
= 0x07; /* Force mode to 0x07 */
56 case 0x10: /* CGA 40x25 */
60 case 0x20: /* CGA 80x25 (MCGA?) */
64 case 0x00: /* EGA/VGA */
65 if (mode
>= 0x07) /* Don't try MDA timings */
66 mode
= 0x01; /* !?!?! */
70 /* Locate data in video parameter table */
71 int1d
= MEM_RW(0x1d << 2);
72 regvals
= ((mode
>> 1) << 4) + int1d
;
79 /** Update BIOS Data Area **/
85 tmp
= MEM_RB(mode
+ int1d
+ 0x48);
89 tmp
= MEM_RW((mode
& 0x06) + int1d
+ 0x40);
95 /* Cursor positions, one for each display page */
96 for (i
= 0x0450; i
< 0x0460; i
+= 2)
99 /* Cursor start & end scanlines */
100 tmp
= MEM_RB(regvals
+ 0x0B);
102 tmp
= MEM_RB(regvals
+ 0x0A);
105 /* Current display page number */
108 /* CRTC I/O address */
109 MEM_WW(0x0463, ioport
);
111 /* CGA Mode register value */
112 cgamode
= MEM_RB(mode
+ int1d
+ 0x50);
113 MEM_WB(0x0465, cgamode
);
115 /* CGA Colour register value */
116 MEM_WB(0x0466, cgacolour
);
119 MEM_WB(0x0484, (25 - 1));
121 /* Programme the mode */
122 outb(ioport
+ 4, cgamode
& 0x37); /* Turn off screen */
123 for (i
= 0; i
< 0x10; i
++) {
124 tmp
= MEM_RB(regvals
+ i
);
126 outb(ioport
+ 1, tmp
);
128 outb(ioport
+ 5, cgacolour
); /* Select colour mode */
129 outb(ioport
+ 4, cgamode
); /* Turn on screen */
134 /* Set Cursor Type */
135 /* Enter: CH = starting line for cursor */
136 /* CL = ending line for cursor */
140 u16 ioport
= MEM_RW(0x0463);
142 MEM_WB(0x0460, X86_CL
);
143 MEM_WB(0x0461, X86_CH
);
146 outb(ioport
+ 1, X86_CH
);
148 outb(ioport
+ 1, X86_CL
);
153 /* Set Cursor Position */
154 /* Enter: BH = display page number */
162 MEM_WB((X86_BH
<< 1) + 0x0450, X86_DL
);
163 MEM_WB((X86_BH
<< 1) + 0x0451, X86_DH
);
165 if (X86_BH
!= MEM_RB(0x0462))
168 offset
= (X86_DH
* MEM_RW(0x044A)) + X86_DL
;
169 offset
+= MEM_RW(0x044E) << 1;
171 ioport
= MEM_RW(0x0463);
173 outb(ioport
+ 1, offset
>> 8);
175 outb(ioport
+ 1, offset
& 0xFF);
180 /* Get Cursor Position */
181 /* Enter: BH = display page number */
182 /* Leave: CH = starting line for cursor */
183 /* CL = ending line for cursor */
188 X86_CL
= MEM_RB(0x0460);
189 X86_CH
= MEM_RB(0x0461);
190 X86_DL
= MEM_RB((X86_BH
<< 1) + 0x0450);
191 X86_DH
= MEM_RB((X86_BH
<< 1) + 0x0451);
196 /* Get Light Pen Position */
198 /* Leave: AH = 0x01 (down/triggered) or 0x00 (not) */
199 /* BX = pixel column */
201 /* DH = character row */
202 /* DL = character column */
203 /* Not Implemented */
205 printf("int%x - Get Light Pen Position. "
206 "Function not implemented.\n", current
->num
);
208 X86_AH
= X86_BX
= X86_CX
= X86_DX
= 0;
213 /* Set Display Page */
214 /* Enter: AL = display page number */
218 u16 start
, ioport
= MEM_RW(0x0463);
221 /* Calculate new start address */
222 MEM_WB(0x0462, X86_AL
);
223 start
= X86_AL
* MEM_RW(0x044C);
224 MEM_WW(0x044E, start
);
227 /* Update start address */
229 outb(ioport
+ 1, start
>> 8);
231 outb(ioport
+ 1, start
& 0xFF);
233 /* Switch cursor position */
234 y
= MEM_RB((X86_AL
<< 1) + 0x0450);
235 x
= MEM_RB((X86_AL
<< 1) + 0x0451);
236 start
+= (y
* MEM_RW(0x044A)) + x
;
238 /* Update cursor position */
240 outb(ioport
+ 1, start
>> 8);
242 outb(ioport
+ 1, start
& 0xFF);
247 /* Initialise or Scroll Window Up */
248 /* Enter: AL = lines to scroll up */
249 /* BH = attribute for blank */
250 /* CH = upper y of window */
251 /* CL = left x of window */
252 /* DH = lower y of window */
253 /* DL = right x of window */
255 /* Not Implemented */
257 printf("int%x: Initialise or Scroll Window Up - "
258 "Function not implemented.\n", current
->num
);
264 /* Initialise or Scroll Window Down */
265 /* Enter: AL = lines to scroll down */
266 /* BH = attribute for blank */
267 /* CH = upper y of window */
268 /* CL = left x of window */
269 /* DH = lower y of window */
270 /* DL = right x of window */
272 /* Not Implemented */
274 printf("int%x: Initialise or Scroll Window Down - "
275 "Function not implemented.\n", current
->num
);
282 /* Read Character and Attribute at Cursor */
283 /* Enter: BH = display page number */
284 /* Leave: AH = attribute */
286 /* Not Implemented */
289 ("int%x: Read Character and Attribute at Cursor - "
290 "Function not implemented.\n", current
->num
);
298 /* Write Character and Attribute at Cursor */
299 /* Enter: AL = character */
300 /* BH = display page number */
301 /* BL = attribute (text) or colour (graphics) */
302 /* CX = replication count */
304 /* Not Implemented */
307 ("int%x: Write Character and Attribute at Cursor - "
308 "Function not implemented.\n", current
->num
);
315 /* Write Character at Cursor */
316 /* Enter: AL = character */
317 /* BH = display page number */
319 /* CX = replication count */
321 /* Not Implemented */
323 printf("int%x: Write Character at Cursor - "
324 "Function not implemented.\n", current
->num
);
331 /* Set Palette, Background or Border */
332 /* Enter: BH = 0x00 or 0x01 */
333 /* BL = colour or palette (respectively) */
337 u16 ioport
= MEM_RW(0x0463) + 5;
338 u8 cgacolour
= MEM_RB(0x0466);
342 cgacolour
|= (X86_BL
& 0x01) << 5;
345 cgacolour
|= X86_BL
& 0x1F;
348 MEM_WB(0x0466, cgacolour
);
349 outb(ioport
, cgacolour
);
354 /* Write Graphics Pixel */
355 /* Enter: AL = pixel value */
356 /* BH = display page number */
360 /* Not Implemented */
362 printf("int%x: Write Graphics Pixel - "
363 "Function not implemented.\n", current
->num
);
370 /* Read Graphics Pixel */
371 /* Enter: BH = display page number */
374 /* Leave: AL = pixel value */
375 /* Not Implemented */
377 printf("int%x: Write Graphics Pixel - "
378 "Function not implemented.\n", current
->num
);
387 /* Write Character in Teletype Mode */
388 /* Enter: AL = character */
389 /* BH = display page number */
390 /* BL = foreground colour */
392 /* Not Implemented */
393 /* WARNING: Emulation of BEL characters will require */
394 /* emulation of RTC and PC speaker I/O. */
395 /* Also, this recurses through int 0x10 */
396 /* which might or might not have been */
400 printf("int%x: Write Character in Teletype Mode - "
401 "Function not implemented.\n", current
->num
);
404 printf("%c", X86_AL
);
411 /* Leave: AH = number of columns */
412 /* AL = video mode number */
413 /* BH = display page number */
416 X86_AH
= MEM_RW(0x044A);
417 X86_AL
= MEM_RB(0x0449);
418 X86_BH
= MEM_RB(0x0462);
423 /* Colour Control (subfunction in AL) */
430 /* Font Control (subfunction in AL) */
437 /* Miscellaneous (subfunction in BL) */
440 /* Ignored. Previous code here optionally allowed */
441 /* the enabling and disabling of VGA, but no system */
442 /* BIOS I've come across actually implements it. */
446 /* Write String in Teletype Mode */
447 /* Enter: AL = write mode */
448 /* BL = attribute (if (AL & 0x02) == 0) */
449 /* CX = string length */
452 /* ES:BP = string segment:offset */
454 /* Not Implemented */
455 /* WARNING: Emulation of BEL characters will require */
456 /* emulation of RTC and PC speaker I/O. */
457 /* Also, this recurses through int 0x10 */
458 /* which might or might not have been */
461 printf("int%x: Write String in Teletype Mode - "
462 "Function not implemented.\n", current
->num
);
469 /* Various extensions */