📄 api.h
字号:
/* efi.h - declare EFI types and functions *//* * GRUB -- GRand Unified Bootloader * Copyright (C) 2006,2007 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GRUB is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GRUB. If not, see <http://www.gnu.org/licenses/>. */#ifndef GRUB_EFI_API_HEADER#define GRUB_EFI_API_HEADER 1#include <grub/types.h>/* For consistency and safety, we name the EFI-defined types differently. All names are transformed into lower case, _t appended, and grub_efi_ prepended. *//* Constants. */#define GRUB_EFI_EVT_TIMER 0x80000000#define GRUB_EFI_EVT_RUNTIME 0x40000000#define GRUB_EFI_EVT_RUNTIME_CONTEXT 0x20000000#define GRUB_EFI_EVT_NOTIFY_WAIT 0x00000100#define GRUB_EFI_EVT_NOTIFY_SIGNAL 0x00000200#define GRUB_EFI_EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201#define GRUB_EFI_EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202#define GRUB_EFI_TPL_APPLICATION 4#define GRUB_EFI_TPL_CALLBACK 8#define GRUB_EFI_TPL_NOTIFY 16#define GRUB_EFI_TPL_HIGH_LEVEL 31#define GRUB_EFI_MEMORY_UC 0x0000000000000001#define GRUB_EFI_MEMORY_WC 0x0000000000000002#define GRUB_EFI_MEMORY_WT 0x0000000000000004#define GRUB_EFI_MEMORY_WB 0x0000000000000008#define GRUB_EFI_MEMORY_UCE 0x0000000000000010#define GRUB_EFI_MEMORY_WP 0x0000000000001000#define GRUB_EFI_MEMORY_RP 0x0000000000002000#define GRUB_EFI_MEMORY_XP 0x0000000000004000#define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000#define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001#define GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002#define GRUB_EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004#define GRUB_EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008#define GRUB_EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010#define GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE 0x00000020#define GRUB_EFI_VARIABLE_NON_VOLATILE 0x0000000000000001#define GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002#define GRUB_EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004#define GRUB_EFI_TIME_ADJUST_DAYLIGHT 0x01#define GRUB_EFI_TIME_IN_DAYLIGHT 0x02#define GRUB_EFI_UNSPECIFIED_TIMEZONE 0x07FF#define GRUB_EFI_OPTIONAL_PTR 0x00000001#define GRUB_EFI_LOADED_IMAGE_GUID \ { 0x5b1b31a1, 0x9562, 0x11d2, \ { 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ }#define GRUB_EFI_DISK_IO_GUID \ { 0xce345171, 0xba0b, 0x11d2, \ { 0x8e, 0x4f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ }#define GRUB_EFI_BLOCK_IO_GUID \ { 0x964e5b21, 0x6459, 0x11d2, \ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ }#define GRUB_EFI_DEVICE_PATH_GUID \ { 0x09576e91, 0x6d3f, 0x11d2, \ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ }/* Enumerations. */enum grub_efi_timer_delay { GRUB_EFI_TIMER_CANCEL, GRUB_EFI_TIMER_PERIODIC, GRUB_EFI_TIMER_RELATIVE };typedef enum grub_efi_timer_delay grub_efi_timer_delay_t;enum grub_efi_allocate_type { GRUB_EFI_ALLOCATE_ANY_PAGES, GRUB_EFI_ALLOCATE_MAX_ADDRESS, GRUB_EFI_ALLOCATE_ADDRESS, GRUB_EFI_MAX_ALLOCATION_TYPE };typedef enum grub_efi_allocate_type grub_efi_allocate_type_t;enum grub_efi_memory_type { GRUB_EFI_RESERVED_MEMORY_TYPE, GRUB_EFI_LOADER_CODE, GRUB_EFI_LOADER_DATA, GRUB_EFI_BOOT_SERVICES_CODE, GRUB_EFI_BOOT_SERVICES_DATA, GRUB_EFI_RUNTIME_SERVICES_CODE, GRUB_EFI_RUNTIME_SERVICES_DATA, GRUB_EFI_CONVENTIONAL_MEMORY, GRUB_EFI_UNUSABLE_MEMORY, GRUB_EFI_ACPI_RECLAIM_MEMORY, GRUB_EFI_ACPI_MEMORY_NVS, GRUB_EFI_MEMORY_MAPPED_IO, GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE, GRUB_EFI_PAL_CODE, GRUB_EFI_MAX_MEMORY_TYPE };typedef enum grub_efi_memory_type grub_efi_memory_type_t;enum grub_efi_interface_type { GRUB_EFI_NATIVE_INTERFACE };typedef enum grub_efi_interface_type grub_efi_interface_type_t;enum grub_efi_locate_search_type { GRUB_EFI_ALL_HANDLES, GRUB_EFI_BY_REGISTER_NOTIFY, GRUB_EFI_BY_PROTOCOL };typedef enum grub_efi_locate_search_type grub_efi_locate_search_type_t;enum grub_efi_reset_type { GRUB_EFI_RESET_COLD, GRUB_EFI_RESET_WARM, GRUB_EFI_RESET_SHUTDOWN };typedef enum grub_efi_reset_type grub_efi_reset_type_t;/* Types. */typedef char grub_efi_boolean_t;typedef long grub_efi_intn_t;typedef unsigned long grub_efi_uintn_t;typedef grub_int8_t grub_efi_int8_t;typedef grub_uint8_t grub_efi_uint8_t;typedef grub_int16_t grub_efi_int16_t;typedef grub_uint16_t grub_efi_uint16_t;typedef grub_int32_t grub_efi_int32_t;typedef grub_uint32_t grub_efi_uint32_t;typedef grub_int64_t grub_efi_int64_t;typedef grub_uint64_t grub_efi_uint64_t;typedef grub_uint8_t grub_efi_char8_t;typedef grub_uint16_t grub_efi_char16_t;typedef grub_efi_intn_t grub_efi_status_t;#define GRUB_EFI_ERROR_CODE(value) \ ((1L << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))#define GRUB_EFI_WARNING_CODE(value) (value)#define GRUB_EFI_SUCCESS 0#define GRUB_EFI_LOAD_ERROR GRUB_EFI_ERROR_CODE (1)#define GRUB_EFI_INVALID_PARAMETER GRUB_EFI_ERROR_CODE (2)#define GRUB_EFI_UNSUPPORTED GRUB_EFI_ERROR_CODE (3)#define GRUB_EFI_BAD_BUFFER_SIZE GRUB_EFI_ERROR_CODE (4)#define GRUB_EFI_BUFFER_TOO_SMALL GRUB_EFI_ERROR_CODE (5)#define GRUB_EFI_NOT_READY GRUB_EFI_ERROR_CODE (6)#define GRUB_EFI_DEVICE_ERROR GRUB_EFI_ERROR_CODE (7)#define GRUB_EFI_WRITE_PROTECTED GRUB_EFI_ERROR_CODE (8)#define GRUB_EFI_OUT_OF_RESOURCES GRUB_EFI_ERROR_CODE (9)#define GRUB_EFI_VOLUME_CORRUPTED GRUB_EFI_ERROR_CODE (10)#define GRUB_EFI_VOLUME_FULL GRUB_EFI_ERROR_CODE (11)#define GRUB_EFI_NO_MEDIA GRUB_EFI_ERROR_CODE (12)#define GRUB_EFI_MEDIA_CHANGED GRUB_EFI_ERROR_CODE (13)#define GRUB_EFI_NOT_FOUND GRUB_EFI_ERROR_CODE (14)#define GRUB_EFI_ACCESS_DENIED GRUB_EFI_ERROR_CODE (15)#define GRUB_EFI_NO_RESPONSE GRUB_EFI_ERROR_CODE (16)#define GRUB_EFI_NO_MAPPING GRUB_EFI_ERROR_CODE (17)#define GRUB_EFI_TIMEOUT GRUB_EFI_ERROR_CODE (18)#define GRUB_EFI_NOT_STARTED GRUB_EFI_ERROR_CODE (19)#define GRUB_EFI_ALREADY_STARTED GRUB_EFI_ERROR_CODE (20)#define GRUB_EFI_ABORTED GRUB_EFI_ERROR_CODE (21)#define GRUB_EFI_ICMP_ERROR GRUB_EFI_ERROR_CODE (22)#define GRUB_EFI_TFTP_ERROR GRUB_EFI_ERROR_CODE (23)#define GRUB_EFI_PROTOCOL_ERROR GRUB_EFI_ERROR_CODE (24)#define GRUB_EFI_INCOMPATIBLE_VERSION GRUB_EFI_ERROR_CODE (25)#define GRUB_EFI_SECURITY_VIOLATION GRUB_EFI_ERROR_CODE (26)#define GRUB_EFI_CRC_ERROR GRUB_EFI_ERROR_CODE (27)#define GRUB_EFI_WARN_UNKNOWN_GLYPH GRUB_EFI_WARNING_CODE (1)#define GRUB_EFI_WARN_DELETE_FAILURE GRUB_EFI_WARNING_CODE (2)#define GRUB_EFI_WARN_WRITE_FAILURE GRUB_EFI_WARNING_CODE (3)#define GRUB_EFI_WARN_BUFFER_TOO_SMALL GRUB_EFI_WARNING_CODE (4)typedef void *grub_efi_handle_t;typedef void *grub_efi_event_t;typedef grub_efi_uint64_t grub_efi_lba_t;typedef grub_efi_uintn_t grub_efi_tpl_t;typedef grub_uint8_t grub_efi_mac_address_t[32];typedef grub_uint8_t grub_efi_ipv4_address_t[4];typedef grub_uint16_t grub_efi_ipv6_address_t[8];typedef grub_uint8_t grub_efi_ip_address_t[8] __attribute__ ((aligned(4)));typedef grub_efi_uint64_t grub_efi_physical_address_t;typedef grub_efi_uint64_t grub_efi_virtual_address_t;struct grub_efi_guid{ grub_uint32_t data1; grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8];} __attribute__ ((aligned(8)));typedef struct grub_efi_guid grub_efi_guid_t;/* XXX although the spec does not specify the padding, this actually must have the padding! */struct grub_efi_memory_descriptor{ grub_efi_uint32_t type; grub_efi_uint32_t padding; grub_efi_physical_address_t physical_start; grub_efi_virtual_address_t virtual_start; grub_efi_uint64_t num_pages; grub_efi_uint64_t attribute;};typedef struct grub_efi_memory_descriptor grub_efi_memory_descriptor_t;/* Device Path definitions. */struct grub_efi_device_path{ grub_efi_uint8_t type; grub_efi_uint8_t subtype; grub_efi_uint8_t length[2];};typedef struct grub_efi_device_path grub_efi_device_path_t;/* XXX EFI does not define EFI_DEVICE_PATH_PROTOCOL but uses it. It seems to be identical to EFI_DEVICE_PATH. */typedef struct grub_efi_device_path grub_efi_device_path_protocol_t;#define GRUB_EFI_DEVICE_PATH_TYPE(dp) ((dp)->type & 0x7f)#define GRUB_EFI_DEVICE_PATH_SUBTYPE(dp) ((dp)->subtype)#define GRUB_EFI_DEVICE_PATH_LENGTH(dp) \ ((dp)->length[0] | ((grub_efi_uint16_t) ((dp)->length[1]) << 8))/* The End of Device Path nodes. */#define GRUB_EFI_END_DEVICE_PATH_TYPE (0xff & 0x7f)#define GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff#define GRUB_EFI_END_THIS_DEVICE_PATH_SUBTYPE 0x01#define GRUB_EFI_END_ENTIRE_DEVICE_PATH(dp) \ (GRUB_EFI_DEVICE_PATH_TYPE (dp) == GRUB_EFI_END_DEVICE_PATH_TYPE \ && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dp) \ == GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE))#define GRUB_EFI_NEXT_DEVICE_PATH(dp) \ ((grub_efi_device_path_t *) ((char *) (dp) \ + GRUB_EFI_DEVICE_PATH_LENGTH (dp)))/* Hardware Device Path. */#define GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE 1#define GRUB_EFI_PCI_DEVICE_PATH_SUBTYPE 1struct grub_efi_pci_device_path{ grub_efi_device_path_t header; grub_efi_uint8_t function; grub_efi_uint8_t device;};typedef struct grub_efi_pci_device_path grub_efi_pci_device_path_t;#define GRUB_EFI_PCCARD_DEVICE_PATH_SUBTYPE 2struct grub_efi_pccard_device_path{ grub_efi_device_path_t header; grub_efi_uint8_t function;};typedef struct grub_efi_pccard_device_path grub_efi_pccard_device_path_t;#define GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE 3struct grub_efi_memory_mapped_device_path{ grub_efi_device_path_t header; grub_efi_memory_type_t memory_type; grub_efi_physical_address_t start_address; grub_efi_physical_address_t end_address;};typedef struct grub_efi_memory_mapped_device_path grub_efi_memory_mapped_device_path_t;#define GRUB_EFI_VENDOR_DEVICE_PATH_SUBTYPE 4struct grub_efi_vendor_device_path{ grub_efi_device_path_t header; grub_efi_guid_t vendor_guid; grub_efi_uint8_t vendor_defined_data[0];};typedef struct grub_efi_vendor_device_path grub_efi_vendor_device_path_t;#define GRUB_EFI_CONTROLLER_DEVICE_PATH_SUBTYPE 5struct grub_efi_controller_device_path{ grub_efi_device_path_t header; grub_efi_uint32_t controller_number;};typedef struct grub_efi_controller_device_path grub_efi_controller_device_path_t;/* ACPI Device Path. */#define GRUB_EFI_ACPI_DEVICE_PATH_TYPE 2#define GRUB_EFI_ACPI_DEVICE_PATH_SUBTYPE 1struct grub_efi_acpi_device_path{ grub_efi_device_path_t header; grub_efi_uint32_t hid; grub_efi_uint32_t uid;};typedef struct grub_efi_acpi_device_path grub_efi_acpi_device_path_t;#define GRUB_EFI_EXPANDED_ACPI_DEVICE_PATH_SUBTYPE 2struct grub_efi_expanded_acpi_device_path{ grub_efi_device_path_t header; grub_efi_uint32_t hid; grub_efi_uint32_t uid; grub_efi_uint32_t cid; char hidstr[1];};typedef struct grub_efi_expanded_acpi_device_path grub_efi_expanded_acpi_device_path_t;#define GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \ (((grub_efi_expanded_acpi_device_path_t *) dp)->hidstr)#define GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \ (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp) \ + grub_strlen (GRUB_EFI_EXPANDED_ACPI_HIDSTR(dp)) + 1)#define GRUB_EFI_EXPANDED_ACPI_CIDSTR(dp) \ (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp) \ + grub_strlen (GRUB_EFI_EXPANDED_ACPI_UIDSTR(dp)) + 1)/* Messaging Device Path. */#define GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE 3#define GRUB_EFI_ATAPI_DEVICE_PATH_SUBTYPE 1struct grub_efi_atapi_device_path{ grub_efi_device_path_t header; grub_efi_uint8_t primary_secondary;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -