Page faults and LEDs
Posted: Tue May 26, 2009 12:59 pm
Hmm, where to start,
Problem:
A function in my keyboard driver to set the keyboard LEDs causes a page fault, it actually has caused a lot of things such as causing the function after itself to loop forever, but I've gotten it to cause a triple fault (page fault) and after the triple fault it then catches the page fault and panics.
So now that you know the basic problem it seems pretty simple and straight forward, the LEDs setting function is causing a page fault. But if I comment out the install for the page fault's IRQ then it works perfectly with no page fault or triple fault.
So that leads me to believe that somehow, the install of the page fault IRQ is causing a page fault... but if I remove the LEDs setting code then it doesn't page fault...
It get's even weirder to know that the function to set the LEDs is called AFTER the install of the page fault.
PF Exception + LED function call: Triple fault (#PF) then page fault caught.
PF Exception + No LED function call: Works fine.
No PF Exception + LED function: Works fine.
core.cpp:
Keyboard driver:
It could also be the PIC but I've already looked at that, and if it was the PIC then I would have known a long time ago because other IRQs work fine...
I'm pretty much stumped to what it could be. I have asked help from a couple of people and both of which couldn't figure it out much either. :/
Anyone got any ideas?
(Also, I just came back to the keyboard driver after working on other parts of the kernel for those of you that remember my last topic. )
Problem:
A function in my keyboard driver to set the keyboard LEDs causes a page fault, it actually has caused a lot of things such as causing the function after itself to loop forever, but I've gotten it to cause a triple fault (page fault) and after the triple fault it then catches the page fault and panics.
So now that you know the basic problem it seems pretty simple and straight forward, the LEDs setting function is causing a page fault. But if I comment out the install for the page fault's IRQ then it works perfectly with no page fault or triple fault.
So that leads me to believe that somehow, the install of the page fault IRQ is causing a page fault... but if I remove the LEDs setting code then it doesn't page fault...
It get's even weirder to know that the function to set the LEDs is called AFTER the install of the page fault.
PF Exception + LED function call: Triple fault (#PF) then page fault caught.
PF Exception + No LED function call: Works fine.
No PF Exception + LED function: Works fine.
core.cpp:
Code: Select all
//<Snip>
enable();
setvect(0,(void (__cdecl &)(void))divide_by_zero_fault);
setvect(1,(void (__cdecl &)(void))single_step_trap);
setvect(2,(void (__cdecl &)(void))nmi_trap);
setvect(3,(void (__cdecl &)(void))breakpoint_trap);
setvect(4,(void (__cdecl &)(void))overflow_trap);
setvect(5,(void (__cdecl &)(void))bounds_check_fault);
setvect(6,(void (__cdecl &)(void))invalid_opcode_fault);
setvect(7,(void (__cdecl &)(void))no_device_fault);
setvect(8,(void (__cdecl &)(void))double_fault_abort);
setvect(10,(void (__cdecl &)(void))invalid_tss_fault);
setvect(11,(void (__cdecl &)(void))no_segment_fault);
setvect(12,(void (__cdecl &)(void))stack_fault);
setvect(13,(void (__cdecl &)(void))general_protection_fault);
setvect(14,(void (__cdecl &)(void))page_fault);
setvect(16,(void (__cdecl &)(void))fpu_fault);
setvect(17,(void (__cdecl &)(void))alignment_check_fault);
setvect(18,(void (__cdecl &)(void))machine_check_abort);
setvect(19,(void (__cdecl &)(void))simd_fpu_fault);
//setvect(38,(void (__cdecl &)(void))i86_fdc_irq);
//<Snip>
//Keyboard driver
kkybrd_install(33);
kkybrd_set_leds(false,false,false);
LoadScreenUpdate();//This loops over and over (Prints out many |'s)
Code: Select all
void kkybrd_set_leds(bool num, bool caps, bool scroll){
uint8_t data = 0;
data=(scroll) ? (data | 1) : data;
data=(num) ? (data | 2) : data;
data=(caps) ? (data | 4) : data;
kybrd_enc_send_cmd(KYBRD_ENC_CMD_SET_LED);//To port 0x64
kybrd_enc_send_cmd(data);//Should be 0000(0)
}
void kkybrd_install(int irq){
setvect(irq,i86_kybrd_irq);
_kkybrd_bat_res=true;
_scancode=0;
_numlock=false;
_scrolllock=false;
_capslock=false;
_shift=false;
_alt=false;
_ctrl=false;
}
I'm pretty much stumped to what it could be. I have asked help from a couple of people and both of which couldn't figure it out much either. :/
Anyone got any ideas?
(Also, I just came back to the keyboard driver after working on other parts of the kernel for those of you that remember my last topic. )