Hi. I have a problem. (So i'm writing ;D) I tried, but it doesn't run. I wrote this function.
// ---------- C++ CODE ---------------
extern "C" void set_idtr();
struct tIDTR{
unsigned int base;
unsigned short limit;
}__attribute__((packed));
struct tIDTR IDTR;
void load_idtr( unsigned int base, unsigned short limit )
{
IDTR.base = base;
IDTR.limit = limit;
set_idtr(); // ASM Extern
}
// -------- ASM CODE ------------
global _set_idtr
extern _IDTR
_set_idtr:
lidt [_IDTR]
ret
But this isn't working. When an interrupt occured, pc rebooting. Is this code wrong? or my isr's wrong? If this code not wrong, i'll continue to question Thanks.
C++ IDTR Loader
Re:C++ IDTR Loader
I'm sorry. In forum, i wrote it wrong. In code, it is true. Another, what can be?
Re:C++ IDTR Loader
Have you set any idt entries? This seems to be missing. Check out the articles on OSDEV regarding interupts
Re:C++ IDTR Loader
Hi..
I dont knw whether this is the problem.. but u can try it out...
My IDT Size Descriptor structure is
Thus when u assing the address of IDT table to this structure try to break it first in 16-16bit halfs & then assign to structure
I dont knw whether this is the problem.. but u can try it out...
My IDT Size Descriptor structure is
Code: Select all
struct IDT_Size_Descriptor
{
unsigned short limit; //How long is IDT
unsigned short lowbase; //Low of Where Table starts
unsigned short highbase; //High of where Table starts
} __attribute__((__packed__));
Code: Select all
sz.limit = (MAXIDT*8)-1;
sz.lowbase = (unsigned int)idt & 0xFFFF;
sz.highbase = ((unsigned int)idt & 0xFFFF0000) >> 16;
__asm__ ("lidt (%%eax)" : : "a"(&sz));