Exception Handler

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
origin of

Exception Handler

Post by origin of »

Hi, how can i write my own exception handler ??
I preput that in my bootloader i create a GDT...
now i have a kernel, with my own cout....and now i want to implement a Exception handler before continuing to write my kernel...

sorry for my english ;D
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re:Exception Handler

Post by Combuster »

Basically, all you need to do is:
- create and IDT
- point it to your handler function (ints 0-31)
- make sure your exception handler pops any error code
- write the rest of the handler
- have it return (if the thread is not being terminated) using IRET
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
origin of

Re:Exception Handler

Post by origin of »

i found this http://www.eastcoastgames.com/articles/cppexception.html, the article doesn't say anything about IDT, pointer and IRET....
is another thing ?
Kemp

Re:Exception Handler

Post by Kemp »

Yup, C++ exceptions are different to machine exceptions. The first deal with the C++ code messing up, are usually entirely a software construction, and handle the exception within the program code (unless it's not caught), while the latter deal with things like protection faults and suchlike and usually involve a hardware mechanism and are usually handled by the OS.
origin of

Re:Exception Handler

Post by origin of »

ok....i make the IDT, and now how can i make handler ?
any guide ?

i also read the third manual, chapter 5 (intel manual)...
Kemp

Re:Exception Handler

Post by Kemp »

Check out the OSFAQ (click the banner at the top of any forum page) for more info, including info on the various different ways to do it and why they should be avoided ;)
Post Reply