|
@@ -1020,6 +1020,28 @@ extern int efi_memattr_init(void);
|
|
|
extern int efi_memattr_apply_permissions(struct mm_struct *mm,
|
|
|
efi_memattr_perm_setter fn);
|
|
|
|
|
|
+/*
|
|
|
+ * efi_early_memdesc_ptr - get the n-th EFI memmap descriptor
|
|
|
+ * @map: the start of efi memmap
|
|
|
+ * @desc_size: the size of space for each EFI memmap descriptor
|
|
|
+ * @n: the index of efi memmap descriptor
|
|
|
+ *
|
|
|
+ * EFI boot service provides the GetMemoryMap() function to get a copy of the
|
|
|
+ * current memory map which is an array of memory descriptors, each of
|
|
|
+ * which describes a contiguous block of memory. It also gets the size of the
|
|
|
+ * map, and the size of each descriptor, etc.
|
|
|
+ *
|
|
|
+ * Note that per section 6.2 of UEFI Spec 2.6 Errata A, the returned size of
|
|
|
+ * each descriptor might not be equal to sizeof(efi_memory_memdesc_t),
|
|
|
+ * since efi_memory_memdesc_t may be extended in the future. Thus the OS
|
|
|
+ * MUST use the returned size of the descriptor to find the start of each
|
|
|
+ * efi_memory_memdesc_t in the memory map array. This should only be used
|
|
|
+ * during bootup since for_each_efi_memory_desc_xxx() is available after the
|
|
|
+ * kernel initializes the EFI subsystem to set up struct efi_memory_map.
|
|
|
+ */
|
|
|
+#define efi_early_memdesc_ptr(map, desc_size, n) \
|
|
|
+ (efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size)))
|
|
|
+
|
|
|
/* Iterate through an efi_memory_map */
|
|
|
#define for_each_efi_memory_desc_in_map(m, md) \
|
|
|
for ((md) = (m)->map; \
|