This is a code I wrote to test my kb interrupt handler
I invoked the kb interrupt handler by software , not by IRQs so that IDT problems are discarded
( as mega-tokyo FAQs recommend ) :
//interrupts.c
asm volatile ( "jmp KB_IRQ1_Handler_Wrapper" ) ;
BOCHSHALT ;// This is a c macro written by Brendan to breakpoint into c code
??? //, at any rate it stops execution here.
;int_wrappers.asm
GLOBAL _KB_IRQ1_Handler_Wrapper
EXTERN KB_IRQ1_Handler
ALIGN 4
KB_IRQ1_Handler_Wrapper :
pushad
call KB_IRQ1_Handler
popad
???;after debugging using bochs I found that
???;if you put "hlt" here then no exceptions occur , but
???;if you continue then exception will be raised .
iret
interrupt handler problem which doesn't relate to hardware
Re:interrupt handler problem which doesn't relate to hardwar
IRET will pop the eflags off the stack as well as the return descriptor/address. Since you've just jumped directly to the routine eflags was never pushed onto the stack, so you're popping junk into eflags. At this point the processor is likely to keel over and die. For testing purposes either replace IRET with RET, put the EFLAGS register on the stack manually, or call using a software interrupt (Assuming you've got your IDT setup).
Re:interrupt handler problem which doesn't relate to hardwar
thank you , I've put ret instead of iret & call instead of jmp , so the test succeeded .
???
???In real world , as you know I have to put iret , and when pressing any key , the handler should be called
???however , bochs reported the following error :
???[CPU ] exception(): 3rd (13) exception with no resolution
???
???In real world , as you know I have to put iret , and when pressing any key , the handler should be called
???however , bochs reported the following error :
???[CPU ] exception(): 3rd (13) exception with no resolution
Re:interrupt handler problem which doesn't relate to hardwar
Another thing to say :
When I tested the os by booting my pc using it ( not using bochs ..) , it booted successfully , but rebooted when press any key
When I tested the os by booting my pc using it ( not using bochs ..) , it booted successfully , but rebooted when press any key
Re:interrupt handler problem which doesn't relate to hardwar
bochs said the CPU triple faulted. Normally a computer would reboot.
The CPU rebooted, and thus triple faulted...
The CPU rebooted, and thus triple faulted...
Re:interrupt handler problem which doesn't relate to hardwar
thanks guys , I've put call instaed of jmp and ret instead of iret , so the problem is solved .
i.e. I could call my handlers from software , but I couldn't call them by hardware ( IDT ) ..
however this is not the subject of this thread as the "Subject"
above says .
thanks a lot
i.e. I could call my handlers from software , but I couldn't call them by hardware ( IDT ) ..
however this is not the subject of this thread as the "Subject"
above says .
thanks a lot