UEFI: Difference between revisions

232 bytes added ,  3 years ago
m
no edit summary
[unchecked revision][unchecked revision]
m (updates on POSIX-UEFI)
mNo edit summary
Line 58:
 
====Development environment====
Legacy bootloaders can be developed in any environment that can generate flat binary images: NASM, GCC, etc. UEFI applications can be developed in any language that can be compiled and linked into a [[PE]] executable file and supports the calling convention used to access functions established in memory by the UEFI firmware. In practice this means one of two development environments: Intel's TianoCore EDK2 or, GNU-EFI or POSIX-UEFI.
 
[[TianoCore]] is a large, complex environment with its own build system. It can be configured to use GCC, MinGW, Microsoft Visual C++, etc. as a cross-compiler. Not only can it be used to compile UEFI applications, but it can also be used to compile UEFI firmware to be flashed to a BIOS ROM.
 
[[GNU-EFI]] is a set of libraries and headers for compiling UEFI applications with a system's native GCC (does not work with LLVM CLang). It can't be used to compile UEFI firmware. Since it's just a couple of libraries against which a UEFI application can be linked, it is much easier to use than TianoCore.
 
[[POSIX-UEFI]] is very similar to GNU-EFI, but it is distributed mainly as a source, not as a binary library, has ANSI C like names and works with GCC as well as LLVM CLang. It's shipped with a Makefile that sets up the compiler flags for you.
 
====Emulation====
Line 126 ⟶ 128:
:''Main article: [[POSIX-UEFI]]
 
An easy way to compile EFI applications on Linux (or any other POSIX compatible system) is POSIX-UEFI. It does not only provide the well-known [[libc]]-like API for your EFI application, but also ships a Makefile that can detect and set up the toolchain for you. Works with both GNU gcc and LLVM CLang. Normally uses the host's compiler, but it is also capable of detecting the need for cross-compilation.
 
It has POSIX-ized typedefs (like ''uintn_t'' instead of ''UINTN''), and it does not need nor ship the standard EFI headers. But if you install those from EDK2 or GNU-EFI, you can safely include those as well, there will be no naming conflicts. Still, those interfaces are properly defined, and all fields have exactly the same name as in EDK2, so a big advantage over GNU-EFI that you can do
<source lang="c">
ST->ConOut->OutputString(ST->ConOut, L"Hi!\r\n");
</source>
 
The traditional "Hello, world" UEFI program goes like this. Note that instead of ''char **argv'', it has ''wchar_t **argv''.
<source lang="c">
#include <uefi.h>
int main (int argc, wchar_tchar **argv)
{
printf(L"Hello, world!\n");
return 0;
}
Anonymous user