The length of my bootsector

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
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

The length of my bootsector

Post by Isaac »

Hi. I'v seen the code of some open source bootsector which is written for ISO 9660. I noticed that the bootsector is 2048 bytes instead of 512. I also noticed that it doesn't have aa55 at the end. I remember reading somewhere that ISO 9660 Bootsectors are different.

Anyway, I'm now trying to write my own ISO 9660 bootsector and it won't run. QEMU says it's not bootable and a real computer just does nothing. Why not?
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: The length of my bootsector

Post by xenos »

If I had to guess I would say because it is not bootable.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: The length of my bootsector

Post by Isaac »

Why isn't it bootable? I assembled it with NASM (if that detail is necessary).
User avatar
Minoto
Member
Member
Posts: 89
Joined: Thu May 12, 2011 7:24 pm

Re: The length of my bootsector

Post by Minoto »

Isaac wrote:I'm now trying to write my own ISO 9660 bootsector and it won't run. QEMU says it's not bootable and a real computer just does nothing. Why not?
You might find this document helpful.
Those who understand Unix are doomed to copy it, poorly.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: The length of my bootsector

Post by SpyderTL »

Ouch! :roll:

Make sure you have your CD blocks layed out correctly. You have to have an entire CD filesystem in place in order to boot from a CD. It doesn't just load the first block and execute it, like a floppy drive.

The following wiki page goes into detail on the bootable CD format.

El-Torito

If you still have problems, let us know.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: The length of my bootsector

Post by SpyderTL »

Just to speed things up, here are some data structures that you are going to need:

Primary Volume Descriptor
Boot Record Descriptor
Supplementary Volume Descriptor
Descriptor Terminator

Boot Descriptor
- Validation Entry
- Default Entry
- Terminator

This is the layout that I'm using, and it seems to work on both real and virtual hardware. Let us know if you have any questions.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: The length of my bootsector

Post by Isaac »

I created an image using genisoimage and burned it to a CD_RW. I then tried to boot this CD_RW on real hardware and it didn't work. Is there something I have to add to my bootsector file? Or is it just good enough to create an image in genisoimage? If so, why doesn't my bootsector work?
User avatar
Combuster
Member
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: The length of my bootsector

Post by Combuster »

For starters, a CD doesn't have a bootsector, which probably means that what you're trying is not going to work either.

Post your genisoimage command as well as the sizes of all the input files if you want to have a sanity check. You can also leech the correct instructions from the wiki.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: The length of my bootsector

Post by Isaac »

My genisoimage command:

Code: Select all

genisoimage -R -b bootsector -no-emul-boot -boot-load-size 2 -boot-info-table -o bootable.iso folder_containing_the_bootsector
I only included one file in my ISO image; my bootsector.
User avatar
JohnBurger
Posts: 7
Joined: Tue Mar 18, 2014 12:20 am
Location: Canberra, Australia

Re: The length of my bootsector

Post by JohnBurger »

Isaac,

As others have said, an ISO doesn't have a bootsector as such. It has a much more complicated environment - but I've already written some NASM code ( [wiki]JohnBurger:Demo/Overview#ISO[/wiki] ) to generate an ISO image at assemble time as part of a bigger Demo.

For your information, when a computer loads a CD at boot time, it actually loads sector #17, not sector #1 (and yes, that's 2,048 byte sectors). But it doesn't just blindly JMP to its first location, so there's no need for the AA55 signature. Instead, that sector is a data table to reference other sectors on the CD.

My code takes advantage of the 32kiB gap at the beginning of the CD to put my code there. It's smaller than 32kiB, so it fits neatly. If yours is larger, you'll need to make some changes...

The trick is that my code sets up the ISO into Floppy emulation mode, so it behaves as if the sectors are 512 bytes in size. The BIOS will read 2,048-byte sectors, but dole them out in 512 byte pieces. And yes, my emulated boot sector has AA55 at location 1FE
Post Reply