Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hi all,
I wrote my ISR for int 0x80 in KERNEL and hooked the ISR into the IDT using the interrupt gate desc.I also have one TSS and its descriptor just to hold SS0 & ESP0 info.After all these when I use 'int 0x80' from user mode code my ISR is not getting invoked
When you set up the entry in your IDT, have you set its DPL3? If you are running user code in ring 3 you will need to do this to allow your user code to call the interrupt.
Do you get any kind of processor fault when this happens? If the above is correct, you should get a GPF.
If your GPF handler is not being invoked, it seems to me that you have either a bad kernel-mode stack, bad paging, or incorrectly loaded segment registers.
One thing I have found useful in this situation is Bochs. In the Bochs source file, try setting the line which is similar to:
When you get the triple fault and the CPU resets, Bochs will halt, displaying current register information. Often, it also displays a helpful comment above this, such as 'SS RPL != DPL', or something similar.
No, that should be no problem, but your user mode code needs access to them.
Maybe you should tell us what works in user mode and what not. What happens if you do a simple loop ( eb fe ) in user mode or if you produce a division by zero ?
Inside the USER MODE code loops and other normal functions works.Exceptions generated by div by zero,INT instructions are not passing the control to ISRs.When ever these things happens it simply reboots.
I have filled TSS with esp0,ss0 and did ltr during init itself.
1. Your IDT isn't available for some reason. If you have paging enabled, have you used a physical or virtual address in your LIDT instruction? Do you get the same behaviour when you enable interrupts?
2. Your IDT is incorrectly formatted. Check the structure you're using is correct. Is the present bit set?
3. The address of your ISR in the IDT is wrong. Have you used physical addresses rather than virtual? Is CS wrong?
4. Your ISR is unavailable. Is it inside the limits of your code segment? Are its pages available and marked as present? If it's in a different code segment, is its descriptor marked as present?
5. Your ISR does something that immediately causes an unhandled exception.
*My IDT & ISRs are working fine when I am in KERNEL MODE.I use physical address in LIDT.
Yes! when I enable interrupts in user mode I get same behaviour.
*All the present bits are set to one.
*My ISR does nothing except SAVE_ALL & RESTORE_ALL register functions.
*My CallGate from user mode to kernel mode is working fine.
Well, you say that lot's of your user space code works, even call gates to kernel mode. So I guess you're able to print something to the screen from usermode ? You could print the values of your idt entry and check whether they are correct ( even if you need to adjust the flags of that page you should do that )