1485b5cf8SAlexander von Gluck IV // Copyright 2016 The Fuchsia Authors. All rights reserved. 2485b5cf8SAlexander von Gluck IV // Use of this source code is governed by a BSD-style license that can be 3485b5cf8SAlexander von Gluck IV // found in the LICENSE file. 4485b5cf8SAlexander von Gluck IV 5485b5cf8SAlexander von Gluck IV #pragma once 6485b5cf8SAlexander von Gluck IV 7485b5cf8SAlexander von Gluck IV #include <efi/types.h> 8485b5cf8SAlexander von Gluck IV #include <efi/protocol/device-path.h> 9485b5cf8SAlexander von Gluck IV #include <stdbool.h> 10485b5cf8SAlexander von Gluck IV 11485b5cf8SAlexander von Gluck IV #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 12485b5cf8SAlexander von Gluck IV #define EFI_BOOT_SERVICES_REVISION EFI_SPECIFICATION_VERSION 13485b5cf8SAlexander von Gluck IV 14485b5cf8SAlexander von Gluck IV typedef size_t efi_tpl; 15485b5cf8SAlexander von Gluck IV 16485b5cf8SAlexander von Gluck IV #define TPL_APPLICATION 4 17485b5cf8SAlexander von Gluck IV #define TPL_CALLBACK 8 18485b5cf8SAlexander von Gluck IV #define TPL_NOTIFY 16 19485b5cf8SAlexander von Gluck IV #define TPL_HIGH_LEVEL 31 20485b5cf8SAlexander von Gluck IV 21485b5cf8SAlexander von Gluck IV typedef enum { 22485b5cf8SAlexander von Gluck IV AllocateAnyPages, 23485b5cf8SAlexander von Gluck IV AllocateMaxAddress, 24485b5cf8SAlexander von Gluck IV AllocateAddress, 25485b5cf8SAlexander von Gluck IV MaxAllocateType 26485b5cf8SAlexander von Gluck IV } efi_allocate_type; 27485b5cf8SAlexander von Gluck IV 28485b5cf8SAlexander von Gluck IV typedef struct { 29485b5cf8SAlexander von Gluck IV uint32_t Type; 30*2db2b212SHan Pengfei uint32_t Padding; 31485b5cf8SAlexander von Gluck IV efi_physical_addr PhysicalStart; 32485b5cf8SAlexander von Gluck IV efi_virtual_addr VirtualStart; 33485b5cf8SAlexander von Gluck IV uint64_t NumberOfPages; 34485b5cf8SAlexander von Gluck IV uint64_t Attribute; 35485b5cf8SAlexander von Gluck IV } efi_memory_descriptor; 36485b5cf8SAlexander von Gluck IV 37485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_UC 0x0000000000000001 38485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_WC 0x0000000000000002 39485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_WT 0x0000000000000004 40485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_WB 0x0000000000000008 41485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_UCE 0x0000000000000010 42485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_WP 0x0000000000001000 43485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_RP 0x0000000000002000 44485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_XP 0x0000000000004000 45485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_NV 0x0000000000008000 46485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000 47485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_RO 0x0000000000020000 48485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_RUNTIME 0x8000000000000000 49485b5cf8SAlexander von Gluck IV 50485b5cf8SAlexander von Gluck IV #define EFI_MEMORY_DESCRIPTOR_VERSION 1 51485b5cf8SAlexander von Gluck IV 52485b5cf8SAlexander von Gluck IV typedef enum { 53485b5cf8SAlexander von Gluck IV EFI_NATIVE_INTERFACE 54485b5cf8SAlexander von Gluck IV } efi_interface_type; 55485b5cf8SAlexander von Gluck IV 56485b5cf8SAlexander von Gluck IV typedef enum { 57485b5cf8SAlexander von Gluck IV AllHandles, 58485b5cf8SAlexander von Gluck IV ByRegisterNotify, 59485b5cf8SAlexander von Gluck IV ByProtocol 60485b5cf8SAlexander von Gluck IV } efi_locate_search_type; 61485b5cf8SAlexander von Gluck IV 62485b5cf8SAlexander von Gluck IV #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 63485b5cf8SAlexander von Gluck IV #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 64485b5cf8SAlexander von Gluck IV #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 65485b5cf8SAlexander von Gluck IV #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 66485b5cf8SAlexander von Gluck IV #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 67485b5cf8SAlexander von Gluck IV #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 68485b5cf8SAlexander von Gluck IV 69485b5cf8SAlexander von Gluck IV typedef struct { 70485b5cf8SAlexander von Gluck IV efi_handle agent_handle; 71485b5cf8SAlexander von Gluck IV efi_handle controller_handle; 72485b5cf8SAlexander von Gluck IV uint32_t attributes; 73485b5cf8SAlexander von Gluck IV uint32_t open_count; 74485b5cf8SAlexander von Gluck IV } efi_open_protocol_information_entry; 75485b5cf8SAlexander von Gluck IV 76485b5cf8SAlexander von Gluck IV #define EFI_HII_PACKAGE_LIST_PROTOCOL_GUID \ 77485b5cf8SAlexander von Gluck IV {0x6a1ee763, 0xd47a, 0x43b4, {0xaa, 0xbe, 0xef, 0x1d, 0xe2, 0xab, 0x56, 0xfc}} 78485b5cf8SAlexander von Gluck IV 79485b5cf8SAlexander von Gluck IV typedef struct efi_hii_package_list_header efi_hii_package_list_header; 80485b5cf8SAlexander von Gluck IV typedef efi_hii_package_list_header* efi_hii_package_list_protocol; 81485b5cf8SAlexander von Gluck IV 82485b5cf8SAlexander von Gluck IV // fwd declare efi_system_table to break circular dependencies 83485b5cf8SAlexander von Gluck IV typedef struct efi_system_table efi_system_table; 84485b5cf8SAlexander von Gluck IV typedef efi_status (*efi_image_entry_point) (efi_handle img, efi_system_table* sys) EFIAPI; 85485b5cf8SAlexander von Gluck IV 86485b5cf8SAlexander von Gluck IV typedef struct { 87485b5cf8SAlexander von Gluck IV efi_table_header Hdr; 88485b5cf8SAlexander von Gluck IV 89485b5cf8SAlexander von Gluck IV efi_tpl (*RaiseTPL) (efi_tpl new_tpl) EFIAPI; 90485b5cf8SAlexander von Gluck IV 91485b5cf8SAlexander von Gluck IV void (*RestoreTPL) (efi_tpl old_tpl) EFIAPI; 92485b5cf8SAlexander von Gluck IV 93485b5cf8SAlexander von Gluck IV efi_status (*AllocatePages) (efi_allocate_type type, efi_memory_type memory_type, 94485b5cf8SAlexander von Gluck IV size_t pages, efi_physical_addr* memory) EFIAPI; 95485b5cf8SAlexander von Gluck IV 96485b5cf8SAlexander von Gluck IV efi_status (*FreePages) (efi_physical_addr memory, size_t pages) EFIAPI; 97485b5cf8SAlexander von Gluck IV 98485b5cf8SAlexander von Gluck IV efi_status (*GetMemoryMap) (size_t* memory_map_size, efi_memory_descriptor* memory_map, 99485b5cf8SAlexander von Gluck IV size_t* map_key, size_t* desc_size, uint32_t* desc_version) EFIAPI; 100485b5cf8SAlexander von Gluck IV 101485b5cf8SAlexander von Gluck IV efi_status (*AllocatePool) (efi_memory_type pool_type, size_t size, void** buf) EFIAPI; 102485b5cf8SAlexander von Gluck IV 103485b5cf8SAlexander von Gluck IV efi_status (*FreePool) (void* buf) EFIAPI; 104485b5cf8SAlexander von Gluck IV 105485b5cf8SAlexander von Gluck IV efi_status (*CreateEvent) (uint32_t type, efi_tpl notify_tpl, 106485b5cf8SAlexander von Gluck IV efi_event_notify notify_fn, void* notify_ctx, 107485b5cf8SAlexander von Gluck IV efi_event* event) EFIAPI; 108485b5cf8SAlexander von Gluck IV 109485b5cf8SAlexander von Gluck IV efi_status (*SetTimer) (efi_event event, efi_timer_delay type, uint64_t trigger_time) EFIAPI; 110485b5cf8SAlexander von Gluck IV 111485b5cf8SAlexander von Gluck IV efi_status (*WaitForEvent) (size_t num_events, efi_event* event, size_t* index) EFIAPI; 112485b5cf8SAlexander von Gluck IV 113485b5cf8SAlexander von Gluck IV efi_status (*SignalEvent) (efi_event event) EFIAPI; 114485b5cf8SAlexander von Gluck IV 115485b5cf8SAlexander von Gluck IV efi_status (*CloseEvent) (efi_event event) EFIAPI; 116485b5cf8SAlexander von Gluck IV 117485b5cf8SAlexander von Gluck IV efi_status (*CheckEvent) (efi_event event) EFIAPI; 118485b5cf8SAlexander von Gluck IV 119485b5cf8SAlexander von Gluck IV efi_status (*InstallProtocolInterface) (efi_handle* handle, efi_guid* protocol, 120485b5cf8SAlexander von Gluck IV efi_interface_type intf_type, void* intf) EFIAPI; 121485b5cf8SAlexander von Gluck IV 122485b5cf8SAlexander von Gluck IV efi_status (*ReinstallProtocolInterface) (efi_handle hadle, efi_guid* protocol, 123485b5cf8SAlexander von Gluck IV void* old_intf, void* new_intf) EFIAPI; 124485b5cf8SAlexander von Gluck IV 125485b5cf8SAlexander von Gluck IV efi_status (*UninstallProtocolInterface) (efi_handle handle, efi_guid* protocol, 126485b5cf8SAlexander von Gluck IV void* intf) EFIAPI; 127485b5cf8SAlexander von Gluck IV 128485b5cf8SAlexander von Gluck IV efi_status (*HandleProtocol) (efi_handle handle, efi_guid* protocol, void** intf) EFIAPI; 129485b5cf8SAlexander von Gluck IV 130485b5cf8SAlexander von Gluck IV void* Reserved; 131485b5cf8SAlexander von Gluck IV 132485b5cf8SAlexander von Gluck IV efi_status (*RegisterProtocolNotify) (efi_guid* protocol, efi_event event, 133485b5cf8SAlexander von Gluck IV void** registration) EFIAPI; 134485b5cf8SAlexander von Gluck IV 135485b5cf8SAlexander von Gluck IV efi_status (*LocateHandle) (efi_locate_search_type search_type, efi_guid* protocol, 136485b5cf8SAlexander von Gluck IV void* search_key, size_t* buf_size, efi_handle* buf) EFIAPI; 137485b5cf8SAlexander von Gluck IV 138485b5cf8SAlexander von Gluck IV efi_status (*LocateDevicePath) (efi_guid* protocol, efi_device_path_protocol** path, 139485b5cf8SAlexander von Gluck IV efi_handle* device) EFIAPI; 140485b5cf8SAlexander von Gluck IV 141485b5cf8SAlexander von Gluck IV efi_status (*InstallConfigurationTable) (efi_guid* guid, void* table) EFIAPI; 142485b5cf8SAlexander von Gluck IV 143485b5cf8SAlexander von Gluck IV efi_status (*LoadImage) (bool boot_policy, efi_handle parent_image_handle, 144485b5cf8SAlexander von Gluck IV efi_device_path_protocol* path, void* src, size_t src_size, 145485b5cf8SAlexander von Gluck IV efi_handle* image_handle) EFIAPI; 146485b5cf8SAlexander von Gluck IV 147485b5cf8SAlexander von Gluck IV efi_status (*StartImage) (efi_handle image_handle, size_t* exit_data_size, 148485b5cf8SAlexander von Gluck IV char16_t** exit_data) EFIAPI; 149485b5cf8SAlexander von Gluck IV 150485b5cf8SAlexander von Gluck IV efi_status (*Exit) (efi_handle image_handle, efi_status exit_status, 151485b5cf8SAlexander von Gluck IV size_t exit_data_size, char16_t* exit_data) EFIAPI; 152485b5cf8SAlexander von Gluck IV 153485b5cf8SAlexander von Gluck IV efi_status (*UnloadImage) (efi_handle image_handle) EFIAPI; 154485b5cf8SAlexander von Gluck IV 155485b5cf8SAlexander von Gluck IV efi_status (*ExitBootServices) (efi_handle image_handle, size_t map_key) EFIAPI; 156485b5cf8SAlexander von Gluck IV 157485b5cf8SAlexander von Gluck IV efi_status (*GetNextMonotonicCount) (uint64_t* count) EFIAPI; 158485b5cf8SAlexander von Gluck IV 159485b5cf8SAlexander von Gluck IV efi_status (*Stall) (size_t microseconds) EFIAPI; 160485b5cf8SAlexander von Gluck IV 161485b5cf8SAlexander von Gluck IV efi_status (*SetWatchdogTimer) (size_t timeout, uint64_t watchdog_code, 162485b5cf8SAlexander von Gluck IV size_t data_size, char16_t* watchdog_data) EFIAPI; 163485b5cf8SAlexander von Gluck IV 164485b5cf8SAlexander von Gluck IV efi_status (*ConnectController) (efi_handle controller_handle, 165485b5cf8SAlexander von Gluck IV efi_handle* driver_image_handle, 166485b5cf8SAlexander von Gluck IV efi_device_path_protocol* remaining_path, 167485b5cf8SAlexander von Gluck IV bool recursive) EFIAPI; 168485b5cf8SAlexander von Gluck IV 169485b5cf8SAlexander von Gluck IV efi_status (*DisconnectController) (efi_handle controller_handle, 170485b5cf8SAlexander von Gluck IV efi_handle driver_image_handle, 171485b5cf8SAlexander von Gluck IV efi_handle child_handle) EFIAPI; 172485b5cf8SAlexander von Gluck IV 173485b5cf8SAlexander von Gluck IV efi_status (*OpenProtocol) (efi_handle handle, efi_guid* protocol, void** intf, 174485b5cf8SAlexander von Gluck IV efi_handle agent_handle, efi_handle controller_handle, 175485b5cf8SAlexander von Gluck IV uint32_t attributes) EFIAPI; 176485b5cf8SAlexander von Gluck IV 177485b5cf8SAlexander von Gluck IV efi_status (*CloseProtocol) (efi_handle handle, efi_guid* protocol, 178485b5cf8SAlexander von Gluck IV efi_handle agent_handle, efi_handle controller_handle) EFIAPI; 179485b5cf8SAlexander von Gluck IV 180485b5cf8SAlexander von Gluck IV efi_status (*OpenProtocolInformation) (efi_handle handle, efi_guid* protocol, 181485b5cf8SAlexander von Gluck IV efi_open_protocol_information_entry** entry_buf, 182485b5cf8SAlexander von Gluck IV size_t* entry_count) EFIAPI; 183485b5cf8SAlexander von Gluck IV 184485b5cf8SAlexander von Gluck IV efi_status (*ProtocolsPerHandle) (efi_handle handle, efi_guid*** protocol_buf, 185485b5cf8SAlexander von Gluck IV size_t* protocol_buf_count) EFIAPI; 186485b5cf8SAlexander von Gluck IV 187485b5cf8SAlexander von Gluck IV efi_status (*LocateHandleBuffer) (efi_locate_search_type search_type, 188485b5cf8SAlexander von Gluck IV efi_guid* protocol, void* search_key, 189485b5cf8SAlexander von Gluck IV size_t* num_handles, efi_handle** buf) EFIAPI; 190485b5cf8SAlexander von Gluck IV 191485b5cf8SAlexander von Gluck IV efi_status (*LocateProtocol) (efi_guid* protocol, void* registration, void** intf) EFIAPI; 192485b5cf8SAlexander von Gluck IV 193485b5cf8SAlexander von Gluck IV efi_status (*InstallMultipleProtocolInterfaces) (efi_handle* handle, ...) EFIAPI; 194485b5cf8SAlexander von Gluck IV 195485b5cf8SAlexander von Gluck IV efi_status (*UninstallMultipleProtocolInterfaces) (efi_handle handle, ...) EFIAPI; 196485b5cf8SAlexander von Gluck IV 197485b5cf8SAlexander von Gluck IV efi_status (*CalculateCrc32) (void* data, size_t len, uint32_t* crc32) EFIAPI; 198485b5cf8SAlexander von Gluck IV 199485b5cf8SAlexander von Gluck IV void (*CopyMem) (void* dest, const void* src, size_t len) EFIAPI; 200485b5cf8SAlexander von Gluck IV 201485b5cf8SAlexander von Gluck IV void (*SetMem) (void* buf, size_t len, uint8_t val) EFIAPI; 202485b5cf8SAlexander von Gluck IV 203485b5cf8SAlexander von Gluck IV efi_status (*CreateEventEx) (uint32_t type, efi_tpl notify_tpl, 204485b5cf8SAlexander von Gluck IV efi_event_notify notify_fn, const void* notify_ctx, 205485b5cf8SAlexander von Gluck IV const efi_guid* event_group, efi_event* event) EFIAPI; 206485b5cf8SAlexander von Gluck IV } efi_boot_services; 207