1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Relevant definitions from linux/efi.h. */ 3 4 #ifndef __LINUX_UEFI_H 5 #define __LINUX_UEFI_H 6 7 #include "libcflat.h" 8 9 #ifndef __packed 10 # define __packed __attribute__((__packed__)) 11 #endif 12 13 #define BITS_PER_LONG 64 14 15 #define EFI_ERROR(a) (((int64_t) a) < 0) 16 #define EFI_SUCCESS 0 17 #define EFI_LOAD_ERROR ( 1 | (1UL << (BITS_PER_LONG-1))) 18 #define EFI_INVALID_PARAMETER ( 2 | (1UL << (BITS_PER_LONG-1))) 19 #define EFI_UNSUPPORTED ( 3 | (1UL << (BITS_PER_LONG-1))) 20 #define EFI_BAD_BUFFER_SIZE ( 4 | (1UL << (BITS_PER_LONG-1))) 21 #define EFI_BUFFER_TOO_SMALL ( 5 | (1UL << (BITS_PER_LONG-1))) 22 #define EFI_NOT_READY ( 6 | (1UL << (BITS_PER_LONG-1))) 23 #define EFI_DEVICE_ERROR ( 7 | (1UL << (BITS_PER_LONG-1))) 24 #define EFI_WRITE_PROTECTED ( 8 | (1UL << (BITS_PER_LONG-1))) 25 #define EFI_OUT_OF_RESOURCES ( 9 | (1UL << (BITS_PER_LONG-1))) 26 #define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG-1))) 27 #define EFI_TIMEOUT (18 | (1UL << (BITS_PER_LONG-1))) 28 #define EFI_ABORTED (21 | (1UL << (BITS_PER_LONG-1))) 29 #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG-1))) 30 31 typedef unsigned long efi_status_t; 32 typedef u8 efi_bool_t; 33 typedef u16 efi_char16_t; /* UNICODE character */ 34 typedef u64 efi_physical_addr_t; 35 typedef void *efi_handle_t; 36 37 #ifdef __x86_64__ 38 #define __efiapi __attribute__((ms_abi)) 39 #else 40 #define __efiapi 41 #endif 42 43 /* 44 * The UEFI spec and EDK2 reference implementation both define EFI_GUID as 45 * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment 46 * is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM), 47 * this means that firmware services invoked by the kernel may assume that 48 * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that 49 * do not tolerate misalignment. So let's set the minimum alignment to 32 bits. 50 * 51 * Note that the UEFI spec as well as some comments in the EDK2 code base 52 * suggest that EFI_GUID should be 64-bit aligned, but this appears to be 53 * a mistake, given that no code seems to exist that actually enforces that 54 * or relies on it. 55 */ 56 typedef struct { 57 u8 b[16]; 58 } guid_t __attribute__((aligned(__alignof__(u32)))); 59 typedef guid_t efi_guid_t; 60 61 #define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \ 62 (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ 63 (b) & 0xff, ((b) >> 8) & 0xff, \ 64 (c) & 0xff, ((c) >> 8) & 0xff, d } } 65 66 #define ACPI_TABLE_GUID EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 67 #define ACPI_20_TABLE_GUID EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81) 68 69 #define DEVICE_TREE_GUID EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) 70 71 #define LOADED_IMAGE_PROTOCOL_GUID EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 72 73 #define EFI_LOAD_FILE2_PROTOCOL_GUID EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d) 74 #define LINUX_EFI_INITRD_MEDIA_GUID EFI_GUID(0x5568e427, 0x68fc, 0x4f3d, 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68) 75 76 typedef struct { 77 efi_guid_t guid; 78 void *table; 79 } efi_config_table_t; 80 81 /* 82 * Generic EFI table header 83 */ 84 typedef struct { 85 u64 signature; 86 u32 revision; 87 u32 headersize; 88 u32 crc32; 89 u32 reserved; 90 } efi_table_hdr_t; 91 92 /* 93 * Memory map descriptor: 94 */ 95 96 /* Memory types: */ 97 #define EFI_RESERVED_TYPE 0 98 #define EFI_LOADER_CODE 1 99 #define EFI_LOADER_DATA 2 100 #define EFI_BOOT_SERVICES_CODE 3 101 #define EFI_BOOT_SERVICES_DATA 4 102 #define EFI_RUNTIME_SERVICES_CODE 5 103 #define EFI_RUNTIME_SERVICES_DATA 6 104 #define EFI_CONVENTIONAL_MEMORY 7 105 #define EFI_UNUSABLE_MEMORY 8 106 #define EFI_ACPI_RECLAIM_MEMORY 9 107 #define EFI_ACPI_MEMORY_NVS 10 108 #define EFI_MEMORY_MAPPED_IO 11 109 #define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12 110 #define EFI_PAL_CODE 13 111 #define EFI_PERSISTENT_MEMORY 14 112 #define EFI_MAX_MEMORY_TYPE 15 113 114 /* Attribute values: */ 115 #define EFI_MEMORY_UC ((u64)0x0000000000000001ULL) /* uncached */ 116 #define EFI_MEMORY_WC ((u64)0x0000000000000002ULL) /* write-coalescing */ 117 #define EFI_MEMORY_WT ((u64)0x0000000000000004ULL) /* write-through */ 118 #define EFI_MEMORY_WB ((u64)0x0000000000000008ULL) /* write-back */ 119 #define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL) /* uncached, exported */ 120 #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ 121 #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ 122 #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ 123 #define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */ 124 #define EFI_MEMORY_MORE_RELIABLE \ 125 ((u64)0x0000000000010000ULL) /* higher reliability */ 126 #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ 127 #define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* soft reserved */ 128 #define EFI_MEMORY_CPU_CRYPTO ((u64)0x0000000000080000ULL) /* supports encryption */ 129 #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ 130 #define EFI_MEMORY_DESCRIPTOR_VERSION 1 131 132 #define EFI_PAGE_SHIFT 12 133 #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) 134 #define EFI_PAGES_MAX (U64_MAX >> EFI_PAGE_SHIFT) 135 136 typedef struct { 137 u32 type; 138 u32 pad; 139 u64 phys_addr; 140 u64 virt_addr; 141 u64 num_pages; 142 u64 attribute; 143 } efi_memory_desc_t; 144 145 typedef struct { 146 efi_guid_t guid; 147 u32 headersize; 148 u32 flags; 149 u32 imagesize; 150 } efi_capsule_header_t; 151 152 /* 153 * EFI capsule flags 154 */ 155 #define EFI_CAPSULE_PERSIST_ACROSS_RESET 0x00010000 156 #define EFI_CAPSULE_POPULATE_SYSTEM_TABLE 0x00020000 157 #define EFI_CAPSULE_INITIATE_RESET 0x00040000 158 159 struct capsule_info { 160 efi_capsule_header_t header; 161 efi_capsule_header_t *capsule; 162 int reset_type; 163 long index; 164 size_t count; 165 size_t total_size; 166 struct page **pages; 167 phys_addr_t *phys; 168 size_t page_bytes_remain; 169 }; 170 171 int __efi_capsule_setup_info(struct capsule_info *cap_info); 172 173 /* 174 * Types and defines for Time Services 175 */ 176 #define EFI_TIME_ADJUST_DAYLIGHT 0x1 177 #define EFI_TIME_IN_DAYLIGHT 0x2 178 #define EFI_UNSPECIFIED_TIMEZONE 0x07ff 179 180 typedef struct { 181 u16 year; 182 u8 month; 183 u8 day; 184 u8 hour; 185 u8 minute; 186 u8 second; 187 u8 pad1; 188 u32 nanosecond; 189 s16 timezone; 190 u8 daylight; 191 u8 pad2; 192 } efi_time_t; 193 194 typedef struct { 195 u32 resolution; 196 u32 accuracy; 197 u8 sets_to_zero; 198 } efi_time_cap_t; 199 200 typedef void *efi_event_t; 201 /* Note that notifications won't work in mixed mode */ 202 typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *); 203 204 typedef enum { 205 EfiTimerCancel, 206 EfiTimerPeriodic, 207 EfiTimerRelative 208 } EFI_TIMER_DELAY; 209 210 /* 211 * EFI Device Path information 212 */ 213 #define EFI_DEV_HW 0x01 214 #define EFI_DEV_PCI 1 215 #define EFI_DEV_PCCARD 2 216 #define EFI_DEV_MEM_MAPPED 3 217 #define EFI_DEV_VENDOR 4 218 #define EFI_DEV_CONTROLLER 5 219 #define EFI_DEV_ACPI 0x02 220 #define EFI_DEV_BASIC_ACPI 1 221 #define EFI_DEV_EXPANDED_ACPI 2 222 #define EFI_DEV_MSG 0x03 223 #define EFI_DEV_MSG_ATAPI 1 224 #define EFI_DEV_MSG_SCSI 2 225 #define EFI_DEV_MSG_FC 3 226 #define EFI_DEV_MSG_1394 4 227 #define EFI_DEV_MSG_USB 5 228 #define EFI_DEV_MSG_USB_CLASS 15 229 #define EFI_DEV_MSG_I20 6 230 #define EFI_DEV_MSG_MAC 11 231 #define EFI_DEV_MSG_IPV4 12 232 #define EFI_DEV_MSG_IPV6 13 233 #define EFI_DEV_MSG_INFINIBAND 9 234 #define EFI_DEV_MSG_UART 14 235 #define EFI_DEV_MSG_VENDOR 10 236 #define EFI_DEV_MEDIA 0x04 237 #define EFI_DEV_MEDIA_HARD_DRIVE 1 238 #define EFI_DEV_MEDIA_CDROM 2 239 #define EFI_DEV_MEDIA_VENDOR 3 240 #define EFI_DEV_MEDIA_FILE 4 241 #define EFI_DEV_MEDIA_PROTOCOL 5 242 #define EFI_DEV_BIOS_BOOT 0x05 243 #define EFI_DEV_END_PATH 0x7F 244 #define EFI_DEV_END_PATH2 0xFF 245 #define EFI_DEV_END_INSTANCE 0x01 246 #define EFI_DEV_END_ENTIRE 0xFF 247 248 struct efi_generic_dev_path { 249 u8 type; 250 u8 sub_type; 251 u16 length; 252 } __packed; 253 254 struct efi_vendor_dev_path { 255 struct efi_generic_dev_path header; 256 efi_guid_t vendorguid; 257 u8 vendordata[]; 258 } __packed; 259 260 typedef struct efi_generic_dev_path efi_device_path_protocol_t; 261 262 /* 263 * EFI Boot Services table 264 */ 265 typedef struct { 266 efi_table_hdr_t hdr; 267 void *raise_tpl; 268 void *restore_tpl; 269 efi_status_t(__efiapi *allocate_pages)(int, int, unsigned long, 270 efi_physical_addr_t *); 271 efi_status_t(__efiapi *free_pages)(efi_physical_addr_t, 272 unsigned long); 273 efi_status_t(__efiapi *get_memory_map)(unsigned long *, void *, 274 unsigned long *, 275 unsigned long *, u32 *); 276 efi_status_t(__efiapi *allocate_pool)(int, unsigned long, 277 void **); 278 efi_status_t(__efiapi *free_pool)(void *); 279 efi_status_t(__efiapi *create_event)(u32, unsigned long, 280 efi_event_notify_t, void *, 281 efi_event_t *); 282 efi_status_t(__efiapi *set_timer)(efi_event_t, 283 EFI_TIMER_DELAY, u64); 284 efi_status_t(__efiapi *wait_for_event)(unsigned long, 285 efi_event_t *, 286 unsigned long *); 287 void *signal_event; 288 efi_status_t(__efiapi *close_event)(efi_event_t); 289 void *check_event; 290 void *install_protocol_interface; 291 void *reinstall_protocol_interface; 292 void *uninstall_protocol_interface; 293 efi_status_t(__efiapi *handle_protocol)(efi_handle_t, 294 efi_guid_t *, void **); 295 void *__reserved; 296 void *register_protocol_notify; 297 efi_status_t(__efiapi *locate_handle)(int, efi_guid_t *, 298 void *, unsigned long *, 299 efi_handle_t *); 300 efi_status_t(__efiapi *locate_device_path)(efi_guid_t *, 301 efi_device_path_protocol_t **, 302 efi_handle_t *); 303 efi_status_t(__efiapi *install_configuration_table)(efi_guid_t *, 304 void *); 305 void *load_image; 306 void *start_image; 307 efi_status_t(__efiapi *exit)(efi_handle_t, 308 efi_status_t, 309 unsigned long, 310 efi_char16_t *); 311 void *unload_image; 312 efi_status_t(__efiapi *exit_boot_services)(efi_handle_t, 313 unsigned long); 314 void *get_next_monotonic_count; 315 efi_status_t(__efiapi *stall)(unsigned long); 316 void *set_watchdog_timer; 317 void *connect_controller; 318 efi_status_t(__efiapi *disconnect_controller)(efi_handle_t, 319 efi_handle_t, 320 efi_handle_t); 321 void *open_protocol; 322 void *close_protocol; 323 void *open_protocol_information; 324 void *protocols_per_handle; 325 void *locate_handle_buffer; 326 efi_status_t(__efiapi *locate_protocol)(efi_guid_t *, void *, 327 void **); 328 void *install_multiple_protocol_interfaces; 329 void *uninstall_multiple_protocol_interfaces; 330 void *calculate_crc32; 331 void *copy_mem; 332 void *set_mem; 333 void *create_event_ex; 334 } efi_boot_services_t; 335 336 /* 337 * Types and defines for EFI ResetSystem 338 */ 339 #define EFI_RESET_COLD 0 340 #define EFI_RESET_WARM 1 341 #define EFI_RESET_SHUTDOWN 2 342 343 /* 344 * EFI Runtime Services table 345 */ 346 #define EFI_RUNTIME_SERVICES_SIGNATURE ((u64)0x5652453544e5552ULL) 347 #define EFI_RUNTIME_SERVICES_REVISION 0x00010000 348 349 typedef efi_status_t efi_get_time_t (efi_time_t *tm, efi_time_cap_t *tc); 350 typedef efi_status_t efi_set_time_t (efi_time_t *tm); 351 typedef efi_status_t efi_get_wakeup_time_t (efi_bool_t *enabled, efi_bool_t *pending, 352 efi_time_t *tm); 353 typedef efi_status_t efi_set_wakeup_time_t (efi_bool_t enabled, efi_time_t *tm); 354 typedef efi_status_t efi_get_variable_t (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, 355 unsigned long *data_size, void *data); 356 typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_char16_t *name, 357 efi_guid_t *vendor); 358 typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, 359 u32 attr, unsigned long data_size, 360 void *data); 361 typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); 362 typedef void efi_reset_system_t (int reset_type, efi_status_t status, 363 unsigned long data_size, efi_char16_t *data); 364 typedef efi_status_t efi_set_virtual_address_map_t (unsigned long memory_map_size, 365 unsigned long descriptor_size, 366 u32 descriptor_version, 367 efi_memory_desc_t *virtual_map); 368 typedef efi_status_t efi_query_variable_info_t(u32 attr, 369 u64 *storage_space, 370 u64 *remaining_space, 371 u64 *max_variable_size); 372 typedef efi_status_t efi_update_capsule_t(efi_capsule_header_t **capsules, 373 unsigned long count, 374 unsigned long sg_list); 375 typedef efi_status_t efi_query_capsule_caps_t(efi_capsule_header_t **capsules, 376 unsigned long count, 377 u64 *max_size, 378 int *reset_type); 379 typedef efi_status_t efi_query_variable_store_t(u32 attributes, 380 unsigned long size, 381 bool nonblocking); 382 383 typedef struct { 384 efi_table_hdr_t hdr; 385 efi_get_time_t __efiapi *get_time; 386 efi_set_time_t __efiapi *set_time; 387 efi_get_wakeup_time_t __efiapi *get_wakeup_time; 388 efi_set_wakeup_time_t __efiapi *set_wakeup_time; 389 efi_set_virtual_address_map_t __efiapi *set_virtual_address_map; 390 void *convert_pointer; 391 efi_get_variable_t __efiapi *get_variable; 392 efi_get_next_variable_t __efiapi *get_next_variable; 393 efi_set_variable_t __efiapi *set_variable; 394 efi_get_next_high_mono_count_t __efiapi *get_next_high_mono_count; 395 efi_reset_system_t __efiapi *reset_system; 396 efi_update_capsule_t __efiapi *update_capsule; 397 efi_query_capsule_caps_t __efiapi *query_capsule_caps; 398 efi_query_variable_info_t __efiapi *query_variable_info; 399 } efi_runtime_services_t; 400 401 #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL) 402 403 #define EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30)) 404 #define EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20)) 405 #define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10)) 406 #define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00)) 407 #define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10)) 408 #define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02)) 409 410 typedef union efi_simple_text_input_protocol efi_simple_text_input_protocol_t; 411 typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t; 412 413 typedef struct { 414 efi_table_hdr_t hdr; 415 unsigned long fw_vendor; /* physical addr of CHAR16 vendor string */ 416 u32 fw_revision; 417 unsigned long con_in_handle; 418 efi_simple_text_input_protocol_t *con_in; 419 unsigned long con_out_handle; 420 efi_simple_text_output_protocol_t *con_out; 421 unsigned long stderr_handle; 422 unsigned long stderr; 423 efi_runtime_services_t *runtime; 424 efi_boot_services_t *boottime; 425 unsigned long nr_tables; 426 unsigned long tables; 427 } efi_system_table_t; 428 429 struct efi_boot_memmap { 430 efi_memory_desc_t **map; 431 unsigned long *map_size; 432 unsigned long *desc_size; 433 u32 *desc_ver; 434 unsigned long *key_ptr; 435 unsigned long *buff_size; 436 }; 437 438 #define __aligned_u64 u64 __attribute__((aligned(8))) 439 440 struct efi_loaded_image_64 { 441 u32 revision; 442 efi_handle_t parent_handle; 443 efi_system_table_t *system_table; 444 efi_handle_t device_handle; 445 void *file_path; 446 void *reserved; 447 u32 load_options_size; 448 void *load_options; 449 void *image_base; 450 __aligned_u64 image_size; 451 unsigned int image_code_type; 452 unsigned int image_data_type; 453 efi_status_t (__efiapi * unload)(efi_handle_t image_handle); 454 }; 455 456 457 typedef struct _efi_simple_file_system_protocol efi_simple_file_system_protocol_t; 458 typedef struct _efi_file_protocol efi_file_protocol_t; 459 typedef efi_simple_file_system_protocol_t efi_file_io_interface_t; 460 typedef efi_file_protocol_t efi_file_t; 461 typedef union efi_load_file_protocol efi_load_file_protocol_t; 462 typedef union efi_load_file_protocol efi_load_file2_protocol_t; 463 464 union efi_load_file_protocol { 465 struct { 466 efi_status_t (__efiapi *load_file)(efi_load_file_protocol_t *, 467 efi_device_path_protocol_t *, 468 bool, unsigned long *, void *); 469 }; 470 struct { 471 u32 load_file; 472 } mixed_mode; 473 }; 474 475 typedef efi_status_t efi_simple_file_system_protocol_open_volume( 476 efi_simple_file_system_protocol_t *this, 477 efi_file_protocol_t **root); 478 479 #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID EFI_GUID(0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 480 481 struct _efi_simple_file_system_protocol { 482 uint64_t revision; 483 efi_simple_file_system_protocol_open_volume __efiapi *open_volume; 484 }; 485 486 /* Open modes */ 487 #define EFI_FILE_MODE_READ 0x0000000000000001ULL 488 #define EFI_FILE_MODE_WRITE 0x0000000000000002ULL 489 #define EFI_FILE_MODE_CREATE 0x8000000000000000ULL 490 491 typedef efi_status_t efi_file_open(efi_file_protocol_t *this, 492 efi_file_protocol_t **new_handle, 493 efi_char16_t *file_name, 494 uint64_t open_mode, 495 uint64_t attributes); 496 typedef efi_status_t efi_file_close(efi_file_protocol_t *this); 497 typedef efi_status_t efi_file_delete(efi_file_protocol_t *this); 498 typedef efi_status_t efi_file_read(efi_file_protocol_t *this, 499 uint64_t *buffer_size, 500 void *buffer); 501 typedef efi_status_t efi_file_write(efi_file_protocol_t *this, 502 uint64_t *buffer_size, 503 void *buffer); 504 typedef efi_status_t efi_file_set_position(efi_file_protocol_t *this, 505 uint64_t position); 506 typedef efi_status_t efi_file_get_position(efi_file_protocol_t *this, 507 uint64_t *position); 508 typedef efi_status_t efi_file_get_info(efi_file_protocol_t *this, 509 efi_guid_t *information_type, 510 uint64_t *buffer_size, 511 void *buffer); 512 typedef efi_status_t efi_file_set_info(efi_file_protocol_t *this, 513 efi_guid_t *information_type, 514 uint64_t *buffer_size, 515 void *buffer); 516 typedef efi_status_t efi_file_flush(efi_file_protocol_t *this); 517 518 typedef struct { 519 efi_event_t event; 520 efi_status_t status; 521 uint64_t buffer_size; 522 void *buffer; 523 } efi_file_io_open_t; 524 525 typedef efi_status_t efi_file_open_ex(efi_file_protocol_t *this, 526 efi_file_protocol_t **new_handle, 527 efi_char16_t *file_name, 528 uint64_t open_mode, 529 uint64_t attributes, 530 efi_file_io_open_t *token); 531 typedef efi_status_t efi_file_read_ex(efi_file_protocol_t *this, 532 efi_file_io_open_t *token); 533 typedef efi_status_t efi_file_write_ex(efi_file_protocol_t *this, 534 efi_file_io_open_t *token); 535 typedef efi_status_t efi_file_flush_ex(efi_file_protocol_t *this, 536 efi_file_io_open_t *token); 537 538 struct _efi_file_protocol { 539 uint64_t revision; 540 efi_file_open __efiapi *open; 541 efi_file_close __efiapi *close; 542 efi_file_delete __efiapi *delete; 543 efi_file_read __efiapi *read; 544 efi_file_write __efiapi *write; 545 efi_file_get_position __efiapi *get_position; 546 efi_file_set_position __efiapi *set_position; 547 efi_file_get_info __efiapi *get_info; 548 efi_file_set_info __efiapi *set_info; 549 efi_file_flush __efiapi *flush; 550 efi_file_open_ex __efiapi *open_ex; 551 efi_file_read_ex __efiapi *read_ex; 552 efi_file_write_ex __efiapi *write_ex; 553 efi_file_flush_ex __efiapi *flush_ex; 554 }; 555 556 #define EFI_FILE_INFO_ID EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 557 558 typedef struct { 559 uint64_t size; 560 uint64_t file_size; 561 uint64_t physical_size; 562 efi_time_t create_time; 563 efi_time_t last_access_time; 564 efi_time_t modification_time; 565 uint64_t attributes; 566 efi_char16_t file_name[1]; 567 } efi_file_info_t; 568 569 #define efi_fn_call(inst, func, ...) (inst)->func(__VA_ARGS__) 570 #define efi_bs_call(func, ...) efi_system_table->boottime->func(__VA_ARGS__) 571 #define efi_rs_call(func, ...) efi_system_table->runtime->func(__VA_ARGS__) 572 #define efi_call_proto(inst, func, ...) ({ \ 573 __typeof__(inst) __inst = (inst); \ 574 efi_fn_call(__inst, func, __inst, ##__VA_ARGS__); \ 575 }) 576 577 #endif /* __LINUX_UEFI_H */ 578