OSDev.org
https://forum.osdev.org/

Looking for advice on EDK2 development
https://forum.osdev.org/viewtopic.php?f=1&t=34109
Page 1 of 1

Author:  ajxs [ Fri Aug 30, 2019 9:02 pm ]
Post subject:  Looking for advice on EDK2 development

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!

Author:  nullplan [ Fri Aug 30, 2019 10:35 pm ]
Post subject:  Re: Looking for advice on EDK2 development

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?

Author:  ajxs [ Fri Aug 30, 2019 11:24 pm ]
Post subject:  Re: Looking for advice on EDK2 development

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).

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/