Don't know what to make of UEFI

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Don't know what to make of UEFI

Post by Antti »

turdus, I am afraid that you are wrong. Modern BIOSes are too smart and cause troubles for us. I have had boot problems because I was not aware of this.
Octocontrabass
Member
Member
Posts: 5501
Joined: Mon Mar 25, 2013 7:01 pm

Re: Don't know what to make of UEFI

Post by Octocontrabass »

turdus wrote:Where did you get such a nonsense?
From booting lots of test code on many computers using a few USB flash drives.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Don't know what to make of UEFI

Post by Brendan »

Hi,
turdus wrote:
Octocontrabass wrote:most BIOSes only allow AH=42h if the first sector is a "valid" MBR
Where did you get such a nonsense? Let's make this clear: AH=42h reads a sector from disk to memory, nothing more, nothing less.
Sadly, it's true.

What happened was that real floppy disks were never large enough to require "int 0x13 extensions", so most BIOSs never bothered supporting "int 0x13 extensions" for floppy disks. Also, hard disks weren't considered removable.

Then CD came along. Originally they weren't bootable at all. Eventually "El Torito" happened, where the media itself tells the BIOS if the CD should emulate a floppy (without "int 0x13 extensions") or emulate a hard disk (with "int 0x13 extensions, but where removable media is assumed to be a "non-removable device") or do no emulation at all (which requires software specifically designed to boot from CD).

Then USB came along. BIOS manufacturers weren't too sure if USB flash should emulate a floppy disk (because it's removable media) or emulate a hard disk (because it's larger than a floppy). A lot of BIOSs decided to support both possibilities - e.g. emulate a floppy (without "int 0x13 extensions" just like a real floppy) or emulate a "not expected to be removable" hard disk (with "int 0x13 extensions").

Some of these BIOSs had an option in their configuration screen to select between emulating floppy and emulating hard disk. Of course that was annoying for users. To fix that problem some BIOS manufacturers decided it'd be fun to auto-detect if the USB should emulate floppy or emulate hard disk. However, it's not like "El Toritio" where there's a sane way to determine what type of device the media should emulate, so they just used the awesome power of stupidity as an alternative.

Of course real floppy disk hardware sucks (no easy way to detect how media was formatted) so Microsoft invented the BPB as a work-around, and everyone expected a (formatted) floppy disk to have BPB. Nobody ever bothered partitioning floppy disks (they were too small). Therefore, for USB, for some BIOSs; if the USB flash has something that looks like a BPB and/or doesn't have something that looks like a partition table; then assume it should emulate a floppy disk (don't bother supporting "int 0x13 extensions" and do support device removal correctly).

