1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #ifndef __BOOT_SERVICE_TABLE_H__ 19 #define __BOOT_SERVICE_TABLE_H__ 20 21 #include "protocols/device_path_protocol.h" 22 #include "types.h" 23 24 typedef enum EFI_LOCATE_HANDLE_SEARCH_TYPE { 25 ALL_HANDLES = 0, 26 BY_REGITER_NOTIFY, 27 BY_PROTOCOL, 28 } EFI_LOCATE_HANDLE_SEARCH_TYPE; 29 30 typedef EFI_LOCATE_HANDLE_SEARCH_TYPE EfiLocateHandleSearchType; 31 32 typedef enum { EFI_NATIVE_INTERFACE } EFI_INTERFACE_TYPE; 33 34 typedef EFI_INTERFACE_TYPE EfiInterfaceType; 35 36 typedef enum EFI_ALLOCATOR_TYPE { 37 ALLOCATE_ANY_PAGES, 38 ALLOCATE_MAX_ADDRESS, 39 ALLOCATE_ADDRESS, 40 MAX_ALLOCATE_TYPE 41 } EfiAllocatorType; 42 43 typedef enum EFI_OPEN_PROTOCOL_ATTRIBUTE : uint32_t { 44 BY_HANDLE_PROTOCOL = 0x00000001, 45 GET_PROTOCOL = 0x00000002, 46 TEST_PROTOCOL = 0x00000004, 47 BY_CHILD_CONTROLLER = 0x00000008, 48 BY_DRIVER = 0x00000010, 49 EXCLUSIVE = 0x00000020, 50 } EfiOpenProtocolAttributes; 51 52 typedef struct { 53 EfiHandle agent_handle; 54 EfiHandle controller_handle; 55 uint32_t attributes; 56 uint32_t open_count; 57 } EfiOpenProtocolInformationEntry; 58 59 typedef struct { 60 EfiTableHeader hdr; 61 EfiTpl (*raise_tpl)(EfiTpl new_tpl); 62 void (*restore_tpl)(EfiTpl old_tpl); 63 EfiStatus (*allocate_pages)(EfiAllocatorType type, EfiMemoryType memory_type, size_t pages, 64 EfiPhysicalAddr* memory); 65 EfiStatus (*free_pages)(EfiPhysicalAddr memory, size_t pages); 66 EfiStatus (*get_memory_map)(size_t* memory_map_size, EfiMemoryDescriptor* memory_map, 67 size_t* map_key, size_t* desc_size, uint32_t* desc_version); 68 EfiStatus (*allocate_pool)(EfiMemoryType pool_type, size_t size, void** buf); 69 EfiStatus (*free_pool)(void* buf); 70 EfiStatus (*create_event)(uint32_t type, EfiTpl notify_tpl, EfiEventNotify notify_fn, 71 void* notify_ctx, EfiEvent* event); 72 EfiStatus (*set_timer)(EfiEvent event, EfiTimerDelay type, uint64_t trigger_time); 73 EfiStatus (*wait_for_event)(size_t num_events, EfiEvent* event, size_t* index); 74 EfiStatus (*signal_event)(EfiEvent event); 75 EfiStatus (*close_event)(EfiEvent event); 76 EfiStatus (*check_event)(EfiEvent event); 77 EfiStatus (*install_protocol_interface)(EfiHandle* handle, const EfiGuid* protocol, 78 EfiInterfaceType intf_type, void* intf); 79 EfiStatus (*reinstall_protocol_interface)(EfiHandle hadle, const EfiGuid* protocol, 80 void* old_intf, void* new_intf); 81 EfiStatus (*uninstall_protocol_interface)(EfiHandle handle, const EfiGuid* protocol, void* intf); 82 EfiStatus (*handle_protocol)(EfiHandle handle, const EfiGuid* protocol, void** intf); 83 void* reserved; 84 EfiStatus (*register_protocol_notify)(const EfiGuid* protocol, EfiEvent event, 85 void** registration); 86 EfiStatus (*locate_handle)(EfiLocateHandleSearchType search_type, const EfiGuid* protocol, 87 void* search_key, size_t* buf_size, EfiHandle* buf); 88 EfiStatus (*locate_device_path)(const EfiGuid* protocol, EfiDevicePathProtocol** path, 89 EfiHandle* device); 90 EfiStatus (*install_configuration_table)(const EfiGuid* guid, void* table); 91 EfiStatus (*load_image)(bool boot_policy, EfiHandle parent_image_handle, 92 EfiDevicePathProtocol* path, void* src, size_t src_size, 93 EfiHandle* image_handle); 94 EfiStatus (*start_image)(EfiHandle image_handle, size_t* exit_data_size, char16_t** exit_data); 95 EfiStatus (*exit)(EfiHandle image_handle, EfiStatus exit_status, size_t exit_data_size, 96 char16_t* exit_data); 97 EfiStatus (*unload_image)(EfiHandle image_handle); 98 EfiStatus (*exit_boot_services)(EfiHandle image_handle, size_t map_key); 99 EfiStatus (*get_next_monotonic_count)(uint64_t* count); 100 EfiStatus (*stall)(size_t microseconds); 101 EfiStatus (*set_watchdog_timer)(size_t timeout, uint64_t watchdog_code, size_t data_size, 102 char16_t* watchdog_data); 103 EfiStatus (*connect_controller)(EfiHandle controller_handle, EfiHandle* driver_image_handle, 104 EfiDevicePathProtocol* remaining_path, bool recursive); 105 EfiStatus (*disconnect_controller)(EfiHandle controller_handle, EfiHandle driver_image_handle, 106 EfiHandle child_handle); 107 EfiStatus (*open_protocol)(EfiHandle handle, const EfiGuid* protocol, void** intf, 108 EfiHandle agent_handle, EfiHandle controller_handle, 109 EfiOpenProtocolAttributes attr); 110 EfiStatus (*close_protocol)(EfiHandle handle, const EfiGuid* protocol, EfiHandle agent_handle, 111 EfiHandle controller_handle); 112 EfiStatus (*open_protocol_information)(EfiHandle handle, const EfiGuid* protocol, 113 EfiOpenProtocolInformationEntry** entry_buf, 114 size_t* entry_count); 115 EfiStatus (*protocols_per_handle)(EfiHandle handle, EfiGuid*** protocol_buf, 116 size_t* protocol_buf_count); 117 EfiStatus (*locate_handle_buffer)(EfiLocateHandleSearchType search_type, const EfiGuid* protocol, 118 void* search_key, size_t* num_handles, EfiHandle** buf); 119 EfiStatus (*locate_protocol)(const EfiGuid* protocol, void* registration, void** intf); 120 EfiStatus (*install_multiple_protocol_interfaces)(EfiHandle* handle, ...); 121 EfiStatus (*uninstall_multiple_protocol_interfaces)(EfiHandle handle, ...); 122 EfiStatus (*calculate_crc32)(void* data, size_t len, uint32_t* crc32); 123 void (*copy_mem)(void* dest, const void* src, size_t len); 124 void (*set_mem)(void* buf, size_t len, uint8_t val); 125 EfiStatus (*create_event_ex)(EfiEventType type, EfiTpl notify_tpl, EfiEventNotify notify_fn, 126 const void* notify_ctx, const EfiGuid* event_group, EfiEvent* event); 127 } EfiBootService; 128 129 #endif // __BOOT_SERVICE_TABLE_H__