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  [ 2 posts ] 
Author Message
 Post subject: UEFI 64-bit and kernel mapping
PostPosted: Fri Nov 10, 2017 3:21 am 
Offline

Joined: Sun May 20, 2012 4:35 pm
Posts: 3
Hi all, just want to ask for some advice regarding UEFI on x64 and mapping higher half kernel.

The process I'm currently designing for my kernel looks something like this:
- UEFI bootloader loads the kernel and all supporting modules
- The bootloader creates the paging table for the kernel and modules and map them to the correct location inside the page table
- Switch over to new page table
- Enter the kernel and continue

The thing that I can't figure out is the step to switch over to the new page table and enter the kernel. UEFI spec states that the boot services and runtime services will be identity mapped, and I presume all allocations made inside the bootloader will also be identity mapped, all other memory locations are undefined. Is there a way to get the memory location of the currently executing UEFI image to identity map it until the time is right to switch page tables, or is there some other way I'm missing of how to do this?


Top
 Profile  
 
 Post subject: Re: UEFI 64-bit and kernel mapping
PostPosted: Fri Nov 10, 2017 1:51 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 641
Location: Ukraine, Bachmut
EFI_LOADED_IMAGE_PROTOCOL.
Quote:
Summary
Can be used on any image handle to obtain information about the loaded image.

Description
Each loaded image has an image handle that supports EFI_LOADED_IMAGE_PROTOCOL. When an image is started, it is passed the image handle for itself. The image can use the handle to obtain its relevant image data stored in the EFI_LOADED_IMAGE_PROTOCOL structure, such as its load options.

The protocol structure has ImageBase and ImageSize fields.

I'm not sure this is the best way of transition from the loader (which owns the memory map) into kernel, I am just out of x86 now. I even am not sure it will work that way, but that is what you've been asking about. :)

It's a context switch, right? Think of it as that. what is needed to do that right on x86? what the sequence? maybe it's not necessary to remap your loader into new address space? It is ready to jump into the kernel, why you would need its image be mapped into that new space?
But don't forget to preserve Runtime Services, ACPI etc. :mrgreen:

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


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

All times are UTC - 6 hours


Who is online

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