Keyboard interrupt
Posted: Sat Feb 21, 2004 9:40 am
Hi @all.
What have I to do, to enable the keyboard interrupt in pmode.
Currently I do this:
1. create and load an IDT Table
2. register my keyboard-handler-function and enable the irq
3. wait for the keyboard to accept commands
4. restart the controller, and enable it
5. set the scanning rate
6. enable interrupts
at point 6 is the problem, with bochs this works fine, with my AMD 5x86 (133Mhz) too but with my AMD Duron(1,00GHz) the interrupt handler for Triple Faults is called (prints out a message).
the code for the steps (2) 3 - 5:
What have I to do, to enable the keyboard interrupt in pmode.
Currently I do this:
1. create and load an IDT Table
2. register my keyboard-handler-function and enable the irq
3. wait for the keyboard to accept commands
4. restart the controller, and enable it
5. set the scanning rate
6. enable interrupts
at point 6 is the problem, with bochs this works fine, with my AMD 5x86 (133Mhz) too but with my AMD Duron(1,00GHz) the interrupt handler for Triple Faults is called (prints out a message).
the code for the steps (2) 3 - 5:
Code: Select all
void init_keyboard()
{
putstr("Initialize the Keyboard..................");
enable_irq(1, keyboardInt, INT_GATE|BITS_32|PRESENT|RING_2);
SendData(0xFF); //Restart keyboard
SendData(0xF4); //Enables keyboard and Scanning
SetRate(KDefault); //Sets default scanning rate
enable(); // if i don't call this function, i don't get the message
putstr(".DONE\n");
for(;;); // this is to be sure nothing else create the triple fault
}
void SendData(unsigned char data) //Sends a command or data to keyboard
{
WaitForReady(); //MicroDelay((unsigned long) 10);
outportb(0x60, data);
}
void WaitForReady(void) //determines if the keyboard is ready to accept a command
{
volatile long i = MAX_TRYES_FOR_READY;
while(i-- && (inportb(0x64) & 0x02));
}
inline static unsigned char inportb(int port)
{
register unsigned char r;
asm volatile
(
"inb %%dx, %%al\n\t"
: "=a" (r)
: "d" (port)
);
return (r);
}
inline static void outportb(int port, unsigned char data)
{
asm volatile
(
"outb %%al, %%dx\n\t"
:
: "a" (data), "d" (port)
);
}
inline static void enable()
{
asm volatile
(
"sti"
:
:
);
}