Best hard disk driver approach

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Bietje
Member
Member
Posts: 100
Joined: Wed Apr 20, 2011 6:57 am

Best hard disk driver approach

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Best hard disk driver approach

Post 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
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
mark3094
Member
Member
Posts: 164
Joined: Mon Feb 14, 2011 10:32 pm
Location: Australia
Contact:

Re: Best hard disk driver approach

Post 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.
Bietje
Member
Member
Posts: 100
Joined: Wed Apr 20, 2011 6:57 am

Re: Best hard disk driver approach

Post by Bietje »

Yes, you are probably right. I should use the bios. Thanks for your reactions!
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Best hard disk driver approach

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Bietje
Member
Member
Posts: 100
Joined: Wed Apr 20, 2011 6:57 am

Re: Best hard disk driver approach

Post 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
Gigasoft
Member
Member
Posts: 855
Joined: Sat Nov 21, 2009 5:11 pm

Re: Best hard disk driver approach

Post by Gigasoft »

Mac OS X?
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Best hard disk driver approach

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Bietje
Member
Member
Posts: 100
Joined: Wed Apr 20, 2011 6:57 am

Re: Best hard disk driver approach

Post by Bietje »

Thanks, I will look at them. GRUB is also using efi I see..
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Best hard disk driver approach

Post 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)
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Best hard disk driver approach

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Best hard disk driver approach

Post 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.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Best hard disk driver approach

Post 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).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Bietje
Member
Member
Posts: 100
Joined: Wed Apr 20, 2011 6:57 am

Re: Best hard disk driver approach

Post 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..
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Best hard disk driver approach

Post 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?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply