From 2c7f83e006c3fee8d26e940eee801a4be9443e50 Mon Sep 17 00:00:00 2001 From: neoraider Date: Mon, 18 Apr 2005 15:18:02 +0000 Subject: Verzeichnisstruktur ver?ndert --- system/kernel.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 system/kernel.c (limited to 'system/kernel.c') diff --git a/system/kernel.c b/system/kernel.c new file mode 100644 index 0000000..e8ad3a9 --- /dev/null +++ b/system/kernel.c @@ -0,0 +1,115 @@ +/* kernel.c - kernel functions */ + +#include +#include + + +extern unsigned char console_std_attr; +extern unsigned short console_cur_pos; +extern unsigned char console_flags; + +unsigned char numprint = 0; + +#define PRINT_ON if(numprint == 0) { \ + asm("cli");\ + console_cursor_off();\ + }\ + numprint++ + +#define PRINT_OFF numprint--;\ + if(numprint == 0) {\ + console_cursor_on();\ + asm("sti");\ + } + + +void print(unsigned char * text) { + print_attr(text, console_std_attr); +} + +void print_attr(unsigned char * text, unsigned char attr) { + PRINT_ON; + while(*text) { + print_char_attr(*text, attr); + text++; + } + PRINT_OFF; +} + +void print_char(unsigned char text) { + print_char_attr(text, console_std_attr); +} + +void print_char_attr(unsigned char text, unsigned char attr) { + PRINT_ON; + switch(text) { + case 0x08: // backspace + if(console_cur_pos) console_cur_pos--; + break; + case 0x09: // tab + console_cur_pos += (8 - (console_cur_pos % 8)); + break; + case 0x0A: // new line + console_cur_pos += (80 - (console_cur_pos % 80)); + break; + case 0x0B: // home + case 0x0C: // form feed + console_cur_pos = 0; + asm( + "cld\n" + "mov $32,%%ax\n" + "mov %%ax,%%es\n" + "xor %%edi,%%edi\n" + "mov %0,%%ah\n" + "mov $0x20,%%al\n" + "mov $2000,%%ecx\n" + "rep stosw" + : : "m" (attr) + ); + break; + case 0x0D: // carriage return + console_cur_pos -= (console_cur_pos % 80); + break; + default: + ANSI2ASCII(text); + asm( + "cld\n" + "mov $32,%%ax\n" + "mov %%ax,%%es\n" + "xor %%eax,%%eax\n" + "mov %0,%%ax\n" + "shl $1,%%eax\n" + "mov %%eax,%%edi\n" + "mov %1,%%al\n" + "mov %2,%%ah\n" + "stosw" + : : "m" (console_cur_pos), "m" (text), "m" (attr) + ); + console_cur_pos++; + } + // scroll + if(console_cur_pos >= 2000) { + console_cur_pos -= 80; + asm( + "cld\n" + "push %%ds\n" + + "mov $32,%%ax\n" + "mov %%ax,%%ds\n" + "mov %%ax,%%es\n" + "mov $1920,%%ecx\n" + "mov $160,%%esi\n" + "xor %%edi,%%edi\n" + "rep movsw\n" + + "mov $80,%%cx\n" + "mov %%cs:%0,%%ah\n" + "mov $0x20,%%al\n" + "rep stosw\n" + + "pop %%ds" + : : "m" (console_std_attr) + ); + } + PRINT_OFF; +} -- cgit v1.2.3