Page 1 of 2

Best hard disk driver approach

Posted: Wed Jul 27, 2011 9:04 am
by Bietje
Hi there!

Currently I am in need of a hard disk driver, but I am not really sure how I should deal with it. I'm writing a bootloader and the driver should be small. I want to hit as many drive types at once with the least bytes of code (which is probably causing poor performance, but I don't care for that yet) because I have a current max executable size of 127 sectors (due to 1 MiB limit, loading from 0x7e00:0x200). I want to use this driver to load the core image of my bootloader.

Would it be wise to use
  • * ATA PIO
    * DMA access
    * AHCI driver
    * Something else I didn't mention yet
Thanks in advance,
Bietje

Re: Best hard disk driver approach

Posted: Wed Jul 27, 2011 11:01 am
by Brendan
Hi,
Bietje wrote:
  • * ATA PIO
    * DMA access
    * AHCI driver
    * Something else I didn't mention yet
  • The functions or services that the firmware provides specifically so that boot loaders don't need to include a large number of different drivers (PATA, ATAPI, AHCI, USB & USB storage devices, lost of different SCSI, etc) that will become useless as soon as the kernel is running.
I vote for the option you forgot.


Cheers,

Brendan

Re: Best hard disk driver approach

Posted: Thu Jul 28, 2011 1:28 am
by mark3094
I agree. The bootloader is just meant to be enough to load the Kernel, or whatever may come next.

In my bootloader, I just use interrupt 13 to load sectors from disk. This loads the Kernel.
Of course this has to be done before entering protected mode.

Re: Best hard disk driver approach

Posted: Thu Jul 28, 2011 4:46 pm
by Bietje
Yes, you are probably right. I should use the bios. Thanks for your reactions!

Re: Best hard disk driver approach

Posted: Thu Jul 28, 2011 6:27 pm
by Love4Boobies
Note that Brendan said "firmware" instead of "BIOS" for a reason. Even x86 boxes can have other types of firmware, the most popular of which are: OFW, EFI, and UEFI---they all have different APIs. Drivers are usually provided by the firmware vendor, but sometimes they can be supplemented by systems programmers.

Re: Best hard disk driver approach

Posted: Sat Jul 30, 2011 8:09 pm
by Bietje
Love4Boobies wrote:Note that Brendan said "firmware" instead of "BIOS" for a reason. Even x86 boxes can have other types of firmware, the most popular of which are: OFW, EFI, and UEFI---they all have different APIs. Drivers are usually provided by the firmware vendor, but sometimes they can be supplemented by systems programmers.
True, true. Are there some existing bootloaders/operating systems which use one of these? So I can look at something more then specifications and documentation..

Greets,

Bietje

Re: Best hard disk driver approach

Posted: Sun Jul 31, 2011 5:15 am
by Gigasoft
Mac OS X?

Re: Best hard disk driver approach

Posted: Sun Jul 31, 2011 6:15 am
by Love4Boobies
Yes, OS X and Windows both support EFI. I don't know about Windows x86/x64 (the answer is probably yes, though) but Windows IA-64 certainly does. I suspect other major OSes have added support for it as well (e.g., Linux, FreeBSD, etc.) but I haven't checked.

According to some quick googling, OS X also supports OFW, which is kind of surprising---will have to look into that. You should probably look into Solaris and z/OS as well.

Re: Best hard disk driver approach

Posted: Sun Jul 31, 2011 4:19 pm
by Bietje
Thanks, I will look at them. GRUB is also using efi I see..

Re: Best hard disk driver approach

Posted: Sun Jul 31, 2011 5:23 pm
by Owen
Love4Boobies wrote:According to some quick googling, OS X also supports OFW, which is kind of surprising---will have to look into that.
OS X PowerPC supports (indeed, requires) OpenFirmware. OS X Intel supports (indeed, requires) EFI. EFI, it seems, of an Apple custom variety.

Solaris/SPARC uses OpenFirmware. Solaris/x86 uses GRUB Legacy. I don't know whether GRUB 2 has integrated the support required to boot it (e.g. ZFS)

Re: Best hard disk driver approach

Posted: Mon Aug 01, 2011 5:38 am
by Love4Boobies
Owen wrote:
Love4Boobies wrote:According to some quick googling, OS X also supports OFW, which is kind of surprising---will have to look into that.
OS X PowerPC supports (indeed, requires) OpenFirmware. OS X Intel supports (indeed, requires) EFI. EFI, it seems, of an Apple custom variety.
I'm obviously not an Apple fanboy :) I was under the impression that OS X was x86(-64)-only and OS 9 was PPC-only; that's why I found it surprising.

Re: Best hard disk driver approach

Posted: Mon Aug 01, 2011 9:49 am
by Brynet-Inc
Love4Boobies wrote:I'm obviously not an Apple fanboy :) I was under the impression that OS X was x86(-64)-only and OS 9 was PPC-only; that's why I found it surprising.
OS X was shipped on PowerPC Macs for many years, it was announced everywhere when they switched to x86, "Intel Macs".

The later PowerPC systems weren't unimpressive, 64-bit, dual-core.. close to 3GHz clock speeds.
http://en.wikipedia.org/wiki/Power_Mac_G5

I'm not a fan of them either, but I still don't live under a rock.

Re: Best hard disk driver approach

Posted: Mon Aug 01, 2011 11:10 am
by Love4Boobies
Brynet-Inc wrote:The later PowerPC systems weren't unimpressive, 64-bit, dual-core.. close to 3GHz clock speeds.
http://en.wikipedia.org/wiki/Power_Mac_G5

I'm not a fan of them either, but I still don't live under a rock.
I own a G5 :wink: (I don't have Mac OS installed on it, though).

Re: Best hard disk driver approach

Posted: Mon Aug 01, 2011 2:32 pm
by Bietje
I have never looked at EFI before.. So, I'm not completely familiar with it. Does it replace the BIOS completely and do I boot with a special image written to boot with EFI? Or can I boot normally with the BIOS, do stuff and when I need the hard disk, I jump to a special image which can use EFI? That last sounds to nice to be true, actually..

Re: Best hard disk driver approach

Posted: Mon Aug 01, 2011 3:16 pm
by Love4Boobies
Bietje wrote:Does it replace the BIOS completely and do I boot with a special image written to boot with EFI? Or can I boot normally with the BIOS, do stuff and when I need the hard disk, I jump to a special image which can use EFI? That last sounds to nice to be true, actually..
It should eventually replace the BIOS, yes. However, most of today's EFI and UEFI systems are actually hybrids. They are either built on top of the PC BIOS or the other way around. The second part of the first question is ambiguous (because you don't specify what you mean by "image"---could be either the firmware or the OS); if you're asking whether your boot loader needs to support (U)EFI, the answer is yes.

As for the second question... I really don't know what you are asking. Whatever it is, it's obviously misguided. Why would you want to use the BIOS and then (U)EFI? Do you eat half of your meal, put the remaining half in a different plate and then eat that?