POSIX-UEFI: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
m fixed typo
m removed uefi_call_wrapper
Line 5:
== Basic Concept ==
 
The concept is, EDK2's API (which gnu-efi tries to comply with) is horrible and ugly as hell. Why can't we just wrap all that up in a nice and friendly POSIX environment? Sure, we can! And that's exactly what POSIX-UEFI is for.
 
No cross-compiler needed like in the [[UEFI App Bare Bones]] tutorial (but if you have it, POSIX-UEFI will use it), and you can compile with both GNU gcc + ld and LLVM CLang + lld.
Line 27:
POSIX-UEFI provides everything in a single header file. It has defines and typedefs for almost everything you'll ever need (Simple File System Protocol, Console In/Out Protocols, Graphics Output Protocol, Serio IO Protocol, Block IO Protocol etc. etc. etc.), but it not complete, and never intended to be. The goal is to have all the defines needed for it's libc. Since it provides a POSIX layer, all the usual UEFI defines are renamed according to ANSI C standards, like EFI_MEMORY_DESCRIPTOR -> efi_memory_descriptor_t, UINTN -> uintn_t etc.
 
If you need some more header files, you can use the onesEDK2 shippedor withgnu-efi your Linuxones distributionunder (/usr/include/efi). POSIX-UEFI will add those include thempaths as well, and its header file was carefully written so that it can work with and without the EDK2those headers, no naming conflicts.
 
=== Linker Script ===
Line 69:
== Calling Any Arbitrary UEFI Function ==
 
Unlike GNU-EFI, which has many many library functions to cover up the EFI ugliness, POSIX-UEFI is really lightweight and only provides threetwo additional functions, no more. It provides the same 'uefi_call_wrapper'globals like GNU-EFI, with the same globals (BS, RT, ST). Furthermore it gives you 'uefi_exit_bsexit_bs' to leave the UEFI realm, and 'uefi_dumpmemgetchar_ifany' tofor non-blocking dumpkey physicalpress memoryreads. Everything else iscan calledbe viaaccessed just like in EDK2, no need for "uefi_call_wrapper.":
<source lang="c">
 
ST->ConOut->OutputString(ST->ConOut, buffer);
</source>
On the other hand, POSIX-UEFI provides standard libc API (hence its name). For example, opening a file goes just like under Linux, you can use fopen. Printing with printf, fprintf; using streams like stdin, stdout, stderr; allocating using malloc / free works the same way as expected on a POSIX compliant system.
 
All string formatting is done on wchar_t, so there's "%C" to print UTF-8 character, "%S" to print UTF-8 strings. There's an extra "%D" format to dump physical memory in hex.
 
== See also ==