version: Update year to 2014
[syslinux/sherbszt.git] / core / rawcon.c
blob6910a849e5e84f97bf121fcaa38ec9579ccef64c
1 /*
2 * writechr: Write a single character in AL to the console without
3 * mangling any registers. This does raw console writes,
4 * since some PXE BIOSes seem to interfere regular console I/O.
5 */
6 #include <sys/io.h>
7 #include <fs.h>
8 #include <com32.h>
10 #include "bios.h"
11 #include "graphics.h"
12 #include <syslinux/video.h>
14 __export void writechr(char data)
16 if (UsingVGA & 0x08)
17 syslinux_force_text_mode();
19 write_serial(data); /* write to serial port if needed */
21 /* Write to screen? */
22 if (DisplayCon & 0x01) {
23 com32sys_t ireg, oreg;
24 bool curxyok = false;
25 uint16_t dx;
27 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
28 ireg.eax.b[1] = 0x03; /* Read cursor position */
29 __intcall(0x10, &ireg, &oreg);
30 ireg.edx.l = oreg.edx.l;
32 switch (data) {
33 case 8:
34 if (ireg.edx.b[0]--) {
35 curxyok = true;
36 break;
39 ireg.edx.b[0] = VidCols;
40 if (ireg.edx.b[1]--) {
41 curxyok = true;
42 break;
45 ireg.edx.b[1] = 0;
46 curxyok = true;
47 break;
48 case 13:
49 ireg.edx.b[0] = 0;
50 curxyok = true;
51 break;
52 case 10:
53 break;
54 default:
55 dx = ireg.edx.w[0];
57 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
58 ireg.ebx.b[0] = 0x07; /* White on black */
59 ireg.ecx.w[0] = 1; /* One only */
60 ireg.eax.b[0] = data;
61 ireg.eax.b[1] = 0x09; /* Write char and attribute */
62 __intcall(0x10, &ireg, NULL);
64 ireg.edx.w[0] = dx;
65 if (++ireg.edx.b[0] <= VidCols)
66 curxyok = true;
67 else
68 ireg.edx.b[0] = 0;
71 if (!curxyok && ++ireg.edx.b[1] > VidRows) {
72 /* Scroll */
73 ireg.edx.b[1]--;
74 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
75 ireg.eax.b[1] = 0x02;
76 __intcall(0x10, &ireg, NULL);
78 ireg.eax.w[0] = 0x0601; /* Scroll up one line */
79 ireg.ebx.b[1] = ScrollAttribute;
80 ireg.ecx.w[0] = 0;
81 ireg.edx.w[0] = ScreenSize; /* The whole screen */
82 __intcall(0x10, &ireg, NULL);
83 } else {
84 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
85 ireg.eax.b[1] = 0x02; /* Set cursor position */
86 __intcall(0x10, &ireg, NULL);
91 void pm_writechr(com32sys_t *regs)
93 writechr(regs->eax.b[0]);