Triple fault in boot, Brokenthorn tutorials
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Triple fault in boot, Brokenthorn tutorials
I'm using parts of the Brokenthorn OSDev tutorials to write my own kernel in assembly. My OS starts to boot, but will crash after my "Loading kernel sectors....................." message with a triple fault. It happens in both Virtual PC and Bochs. Halp!
I've attached the .zip. Assemble k_main.asm and boot.asm with NASM. The bootloader expects the assembled k_main.asm to be called tboskrnl.sys.
I've attached the .zip. Assemble k_main.asm and boot.asm with NASM. The bootloader expects the assembled k_main.asm to be called tboskrnl.sys.
- Attachments
-
- os.zip
- The troublesome OS...
- (6.16 KiB) Downloaded 83 times
Re: Triple fault in boot, Brokenthorn tutorials
Add org 0x500 to the top of your k_main.asm file. This is where the bootloader loads your kernel image to.
Running it through Bochs, it seems its getting to your kernel just fine. Adding the above fixed it for me. (Although it did triple fault afterwords inside of your kernel...thats a different problem though)
If you are still unable to get it to work, can you please post the command line you use to assemble your kernel?
Running it through Bochs, it seems its getting to your kernel just fine. Adding the above fixed it for me. (Although it did triple fault afterwords inside of your kernel...thats a different problem though)
If you are still unable to get it to work, can you please post the command line you use to assemble your kernel?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Triple fault in boot, Brokenthorn tutorials
Hehe, thanks neon. I'm a bit of an idiot.
It triple faults somewhere after the kernel starts, but before the LoadingMsg is printed. That's still in real mode though...
I use nasm -o tboskrnl.sys k_main.asm to assemble it with the latest version of NASM. I grabbed some of the code from the tutorial "Preparing for the kernel Part 1", just so you know.
It triple faults somewhere after the kernel starts, but before the LoadingMsg is printed. That's still in real mode though...
I use nasm -o tboskrnl.sys k_main.asm to assemble it with the latest version of NASM. I grabbed some of the code from the tutorial "Preparing for the kernel Part 1", just so you know.
Re: Triple fault in boot, Brokenthorn tutorials
Try this:
Replace "main" with this:
...
It's triplefaulting in rmode? I think the DS was set incorrectly, maybe that was the culprit why the loadingmsg didnt print.
BTW I think you'll not succeed in "read_kbd", since you don't have a valid IDT... Maybe that is the culprit, too.
//EDIT: I've debugged your code, it seems to triplefault after the mov cr0,eax and jmp far. Disassembled code shows "selector 8 > GDT size limit".vGDT may be bad, but I think the A20 switching code is too small...
You're right, it doesnt display the msg after all... bootloader problem?
Replace "main" with this:
...
Code: Select all
main:
mov ax,cs ; AX = your code segment
mov ds,ax ;make ds equal
mov es,ax ;same for ES
xor ax,ax ;AX = 0000
mov ss,ax ;SS = 0
mov sp,7C00h ;SS:SP = 0:7C00, should be enough for the pmode switch
BTW I think you'll not succeed in "read_kbd", since you don't have a valid IDT... Maybe that is the culprit, too.
//EDIT: I've debugged your code, it seems to triplefault after the mov cr0,eax and jmp far. Disassembled code shows "selector 8 > GDT size limit".vGDT may be bad, but I think the A20 switching code is too small...
You're right, it doesnt display the msg after all... bootloader problem?
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English )
Derrick operating system: http://derrick.xf.cz (Slovak and English )
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Triple fault in boot, Brokenthorn tutorials
I did some looking around, and different sites have different GDT values. I'd like to see some of your values and test them out.
Re: Triple fault in boot, Brokenthorn tutorials
Commenting the call to read_kbd seems to fix it for me...Worked fine in both Bochs and Virtual PC.
I am thinking inflater is right. If any interrupt is triggered in protected mode it will surely triple fault without a valid IDT. I would recommend creating a new IDT and remapping the PIC before attempting to develop the keyboard driver.
Also, your GDT is fine
With regards to your A20 code, Bochs enables A20 by default so if you run into problems with other systems you may need to use another more portable method.
I am thinking inflater is right. If any interrupt is triggered in protected mode it will surely triple fault without a valid IDT. I would recommend creating a new IDT and remapping the PIC before attempting to develop the keyboard driver.
Also, your GDT is fine
With regards to your A20 code, Bochs enables A20 by default so if you run into problems with other systems you may need to use another more portable method.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Triple fault in boot, Brokenthorn tutorials
I'm only using I/O ports for the keyboard driver, so how does that affect anything?
Also, tried that, still dies somewhere.
Also, tried that, still dies somewhere.
Re: Triple fault in boot, Brokenthorn tutorials
Ah, your right. I think I found a problem though... You are mixing 16 bit and 32 bit code.
Move %include "k_studio.h" and your msg_name_ver varable inside of a 32 bit code section. ie:
Try this, in addition to the org 0x500 posted earlier.
Move %include "k_studio.h" and your msg_name_ver varable inside of a 32 bit code section. ie:
Code: Select all
bits 32
%include "k_stdio.asm"
msg_name_ver db "TBOS version 0.2.1", 0x0D, 0x0A, 0
kernel:
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: Triple fault in boot, Brokenthorn tutorials
Woohooo! Works now! I did a little once-over of the stdio routines to make some more checks, and I noticed that you used LF and not CRLF as a newline. Very *n?x of you.
EDIT: Contrary to what was said about my read_kbd routine, it's stable with no alterations! The only thing is I need to advance the cursor when the letter is typed out!
EDIT: Contrary to what was said about my read_kbd routine, it's stable with no alterations! The only thing is I need to advance the cursor when the letter is typed out!