OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Nov 22, 2019 9:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: How do you rewrite the kernel if you chose use UEFI to s
PostPosted: Fri Nov 08, 2019 1:30 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 409
Hi,
ajxs wrote:
benji wrote:
The kernel may not be the kernel.bin, The kernel became kernel.efi???? I really want to know those basic problem. Thank you so much!


Apologies for resurrecting a dead thread, I figure it's worth a reply in case this helps someone.
No one has addressed the fact that you shouldn't be compiling your kernel into the UEFI bootloader. This statement suggests that OP is a little confused regarding the bootloader's purpose and how it differs from the kernel itself. UEFI is not for writing a kernel, it's for writing a bootloader to load the kernel. The bootloader's job is to set up the initial environment for loading and executing the kernel. While the kernel is highly coupled to the bootloader, they are separate programs entirely. The UEFI bootloader should be compiled as an EFI executable, which then loads the separate kernel executable in whatever binary format it is in.
Regarding OP's original question of what you need to rewrite in your kernel: This is a really pedantic answer, but... nothing. Maybe. Most online tutorials suggest using GRUB and writing your kernel to adhere to the Multiboot standard. An advantage of doing this is that it would theoretically be compatible with any bootloader implementing this standard. If you roll your own bootloader you're going to need to decide for yourself what state your kernel expects the environment to be in.
If you're having trouble with writing your kernel, UEFI won't offer you much help. Writing your own bootloader in UEFI will not simplify any part of the kernel development process.
Basically you're right. However it is not impossible nor uncommon to write the kernel as an UEFI binary. For example the Linux kernel has manually hardcoded bytes in it so that the UEFI firmware sees it as an UEFI executable and it can load it directly.

But this is a hack. You should separate your kernel from the bootloader (probably using a standard interface with which you'll be able to load your kernel on non-UEFI machines too, either Multiboot, BOOTBOOT, whatever), and you're right writing your own bootloader in UEFI won't simplify anything.

Cheers,
bzt


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 14 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