27 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_CONSOLE) || defined (POK_NEEDS_INSTRUMENTATION) || defined (POK_NEEDS_COVERAGE_INFOS)
29 static const int screen_w = 80;
30 static const int screen_h = 25;
31 static const int tab_size = 8;
32 static char *
const vga_base = (
char *)0xb8000;
35 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_INSTRUMENTATION) || defined (POK_NEEDS_COVERAGE_INFOS)
38 int is_transmit_empty() {
39 return inb(COM1 + 5) & 0x20;
42 void write_serial(
char a) {
43 while (is_transmit_empty() == 0);
51 void pok_cons_print_char (
const char c)
53 #ifdef POK_NEEDS_CONSOLE
55 static struct s_cons local_curs;
59 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_INSTRUMENTATION) || defined (POK_NEEDS_COVERAGE_INFOS)
63 #ifdef POK_NEEDS_CONSOLE
79 local_curs.col += tab_size - local_curs.col % tab_size;
82 if (c !=
'\r' && c !=
'\n' && c !=
'\t')
84 ptr = vga_base + 2 * screen_w * local_curs.row + 2 * local_curs.col++;
87 *ptr = local_curs.cur_attr;
90 if (local_curs.col >= screen_w)
96 if (local_curs.row >= screen_h)
98 memcpy (vga_base, vga_base + 2 * screen_w, (screen_h - 1) * screen_w * 2);
99 for (i = 0; i < screen_w; ++i)
101 *(vga_base + 2 * screen_w * (screen_h - 1) + 2 * i) = 0;
102 *(vga_base + 2 * screen_w * (screen_h - 1) + 2 * i + 1) = local_curs.cur_attr;
104 local_curs.row = screen_h - 1;
112 void pok_cons_attr (
uint8_t attr)
114 g_cons.cur_attr = attr;
117 void pok_cons_clear (
void)
122 static struct s_cons local_curs;
127 for (i = 0 ; i < screen_h ; ++i)
129 for (j = 0 ; j < screen_w ; ++j)
133 *ptr = g_cons.cur_attr;
155 if ((
const unsigned char)s[i] == CONS_ESCAPE)
165 pok_cons_attr((
const unsigned char)s[i]);
169 g_cons.row = (
const unsigned char)s[i] % screen_h;
173 g_cons.col = (
const unsigned char)s[i] % screen_w;
176 pok_cons_print_char(s[i]);
182 pok_cons_print_char(s[i]);
190 #ifdef POK_NEEDS_CONSOLE
191 void pok_cons_disable_cursor (
void)
196 if (
inb(0x3cc) & 0x01)
205 tmp =
inb (base_port);
206 outb (base_port, 0x0a);
207 outb (base_port + 1,
inb (base_port + 1) | 0x20);
208 outb (base_port, tmp);
214 #ifdef POK_NEEDS_CONSOLE
215 g_cons.cur_attr = CONS_FRONT (CONS_WHITE) | CONS_BACK (CONS_BLACK);
217 pok_cons_disable_cursor ();
218 pok_print_init (pok_cons_print_char, pok_cons_attr);
221 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_INSTRUMENTATION) || defined (POK_NEEDS_COVERAGE_INFOS)
223 outb(COM1 + 1, 0x00);
224 outb(COM1 + 3, 0x80);
225 outb(COM1 + 0, 0x03);
226 outb(COM1 + 1, 0x00);
227 outb(COM1 + 3, 0x03);
228 outb(COM1 + 2, 0xC7);
229 outb(COM1 + 4, 0x0B);