Reserved exceptions and/or interrupts

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.
Post Reply
ManOfSteel

Reserved exceptions and/or interrupts

Post by ManOfSteel »

Hello,
What are the reserved exceptions and/or interrupts (number 15, 17, ..., 32)? Do I have to put something there or I just can leave them empty?
Thanks for any help.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Reserved exceptions and/or interrupts

Post by Brendan »

Hi,

You can do what-ever you like with the reserved exceptions. I normally treat them the same as other exceptions, so if one is generated the user gets an "Unknown exception #??" critical error (just in case future CPUs use them).

Also, exception 17 is "Alignment Check Exception (#AC)".


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
ManOfSteel

Re:Reserved exceptions and/or interrupts

Post by ManOfSteel »

Hello, and thank you for your help.
I still have a question about the format of the exception handler.
Would it be like this?! 'cause I had some trouble: when I tried to print the name of the exception using my default protected mode print routine, it printed a weird message and/or crashed Bochs.

Code: Select all

DivByZeroEx:
    pusha

;    mov word [0B8000h],'e '
;instead of the above I call my print routine

    mov al,20h
    out 20h,al
    popa
    jmp $
    iret
ManOfSteel

Re:Reserved exceptions and/or interrupts

Post by ManOfSteel »

Hello,
I found what was the problem (bad memory address) but I still want to know some things about the format of the handler.
Are "pusha" and "popa" necessary? Do I have to put the EOI code (mov al,20h / out 20h,al)? Since a lot of exceptions can't be undone, do I have to include the "iret" instruction?
Thanks.
JFF

Re:Reserved exceptions and/or interrupts

Post by JFF »

As far as I know... you don't need the EOI code with exceptions. I never. If i remember correctly EOI means End Of Interrupt... and this is a code sent to the PIC to tell it that the interrupt has been handled so it can trigger the next interrupt. My handler looks like this :

Code: Select all

DivideError:
   push %ds
   push %es
   push %fs
   push %gs
   pusha
   pushl $0x0
   call exceptions
   popl %eax
   popa
   pop %gs
   pop %fs
   pop %es
   pop %ds
   iret
This pushes wich interrupts it is then call a c procedure to displays the error and panic (halt the cpu ans show registers and stack).

Code: Select all

   pushl $0x0
   call exceptions
   popl %eax
When I handle an Interrupt I send the EOI, because without this no other interrupt will be triggered and since the architecture is interrupt driven... interrupts that will be handled once are not going to make things work properlly.
Dreamsmith

Re:Reserved exceptions and/or interrupts

Post by Dreamsmith »

ManOfSteel wrote:Are "pusha" and "popa" necessary?
Only if you intend to return to the application. Since you don't know what the problem is and how to fix it, you're probably just going to kill the process that caused it, in which case, no, you don't really need to preserve any of its registers.
ManOfSteel wrote:Do I have to put the EOI code (mov al,20h / out 20h,al)?
Absolutely not. That goes for any processor exception. You ONLY use that code when dealing with interrupts from the PIC.
ManOfSteel wrote:Since a lot of exceptions can't be undone, do I have to include the "iret" instruction?
Since you don't know how to deal with an exception that was reserved at the time you wrote your code, returning would be a bad idea. So, no, don't iret.
Post Reply