Hard disks where mostly always partitioned (even if it's a single partition covering almost all sectors) and the MBR never really needed a BPB (MBR is not the first sector of a FAT partition). Therefore, for USB, for some BIOSs; if the USB has something that looks like a partition table and/or doesn't have something that looks like a BPB; then assume it should emulate a hard disk (do support "int 0x13 extensions", but don't bother supporting device removal correctly).

Over time, USB flash sizes grew and floppy became much less popular. Now it seems silly to emulate a floppy at all, and silly not to support "int 0x13 extensions". I wouldn't be surprised if almost all modern computers just assume USB should emulate a hard disk; but old computers still exist.

Mostly, I'd recommend making sure your bootable USB does not have anything that looks like a valid BPB and does have something that looks like a valid partition table, just in case someone wants to use it to boot an older computer. More specifically, with UEFI looming, I'd recommend not having a BPB and using a hybrid "MBR + GPT" partitioning scheme.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Don't know what to make of UEFI

Post by turdus »

@Antti: in the last about 10 years I have never found such BIOS. Including iMac and Macbook (booting in legacy mode with BootCamp). What's more, since Vista windows mbr uses AH=42 only, so it would mean you were unable to boot a mainstream OS on those BIOSes. Possible, but highly unlikely. If you had problems booting your code on those modern smart BIOSes, all I can say you weren't thorough. I had difficulties too, I give you that, but always managed to came around by reading the spec carefully, and always turned out to be my mistake that caused troubles. (As a matter of fact when I wrote my first mbr code about 20 years ago, I didn't had the spec at all, everything had to be reverse-engineered. Things were simplier back then.)

@Octocontrabass: Please show me one BIOS that "only allow AH=42h if the first sector is a "valid" MBR". Detecting if the first sector is bootable and loading any arbitrary sector into memory quite different things, don't mix them (although the former includes the latter).

@Brendan: as said to Antti, I've never saw BIOS that was capable of booting from USB and unable to use AH=42 with the same drive. Maybe my samples weren't representative (not sure about the time of removable/not-removable era). You may be right about old computers, but consider this:
1. those that don't support AH=42 and USB, most probably don't have a 64 bit CPU so they can't execute my kernel anyway.
2. creating an OS takes years at least (I'm not talking about copy'n'paste kiddies). If you start today, how many of those old machines will be there by the time you got something worthy to test? Maybe it's just me, but I try to focus on hardware that would be common in the foreseeable future, and not methuselahs. :wink:
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Don't know what to make of UEFI

Post by Antti »

turdus wrote:What's more, since Vista windows mbr uses AH=42 only, so it would mean you were unable to boot a mainstream OS on those BIOSes.
We can assume that the INT 13h "AH=42h" services are available. It does not change the fact that those services might be unavailable if the USB media is emulated as a floppy. Vista works because I do not think a real hard drive will be ever emulated as a floppy. There are two reasons: it usually is a "real" hard drive (not a USB stick) and it contains a valid partition table.
Octocontrabass
Member
Member
Posts: 5501
Joined: Mon Mar 25, 2013 7:01 pm

Re: Don't know what to make of UEFI

Post by Octocontrabass »

turdus wrote:@Octocontrabass: Please show me one BIOS that "only allow AH=42h if the first sector is a "valid" MBR".
The BIOS for my ASRock M3A770DE motherboard will only allow AH=42h if the USB flash drive has a valid partition table.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Don't know what to make of UEFI

Post by turdus »

Octocontrabass wrote:
turdus wrote:@Octocontrabass: Please show me one BIOS that "only allow AH=42h if the first sector is a "valid" MBR".
The BIOS for my ASRock M3A770DE motherboard will only allow AH=42h if the USB flash drive has a valid partition table.
You have found a really buggy BIOS. Congrats. How does it change the BIOS Boot Specification?
Octocontrabass
Member
Member
Posts: 5501
Joined: Mon Mar 25, 2013 7:01 pm

Re: Don't know what to make of UEFI

Post by Octocontrabass »

turdus wrote:You have found a really buggy BIOS. Congrats.
Really? There must be a lot of buggy BIOSes out there, because most of the computers I tried behave exactly the same way.
turdus wrote:How does it change the BIOS Boot Specification?
What do you mean? This behavior does not contradict the BIOS boot specification.
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Don't know what to make of UEFI

Post by FallenAvatar »

turdus wrote:
Octocontrabass wrote:
turdus wrote:@Octocontrabass: Please show me one BIOS that "only allow AH=42h if the first sector is a "valid" MBR".
The BIOS for my ASRock M3A770DE motherboard will only allow AH=42h if the USB flash drive has a valid partition table.
You have found a really buggy BIOS. Congrats. How does it change the BIOS Boot Specification?
I have seen links to BIOS Boot specs in the past, but I can not seem to find any of them atm. Since you are refering to it directly, do you have a link to it?

- Monk
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Don't know what to make of UEFI

Post by Antti »

http://www.rodsbooks.com/gdisk/bios.html wrote:Some Intel BIOSes (and perhaps others) require that at least one hard disk have at least one MBR partition that's marked as bootable/active.
http://www.rodsbooks.com/gdisk/bios.html wrote:At least one computer I owned (using a Biostar PT880 Pro-A7 motherboard with a Phoenix/Award BIOS version 6.00G, dated 7/27/2006) seemed to require CHS geometries that are legal in the peculiar CHS encoding scheme.
Few other things to remember. Actually, the last one makes sense. I think BIOS will adjust the "heads" and "sectors per track" according to "geometry" it finds in the partition table.
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Don't know what to make of UEFI

Post by turdus »

tjmonk15 wrote: I have seen links to BIOS Boot specs in the past, but I can not seem to find any of them atm. Since you are refering to it directly, do you have a link to it?

- Monk
No, but Google returns these for "bios boot specification" on first page:
http://www.scs.stanford.edu/nyu/04fa/la ... bbs101.pdf
http://www.intel-assembler.it/portale/5 ... cation.asp

I've checked, the first is identical to what I've downloaded anno.
User avatar
seppe
Posts: 1
Joined: Mon Jul 21, 2014 12:49 pm

Re: Don't know what to make of UEFI

Post by seppe »

I compiled the hello world example from the UEFI.inc wiki page.
The result however displayed a lot of junk.
Modifying "db 'Hello World',13,10,0" to "du 'Hello World',13,10,0" solved the problem. :)
Console output is terribly slow. Is that intentionally?

Greetings from Seppe :)
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Don't know what to make of UEFI

Post by jnc100 »

seppe wrote:Modifying "db 'Hello World',13,10,0" to "du 'Hello World',13,10,0" solved the problem. :)
Many thanks, I've fixed that in the wiki.

Regards,
John.
Post Reply