OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:37 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Boot Media And Memory Confusion
PostPosted: Tue Dec 11, 2018 3:28 pm 
Offline
Member
Member
User avatar

Joined: Tue Dec 11, 2018 3:13 pm
Posts: 50
Hi, my apologies for this (potentially) noob question, but I am slightly confused about boot media/devices/drives and memory. I have looked over the Wiki, and this is exactly why I made this thread, because I couldn't find anything that answered my question.

My confusion is from all of the sources that I have read; all of which, say that 512 bytes are loaded into memory when the computer finds a boot-able disk/drive and boots from it. But since a DVD or optical media has 2 KB sectors, does the computer load 512 * 4 bytes into memory, or does it still only load 512 bytes into memory?

Thanks, and kind regards.


Top
 Profile  
 
 Post subject: Re: Boot Media And Memory Confusion
PostPosted: Tue Dec 11, 2018 3:34 pm 
Offline
Member
Member

Joined: Sat Sep 24, 2016 12:06 am
Posts: 90
Hi, BIOS loads all 2kb to memory, you can make a 2kb-bootloader, but signature at offset 510 must be a valid signature.
When BIOS gives control to your bootloader, in dl stored disk number, you can use it for int 13h.
Cheers,
Aleksandr


Top
 Profile  
 
 Post subject: Re: Boot Media And Memory Confusion
PostPosted: Tue Dec 11, 2018 5:40 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
Hi,

The (Legacy) BIOS will usually load a single sector. That doesn't mean that a sector is only 512 bytes. A sector is a sector. If that sector happens to be on a media device that has 2048-byte sectors, then it will load 2048 bytes. Same for 4096-byte sectors.

However, and this is a big however. It also depends on what the BIOS is doing. If the BIOS sees a Bootable CDROM and is in emulation mode, the emulation mode will determine if it has 512 bytes or 2048 bytes. For example, if the emulation is a 1.44Meg floppy, the BIOS might load 2048 bytes, but you can only assume that the first 512 are valid. You must treat the media device as a 1.44meg floppy and read any remaining 512-byte sectors that your boot code might need.

For example, if your boot code needs four (4) 512-byte sectors and you just booted from a CDROM that is using 1.44meg floppy emulation, even though the BIOS might have already loaded the 2048 bytes your code requires, you must call the BIOS to load three (3) more 512-byte sectors from the media, the second, third, and fourth (emulated) sectors. It is up to the BIOS whether it thinks it needs to read from the physical device or know that it has the 2048 bytes in memory and just reads from there. Your code must not assume so.

If the BIOS is in Hard Drive emulation (when booting from a CDROM), it might load a few more than one (512-byte) sector. The El Torito Specification states that the BIOS should read up to 256 sectors, depending on the value found in the boot catalog. (256 is from memory, i.e.: a single byte used for the count).

This same specification (go look it up) also allows you to specify which emulation you are using, the endian-ness of the information, etc.

Therefore, depending on whether your boot code is specific for the CDROM, and if so, what filesystem (ISO9660 or UDF), or if your code is generic and can easily be emulated as a hard drive image, will determine how many bytes are loaded for the first sector.

Ben
- http://www.fysnet.net/osdesign_book_series.htm


Top
 Profile  
 
 Post subject: Re: Boot Media And Memory Confusion
PostPosted: Tue Dec 11, 2018 8:45 pm 
Offline
Member
Member
User avatar

Joined: Tue Dec 11, 2018 3:13 pm
Posts: 50
Alright, I am starting to understand now. Thanks a lot, both of you. That confusion was causing me to not be able to move on with my multi-stage boot loader.


Top
 Profile  
 
 Post subject: Re: Boot Media And Memory Confusion
PostPosted: Wed Dec 12, 2018 6:49 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
Hi,

BenLunt's answer is absolutely correct, although I'd like to point out the importance of boot catalog. On floppies and harddisks the BIOS always loads the very FIRST sector. On CDROM in no emulation mode, it's consulting the boot catalog to figure out which sector to load, which is probably not the first sector (but could be). The boot catalog may contain pointers to several boot sectors for different architectures and firmware, because CDROM images were designed to be bootable on multiple machines. Also note that many BIOSes are buggy, and they are only capable of reading the first entry in the catalog (I had problems with mixing EFI-x86 and BIOS-x86 entries on real machines, in my case the solution was to put BIOS-x86 in the first entry, and EFI-x86 in the second).

Cheers,
bzt


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: nullpointer and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group