Page 1 of 1
pmode Triple Fault
Posted: Sat Oct 18, 2014 5:02 pm
by gudenau
So, I have started to work on a little OS. I attempted to get into pmode but it seems to create a triple fault in Virtual Box and my laptop. I have attached the source and it appears that it happens around line 7 in loader/pmode.asm
Any help would be appreciated, as I am missing somthing here.
Edit:
Source
Re: pmode Triple Fault
Posted: Sat Oct 18, 2014 6:15 pm
by b.zaar
gudenau wrote:
Any help would be appreciated, as I am missing somthing here.
The attachment...
Re: pmode Triple Fault
Posted: Sat Oct 18, 2014 6:19 pm
by gudenau
b.zaar wrote:gudenau wrote:
Any help would be appreciated, as I am missing somthing here.
The attachment...
Where did that go?
Source
Re: pmode Triple Fault
Posted: Sun Oct 19, 2014 11:07 pm
by thepowersgang
Here's a hint - Nobody here (well... none of the expirenced members, unless they're really bored) will just download and open an archive.
You think you've discovered the offending line, why do you think that? Is it a guess, or have you checked the manuals but don't know how to solve the failure?
Have you run in bochs and checked what its log says? (And actually read that log, if you don't understand what the message means then search the bochs source, some of the messages are a little cryptic)
Re: pmode Triple Fault
Posted: Mon Oct 20, 2014 11:24 am
by gudenau
thepowersgang wrote:Here's a hint - Nobody here (well... none of the expirenced members, unless they're really bored) will just download and open an archive.
You think you've discovered the offending line, why do you think that? Is it a guess, or have you checked the manuals but don't know how to solve the failure?
Have you run in bochs and checked what its log says? (And actually read that log, if you don't understand what the message means then search the bochs source, some of the messages are a little cryptic)
It crashes around here:
Code: Select all
xor ah, ah
int 0x16
cli
lgdt [pmode_toc]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp dword 08h:pmode_entry
bits 32
pmode_entry:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp $
GDT
Code: Select all
pmode_basicGDT:
; Null
dw 0x0000 ; Limit low
dw 0x0000 ; Base low
db 0x00 ; Base middle
db 0b00000000 ; Access
db 0b00000000 ; Granularity
db 0x00 ; Base high
; Code
dw 0xFFFF ; Limit low
dw 0x0000 ; Base low
db 0x00 ; Base middle
db 0b10011010 ; Access
db 0b11001111 ; Granularity
db 0x00 ; Base high
; Data
dw 0xFFFF ; Limit low
dw 0x0000 ; Base low
db 0x00 ; Base middle
db 0b10010010 ; Access
db 0b11001111 ; Granularity
db 0x00 ; Base high
pmode_GDTSize equ $ - pmode_basicGDT
pmode_toc:
dw pmode_GDTSize - 1
dd pmode_basicGDT
I will also look into Bochs.
Re: pmode Triple Fault
Posted: Mon Oct 20, 2014 12:01 pm
by Combuster
I took a quick look at the code, and it appears you're making the common mistake of mixing up virtual and linear addresses.
In other words, you're using garbage for the GDT.
Re: pmode Triple Fault
Posted: Mon Oct 20, 2014 2:18 pm
by CelestialMechanic
Code: Select all
bits 32
pmode_entry:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp $
I see an awful lot of this these days. You should have "mov esp,
something"
immediately after the mov ss, ax. Where is your stack? Did you set up a proper IDT? Faults can occur and just one of them to a defective stack can add up to a triple fault
mucho prestissimo bingo.
Re: pmode Triple Fault
Posted: Mon Oct 20, 2014 4:26 pm
by gudenau
CelestialMechanic wrote:Code: Select all
bits 32
pmode_entry:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp $
I see an awful lot of this these days. You should have "mov esp,
something"
immediately after the mov ss, ax. Where is your stack? Did you set up a proper IDT? Faults can occur and just one of them to a defective stack can add up to a triple fault
mucho prestissimo bingo.
I thought that you only needed an IDT if interrupts were enabled, so I was going to do that next.
Edit:
Apparently my segment stuff was not correct, yay.
Re: pmode Triple Fault
Posted: Tue Oct 21, 2014 3:49 pm
by jrhetf4xb
gudenau wrote:
Edit:
Apparently my segment stuff was not correct, yay.
Could you point out what you did to fix it?
Re: pmode Triple Fault
Posted: Wed Oct 22, 2014 12:12 am
by iansjack
gudenau wrote:
I thought that you only needed an IDT if interrupts were enabled, so I was going to do that next.
As well as interrupts, the IDT points to handlers for exceptions. Exceptions happen whether interrupts are enabled or not. This means that if you have no exception handlers (and an IDT to point to them) any error in your code leads to an instant triple fault. This makes debugging more difficult. It is useful to know where an error occurs, what sort of error it is, and further information that the exception provides in an error code; for example, your exception handler could print these to the screen and then halt the processor.
When your OS is more refined the exception handlers will actually take steps to allow for common exceptions and keep the system running (in particular, page faults are not always errors).
So, although not absolutely essential, not having exception handlers is like working with both hands tied behind your back.