OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Sep 19, 2019 10:58 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Looking for advice on EDK2 development
PostPosted: Fri Aug 30, 2019 9:02 pm 
Offline

Joined: Mon Jun 13, 2016 2:25 am
Posts: 13
Location: Sydney
I've recently set myself the task of writing a UEFI bootloader for my hobby operating system. I've had a good run so far. My very simple bootloader an ELF executable and successfully transfers control to the kernel. I've used GNU-EFI up until this point, since it integrates perfectly with the rest of my GNU based build toolchain. The only thing I'm not happy with is having to use the included call wrappers to target the Microsoft calling convention. This is adequate, but I don't like that it forgoes any compile-time type safety and increases the complexity and amount of boilerplate code.
I've seen that some people ( such as the author of the 'uefi' page on the wiki ) have used a cross-compiler to target PE32+ directly. While this seems to work, it seems to me like using a hack to avoid using a hack. From the GNU-EFI documentation, their entire build system seems designed around the idea of creating an ELF executable which is compatible with being copied directly into a valid PE32+ binary. I like the increased code clarity this offers, but I don't like the increase in the build pipeline's complexity.
I was wondering if other people could share their experience and opinions on whether or not it's worth using EDK2 for building a bootloader for a hobby kernel. I've successfully set up EDK2, but I don't really like the build pipeline it requires.
Has anyone been able to integrate development using EDK2 easily into their build environment? I don't like the idea of having to use their source tree as my working directory. I know I can get around this with symlinks and other constructs, but that's just more of the complexity I'm trying to avoid.
Does anyone have any suggestions here on good ways to use EDK2 while minimising the complexity in the development environment and OS source tree?

Also, if anyone would be willing to offer me any help with some code review, I would really appreciate it! Thank you!


Top
 Profile  
 
 Post subject: Re: Looking for advice on EDK2 development
PostPosted: Fri Aug 30, 2019 10:35 pm 
Online
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 240
Whether or not something is a hack is a matter of taste. I think objcopy is a hack, and compiling directly for PE32+ seems like the normal approach. However, even an ELF compiler should be able to be told that a certain function uses a certain ABI. Maybe only the attributes are missing?


Top
 Profile  
 
 Post subject: Re: Looking for advice on EDK2 development
PostPosted: Fri Aug 30, 2019 11:24 pm 
Offline

Joined: Mon Jun 13, 2016 2:25 am
Posts: 13
Location: Sydney
Of course, you can use function attributes to denote that a function uses the Microsoft ABI. Whether you prefer that or the call wrapper is a matter of taste I guess. Thus far I've followed the methodology outlined in the GNU-EFI documentation. Which, for better or worse, recommends using the call wrapper, using the EFI_API annotation, linking with their supplied linker script and using objcopy to generate a valid EFI binary.
Taste will obviously vary on this issue. My rationale for following the GNU-EFI recommendations to a tee is to minimise the cognitive burden of anyone else unfortunate enough to read the code (hint hint).


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot], nullplan and 18 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