diff options
Diffstat (limited to 'include/linux/efi.h')
-rw-r--r-- | include/linux/efi.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/efi.h b/include/linux/efi.h index 561db9deedae..8d267715ce22 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -48,6 +48,19 @@ typedef u16 efi_char16_t; /* UNICODE character */ typedef u64 efi_physical_addr_t; typedef void *efi_handle_t; +#define efi_get_handle_at(array, idx) \ + (efi_is_64bit() ? (efi_handle_t)(unsigned long)((u64 *)(array))[idx] \ + : (efi_handle_t)(unsigned long)((u32 *)(array))[idx]) + +#define efi_get_handle_num(size) \ + ((size) / (efi_is_64bit() ? sizeof(u64) : sizeof(u32))) + +#define for_each_efi_handle(handle, array, size, i) \ + for (i = 0; \ + i < efi_get_handle_num(size) && \ + ((handle = efi_get_handle_at((array), i)) || true); \ + i++) + /* * The UEFI spec and EDK2 reference implementation both define EFI_GUID as * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment |