OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Moving to UEFI Booting
PostPosted: Thu Mar 15, 2018 8:55 pm 
Offline

Joined: Tue Feb 28, 2012 6:14 am
Posts: 9
Hello,

My baremetal hypervisor currently boots using the multiboot specification with the help of GRUB. I use VGA for printing and not framebuffer. I want to move to UEFI mode booting. What are your recommendations to do that? What would be required to continue booting from GRUB in UEFI mode. Can the OS be a UEFI application and stays in UEFI-land for ever?

Any help or pointer would be of help.

Regards
Himanshu


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Fri Mar 16, 2018 6:16 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

chauhanjpr wrote:
My baremetal hypervisor currently boots using the multiboot specification with the help of GRUB. I use VGA for printing and not framebuffer. I want to move to UEFI mode booting. What are your recommendations to do that?


My recommendation would be to find anything that depends on legacy stuff (BIOS) and replace them with things that don't (while still using BIOS); and then start trying to move to UEFI afterwards. My reason is that it's easier to change one piece at a time while everything else still works (and harder to fix many incompatibilities at the same time).

chauhanjpr wrote:
What would be required to continue booting from GRUB in UEFI mode.


If you use multi-boot's memory map, GRUB's video mode setting, and multi-boot's "video mode information" structures (and the frame buffer GRUB sets up); then it can (in theory, depending on which multi-boot it uses) involve no changes to the code at all (e.g. just fighting with tools to generate a disk image for UEFI).

chauhanjpr wrote:
Can the OS be a UEFI application and stays in UEFI-land for ever?


