STI is benutzt, und der klartext fehlt weil ich selber nicht den Durchblick habe was da los is...
[edit]Also im klartext: Die IRQ's waren nicht gemappt, also hätte theoretisch die Exception 13 feuern müssen beim ersten Versuch des PIT, irgendwas zu melden... Und nach dem Einschalten der IRQ's kommt der PIT genau einmal zu Wort, dann ist schluss... [/edit]
Der IDT code:
#include <system.h>
#include <video.h>
typedef struct
{
unsigned short base_low;
unsigned short sel;
unsigned char resvd;
unsigned char flags;
unsigned short base_high;
} __attribute__((packed)) IDT_ENTRY;
typedef struct
{
unsigned short limit;
unsigned int base;
} __attribute__((packed)) IDT_PTR;
void load_idt();
void _isr00();
[...]
void _isr31();
void _irq00();
[...]
void _irq15();
IDT_ENTRY idt[256];
IDT_PTR idtp;
void set_idt_entry(unsigned char num,unsigned int base,unsigned short sel,unsigned char flags)
{
idt[num].base_low = base & 0xFFFF;
idt[num].base_high = (base >> 16) & 0xFFFF;
idt[num].sel = sel;
idt[num].flags = flags;
idt[num].resvd = 0;
}
void install_idt()
{
idtp.limit = sizeof(IDT_ENTRY)*256 - 1;
idtp.base = (unsigned int)&idt;
memset((unsigned char*)&idt,0,sizeof(IDT_ENTRY)*256);
// insert interrupt handlers here
set_idt_entry(0,(unsigned int)_isr00,0x8,0x8E);
[...]
set_idt_entry(31,(unsigned int)_isr31,0x8,0x8E);
outport(0x20,0x11);
outport(0xA0,0x11);
outport(0x21,0x20);
outport(0xA1,0x28);
outport(0x21,0x04);
outport(0xA1,0x02);
outport(0x21,0x01);
outport(0xA1,0x01);
outport(0x21,0x0);
outport(0xA1,0x0);
set_idt_entry(32,(unsigned int)_irq00,0x8,0x8E);
[...]
set_idt_entry(47,(unsigned int)_irq15,0x8,0x8E);
load_idt();
}
const char* error_messages[] =
{
"Division By Zero\n",
[...]
"Reserved\n",
};
void fault_handler(unsigned char code,unsigned char error)
{
set_colour(1,0);
if(error >= 19) print(error_messages[19]);
else
{
print(error_messages[error]);
if(code > 0)
{
print("Error code: ");
putnum(code);
}
}
putnum(code);
putnum(error);
}
void irq_handler(unsigned char num)
{
putnum(num);
if(num >= 8) outport(0xA0,0x20);
outport(0x20,0x20);
}
Die ISR's sehen so aus:
[GLOBAL _isr00]
_isr00:
cli
push dword 0
push dword 0
call fault_handler
sti
iret
Die IRQ's sehen in etwa alle so aus
[GLOBAL _irq00]
_irq00:
cli
push dword 0
call irq_handler
sti
iret