pmode Triple Fault
pmode Triple Fault
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
Any help would be appreciated, as I am missing somthing here.
Edit:
Source
Last edited by gudenau on Sat Oct 18, 2014 6:20 pm, edited 1 time in total.
Re: pmode Triple Fault
The attachment...gudenau wrote: Any help would be appreciated, as I am missing somthing here.
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Re: pmode Triple Fault
Where did that go?b.zaar wrote:The attachment...gudenau wrote: Any help would be appreciated, as I am missing somthing here.
Source
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: pmode Triple Fault
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)
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)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: pmode Triple Fault
It crashes around here: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)
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 $
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
- Combuster
- 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: pmode Triple Fault
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.
In other words, you're using garbage for the GDT.
-
- Member
- Posts: 52
- Joined: Mon Oct 11, 2010 11:37 pm
- Location: Milwaukee, Wisconsin
Re: pmode Triple Fault
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 $
Microsoft is over if you want it.
Re: pmode Triple Fault
I thought that you only needed an IDT if interrupts were enabled, so I was going to do that next.CelestialMechanic wrote: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.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 $
Edit:
Apparently my segment stuff was not correct, yay.
Re: pmode Triple Fault
Could you point out what you did to fix it?gudenau wrote: Edit:
Apparently my segment stuff was not correct, yay.
Practice makes perfect.
Re: pmode Triple Fault
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.gudenau wrote: I thought that you only needed an IDT if interrupts were enabled, so I was going to do that next.
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.