okay, first ... please register to this forum, so that you'll be able to post your code rather than flooding a thread with poorly formatted code (there's a [ code ] [ /code ] style for short code fragments).
second. I'm afraid you have *not* "done eveything according tutorials" ... For instance:
Code: Select all
typedef struct
{
unsigned short limit; // length of the IDT
__u32 base; // address fo the start of the IDT
}IdtP;
has little chance to follow the 6 bytes packing intel requires. Instead, the compiler will actually implement the structure as
Code: Select all
{
unsigned short limit;
short padding;
__u32 base;
}IdtP;
so that base will be 4bytes-aligned. Check your compiler's documentation to know how you can get around this. A possible trick is to put padding *then* limit and to tranmit
((void*)&IDTR)+2 to your lidt instruction.
Fix this first: until you have a valid IDTR, you cannot receive exception correctly.
third, please, for the sake of readability, consider declaring "outb()" and "inb()" macros rather than using ASM() commands everywhere... And if i were you, i would *not* restore the old masks after remapping because you're not sure of what interrupt you will receive. Unmask interrupts one by one, when you install handlers for them.
fourth (damn, i didn't plan to go that far), you should *not* issue several asm() commands and expect register values to be preserved from on to another.
Code: Select all
void Int::disableNMI(){
__asm__("inb %%dx, %%al \t\n"::"d"(0x70));
__asm__("andb 0x7f, %al \t\n");
__asm__("outb %%al, %%dx \t\n"::"d"(0x70));
}
should rather be written
Code: Select all
void Int::disableNMI(){
__asm__ volatile("inb %%dx, %%al \t\nandb 0x7f, %al \t\noutb %%al, %%dx \t\n"::"d"(0x70));
}
The 'volatile' keyword will force the compiler to issue the assembler statement even if it thinks these commands may be omitted for optimization purpose.
or better:
Code: Select all
//io.h
static inline __u8 inb(__u16 port)
{
__u8 val;
__asm__ volatile("inb %1, %0":"=a"(val):"d"(port));
}
// your file
void Int::disableNMI() {
outb(0x70,inb(0x70)&0x7f);
}