Page 1 of 1

Booting a basic OS

Posted: Sat Feb 07, 2009 12:23 pm
by gsingh2011
I'm using the exact code from http://wiki.osdev.org/Bare_Bones. I made the floppy.img file and now I'm trying to boot it. I tried Bochs, but when I ran it, the boot screen kept repeating over and over. Then I tried QEMU for windows, and I couldn't figure out how to boot it from there. Then I tried Virtual Box, and that gave me an unhandled win32 exception and asked me to debug.

What's wrong?

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 12:34 pm
by neon
Hello,

In your bochs configuation file, add the following line:

Code: Select all

log:         os.log
Run it again using Bochs and it should output a log file, os.log. Post the last few lines of that log (registers, any errors or PANICs here.)

I personally suspect either GRUB is not installed correctly or the floppy disk image is not being correctly copied over. I cannot troubleshoot further however until I see the log.

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 1:27 pm
by gsingh2011
Sorry, I really didn't know which information you needed, so I just uploaded the whole file so you can see what you need.

os.log

Thanks for the help.

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 2:01 pm
by neon
Here is the important info from the log:

Code: Select all

00008023335i[BIOS ] Booting from 0000:7c00
00008334848i[FDD  ] partial read() on floppy image returns 374/512
00008357581i[FDD  ] read() on floppy image returns 0

...

00025568511i[FDD  ] read() on floppy image returns 0
00025591244i[FDD  ] read() on floppy image returns 0
00025625159i[FDD  ] read() on floppy image returns 0
00025651077e[CPU0 ] check_cs(0x0008): attempt to jump to long mode without enabling EFER.LMA !
00025651077e[CPU0 ] check_cs(0x0008): conforming code seg descriptor dpl > cpl, dpl=3, cpl=0
00025651077i[CPU0 ] CPU is in protected mode (active)
00025651077i[CPU0 ] CS.d_b = 16 bit
00025651077i[CPU0 ] SS.d_b = 16 bit
00025651077i[CPU0 ] EFER   = 0x00000000
00025651077i[CPU0 ] | RAX=0000000060000011  RBX=0000000000000001
00025651077i[CPU0 ] | RCX=0000000000000501  RDX=0000000000000000
00025651077i[CPU0 ] | RSP=0000000000001fec  RBP=0000000000001ff0
00025651077i[CPU0 ] | RSI=00000000ffff8116  RDI=00000000000881f0
00025651077i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00025651077i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00025651077i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00025651077i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00025651077i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00025651077i[CPU0 ] | SEG selector     base    limit G D
00025651077i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00025651077i[CPU0 ] |  CS:0000( 0004| 0|  0) 00000000 0000ffff 0 0
00025651077i[CPU0 ] |  DS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00025651077i[CPU0 ] |  SS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00025651077i[CPU0 ] |  ES:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00025651077i[CPU0 ] |  FS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00025651077i[CPU0 ] |  GS:0000( 0005| 0|  0) 00000000 0000ffff 0 0
00025651077i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00025651077i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00025651077i[CPU0 ] | RIP=0000000000008789 (0000000000008789)
00025651077i[CPU0 ] | CR0=0x60000011 CR1=0x0 CR2=0x0000000000000000
00025651077i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00025651077i[CPU0 ] >> jmp far 0008:00008791 : 66EA918700000800
00025651077e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 8:54 pm
by gsingh2011
Yea... I have no clue what that means. It's my first time doing this...

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 10:07 pm
by neon
gsingh2011 wrote:Yea... I have no clue what that means. It's my first time doing this...
How much experience do you have with assembly language? If you know it (at least the basics) most of the log should be fairly easy to understand.

However I do not have much experience with GRUB so cannot assist you in setting it up. Perhaps another member here can help you with that.

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 10:12 pm
by gsingh2011
I do not have a very good understanding at assembly, although I attempted learning once. Thank you for all your help so far neon! Can anyone else identify the problem?

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 10:15 pm
by neon
I suspect that it is failing inside of GRUB. I know it is booting into the boot loader (based upon that eip is not inside of the bios and above 0x7c00). Perhaps GRUB is not configured correctly? Or the floppy image is not built correctly?

Re: Booting a basic OS

Posted: Sat Feb 07, 2009 10:49 pm
by AndrewAPrice

Code: Select all

00025651077i[CPU0 ] >> jmp far 0008:00008791 : 66EA918700000800
Is the hint (it's a disassembly of the instruction that caused the fault that caused the double fault that caused the triple fault). You're trying to far jump to a bad segment. Check your linker script to make sure your program starts at 1MB.

Re: Booting a basic OS

Posted: Sun Feb 08, 2009 10:13 am
by Combuster
Also
00025625159i[FDD ] read() on floppy image returns 0
Bochs is complaining to you about your floppy image being broken (it should be exactly 1.44Mb in size!)

Re: Booting a basic OS

Posted: Sun Feb 08, 2009 10:24 am
by Love4Boobies
gsingh2011 wrote:Then I tried QEMU for windows, and I couldn't figure out how to boot it from there.
Look for bios.bin. It should either be in the sub-directory pc-bios, or in the main directory, depending on where you got the package from (as I'm assuming you haven't compiled it yourself). Then, try the following command:

Code: Select all

qemu -fda floppy.img -boot a -L pc-bios
Replace pc-bios with the path to bios.bin. If it's in the current directory, write "-L ." instead.