Can you call something an OS if it doesn't take control of the hardware (e.g. by calling UEFI's "exitBootServices()" function)? I'd say that (in general, excluding virtualisation and paravirtualisation) an application (that depends on something else) can't be an OS, and an OS (that doesn't depend on something else) can't be an application.


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.


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Fri Mar 16, 2018 9:37 pm 
Offline

Joined: Sun Jul 07, 2013 7:29 pm
Posts: 16
chauhanjpr wrote:
Hello,

My baremetal hypervisor currently boots using the multiboot specification with the help of GRUB. I use VGA for printing and not framebuffer. I want to move to UEFI mode booting. What are your recommendations to do that? What would be required to continue booting from GRUB in UEFI mode. Can the OS be a UEFI application and stays in UEFI-land for ever?

Any help or pointer would be of help.

Regards
Himanshu


Hello Himanshu, I am literally in the same position. Currently I am porting my homebrewed OS from multiboot1 to UEFI. The are some progress but the work is not fully completed yet.

Basically there are multiple differences between these two boot mechanisms:
- The system starts in 64bit mode (vs 32bit mode of multiboot). Thus your OS initialization code need to do slightly less.
- UEFI firmware loads UEFI applications and provides pointers to BootServices structure. UEFI application have to be a PE binary (i.e. Windows format app). And to deal with it you either need to compile the application in PE format or write a simple bootloader that loads your ELF into memory and then jump to its entry point.
- I believe there is no VGA text mode available for UEFI application. So if you want to output a text to screen you need to use framebuffer and draw fonts directly to it. Or use serial port that is useful for QEMU development.


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Sat Mar 17, 2018 6:11 am 
Offline

Joined: Tue Feb 28, 2012 6:14 am
Posts: 9
Thanks for the reply Brenden!

Brenden wrote:
Can you call something an OS if it doesn't take control of the hardware (e.g. by calling UEFI's "exitBootServices()" function)? I'd say that (in general, excluding virtualisation and paravirtualisation) an application (that depends on something else) can't be an OS, and an OS (that doesn't depend on something else) can't be an application.


I was just thinking out loud. BTW, I got the framebuffer to work in non-UEFI mode but on the machines with UEFI its not working. Possibly because in UEFI mode multiboot's vbeinfo is not populated. I am yet to try the frame buffer specific section in multiboot header. Anything else that would be needed to get FB to work under UEFI?

Regards
Himanshu


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Sat Mar 17, 2018 6:21 am 
Offline

Joined: Tue Feb 28, 2012 6:14 am
Posts: 9
anatolik wrote:
Hello Himanshu, I am literally in the same position. Currently I am porting my homebrewed OS from multiboot1 to UEFI. The are some progress but the work is not fully completed yet.

I am also trying to get Multiboot 1 to work with UEFI.


anatolik wrote:
- The system starts in 64bit mode (vs 32bit mode of multiboot). Thus your OS initialization code need to do slightly less.

It would be easier for me as I am not planning to support 32bit, I guess, ever! So I can fixate on booting part.

anatolik wrote:
- UEFI firmware loads UEFI applications and provides pointers to BootServices structure. UEFI application have to be a PE binary (i.e. Windows format app). And to deal with it you either need to compile the application in PE format or write a simple bootloader that loads your ELF into memory and then jump to its entry point.

I am using Grub to boot the hypervisor. Grub, as I have read on the internet, exits the boot services before it launches the OS. So I need to just get the framebuffer working in UEFI mode. I don't know if the framebuffer section of multiboot header will give the enough information because VBE section info doesn't work.

Regards
Himanshu


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Sat Mar 17, 2018 6:54 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

chauhanjpr wrote:
I was just thinking out loud. BTW, I got the framebuffer to work in non-UEFI mode but on the machines with UEFI its not working. Possibly because in UEFI mode multiboot's vbeinfo is not populated. I am yet to try the frame buffer specific section in multiboot header. Anything else that would be needed to get FB to work under UEFI?


I'm not sure how much of what GRUB supports under UEFI; but the reason they created multi-boot 2 is that the original multi-boot 1 was only designed for BIOS systems and wasn't very portable. Also note that GRUB 2 tends to rely on "optional" modules, so maybe the problem is that GRUB 2 is missing some sort of video related module.

chauhanjpr wrote:
anatolik wrote:
Hello Himanshu, I am literally in the same position. Currently I am porting my homebrewed OS from multiboot1 to UEFI. The are some progress but the work is not fully completed yet.

I am also trying to get Multiboot 1 to work with UEFI.


I'm fairly sure (based on information elsewhere) that anatolik is porting code to "raw UEFI" so that it won't use multi boot and won't need a loader like GRUB.

You seem to want to continue using multi-boot and GRUB; which is quite different to what anatolik is doing.

anatolik wrote:
I am using Grub to boot the hypervisor. Grub, as I have read on the internet, exits the boot services before it launches the OS. So I need to just get the framebuffer working in UEFI mode. I don't know if the framebuffer section of multiboot header will give the enough information because VBE section info doesn't work.


Erm, this is getting a little confusing.

Just to be sure, for what you're planning:
  • GRUB starts running on the real/host machine
  • GRUB (on the host machine) exits the host machine's boot services
  • GRUB (on the host machine) starts a hypervisor
  • Hypervisor creates a whole new (virtual) machine with it's own completely unrelated UEFI and it's own boot services
  • Hypervisor starts a completely different copy of GRUB inside the virtual machine
  • GRUB (in the virtual machine) exits the virtual machine's boot services
  • GRUB (in the virtual machine) passes control to your code using "multi-boot 1"

The alternative is something like:
  • GRUB starts running on the real/host machine
  • GRUB (on the host machine) exits the host machine's boot services
  • GRUB (on the host machine) starts a hypervisor
  • Hypervisor creates a whole new (virtual) machine with it's own completely unrelated UEFI and it's own boot services
  • Hypervisor starts boots your code (without using GRUB inside the virtual machine, and without multi-boot being used by your code at all) and you have to exit boot services yourself


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.


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Sat Mar 17, 2018 9:01 am 
Offline

Joined: Tue Feb 28, 2012 6:14 am
Posts: 9
Hi Brendan,

Brendan wrote:
Erm, this is getting a little confusing.

Just to be sure, for what you're planning:
  • GRUB starts running on the real/host machine
  • GRUB (on the host machine) exits the host machine's boot services
  • GRUB (on the host machine) starts a hypervisor
  • Hypervisor creates a whole new (virtual) machine with it's own completely unrelated UEFI and it's own boot services
  • Hypervisor starts a completely different copy of GRUB inside the virtual machine
  • GRUB (in the virtual machine) exits the virtual machine's boot services
  • GRUB (in the virtual machine) passes control to your code using "multi-boot 1"



Till point 3 its good. My code is hypervisor. I am trying to get my hypervisor booting in UEFI mode. Currently it boots on a real machine using Multiboot-1. On another machine, UEFI is enabled and I want to support UEFI mode in my hypervisor.

Regards
Himanshu


Top
 Profile  
 
 Post subject: Re: Moving to UEFI Booting
PostPosted: Fri Mar 23, 2018 8:52 pm 
Offline

Joined: Tue May 13, 2008 7:49 am
Posts: 3
GNU-EFI has a Print() function you can use until you call ExitBootServices();

https://www.rodsbooks.com/efi-programming/hello.html


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot] and 66 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