c78952
From 2a6e1d2491b7334985ad25315faa22d26354d8b7 Mon Sep 17 00:00:00 2001
6f1e3d
From: Peter Jones <pjones@redhat.com>
6f1e3d
Date: Thu, 1 Jun 2017 09:59:56 -0400
31cddd
Subject: [PATCH] Add grub_efi_allocate_pool() and grub_efi_free_pool()
6f1e3d
 wrappers.
6f1e3d
6f1e3d
Signed-off-by: Peter Jones <pjones@redhat.com>
6f1e3d
---
6f1e3d
 include/grub/efi/efi.h | 36 ++++++++++++++++++++++++++++++++----
6f1e3d
 1 file changed, 32 insertions(+), 4 deletions(-)
6f1e3d
6f1e3d
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
ec4acb
index 91e29ce66f1..68326d96f5a 100644
6f1e3d
--- a/include/grub/efi/efi.h
6f1e3d
+++ b/include/grub/efi/efi.h
6f1e3d
@@ -24,6 +24,10 @@
6f1e3d
 #include <grub/dl.h>
6f1e3d
 #include <grub/efi/api.h>
6f1e3d
 
6f1e3d
+/* Variables.  */
6f1e3d
+extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
6f1e3d
+extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
6f1e3d
+
6f1e3d
 /* Functions.  */
6f1e3d
 void *EXPORT_FUNC(grub_efi_locate_protocol) (grub_efi_guid_t *protocol,
6f1e3d
 					     void *registration);
6f1e3d
@@ -58,6 +62,33 @@ EXPORT_FUNC(grub_efi_get_memory_map) (grub_efi_uintn_t *memory_map_size,
6f1e3d
 				      grub_efi_uintn_t *map_key,
6f1e3d
 				      grub_efi_uintn_t *descriptor_size,
6f1e3d
 				      grub_efi_uint32_t *descriptor_version);
6f1e3d
+
6f1e3d
+static inline grub_efi_status_t
6f1e3d
+__attribute__((__unused__))
6f1e3d
+grub_efi_allocate_pool (grub_efi_memory_type_t pool_type,
6f1e3d
+			grub_efi_uintn_t buffer_size,
6f1e3d
+			void **buffer)
6f1e3d
+{
6f1e3d
+  grub_efi_boot_services_t *b;
6f1e3d
+  grub_efi_status_t status;
6f1e3d
+
6f1e3d
+  b = grub_efi_system_table->boot_services;
6f1e3d
+  status = efi_call_3 (b->allocate_pool, pool_type, buffer_size, buffer);
6f1e3d
+  return status;
6f1e3d
+}
6f1e3d
+
6f1e3d
+static inline grub_efi_status_t
6f1e3d
+__attribute__((__unused__))
6f1e3d
+grub_efi_free_pool (void *buffer)
6f1e3d
+{
6f1e3d
+  grub_efi_boot_services_t *b;
6f1e3d
+  grub_efi_status_t status;
6f1e3d
+
6f1e3d
+  b = grub_efi_system_table->boot_services;
6f1e3d
+  status = efi_call_1 (b->free_pool, buffer);
6f1e3d
+  return status;
6f1e3d
+}
6f1e3d
+
6f1e3d
 grub_efi_loaded_image_t *EXPORT_FUNC(grub_efi_get_loaded_image) (grub_efi_handle_t image_handle);
6f1e3d
 void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp);
6f1e3d
 char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp);
6f1e3d
@@ -103,10 +134,7 @@ void grub_efi_init (void);
6f1e3d
 void grub_efi_fini (void);
6f1e3d
 void grub_efi_set_prefix (void);
6f1e3d
 
6f1e3d
-/* Variables.  */
6f1e3d
-extern grub_efi_system_table_t *EXPORT_VAR(grub_efi_system_table);
6f1e3d
-extern grub_efi_handle_t EXPORT_VAR(grub_efi_image_handle);
6f1e3d
-
6f1e3d
+/* More variables.  */
6f1e3d
 extern int EXPORT_VAR(grub_efi_is_finished);
6f1e3d
 
6f1e3d
 struct grub_net_card;