17445 FreeBSD EFI bootloader concerns - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > FreeBSD Development

FreeBSD Development Kernel development, writing drivers, coding, and questions regarding FreeBSD internals.

Reply
 
Thread Tools Display Modes
  #1  
Old March 30th, 2011, 08:32
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default FreeBSD EFI bootloader concerns

Hello everyone. While I am exploring the possibility of EFI (Extensible Firmware Interface) bootstrapping of FreeBSD to allow it to boot natively on my MacBook Pro without BIOS-emulation provided by Boot Camp, I am interested in knowing whether the i386/amd64 versions of FreeBSD rely on BIOS runtime services, so that FreeBSD will work as usual without BIOS.

I found out that modern Linux implements its own low-level I/O without the BIOS facility. Could someone please tell me if FreeBSD does the same?

Thank you.

Last edited by DutchDaemon; March 30th, 2011 at 21:13.
Reply With Quote
  #2  
Old April 7th, 2011, 20:10
phs phs is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As far as I know, the FreeBSD kernel does rely on some BIOS calls during the early boot phase. The standard i386/amd64 loader certainly needs a BIOS, even though there apparently is an EFI version of it.
Reply With Quote
  #3  
Old April 8th, 2011, 06:16
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you phs.
I am aware of the fact that FreeBSD/i386 relies on BIOS during bootstrapping. I am more interested in knowing if the current FreeBSD/i386 kernel is compiled with references to BIOS (I am sure FreeBSD/ia64 kernel must not be), so that the kernel will not break on BIOS-less systems once it starts up.
Reply With Quote
  #4  
Old April 8th, 2011, 21:51
phs phs is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Once the operating system is up and running, you really don't want any interaction with the platform firmware for performance reasons. However, there are certain functions that rely on firmware, e.g. rebooting or powering off a system. I think on i386/amd64 this is abstracted through ACPI which is partially available in UEFI as well.

In other words: If you get the kernel to boot on a UEFI system, you have done significant amount of the work required to "run" on a UEFI system.
Reply With Quote
  #5  
Old April 11th, 2011, 08:06
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much.
So can I say that the work required to boot FreeBSD/i386 on EFI already includes that to run FreeBSD on EFI?

Last edited by DutchDaemon; April 11th, 2011 at 18:34.
Reply With Quote
  #6  
Old April 11th, 2011, 14:40
phs phs is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, but you may or may not be able to use features like rebooting or powering off.
Reply With Quote
  #7  
Old April 11th, 2011, 17:54
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have planned to write an EFI bootloader for FreeBSD/i386. I recently submitted my proposal to apply for this project as my Google Summer of Code 2011 participation.

My approach was to implement the following three components:
1) an EFI application that loads 2);
2) a patched /boot/loader that utilizes EFI instead of BIOS and loads 3);
3) a custom compiled FreeBSD/i386 kernel without dependency on BIOS.

Based on what we have discussed so far, does it mean that 3) is not really necessary, since FreeBSD kernel avoids BIOS and instead uses higher level facilities like ACPI?

Thank you so much.

Last edited by DutchDaemon; April 11th, 2011 at 18:35.
Reply With Quote
  #8  
Old April 11th, 2011, 19:36
phs phs is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I think you may want to look at the boot code and dig around a bit. Here's what I know.

In sys/boot, there's a lot of code already that makes up the loader. As the loader used to be able to boot an ia64 aka Itanium which exclusively has EFI and no BIOS, there's some EFI code available already. This may give a good starting point for 1) and 2).

In my opinion, the real challenge lies in 3). Have a look at sys/i386/i386/locore.s which is the kernel's entry point. The code goes on to init386() in sys/i386/i386/machdep.c and then calls into mi_startup() in sys/kern/init_main.c. The former is the machine dependent (MD) start-up code while the latter is the machine independent (MI) code.

As the name implies, the MD code is i386 specific and I wouldn't be surprised if there were a BIOS dependency in there. In fact, it seems init386() calls getmemsize() from sys/i386/i386/machdep.c which looks to me as if it went for the BIOS to query the system's memory size.

Also, mi_startup() is the core of the SYSINIT framework which orders and runs the constructors of various kernel subsystems. One of those subsystems is "bios32", declared in sys/i386/i386/bios.c. It looks like at least the APM functionality depends on that subsystem. I don't know if anything else depends on it.

Anyways, you shouldn't be discouraged by what I'm telling you. I'm merely trying to point you to the right places of the documentation which often times is in fact the code itself.

