2 efi.[ch] - Manipulates EFI variables as exported in /proc/efi/vars
4 Copyright (C) 2001 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
31 #define BITS_PER_LONG (sizeof(unsigned long) * 8)
33 #define EFI_ERROR(x) ((x) | (1L << (BITS_PER_LONG - 1)))
36 #define EFI_LOAD_ERROR EFI_ERROR(1)
37 #define EFI_INVALID_PARAMETER EFI_ERROR(2)
38 #define EFI_UNSUPPORTED EFI_ERROR(3)
39 #define EFI_BAD_BUFFER_SIZE EFI_ERROR(4)
40 #define EFI_BUFFER_TOO_SMALL EFI_ERROR(5)
41 #define EFI_NOT_FOUND EFI_ERROR(14)
42 #define EFI_OUT_OF_RESOURCES EFI_ERROR(15)
45 /*******************************************************
46 * Boot Option Attributes
47 *******************************************************/
48 #define LOAD_OPTION_ACTIVE 0x00000001
50 /******************************************************
51 * EFI Variable Attributes
52 ******************************************************/
53 #define EFI_VARIABLE_NON_VOLATILE 0x0000000000000001
54 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
55 #define EFI_VARIABLE_RUNTIME_ACCESS 0x0000000000000004
62 #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
64 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
65 (b) & 0xff, ((b) >> 8) & 0xff, \
66 (c) & 0xff, ((c) >> 8) & 0xff, \
67 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
70 /******************************************************
72 ******************************************************/
73 #define DEVICE_PATH_PROTOCOL \
74 EFI_GUID( 0x09576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
75 #define EFI_GLOBAL_VARIABLE \
76 EFI_GUID( 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C)
77 #define EDD10_HARDWARE_VENDOR_PATH_GUID \
78 EFI_GUID( 0xCF31FAC5, 0xC24E, 0x11d2, 0x85, 0xF3, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B)
79 #define BLKX_UNKNOWN_GUID \
80 EFI_GUID( 0x47c7b225, 0xc42a, 0x11d2, 0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
81 #define DIR_UNKNOWN_GUID \
82 EFI_GUID( 0x47c7b227, 0xc42a, 0x11d2, 0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
83 #define ESP_UNKNOWN_GUID \
84 EFI_GUID( 0x47c7b226, 0xc42a, 0x11d2, 0x8e, 0x57, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
87 efi_guidcmp(efi_guid_t left, efi_guid_t right)
89 return memcmp(&left, &right, sizeof (efi_guid_t));
93 typedef unsigned long efi_status_t;
94 typedef uint8_t efi_bool_t;
95 typedef uint16_t efi_char16_t; /* UNICODE character */
97 typedef struct _efi_variable_t {
98 efi_char16_t VariableName[1024/sizeof(efi_char16_t)];
99 efi_guid_t VendorGuid;
104 } __attribute__((packed)) efi_variable_t;
112 } __attribute__((packed)) EFI_DEVICE_PATH;
116 uint16_t file_path_list_length;
117 efi_char16_t description[1];
118 EFI_DEVICE_PATH _unused_file_path_list[1];
119 } __attribute__((packed)) EFI_LOAD_OPTION;
128 } __attribute__((packed)) ACPI_DEVICE_PATH;
134 efi_guid_t vendor_guid;
136 } __attribute__((packed)) VENDOR_DEVICE_PATH;
138 #define EDD10_HARDWARE_VENDOR_PATH_LENGTH 24
146 } __attribute__((packed)) PCI_DEVICE_PATH;
153 } __attribute__((packed)) PCCARD_DEVICE_PATH;
159 uint32_t memory_type;
162 } __attribute__((packed)) MEMORY_MAPPED_DEVICE_PATH;
169 } __attribute__((packed)) CONTROLLER_DEVICE_PATH;
178 } __attribute__((packed)) SCSI_DEVICE_PATH;
184 uint8_t primary_secondary;
185 uint8_t slave_master;
187 } __attribute__((packed)) ATAPI_DEVICE_PATH;
196 } __attribute__((packed)) FIBRE_CHANNEL_DEVICE_PATH;
204 } __attribute__((packed)) I1394_DEVICE_PATH;
212 } __attribute__((packed)) USB_DEVICE_PATH;
223 } __attribute__((packed)) USB_CLASS_DEVICE_PATH;
230 } __attribute__((packed)) I2O_DEVICE_PATH;
238 } __attribute__((packed)) MAC_ADDR_DEVICE_PATH;
247 uint16_t remote_port;
250 } __attribute__((packed)) IPv4_DEVICE_PATH;
256 uint8_t local_ip[16];
257 uint8_t remote_ip[16];
259 uint16_t remote_port;
262 } __attribute__((packed)) IPv6_DEVICE_PATH;
272 } __attribute__((packed)) INFINIBAND_DEVICE_PATH;
283 } __attribute__((packed)) UART_DEVICE_PATH;
293 uint8_t signature[16];
295 uint8_t signature_type;
296 uint8_t padding[6]; /* Emperically needed */
297 } __attribute__((packed)) HARDDRIVE_DEVICE_PATH;
306 } __attribute__((packed)) CDROM_DEVICE_PATH;
312 efi_char16_t path_name[1];
313 } __attribute__((packed)) FILE_PATH_DEVICE_PATH;
321 } __attribute__((packed)) MEDIA_PROTOCOL_DEVICE_PATH;
327 uint16_t device_type;
328 uint16_t status_flag;
329 uint8_t description[1];
330 } __attribute__((packed)) BIOS_BOOT_SPEC_DEVICE_PATH;
336 } __attribute__((packed)) END_DEVICE_PATH;
339 /* Used for ACPI _HID */
340 #define EISAID_PNP0A03 0xa0341d0
342 #define PROC_DIR_EFI_VARS "/proc/efi/vars/"
346 /* Exported functions */
348 efi_status_t read_variable(char *name, efi_variable_t *var);
349 efi_status_t write_variable(efi_variable_t *var);
350 int make_linux_efi_variable(efi_variable_t *var,
351 unsigned int free_number);
352 char * efi_guid_unparse(efi_guid_t *guid, char *out);
353 EFI_DEVICE_PATH *load_option_path(EFI_LOAD_OPTION *option);
359 #endif /* _ASM_IA64_EFI_H */