Page 1 of 1
Exception halts the system.
Posted: Thu Apr 16, 2009 7:47 pm
by abhishekmaharana
Hello and sorry for yet another newbie question.
In my timer driver(protected mode kernel) using inline assembly in gcc, I get an exception and the system halts.
ACTUALLY I was trying to read the number of ticks from the BIOS but got an exception. my code is given below-
Code: Select all
__asm__ __volatile__ ("movl $0 5eax;");
__asm__ __volatile__ ("int $31;");//31 is for 1Ah
putint(r->eax);//r=struct regs pointer variable
without this bit of code,the system is running smoothly.
Can you please point out what is going wrong?
Thanks and regards.
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 8:22 pm
by neon
You cant use bios interrupts in protected mode. There are methods around this (like v86 mode or switching between real and protected modes) though if you need to use the bios.
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 8:24 pm
by Troy Martin
You could always write a timer interrupt and set up the PIC.
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 8:32 pm
by Zenith
You're in protected mode, so the BIOS functions... do not function
. Especially if you've moved the IDT to a different place.
The reason you're causing an exception is because you're calling one directly! Interrupt 31 is classified as a reserved exception (in protected and long mode) by Intel, and if you call it, then it'll occur, and an emulator would report it as an exception
. There'd probably be no code to handle it, leading to a triple fault, and crashing the computer.
Here's an article on using the Real Time Clock (if you want to get the date and time), and
here's an article on using the Programmable Interval Timer (PIT) to generate an interrupt at set time intervals.
Good luck
EDIT: Damn, I'm slow at replying. TroyMartin, don't be too hard on him. From his previous posts, he seems like a welcome change to the regular how-2-rite-os!? n00bs that we usually have. How many of us were actually aware of the functionality of 16-bit real mode and programming the PIT before we started OSDev?
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 8:34 pm
by Troy Martin
Boredom hit the better of me.
ahhh god I'm gonna hear from James about this in the morning...
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 8:49 pm
by neon
Zenith wrote:How many of us were actually aware of the functionality of 16-bit real mode and programming the PIT before we started OSDev?
Im sure alot of members here... *ahem* (Except the PIT for me..)
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 8:59 pm
by 01000101
I've decided not to lock this thread (yet) as it would be both unfair to the OP to not get a chance to reply and unfair in that this could potentially be a good learning experience for a starter. Let's not be to harsh just yet, it's better to deal with a little bit of foolishness and help him/her out than to be overly-harsh and make a fool of yourself.
keep in mind: OSDev.org - The Place to
Start for Operating System Developers
@OP:
PIT information and
a few starter tutorials, get readin'!
Re: Exception halts the system.
Posted: Thu Apr 16, 2009 9:24 pm
by Troy Martin
I learned real mode and stuffs through indirect OSDev. I meddled around with MikeOS to learn the basics and then learned more assembly and OSDev.
Re: Exception halts the system.
Posted: Fri Apr 17, 2009 7:09 am
by abhishekmaharana
Thank you everybody.I didn't know that we can't call BIOS routines in protected mode.
And thanks for being considerate enough to entertain a newbie.
Thank you Zenith for those two links.
Re: Exception halts the system.
Posted: Fri Apr 17, 2009 8:06 am
by JamesM
Troy Martin wrote:Boredom hit the better of me.
ahhh god I'm gonna hear from James about this in the morning...
No, you're not, because you edited your post too quickly
Re: Exception halts the system.
Posted: Fri Apr 17, 2009 8:48 am
by Troy Martin
*whew*
Newbie latency and spark-o-the-moment thought triumph again!