]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: Move efi_allocate_pool implementation to efi_memory.c
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Sun, 9 Oct 2016 20:17:18 +0000 (22:17 +0200)
committerAlexander Graf <agraf@suse.de>
Tue, 18 Oct 2016 07:08:07 +0000 (09:08 +0200)
We currently handle efi_allocate_pool() in our boot time service
file. In the following patch, pool allocation will receive additional
internal semantics that we should preserve inside efi_memory.c instead.

As foundation for those changes, split the function into an externally
facing efi_allocate_pool_ext() for use by payloads and an internal helper
efi_allocate_pool() in efi_memory.c that handles the actual allocation.

While at it, change the magic 0xfff / 12 constants to the more obvious
EFI_PAGE_MASK/SHIFT defines.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
include/efi_loader.h
lib/efi_loader/efi_boottime.c
lib/efi_loader/efi_memory.c

index 97388350eb90e87ad32bbb56ed667ce0b14f12c6..f0473aba7cd3b78c719c1d69ea66027886cf2038 100644 (file)
@@ -119,6 +119,9 @@ efi_status_t efi_allocate_pages(int type, int memory_type, unsigned long pages,
                                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,
index a11100f4fcd4bd039b5e6ecf7864660959a76889..05b93e87bfb21b6fbd637f7631484746b4ff8de8 100644 (file)
@@ -130,15 +130,14 @@ efi_status_t EFIAPI efi_get_memory_map_ext(unsigned long *memory_map_size,
        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);
 }
 
@@ -736,7 +735,7 @@ static const struct efi_boot_services efi_boot_services = {
        .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,
index 1d23783020213bf3d3bde7ad05483ae7fe1ec625..be642f12a927ff20193dd703974e98220c20e082 100644 (file)
@@ -327,6 +327,20 @@ efi_status_t efi_free_pages(uint64_t memory, unsigned long pages)
        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,