OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 5:55 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: UEFI booting
PostPosted: Sun Sep 10, 2017 8:35 am 
Offline

Joined: Thu Sep 07, 2017 1:29 pm
Posts: 7
I've been using "legacy" BIOS so far, but want to switch to UEFI. However, reading the UEFI documentation, I can't seem to find anywhere where it says what the boot environment is like. For example, is paging enabled? Is there a GDT set up? Are there any special considerations I have to take into account when setting these things up, assuming they're not set up?


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Sun Sep 10, 2017 8:41 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
jordyd wrote:
For example, is paging enabled? Is there a GDT set up? Are there any special considerations I have to take into account when setting these things up, assuming they're not set up?

I don't know a whole lot about UEFI, but UEFI normally leaves you in 64-bit mode, which means paging is enabled and there is a GDT, with the segment registers set to 64-bit long mode selectors. Supposedly, UEFI leaves all memory identity-mapped, which means virtual address equals physical address. So you can easily set up your own paging/GDT structures without taking into consideration the current paging structures, and then reload CR3 and the segment registers.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Sun Sep 10, 2017 9:42 am 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
The UEFI spec requires all memory listed by the UEFI memory map to be identity mapped in long mode, while also allowing paging to be disabled in protected mode. As for the GDT, the UEFI spec doesn't say anything about the state you are left with - it does say however that using the firmware requires you to restore the original GDT. You can assume that you will be left with a working state when you take over, but really nothing beyond that.

_________________
managarm


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Sun Sep 10, 2017 9:46 am 
Offline

Joined: Thu Sep 07, 2017 1:29 pm
Posts: 7
Thanks guys, that was very informative. I was under the impression that UEFI could be used on 32-bit computers, and presumably would drop you into protected mode on those computers. Is this incorrect? I'm not really sure where I got that idea.


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Mon Sep 11, 2017 7:31 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5134
No, that's correct. A 32-bit computer can have UEFI, and 32-bit UEFI will start you in protected mode.

It's also possible (but uncommon) for a 64-bit computer to have 32-bit UEFI. It'll start you in protected mode, but you can switch to long mode.


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Mon Sep 11, 2017 5:26 pm 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 154
one option is to use grub 2.0 to boot using UEFI and load your kernel

_________________
complexity is the core of simplicity


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Mon Sep 11, 2017 11:46 pm 
Offline

Joined: Thu Sep 07, 2017 1:29 pm
Posts: 7
Main reason I want to use UEFI is that I need access to the EBDA on systems that use both legacy BIOS as well as UEFI, so I'm trying to figure out how to do that. I don't want to make this into a thread about finding the EBDA, however. I just noted that on the page describing how to find the EBDA on the OSDev Wiki, it mentions that on UEFI systems the method may not work, and on those systems it requires looking in the system tables. Does GRUB provide me with UEFI data structures? I can't seem to find anything on that, and it doesn't appear to be in the multiboot spec.


Top
 Profile  
 
 Post subject: Re: UEFI booting
PostPosted: Tue Sep 12, 2017 12:56 am 
Offline

Joined: Thu Sep 07, 2017 1:29 pm
Posts: 7
I did some reading and found this https://www.gnu.org/software/grub/manual/multiboot2/html_node/Boot-information-format.html#Boot-information-format, which, if you scroll enough, indicates that you can access the UEFI system table pointer from Multiboot 2, which effectively solves my issue. Hopefully someone else will find this useful as well.


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: Bing [Bot] and 769 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