I think I need a fresh eye on my issue. Using FASM I kind of fail opening the loaded image protocol at the very start of a small EFI project. I think I'm following what the specs say, I disassembled to check that the instructions are in place, I read the assembly to check that the protocol GUID is right. But whatever the case, the BootService.OpenProtocol always returns a 2 for "invalid parameter".
Can someone check that this call seems right?
Code: Select all
format pe64 dll efi
entry main
section '.text' code executable readable
include "efi_test.inc"
main:
mov [Handle], rcx ; ImageHandle
mov [SystemTable], rdx ; pointer to SystemTable
; this is calling OpenProtocol on the image handle for EFI_LOADED_IMAGE_PROTOCOL_GUID
mov rcx, [Handle] ; param 1: image handle
lea rdx, [EFI_LOADED_IMAGE_PROTOCOL_GUID] ; param 2: GUID
lea r8, [LoadedImageProtocol] ; param 3: pointer where to store the protocol
mov r9, rcx ; param 4: image handle
mov r10, 0
push r10 ; param 5: optional null, not a driver
mov r10, 2
push r10 ; param 6: attributes=2=EFI_OPEN_PROTOCOL_GET_PROTOCOL
mov rax, [SystemTable]
mov rax, [rax + EFI_SYSTEM_TABLE.BootServices]
call [rax + EFI_BOOT_SERVICES_TABLE.OpenProtocol]
pop rcx
pop rcx
cmp rax, EFI_SUCCESS
je got_protocol
; ... display error message here