2 efi.[ch] - Extensible Firmware Interface definitions
4 Copyright (C) 2001, 2003 Dell Computer Corporation <Matt_Domsch@dell.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Extensible Firmware Interface
26 * Based on 'Extensible Firmware Interface Specification'
27 * version 1.02, 12 December, 2000
32 #define BITS_PER_LONG (sizeof(unsigned long) * 8)
34 #define EFI_ERROR(x) ((x) | (1L << (BITS_PER_LONG - 1)))
37 #define EFI_LOAD_ERROR EFI_ERROR(1)
38 #define EFI_INVALID_PARAMETER EFI_ERROR(2)
39 #define EFI_UNSUPPORTED EFI_ERROR(3)
40 #define EFI_BAD_BUFFER_SIZE EFI_ERROR(4)
41 #define EFI_BUFFER_TOO_SMALL EFI_ERROR(5)
42 #define EFI_NOT_FOUND EFI_ERROR(14)
43 #define EFI_OUT_OF_RESOURCES EFI_ERROR(15)
46 /*******************************************************
47 * Boot Option Attributes
48 *******************************************************/
49 #define LOAD_OPTION_ACTIVE 0x00000001
51 /******************************************************
52 * EFI Variable Attributes
53 ******************************************************/
54 #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
55 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
56 #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
63 #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
65 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
66 (b) & 0xff, ((b) >> 8) & 0xff, \
67 (c) & 0xff, ((c) >> 8) & 0xff, \
68 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
71 /******************************************************
73 ******************************************************/
74 #define DEVICE_PATH_PROTOCOL \
75 EFI_GUID( 0x09576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
76 #define EFI_GLOBAL_VARIABLE \
77 EFI_GUID( 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C)
78 #define EDD10_HARDWARE_VENDOR_PATH_GUID \
79 EFI_GUID( 0xCF31FAC5, 0xC24E, 0x11d2, 0x85, 0xF3, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B)
80 #define BLKX_UNKNOWN_GUID \
81 EFI_GUID( 0x47c7b225, 0xc42a, 0x11d2, 0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
82 #define DIR_UNKNOWN_GUID \
83 EFI_GUID( 0x47c7b227, 0xc42a, 0x11d2, 0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
84 #define ESP_UNKNOWN_GUID \
85 EFI_GUID( 0x47c7b226, 0xc42a, 0x11d2, 0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
88 efi_guidcmp(efi_guid_t left, efi_guid_t right)
90 return memcmp(&left, &right, sizeof (efi_guid_t));
94 typedef unsigned long efi_status_t;
95 typedef uint8_t efi_bool_t;
96 typedef uint16_t efi_char16_t; /* UNICODE character */
98 typedef struct _efi_variable_t {
99 efi_char16_t VariableName[1024/sizeof(efi_char16_t)];
100 efi_guid_t VendorGuid;
105 } __attribute__((packed)) efi_variable_t;
113 } __attribute__((packed)) EFI_DEVICE_PATH;
117 uint16_t file_path_list_length;
118 efi_char16_t description[1];
119 EFI_DEVICE_PATH _unused_file_path_list[1];
120 } __attribute__((packed)) EFI_LOAD_OPTION;
129 } __attribute__((packed)) ACPI_DEVICE_PATH;
135 efi_guid_t vendor_guid;
137 } __attribute__((packed)) VENDOR_DEVICE_PATH;
139 #define EDD10_HARDWARE_VENDOR_PATH_LENGTH 24
147 } __attribute__((packed)) PCI_DEVICE_PATH;
154 } __attribute__((packed)) PCCARD_DEVICE_PATH;
160 uint32_t memory_type;
163 } __attribute__((packed)) MEMORY_MAPPED_DEVICE_PATH;
170 } __attribute__((packed)) CONTROLLER_DEVICE_PATH;
179 } __attribute__((packed)) SCSI_DEVICE_PATH;
185 uint8_t primary_secondary;
186 uint8_t slave_master;
188 } __attribute__((packed)) ATAPI_DEVICE_PATH;
197 } __attribute__((packed)) FIBRE_CHANNEL_DEVICE_PATH;
205 } __attribute__((packed)) I1394_DEVICE_PATH;
213 } __attribute__((packed)) USB_DEVICE_PATH;
224 } __attribute__((packed)) USB_CLASS_DEVICE_PATH;
231 } __attribute__((packed)) I2O_DEVICE_PATH;
239 } __attribute__((packed)) MAC_ADDR_DEVICE_PATH;
248 uint16_t remote_port;
251 } __attribute__((packed)) IPv4_DEVICE_PATH;
257 uint8_t local_ip[16];
258 uint8_t remote_ip[16];
260 uint16_t remote_port;
263 } __attribute__((packed)) IPv6_DEVICE_PATH;
273 } __attribute__((packed)) INFINIBAND_DEVICE_PATH;
284 } __attribute__((packed)) UART_DEVICE_PATH;
294 uint8_t signature[16];
296 uint8_t signature_type;
297 uint8_t padding[6]; /* Emperically needed */
298 } __attribute__((packed)) HARDDRIVE_DEVICE_PATH;
307 } __attribute__((packed)) CDROM_DEVICE_PATH;
313 efi_char16_t path_name[1];
314 } __attribute__((packed)) FILE_PATH_DEVICE_PATH;
322 } __attribute__((packed)) MEDIA_PROTOCOL_DEVICE_PATH;
328 uint16_t device_type;
329 uint16_t status_flag;
330 uint8_t description[1];
331 } __attribute__((packed)) BIOS_BOOT_SPEC_DEVICE_PATH;
337 } __attribute__((packed)) END_DEVICE_PATH;
340 struct efivar_kernel_calls {
341 efi_status_t (*read)(const char *name, efi_variable_t *var);
342 efi_status_t (*edit)(const char *name, efi_variable_t *var);
343 efi_status_t (*create)(efi_variable_t *var);
344 efi_status_t (*delete)(efi_variable_t *var);
349 /* Used for ACPI _HID */
350 #define EISAID_PNP0A03 0xa0341d0
352 /* Exported functions */
354 extern int make_linux_efi_variable(efi_variable_t *var,
355 unsigned int free_number);
356 extern char * efi_guid_unparse(efi_guid_t *guid, char *out);
357 extern EFI_DEVICE_PATH *load_option_path(EFI_LOAD_OPTION *option);
359 extern efi_status_t read_variable(const char *name, efi_variable_t *var);
360 extern efi_status_t edit_variable(efi_variable_t *var);
361 extern efi_status_t create_variable(efi_variable_t *var);
362 extern efi_status_t delete_variable(efi_variable_t *var);
363 extern efi_status_t create_or_edit_variable(efi_variable_t *var);
365 extern void set_fs_kernel_calls();
366 extern int read_boot_var_names(struct dirent ***namelist);
367 extern int variable_to_name(efi_variable_t *var, char *name);
368 extern int var_name_to_path(const char *name, char *path);