summaryrefslogtreecommitdiff
path: root/include/efi_loader.h
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2018-11-18 17:58:49 +0100
committerAlexander Graf <agraf@suse.de>2018-12-02 21:59:37 +0100
commitc3772ca1e38f36f2486b44c27094421442414e5e (patch)
tree9e0796c02e18c264c21bf0f3964cd20490174843 /include/efi_loader.h
parent42910ff1baa9c6bf9e0eecbe252bf06e11861fa8 (diff)
efi_loader: macro efi_size_in_pages()
When allocating EFI memory pages the size in bytes has to be converted to pages. Provide a macro efi_size_in_pages() for this conversion. Use it in the EFI subsystem and correct related comments. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'include/efi_loader.h')
-rw-r--r--include/efi_loader.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/efi_loader.h b/include/efi_loader.h
index f399e99506..3c90515fef 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -344,7 +344,16 @@ struct efi_simple_file_system_protocol *efi_simple_file_system(
/* open file from device-path: */
struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp);
-
+/**
+ * efi_size_in_pages() - convert size in bytes to size in pages
+ *
+ * This macro returns the number of EFI memory pages required to hold 'size'
+ * bytes.
+ *
+ * @size: size in bytes
+ * Return: size in pages
+ */
+#define efi_size_in_pages(size) ((size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT)
/* Generic EFI memory allocator, call this to get memory */
void *efi_alloc(uint64_t len, int memory_type);
/* More specific EFI memory allocator, called by EFI payloads */