User:Combuster/notepad: Difference between revisions

Content deleted Content added
Combuster (talk | contribs)
Combuster (talk | contribs)
Line 4:
A bunch of notes regarding UEFI and how people have tried hard to make things stupid:
 
=== officialOfficial documentation ===
Those morons put a contract on the documentation, so the only one you can download straight from google is an older 2.0 specification. And it's got a fair share of pitfalls.
 
==== ABI ====
The EFI ABI for x86_64 is severely limtedly documented in the UEFI specification, which leads to issues where you are not expecting them. Notable problems:
* You need to "push" all arguments on the stack - including all arguments that you also pass in a register. The function should use the register version, so you can leave anything in those holes, but many functions will simply write back the arguments to their locations. If you're not reserving space, that means your stack gets overwritten.
Line 10 ⟶ 13:
* The documentation gives you 4K stack minimum, but doesn't describe ownership for anything past the top of the stack. In fact, there's no red zone and interrupts will simply jump to the firmware and overwrite anything you put past the stackpointer. If you internally resort to the AMD64 ABI, make sure you pass <tt>-mno-red-zone </tt>
Basically, it boils down to the fact that the EFI ABI follows exactly the Microsoft x86_64 ABI, including everything it didn't copy over from the [http://msdn.microsoft.com/en-us/library/ew5tede7%28v=vs.80%29.aspx original documentation] (and all associated surprises thereof)
 
==== EFI_BOOT_SERVICES ====
In the table, there's a missing pointer, which means everything you use past it has wrong offsets and therefore calls the wrong function
<pre>EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
EFI_HANDLE_PROTOCOL HandleProtocol;
EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;</pre>
This should be something like
<pre>EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
void * PossiblyHandleProtocol_1;
void * PossiblyHandleProtocol_2;
EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;</pre>
 
=== gnu-efi ===