Last edited by DutchDaemon; April 11th, 2011 at 20:27.
Reply With Quote
  #9  
Old April 12th, 2011, 02:58
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you phs for your advice. I will surely not be discouraged by the challenges. Actually I was prepared for the sheer difficulty that lies in the kernel initialization (e.g. init386() and mi_startup()). However I was surprised to know that even the machine-independent mi_startup() contains some BIOS-specific code. I will definitely look into this part and find out if the APM module can be dropped in favor of ACPI.

I shall also make good use of the existing EFI loader from FreeBSD/ia64 as well as linux's elilo as my reference.

Last edited by DutchDaemon; April 12th, 2011 at 13:03.
Reply With Quote
  #10  
Old April 13th, 2011, 04:18
jb_fvwm2 jb_fvwm2 is offline
Senior Member
 
Join Date: Nov 2008
Posts: 1,386
Thanks: 60
Thanked 145 Times in 130 Posts
Default

Somewhat off-topic to the thread, but as regards UEFI what I read in another thread elsewhere, many/some/(all?) hardware raid cards currently do not support use in a UEFI motherboard. Unsure if that one instance can be extrapolated to all motherboards etc...

Last edited by DutchDaemon; April 13th, 2011 at 13:16.
Reply With Quote
  #11  
Old April 13th, 2011, 04:32
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That is very likely true, considering Raid controllers generally have built-in BIOS that chained with motherboard BIOS.
Probably only a select Intel Raid controllers can work with EFI.

Thank you for your information though.
Reply With Quote
  #12  
Old May 12th, 2011, 20:13
emc2 emc2 is offline
Junior Member
 
Join Date: May 2011
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Default

Did this project ever get approved as a Summer of Code project? I'm trying to get FreeBSD running on a MacBook Pro, so I'd like to see a proper EFI/GPT system as opposed to the current BIOS/MBR solution.
Reply With Quote
  #13  
Old May 13th, 2011, 12:21
jasonnfls jasonnfls is offline
Junior Member
 
Join Date: Mar 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello emc2. Unfortunately my proposal was not accepted and neither was any other proposal on the same project.
Reply With Quote
  #14  
Old June 6th, 2011, 10:02
Beeblebrox's Avatar
Beeblebrox Beeblebrox is offline
Member
 
Join Date: Sep 2010
Posts: 713
Thanks: 39
Thanked 76 Times in 68 Posts
Default

Slightly off-topic, and can be risky to implement, but you have heard of coreboot I assume? AFAIK it should be able to build the BIOS for a large number of systems, including EFI running ones. If you prefer EFI to BIOS, that's different.
__________________
branch:head - root on zfs - amd64
BLUES, ELWOOD
ILLINOIS LICENSE : B263-1655-2187
CURRENTLY UNDER SUSPENSION
WARRANTS OUTSTANDING : PARKG. 116
MOVING VIOLATIONS : 56
ARREST DRIVER ... IMPOUND VEHICLE
Reply With Quote
  #15  
Old July 28th, 2011, 13:05
emc2 emc2 is offline
Junior Member
 
Join Date: May 2011
Posts: 17
Thanks: 0
Thanked 1 Time in 1 Post
Default

I read somewhere that EFI boot on i386/amd64 has apparently been restarted as part of 9-CURRENT development. According to Rui Paolo's blog, he apparently had developed an EFI loader at some point which can load an ELF kernel, but does not boot it.

In any case, FreeBSD on a MacBook has become a personal project of mine, so I would certainly like to work on getting an EFI boot process working, if anyone else is still interested.
Reply With Quote
Reply

Tags
bios, bootloader, efi

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Porting concerns while migrating from wolfdale to sandy bridge saikatsanyal FreeBSD Development 5 March 15th, 2011 20:20
booting up freebsd from pendrive using bootloader Magnesik Peripheral Hardware 7 April 12th, 2010 10:46
[Solved] FreeBSD on EFI motherboard Glebushka System Hardware 3 March 19th, 2010 10:28
FreeBSD Bootloader on Install DVD hangs Brentx Installing & Upgrading 0 September 21st, 2009 03:47
Dell Studio 15 (1555) Wont boot (bootloader problem) in Freebsd 7.2 or 8.0 chenxiaolong Installing & Upgrading 14 September 3rd, 2009 02:38


All times are GMT +1. The time now is 01:49.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0