Exception handling

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
pepito
Posts: 23
Joined: Thu Oct 21, 2004 11:00 pm
Location: México D.F.

Exception handling

Post by pepito »

I want to include an exception handler into my OS. So far I have included an ISR for each exception interrupt that just display a message, like this:

[MISIS: Error de division entre cero]

But when an error happen the ISR is called again and again infinitely. Then I get some like this:

[MISIS: Error de division entre cero]
[MISIS: Error de division entre cero]
[MISIS: Error de division entre cero]
[MISIS: Error de division entre cero]
[MISIS: Error de division entre cero]
[MISIS: Error de division entre cero]
...

What am I doing wrong?
What an ISR for an error/exception must do?

Any information about "how error/exception handle must be designed" will be appreciated.

Sorry my poor english,
Pepito :)
bregma
Member
Member
Posts: 25
Joined: Tue Oct 26, 2004 11:00 pm
Location: the back woods
Contact:

Re: Exception handling

Post by bregma »

pepito wrote:But when an error happen the ISR is called again and again infinitely.
It's possible that the exception is not being called infinitely.

When standard Intel-style systems are first started, interrupts are mapped into the same vectors as exceptions. What you may be seeing is the timer interrupt coming through.

From the looks of it, that's exactly what's happening, since the system timer defaults to IRQ 0 (which is the divide-by-zero exception).

You probably want to look into remapping your interrupts. Google for PIC or APIC.
Last edited by bregma on Thu Nov 25, 2004 12:00 am, edited 1 time in total.
[AlAdDiN]
Member
Member
Posts: 107
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Exception handling

Post by [AlAdDiN] »

IMHO : it s normal if ur exception handler looks like this

Code: Select all

void Handle_Exc_01()
{
printk("[MISIS: Error de division entre cero]\n");
}
becose this code return back to ur kernel after printing the message, but the exception is not resolved so it will be raised again and again ....


u must add a while(true); at the end of all unresolved exceptions' handlers

to be able to return back to the kernel without having the same exception to be rised u must correct the problem that caused thi exception first
so u have to read intel manual 3 section ("interrupt and exception handling").
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
dembol
Posts: 5
Joined: Wed Nov 24, 2004 12:00 am
Location: Gdynia, Poland
Contact:

Re: Exception handling

Post by dembol »

If your task really generated a divide error exception, you should kill this task because #DE is a fault (not a trap). Divide fault saves contents of CS and EIP registers which points to the instruction that generated the exception. I think that your interrupt procedure return to the instruction that generated exception and this instruction is called infinitely.
Post Reply