diff options
author | Steve McIntyre <steve@einval.com> | 2021-03-23 23:49:46 +0000 |
---|---|---|
committer | Steve McIntyre <steve@einval.com> | 2021-03-23 23:49:46 +0000 |
commit | 1251a7ba86fc40a6aad8b4fecdbca2b61808d9fa (patch) | |
tree | 2125fda549aaca55cb49a48d54be77dec7fbf3df /gnu-efi/apps/drv0_use.c | |
parent | 85b409232ce89b34626df9d72abedf5d4f5ccef6 (diff) | |
parent | 031e5cce385d3f96b1caa1d53495332a7eb03749 (diff) | |
download | efi-boot-shim-debian/15.3-1.tar.gz efi-boot-shim-debian/15.3-1.zip |
Update upstream source from tag 'upstream/15.3'debian/15.3-1
Update to upstream version '15.3'
with Debian dir 1b484f1c1ac270604a5a1451b34de4b0865c6211
Diffstat (limited to 'gnu-efi/apps/drv0_use.c')
-rw-r--r-- | gnu-efi/apps/drv0_use.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/gnu-efi/apps/drv0_use.c b/gnu-efi/apps/drv0_use.c new file mode 100644 index 00000000..d8688cf1 --- /dev/null +++ b/gnu-efi/apps/drv0_use.c @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2013 David Decotigny <decot@googlers.com> + * + * See drv0.c for an example session. + */ + +#include <efi.h> +#include <efilib.h> +#include "drv0.h" + + +static EFI_GUID GnuEfiAppsDrv0ProtocolGuid + = GNU_EFI_APPS_DRV0_PROTOCOL_GUID; + + +static +EFI_STATUS +PlayWithGnuEfiAppsDrv0Protocol(IN EFI_HANDLE DrvHandle) { + EFI_STATUS Status; + GNU_EFI_APPS_DRV0_PROTOCOL *drv = NULL; + UINTN NumberOfHello = 0; + + Status = uefi_call_wrapper(BS->OpenProtocol, 6, + DrvHandle, + &GnuEfiAppsDrv0ProtocolGuid, + (void**)&drv, + DrvHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (EFI_ERROR(Status)) { + Print(L"Cannot open proto: %d\n", Status); + return Status; + } + + Status = uefi_call_wrapper(drv->SayHello, 2, L"Sample UEFI Driver"); + if (EFI_ERROR(Status)) { + Print(L"Cannot call SayHello: %d\n", Status); + } + + Status = uefi_call_wrapper(drv->GetNumberOfHello, 2, &NumberOfHello); + if (EFI_ERROR(Status)) { + Print(L"Cannot call GetNumberOfHello: %d\n", Status); + } else { + Print(L"Hello was called %d time(s).\n", NumberOfHello); + } + + return EFI_SUCCESS; +} + + +EFI_STATUS +efi_main (EFI_HANDLE Image, EFI_SYSTEM_TABLE *SysTab) +{ + EFI_STATUS Status; + EFI_HANDLE *Handles = NULL; + UINTN i, NoHandles = 0; + + InitializeLib(Image, SysTab); + + Status = LibLocateHandle(ByProtocol, &GnuEfiAppsDrv0ProtocolGuid, + NULL, &NoHandles, &Handles); + if (EFI_ERROR(Status)) { + Print(L"Error looking up handles for proto: %d\n", Status); + return Status; + } + + for (i = 0 ; i < NoHandles ; ++i) + { + Print(L"Playing with driver instance %d...\n", i); + Status = PlayWithGnuEfiAppsDrv0Protocol(Handles[i]); + if (EFI_ERROR(Status)) + Print(L"Error playing with instance %d, skipping\n", i); + } + + if (Handles) + FreePool(Handles); + + return EFI_SUCCESS; +} |