"Das U-Boot" Source Tree
at master 2386 lines 76 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Extensible Firmware Interface 4 * Based on 'Extensible Firmware Interface Specification' version 0.9, 5 * April 30, 1999 6 * 7 * Copyright (C) 1999 VA Linux Systems 8 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com> 9 * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co. 10 * David Mosberger-Tang <davidm@hpl.hp.com> 11 * Stephane Eranian <eranian@hpl.hp.com> 12 * 13 * From include/linux/efi.h in kernel 4.1 with some additions/subtractions 14 */ 15 16#ifndef _EFI_API_H 17#define _EFI_API_H 18 19#include <efi.h> 20#include <charset.h> 21#include <pe.h> 22 23/** 24 * define EFI_SPECIFICATION_VERSION - UEFI specification version 25 */ 26#define EFI_SPECIFICATION_VERSION (2 << 16 | 110) 27 28/* Types and defines for EFI CreateEvent */ 29enum efi_timer_delay { 30 EFI_TIMER_STOP = 0, 31 EFI_TIMER_PERIODIC = 1, 32 EFI_TIMER_RELATIVE = 2 33}; 34 35typedef void *efi_hii_handle_t; 36typedef u16 *efi_string_t; 37typedef u16 efi_string_id_t; 38typedef u32 efi_hii_font_style_t; 39typedef u16 efi_question_id_t; 40typedef u16 efi_image_id_t; 41typedef u16 efi_form_id_t; 42 43#define EVT_TIMER 0x80000000 44#define EVT_RUNTIME 0x40000000 45#define EVT_NOTIFY_WAIT 0x00000100 46#define EVT_NOTIFY_SIGNAL 0x00000200 47#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 48#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 49 50#define TPL_APPLICATION 0x04 51#define TPL_CALLBACK 0x08 52#define TPL_NOTIFY 0x10 53#define TPL_HIGH_LEVEL 0x1F 54 55struct efi_event; 56 57/* OsIndicationsSupported flags */ 58#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001 59#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002 60#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004 61#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008 62#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010 63#define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020 64#define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY 0x0000000000000040 65#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH 0x0000000000000080 66 67/* EFI Boot Services table */ 68#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42 69struct efi_boot_services { 70 struct efi_table_hdr hdr; 71 efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl); 72 void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl); 73 74 efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t, 75 efi_physical_addr_t *); 76 efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t); 77 efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size, 78 struct efi_mem_desc *desc, 79 efi_uintn_t *key, 80 efi_uintn_t *desc_size, 81 u32 *desc_version); 82 efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **); 83 efi_status_t (EFIAPI *free_pool)(void *); 84 85 efi_status_t (EFIAPI *create_event)(uint32_t type, 86 efi_uintn_t notify_tpl, 87 void (EFIAPI *notify_function) ( 88 struct efi_event *event, 89 void *context), 90 void *notify_context, struct efi_event **event); 91 efi_status_t (EFIAPI *set_timer)(struct efi_event *event, 92 enum efi_timer_delay type, 93 uint64_t trigger_time); 94 efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events, 95 struct efi_event **event, 96 efi_uintn_t *index); 97 efi_status_t (EFIAPI *signal_event)(struct efi_event *event); 98 efi_status_t (EFIAPI *close_event)(struct efi_event *event); 99 efi_status_t (EFIAPI *check_event)(struct efi_event *event); 100#define EFI_NATIVE_INTERFACE 0x00000000 101 efi_status_t (EFIAPI *install_protocol_interface)( 102 efi_handle_t *handle, const efi_guid_t *protocol, 103 int protocol_interface_type, void *protocol_interface); 104 efi_status_t (EFIAPI *reinstall_protocol_interface)( 105 efi_handle_t handle, const efi_guid_t *protocol, 106 void *old_interface, void *new_interface); 107 efi_status_t (EFIAPI *uninstall_protocol_interface)( 108 efi_handle_t handle, const efi_guid_t *protocol, 109 void *protocol_interface); 110 efi_status_t (EFIAPI *handle_protocol)( 111 efi_handle_t handle, const efi_guid_t *protocol, 112 void **protocol_interface); 113 void *reserved; 114 efi_status_t (EFIAPI *register_protocol_notify)( 115 const efi_guid_t *protocol, struct efi_event *event, 116 void **registration); 117 efi_status_t (EFIAPI *locate_handle)( 118 enum efi_locate_search_type search_type, 119 const efi_guid_t *protocol, void *search_key, 120 efi_uintn_t *buffer_size, efi_handle_t *buffer); 121 efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol, 122 struct efi_device_path **device_path, 123 efi_handle_t *device); 124 efi_status_t (EFIAPI *install_configuration_table)( 125 const efi_guid_t *guid, void *table); 126 127 efi_status_t (EFIAPI *load_image)(bool boot_policiy, 128 efi_handle_t parent_image, 129 struct efi_device_path *file_path, void *source_buffer, 130 efi_uintn_t source_size, efi_handle_t *image); 131 efi_status_t (EFIAPI *start_image)(efi_handle_t handle, 132 efi_uintn_t *exitdata_size, 133 u16 **exitdata); 134 efi_status_t (EFIAPI *exit)(efi_handle_t handle, 135 efi_status_t exit_status, 136 efi_uintn_t exitdata_size, u16 *exitdata); 137 efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle); 138 efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t image_handle, 139 efi_uintn_t map_key); 140 141 efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count); 142 efi_status_t (EFIAPI *stall)(unsigned long usecs); 143 efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout, 144 uint64_t watchdog_code, unsigned long data_size, 145 uint16_t *watchdog_data); 146 efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle, 147 efi_handle_t *driver_image_handle, 148 struct efi_device_path *remaining_device_path, 149 bool recursive); 150 efi_status_t (EFIAPI *disconnect_controller)( 151 efi_handle_t controller_handle, 152 efi_handle_t driver_image_handle, 153 efi_handle_t child_handle); 154#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 155#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 156#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 157#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 158#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 159#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 160 efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle, 161 const efi_guid_t *protocol, void **interface, 162 efi_handle_t agent_handle, 163 efi_handle_t controller_handle, u32 attributes); 164 efi_status_t (EFIAPI *close_protocol)( 165 efi_handle_t handle, const efi_guid_t *protocol, 166 efi_handle_t agent_handle, 167 efi_handle_t controller_handle); 168 efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle, 169 const efi_guid_t *protocol, 170 struct efi_open_protocol_info_entry **entry_buffer, 171 efi_uintn_t *entry_count); 172 efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle, 173 efi_guid_t ***protocol_buffer, 174 efi_uintn_t *protocols_buffer_count); 175 efi_status_t (EFIAPI *locate_handle_buffer) ( 176 enum efi_locate_search_type search_type, 177 const efi_guid_t *protocol, void *search_key, 178 efi_uintn_t *no_handles, efi_handle_t **buffer); 179 efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol, 180 void *registration, void **protocol_interface); 181 efi_status_t (EFIAPI *install_multiple_protocol_interfaces)( 182 efi_handle_t *handle, ...); 183 efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)( 184 efi_handle_t handle, ...); 185 efi_status_t (EFIAPI *calculate_crc32)(const void *data, 186 efi_uintn_t data_size, 187 u32 *crc32); 188 void (EFIAPI *copy_mem)(void *destination, const void *source, 189 size_t length); 190 void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value); 191 efi_status_t (EFIAPI *create_event_ex)( 192 uint32_t type, efi_uintn_t notify_tpl, 193 void (EFIAPI *notify_function) ( 194 struct efi_event *event, 195 void *context), 196 void *notify_context, 197 const efi_guid_t *event_group, 198 struct efi_event **event); 199}; 200 201/* Types and defines for EFI ResetSystem */ 202enum efi_reset_type { 203 EFI_RESET_COLD = 0, 204 EFI_RESET_WARM = 1, 205 EFI_RESET_SHUTDOWN = 2, 206 EFI_RESET_PLATFORM_SPECIFIC = 3, 207}; 208 209/* EFI Runtime Services table */ 210#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL 211 212#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 213#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 214#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 215 216#define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001 217#define CAPSULE_SUPPORT_DEPENDENCY 0x0000000000000002 218 219#define EFI_CAPSULE_REPORT_GUID \ 220 EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \ 221 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3) 222 223#define EFI_MEMORY_RANGE_CAPSULE_GUID \ 224 EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \ 225 0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72) 226 227#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \ 228 EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 229 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a) 230 231#define EFI_CONFORMANCE_PROFILES_TABLE_GUID \ 232 EFI_GUID(0x36122546, 0xf7e7, 0x4c8f, 0xbd, 0x9b, \ 233 0xeb, 0x85, 0x25, 0xb5, 0x0c, 0x0b) 234 235#define EFI_CONFORMANCE_PROFILES_TABLE_VERSION 1 236 237#define EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID \ 238 EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \ 239 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27) 240 241struct efi_conformance_profiles_table { 242 u16 version; 243 u16 number_of_profiles; 244 efi_guid_t conformance_profiles[]; 245} __packed; 246 247struct efi_capsule_header { 248 efi_guid_t capsule_guid; 249 u32 header_size; 250 u32 flags; 251 u32 capsule_image_size; 252} __packed; 253 254struct efi_capsule_result_variable_header { 255 u32 variable_total_size; 256 u32 reserved; 257 efi_guid_t capsule_guid; 258 struct efi_time capsule_processed; 259 efi_status_t capsule_status; 260} __packed; 261 262struct efi_memory_range { 263 efi_physical_addr_t address; 264 u64 length; 265}; 266 267struct efi_memory_range_capsule { 268 struct efi_capsule_header *header; 269 /* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */ 270 enum efi_memory_type os_requested_memory_type; 271 u64 number_of_memory_ranges; 272 struct efi_memory_range memory_ranges[]; 273} __packed; 274 275struct efi_firmware_management_capsule_header { 276 u32 version; 277 u16 embedded_driver_count; 278 u16 payload_item_count; 279 u64 item_offset_list[]; 280} __packed; 281 282struct efi_firmware_management_capsule_image_header { 283 u32 version; 284 efi_guid_t update_image_type_id; 285 u8 update_image_index; 286 u8 reserved[3]; 287 u32 update_image_size; 288 u32 update_vendor_code_size; 289 u64 update_hardware_instance; 290 u64 image_capsule_support; 291} __packed; 292 293struct efi_capsule_result_variable_fmp { 294 u16 version; 295 u8 payload_index; 296 u8 update_image_index; 297 efi_guid_t update_image_type_id; 298 // u16 capsule_file_name[]; 299 // u16 capsule_target[]; 300} __packed; 301 302#define EFI_RT_SUPPORTED_GET_TIME 0x0001 303#define EFI_RT_SUPPORTED_SET_TIME 0x0002 304#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004 305#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME 0x0008 306#define EFI_RT_SUPPORTED_GET_VARIABLE 0x0010 307#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME 0x0020 308#define EFI_RT_SUPPORTED_SET_VARIABLE 0x0040 309#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP 0x0080 310#define EFI_RT_SUPPORTED_CONVERT_POINTER 0x0100 311#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT 0x0200 312#define EFI_RT_SUPPORTED_RESET_SYSTEM 0x0400 313#define EFI_RT_SUPPORTED_UPDATE_CAPSULE 0x0800 314#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES 0x1000 315#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO 0x2000 316 317#define EFI_RT_PROPERTIES_TABLE_GUID \ 318 EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \ 319 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9) 320 321#define EFI_RT_PROPERTIES_TABLE_VERSION 0x1 322 323struct efi_rt_properties_table { 324 u16 version; 325 u16 length; 326 u32 runtime_services_supported; 327}; 328 329#define EFI_OPTIONAL_PTR 0x00000001 330 331struct efi_runtime_services { 332 struct efi_table_hdr hdr; 333 efi_status_t (EFIAPI *get_time)(struct efi_time *time, 334 struct efi_time_cap *capabilities); 335 efi_status_t (EFIAPI *set_time)(struct efi_time *time); 336 efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending, 337 struct efi_time *time); 338 efi_status_t (EFIAPI *set_wakeup_time)(char enabled, 339 struct efi_time *time); 340 efi_status_t (EFIAPI *set_virtual_address_map)( 341 efi_uintn_t memory_map_size, 342 efi_uintn_t descriptor_size, 343 uint32_t descriptor_version, 344 struct efi_mem_desc *virtmap); 345 efi_status_t (EFIAPI *convert_pointer)( 346 efi_uintn_t debug_disposition, void **address); 347 efi_status_t (EFIAPI *get_variable)(u16 *variable_name, 348 const efi_guid_t *vendor, 349 u32 *attributes, 350 efi_uintn_t *data_size, void *data); 351 efi_status_t (EFIAPI *get_next_variable_name)( 352 efi_uintn_t *variable_name_size, 353 u16 *variable_name, efi_guid_t *vendor); 354 efi_status_t (EFIAPI *set_variable)(u16 *variable_name, 355 const efi_guid_t *vendor, 356 u32 attributes, 357 efi_uintn_t data_size, 358 const void *data); 359 efi_status_t (EFIAPI *get_next_high_mono_count)( 360 uint32_t *high_count); 361 void (EFIAPI *reset_system)(enum efi_reset_type reset_type, 362 efi_status_t reset_status, 363 unsigned long data_size, void *reset_data); 364 efi_status_t (EFIAPI *update_capsule)( 365 struct efi_capsule_header **capsule_header_array, 366 efi_uintn_t capsule_count, 367 u64 scatter_gather_list); 368 efi_status_t (EFIAPI *query_capsule_caps)( 369 struct efi_capsule_header **capsule_header_array, 370 efi_uintn_t capsule_count, 371 u64 *maximum_capsule_size, 372 u32 *reset_type); 373 efi_status_t (EFIAPI *query_variable_info)( 374 u32 attributes, 375 u64 *maximum_variable_storage_size, 376 u64 *remaining_variable_storage_size, 377 u64 *maximum_variable_size); 378}; 379 380/* EFI event group GUID definitions */ 381 382#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \ 383 EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \ 384 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf) 385 386#define EFI_EVENT_GROUP_BEFORE_EXIT_BOOT_SERVICES \ 387 EFI_GUID(0x8be0e274, 0x3970, 0x4b44, 0x80, 0xc5, \ 388 0x1a, 0xb9, 0x50, 0x2f, 0x3b, 0xfc) 389 390#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \ 391 EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \ 392 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96) 393 394#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \ 395 EFI_GUID(0x78bee926, 0x692f, 0x48fd, 0x9e, 0xdb, \ 396 0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab) 397 398#define EFI_EVENT_GROUP_READY_TO_BOOT \ 399 EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \ 400 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b) 401 402#define EFI_EVENT_GROUP_AFTER_READY_TO_BOOT \ 403 EFI_GUID(0x3a2a00ad, 0x98b9, 0x4cdf, 0xa4, 0x78, \ 404 0x70, 0x27, 0x77, 0xf1, 0xc1, 0xb) 405 406#define EFI_EVENT_GROUP_RESET_SYSTEM \ 407 EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \ 408 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b) 409#define EFI_EVENT_GROUP_RETURN_TO_EFIBOOTMGR \ 410 EFI_GUID(0xb4a40fe6, 0x9149, 0x4f29, 0x94, 0x47, \ 411 0x49, 0x38, 0x7a, 0x7f, 0xab, 0x87) 412 413/* EFI Configuration Table and GUID definitions */ 414#define NULL_GUID \ 415 EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \ 416 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) 417 418#define EFI_GLOBAL_VARIABLE_GUID \ 419 EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \ 420 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) 421 422#define EFI_IMAGE_SECURITY_DATABASE_GUID \ 423 EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, \ 424 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f) 425 426#define EFI_FDT_GUID \ 427 EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \ 428 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) 429 430#define EFI_ACPI_TABLE_GUID \ 431 EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \ 432 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81) 433 434#define SMBIOS_TABLE_GUID \ 435 EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \ 436 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 437 438#define SMBIOS3_TABLE_GUID \ 439 EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, \ 440 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94) 441 442#define EFI_LOAD_FILE_PROTOCOL_GUID \ 443 EFI_GUID(0x56ec3091, 0x954c, 0x11d2, \ 444 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 445 446#define EFI_LOAD_FILE2_PROTOCOL_GUID \ 447 EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \ 448 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d) 449 450#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \ 451 EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \ 452 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) 453 454#define EFI_RNG_PROTOCOL_GUID \ 455 EFI_GUID(0x3152bca5, 0xeade, 0x433d, 0x86, 0x2e, \ 456 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44) 457 458#define EFI_DT_FIXUP_PROTOCOL_GUID \ 459 EFI_GUID(0xe617d64c, 0xfe08, 0x46da, 0xf4, 0xdc, \ 460 0xbb, 0xd5, 0x87, 0x0c, 0x73, 0x00) 461 462#define EFI_TCG2_PROTOCOL_GUID \ 463 EFI_GUID(0x607f766c, 0x7455, 0x42be, 0x93, \ 464 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f) 465 466#define RISCV_EFI_BOOT_PROTOCOL_GUID \ 467 EFI_GUID(0xccd15fec, 0x6f73, 0x4eec, 0x83, \ 468 0x95, 0x3e, 0x69, 0xe4, 0xb9, 0x40, 0xbf) 469 470/** 471 * struct efi_configuration_table - EFI Configuration Table 472 * 473 * This table contains a set of GUID/pointer pairs. 474 * The EFI Configuration Table may contain at most one instance of each table type. 475 * 476 * @guid: GUID that uniquely identifies the system configuration table 477 * @table: A pointer to the table associated with guid 478 */ 479struct efi_configuration_table { 480 efi_guid_t guid; 481 void *table; 482} __packed; 483 484#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) 485 486/** 487 * struct efi_system_table - EFI System Table 488 * 489 * EFI System Table contains pointers to the runtime and boot services tables. 490 * 491 * @hdr: The table header for the EFI System Table 492 * @fw_vendor: A pointer to a null terminated string that identifies the vendor 493 * that produces the system firmware 494 * @fw_revision: The revision of the system firmware 495 * @con_in_handle: The handle for the active console input device 496 * @con_in: A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface 497 * that is associated with con_in_handle 498 * @con_out_handle: The handle for the active console output device 499 * @con_out: A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface 500 * that is associated with con_out_handle 501 * @stderr_handle: The handle for the active standard error console device 502 * @std_err: A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface 503 * that is associated with stderr_handle 504 * @runtime: A pointer to the EFI Runtime Services Table 505 * @boottime: A pointer to the EFI Boot Services Table 506 * @nr_tables: The number of system configuration tables 507 * @tables: A pointer to the system configuration tables 508 */ 509struct efi_system_table { 510 struct efi_table_hdr hdr; 511 u16 *fw_vendor; /* physical addr of wchar_t vendor string */ 512 u32 fw_revision; 513 efi_handle_t con_in_handle; 514 struct efi_simple_text_input_protocol *con_in; 515 efi_handle_t con_out_handle; 516 struct efi_simple_text_output_protocol *con_out; 517 efi_handle_t stderr_handle; 518 struct efi_simple_text_output_protocol *std_err; 519 struct efi_runtime_services *runtime; 520 struct efi_boot_services *boottime; 521 efi_uintn_t nr_tables; 522 struct efi_configuration_table *tables; 523}; 524 525/** 526 * efi_main() - entry point of EFI applications 527 * 528 * @image_handle: handle with the Loaded Image Protocol 529 * @systab: pointer to the system table 530 * Return: status code 531 */ 532efi_status_t EFIAPI efi_main(efi_handle_t image_handle, 533 struct efi_system_table *systab); 534 535#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ 536 EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \ 537 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 538 539#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ 540 EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \ 541 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf) 542 543#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 544 545struct efi_loaded_image { 546 u32 revision; 547 void *parent_handle; 548 struct efi_system_table *system_table; 549 efi_handle_t device_handle; 550 struct efi_device_path *file_path; 551 void *reserved; 552 u32 load_options_size; 553 void *load_options; 554 void *image_base; 555 aligned_u64 image_size; 556 unsigned int image_code_type; 557 unsigned int image_data_type; 558 efi_status_t (EFIAPI *unload)(efi_handle_t image_handle); 559}; 560 561#define EFI_DEVICE_PATH_PROTOCOL_GUID \ 562 EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \ 563 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 564 565#define DEVICE_PATH_TYPE_END 0x7f 566# define DEVICE_PATH_SUB_TYPE_INSTANCE_END 0x01 567# define DEVICE_PATH_SUB_TYPE_END 0xff 568 569struct efi_mac_addr { 570 u8 addr[32]; 571} __packed; 572 573#define DEVICE_PATH_TYPE_HARDWARE_DEVICE 0x01 574# define DEVICE_PATH_SUB_TYPE_MEMORY 0x03 575# define DEVICE_PATH_SUB_TYPE_VENDOR 0x04 576# define DEVICE_PATH_SUB_TYPE_CONTROLLER 0x05 577 578struct efi_device_path_memory { 579 struct efi_device_path dp; 580 u32 memory_type; 581 u64 start_address; 582 u64 end_address; 583} __packed; 584 585struct efi_device_path_vendor { 586 struct efi_device_path dp; 587 efi_guid_t guid; 588 u8 vendor_data[]; 589} __packed; 590 591struct efi_device_path_udevice { 592 struct efi_device_path dp; 593 efi_guid_t guid; 594 int uclass_id; 595 int dev_number; 596} __packed; 597 598struct efi_device_path_controller { 599 struct efi_device_path dp; 600 u32 controller_number; 601} __packed; 602 603#define DEVICE_PATH_TYPE_ACPI_DEVICE 0x02 604# define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE 0x01 605 606#define EFI_PNP_ID(ID) (u32)(((ID) << 16) | 0x41D0) 607#define EISA_PNP_ID(ID) EFI_PNP_ID(ID) 608#define EISA_PNP_NUM(ID) ((ID) >> 16) 609 610struct efi_device_path_acpi_path { 611 struct efi_device_path dp; 612 u32 hid; 613 u32 uid; 614} __packed; 615 616#define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03 617# define DEVICE_PATH_SUB_TYPE_MSG_ATAPI 0x01 618# define DEVICE_PATH_SUB_TYPE_MSG_SCSI 0x02 619# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05 620# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b 621# define DEVICE_PATH_SUB_TYPE_MSG_IPV4 0x0c 622# define DEVICE_PATH_SUB_TYPE_MSG_UART 0x0e 623# define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f 624# define DEVICE_PATH_SUB_TYPE_MSG_USB_WWI 0x10 625# define DEVICE_PATH_SUB_TYPE_MSG_SATA 0x12 626# define DEVICE_PATH_SUB_TYPE_MSG_NVME 0x17 627# define DEVICE_PATH_SUB_TYPE_MSG_URI 0x18 628# define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a 629# define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d 630 631struct efi_device_path_atapi { 632 struct efi_device_path dp; 633 u8 primary_secondary; 634 u8 slave_master; 635 u16 logical_unit_number; 636} __packed; 637 638struct efi_device_path_scsi { 639 struct efi_device_path dp; 640 u16 target_id; 641 u16 logical_unit_number; 642} __packed; 643 644struct efi_device_path_uart { 645 struct efi_device_path dp; 646 u32 reserved; 647 u64 baud_rate; 648 u8 data_bits; 649 u8 parity; 650 u8 stop_bits; 651} __packed; 652 653struct efi_device_path_usb { 654 struct efi_device_path dp; 655 u8 parent_port_number; 656 u8 usb_interface; 657} __packed; 658 659struct efi_device_path_sata { 660 struct efi_device_path dp; 661 u16 hba_port; 662 u16 port_multiplier_port; 663 u16 logical_unit_number; 664} __packed; 665 666struct efi_device_path_mac_addr { 667 struct efi_device_path dp; 668 struct efi_mac_addr mac; 669 u8 if_type; 670} __packed; 671 672struct efi_device_path_usb_class { 673 struct efi_device_path dp; 674 u16 vendor_id; 675 u16 product_id; 676 u8 device_class; 677 u8 device_subclass; 678 u8 device_protocol; 679} __packed; 680 681struct efi_device_path_sd_mmc_path { 682 struct efi_device_path dp; 683 u8 slot_number; 684} __packed; 685 686struct efi_device_path_nvme { 687 struct efi_device_path dp; 688 u32 ns_id; 689 u8 eui64[8]; 690} __packed; 691 692struct efi_device_path_uri { 693 struct efi_device_path dp; 694 u8 uri[]; 695} __packed; 696 697struct efi_ipv4_address { 698 u8 ip_addr[4]; 699}; 700 701struct efi_device_path_ipv4 { 702 struct efi_device_path dp; 703 struct efi_ipv4_address local_ip_address; 704 struct efi_ipv4_address remote_ip_address; 705 u16 local_port; 706 u16 remote_port; 707 u16 protocol; 708 u8 static_ip_address; 709 struct efi_ipv4_address gateway_ip_address; 710 struct efi_ipv4_address subnet_mask; 711} __packed; 712 713#define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04 714# define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01 715# define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02 716# define DEVICE_PATH_SUB_TYPE_VENDOR_PATH 0x03 717# define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04 718 719struct efi_device_path_hard_drive_path { 720 struct efi_device_path dp; 721 u32 partition_number; 722 u64 partition_start; 723 u64 partition_end; 724 u8 partition_signature[16]; 725 u8 partmap_type; 726 u8 signature_type; 727} __packed; 728 729struct efi_device_path_cdrom_path { 730 struct efi_device_path dp; 731 u32 boot_entry; 732 u64 partition_start; 733 u64 partition_size; 734} __packed; 735 736struct efi_device_path_file_path { 737 struct efi_device_path dp; 738 u16 str[]; 739} __packed; 740 741#define EFI_BLOCK_IO_PROTOCOL_GUID \ 742 EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \ 743 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 744 745struct efi_block_io_media { 746 u32 media_id; 747 char removable_media; 748 char media_present; 749 char logical_partition; 750 char read_only; 751 char write_caching; 752 u8 pad[3]; 753 u32 block_size; 754 u32 io_align; 755 u8 pad2[4]; 756 u64 last_block; 757 /* Added in revision 2 of the protocol */ 758 u64 lowest_aligned_lba; 759 u32 logical_blocks_per_physical_block; 760 /* Added in revision 3 of the protocol */ 761 u32 optimal_transfer_length_granualarity; 762}; 763 764#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001 765#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x0002001f 766 767struct efi_block_io { 768 u64 revision; 769 struct efi_block_io_media *media; 770 efi_status_t (EFIAPI *reset)(struct efi_block_io *this, 771 char extended_verification); 772 efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this, 773 u32 media_id, u64 lba, efi_uintn_t buffer_size, 774 void *buffer); 775 efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this, 776 u32 media_id, u64 lba, efi_uintn_t buffer_size, 777 void *buffer); 778 efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this); 779}; 780 781struct simple_text_output_mode { 782 s32 max_mode; 783 s32 mode; 784 s32 attribute; 785 s32 cursor_column; 786 s32 cursor_row; 787 bool cursor_visible; 788}; 789 790#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \ 791 EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \ 792 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 793 794#define EFI_BLACK 0x00 795#define EFI_BLUE 0x01 796#define EFI_GREEN 0x02 797#define EFI_CYAN 0x03 798#define EFI_RED 0x04 799#define EFI_MAGENTA 0x05 800#define EFI_BROWN 0x06 801#define EFI_LIGHTGRAY 0x07 802#define EFI_BRIGHT 0x08 803#define EFI_DARKGRAY 0x08 804#define EFI_LIGHTBLUE 0x09 805#define EFI_LIGHTGREEN 0x0a 806#define EFI_LIGHTCYAN 0x0b 807#define EFI_LIGHTRED 0x0c 808#define EFI_LIGHTMAGENTA 0x0d 809#define EFI_YELLOW 0x0e 810#define EFI_WHITE 0x0f 811#define EFI_BACKGROUND_BLACK 0x00 812#define EFI_BACKGROUND_BLUE 0x10 813#define EFI_BACKGROUND_GREEN 0x20 814#define EFI_BACKGROUND_CYAN 0x30 815#define EFI_BACKGROUND_RED 0x40 816#define EFI_BACKGROUND_MAGENTA 0x50 817#define EFI_BACKGROUND_BROWN 0x60 818#define EFI_BACKGROUND_LIGHTGRAY 0x70 819 820/* extract foreground color from EFI attribute */ 821#define EFI_ATTR_FG(attr) ((attr) & 0x07) 822/* treat high bit of FG as bright/bold (similar to edk2) */ 823#define EFI_ATTR_BOLD(attr) (((attr) >> 3) & 0x01) 824/* extract background color from EFI attribute */ 825#define EFI_ATTR_BG(attr) (((attr) >> 4) & 0x7) 826 827struct efi_simple_text_output_protocol { 828 efi_status_t (EFIAPI *reset)( 829 struct efi_simple_text_output_protocol *this, 830 char extended_verification); 831 efi_status_t (EFIAPI *output_string)( 832 struct efi_simple_text_output_protocol *this, 833 const u16 *str); 834 efi_status_t (EFIAPI *test_string)( 835 struct efi_simple_text_output_protocol *this, 836 const u16 *str); 837 efi_status_t(EFIAPI *query_mode)( 838 struct efi_simple_text_output_protocol *this, 839 unsigned long mode_number, unsigned long *columns, 840 unsigned long *rows); 841 efi_status_t(EFIAPI *set_mode)( 842 struct efi_simple_text_output_protocol *this, 843 unsigned long mode_number); 844 efi_status_t(EFIAPI *set_attribute)( 845 struct efi_simple_text_output_protocol *this, 846 unsigned long attribute); 847 efi_status_t(EFIAPI *clear_screen) ( 848 struct efi_simple_text_output_protocol *this); 849 efi_status_t(EFIAPI *set_cursor_position) ( 850 struct efi_simple_text_output_protocol *this, 851 unsigned long column, unsigned long row); 852 efi_status_t(EFIAPI *enable_cursor)( 853 struct efi_simple_text_output_protocol *this, 854 bool enable); 855 struct simple_text_output_mode *mode; 856}; 857 858#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ 859 EFI_GUID(0xdd9e7534, 0x7762, 0x4698, \ 860 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa) 861 862struct efi_input_key { 863 u16 scan_code; 864 u16 unicode_char; 865}; 866 867#define EFI_SHIFT_STATE_INVALID 0x00000000 868#define EFI_RIGHT_SHIFT_PRESSED 0x00000001 869#define EFI_LEFT_SHIFT_PRESSED 0x00000002 870#define EFI_RIGHT_CONTROL_PRESSED 0x00000004 871#define EFI_LEFT_CONTROL_PRESSED 0x00000008 872#define EFI_RIGHT_ALT_PRESSED 0x00000010 873#define EFI_LEFT_ALT_PRESSED 0x00000020 874#define EFI_RIGHT_LOGO_PRESSED 0x00000040 875#define EFI_LEFT_LOGO_PRESSED 0x00000080 876#define EFI_MENU_KEY_PRESSED 0x00000100 877#define EFI_SYS_REQ_PRESSED 0x00000200 878#define EFI_SHIFT_STATE_VALID 0x80000000 879 880#define EFI_TOGGLE_STATE_INVALID 0x00 881#define EFI_SCROLL_LOCK_ACTIVE 0x01 882#define EFI_NUM_LOCK_ACTIVE 0x02 883#define EFI_CAPS_LOCK_ACTIVE 0x04 884#define EFI_KEY_STATE_EXPOSED 0x40 885#define EFI_TOGGLE_STATE_VALID 0x80 886 887struct efi_key_state { 888 u32 key_shift_state; 889 u8 key_toggle_state; 890}; 891 892struct efi_key_data { 893 struct efi_input_key key; 894 struct efi_key_state key_state; 895}; 896 897struct efi_simple_text_input_ex_protocol { 898 efi_status_t (EFIAPI *reset) ( 899 struct efi_simple_text_input_ex_protocol *this, 900 bool extended_verification); 901 efi_status_t (EFIAPI *read_key_stroke_ex) ( 902 struct efi_simple_text_input_ex_protocol *this, 903 struct efi_key_data *key_data); 904 struct efi_event *wait_for_key_ex; 905 efi_status_t (EFIAPI *set_state) ( 906 struct efi_simple_text_input_ex_protocol *this, 907 u8 *key_toggle_state); 908 efi_status_t (EFIAPI *register_key_notify) ( 909 struct efi_simple_text_input_ex_protocol *this, 910 struct efi_key_data *key_data, 911 efi_status_t (EFIAPI *key_notify_function)( 912 struct efi_key_data *key_data), 913 void **notify_handle); 914 efi_status_t (EFIAPI *unregister_key_notify) ( 915 struct efi_simple_text_input_ex_protocol *this, 916 void *notification_handle); 917}; 918 919#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ 920 EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \ 921 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 922 923struct efi_simple_text_input_protocol { 924 efi_status_t(EFIAPI *reset)(struct efi_simple_text_input_protocol *this, 925 bool extended_verification); 926 efi_status_t(EFIAPI *read_key_stroke)( 927 struct efi_simple_text_input_protocol *this, 928 struct efi_input_key *key); 929 struct efi_event *wait_for_key; 930}; 931 932#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ 933 EFI_GUID(0x8b843e20, 0x8132, 0x4852, \ 934 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c) 935 936struct efi_device_path_to_text_protocol { 937 uint16_t *(EFIAPI *convert_device_node_to_text)( 938 struct efi_device_path *device_node, 939 bool display_only, 940 bool allow_shortcuts); 941 uint16_t *(EFIAPI *convert_device_path_to_text)( 942 struct efi_device_path *device_path, 943 bool display_only, 944 bool allow_shortcuts); 945}; 946 947#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ 948 EFI_GUID(0x0379be4e, 0xd706, 0x437d, \ 949 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4) 950 951struct efi_device_path_utilities_protocol { 952 efi_uintn_t (EFIAPI *get_device_path_size)( 953 const struct efi_device_path *device_path); 954 struct efi_device_path *(EFIAPI *duplicate_device_path)( 955 const struct efi_device_path *device_path); 956 struct efi_device_path *(EFIAPI *append_device_path)( 957 const struct efi_device_path *src1, 958 const struct efi_device_path *src2); 959 struct efi_device_path *(EFIAPI *append_device_node)( 960 const struct efi_device_path *device_path, 961 const struct efi_device_path *device_node); 962 struct efi_device_path *(EFIAPI *append_device_path_instance)( 963 const struct efi_device_path *device_path, 964 const struct efi_device_path *device_path_instance); 965 struct efi_device_path *(EFIAPI *get_next_device_path_instance)( 966 struct efi_device_path **device_path_instance, 967 efi_uintn_t *device_path_instance_size); 968 bool (EFIAPI *is_device_path_multi_instance)( 969 const struct efi_device_path *device_path); 970 struct efi_device_path *(EFIAPI *create_device_node)( 971 uint8_t node_type, 972 uint8_t node_sub_type, 973 uint16_t node_length); 974}; 975 976/* 977 * Human Interface Infrastructure (HII) 978 */ 979struct efi_hii_package_list_header { 980 efi_guid_t package_list_guid; 981 u32 package_length; 982} __packed; 983 984/** 985 * struct efi_hii_package_header - EFI HII package header 986 * 987 * @fields: 'fields' replaces the bit-fields defined in the EFI 988 * specification to to avoid possible compiler incompatibilities:: 989 * 990 * u32 length:24; 991 * u32 type:8; 992 */ 993struct efi_hii_package_header { 994 u32 fields; 995} __packed; 996 997#define __EFI_HII_PACKAGE_LEN_SHIFT 0 998#define __EFI_HII_PACKAGE_TYPE_SHIFT 24 999#define __EFI_HII_PACKAGE_LEN_MASK 0xffffff 1000#define __EFI_HII_PACKAGE_TYPE_MASK 0xff 1001 1002#define EFI_HII_PACKAGE_TYPE_ALL 0x00 1003#define EFI_HII_PACKAGE_TYPE_GUID 0x01 1004#define EFI_HII_PACKAGE_FORMS 0x02 1005#define EFI_HII_PACKAGE_STRINGS 0x04 1006#define EFI_HII_PACKAGE_FONTS 0x05 1007#define EFI_HII_PACKAGE_IMAGES 0x06 1008#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07 1009#define EFI_HII_PACKAGE_DEVICE_PATH 0x08 1010#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09 1011#define EFI_HII_PACKAGE_ANIMATIONS 0x0A 1012#define EFI_HII_PACKAGE_END 0xDF 1013#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0 1014#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF 1015 1016/* 1017 * HII GUID package 1018 */ 1019struct efi_hii_guid_package { 1020 struct efi_hii_package_header header; 1021 efi_guid_t guid; 1022 char data[]; 1023} __packed; 1024 1025/* 1026 * HII string package 1027 */ 1028struct efi_hii_strings_package { 1029 struct efi_hii_package_header header; 1030 u32 header_size; 1031 u32 string_info_offset; 1032 u16 language_window[16]; 1033 efi_string_id_t language_name; 1034 u8 language[]; 1035} __packed; 1036 1037struct efi_hii_string_block { 1038 u8 block_type; 1039 /* u8 block_body[]; */ 1040} __packed; 1041 1042#define EFI_HII_SIBT_END 0x00 1043#define EFI_HII_SIBT_STRING_SCSU 0x10 1044#define EFI_HII_SIBT_STRING_SCSU_FONT 0x11 1045#define EFI_HII_SIBT_STRINGS_SCSU 0x12 1046#define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13 1047#define EFI_HII_SIBT_STRING_UCS2 0x14 1048#define EFI_HII_SIBT_STRING_UCS2_FONT 0x15 1049#define EFI_HII_SIBT_STRINGS_UCS2 0x16 1050#define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17 1051#define EFI_HII_SIBT_DUPLICATE 0x20 1052#define EFI_HII_SIBT_SKIP2 0x21 1053#define EFI_HII_SIBT_SKIP1 0x22 1054#define EFI_HII_SIBT_EXT1 0x30 1055#define EFI_HII_SIBT_EXT2 0x31 1056#define EFI_HII_SIBT_EXT4 0x32 1057#define EFI_HII_SIBT_FONT 0x40 1058 1059struct efi_hii_sibt_string_ucs2_block { 1060 struct efi_hii_string_block header; 1061 u16 string_text[]; 1062} __packed; 1063 1064static inline struct efi_hii_string_block * 1065efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk) 1066{ 1067 return ((void *)blk) + sizeof(*blk) + 1068 (u16_strlen(blk->string_text) + 1) * 2; 1069} 1070 1071/* 1072 * HII forms package 1073 * TODO: full scope of definitions 1074 */ 1075struct efi_hii_time { 1076 u8 hour; 1077 u8 minute; 1078 u8 second; 1079}; 1080 1081struct efi_hii_date { 1082 u16 year; 1083 u8 month; 1084 u8 day; 1085}; 1086 1087struct efi_hii_ref { 1088 efi_question_id_t question_id; 1089 efi_form_id_t form_id; 1090 efi_guid_t form_set_guid; 1091 efi_string_id_t device_path; 1092}; 1093 1094union efi_ifr_type_value { 1095 u8 u8; // EFI_IFR_TYPE_NUM_SIZE_8 1096 u16 u16; // EFI_IFR_TYPE_NUM_SIZE_16 1097 u32 u32; // EFI_IFR_TYPE_NUM_SIZE_32 1098 u64 u64; // EFI_IFR_TYPE_NUM_SIZE_64 1099 bool b; // EFI_IFR_TYPE_BOOLEAN 1100 struct efi_hii_time time; // EFI_IFR_TYPE_TIME 1101 struct efi_hii_date date; // EFI_IFR_TYPE_DATE 1102 efi_string_id_t string; // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION 1103 struct efi_hii_ref ref; // EFI_IFR_TYPE_REF 1104 // u8 buffer[]; // EFI_IFR_TYPE_BUFFER 1105}; 1106 1107#define EFI_IFR_TYPE_NUM_SIZE_8 0x00 1108#define EFI_IFR_TYPE_NUM_SIZE_16 0x01 1109#define EFI_IFR_TYPE_NUM_SIZE_32 0x02 1110#define EFI_IFR_TYPE_NUM_SIZE_64 0x03 1111#define EFI_IFR_TYPE_BOOLEAN 0x04 1112#define EFI_IFR_TYPE_TIME 0x05 1113#define EFI_IFR_TYPE_DATE 0x06 1114#define EFI_IFR_TYPE_STRING 0x07 1115#define EFI_IFR_TYPE_OTHER 0x08 1116#define EFI_IFR_TYPE_UNDEFINED 0x09 1117#define EFI_IFR_TYPE_ACTION 0x0A 1118#define EFI_IFR_TYPE_BUFFER 0x0B 1119#define EFI_IFR_TYPE_REF 0x0C 1120#define EFI_IFR_OPTION_DEFAULT 0x10 1121#define EFI_IFR_OPTION_DEFAULT_MFG 0x20 1122 1123#define EFI_IFR_ONE_OF_OPTION_OP 0x09 1124 1125struct efi_ifr_op_header { 1126 u8 opCode; 1127 u8 length:7; 1128 u8 scope:1; 1129}; 1130 1131struct efi_ifr_one_of_option { 1132 struct efi_ifr_op_header header; 1133 efi_string_id_t option; 1134 u8 flags; 1135 u8 type; 1136 union efi_ifr_type_value value; 1137}; 1138 1139typedef efi_uintn_t efi_browser_action_t; 1140 1141#define EFI_BROWSER_ACTION_REQUEST_NONE 0 1142#define EFI_BROWSER_ACTION_REQUEST_RESET 1 1143#define EFI_BROWSER_ACTION_REQUEST_SUBMIT 2 1144#define EFI_BROWSER_ACTION_REQUEST_EXIT 3 1145#define EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT 4 1146#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT 5 1147#define EFI_BROWSER_ACTION_REQUEST_FORM_APPLY 6 1148#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD 7 1149#define EFI_BROWSER_ACTION_REQUEST_RECONNECT 8 1150 1151typedef efi_uintn_t efi_browser_action_request_t; 1152 1153#define EFI_BROWSER_ACTION_CHANGING 0 1154#define EFI_BROWSER_ACTION_CHANGED 1 1155#define EFI_BROWSER_ACTION_RETRIEVE 2 1156#define EFI_BROWSER_ACTION_FORM_OPEN 3 1157#define EFI_BROWSER_ACTION_FORM_CLOSE 4 1158#define EFI_BROWSER_ACTION_SUBMITTED 5 1159#define EFI_BROWSER_ACTION_DEFAULT_STANDARD 0x1000 1160#define EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING 0x1001 1161#define EFI_BROWSER_ACTION_DEFAULT_SAFE 0x1002 1162#define EFI_BROWSER_ACTION_DEFAULT_PLATFORM 0x2000 1163#define EFI_BROWSER_ACTION_DEFAULT_HARDWARE 0x3000 1164#define EFI_BROWSER_ACTION_DEFAULT_FIRMWARE 0x4000 1165 1166/* 1167 * HII keyboard package 1168 */ 1169typedef enum { 1170 EFI_KEY_LCTRL, EFI_KEY_A0, EFI_KEY_LALT, EFI_KEY_SPACE_BAR, 1171 EFI_KEY_A2, EFI_KEY_A3, EFI_KEY_A4, EFI_KEY_RCTRL, EFI_KEY_LEFT_ARROW, 1172 EFI_KEY_DOWN_ARROW, EFI_KEY_RIGHT_ARROW, EFI_KEY_ZERO, 1173 EFI_KEY_PERIOD, EFI_KEY_ENTER, EFI_KEY_LSHIFT, EFI_KEY_B0, 1174 EFI_KEY_B1, EFI_KEY_B2, EFI_KEY_B3, EFI_KEY_B4, EFI_KEY_B5, EFI_KEY_B6, 1175 EFI_KEY_B7, EFI_KEY_B8, EFI_KEY_B9, EFI_KEY_B10, EFI_KEY_RSHIFT, 1176 EFI_KEY_UP_ARROW, EFI_KEY_ONE, EFI_KEY_TWO, EFI_KEY_THREE, 1177 EFI_KEY_CAPS_LOCK, EFI_KEY_C1, EFI_KEY_C2, EFI_KEY_C3, EFI_KEY_C4, 1178 EFI_KEY_C5, EFI_KEY_C6, EFI_KEY_C7, EFI_KEY_C8, EFI_KEY_C9, 1179 EFI_KEY_C10, EFI_KEY_C11, EFI_KEY_C12, EFI_KEY_FOUR, EFI_KEY_FIVE, 1180 EFI_KEY_SIX, EFI_KEY_PLUS, EFI_KEY_TAB, EFI_KEY_D1, EFI_KEY_D2, 1181 EFI_KEY_D3, EFI_KEY_D4, EFI_KEY_D5, EFI_KEY_D6, EFI_KEY_D7, EFI_KEY_D8, 1182 EFI_KEY_D9, EFI_KEY_D10, EFI_KEY_D11, EFI_KEY_D12, EFI_KEY_D13, 1183 EFI_KEY_DEL, EFI_KEY_END, EFI_KEY_PG_DN, EFI_KEY_SEVEN, EFI_KEY_EIGHT, 1184 EFI_KEY_NINE, EFI_KEY_E0, EFI_KEY_E1, EFI_KEY_E2, EFI_KEY_E3, 1185 EFI_KEY_E4, EFI_KEY_E5, EFI_KEY_E6, EFI_KEY_E7, EFI_KEY_E8, EFI_KEY_E9, 1186 EFI_KEY_E10, EFI_KEY_E11, EFI_KEY_E12, EFI_KEY_BACK_SPACE, 1187 EFI_KEY_INS, EFI_KEY_HOME, EFI_KEY_PG_UP, EFI_KEY_NLCK, EFI_KEY_SLASH, 1188 EFI_KEY_ASTERISK, EFI_KEY_MINUS, EFI_KEY_ESC, EFI_KEY_F1, EFI_KEY_F2, 1189 EFI_KEY_F3, EFI_KEY_F4, EFI_KEY_F5, EFI_KEY_F6, EFI_KEY_F7, EFI_KEY_F8, 1190 EFI_KEY_F9, EFI_KEY_F10, EFI_KEY_F11, EFI_KEY_F12, EFI_KEY_PRINT, 1191 EFI_KEY_SLCK, EFI_KEY_PAUSE, 1192} efi_key; 1193 1194struct efi_key_descriptor { 1195 u32 key; 1196 u16 unicode; 1197 u16 shifted_unicode; 1198 u16 alt_gr_unicode; 1199 u16 shifted_alt_gr_unicode; 1200 u16 modifier; 1201 u16 affected_attribute; 1202} __packed; 1203 1204struct efi_hii_keyboard_layout { 1205 u16 layout_length; 1206 /* 1207 * The EFI spec defines this as efi_guid_t. 1208 * clang and gcc both report alignment problems here. 1209 * clang with -Wunaligned-access 1210 * warning: field guid within 'struct efi_hii_keyboard_layout' is less 1211 * aligned than 'efi_guid_t' and is usually due to 1212 * 'struct efi_hii_keyboard_layout' being packed, which can lead to 1213 * unaligned accesses 1214 * 1215 * GCC with -Wpacked-not-aligned -Waddress-of-packed-member 1216 * 'efi_guid_t' offset 2 in 'struct efi_hii_keyboard_layout' 1217 * isn't aligned to 4 1218 * 1219 * Removing the alignment from efi_guid_t is not an option, since 1220 * it is also used in non-packed structs and that would break 1221 * calculations with offsetof 1222 * 1223 * This is the only place we get a report for. That happens because 1224 * all other declarations of efi_guid_t within a packed struct happens 1225 * to be 4-byte aligned. i.e a u32, a u64 a 2 * u16 or any combination 1226 * that ends up landing efi_guid_t on a 4byte boundary precedes. 1227 * 1228 * Replace this with a 1-byte aligned counterpart of b[16]. This is a 1229 * packed struct so the memory placement of efi_guid_t should not change 1230 * 1231 */ 1232 u8 guid[16]; 1233 u32 layout_descriptor_string_offset; 1234 u8 descriptor_count; 1235 /* struct efi_key_descriptor descriptors[]; follows here */ 1236} __packed; 1237 1238struct efi_hii_keyboard_package { 1239 struct efi_hii_package_header header; 1240 u16 layout_count; 1241 struct efi_hii_keyboard_layout layout[]; 1242} __packed; 1243 1244/* 1245 * HII protocols 1246 */ 1247#define EFI_HII_STRING_PROTOCOL_GUID \ 1248 EFI_GUID(0x0fd96974, 0x23aa, 0x4cdc, \ 1249 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a) 1250 1251struct efi_font_info { 1252 efi_hii_font_style_t font_style; 1253 u16 font_size; 1254 u16 font_name[1]; 1255}; 1256 1257struct efi_hii_string_protocol { 1258 efi_status_t(EFIAPI *new_string)( 1259 const struct efi_hii_string_protocol *this, 1260 efi_hii_handle_t package_list, 1261 efi_string_id_t *string_id, 1262 const u8 *language, 1263 const u16 *language_name, 1264 const efi_string_t string, 1265 const struct efi_font_info *string_font_info); 1266 efi_status_t(EFIAPI *get_string)( 1267 const struct efi_hii_string_protocol *this, 1268 const u8 *language, 1269 efi_hii_handle_t package_list, 1270 efi_string_id_t string_id, 1271 efi_string_t string, 1272 efi_uintn_t *string_size, 1273 struct efi_font_info **string_font_info); 1274 efi_status_t(EFIAPI *set_string)( 1275 const struct efi_hii_string_protocol *this, 1276 efi_hii_handle_t package_list, 1277 efi_string_id_t string_id, 1278 const u8 *language, 1279 const efi_string_t string, 1280 const struct efi_font_info *string_font_info); 1281 efi_status_t(EFIAPI *get_languages)( 1282 const struct efi_hii_string_protocol *this, 1283 efi_hii_handle_t package_list, 1284 u8 *languages, 1285 efi_uintn_t *languages_size); 1286 efi_status_t(EFIAPI *get_secondary_languages)( 1287 const struct efi_hii_string_protocol *this, 1288 efi_hii_handle_t package_list, 1289 const u8 *primary_language, 1290 u8 *secondary_languages, 1291 efi_uintn_t *secondary_languages_size); 1292}; 1293 1294#define EFI_HII_DATABASE_PROTOCOL_GUID \ 1295 EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \ 1296 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42) 1297 1298struct efi_hii_database_protocol { 1299 efi_status_t(EFIAPI *new_package_list)( 1300 const struct efi_hii_database_protocol *this, 1301 const struct efi_hii_package_list_header *package_list, 1302 const efi_handle_t driver_handle, 1303 efi_hii_handle_t *handle); 1304 efi_status_t(EFIAPI *remove_package_list)( 1305 const struct efi_hii_database_protocol *this, 1306 efi_hii_handle_t handle); 1307 efi_status_t(EFIAPI *update_package_list)( 1308 const struct efi_hii_database_protocol *this, 1309 efi_hii_handle_t handle, 1310 const struct efi_hii_package_list_header *package_list); 1311 efi_status_t(EFIAPI *list_package_lists)( 1312 const struct efi_hii_database_protocol *this, 1313 u8 package_type, 1314 const efi_guid_t *package_guid, 1315 efi_uintn_t *handle_buffer_length, 1316 efi_hii_handle_t *handle); 1317 efi_status_t(EFIAPI *export_package_lists)( 1318 const struct efi_hii_database_protocol *this, 1319 efi_hii_handle_t handle, 1320 efi_uintn_t *buffer_size, 1321 struct efi_hii_package_list_header *buffer); 1322 efi_status_t(EFIAPI *register_package_notify)( 1323 const struct efi_hii_database_protocol *this, 1324 u8 package_type, 1325 const efi_guid_t *package_guid, 1326 const void *package_notify_fn, 1327 efi_uintn_t notify_type, 1328 efi_handle_t *notify_handle); 1329 efi_status_t(EFIAPI *unregister_package_notify)( 1330 const struct efi_hii_database_protocol *this, 1331 efi_handle_t notification_handle 1332 ); 1333 efi_status_t(EFIAPI *find_keyboard_layouts)( 1334 const struct efi_hii_database_protocol *this, 1335 u16 *key_guid_buffer_length, 1336 efi_guid_t *key_guid_buffer); 1337 efi_status_t(EFIAPI *get_keyboard_layout)( 1338 const struct efi_hii_database_protocol *this, 1339 efi_guid_t *key_guid, 1340 u16 *keyboard_layout_length, 1341 struct efi_hii_keyboard_layout *keyboard_layout); 1342 efi_status_t(EFIAPI *set_keyboard_layout)( 1343 const struct efi_hii_database_protocol *this, 1344 efi_guid_t *key_guid); 1345 efi_status_t(EFIAPI *get_package_list_handle)( 1346 const struct efi_hii_database_protocol *this, 1347 efi_hii_handle_t package_list_handle, 1348 efi_handle_t *driver_handle); 1349}; 1350 1351#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \ 1352 EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \ 1353 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f) 1354 1355struct efi_hii_config_routing_protocol { 1356 efi_status_t(EFIAPI *extract_config)( 1357 const struct efi_hii_config_routing_protocol *this, 1358 const efi_string_t request, 1359 efi_string_t *progress, 1360 efi_string_t *results); 1361 efi_status_t(EFIAPI *export_config)( 1362 const struct efi_hii_config_routing_protocol *this, 1363 efi_string_t *results); 1364 efi_status_t(EFIAPI *route_config)( 1365 const struct efi_hii_config_routing_protocol *this, 1366 const efi_string_t configuration, 1367 efi_string_t *progress); 1368 efi_status_t(EFIAPI *block_to_config)( 1369 const struct efi_hii_config_routing_protocol *this, 1370 const efi_string_t config_request, 1371 const uint8_t *block, 1372 const efi_uintn_t block_size, 1373 efi_string_t *config, 1374 efi_string_t *progress); 1375 efi_status_t(EFIAPI *config_to_block)( 1376 const struct efi_hii_config_routing_protocol *this, 1377 const efi_string_t config_resp, 1378 const uint8_t *block, 1379 const efi_uintn_t *block_size, 1380 efi_string_t *progress); 1381 efi_status_t(EFIAPI *get_alt_config)( 1382 const struct efi_hii_config_routing_protocol *this, 1383 const efi_string_t config_resp, 1384 const efi_guid_t *guid, 1385 const efi_string_t name, 1386 const struct efi_device_path *device_path, 1387 const efi_string_t alt_cfg_id, 1388 efi_string_t *alt_cfg_resp); 1389}; 1390 1391#define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \ 1392 EFI_GUID(0x330d4706, 0xf2a0, 0x4e4f, \ 1393 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85) 1394 1395struct efi_hii_config_access_protocol { 1396 efi_status_t(EFIAPI *extract_config_access)( 1397 const struct efi_hii_config_access_protocol *this, 1398 const efi_string_t request, 1399 efi_string_t *progress, 1400 efi_string_t *results); 1401 efi_status_t(EFIAPI *route_config_access)( 1402 const struct efi_hii_config_access_protocol *this, 1403 const efi_string_t configuration, 1404 efi_string_t *progress); 1405 efi_status_t(EFIAPI *form_callback)( 1406 const struct efi_hii_config_access_protocol *this, 1407 efi_browser_action_t action, 1408 efi_question_id_t question_id, 1409 u8 type, 1410 union efi_ifr_type_value *value, 1411 efi_browser_action_request_t *action_request); 1412}; 1413 1414#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ 1415 EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \ 1416 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) 1417 1418#define EFI_GOT_RGBA8 0 1419#define EFI_GOT_BGRA8 1 1420#define EFI_GOT_BITMASK 2 1421 1422struct efi_gop_mode_info { 1423 u32 version; 1424 u32 width; 1425 u32 height; 1426 u32 pixel_format; 1427 u32 pixel_bitmask[4]; 1428 u32 pixels_per_scanline; 1429}; 1430 1431struct efi_gop_mode { 1432 u32 max_mode; 1433 u32 mode; 1434 struct efi_gop_mode_info *info; 1435 unsigned long info_size; 1436 efi_physical_addr_t fb_base; 1437 unsigned long fb_size; 1438}; 1439 1440struct efi_gop_pixel { 1441 u8 blue; 1442 u8 green; 1443 u8 red; 1444 u8 reserved; 1445}; 1446 1447#define EFI_BLT_VIDEO_FILL 0 1448#define EFI_BLT_VIDEO_TO_BLT_BUFFER 1 1449#define EFI_BLT_BUFFER_TO_VIDEO 2 1450#define EFI_BLT_VIDEO_TO_VIDEO 3 1451 1452struct efi_gop { 1453 efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number, 1454 efi_uintn_t *size_of_info, 1455 struct efi_gop_mode_info **info); 1456 efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number); 1457 efi_status_t (EFIAPI *blt)(struct efi_gop *this, 1458 struct efi_gop_pixel *buffer, 1459 u32 operation, efi_uintn_t sx, 1460 efi_uintn_t sy, efi_uintn_t dx, 1461 efi_uintn_t dy, efi_uintn_t width, 1462 efi_uintn_t height, efi_uintn_t delta); 1463 struct efi_gop_mode *mode; 1464}; 1465 1466#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ 1467 EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ 1468 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 1469 1470struct efi_mac_address { 1471 char mac_addr[32]; 1472}; 1473 1474struct efi_ip_address { 1475 u8 ip_addr[16]; 1476} __attribute__((aligned(4))); 1477 1478enum efi_simple_network_state { 1479 EFI_NETWORK_STOPPED, 1480 EFI_NETWORK_STARTED, 1481 EFI_NETWORK_INITIALIZED, 1482}; 1483 1484struct efi_simple_network_mode { 1485 enum efi_simple_network_state state; 1486 u32 hwaddr_size; 1487 u32 media_header_size; 1488 u32 max_packet_size; 1489 u32 nvram_size; 1490 u32 nvram_access_size; 1491 u32 receive_filter_mask; 1492 u32 receive_filter_setting; 1493 u32 max_mcast_filter_count; 1494 u32 mcast_filter_count; 1495 struct efi_mac_address mcast_filter[16]; 1496 struct efi_mac_address current_address; 1497 struct efi_mac_address broadcast_address; 1498 struct efi_mac_address permanent_address; 1499 u8 if_type; 1500 u8 mac_changeable; 1501 u8 multitx_supported; 1502 u8 media_present_supported; 1503 u8 media_present; 1504}; 1505 1506/* receive_filters bit mask */ 1507#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01 1508#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02 1509#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04 1510#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08 1511#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10 1512 1513/* interrupt status bit mask */ 1514#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01 1515#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02 1516#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04 1517#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08 1518 1519/* revision of the simple network protocol */ 1520#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 1521 1522struct efi_simple_network { 1523 u64 revision; 1524 efi_status_t (EFIAPI *start)(struct efi_simple_network *this); 1525 efi_status_t (EFIAPI *stop)(struct efi_simple_network *this); 1526 efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this, 1527 ulong extra_rx, ulong extra_tx); 1528 efi_status_t (EFIAPI *reset)(struct efi_simple_network *this, 1529 int extended_verification); 1530 efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this); 1531 efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this, 1532 u32 enable, u32 disable, int reset_mcast_filter, 1533 ulong mcast_filter_count, 1534 struct efi_mac_address *mcast_filter); 1535 efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this, 1536 int reset, struct efi_mac_address *new_mac); 1537 efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this, 1538 int reset, ulong *stat_size, void *stat_table); 1539 efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this, 1540 int ipv6, struct efi_ip_address *ip, 1541 struct efi_mac_address *mac); 1542 efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this, 1543 int read_write, ulong offset, ulong buffer_size, 1544 char *buffer); 1545 efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this, 1546 u32 *int_status, void **txbuf); 1547 efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this, 1548 size_t header_size, size_t buffer_size, void *buffer, 1549 struct efi_mac_address *src_addr, 1550 struct efi_mac_address *dest_addr, u16 *protocol); 1551 efi_status_t (EFIAPI *receive)(struct efi_simple_network *this, 1552 size_t *header_size, size_t *buffer_size, void *buffer, 1553 struct efi_mac_address *src_addr, 1554 struct efi_mac_address *dest_addr, u16 *protocol); 1555 struct efi_event *wait_for_packet; 1556 struct efi_simple_network_mode *mode; 1557 /* private fields */ 1558 u32 int_status; 1559}; 1560 1561#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \ 1562 EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \ 1563 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 1564 1565#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000 1566#define EFI_PXE_BASE_CODE_MAX_IPCNT 8 1567 1568struct efi_pxe_packet { 1569 u8 packet[1472]; 1570}; 1571 1572struct efi_pxe_mode { 1573 u8 started; 1574 u8 ipv6_available; 1575 u8 ipv6_supported; 1576 u8 using_ipv6; 1577 u8 bis_supported; 1578 u8 bis_detected; 1579 u8 auto_arp; 1580 u8 send_guid; 1581 u8 dhcp_discover_valid; 1582 u8 dhcp_ack_received; 1583 u8 proxy_offer_received; 1584 u8 pxe_discover_valid; 1585 u8 pxe_reply_received; 1586 u8 pxe_bis_reply_received; 1587 u8 icmp_error_received; 1588 u8 tftp_error_received; 1589 u8 make_callbacks; 1590 u8 ttl; 1591 u8 tos; 1592 u8 pad; 1593 struct efi_ip_address station_ip; 1594 struct efi_ip_address subnet_mask; 1595 struct efi_pxe_packet dhcp_discover; 1596 struct efi_pxe_packet dhcp_ack; 1597 struct efi_pxe_packet proxy_offer; 1598 struct efi_pxe_packet pxe_discover; 1599 struct efi_pxe_packet pxe_reply; 1600}; 1601 1602struct efi_pxe_base_code_srvlist { 1603 u16 type; 1604 u8 accept_any_response; 1605 u8 reserved; 1606 struct efi_ip_address ip_addr; 1607}; 1608 1609struct efi_pxe_base_code_discover_info { 1610 u8 use_m_cast; 1611 u8 use_b_cast; 1612 u8 use_u_cast; 1613 u8 must_use_list; 1614 struct efi_ip_address server_m_cast_ip; 1615 u16 ip_cnt; 1616 struct efi_pxe_base_code_srvlist srv_list[]; 1617}; 1618 1619struct efi_pxe_base_code_mtftp_info { 1620 struct efi_ip_address m_cast_ip; 1621 u16 cport; 1622 u16 sport; 1623 u16 listen_timeout; 1624 u16 transit_timeout; 1625}; 1626 1627struct efi_pxe_base_code_filter { 1628 u8 filters; 1629 u8 ip_cnt; 1630 u16 reserved; 1631 struct efi_ip_address ip_list[EFI_PXE_BASE_CODE_MAX_IPCNT]; 1632}; 1633 1634struct efi_pxe_base_code_dhcpv4_packet { 1635 u8 bootp_op_code; 1636 u8 bootp_hw_type; 1637 u8 bootp_addr_len; 1638 u8 bootp_gate_hops; 1639 u32 bootp_ident; 1640 u16 bootp_seconds; 1641 u16 bootp_flags; 1642 u8 bootp_ci_addr[4]; 1643 u8 bootp_yi_addr[4]; 1644 u8 bootp_si_addr[4]; 1645 u8 bootp_gi_addr[4]; 1646 u8 bootp_hw_addr[16]; 1647 u8 bootp_srv_name[64]; 1648 u8 bootp_boot_file[128]; 1649 u32 dhcp_magick; 1650 u8 dhcp_options[56]; 1651}; 1652 1653struct efi_pxe_base_code_dhcpv6_packet { 1654 u8 message_type; 1655 u8 transaction_id[3]; 1656 u8 dhcp_options[1024]; 1657}; 1658 1659typedef union { 1660 u8 raw[1472]; 1661 struct efi_pxe_base_code_dhcpv4_packet dhcpv4; 1662 struct efi_pxe_base_code_dhcpv6_packet dhcpv6; 1663} EFI_PXE_BASE_CODE_PACKET; 1664 1665struct efi_pxe_base_code_protocol { 1666 u64 revision; 1667 efi_status_t (EFIAPI *start)(struct efi_pxe_base_code_protocol *this, 1668 u8 use_ipv6); 1669 efi_status_t (EFIAPI *stop)(struct efi_pxe_base_code_protocol *this); 1670 efi_status_t (EFIAPI *dhcp)(struct efi_pxe_base_code_protocol *this, 1671 u8 sort_offers); 1672 efi_status_t (EFIAPI *discover)( 1673 struct efi_pxe_base_code_protocol *this, 1674 u16 type, u16 *layer, u8 bis, 1675 struct efi_pxe_base_code_discover_info *info); 1676 efi_status_t (EFIAPI *mtftp)( 1677 struct efi_pxe_base_code_protocol *this, 1678 u32 operation, void *buffer_ptr, 1679 u8 overwrite, efi_uintn_t *buffer_size, 1680 struct efi_ip_address server_ip, char *filename, 1681 struct efi_pxe_base_code_mtftp_info *info, 1682 u8 dont_use_buffer); 1683 efi_status_t (EFIAPI *udp_write)( 1684 struct efi_pxe_base_code_protocol *this, 1685 u16 op_flags, struct efi_ip_address *dest_ip, 1686 u16 *dest_port, 1687 struct efi_ip_address *gateway_ip, 1688 struct efi_ip_address *src_ip, u16 *src_port, 1689 efi_uintn_t *header_size, void *header_ptr, 1690 efi_uintn_t *buffer_size, void *buffer_ptr); 1691 efi_status_t (EFIAPI *udp_read)( 1692 struct efi_pxe_base_code_protocol *this, 1693 u16 op_flags, struct efi_ip_address *dest_ip, 1694 u16 *dest_port, struct efi_ip_address *src_ip, 1695 u16 *src_port, efi_uintn_t *header_size, 1696 void *header_ptr, efi_uintn_t *buffer_size, 1697 void *buffer_ptr); 1698 efi_status_t (EFIAPI *set_ip_filter)( 1699 struct efi_pxe_base_code_protocol *this, 1700 struct efi_pxe_base_code_filter *new_filter); 1701 efi_status_t (EFIAPI *arp)(struct efi_pxe_base_code_protocol *this, 1702 struct efi_ip_address *ip_addr, 1703 struct efi_mac_address *mac_addr); 1704 efi_status_t (EFIAPI *set_parameters)( 1705 struct efi_pxe_base_code_protocol *this, 1706 u8 *new_auto_arp, u8 *new_send_guid, 1707 u8 *new_ttl, u8 *new_tos, 1708 u8 *new_make_callback); 1709 efi_status_t (EFIAPI *set_station_ip)( 1710 struct efi_pxe_base_code_protocol *this, 1711 struct efi_ip_address *new_station_ip, 1712 struct efi_ip_address *new_subnet_mask); 1713 efi_status_t (EFIAPI *set_packets)( 1714 struct efi_pxe_base_code_protocol *this, 1715 u8 *new_dhcp_discover_valid, 1716 u8 *new_dhcp_ack_received, 1717 u8 *new_proxy_offer_received, 1718 u8 *new_pxe_discover_valid, 1719 u8 *new_pxe_reply_received, 1720 u8 *new_pxe_bis_reply_received, 1721 EFI_PXE_BASE_CODE_PACKET *new_dchp_discover, 1722 EFI_PXE_BASE_CODE_PACKET *new_dhcp_acc, 1723 EFI_PXE_BASE_CODE_PACKET *new_proxy_offer, 1724 EFI_PXE_BASE_CODE_PACKET *new_pxe_discover, 1725 EFI_PXE_BASE_CODE_PACKET *new_pxe_reply, 1726 EFI_PXE_BASE_CODE_PACKET *new_pxe_bis_reply); 1727 struct efi_pxe_mode *mode; 1728}; 1729 1730#define EFI_IP4_CONFIG2_PROTOCOL_GUID \ 1731 EFI_GUID(0x5b446ed1, 0xe30b, 0x4faa, \ 1732 0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80) 1733 1734enum efi_ip4_config2_data_type { 1735 EFI_IP4_CONFIG2_DATA_TYPE_INTERFACEINFO, 1736 EFI_IP4_CONFIG2_DATA_TYPE_POLICY, 1737 EFI_IP4_CONFIG2_DATA_TYPE_MANUAL_ADDRESS, 1738 EFI_IP4_CONFIG2_DATA_TYPE_GATEWAY, 1739 EFI_IP4_CONFIG2_DATA_TYPE_DNSSERVER, 1740 EFI_IP4_CONFIG2_DATA_TYPE_MAXIMUM, 1741}; 1742 1743struct efi_ip4_config2_protocol { 1744 efi_status_t (EFIAPI * set_data)(struct efi_ip4_config2_protocol *this, 1745 enum efi_ip4_config2_data_type data_type, 1746 efi_uintn_t data_size, 1747 void *data); 1748 efi_status_t (EFIAPI * get_data)(struct efi_ip4_config2_protocol *this, 1749 enum efi_ip4_config2_data_type data_type, 1750 efi_uintn_t *data_size, 1751 void *data); 1752 efi_status_t (EFIAPI * register_data_notify)(struct efi_ip4_config2_protocol *this, 1753 enum efi_ip4_config2_data_type data_type, 1754 struct efi_event *event); 1755 efi_status_t (EFIAPI * unregister_data_notify)(struct efi_ip4_config2_protocol *this, 1756 enum efi_ip4_config2_data_type data_type, 1757 struct efi_event *event); 1758}; 1759 1760struct efi_ip4_route_table { 1761 struct efi_ipv4_address subnet_address; 1762 struct efi_ipv4_address subnet_mask; 1763 struct efi_ipv4_address gateway_address; 1764}; 1765 1766#define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE 32 1767 1768struct efi_ip4_config2_interface_info { 1769 u16 name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE]; 1770 u8 if_type; 1771 u32 hw_address_size; 1772 struct efi_mac_address hw_address; 1773 struct efi_ipv4_address station_address; 1774 struct efi_ipv4_address subnet_mask; 1775 u32 route_table_size; 1776 struct efi_ip4_route_table *route_table; 1777}; 1778 1779enum efi_ip4_config2_policy { 1780 EFI_IP4_CONFIG2_POLICY_STATIC, 1781 EFI_IP4_CONFIG2_POLICY_DHCP, 1782 EFI_IP4_CONFIG2_POLICY_MAX 1783}; 1784 1785struct efi_ip4_config2_manual_address { 1786 struct efi_ipv4_address address; 1787 struct efi_ipv4_address subnet_mask; 1788}; 1789 1790#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \ 1791 EFI_GUID(0xbdc8e6af, 0xd9bc, 0x4379, \ 1792 0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c) 1793 1794struct efi_service_binding_protocol { 1795 efi_status_t (EFIAPI * create_child)(struct efi_service_binding_protocol *this, 1796 efi_handle_t *child_handle); 1797 efi_status_t (EFIAPI * destroy_child)(struct efi_service_binding_protocol *this, 1798 efi_handle_t child_handle); 1799}; 1800 1801#define EFI_HTTP_PROTOCOL_GUID \ 1802 EFI_GUID(0x7A59B29B, 0x910B, 0x4171, \ 1803 0x82, 0x42, 0xA8, 0x5A, 0x0D, 0xF2, 0x5B, 0x5B) 1804 1805enum efi_http_version { 1806 HTTPVERSION10, 1807 HTTPVERSION11, 1808 HTTPVERSIONUNSUPPORTED 1809}; 1810 1811struct efi_httpv4_access_point { 1812 bool use_default_address; 1813 struct efi_ipv4_address local_address; 1814 struct efi_ipv4_address local_subnet; 1815 u16 local_port; 1816}; 1817 1818union efi_http_access_point { 1819 struct efi_httpv4_access_point *ipv4_node; 1820 struct efi_httpv6_access_point *ipv6_node; 1821}; 1822 1823struct efi_http_config_data { 1824 enum efi_http_version http_version; 1825 u32 timeout; 1826 bool is_ipv6; 1827 union efi_http_access_point access_point; 1828}; 1829 1830enum efi_http_method { 1831 HTTP_METHOD_GET, 1832 HTTP_METHOD_POST, 1833 HTTP_METHOD_PATCH, 1834 HTTP_METHOD_OPTIONS, 1835 HTTP_METHOD_CONNECT, 1836 HTTP_METHOD_HEAD, 1837 HTTP_METHOD_PUT, 1838 HTTP_METHOD_DELETE, 1839 HTTP_METHOD_TRACE, 1840 HTTP_METHOD_MAX 1841}; 1842 1843enum efi_http_status_code { 1844 HTTP_STATUS_UNSUPPORTED_STATUS = 0, 1845 HTTP_STATUS_100_CONTINUE, 1846 HTTP_STATUS_101_SWITCHING_PROTOCOLS, 1847 HTTP_STATUS_200_OK, 1848 HTTP_STATUS_201_CREATED, 1849 HTTP_STATUS_202_ACCEPTED, 1850 HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION, 1851 HTTP_STATUS_204_NO_CONTENT, 1852 HTTP_STATUS_205_RESET_CONTENT, 1853 HTTP_STATUS_206_PARTIAL_CONTENT, 1854 HTTP_STATUS_300_MULTIPLE_CHOICES, 1855 HTTP_STATUS_301_MOVED_PERMANENTLY, 1856 HTTP_STATUS_302_FOUND, 1857 HTTP_STATUS_303_SEE_OTHER, 1858 HTTP_STATUS_304_NOT_MODIFIED, 1859 HTTP_STATUS_305_USE_PROXY, 1860 HTTP_STATUS_307_TEMPORARY_REDIRECT, 1861 HTTP_STATUS_400_BAD_REQUEST, 1862 HTTP_STATUS_401_UNAUTHORIZED, 1863 HTTP_STATUS_402_PAYMENT_REQUIRED, 1864 HTTP_STATUS_403_FORBIDDEN, 1865 HTTP_STATUS_404_NOT_FOUND, 1866 HTTP_STATUS_405_METHOD_NOT_ALLOWED, 1867 HTTP_STATUS_406_NOT_ACCEPTABLE, 1868 HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED, 1869 HTTP_STATUS_408_REQUEST_TIME_OUT, 1870 HTTP_STATUS_409_CONFLICT, 1871 HTTP_STATUS_410_GONE, 1872 HTTP_STATUS_411_LENGTH_REQUIRED, 1873 HTTP_STATUS_412_PRECONDITION_FAILED, 1874 HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE, 1875 HTTP_STATUS_414_REQUEST_URI_TOO_LARGE, 1876 HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE, 1877 HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED, 1878 HTTP_STATUS_417_EXPECTATION_FAILED, 1879 HTTP_STATUS_500_INTERNAL_SERVER_ERROR, 1880 HTTP_STATUS_501_NOT_IMPLEMENTED, 1881 HTTP_STATUS_502_BAD_GATEWAY, 1882 HTTP_STATUS_503_SERVICE_UNAVAILABLE, 1883 HTTP_STATUS_504_GATEWAY_TIME_OUT, 1884 HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED, 1885 HTTP_STATUS_308_PERMANENT_REDIRECT 1886}; 1887 1888struct efi_http_request_data { 1889 enum efi_http_method method; 1890 u16 *url; 1891}; 1892 1893struct efi_http_response_data { 1894 enum efi_http_status_code status_code; 1895}; 1896 1897struct efi_http_header { 1898 char *field_name; 1899 char *field_value; 1900}; 1901 1902struct efi_http_message { 1903 union { 1904 struct efi_http_request_data *request; 1905 struct efi_http_response_data *response; 1906 } data; 1907 efi_uintn_t header_count; 1908 struct efi_http_header *headers; 1909 efi_uintn_t body_length; 1910 void *body; 1911}; 1912 1913struct efi_http_token { 1914 struct efi_event *event; 1915 efi_status_t status; 1916 struct efi_http_message *message; 1917}; 1918 1919struct efi_http_protocol { 1920 efi_status_t (EFIAPI * get_mode_data)(struct efi_http_protocol *this, 1921 struct efi_http_config_data *data); 1922 efi_status_t (EFIAPI * configure)(struct efi_http_protocol *this, 1923 struct efi_http_config_data *data); 1924 efi_status_t (EFIAPI * request)(struct efi_http_protocol *this, 1925 struct efi_http_token *token); 1926 efi_status_t (EFIAPI * cancel)(struct efi_http_protocol *this, 1927 struct efi_http_token *token); 1928 efi_status_t (EFIAPI * response)(struct efi_http_protocol *this, 1929 struct efi_http_token *token); 1930 efi_status_t (EFIAPI * poll)(struct efi_http_protocol *this); 1931}; 1932 1933#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ 1934 EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \ 1935 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 1936#define EFI_FILE_PROTOCOL_REVISION 0x00010000 1937#define EFI_FILE_PROTOCOL_REVISION2 0x00020000 1938#define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2 1939 1940struct efi_file_io_token { 1941 struct efi_event *event; 1942 efi_status_t status; 1943 efi_uintn_t buffer_size; 1944 void *buffer;}; 1945 1946struct efi_file_handle { 1947 u64 rev; 1948 efi_status_t (EFIAPI *open)(struct efi_file_handle *this, 1949 struct efi_file_handle **new_handle, 1950 u16 *file_name, u64 open_mode, u64 attributes); 1951 efi_status_t (EFIAPI *close)(struct efi_file_handle *this); 1952 efi_status_t (EFIAPI *delete)(struct efi_file_handle *this); 1953 efi_status_t (EFIAPI *read)(struct efi_file_handle *this, 1954 efi_uintn_t *buffer_size, void *buffer); 1955 efi_status_t (EFIAPI *write)(struct efi_file_handle *this, 1956 efi_uintn_t *buffer_size, void *buffer); 1957 efi_status_t (EFIAPI *getpos)(struct efi_file_handle *this, 1958 u64 *pos); 1959 efi_status_t (EFIAPI *setpos)(struct efi_file_handle *this, 1960 u64 pos); 1961 efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *this, 1962 const efi_guid_t *info_type, efi_uintn_t *buffer_size, 1963 void *buffer); 1964 efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *this, 1965 const efi_guid_t *info_type, efi_uintn_t buffer_size, 1966 void *buffer); 1967 efi_status_t (EFIAPI *flush)(struct efi_file_handle *this); 1968 efi_status_t (EFIAPI *open_ex)(struct efi_file_handle *this, 1969 struct efi_file_handle **new_handle, 1970 u16 *file_name, u64 open_mode, u64 attributes, 1971 struct efi_file_io_token *token); 1972 efi_status_t (EFIAPI *read_ex)(struct efi_file_handle *this, 1973 struct efi_file_io_token *token); 1974 efi_status_t (EFIAPI *write_ex)(struct efi_file_handle *this, 1975 struct efi_file_io_token *token); 1976 efi_status_t (EFIAPI *flush_ex)(struct efi_file_handle *this, 1977 struct efi_file_io_token *token); 1978}; 1979 1980#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000 1981 1982struct efi_simple_file_system_protocol { 1983 u64 rev; 1984 efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this, 1985 struct efi_file_handle **root); 1986}; 1987 1988#define EFI_FILE_INFO_GUID \ 1989 EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \ 1990 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 1991 1992#define EFI_FILE_SYSTEM_INFO_GUID \ 1993 EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \ 1994 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 1995 1996#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \ 1997 EFI_GUID(0xdb47d7d3, 0xfe81, 0x11d3, \ 1998 0x9a, 0x35, 0x00, 0x90, 0x27, 0x3f, 0xC1, 0x4d) 1999 2000#define EFI_FILE_MODE_READ 0x0000000000000001 2001#define EFI_FILE_MODE_WRITE 0x0000000000000002 2002#define EFI_FILE_MODE_CREATE 0x8000000000000000 2003 2004#define EFI_FILE_READ_ONLY 0x0000000000000001 2005#define EFI_FILE_HIDDEN 0x0000000000000002 2006#define EFI_FILE_SYSTEM 0x0000000000000004 2007#define EFI_FILE_RESERVED 0x0000000000000008 2008#define EFI_FILE_DIRECTORY 0x0000000000000010 2009#define EFI_FILE_ARCHIVE 0x0000000000000020 2010#define EFI_FILE_VALID_ATTR 0x0000000000000037 2011 2012struct efi_file_info { 2013 u64 size; 2014 u64 file_size; 2015 u64 physical_size; 2016 struct efi_time create_time; 2017 struct efi_time last_access_time; 2018 struct efi_time modification_time; 2019 u64 attribute; 2020 u16 file_name[0]; 2021}; 2022 2023struct efi_file_system_info { 2024 u64 size; 2025 u8 read_only; 2026 u64 volume_size; 2027 u64 free_space; 2028 u32 block_size; 2029 u16 volume_label[0]; 2030}; 2031 2032#define EFI_DRIVER_BINDING_PROTOCOL_GUID \ 2033 EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\ 2034 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71) 2035struct efi_driver_binding_protocol { 2036 efi_status_t (EFIAPI * supported)( 2037 struct efi_driver_binding_protocol *this, 2038 efi_handle_t controller_handle, 2039 struct efi_device_path *remaining_device_path); 2040 efi_status_t (EFIAPI * start)( 2041 struct efi_driver_binding_protocol *this, 2042 efi_handle_t controller_handle, 2043 struct efi_device_path *remaining_device_path); 2044 efi_status_t (EFIAPI * stop)( 2045 struct efi_driver_binding_protocol *this, 2046 efi_handle_t controller_handle, 2047 efi_uintn_t number_of_children, 2048 efi_handle_t *child_handle_buffer); 2049 u32 version; 2050 efi_handle_t image_handle; 2051 efi_handle_t driver_binding_handle; 2052}; 2053 2054/* Current version of the Unicode collation protocol */ 2055#define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \ 2056 EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \ 2057 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49) 2058struct efi_unicode_collation_protocol { 2059 efi_intn_t (EFIAPI *stri_coll)( 2060 struct efi_unicode_collation_protocol *this, u16 *s1, u16 *s2); 2061 bool (EFIAPI *metai_match)(struct efi_unicode_collation_protocol *this, 2062 const u16 *string, const u16 *patter); 2063 void (EFIAPI *str_lwr)(struct efi_unicode_collation_protocol 2064 *this, u16 *string); 2065 void (EFIAPI *str_upr)(struct efi_unicode_collation_protocol *this, 2066 u16 *string); 2067 void (EFIAPI *fat_to_str)(struct efi_unicode_collation_protocol *this, 2068 efi_uintn_t fat_size, char *fat, u16 *string); 2069 bool (EFIAPI *str_to_fat)(struct efi_unicode_collation_protocol *this, 2070 const u16 *string, efi_uintn_t fat_size, 2071 char *fat); 2072 char *supported_languages; 2073}; 2074 2075struct efi_load_file_protocol { 2076 efi_status_t (EFIAPI *load_file)(struct efi_load_file_protocol *this, 2077 struct efi_device_path *file_path, 2078 bool boot_policy, 2079 efi_uintn_t *buffer_size, 2080 void *buffer); 2081}; 2082 2083struct efi_system_resource_entry { 2084 efi_guid_t fw_class; 2085 u32 fw_type; 2086 u32 fw_version; 2087 u32 lowest_supported_fw_version; 2088 u32 capsule_flags; 2089 u32 last_attempt_version; 2090 u32 last_attempt_status; 2091} __packed; 2092 2093struct efi_system_resource_table { 2094 u32 fw_resource_count; 2095 u32 fw_resource_count_max; 2096 u64 fw_resource_version; 2097 struct efi_system_resource_entry entries[]; 2098} __packed; 2099 2100/* Boot manager load options */ 2101#define LOAD_OPTION_ACTIVE 0x00000001 2102#define LOAD_OPTION_FORCE_RECONNECT 0x00000002 2103#define LOAD_OPTION_HIDDEN 0x00000008 2104/* All values 0x00000200-0x00001F00 are reserved */ 2105#define LOAD_OPTION_CATEGORY 0x00001F00 2106#define LOAD_OPTION_CATEGORY_BOOT 0x00000000 2107#define LOAD_OPTION_CATEGORY_APP 0x00000100 2108 2109/* 2110 * System Resource Table 2111 */ 2112/* Firmware Type Definitions */ 2113#define ESRT_FW_TYPE_UNKNOWN 0x00000000 2114#define ESRT_FW_TYPE_SYSTEMFIRMWARE 0x00000001 2115#define ESRT_FW_TYPE_DEVICEFIRMWARE 0x00000002 2116#define ESRT_FW_TYPE_UEFIDRIVER 0x00000003 2117 2118#define EFI_SYSTEM_RESOURCE_TABLE_GUID\ 2119 EFI_GUID(0xb122a263, 0x3661, 0x4f68,\ 2120 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80) 2121 2122/* Last Attempt Status Values */ 2123#define LAST_ATTEMPT_STATUS_SUCCESS 0x00000000 2124#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL 0x00000001 2125#define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES 0x00000002 2126#define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION 0x00000003 2127#define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT 0x00000004 2128#define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR 0x00000005 2129#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC 0x00000006 2130#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT 0x00000007 2131#define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES 0x00000008 2132 2133/* 2134 * The LastAttemptStatus values of 0x1000 - 0x4000 are reserved for vendor 2135 * usage. 2136 */ 2137#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN 0x00001000 2138#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX 0x00004000 2139 2140/* Certificate types in signature database */ 2141#define EFI_CERT_SHA1_GUID \ 2142 EFI_GUID(0x826ca512, 0xcf10, 0x4ac9, 0xb1, 0x87, \ 2143 0xbe, 0x01, 0x49, 0x66, 0x31, 0xbd) 2144#define EFI_CERT_SHA224_GUID \ 2145 EFI_GUID(0xb6e5233, 0xa65c, 0x44c9, 0x94, 0x07, \ 2146 0xd9, 0xab, 0x83, 0xbf, 0xc8, 0xbd) 2147#define EFI_CERT_SHA256_GUID \ 2148 EFI_GUID(0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, \ 2149 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28) 2150#define EFI_CERT_SHA384_GUID \ 2151 EFI_GUID(0xff3e5307, 0x9fd0, 0x48c9, 0x85, 0xf1, \ 2152 0x8a, 0xd5, 0x6c, 0x70, 0x1e, 0x01) 2153#define EFI_CERT_SHA512_GUID \ 2154 EFI_GUID(0x93e0fae, 0xa6c4, 0x4f50, 0x9f, 0x1b, \ 2155 0xd4, 0x1e, 0x2b, 0x89, 0xc1, 0x9a) 2156#define EFI_CERT_RSA2048_GUID \ 2157 EFI_GUID(0x3c5766e8, 0x269c, 0x4e34, 0xaa, 0x14, \ 2158 0xed, 0x77, 0x6e, 0x85, 0xb3, 0xb6) 2159#define EFI_CERT_X509_GUID \ 2160 EFI_GUID(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, \ 2161 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72) 2162#define EFI_CERT_X509_SHA256_GUID \ 2163 EFI_GUID(0x3bd2a492, 0x96c0, 0x4079, 0xb4, 0x20, \ 2164 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed) 2165#define EFI_CERT_X509_SHA384_GUID \ 2166 EFI_GUID(0x7076876e, 0x80c2, 0x4ee6, \ 2167 0xaa, 0xd2, 0x28, 0xb3, 0x49, 0xa6, 0x86, 0x5b) 2168#define EFI_CERT_X509_SHA512_GUID \ 2169 EFI_GUID(0x446dbf63, 0x2502, 0x4cda, \ 2170 0xbc, 0xfa, 0x24, 0x65, 0xd2, 0xb0, 0xfe, 0x9d) 2171#define EFI_CERT_TYPE_PKCS7_GUID \ 2172 EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 2173 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7) 2174 2175#define EFI_LZMA_COMPRESSED \ 2176 EFI_GUID(0xee4e5898, 0x3914, 0x4259, 0x9d, 0x6e, \ 2177 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf) 2178#define EFI_DXE_SERVICES \ 2179 EFI_GUID(0x05ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, \ 2180 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9) 2181#define EFI_HOB_LIST \ 2182 EFI_GUID(0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, \ 2183 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 2184#define EFI_MEMORY_TYPE \ 2185 EFI_GUID(0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \ 2186 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa) 2187#define EFI_MEM_STATUS_CODE_REC \ 2188 EFI_GUID(0x060cc026, 0x4c0d, 0x4dda, 0x8f, 0x41, \ 2189 0x59, 0x5f, 0xef, 0x00, 0xa5, 0x02) 2190#define EFI_GUID_EFI_ACPI1 \ 2191 EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, \ 2192 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 2193 2194/** 2195 * struct win_certificate_uefi_guid - A certificate that encapsulates 2196 * a GUID-specific signature 2197 * 2198 * @hdr: Windows certificate header 2199 * @cert_type: Certificate type 2200 * @cert_data: Certificate data 2201 */ 2202struct win_certificate_uefi_guid { 2203 WIN_CERTIFICATE hdr; 2204 efi_guid_t cert_type; 2205 u8 cert_data[]; 2206} __attribute__((__packed__)); 2207 2208/** 2209 * struct efi_variable_authentication_2 - A time-based authentication method 2210 * descriptor 2211 * 2212 * This structure describes an authentication information for 2213 * a variable with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 2214 * and should be included as part of a variable's value. 2215 * Only EFI_CERT_TYPE_PKCS7_GUID is accepted. 2216 * 2217 * @time_stamp: Descriptor's time stamp 2218 * @auth_info: Authentication info 2219 */ 2220struct efi_variable_authentication_2 { 2221 struct efi_time time_stamp; 2222 struct win_certificate_uefi_guid auth_info; 2223} __attribute__((__packed__)); 2224 2225/** 2226 * struct efi_firmware_image_authentication - Capsule authentication method 2227 * descriptor 2228 * 2229 * This structure describes an authentication information for 2230 * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set 2231 * and should be included as part of the capsule. 2232 * Only EFI_CERT_TYPE_PKCS7_GUID is accepted. 2233 * 2234 * @monotonic_count: Count to prevent replay 2235 * @auth_info: Authentication info 2236 */ 2237struct efi_firmware_image_authentication { 2238 uint64_t monotonic_count; 2239 struct win_certificate_uefi_guid auth_info; 2240} __attribute__((__packed__)); 2241 2242/** 2243 * struct efi_signature_data - A format of signature 2244 * 2245 * This structure describes a single signature in signature database. 2246 * 2247 * @signature_owner: Signature owner 2248 * @signature_data: Signature data 2249 */ 2250struct efi_signature_data { 2251 efi_guid_t signature_owner; 2252 u8 signature_data[]; 2253} __attribute__((__packed__)); 2254 2255/** 2256 * struct efi_signature_list - A format of signature database 2257 * 2258 * This structure describes a list of signatures with the same type. 2259 * An authenticated variable's value is a concatenation of one or more 2260 * efi_signature_list's. 2261 * 2262 * @signature_type: Signature type 2263 * @signature_list_size: Size of signature list 2264 * @signature_header_size: Size of signature header 2265 * @signature_size: Size of signature 2266 */ 2267struct efi_signature_list { 2268 efi_guid_t signature_type; 2269 u32 signature_list_size; 2270 u32 signature_header_size; 2271 u32 signature_size; 2272/* u8 signature_header[signature_header_size]; */ 2273/* struct efi_signature_data signatures[...][signature_size]; */ 2274} __attribute__((__packed__)); 2275 2276/* 2277 * Firmware management protocol 2278 */ 2279#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \ 2280 EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \ 2281 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7) 2282 2283#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 2284#define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 2285#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 2286#define IMAGE_ATTRIBUTE_IN_USE 0x0000000000000008 2287#define IMAGE_ATTRIBUTE_UEFI_IMAGE 0x0000000000000010 2288#define IMAGE_ATTRIBUTE_DEPENDENCY 0x0000000000000020 2289 2290#define IMAGE_COMPATIBILITY_CHECK_SUPPORTED 0x0000000000000001 2291 2292#define IMAGE_UPDATABLE_VALID 0x0000000000000001 2293#define IMAGE_UPDATABLE_INVALID 0x0000000000000002 2294#define IMAGE_UPDATABLE_INVALID_TYPE 0x0000000000000004 2295#define IMAGE_UPDATABLE_INVALID_OLLD 0x0000000000000008 2296#define IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE 0x0000000000000010 2297 2298#define PACKAGE_ATTRIBUTE_VERSION_UPDATABLE 0x0000000000000001 2299#define PACKAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 2300#define PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 2301 2302#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION 4 2303 2304typedef struct efi_firmware_image_dependencies { 2305 u8 dependencies[0]; 2306} efi_firmware_image_dep_t; 2307 2308struct efi_firmware_image_descriptor { 2309 u8 image_index; 2310 efi_guid_t image_type_id; 2311 u64 image_id; 2312 u16 *image_id_name; 2313 u32 version; 2314 u16 *version_name; 2315 efi_uintn_t size; 2316 u64 attributes_supported; 2317 u64 attributes_setting; 2318 u64 compatibilities; 2319 u32 lowest_supported_image_version; 2320 u32 last_attempt_version; 2321 u32 last_attempt_status; 2322 u64 hardware_instance; 2323 efi_firmware_image_dep_t *dependencies; 2324}; 2325 2326struct efi_firmware_management_protocol { 2327 efi_status_t (EFIAPI *get_image_info)( 2328 struct efi_firmware_management_protocol *this, 2329 efi_uintn_t *image_info_size, 2330 struct efi_firmware_image_descriptor *image_info, 2331 u32 *descriptor_version, 2332 u8 *descriptor_count, 2333 efi_uintn_t *descriptor_size, 2334 u32 *package_version, 2335 u16 **package_version_name); 2336 efi_status_t (EFIAPI *get_image)( 2337 struct efi_firmware_management_protocol *this, 2338 u8 image_index, 2339 void *image, 2340 efi_uintn_t *image_size); 2341 efi_status_t (EFIAPI *set_image)( 2342 struct efi_firmware_management_protocol *this, 2343 u8 image_index, 2344 const void *image, 2345 efi_uintn_t image_size, 2346 const void *vendor_code, 2347 efi_status_t (*progress)(efi_uintn_t completion), 2348 u16 **abort_reason); 2349 efi_status_t (EFIAPI *check_image)( 2350 struct efi_firmware_management_protocol *this, 2351 u8 image_index, 2352 const void *image, 2353 efi_uintn_t *image_size, 2354 u32 *image_updatable); 2355 efi_status_t (EFIAPI *get_package_info)( 2356 struct efi_firmware_management_protocol *this, 2357 u32 *package_version, 2358 u16 **package_version_name, 2359 u32 *package_version_name_maxlen, 2360 u64 *attributes_supported, 2361 u64 *attributes_setting); 2362 efi_status_t (EFIAPI *set_package_info)( 2363 struct efi_firmware_management_protocol *this, 2364 const void *image, 2365 efi_uintn_t *image_size, 2366 const void *vendor_code, 2367 u32 package_version, 2368 const u16 *package_version_name); 2369}; 2370 2371#define EFI_DISK_IO_PROTOCOL_GUID \ 2372 EFI_GUID(0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, \ 2373 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 2374 2375struct efi_disk { 2376 u64 revision; 2377 efi_status_t (EFIAPI *read_disk)(struct efi_disk *this, u32 media_id, 2378 u64 offset, efi_uintn_t buffer_size, 2379 void *buffer); 2380 2381 efi_status_t (EFIAPI *write_disk)(struct efi_disk *this, u32 media_id, 2382 u64 offset, efi_uintn_t buffer_size, 2383 void *buffer); 2384}; 2385 2386#endif