insert an interrupt, and call this interrupt with int n.
My system reboots at the point of the int-instruction.
(i tried it out with the int outcommented and it did not reboot then, so it must be the int).
So either my idt is completely false or i do something wrong installing the interrupt vector.
But i cannot imagine where there can be a bug, for i use pretty much the same code as several other kernels i found on the web...
Please help me with that - thank you.
Here is my kmain(stripped off the text-output to keep it short):
Code: Select all
void kmain()
{
initIDT(); //setup an idt
setinteruptvector(9,kbhandler,0x08,0xEE00);//install an interupt vector -later it will be the keyboard handler
asm("int $9");//call the interupt
while(true);//hang
};
//This is my struct for idt entries:
typedef struct interrupt_vector
{
word handleroffset_l;
word segmentselector;
word properties;
word handleroffset_h;
}intvect;
Code: Select all
intvect* idt; //Interupt Descriptor Table (global)
inline void initIDT()
{
unsigned long idtinfo[2]; //this is the info i am going to load into idtr
int i;
for(i=0; i<256; i++)setinteruptvector(i,emptyint,0x08,0xEE00);//fill idt with empty ints
asm("pushfl");//disable ints while loading idt
idtinfo[0]=(256*(sizeof(intvect)-1))<<16; //size of idt
//(i also tried it without '<<16', because some sources do it and others not
// i also wonder why one should do that '<<16')
idtinfo[1]=(unsigned long)idt; //idt adress
__asm__ __volatile__ ("lidt (%0)": :"p" (((char *) idtinfo)+2));//load the idt-info stuff
asm("popfl"); //re-enable ints
};
void setinteruptvector(int tableindex, void *hoffset, word selector, word properties)
//I also tried void(*hoffset)() instead of void* hoffset
//(and when calling: &kbhandler instead of kbhandler)
//i have seen both and i think in the end it does the same...(?)
{
idt[tableindex].segmentselector=selector;
idt[tableindex].properties=properties;
idt[tableindex].handleroffset_l=(unsigned short)(((unsigned long)hoffset) & 0xFFFF);
idt[tableindex].handleroffset_h=(unsigned short)(((unsigned long)hoffset) >>16);
};
Code: Select all
void kbhandler()
{
//asm ("cli \n");
kprint("Keyboard input or Coprocessor Overrun Exception!",7);
while(true);
//asm("sti \n" "iret \n");
};
void emptyint()
{
//asm ("cli \n");
kprint("Empty Interupt!",7);
while(true);
//asm("sti \n" "iret \n");
};
//I also tried it with the asm statements not outcommented and the while(true);
//outcommented - same result