Code: Select all
void PS2Keyboard::IRQHandler()
{
DebugConsole& console = Kernel::Get()->GetConsole(); //works
uint8_t scan_code = __inbyte(0x60); //works
console.SetCol(0x0F); //works
console.Printf("Key"); //works
PIC::SendEOI(mCurrentIRQLine); //works
__asm leave; //problem (i also tried pop esi)
__asm iret; //problem
__halt();
}
i also Remaped the Pic to 32 (pic1) and 40 (pic2) so it doesnt conflict with the reserved intel interrupts
Everything works as expected(and if i remove the problem lines it works but only once since i dont return and just halt there)
but if i try to return from it with iret it gives me a General Protection Fault.
i looked at the assembly code the compiler gave me and it looks like that:
READ COMMENTS
Code: Select all
push esi
;skipping uninteresting code
;DebugConsole& console = Kernel::Get()->GetConsole();
;uint8_t scan_code = __inbyte(0x60);
;console.SetCol(0x0F);
;console.Printf("Key");
;PIC::SendEOI(mCurrentIRQLine);
leave ;insert my custom return code wich might be the problem but if i try to make the function naked
iret ;wich means that it doesnt have a Function prologue or function epilogue but then im very limmited in what i can do in
hlt ;that function( i cant even create local variables) it still wont work. I tried software interrupts and they work fine
pop esi ;but i have to return with RETF 2 wich is probably a problem too ??
ret 0
flags for that interrupt are Present, Ring0 and 32bit InterruptGate (TrapGate wont make a difference??)
does anyone know what might cause this ? (empty function has the same problems)
or if anyone knows a better way to create Interrupt handlers in MSVC++