#include #include "console.h" // this will allow us to write to screen //// interrupt stuff ///// // #define INT_MAX 255 // interrupt descriptor table static struct int_desc { uint16_t addrLo; uint16_t sel; uint8_t zeros; uint8_t flags; uint16_t addrHi; } idt[INT_MAX]; static struct int_desc *idt_old=0x1000; // interrupt descriptor table descriptor static struct idt_desc { uint16_t size; uint32_t base; } idtd; volatile char col=100; char col2=0; int cursor=0; char last_code=0; volatile void int_def_handler() { __asm__("pusha"); col++; print_str(5,5,"Interrupted"); __asm__("popa"); __asm__("iret"); } void int_init(uint16_t sel) { int i; idtd.size=sizeof(struct int_desc)*INT_MAX-1; // why the -1 ?? idtd.base=(uint32_t)&idt[0]; for(i=0; i> 16) & 0xffff; idt_old[irq].addrLo = 0x087c; idt_old[irq].addrHi = 0x0; idt_old[irq].zeros=0; idt_old[irq].flags=flags; idt_old[irq].sel=sel; } void int_install() { __asm__("lidt %0"::"m" (idtd)); } void int_disable() { __asm__("cli"); } void int_enable() { __asm__("sti"); } void kernel_main() { char str[]="ABC"; // int_init(0x08); // offset in GDT (CODE_SEG) int_install_ir(33,0b1000110,0x8,&int_def_handler); int_install_ir(33,0b1000110,0x8,0x087c); // int_install(); // int_enable(); print_str(0,0,"Interrupts Enabled"); while(1) { print_str_col(0,0,str,col); print_str_col(0,2,str,col2++); int0(); } } void int0() { int i=0; char* int_count=(char *)0x7c00+3; char make_codes[]={ 0x1e, // A 0x30, // B 0x2e, // C 0x20, // D 0x12, // E 0x21, // F 0x22, // G 0x23, // H 0x17, // I 0x24, // J 0x25, // K 0x26, // L 0x32, // M 0x31, // N 0x18, // O 0x19, // P 0x10, // Q 0x13, // R 0x1F, // S 0x14, // T 0x16, // U 0x2F, // V 0x11, // W 0x2D, // X 0x15, // Y 0x2c, // Z }; char break_codes[]={ 0x9e, // A 0xb0, // B 0xae, // C 0xa0, // D 0x92, // E 0xa1, // F 0xa2, // G 0xa3, // H 0x97, // I 0xa4, // J 0xa5, // K 0xa6, // L 0xb2, // M 0xb1, // N 0x98, // O 0x99, // P 0x90, // Q 0x93, // R 0x9F, // S 0x94, // T 0x96, // U 0xaF, // V 0x91, // W 0xaD, // X 0x95, // Y 0xac, // Z }; print_str(6,6,*int_count); if(last_code==*int_count)return; for(i=0;i<26;i++) { if(make_codes[i]==*int_count) { print_char_col(cursor,10,'A'+i,0xf); } } for(i=0;i<26;i++) { if(break_codes[i]==*int_count) { print_char_col(cursor++,10,'a'+i,SCR_RED); } } last_code=*int_count; }