uint64_t *memory);
/* EFI memory free function. Not implemented today */
efi_status_t efi_free_pages(uint64_t memory, unsigned long pages);
+/* EFI memory allocator for small allocations */
+efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
+ void **buffer);
/* Returns the EFI memory map */
efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
struct efi_mem_desc *memory_map,
return EFI_EXIT(r);
}
-static efi_status_t EFIAPI efi_allocate_pool(int pool_type, unsigned long size,
- void **buffer)
+static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type,
+ unsigned long size,
+ void **buffer)
{
efi_status_t r;
- efi_physical_addr_t t;
EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
- r = efi_allocate_pages(0, pool_type, (size + 0xfff) >> 12, &t);
- *buffer = (void *)(uintptr_t)t;
+ r = efi_allocate_pool(pool_type, size, buffer);
return EFI_EXIT(r);
}
.allocate_pages = efi_allocate_pages_ext,
.free_pages = efi_free_pages_ext,
.get_memory_map = efi_get_memory_map_ext,
- .allocate_pool = efi_allocate_pool,
+ .allocate_pool = efi_allocate_pool_ext,
.free_pool = efi_free_pool,
.create_event = efi_create_event,
.set_timer = efi_set_timer,
return EFI_SUCCESS;
}
+efi_status_t efi_allocate_pool(int pool_type, unsigned long size,
+ void **buffer)
+{
+ efi_status_t r;
+ efi_physical_addr_t t;
+ u64 num_pages = (size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
+
+ r = efi_allocate_pages(0, pool_type, num_pages, &t);
+ if (r == EFI_SUCCESS)
+ *buffer = (void *)(uintptr_t)t;
+
+ return r;
+}
+
efi_status_t efi_get_memory_map(unsigned long *memory_map_size,
struct efi_mem_desc *memory_map,
unsigned long *map_key,