module: Allow .c32 files to execute themselves
[syslinux.git] / core / rawcon.c
blob92f0898a2b5397ed92a0763d8fe519f15b8a37c8
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"
13 __export void writechr(char data)
15 if (UsingVGA & 0x08)
16 syslinux_force_text_mode();
18 write_serial(data); /* write to serial port if needed */
20 /* Write to screen? */
21 if (DisplayCon & 0x01) {
22 com32sys_t ireg, oreg;
23 bool curxyok = false;
24 uint16_t dx;
26 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
27 ireg.eax.b[1] = 0x03; /* Read cursor position */
28 __intcall(0x10, &ireg, &oreg);
29 ireg.edx.l = oreg.edx.l;
31 switch (data) {
32 case 8:
33 if (ireg.edx.b[0]--) {
34 curxyok = true;
35 break;
38 ireg.edx.b[0] = VidCols;
39 if (ireg.edx.b[1]--) {
40 curxyok = true;
41 break;
44 ireg.edx.b[1] = 0;
45 curxyok = true;
46 break;
47 case 13:
48 ireg.edx.b[0] = 0;
49 curxyok = true;
50 break;
51 case 10:
52 break;
53 default:
54 dx = ireg.edx.w[0];
56 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
57 ireg.ebx.b[0] = 0x07; /* White on black */
58 ireg.ecx.w[0] = 1; /* One only */
59 ireg.eax.b[0] = data;
60 ireg.eax.b[1] = 0x09; /* Write char and attribute */
61 __intcall(0x10, &ireg, NULL);
63 ireg.edx.w[0] = dx;
64 if (++ireg.edx.b[0] <= VidCols)
65 curxyok = true;
66 else
67 ireg.edx.b[0] = 0;
70 if (!curxyok && ++ireg.edx.b[1] > VidRows) {
71 /* Scroll */
72 ireg.edx.b[1]--;
73 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
74 ireg.eax.b[1] = 0x02;
75 __intcall(0x10, &ireg, NULL);
77 ireg.eax.w[0] = 0x0601; /* Scroll up one line */
78 ireg.ebx.b[1] = ScrollAttribute;
79 ireg.ecx.w[0] = 0;
80 ireg.edx.w[0] = ScreenSize; /* The whole screen */
81 __intcall(0x10, &ireg, NULL);
82 } else {
83 ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
84 ireg.eax.b[1] = 0x02; /* Set cursor position */
85 __intcall(0x10, &ireg, NULL);
90 void pm_writechr(com32sys_t *regs)
92 writechr(regs->eax.b[0]);