Moldytzu
Moldytzu

Reputation: 25

How can I get a protocol working under GNU-EFI?

I use GNU-EFI to develop UEFI apps. I have some trouble getting a protocol (EFI_SHELL_PROTOCOL) working under GNU-EFI. My compiler says that it is undefined. Should I include something? I already included efi.h and efilib.h. Do I need more?

Code that I tried:

EFI_SHELL_PROTOCOL shell;

The error that I got:

error: unknown type name ‘EFI_SHELL_PROTOCOL’; did you mean ‘EFI_OPEN_PROTOCOL’?
  161 |  EFI_SHELL_PROTOCOL shell;

Upvotes: 0

Views: 810

Answers (3)

fpmurphy
fpmurphy

Reputation: 2537

The EFI_SHELL_PROTOCOL is fully documented in the UEFI Shell Specification (currently v2.2) which can be downloaded at https://uefi.org/specifications

GNU EFI does not currently implement EFI_SHELL_PROTOCOL or, indeed, all of the current UEFI Specification. For a reference implementation of the UEFI Shell Specification look at the EDK11 ShellPkg source code.

Upvotes: 0

KagurazakaKotori
KagurazakaKotori

Reputation: 572

Currently, GNU-EFI does not support EFI_SHELL_PROTOCOL. It doesn't contain any related definitions about it.

If you want to use it with GNU-EFI, you can use this header file from edk2 (put it in inc folder, for example, inc/efishell.h). Then include this header file in inc/efi.h and add these lines:

lib/data.c:

EFI_GUID ShellProtocol = EFI_SHELL_PROTOCOL_GUID;

inc/efilib.h:

extern EFI_GUID ShellProtocol;

Rebuild your GNU-EFI and now you can use EFI_SHELL_PROTOCOL by locating it first.

EFI_SHELL_PROTOCOL *SP;

uefi_call_wrapper(BS->LocateProtocol, 3, &ShellProtocol, NULL, &SP);

Upvotes: 1

Brendan
Brendan

Reputation: 37214

The EFI_SHELL_PROTOCOL isn't part of the main UEFI interface, and is therefore not included in the main header files (e.g. efi.h) and not included in the main UEFI standard.

Instead, EFI_SHELL_PROTOCOL is just an optional extension (that may not exist, and I'd assume is only likely to exist when a shell is being used and provides it), with its own separate standard and its own separate header file.

Assuming you're using GNU's tools; the right files to include are probably efishellintf.h and efishellparm.h.

Upvotes: 1

Related Questions