From 3767a07d8e8051997a266264819c7cf24a7a3d4f Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sat, 22 Feb 2020 14:26:52 -0800 Subject: [PATCH] Add allocate_pages to boot services --- include/uefi/boot_services.h | 6 ++++-- include/uefi/types.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/uefi/boot_services.h b/include/uefi/boot_services.h index 5997e93..441d158 100644 --- a/include/uefi/boot_services.h +++ b/include/uefi/boot_services.h @@ -9,10 +9,12 @@ #include #include +#include namespace uefi { namespace bs_impl { - using locate_protocol = uefi::status (*)(const uefi::guid *, void *, void **); + using allocate_pages = status (*)(allocate_type, memory_type, uint64_t, uintptr_t*); + using locate_protocol = status (*)(const guid *, void *, void **); } struct boot_services { @@ -25,7 +27,7 @@ struct boot_services { void *restore_tpl; // Memory Services - void *allocate_pages; + bs_impl::allocate_pages allocate_pages; void *free_pages; void *get_memory_map; void *allocate_pool; diff --git a/include/uefi/types.h b/include/uefi/types.h index 5ab9960..015db34 100644 --- a/include/uefi/types.h +++ b/include/uefi/types.h @@ -28,6 +28,34 @@ enum class status : uint64_t }; inline bool is_error(status s) { return static_cast(s) & error_bit; } +inline bool is_warning(status s) { return !is_error(s) && s != status::success; } + +enum class memory_type : uint32_t +{ + reserved_memory_type, + loader_code, + loader_data, + boot_services_code, + boot_services_data, + runtime_services_code, + runtime_services_data, + conventional_memory, + unusable_memory, + acpi_reclaim_memory, + acpi_memory_nvs, + memory_mapped_io, + memory_mapped_io_port_space, + pal_code, + persistent_memory, + max_memory_type +}; + +enum class allocate_type : uint32_t +{ + any_pages, + max_address, + address +}; } // namespace uefi