Enable intterupts once in pmode

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
Lprogster
Member
Member
Posts: 174
Joined: Tue Nov 14, 2006 11:59 am

Enable intterupts once in pmode

Post by Lprogster »

...

Thanks all,
Lprogster
Last edited by Lprogster on Tue Oct 23, 2007 11:31 am, edited 1 time in total.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

A few things that have caused this before in my OS:

* Have you definitely got a valid IDT?
* If in PMode is your GDT valid?


Is it possible (using Bochs or similar) to see what the register state is when the CPU triple-faults (ie, which exception number is actually causing the first exception?).

HTH
Lprogster
Member
Member
Posts: 174
Joined: Tue Nov 14, 2006 11:59 am

Post by Lprogster »

I am not using Bochs. Ill post the source code, would that help?

NOTE: This is probably poorly written/ unsafe!

Code: Select all

;{EDIT}
Thanks,
Lprogster
Last edited by Lprogster on Wed Nov 15, 2006 8:26 am, edited 1 time in total.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

I haven't had time to read this in detail, but does the CPU also reset if you change:

Code: Select all

jmp 08h:01000h
to

Code: Select all

jmp $
This will at least let you know if the area you are jumping to is causing the problem.

Sorry if I have missed something obvious but I am doing this in between other work! I am also fairly new to OS dev myself...

Adam
Lprogster
Member
Member
Posts: 174
Joined: Tue Nov 14, 2006 11:59 am

Post by Lprogster »

When that line is changed my OS still restarts but displays nothing on the screen first.

Thanks,
Lprogster
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Enable intterupts once in pmode

Post by Brendan »

Hi,
Lprogster wrote:How should I enable interrupts?
For protected mode, you must tell the CPU where to find a "32 bit compatible" IDT, then you need to either mask all IRQs or provide 32-bit protected mode IRQ handlers for anything that isn't masked.

You're doing none of this, so the first time an IRQ is received the CPU thinks there's a valid 32-bit protected mode IDT where the old (real mode only) IVT is at 0x00000000. In this case the CPU crashes trying to load the IDT entry for the IRQ (causing a double fault, then triple fault/CPU reset).


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.
Lprogster
Member
Member
Posts: 174
Joined: Tue Nov 14, 2006 11:59 am

Post by Lprogster »

How should I build an IDT?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

For my first test kernel, I used:

http://www.osdever.net/bkerndev/index.php?the_id=90

which seems to take you through each stage step-by-step. Sorry I didn't mention the protected mode IDT - as I said, I'm fairly new to all this myself.

Adam[/url]
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

get the intel manuals -- they will be a very big help, especially with the beginning where you are now

there is a link to the intel manuals in my signature, where you can download them, at the bottom of the page is a link to instructions on ordering hard-copies highly recommended, and completely free -- you need volume 3a most, but i recommend getting all 5 books

read very closely, volume 3, particularly chapters 2-5, and then you will probably want to reread them again before beginning to understand, but its very important -- the CPU is complicated, but important, and all your work is Dependant on that chip
Post Reply