blob: e854a8b3a11203bee555c9031cb16a46b8bbabbe [file] [log] [blame]
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +02001/* SPDX-License-Identifier: GPL-2.0 */
Simon Glass867a6ac2015-07-31 09:31:36 -06002/*
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>
Leif Lindholmc9bfb222019-01-21 12:12:57 +090020#include <charset.h>
AKASHI Takahiro593e17d2020-04-14 11:51:39 +090021#include <pe.h>
Simon Glass867a6ac2015-07-31 09:31:36 -060022
Heinrich Schuchardtc7308d62019-06-28 19:31:55 +020023/* UEFI spec version 2.8 */
24#define EFI_SPECIFICATION_VERSION (2 << 16 | 80)
Heinrich Schuchardt112f2432018-06-28 12:45:27 +020025
Alexander Graf2bb9b792016-03-04 01:09:57 +010026/* Types and defines for EFI CreateEvent */
xypron.glpk@gmx.deb521d292017-07-19 19:22:34 +020027enum efi_timer_delay {
Alexander Graf2bb9b792016-03-04 01:09:57 +010028 EFI_TIMER_STOP = 0,
29 EFI_TIMER_PERIODIC = 1,
30 EFI_TIMER_RELATIVE = 2
31};
32
Leif Lindholmc9bfb222019-01-21 12:12:57 +090033typedef void *efi_hii_handle_t;
34typedef u16 *efi_string_t;
35typedef u16 efi_string_id_t;
36typedef u32 efi_hii_font_style_t;
AKASHI Takahirocb728e52019-01-21 12:13:00 +090037typedef u16 efi_question_id_t;
38typedef u16 efi_image_id_t;
39typedef u16 efi_form_id_t;
xypron.glpk@gmx.de503f2692017-07-18 20:17:19 +020040
xypron.glpk@gmx.dec6841592017-07-18 20:17:18 +020041#define EVT_TIMER 0x80000000
42#define EVT_RUNTIME 0x40000000
43#define EVT_NOTIFY_WAIT 0x00000100
44#define EVT_NOTIFY_SIGNAL 0x00000200
45#define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
46#define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
47
48#define TPL_APPLICATION 0x04
49#define TPL_CALLBACK 0x08
50#define TPL_NOTIFY 0x10
51#define TPL_HIGH_LEVEL 0x1F
Jonathan Gray37a980b2017-03-12 19:26:06 +110052
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +020053struct efi_event;
54
AKASHI Takahiro7cceef72020-03-17 11:12:34 +090055/* OsIndicationsSupported flags */
56#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
57#define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
58#define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED 0x0000000000000004
59#define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED 0x0000000000000008
60#define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED 0x0000000000000010
61#define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020
62#define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY 0x0000000000000040
63#define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH 0x0000000000000080
64
Simon Glass867a6ac2015-07-31 09:31:36 -060065/* EFI Boot Services table */
Heinrich Schuchardt112f2432018-06-28 12:45:27 +020066#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
Simon Glass867a6ac2015-07-31 09:31:36 -060067struct efi_boot_services {
68 struct efi_table_hdr hdr;
Heinrich Schuchardt152cade2017-11-06 21:17:47 +010069 efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl);
70 void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl);
Simon Glass867a6ac2015-07-31 09:31:36 -060071
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +010072 efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t,
Simon Glass867a6ac2015-07-31 09:31:36 -060073 efi_physical_addr_t *);
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +010074 efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t);
75 efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size,
76 struct efi_mem_desc *desc,
77 efi_uintn_t *key,
78 efi_uintn_t *desc_size,
79 u32 *desc_version);
80 efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **);
Simon Glass867a6ac2015-07-31 09:31:36 -060081 efi_status_t (EFIAPI *free_pool)(void *);
82
xypron.glpk@gmx.deb521d292017-07-19 19:22:34 +020083 efi_status_t (EFIAPI *create_event)(uint32_t type,
Heinrich Schuchardt152cade2017-11-06 21:17:47 +010084 efi_uintn_t notify_tpl,
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +020085 void (EFIAPI *notify_function) (
86 struct efi_event *event,
87 void *context),
88 void *notify_context, struct efi_event **event);
xypron.glpk@gmx.deb521d292017-07-19 19:22:34 +020089 efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
90 enum efi_timer_delay type,
91 uint64_t trigger_time);
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +010092 efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events,
93 struct efi_event **event,
94 efi_uintn_t *index);
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +020095 efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
96 efi_status_t (EFIAPI *close_event)(struct efi_event *event);
97 efi_status_t (EFIAPI *check_event)(struct efi_event *event);
xypron.glpk@gmx.dee0549f82017-07-11 22:06:16 +020098#define EFI_NATIVE_INTERFACE 0x00000000
Alexander Graf2bb9b792016-03-04 01:09:57 +010099 efi_status_t (EFIAPI *install_protocol_interface)(
Heinrich Schuchardtfaea1042018-09-26 05:27:54 +0200100 efi_handle_t *handle, const efi_guid_t *protocol,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100101 int protocol_interface_type, void *protocol_interface);
102 efi_status_t (EFIAPI *reinstall_protocol_interface)(
Heinrich Schuchardtfaea1042018-09-26 05:27:54 +0200103 efi_handle_t handle, const efi_guid_t *protocol,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100104 void *old_interface, void *new_interface);
Heinrich Schuchardt2074f702018-01-11 08:16:09 +0100105 efi_status_t (EFIAPI *uninstall_protocol_interface)(
106 efi_handle_t handle, const efi_guid_t *protocol,
107 void *protocol_interface);
108 efi_status_t (EFIAPI *handle_protocol)(
109 efi_handle_t handle, const efi_guid_t *protocol,
110 void **protocol_interface);
Simon Glass867a6ac2015-07-31 09:31:36 -0600111 void *reserved;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100112 efi_status_t (EFIAPI *register_protocol_notify)(
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200113 const efi_guid_t *protocol, struct efi_event *event,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100114 void **registration);
Simon Glass867a6ac2015-07-31 09:31:36 -0600115 efi_status_t (EFIAPI *locate_handle)(
116 enum efi_locate_search_type search_type,
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200117 const efi_guid_t *protocol, void *search_key,
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +0100118 efi_uintn_t *buffer_size, efi_handle_t *buffer);
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200119 efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
Simon Glass867a6ac2015-07-31 09:31:36 -0600120 struct efi_device_path **device_path,
121 efi_handle_t *device);
Alexander Graf2bb9b792016-03-04 01:09:57 +0100122 efi_status_t (EFIAPI *install_configuration_table)(
123 efi_guid_t *guid, void *table);
Simon Glass867a6ac2015-07-31 09:31:36 -0600124
125 efi_status_t (EFIAPI *load_image)(bool boot_policiy,
126 efi_handle_t parent_image,
127 struct efi_device_path *file_path, void *source_buffer,
Heinrich Schuchardt7fb96a12018-04-03 22:29:30 +0200128 efi_uintn_t source_size, efi_handle_t *image);
Simon Glass867a6ac2015-07-31 09:31:36 -0600129 efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
Heinrich Schuchardtcc8e3412018-12-28 12:41:15 +0100130 efi_uintn_t *exitdata_size,
131 u16 **exitdata);
Simon Glass867a6ac2015-07-31 09:31:36 -0600132 efi_status_t (EFIAPI *exit)(efi_handle_t handle,
133 efi_status_t exit_status,
Heinrich Schuchardtcc8e3412018-12-28 12:41:15 +0100134 efi_uintn_t exitdata_size, u16 *exitdata);
Heinrich Schuchardt2074f702018-01-11 08:16:09 +0100135 efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
Heinrich Schuchardtb015ab52019-05-05 21:58:35 +0200136 efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t image_handle,
137 efi_uintn_t map_key);
Simon Glass867a6ac2015-07-31 09:31:36 -0600138
139 efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
140 efi_status_t (EFIAPI *stall)(unsigned long usecs);
Alexander Graf2bb9b792016-03-04 01:09:57 +0100141 efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
142 uint64_t watchdog_code, unsigned long data_size,
143 uint16_t *watchdog_data);
Simon Glass867a6ac2015-07-31 09:31:36 -0600144 efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
145 efi_handle_t *driver_image_handle,
146 struct efi_device_path *remaining_device_path,
147 bool recursive);
Heinrich Schuchardt3ebcd002018-01-11 08:16:03 +0100148 efi_status_t (EFIAPI *disconnect_controller)(
149 efi_handle_t controller_handle,
150 efi_handle_t driver_image_handle,
151 efi_handle_t child_handle);
Simon Glass867a6ac2015-07-31 09:31:36 -0600152#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
153#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
154#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
155#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
156#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
157#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
158 efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200159 const efi_guid_t *protocol, void **interface,
Simon Glass867a6ac2015-07-31 09:31:36 -0600160 efi_handle_t agent_handle,
161 efi_handle_t controller_handle, u32 attributes);
Heinrich Schuchardt2074f702018-01-11 08:16:09 +0100162 efi_status_t (EFIAPI *close_protocol)(
163 efi_handle_t handle, const efi_guid_t *protocol,
164 efi_handle_t agent_handle,
165 efi_handle_t controller_handle);
Simon Glass867a6ac2015-07-31 09:31:36 -0600166 efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200167 const efi_guid_t *protocol,
Simon Glass867a6ac2015-07-31 09:31:36 -0600168 struct efi_open_protocol_info_entry **entry_buffer,
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +0100169 efi_uintn_t *entry_count);
Simon Glass867a6ac2015-07-31 09:31:36 -0600170 efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
171 efi_guid_t ***protocol_buffer,
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +0100172 efi_uintn_t *protocols_buffer_count);
Simon Glass867a6ac2015-07-31 09:31:36 -0600173 efi_status_t (EFIAPI *locate_handle_buffer) (
174 enum efi_locate_search_type search_type,
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200175 const efi_guid_t *protocol, void *search_key,
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +0100176 efi_uintn_t *no_handles, efi_handle_t **buffer);
Heinrich Schuchardt5a9682d2017-10-05 16:35:53 +0200177 efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100178 void *registration, void **protocol_interface);
179 efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
Heinrich Schuchardtfaea1042018-09-26 05:27:54 +0200180 efi_handle_t *handle, ...);
Alexander Graf2bb9b792016-03-04 01:09:57 +0100181 efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
Heinrich Schuchardtfaea1042018-09-26 05:27:54 +0200182 efi_handle_t handle, ...);
Heinrich Schuchardt8aa83602018-07-07 15:36:04 +0200183 efi_status_t (EFIAPI *calculate_crc32)(const void *data,
184 efi_uintn_t data_size,
185 u32 *crc32);
Heinrich Schuchardtfc05a952017-10-05 16:35:52 +0200186 void (EFIAPI *copy_mem)(void *destination, const void *source,
187 size_t length);
188 void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
Heinrich Schuchardt9f0930e2018-02-04 23:05:13 +0100189 efi_status_t (EFIAPI *create_event_ex)(
190 uint32_t type, efi_uintn_t notify_tpl,
191 void (EFIAPI *notify_function) (
192 struct efi_event *event,
193 void *context),
194 void *notify_context,
195 efi_guid_t *event_group,
196 struct efi_event **event);
Simon Glass867a6ac2015-07-31 09:31:36 -0600197};
198
199/* Types and defines for EFI ResetSystem */
200enum efi_reset_type {
201 EFI_RESET_COLD = 0,
202 EFI_RESET_WARM = 1,
Heinrich Schuchardt482fc902018-02-06 22:00:22 +0100203 EFI_RESET_SHUTDOWN = 2,
204 EFI_RESET_PLATFORM_SPECIFIC = 3,
Simon Glass867a6ac2015-07-31 09:31:36 -0600205};
206
207/* EFI Runtime Services table */
Heinrich Schuchardtbdfb8942018-06-28 12:45:28 +0200208#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552ULL
Simon Glass867a6ac2015-07-31 09:31:36 -0600209
Heinrich Schuchardt0c230742018-02-09 20:41:21 +0100210#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
211#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
212#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000
213
AKASHI Takahiro8d990262020-11-30 18:12:11 +0900214#define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001
215#define CAPSULE_SUPPORT_DEPENDENCY 0x0000000000000002
216
AKASHI Takahiro2bc27ca2020-11-17 09:27:55 +0900217#define EFI_CAPSULE_REPORT_GUID \
218 EFI_GUID(0x39b68c46, 0xf7fb, 0x441b, 0xb6, 0xec, \
219 0x16, 0xb0, 0xf6, 0x98, 0x21, 0xf3)
220
AKASHI Takahiroed9349c2020-11-17 09:27:57 +0900221#define EFI_MEMORY_RANGE_CAPSULE_GUID \
222 EFI_GUID(0xde9f0ec, 0x88b6, 0x428f, 0x97, 0x7a, \
223 0x25, 0x8f, 0x1d, 0xe, 0x5e, 0x72)
224
AKASHI Takahiro8d990262020-11-30 18:12:11 +0900225#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
226 EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
227 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
228
Heinrich Schuchardt0c230742018-02-09 20:41:21 +0100229struct efi_capsule_header {
AKASHI Takahiro74b44872020-03-17 11:12:37 +0900230 efi_guid_t capsule_guid;
Heinrich Schuchardt0c230742018-02-09 20:41:21 +0100231 u32 header_size;
232 u32 flags;
233 u32 capsule_image_size;
AKASHI Takahiro74b44872020-03-17 11:12:37 +0900234} __packed;
Heinrich Schuchardt0c230742018-02-09 20:41:21 +0100235
AKASHI Takahiro2bc27ca2020-11-17 09:27:55 +0900236struct efi_capsule_result_variable_header {
237 u32 variable_total_size;
238 u32 reserved;
239 efi_guid_t capsule_guid;
240 struct efi_time capsule_processed;
241 efi_status_t capsule_status;
242} __packed;
243
AKASHI Takahiroed9349c2020-11-17 09:27:57 +0900244struct efi_memory_range {
245 efi_physical_addr_t address;
246 u64 length;
247};
248
249struct efi_memory_range_capsule {
250 struct efi_capsule_header *header;
251 /* EFI_MEMORY_TYPE: 0x80000000-0xFFFFFFFF */
252 enum efi_mem_type os_requested_memory_type;
253 u64 number_of_memory_ranges;
254 struct efi_memory_range memory_ranges[];
255} __packed;
256
AKASHI Takahiro8d990262020-11-30 18:12:11 +0900257struct efi_firmware_management_capsule_header {
258 u32 version;
259 u16 embedded_driver_count;
260 u16 payload_item_count;
261 u64 item_offset_list[];
262} __packed;
263
264struct efi_firmware_management_capsule_image_header {
265 u32 version;
266 efi_guid_t update_image_type_id;
267 u8 update_image_index;
268 u8 reserved[3];
269 u32 update_image_size;
270 u32 update_vendor_code_size;
271 u64 update_hardware_instance;
272 u64 image_capsule_support;
273} __packed;
274
275struct efi_capsule_result_variable_fmp {
276 u16 version;
277 u8 payload_index;
278 u8 update_image_index;
279 efi_guid_t update_image_type_id;
280 // u16 capsule_file_name[];
281 // u16 capsule_target[];
282} __packed;
283
AKASHI Takahiroe771b4b2019-06-05 13:21:38 +0900284#define EFI_RT_SUPPORTED_GET_TIME 0x0001
285#define EFI_RT_SUPPORTED_SET_TIME 0x0002
286#define EFI_RT_SUPPORTED_GET_WAKEUP_TIME 0x0004
287#define EFI_RT_SUPPORTED_SET_WAKEUP_TIME 0x0008
288#define EFI_RT_SUPPORTED_GET_VARIABLE 0x0010
289#define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME 0x0020
290#define EFI_RT_SUPPORTED_SET_VARIABLE 0x0040
291#define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP 0x0080
292#define EFI_RT_SUPPORTED_CONVERT_POINTER 0x0100
293#define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT 0x0200
294#define EFI_RT_SUPPORTED_RESET_SYSTEM 0x0400
295#define EFI_RT_SUPPORTED_UPDATE_CAPSULE 0x0800
296#define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES 0x1000
297#define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO 0x2000
298
Heinrich Schuchardt76be6872020-02-19 20:48:49 +0100299#define EFI_RT_PROPERTIES_TABLE_GUID \
300 EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \
301 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
302
303#define EFI_RT_PROPERTIES_TABLE_VERSION 0x1
304
305struct efi_rt_properties_table {
306 u16 version;
307 u16 length;
308 u32 runtime_services_supported;
309};
310
Heinrich Schuchardt724d2812020-03-24 17:52:40 +0100311#define EFI_OPTIONAL_PTR 0x00000001
312
Simon Glass867a6ac2015-07-31 09:31:36 -0600313struct efi_runtime_services {
314 struct efi_table_hdr hdr;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100315 efi_status_t (EFIAPI *get_time)(struct efi_time *time,
316 struct efi_time_cap *capabilities);
317 efi_status_t (EFIAPI *set_time)(struct efi_time *time);
318 efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
319 struct efi_time *time);
320 efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
321 struct efi_time *time);
322 efi_status_t (EFIAPI *set_virtual_address_map)(
Heinrich Schuchardt24e67222019-07-27 20:28:47 +0200323 efi_uintn_t memory_map_size,
324 efi_uintn_t descriptor_size,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100325 uint32_t descriptor_version,
326 struct efi_mem_desc *virtmap);
Heinrich Schuchardtefcf0a12019-06-29 03:51:36 +0200327 efi_status_t (EFIAPI *convert_pointer)(
328 efi_uintn_t debug_disposition, void **address);
Heinrich Schuchardt45c66f92018-05-17 07:57:05 +0200329 efi_status_t (EFIAPI *get_variable)(u16 *variable_name,
Heinrich Schuchardt0bda81b2018-12-30 20:53:51 +0100330 const efi_guid_t *vendor,
331 u32 *attributes,
Heinrich Schuchardt45c66f92018-05-17 07:57:05 +0200332 efi_uintn_t *data_size, void *data);
333 efi_status_t (EFIAPI *get_next_variable_name)(
334 efi_uintn_t *variable_name_size,
Heinrich Schuchardt7a4e7172020-03-22 18:28:20 +0100335 u16 *variable_name, efi_guid_t *vendor);
Heinrich Schuchardt45c66f92018-05-17 07:57:05 +0200336 efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
Heinrich Schuchardt0bda81b2018-12-30 20:53:51 +0100337 const efi_guid_t *vendor,
338 u32 attributes,
Heinrich Schuchardt452257a2018-12-30 21:03:15 +0100339 efi_uintn_t data_size,
340 const void *data);
Alexander Graf2bb9b792016-03-04 01:09:57 +0100341 efi_status_t (EFIAPI *get_next_high_mono_count)(
342 uint32_t *high_count);
Simon Glass867a6ac2015-07-31 09:31:36 -0600343 void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
344 efi_status_t reset_status,
345 unsigned long data_size, void *reset_data);
Heinrich Schuchardt0c230742018-02-09 20:41:21 +0100346 efi_status_t (EFIAPI *update_capsule)(
347 struct efi_capsule_header **capsule_header_array,
348 efi_uintn_t capsule_count,
349 u64 scatter_gather_list);
350 efi_status_t (EFIAPI *query_capsule_caps)(
351 struct efi_capsule_header **capsule_header_array,
352 efi_uintn_t capsule_count,
AKASHI Takahiro19dd9072018-11-14 16:18:53 +0900353 u64 *maximum_capsule_size,
354 u32 *reset_type);
Heinrich Schuchardt0c230742018-02-09 20:41:21 +0100355 efi_status_t (EFIAPI *query_variable_info)(
356 u32 attributes,
Heinrich Schuchardt45c66f92018-05-17 07:57:05 +0200357 u64 *maximum_variable_storage_size,
358 u64 *remaining_variable_storage_size,
359 u64 *maximum_variable_size);
Simon Glass867a6ac2015-07-31 09:31:36 -0600360};
361
Heinrich Schuchardta3a28f52018-02-18 15:17:51 +0100362/* EFI event group GUID definitions */
363#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \
364 EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \
365 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf)
366
367#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
368 EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \
369 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96)
370
371#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \
372 EFI_GUID(0x78bee926, 0x692f, 0x48fd, 0x9e, 0xdb, \
373 0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab)
374
375#define EFI_EVENT_GROUP_READY_TO_BOOT \
376 EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \
377 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b)
378
379#define EFI_EVENT_GROUP_RESET_SYSTEM \
380 EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \
381 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b)
382
Simon Glass867a6ac2015-07-31 09:31:36 -0600383/* EFI Configuration Table and GUID definitions */
384#define NULL_GUID \
385 EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
387
Rob Clark9975fe92017-09-13 18:05:38 -0400388#define EFI_GLOBAL_VARIABLE_GUID \
389 EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
390 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
391
AKASHI Takahiro593e17d2020-04-14 11:51:39 +0900392#define EFI_IMAGE_SECURITY_DATABASE_GUID \
393 EFI_GUID(0xd719b2cb, 0x3d3a, 0x4596, 0xa3, 0xbc, \
394 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f)
395
Alexander Graf2bb9b792016-03-04 01:09:57 +0100396#define EFI_FDT_GUID \
397 EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
398 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
399
Bin Meng86df34d2018-06-27 20:38:03 -0700400#define EFI_ACPI_TABLE_GUID \
401 EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \
402 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
403
Alexander Grafe663b352016-08-19 01:23:29 +0200404#define SMBIOS_TABLE_GUID \
405 EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \
406 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
407
Ilias Apalodimasec80b472020-02-21 09:55:45 +0200408#define EFI_LOAD_FILE_PROTOCOL_GUID \
409 EFI_GUID(0x56ec3091, 0x954c, 0x11d2, \
410 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
411
412#define EFI_LOAD_FILE2_PROTOCOL_GUID \
413 EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \
414 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d)
415
Ilias Apalodimasc8d0fd52020-11-30 11:47:40 +0200416#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \
417 EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \
418 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
419
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +0200420struct efi_configuration_table {
Alexander Graf2bb9b792016-03-04 01:09:57 +0100421 efi_guid_t guid;
422 void *table;
Heinrich Schuchardt2859f442018-12-18 00:06:05 +0100423} __packed;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100424
425#define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
426
Simon Glass867a6ac2015-07-31 09:31:36 -0600427struct efi_system_table {
428 struct efi_table_hdr hdr;
Heinrich Schuchardt0b386532018-06-28 12:45:30 +0200429 u16 *fw_vendor; /* physical addr of wchar_t vendor string */
Simon Glass867a6ac2015-07-31 09:31:36 -0600430 u32 fw_revision;
Heinrich Schuchardtcc20ed02018-01-19 20:24:52 +0100431 efi_handle_t con_in_handle;
Heinrich Schuchardt3e603ec2018-09-08 10:20:10 +0200432 struct efi_simple_text_input_protocol *con_in;
Heinrich Schuchardtcc20ed02018-01-19 20:24:52 +0100433 efi_handle_t con_out_handle;
Simon Glass867a6ac2015-07-31 09:31:36 -0600434 struct efi_simple_text_output_protocol *con_out;
Heinrich Schuchardtcc20ed02018-01-19 20:24:52 +0100435 efi_handle_t stderr_handle;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100436 struct efi_simple_text_output_protocol *std_err;
Simon Glass867a6ac2015-07-31 09:31:36 -0600437 struct efi_runtime_services *runtime;
438 struct efi_boot_services *boottime;
Heinrich Schuchardtf5a2a932017-11-06 21:17:48 +0100439 efi_uintn_t nr_tables;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100440 struct efi_configuration_table *tables;
Simon Glass867a6ac2015-07-31 09:31:36 -0600441};
442
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +0200443#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
Alexander Graf2bb9b792016-03-04 01:09:57 +0100444 EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
445 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
446
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +0200447#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
AKASHI Takahirobc8fc322019-03-27 13:40:32 +0900448 EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \
449 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf)
450
Heinrich Schuchardt95147312018-07-05 08:17:58 +0200451#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
452
Simon Glass867a6ac2015-07-31 09:31:36 -0600453struct efi_loaded_image {
454 u32 revision;
455 void *parent_handle;
456 struct efi_system_table *system_table;
Heinrich Schuchardt43dace52018-04-03 22:29:33 +0200457 efi_handle_t device_handle;
458 struct efi_device_path *file_path;
Simon Glass867a6ac2015-07-31 09:31:36 -0600459 void *reserved;
460 u32 load_options_size;
461 void *load_options;
462 void *image_base;
463 aligned_u64 image_size;
464 unsigned int image_code_type;
465 unsigned int image_data_type;
Heinrich Schuchardtdf116e82019-05-01 18:25:45 +0200466 efi_status_t (EFIAPI *unload)(efi_handle_t image_handle);
Simon Glass867a6ac2015-07-31 09:31:36 -0600467};
468
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +0200469#define EFI_DEVICE_PATH_PROTOCOL_GUID \
Alexander Graf2bb9b792016-03-04 01:09:57 +0100470 EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +0200471 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
Alexander Graf2bb9b792016-03-04 01:09:57 +0100472
473#define DEVICE_PATH_TYPE_END 0x7f
Heinrich Schuchardt3acef5d2018-04-16 07:59:09 +0200474# define DEVICE_PATH_SUB_TYPE_INSTANCE_END 0x01
Alexander Graf2bb9b792016-03-04 01:09:57 +0100475# define DEVICE_PATH_SUB_TYPE_END 0xff
476
Simon Glass867a6ac2015-07-31 09:31:36 -0600477struct efi_device_path {
478 u8 type;
479 u8 sub_type;
480 u16 length;
Rob Clarka8606ef2017-09-13 18:05:26 -0400481} __packed;
Simon Glass867a6ac2015-07-31 09:31:36 -0600482
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700483struct efi_mac_addr {
484 u8 addr[32];
Rob Clarka8606ef2017-09-13 18:05:26 -0400485} __packed;
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700486
Peter Jonesc80214c2017-09-13 18:05:27 -0400487#define DEVICE_PATH_TYPE_HARDWARE_DEVICE 0x01
Rob Clarkbf192732017-10-10 08:23:06 -0400488# define DEVICE_PATH_SUB_TYPE_MEMORY 0x03
Peter Jonesc80214c2017-09-13 18:05:27 -0400489# define DEVICE_PATH_SUB_TYPE_VENDOR 0x04
490
Rob Clarkbf192732017-10-10 08:23:06 -0400491struct efi_device_path_memory {
492 struct efi_device_path dp;
493 u32 memory_type;
494 u64 start_address;
495 u64 end_address;
496} __packed;
497
Peter Jonesc80214c2017-09-13 18:05:27 -0400498struct efi_device_path_vendor {
499 struct efi_device_path dp;
500 efi_guid_t guid;
501 u8 vendor_data[];
502} __packed;
503
504#define DEVICE_PATH_TYPE_ACPI_DEVICE 0x02
505# define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE 0x01
506
507#define EFI_PNP_ID(ID) (u32)(((ID) << 16) | 0x41D0)
508#define EISA_PNP_ID(ID) EFI_PNP_ID(ID)
Rob Clarkadae4312017-09-13 18:05:30 -0400509#define EISA_PNP_NUM(ID) ((ID) >> 16)
Peter Jonesc80214c2017-09-13 18:05:27 -0400510
511struct efi_device_path_acpi_path {
512 struct efi_device_path dp;
513 u32 hid;
514 u32 uid;
515} __packed;
516
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700517#define DEVICE_PATH_TYPE_MESSAGING_DEVICE 0x03
Heinrich Schuchardtaf3106a2017-12-11 12:56:44 +0100518# define DEVICE_PATH_SUB_TYPE_MSG_ATAPI 0x01
519# define DEVICE_PATH_SUB_TYPE_MSG_SCSI 0x02
Peter Jonesc80214c2017-09-13 18:05:27 -0400520# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700521# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
Heinrich Schuchardtf0272222021-03-19 02:49:54 +0100522# define DEVICE_PATH_SUB_TYPE_MSG_UART 0x0e
Rob Clarkb66c60d2017-09-13 18:05:28 -0400523# define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f
Heinrich Schuchardtbf3bcef2020-05-20 23:12:02 +0200524# define DEVICE_PATH_SUB_TYPE_MSG_SATA 0x12
Patrick Wildtf2d247d2019-10-03 16:24:17 +0200525# define DEVICE_PATH_SUB_TYPE_MSG_NVME 0x17
Peter Jonesc80214c2017-09-13 18:05:27 -0400526# define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a
527# define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d
528
Heinrich Schuchardtaf3106a2017-12-11 12:56:44 +0100529struct efi_device_path_atapi {
530 struct efi_device_path dp;
531 u8 primary_secondary;
532 u8 slave_master;
533 u16 logical_unit_number;
534} __packed;
535
536struct efi_device_path_scsi {
537 struct efi_device_path dp;
538 u16 target_id;
539 u16 logical_unit_number;
540} __packed;
541
Heinrich Schuchardtf0272222021-03-19 02:49:54 +0100542struct efi_device_path_uart {
543 struct efi_device_path dp;
544 u32 reserved;
545 u64 baud_rate;
546 u8 data_bits;
547 u8 parity;
548 u8 stop_bits;
549} __packed;
550
Peter Jonesc80214c2017-09-13 18:05:27 -0400551struct efi_device_path_usb {
552 struct efi_device_path dp;
553 u8 parent_port_number;
554 u8 usb_interface;
555} __packed;
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700556
Heinrich Schuchardtbf3bcef2020-05-20 23:12:02 +0200557struct efi_device_path_sata {
558 struct efi_device_path dp;
559 u16 hba_port;
560 u16 port_multiplier_port;
561 u16 logical_unit_number;
562} __packed;
563
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700564struct efi_device_path_mac_addr {
565 struct efi_device_path dp;
566 struct efi_mac_addr mac;
567 u8 if_type;
Rob Clarka8606ef2017-09-13 18:05:26 -0400568} __packed;
Oleksandr Tymoshenkod7608ab2016-10-24 10:47:01 -0700569
Rob Clarkb66c60d2017-09-13 18:05:28 -0400570struct efi_device_path_usb_class {
571 struct efi_device_path dp;
572 u16 vendor_id;
573 u16 product_id;
574 u8 device_class;
575 u8 device_subclass;
576 u8 device_protocol;
577} __packed;
578
Peter Jonesc80214c2017-09-13 18:05:27 -0400579struct efi_device_path_sd_mmc_path {
580 struct efi_device_path dp;
581 u8 slot_number;
582} __packed;
583
Patrick Wildtf2d247d2019-10-03 16:24:17 +0200584struct efi_device_path_nvme {
585 struct efi_device_path dp;
586 u32 ns_id;
587 u8 eui64[8];
588} __packed;
589
Alexander Graf2bb9b792016-03-04 01:09:57 +0100590#define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04
Peter Jonesc80214c2017-09-13 18:05:27 -0400591# define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
592# define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
Ilias Apalodimasec80b472020-02-21 09:55:45 +0200593# define DEVICE_PATH_SUB_TYPE_VENDOR_PATH 0x03
Alexander Graf2bb9b792016-03-04 01:09:57 +0100594# define DEVICE_PATH_SUB_TYPE_FILE_PATH 0x04
595
Peter Jonesc80214c2017-09-13 18:05:27 -0400596struct efi_device_path_hard_drive_path {
597 struct efi_device_path dp;
598 u32 partition_number;
599 u64 partition_start;
600 u64 partition_end;
601 u8 partition_signature[16];
602 u8 partmap_type;
603 u8 signature_type;
604} __packed;
605
606struct efi_device_path_cdrom_path {
607 struct efi_device_path dp;
608 u32 boot_entry;
609 u64 partition_start;
Heinrich Schuchardtd0384d52019-09-04 13:56:01 +0200610 u64 partition_size;
Peter Jonesc80214c2017-09-13 18:05:27 -0400611} __packed;
612
Alexander Graf2bb9b792016-03-04 01:09:57 +0100613struct efi_device_path_file_path {
614 struct efi_device_path dp;
Rob Clark61b7e222017-09-13 18:05:39 -0400615 u16 str[];
Rob Clarka8606ef2017-09-13 18:05:26 -0400616} __packed;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100617
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +0200618#define EFI_BLOCK_IO_PROTOCOL_GUID \
Alexander Graf2bb9b792016-03-04 01:09:57 +0100619 EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
620 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
621
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +0200622struct efi_block_io_media {
Alexander Graf2bb9b792016-03-04 01:09:57 +0100623 u32 media_id;
624 char removable_media;
625 char media_present;
626 char logical_partition;
627 char read_only;
628 char write_caching;
629 u8 pad[3];
630 u32 block_size;
631 u32 io_align;
632 u8 pad2[4];
633 u64 last_block;
Heinrich Schuchardt4f948652018-01-19 20:24:48 +0100634 /* Added in revision 2 of the protocol */
635 u64 lowest_aligned_lba;
636 u32 logical_blocks_per_physical_block;
637 /* Added in revision 3 of the protocol */
638 u32 optimal_transfer_length_granualarity;
Alexander Graf2bb9b792016-03-04 01:09:57 +0100639};
640
Heinrich Schuchardt4f948652018-01-19 20:24:48 +0100641#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
642#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x0002001f
643
Alexander Graf2bb9b792016-03-04 01:09:57 +0100644struct efi_block_io {
645 u64 revision;
646 struct efi_block_io_media *media;
647 efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
648 char extended_verification);
649 efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
Heinrich Schuchardt4f948652018-01-19 20:24:48 +0100650 u32 media_id, u64 lba, efi_uintn_t buffer_size,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100651 void *buffer);
652 efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
Heinrich Schuchardt4f948652018-01-19 20:24:48 +0100653 u32 media_id, u64 lba, efi_uintn_t buffer_size,
Alexander Graf2bb9b792016-03-04 01:09:57 +0100654 void *buffer);
655 efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
656};
657
Simon Glass867a6ac2015-07-31 09:31:36 -0600658struct simple_text_output_mode {
659 s32 max_mode;
660 s32 mode;
661 s32 attribute;
662 s32 cursor_column;
663 s32 cursor_row;
664 bool cursor_visible;
665};
666
Rob Clarka17e62c2017-07-24 10:39:01 -0400667#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
668 EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
669 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
670
Rob Clark2d5dc2a2017-10-10 08:23:01 -0400671#define EFI_BLACK 0x00
672#define EFI_BLUE 0x01
673#define EFI_GREEN 0x02
674#define EFI_CYAN 0x03
675#define EFI_RED 0x04
676#define EFI_MAGENTA 0x05
677#define EFI_BROWN 0x06
678#define EFI_LIGHTGRAY 0x07
679#define EFI_BRIGHT 0x08
680#define EFI_DARKGRAY 0x08
681#define EFI_LIGHTBLUE 0x09
682#define EFI_LIGHTGREEN 0x0a
683#define EFI_LIGHTCYAN 0x0b
684#define EFI_LIGHTRED 0x0c
685#define EFI_LIGHTMAGENTA 0x0d
686#define EFI_YELLOW 0x0e
687#define EFI_WHITE 0x0f
688#define EFI_BACKGROUND_BLACK 0x00
689#define EFI_BACKGROUND_BLUE 0x10
690#define EFI_BACKGROUND_GREEN 0x20
691#define EFI_BACKGROUND_CYAN 0x30
692#define EFI_BACKGROUND_RED 0x40
693#define EFI_BACKGROUND_MAGENTA 0x50
694#define EFI_BACKGROUND_BROWN 0x60
695#define EFI_BACKGROUND_LIGHTGRAY 0x70
696
697/* extract foreground color from EFI attribute */
698#define EFI_ATTR_FG(attr) ((attr) & 0x07)
699/* treat high bit of FG as bright/bold (similar to edk2) */
700#define EFI_ATTR_BOLD(attr) (((attr) >> 3) & 0x01)
701/* extract background color from EFI attribute */
702#define EFI_ATTR_BG(attr) (((attr) >> 4) & 0x7)
703
Simon Glass867a6ac2015-07-31 09:31:36 -0600704struct efi_simple_text_output_protocol {
Heinrich Schuchardt21b6b542019-06-15 14:47:25 +0200705 efi_status_t (EFIAPI *reset)(
706 struct efi_simple_text_output_protocol *this,
707 char extended_verification);
Simon Glass867a6ac2015-07-31 09:31:36 -0600708 efi_status_t (EFIAPI *output_string)(
709 struct efi_simple_text_output_protocol *this,
Heinrich Schuchardt7913c7d2021-01-05 07:50:09 +0100710 const u16 *str);
Alexander Graf2bb9b792016-03-04 01:09:57 +0100711 efi_status_t (EFIAPI *test_string)(
712 struct efi_simple_text_output_protocol *this,
Heinrich Schuchardt7913c7d2021-01-05 07:50:09 +0100713 const u16 *str);
Simon Glass867a6ac2015-07-31 09:31:36 -0600714 efi_status_t(EFIAPI *query_mode)(
715 struct efi_simple_text_output_protocol *this,
716 unsigned long mode_number, unsigned long *columns,
717 unsigned long *rows);
718 efi_status_t(EFIAPI *set_mode)(
719 struct efi_simple_text_output_protocol *this,
720 unsigned long mode_number);
721 efi_status_t(EFIAPI *set_attribute)(
722 struct efi_simple_text_output_protocol *this,
723 unsigned long attribute);
724 efi_status_t(EFIAPI *clear_screen) (
725 struct efi_simple_text_output_protocol *this);
726 efi_status_t(EFIAPI *set_cursor_position) (
727 struct efi_simple_text_output_protocol *this,
728 unsigned long column, unsigned long row);
Alexander Graf2bb9b792016-03-04 01:09:57 +0100729 efi_status_t(EFIAPI *enable_cursor)(
730 struct efi_simple_text_output_protocol *this,
731 bool enable);
Simon Glass867a6ac2015-07-31 09:31:36 -0600732 struct simple_text_output_mode *mode;
733};
734
Heinrich Schuchardt110c6282018-09-11 22:38:08 +0200735#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
736 EFI_GUID(0xdd9e7534, 0x7762, 0x4698, \
737 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa)
738
Simon Glass867a6ac2015-07-31 09:31:36 -0600739struct efi_input_key {
740 u16 scan_code;
741 s16 unicode_char;
742};
743
Heinrich Schuchardt110c6282018-09-11 22:38:08 +0200744#define EFI_SHIFT_STATE_INVALID 0x00000000
745#define EFI_RIGHT_SHIFT_PRESSED 0x00000001
746#define EFI_LEFT_SHIFT_PRESSED 0x00000002
747#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
748#define EFI_LEFT_CONTROL_PRESSED 0x00000008
749#define EFI_RIGHT_ALT_PRESSED 0x00000010
750#define EFI_LEFT_ALT_PRESSED 0x00000020
751#define EFI_RIGHT_LOGO_PRESSED 0x00000040
752#define EFI_LEFT_LOGO_PRESSED 0x00000080
753#define EFI_MENU_KEY_PRESSED 0x00000100
754#define EFI_SYS_REQ_PRESSED 0x00000200
755#define EFI_SHIFT_STATE_VALID 0x80000000
756
757#define EFI_TOGGLE_STATE_INVALID 0x00
758#define EFI_SCROLL_LOCK_ACTIVE 0x01
759#define EFI_NUM_LOCK_ACTIVE 0x02
760#define EFI_CAPS_LOCK_ACTIVE 0x04
761#define EFI_KEY_STATE_EXPOSED 0x40
762#define EFI_TOGGLE_STATE_VALID 0x80
763
764struct efi_key_state {
765 u32 key_shift_state;
766 u8 key_toggle_state;
767};
768
769struct efi_key_data {
770 struct efi_input_key key;
771 struct efi_key_state key_state;
772};
773
774struct efi_simple_text_input_ex_protocol {
775 efi_status_t (EFIAPI *reset) (
776 struct efi_simple_text_input_ex_protocol *this,
777 bool extended_verification);
778 efi_status_t (EFIAPI *read_key_stroke_ex) (
779 struct efi_simple_text_input_ex_protocol *this,
780 struct efi_key_data *key_data);
781 struct efi_event *wait_for_key_ex;
782 efi_status_t (EFIAPI *set_state) (
783 struct efi_simple_text_input_ex_protocol *this,
Heinrich Schuchardtacee9652019-05-18 17:07:52 +0200784 u8 *key_toggle_state);
Heinrich Schuchardt110c6282018-09-11 22:38:08 +0200785 efi_status_t (EFIAPI *register_key_notify) (
786 struct efi_simple_text_input_ex_protocol *this,
787 struct efi_key_data *key_data,
788 efi_status_t (EFIAPI *key_notify_function)(
789 struct efi_key_data *key_data),
790 void **notify_handle);
791 efi_status_t (EFIAPI *unregister_key_notify) (
792 struct efi_simple_text_input_ex_protocol *this,
793 void *notification_handle);
794};
795
Rob Clarka17e62c2017-07-24 10:39:01 -0400796#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
797 EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
798 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
799
Heinrich Schuchardt3e603ec2018-09-08 10:20:10 +0200800struct efi_simple_text_input_protocol {
801 efi_status_t(EFIAPI *reset)(struct efi_simple_text_input_protocol *this,
802 bool extended_verification);
Simon Glass867a6ac2015-07-31 09:31:36 -0600803 efi_status_t(EFIAPI *read_key_stroke)(
Heinrich Schuchardt3e603ec2018-09-08 10:20:10 +0200804 struct efi_simple_text_input_protocol *this,
Simon Glass867a6ac2015-07-31 09:31:36 -0600805 struct efi_input_key *key);
xypron.glpk@gmx.de2fd945f2017-07-18 20:17:17 +0200806 struct efi_event *wait_for_key;
Simon Glass867a6ac2015-07-31 09:31:36 -0600807};
808
xypron.glpk@gmx.decc5b7082017-07-11 22:06:25 +0200809#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
810 EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
811 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
812
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +0200813struct efi_device_path_to_text_protocol {
xypron.glpk@gmx.decc5b7082017-07-11 22:06:25 +0200814 uint16_t *(EFIAPI *convert_device_node_to_text)(
Rob Clark9309a1b2017-09-13 18:05:29 -0400815 struct efi_device_path *device_node,
xypron.glpk@gmx.decc5b7082017-07-11 22:06:25 +0200816 bool display_only,
817 bool allow_shortcuts);
818 uint16_t *(EFIAPI *convert_device_path_to_text)(
Rob Clark9309a1b2017-09-13 18:05:29 -0400819 struct efi_device_path *device_path,
xypron.glpk@gmx.decc5b7082017-07-11 22:06:25 +0200820 bool display_only,
821 bool allow_shortcuts);
822};
823
Leif Lindholme70f8df2018-03-09 17:43:21 +0100824#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
825 EFI_GUID(0x0379be4e, 0xd706, 0x437d, \
826 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4)
827
828struct efi_device_path_utilities_protocol {
829 efi_uintn_t (EFIAPI *get_device_path_size)(
830 const struct efi_device_path *device_path);
831 struct efi_device_path *(EFIAPI *duplicate_device_path)(
832 const struct efi_device_path *device_path);
833 struct efi_device_path *(EFIAPI *append_device_path)(
834 const struct efi_device_path *src1,
835 const struct efi_device_path *src2);
836 struct efi_device_path *(EFIAPI *append_device_node)(
837 const struct efi_device_path *device_path,
838 const struct efi_device_path *device_node);
839 struct efi_device_path *(EFIAPI *append_device_path_instance)(
840 const struct efi_device_path *device_path,
841 const struct efi_device_path *device_path_instance);
842 struct efi_device_path *(EFIAPI *get_next_device_path_instance)(
843 struct efi_device_path **device_path_instance,
844 efi_uintn_t *device_path_instance_size);
845 bool (EFIAPI *is_device_path_multi_instance)(
846 const struct efi_device_path *device_path);
847 struct efi_device_path *(EFIAPI *create_device_node)(
848 uint8_t node_type,
849 uint8_t node_sub_type,
850 uint16_t node_length);
851};
852
Leif Lindholmc9bfb222019-01-21 12:12:57 +0900853/*
854 * Human Interface Infrastructure (HII)
855 */
856struct efi_hii_package_list_header {
857 efi_guid_t package_list_guid;
858 u32 package_length;
859} __packed;
860
861/**
862 * struct efi_hii_package_header - EFI HII package header
863 *
864 * @fields: 'fields' replaces the bit-fields defined in the EFI
865 * specification to to avoid possible compiler incompatibilities::
866 *
867 * u32 length:24;
868 * u32 type:8;
869 */
870struct efi_hii_package_header {
871 u32 fields;
872} __packed;
873
874#define __EFI_HII_PACKAGE_LEN_SHIFT 0
875#define __EFI_HII_PACKAGE_TYPE_SHIFT 24
876#define __EFI_HII_PACKAGE_LEN_MASK 0xffffff
877#define __EFI_HII_PACKAGE_TYPE_MASK 0xff
878
879#define EFI_HII_PACKAGE_TYPE_ALL 0x00
880#define EFI_HII_PACKAGE_TYPE_GUID 0x01
881#define EFI_HII_PACKAGE_FORMS 0x02
882#define EFI_HII_PACKAGE_STRINGS 0x04
883#define EFI_HII_PACKAGE_FONTS 0x05
884#define EFI_HII_PACKAGE_IMAGES 0x06
885#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07
886#define EFI_HII_PACKAGE_DEVICE_PATH 0x08
887#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09
888#define EFI_HII_PACKAGE_ANIMATIONS 0x0A
889#define EFI_HII_PACKAGE_END 0xDF
890#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
891#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF
892
893/*
AKASHI Takahiro9ab0bdd2019-01-21 12:12:58 +0900894 * HII GUID package
895 */
896struct efi_hii_guid_package {
897 struct efi_hii_package_header header;
898 efi_guid_t guid;
899 char data[];
900} __packed;
901
902/*
Leif Lindholmc9bfb222019-01-21 12:12:57 +0900903 * HII string package
904 */
905struct efi_hii_strings_package {
906 struct efi_hii_package_header header;
907 u32 header_size;
908 u32 string_info_offset;
909 u16 language_window[16];
910 efi_string_id_t language_name;
911 u8 language[];
912} __packed;
913
914struct efi_hii_string_block {
915 u8 block_type;
916 /* u8 block_body[]; */
917} __packed;
918
919#define EFI_HII_SIBT_END 0x00
920#define EFI_HII_SIBT_STRING_SCSU 0x10
921#define EFI_HII_SIBT_STRING_SCSU_FONT 0x11
922#define EFI_HII_SIBT_STRINGS_SCSU 0x12
923#define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13
924#define EFI_HII_SIBT_STRING_UCS2 0x14
925#define EFI_HII_SIBT_STRING_UCS2_FONT 0x15
926#define EFI_HII_SIBT_STRINGS_UCS2 0x16
927#define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17
928#define EFI_HII_SIBT_DUPLICATE 0x20
929#define EFI_HII_SIBT_SKIP2 0x21
930#define EFI_HII_SIBT_SKIP1 0x22
931#define EFI_HII_SIBT_EXT1 0x30
932#define EFI_HII_SIBT_EXT2 0x31
933#define EFI_HII_SIBT_EXT4 0x32
934#define EFI_HII_SIBT_FONT 0x40
935
936struct efi_hii_sibt_string_ucs2_block {
937 struct efi_hii_string_block header;
938 u16 string_text[];
939} __packed;
940
941static inline struct efi_hii_string_block *
942efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk)
943{
944 return ((void *)blk) + sizeof(*blk) +
945 (u16_strlen(blk->string_text) + 1) * 2;
946}
947
948/*
AKASHI Takahirocb728e52019-01-21 12:13:00 +0900949 * HII forms package
950 * TODO: full scope of definitions
951 */
952struct efi_hii_time {
953 u8 hour;
954 u8 minute;
955 u8 second;
956};
957
958struct efi_hii_date {
959 u16 year;
960 u8 month;
961 u8 day;
962};
963
964struct efi_hii_ref {
965 efi_question_id_t question_id;
966 efi_form_id_t form_id;
967 efi_guid_t form_set_guid;
968 efi_string_id_t device_path;
969};
970
971union efi_ifr_type_value {
972 u8 u8; // EFI_IFR_TYPE_NUM_SIZE_8
973 u16 u16; // EFI_IFR_TYPE_NUM_SIZE_16
974 u32 u32; // EFI_IFR_TYPE_NUM_SIZE_32
975 u64 u64; // EFI_IFR_TYPE_NUM_SIZE_64
976 bool b; // EFI_IFR_TYPE_BOOLEAN
977 struct efi_hii_time time; // EFI_IFR_TYPE_TIME
978 struct efi_hii_date date; // EFI_IFR_TYPE_DATE
979 efi_string_id_t string; // EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION
980 struct efi_hii_ref ref; // EFI_IFR_TYPE_REF
981 // u8 buffer[]; // EFI_IFR_TYPE_BUFFER
982};
983
984#define EFI_IFR_TYPE_NUM_SIZE_8 0x00
985#define EFI_IFR_TYPE_NUM_SIZE_16 0x01
986#define EFI_IFR_TYPE_NUM_SIZE_32 0x02
987#define EFI_IFR_TYPE_NUM_SIZE_64 0x03
988#define EFI_IFR_TYPE_BOOLEAN 0x04
989#define EFI_IFR_TYPE_TIME 0x05
990#define EFI_IFR_TYPE_DATE 0x06
991#define EFI_IFR_TYPE_STRING 0x07
992#define EFI_IFR_TYPE_OTHER 0x08
993#define EFI_IFR_TYPE_UNDEFINED 0x09
994#define EFI_IFR_TYPE_ACTION 0x0A
995#define EFI_IFR_TYPE_BUFFER 0x0B
996#define EFI_IFR_TYPE_REF 0x0C
997#define EFI_IFR_OPTION_DEFAULT 0x10
998#define EFI_IFR_OPTION_DEFAULT_MFG 0x20
999
1000#define EFI_IFR_ONE_OF_OPTION_OP 0x09
1001
1002struct efi_ifr_op_header {
1003 u8 opCode;
1004 u8 length:7;
1005 u8 scope:1;
1006};
1007
1008struct efi_ifr_one_of_option {
1009 struct efi_ifr_op_header header;
1010 efi_string_id_t option;
1011 u8 flags;
1012 u8 type;
1013 union efi_ifr_type_value value;
1014};
1015
1016typedef efi_uintn_t efi_browser_action_t;
1017
1018#define EFI_BROWSER_ACTION_REQUEST_NONE 0
1019#define EFI_BROWSER_ACTION_REQUEST_RESET 1
1020#define EFI_BROWSER_ACTION_REQUEST_SUBMIT 2
1021#define EFI_BROWSER_ACTION_REQUEST_EXIT 3
1022#define EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT 4
1023#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT 5
1024#define EFI_BROWSER_ACTION_REQUEST_FORM_APPLY 6
1025#define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD 7
1026#define EFI_BROWSER_ACTION_REQUEST_RECONNECT 8
1027
1028typedef efi_uintn_t efi_browser_action_request_t;
1029
1030#define EFI_BROWSER_ACTION_CHANGING 0
1031#define EFI_BROWSER_ACTION_CHANGED 1
1032#define EFI_BROWSER_ACTION_RETRIEVE 2
1033#define EFI_BROWSER_ACTION_FORM_OPEN 3
1034#define EFI_BROWSER_ACTION_FORM_CLOSE 4
1035#define EFI_BROWSER_ACTION_SUBMITTED 5
1036#define EFI_BROWSER_ACTION_DEFAULT_STANDARD 0x1000
1037#define EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING 0x1001
1038#define EFI_BROWSER_ACTION_DEFAULT_SAFE 0x1002
1039#define EFI_BROWSER_ACTION_DEFAULT_PLATFORM 0x2000
1040#define EFI_BROWSER_ACTION_DEFAULT_HARDWARE 0x3000
1041#define EFI_BROWSER_ACTION_DEFAULT_FIRMWARE 0x4000
1042
1043/*
Leif Lindholmc9bfb222019-01-21 12:12:57 +09001044 * HII keyboard package
1045 */
1046typedef enum {
1047 EFI_KEY_LCTRL, EFI_KEY_A0, EFI_KEY_LALT, EFI_KEY_SPACE_BAR,
1048 EFI_KEY_A2, EFI_KEY_A3, EFI_KEY_A4, EFI_KEY_RCTRL, EFI_KEY_LEFT_ARROW,
1049 EFI_KEY_DOWN_ARROW, EFI_KEY_RIGHT_ARROW, EFI_KEY_ZERO,
1050 EFI_KEY_PERIOD, EFI_KEY_ENTER, EFI_KEY_LSHIFT, EFI_KEY_B0,
1051 EFI_KEY_B1, EFI_KEY_B2, EFI_KEY_B3, EFI_KEY_B4, EFI_KEY_B5, EFI_KEY_B6,
1052 EFI_KEY_B7, EFI_KEY_B8, EFI_KEY_B9, EFI_KEY_B10, EFI_KEY_RSHIFT,
1053 EFI_KEY_UP_ARROW, EFI_KEY_ONE, EFI_KEY_TWO, EFI_KEY_THREE,
1054 EFI_KEY_CAPS_LOCK, EFI_KEY_C1, EFI_KEY_C2, EFI_KEY_C3, EFI_KEY_C4,
1055 EFI_KEY_C5, EFI_KEY_C6, EFI_KEY_C7, EFI_KEY_C8, EFI_KEY_C9,
1056 EFI_KEY_C10, EFI_KEY_C11, EFI_KEY_C12, EFI_KEY_FOUR, EFI_KEY_FIVE,
1057 EFI_KEY_SIX, EFI_KEY_PLUS, EFI_KEY_TAB, EFI_KEY_D1, EFI_KEY_D2,
1058 EFI_KEY_D3, EFI_KEY_D4, EFI_KEY_D5, EFI_KEY_D6, EFI_KEY_D7, EFI_KEY_D8,
1059 EFI_KEY_D9, EFI_KEY_D10, EFI_KEY_D11, EFI_KEY_D12, EFI_KEY_D13,
1060 EFI_KEY_DEL, EFI_KEY_END, EFI_KEY_PG_DN, EFI_KEY_SEVEN, EFI_KEY_EIGHT,
1061 EFI_KEY_NINE, EFI_KEY_E0, EFI_KEY_E1, EFI_KEY_E2, EFI_KEY_E3,
1062 EFI_KEY_E4, EFI_KEY_E5, EFI_KEY_E6, EFI_KEY_E7, EFI_KEY_E8, EFI_KEY_E9,
1063 EFI_KEY_E10, EFI_KEY_E11, EFI_KEY_E12, EFI_KEY_BACK_SPACE,
1064 EFI_KEY_INS, EFI_KEY_HOME, EFI_KEY_PG_UP, EFI_KEY_NLCK, EFI_KEY_SLASH,
1065 EFI_KEY_ASTERISK, EFI_KEY_MINUS, EFI_KEY_ESC, EFI_KEY_F1, EFI_KEY_F2,
1066 EFI_KEY_F3, EFI_KEY_F4, EFI_KEY_F5, EFI_KEY_F6, EFI_KEY_F7, EFI_KEY_F8,
1067 EFI_KEY_F9, EFI_KEY_F10, EFI_KEY_F11, EFI_KEY_F12, EFI_KEY_PRINT,
1068 EFI_KEY_SLCK, EFI_KEY_PAUSE,
1069} efi_key;
1070
1071struct efi_key_descriptor {
1072 u32 key;
1073 u16 unicode;
1074 u16 shifted_unicode;
1075 u16 alt_gr_unicode;
1076 u16 shifted_alt_gr_unicode;
1077 u16 modifier;
1078 u16 affected_attribute;
1079} __packed;
1080
1081struct efi_hii_keyboard_layout {
1082 u16 layout_length;
1083 efi_guid_t guid;
1084 u32 layout_descriptor_string_offset;
1085 u8 descriptor_count;
1086 struct efi_key_descriptor descriptors[];
1087} __packed;
1088
AKASHI Takahiro8d3b77e2019-01-21 12:12:59 +09001089struct efi_hii_keyboard_package {
1090 struct efi_hii_package_header header;
1091 u16 layout_count;
1092 struct efi_hii_keyboard_layout layout[];
1093} __packed;
1094
Leif Lindholmc9bfb222019-01-21 12:12:57 +09001095/*
1096 * HII protocols
1097 */
1098#define EFI_HII_STRING_PROTOCOL_GUID \
1099 EFI_GUID(0x0fd96974, 0x23aa, 0x4cdc, \
1100 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a)
1101
1102struct efi_font_info {
1103 efi_hii_font_style_t font_style;
1104 u16 font_size;
1105 u16 font_name[1];
1106};
1107
1108struct efi_hii_string_protocol {
1109 efi_status_t(EFIAPI *new_string)(
1110 const struct efi_hii_string_protocol *this,
1111 efi_hii_handle_t package_list,
1112 efi_string_id_t *string_id,
1113 const u8 *language,
1114 const u16 *language_name,
1115 const efi_string_t string,
1116 const struct efi_font_info *string_font_info);
1117 efi_status_t(EFIAPI *get_string)(
1118 const struct efi_hii_string_protocol *this,
1119 const u8 *language,
1120 efi_hii_handle_t package_list,
1121 efi_string_id_t string_id,
1122 efi_string_t string,
1123 efi_uintn_t *string_size,
1124 struct efi_font_info **string_font_info);
1125 efi_status_t(EFIAPI *set_string)(
1126 const struct efi_hii_string_protocol *this,
1127 efi_hii_handle_t package_list,
1128 efi_string_id_t string_id,
1129 const u8 *language,
1130 const efi_string_t string,
1131 const struct efi_font_info *string_font_info);
1132 efi_status_t(EFIAPI *get_languages)(
1133 const struct efi_hii_string_protocol *this,
1134 efi_hii_handle_t package_list,
1135 u8 *languages,
1136 efi_uintn_t *languages_size);
1137 efi_status_t(EFIAPI *get_secondary_languages)(
1138 const struct efi_hii_string_protocol *this,
1139 efi_hii_handle_t package_list,
1140 const u8 *primary_language,
1141 u8 *secondary_languages,
1142 efi_uintn_t *secondary_languages_size);
1143};
1144
1145#define EFI_HII_DATABASE_PROTOCOL_GUID \
1146 EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \
1147 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42)
1148
1149struct efi_hii_database_protocol {
1150 efi_status_t(EFIAPI *new_package_list)(
1151 const struct efi_hii_database_protocol *this,
1152 const struct efi_hii_package_list_header *package_list,
1153 const efi_handle_t driver_handle,
1154 efi_hii_handle_t *handle);
1155 efi_status_t(EFIAPI *remove_package_list)(
1156 const struct efi_hii_database_protocol *this,
1157 efi_hii_handle_t handle);
1158 efi_status_t(EFIAPI *update_package_list)(
1159 const struct efi_hii_database_protocol *this,
1160 efi_hii_handle_t handle,
1161 const struct efi_hii_package_list_header *package_list);
1162 efi_status_t(EFIAPI *list_package_lists)(
1163 const struct efi_hii_database_protocol *this,
1164 u8 package_type,
1165 const efi_guid_t *package_guid,
1166 efi_uintn_t *handle_buffer_length,
1167 efi_hii_handle_t *handle);
1168 efi_status_t(EFIAPI *export_package_lists)(
1169 const struct efi_hii_database_protocol *this,
1170 efi_hii_handle_t handle,
1171 efi_uintn_t *buffer_size,
1172 struct efi_hii_package_list_header *buffer);
1173 efi_status_t(EFIAPI *register_package_notify)(
1174 const struct efi_hii_database_protocol *this,
1175 u8 package_type,
1176 const efi_guid_t *package_guid,
1177 const void *package_notify_fn,
1178 efi_uintn_t notify_type,
1179 efi_handle_t *notify_handle);
1180 efi_status_t(EFIAPI *unregister_package_notify)(
1181 const struct efi_hii_database_protocol *this,
1182 efi_handle_t notification_handle
1183 );
1184 efi_status_t(EFIAPI *find_keyboard_layouts)(
1185 const struct efi_hii_database_protocol *this,
1186 u16 *key_guid_buffer_length,
1187 efi_guid_t *key_guid_buffer);
1188 efi_status_t(EFIAPI *get_keyboard_layout)(
1189 const struct efi_hii_database_protocol *this,
1190 efi_guid_t *key_guid,
1191 u16 *keyboard_layout_length,
1192 struct efi_hii_keyboard_layout *keyboard_layout);
1193 efi_status_t(EFIAPI *set_keyboard_layout)(
1194 const struct efi_hii_database_protocol *this,
1195 efi_guid_t *key_guid);
1196 efi_status_t(EFIAPI *get_package_list_handle)(
1197 const struct efi_hii_database_protocol *this,
1198 efi_hii_handle_t package_list_handle,
1199 efi_handle_t *driver_handle);
1200};
1201
AKASHI Takahirocb728e52019-01-21 12:13:00 +09001202#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
1203 EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \
1204 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f)
1205
1206struct efi_hii_config_routing_protocol {
1207 efi_status_t(EFIAPI *extract_config)(
1208 const struct efi_hii_config_routing_protocol *this,
1209 const efi_string_t request,
1210 efi_string_t *progress,
1211 efi_string_t *results);
1212 efi_status_t(EFIAPI *export_config)(
1213 const struct efi_hii_config_routing_protocol *this,
1214 efi_string_t *results);
1215 efi_status_t(EFIAPI *route_config)(
1216 const struct efi_hii_config_routing_protocol *this,
1217 const efi_string_t configuration,
1218 efi_string_t *progress);
1219 efi_status_t(EFIAPI *block_to_config)(
1220 const struct efi_hii_config_routing_protocol *this,
1221 const efi_string_t config_request,
1222 const uint8_t *block,
1223 const efi_uintn_t block_size,
1224 efi_string_t *config,
1225 efi_string_t *progress);
1226 efi_status_t(EFIAPI *config_to_block)(
1227 const struct efi_hii_config_routing_protocol *this,
1228 const efi_string_t config_resp,
1229 const uint8_t *block,
1230 const efi_uintn_t *block_size,
1231 efi_string_t *progress);
1232 efi_status_t(EFIAPI *get_alt_config)(
1233 const struct efi_hii_config_routing_protocol *this,
1234 const efi_string_t config_resp,
1235 const efi_guid_t *guid,
1236 const efi_string_t name,
1237 const struct efi_device_path *device_path,
1238 const efi_string_t alt_cfg_id,
1239 efi_string_t *alt_cfg_resp);
1240};
1241
1242#define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
1243 EFI_GUID(0x330d4706, 0xf2a0, 0x4e4f, \
1244 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85)
1245
1246struct efi_hii_config_access_protocol {
1247 efi_status_t(EFIAPI *extract_config_access)(
1248 const struct efi_hii_config_access_protocol *this,
1249 const efi_string_t request,
1250 efi_string_t *progress,
1251 efi_string_t *results);
1252 efi_status_t(EFIAPI *route_config_access)(
1253 const struct efi_hii_config_access_protocol *this,
1254 const efi_string_t configuration,
1255 efi_string_t *progress);
1256 efi_status_t(EFIAPI *form_callback)(
1257 const struct efi_hii_config_access_protocol *this,
1258 efi_browser_action_t action,
1259 efi_question_id_t question_id,
1260 u8 type,
1261 union efi_ifr_type_value *value,
1262 efi_browser_action_request_t *action_request);
1263};
1264
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +02001265#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
Alexander Grafbe8d3242016-03-15 18:38:21 +01001266 EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
1267 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
1268
1269#define EFI_GOT_RGBA8 0
1270#define EFI_GOT_BGRA8 1
1271#define EFI_GOT_BITMASK 2
1272
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +02001273struct efi_gop_mode_info {
Alexander Grafbe8d3242016-03-15 18:38:21 +01001274 u32 version;
1275 u32 width;
1276 u32 height;
1277 u32 pixel_format;
1278 u32 pixel_bitmask[4];
1279 u32 pixels_per_scanline;
1280};
1281
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +02001282struct efi_gop_mode {
Alexander Grafbe8d3242016-03-15 18:38:21 +01001283 u32 max_mode;
1284 u32 mode;
1285 struct efi_gop_mode_info *info;
1286 unsigned long info_size;
1287 efi_physical_addr_t fb_base;
1288 unsigned long fb_size;
1289};
1290
Heinrich Schuchardt0e0a3ce2018-02-07 22:14:22 +01001291struct efi_gop_pixel {
1292 u8 blue;
1293 u8 green;
1294 u8 red;
1295 u8 reserved;
1296};
1297
Alexander Grafbe8d3242016-03-15 18:38:21 +01001298#define EFI_BLT_VIDEO_FILL 0
1299#define EFI_BLT_VIDEO_TO_BLT_BUFFER 1
1300#define EFI_BLT_BUFFER_TO_VIDEO 2
1301#define EFI_BLT_VIDEO_TO_VIDEO 3
1302
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +02001303struct efi_gop {
Alexander Grafbe8d3242016-03-15 18:38:21 +01001304 efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
Heinrich Schuchardt1c38a772017-10-26 19:25:51 +02001305 efi_uintn_t *size_of_info,
Alexander Grafbe8d3242016-03-15 18:38:21 +01001306 struct efi_gop_mode_info **info);
1307 efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
Heinrich Schuchardt0e0a3ce2018-02-07 22:14:22 +01001308 efi_status_t (EFIAPI *blt)(struct efi_gop *this,
1309 struct efi_gop_pixel *buffer,
Heinrich Schuchardt1c38a772017-10-26 19:25:51 +02001310 u32 operation, efi_uintn_t sx,
1311 efi_uintn_t sy, efi_uintn_t dx,
1312 efi_uintn_t dy, efi_uintn_t width,
1313 efi_uintn_t height, efi_uintn_t delta);
Alexander Grafbe8d3242016-03-15 18:38:21 +01001314 struct efi_gop_mode *mode;
1315};
1316
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +02001317#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001318 EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
1319 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
1320
1321struct efi_mac_address {
1322 char mac_addr[32];
1323};
1324
1325struct efi_ip_address {
1326 u8 ip_addr[16];
Patrick Wildte2742352018-03-27 14:23:20 +02001327} __attribute__((aligned(4)));
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001328
1329enum efi_simple_network_state {
1330 EFI_NETWORK_STOPPED,
1331 EFI_NETWORK_STARTED,
1332 EFI_NETWORK_INITIALIZED,
1333};
1334
1335struct efi_simple_network_mode {
1336 enum efi_simple_network_state state;
1337 u32 hwaddr_size;
1338 u32 media_header_size;
1339 u32 max_packet_size;
1340 u32 nvram_size;
1341 u32 nvram_access_size;
1342 u32 receive_filter_mask;
1343 u32 receive_filter_setting;
1344 u32 max_mcast_filter_count;
1345 u32 mcast_filter_count;
1346 struct efi_mac_address mcast_filter[16];
1347 struct efi_mac_address current_address;
1348 struct efi_mac_address broadcast_address;
1349 struct efi_mac_address permanent_address;
1350 u8 if_type;
1351 u8 mac_changeable;
1352 u8 multitx_supported;
1353 u8 media_present_supported;
1354 u8 media_present;
1355};
1356
Heinrich Schuchardt2e0864a2017-10-05 16:35:56 +02001357/* receive_filters bit mask */
1358#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
1359#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
1360#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
1361#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
1362#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001363
Heinrich Schuchardt891b3d92017-10-05 16:36:02 +02001364/* interrupt status bit mask */
1365#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
1366#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
1367#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
1368#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
1369
Heinrich Schuchardtbdecf972017-10-05 16:35:57 +02001370/* revision of the simple network protocol */
1371#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
1372
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +02001373struct efi_simple_network {
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001374 u64 revision;
1375 efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
1376 efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
1377 efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
1378 ulong extra_rx, ulong extra_tx);
1379 efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
1380 int extended_verification);
1381 efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
1382 efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
1383 u32 enable, u32 disable, int reset_mcast_filter,
1384 ulong mcast_filter_count,
1385 struct efi_mac_address *mcast_filter);
1386 efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
1387 int reset, struct efi_mac_address *new_mac);
1388 efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
1389 int reset, ulong *stat_size, void *stat_table);
1390 efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
1391 int ipv6, struct efi_ip_address *ip,
1392 struct efi_mac_address *mac);
1393 efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
1394 int read_write, ulong offset, ulong buffer_size,
1395 char *buffer);
1396 efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
1397 u32 *int_status, void **txbuf);
1398 efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
Heinrich Schuchardt8db174d2017-10-05 16:36:03 +02001399 size_t header_size, size_t buffer_size, void *buffer,
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001400 struct efi_mac_address *src_addr,
1401 struct efi_mac_address *dest_addr, u16 *protocol);
1402 efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
Heinrich Schuchardt8db174d2017-10-05 16:36:03 +02001403 size_t *header_size, size_t *buffer_size, void *buffer,
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001404 struct efi_mac_address *src_addr,
1405 struct efi_mac_address *dest_addr, u16 *protocol);
Heinrich Schuchardt84a12ce2017-10-05 16:35:55 +02001406 struct efi_event *wait_for_packet;
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001407 struct efi_simple_network_mode *mode;
Heinrich Schuchardt7f6d8742019-08-31 09:56:30 +02001408 /* private fields */
1409 u32 int_status;
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001410};
1411
Heinrich Schuchardtdec88e42019-04-20 07:39:11 +02001412#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001413 EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
1414 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
1415
Heinrich Schuchardta6d37092019-08-06 08:13:33 +02001416#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000
1417#define EFI_PXE_BASE_CODE_MAX_IPCNT 8
1418
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001419struct efi_pxe_packet {
1420 u8 packet[1472];
1421};
1422
Heinrich Schuchardt2e0d79a2018-09-08 10:50:40 +02001423struct efi_pxe_mode {
Patrick Wildte2742352018-03-27 14:23:20 +02001424 u8 started;
1425 u8 ipv6_available;
1426 u8 ipv6_supported;
1427 u8 using_ipv6;
1428 u8 bis_supported;
1429 u8 bis_detected;
1430 u8 auto_arp;
1431 u8 send_guid;
1432 u8 dhcp_discover_valid;
1433 u8 dhcp_ack_received;
1434 u8 proxy_offer_received;
1435 u8 pxe_discover_valid;
1436 u8 pxe_reply_received;
1437 u8 pxe_bis_reply_received;
1438 u8 icmp_error_received;
1439 u8 tftp_error_received;
1440 u8 make_callbacks;
1441 u8 ttl;
1442 u8 tos;
1443 u8 pad;
1444 struct efi_ip_address station_ip;
1445 struct efi_ip_address subnet_mask;
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001446 struct efi_pxe_packet dhcp_discover;
1447 struct efi_pxe_packet dhcp_ack;
1448 struct efi_pxe_packet proxy_offer;
1449 struct efi_pxe_packet pxe_discover;
1450 struct efi_pxe_packet pxe_reply;
1451};
1452
Heinrich Schuchardta6d37092019-08-06 08:13:33 +02001453struct efi_pxe_base_code_srvlist {
1454 u16 type;
1455 u8 accept_any_response;
1456 u8 reserved;
1457 struct efi_ip_address ip_addr;
1458};
1459
1460struct efi_pxe_base_code_discover_info {
1461 u8 use_m_cast;
1462 u8 use_b_cast;
1463 u8 use_u_cast;
1464 u8 must_use_list;
1465 struct efi_ip_address server_m_cast_ip;
1466 u16 ip_cnt;
1467 struct efi_pxe_base_code_srvlist srv_list[];
1468};
1469
1470struct efi_pxe_base_code_mtftp_info {
1471 struct efi_ip_address m_cast_ip;
1472 u16 cport;
1473 u16 sport;
1474 u16 listen_timeout;
1475 u16 transit_timeout;
1476};
1477
1478struct efi_pxe_base_code_filter {
1479 u8 filters;
1480 u8 ip_cnt;
1481 u16 reserved;
1482 struct efi_ip_address ip_list[EFI_PXE_BASE_CODE_MAX_IPCNT];
1483};
1484
1485struct efi_pxe_base_code_dhcpv4_packet {
1486 u8 bootp_op_code;
1487 u8 bootp_hw_type;
1488 u8 bootp_addr_len;
1489 u8 bootp_gate_hops;
1490 u32 bootp_ident;
1491 u16 bootp_seconds;
1492 u16 bootp_flags;
1493 u8 bootp_ci_addr[4];
1494 u8 bootp_yi_addr[4];
1495 u8 bootp_si_addr[4];
1496 u8 bootp_gi_addr[4];
1497 u8 bootp_hw_addr[16];
1498 u8 bootp_srv_name[64];
1499 u8 bootp_boot_file[128];
1500 u32 dhcp_magick;
1501 u8 dhcp_options[56];
1502};
1503
1504struct efi_pxe_base_code_dhcpv6_packet {
1505 u8 message_type;
1506 u8 transaction_id[3];
1507 u8 dhcp_options[1024];
1508};
1509
1510typedef union {
1511 u8 raw[1472];
1512 struct efi_pxe_base_code_dhcpv4_packet dhcpv4;
1513 struct efi_pxe_base_code_dhcpv6_packet dhcpv6;
1514} EFI_PXE_BASE_CODE_PACKET;
1515
1516struct efi_pxe_base_code_protocol {
1517 u64 revision;
1518 efi_status_t (EFIAPI *start)(struct efi_pxe_base_code_protocol *this,
1519 u8 use_ipv6);
1520 efi_status_t (EFIAPI *stop)(struct efi_pxe_base_code_protocol *this);
1521 efi_status_t (EFIAPI *dhcp)(struct efi_pxe_base_code_protocol *this,
1522 u8 sort_offers);
1523 efi_status_t (EFIAPI *discover)(
1524 struct efi_pxe_base_code_protocol *this,
1525 u16 type, u16 *layer, u8 bis,
1526 struct efi_pxe_base_code_discover_info *info);
1527 efi_status_t (EFIAPI *mtftp)(
1528 struct efi_pxe_base_code_protocol *this,
1529 u32 operation, void *buffer_ptr,
1530 u8 overwrite, efi_uintn_t *buffer_size,
1531 struct efi_ip_address server_ip, char *filename,
1532 struct efi_pxe_base_code_mtftp_info *info,
1533 u8 dont_use_buffer);
1534 efi_status_t (EFIAPI *udp_write)(
1535 struct efi_pxe_base_code_protocol *this,
1536 u16 op_flags, struct efi_ip_address *dest_ip,
1537 u16 *dest_port,
1538 struct efi_ip_address *gateway_ip,
1539 struct efi_ip_address *src_ip, u16 *src_port,
1540 efi_uintn_t *header_size, void *header_ptr,
1541 efi_uintn_t *buffer_size, void *buffer_ptr);
1542 efi_status_t (EFIAPI *udp_read)(
1543 struct efi_pxe_base_code_protocol *this,
1544 u16 op_flags, struct efi_ip_address *dest_ip,
1545 u16 *dest_port, struct efi_ip_address *src_ip,
1546 u16 *src_port, efi_uintn_t *header_size,
1547 void *header_ptr, efi_uintn_t *buffer_size,
1548 void *buffer_ptr);
1549 efi_status_t (EFIAPI *set_ip_filter)(
1550 struct efi_pxe_base_code_protocol *this,
1551 struct efi_pxe_base_code_filter *new_filter);
1552 efi_status_t (EFIAPI *arp)(struct efi_pxe_base_code_protocol *this,
1553 struct efi_ip_address *ip_addr,
1554 struct efi_mac_address *mac_addr);
1555 efi_status_t (EFIAPI *set_parameters)(
1556 struct efi_pxe_base_code_protocol *this,
1557 u8 *new_auto_arp, u8 *new_send_guid,
1558 u8 *new_ttl, u8 *new_tos,
1559 u8 *new_make_callback);
1560 efi_status_t (EFIAPI *set_station_ip)(
1561 struct efi_pxe_base_code_protocol *this,
1562 struct efi_ip_address *new_station_ip,
1563 struct efi_ip_address *new_subnet_mask);
1564 efi_status_t (EFIAPI *set_packets)(
1565 struct efi_pxe_base_code_protocol *this,
1566 u8 *new_dhcp_discover_valid,
1567 u8 *new_dhcp_ack_received,
1568 u8 *new_proxy_offer_received,
1569 u8 *new_pxe_discover_valid,
1570 u8 *new_pxe_reply_received,
1571 u8 *new_pxe_bis_reply_received,
1572 EFI_PXE_BASE_CODE_PACKET *new_dchp_discover,
1573 EFI_PXE_BASE_CODE_PACKET *new_dhcp_acc,
1574 EFI_PXE_BASE_CODE_PACKET *new_proxy_offer,
1575 EFI_PXE_BASE_CODE_PACKET *new_pxe_discover,
1576 EFI_PXE_BASE_CODE_PACKET *new_pxe_reply,
1577 EFI_PXE_BASE_CODE_PACKET *new_pxe_bis_reply);
Alexander Graf0efe1bc2016-05-06 21:01:01 +02001578 struct efi_pxe_mode *mode;
1579};
1580
Rob Clark2a920802017-09-13 18:05:34 -04001581#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
1582 EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
1583 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
Heinrich Schuchardt17394f92019-03-27 21:41:04 +01001584#define EFI_FILE_PROTOCOL_REVISION 0x00010000
1585#define EFI_FILE_PROTOCOL_REVISION2 0x00020000
1586#define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2
Rob Clark2a920802017-09-13 18:05:34 -04001587
Heinrich Schuchardte692ed12019-09-08 09:35:32 +02001588struct efi_file_io_token {
1589 struct efi_event *event;
1590 efi_status_t status;
1591 efi_uintn_t buffer_size;
1592 void *buffer;};
1593
Rob Clark2a920802017-09-13 18:05:34 -04001594struct efi_file_handle {
1595 u64 rev;
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001596 efi_status_t (EFIAPI *open)(struct efi_file_handle *this,
Rob Clark2a920802017-09-13 18:05:34 -04001597 struct efi_file_handle **new_handle,
Heinrich Schuchardtc82f8f62019-01-12 12:02:33 +01001598 u16 *file_name, u64 open_mode, u64 attributes);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001599 efi_status_t (EFIAPI *close)(struct efi_file_handle *this);
1600 efi_status_t (EFIAPI *delete)(struct efi_file_handle *this);
1601 efi_status_t (EFIAPI *read)(struct efi_file_handle *this,
Heinrich Schuchardtb6dd5772018-04-03 22:37:11 +02001602 efi_uintn_t *buffer_size, void *buffer);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001603 efi_status_t (EFIAPI *write)(struct efi_file_handle *this,
Heinrich Schuchardtb6dd5772018-04-03 22:37:11 +02001604 efi_uintn_t *buffer_size, void *buffer);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001605 efi_status_t (EFIAPI *getpos)(struct efi_file_handle *this,
Heinrich Schuchardt0801d4d2018-10-07 05:26:26 +02001606 u64 *pos);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001607 efi_status_t (EFIAPI *setpos)(struct efi_file_handle *this,
Heinrich Schuchardt0801d4d2018-10-07 05:26:26 +02001608 u64 pos);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001609 efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *this,
Heinrich Schuchardt9c9021e2018-04-04 15:42:09 +02001610 const efi_guid_t *info_type, efi_uintn_t *buffer_size,
Heinrich Schuchardtb6dd5772018-04-03 22:37:11 +02001611 void *buffer);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001612 efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *this,
Heinrich Schuchardt9c9021e2018-04-04 15:42:09 +02001613 const efi_guid_t *info_type, efi_uintn_t buffer_size,
Heinrich Schuchardtb6dd5772018-04-03 22:37:11 +02001614 void *buffer);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001615 efi_status_t (EFIAPI *flush)(struct efi_file_handle *this);
1616 efi_status_t (EFIAPI *open_ex)(struct efi_file_handle *this,
Heinrich Schuchardte692ed12019-09-08 09:35:32 +02001617 struct efi_file_handle **new_handle,
1618 u16 *file_name, u64 open_mode, u64 attributes,
1619 struct efi_file_io_token *token);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001620 efi_status_t (EFIAPI *read_ex)(struct efi_file_handle *this,
Heinrich Schuchardte692ed12019-09-08 09:35:32 +02001621 struct efi_file_io_token *token);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001622 efi_status_t (EFIAPI *write_ex)(struct efi_file_handle *this,
Heinrich Schuchardte692ed12019-09-08 09:35:32 +02001623 struct efi_file_io_token *token);
Heinrich Schuchardtdb12f512021-01-01 08:39:43 +01001624 efi_status_t (EFIAPI *flush_ex)(struct efi_file_handle *this,
Heinrich Schuchardte692ed12019-09-08 09:35:32 +02001625 struct efi_file_io_token *token);
Rob Clark2a920802017-09-13 18:05:34 -04001626};
1627
Rob Clark2a920802017-09-13 18:05:34 -04001628#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
1629
1630struct efi_simple_file_system_protocol {
1631 u64 rev;
1632 efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
1633 struct efi_file_handle **root);
1634};
1635
1636#define EFI_FILE_INFO_GUID \
1637 EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
1638 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
1639
Heinrich Schuchardt9e6835e2018-04-04 15:42:11 +02001640#define EFI_FILE_SYSTEM_INFO_GUID \
1641 EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \
1642 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
1643
Heinrich Schuchardt632834c2019-09-08 10:32:54 +02001644#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \
1645 EFI_GUID(0xdb47d7d3, 0xfe81, 0x11d3, \
1646 0x9a, 0x35, 0x00, 0x90, 0x27, 0x3f, 0xC1, 0x4d)
1647
Rob Clark2a920802017-09-13 18:05:34 -04001648#define EFI_FILE_MODE_READ 0x0000000000000001
1649#define EFI_FILE_MODE_WRITE 0x0000000000000002
1650#define EFI_FILE_MODE_CREATE 0x8000000000000000
1651
1652#define EFI_FILE_READ_ONLY 0x0000000000000001
1653#define EFI_FILE_HIDDEN 0x0000000000000002
1654#define EFI_FILE_SYSTEM 0x0000000000000004
1655#define EFI_FILE_RESERVED 0x0000000000000008
1656#define EFI_FILE_DIRECTORY 0x0000000000000010
1657#define EFI_FILE_ARCHIVE 0x0000000000000020
1658#define EFI_FILE_VALID_ATTR 0x0000000000000037
1659
1660struct efi_file_info {
1661 u64 size;
1662 u64 file_size;
1663 u64 physical_size;
1664 struct efi_time create_time;
1665 struct efi_time last_access_time;
1666 struct efi_time modification_time;
1667 u64 attribute;
Heinrich Schuchardt02c2f022018-11-05 20:22:12 +01001668 u16 file_name[0];
Rob Clark2a920802017-09-13 18:05:34 -04001669};
1670
Heinrich Schuchardt9e6835e2018-04-04 15:42:11 +02001671struct efi_file_system_info {
1672 u64 size;
1673 u8 read_only;
1674 u64 volume_size;
1675 u64 free_space;
1676 u32 block_size;
1677 u16 volume_label[0];
1678};
1679
Heinrich Schuchardtf0959db2018-01-11 08:16:02 +01001680#define EFI_DRIVER_BINDING_PROTOCOL_GUID \
1681 EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\
1682 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71)
1683struct efi_driver_binding_protocol {
1684 efi_status_t (EFIAPI * supported)(
1685 struct efi_driver_binding_protocol *this,
1686 efi_handle_t controller_handle,
1687 struct efi_device_path *remaining_device_path);
1688 efi_status_t (EFIAPI * start)(
1689 struct efi_driver_binding_protocol *this,
1690 efi_handle_t controller_handle,
1691 struct efi_device_path *remaining_device_path);
1692 efi_status_t (EFIAPI * stop)(
1693 struct efi_driver_binding_protocol *this,
1694 efi_handle_t controller_handle,
1695 efi_uintn_t number_of_children,
1696 efi_handle_t *child_handle_buffer);
1697 u32 version;
1698 efi_handle_t image_handle;
1699 efi_handle_t driver_binding_handle;
1700};
1701
Heinrich Schuchardtb1b782d2019-05-16 18:19:00 +02001702/* Current version of the Unicode collation protocol */
Heinrich Schuchardt0bc4b0d2018-09-04 19:34:58 +02001703#define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
1704 EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \
1705 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49)
1706struct efi_unicode_collation_protocol {
1707 efi_intn_t (EFIAPI *stri_coll)(
1708 struct efi_unicode_collation_protocol *this, u16 *s1, u16 *s2);
1709 bool (EFIAPI *metai_match)(struct efi_unicode_collation_protocol *this,
1710 const u16 *string, const u16 *patter);
1711 void (EFIAPI *str_lwr)(struct efi_unicode_collation_protocol
1712 *this, u16 *string);
1713 void (EFIAPI *str_upr)(struct efi_unicode_collation_protocol *this,
1714 u16 *string);
1715 void (EFIAPI *fat_to_str)(struct efi_unicode_collation_protocol *this,
1716 efi_uintn_t fat_size, char *fat, u16 *string);
1717 bool (EFIAPI *str_to_fat)(struct efi_unicode_collation_protocol *this,
1718 const u16 *string, efi_uintn_t fat_size,
1719 char *fat);
1720 char *supported_languages;
1721};
1722
Ilias Apalodimasec80b472020-02-21 09:55:45 +02001723struct efi_load_file_protocol {
1724 efi_status_t (EFIAPI *load_file)(struct efi_load_file_protocol *this,
1725 struct efi_device_path *file_path,
1726 bool boot_policy,
1727 efi_uintn_t *buffer_size,
1728 void *buffer);
1729};
1730
Jose Marinho64a8aae2021-03-02 17:26:38 +00001731struct efi_system_resource_entry {
1732 efi_guid_t fw_class;
1733 u32 fw_type;
1734 u32 fw_version;
1735 u32 lowest_supported_fw_version;
1736 u32 capsule_flags;
1737 u32 last_attempt_version;
1738 u32 last_attempt_status;
1739} __packed;
1740
1741struct efi_system_resource_table {
1742 u32 fw_resource_count;
1743 u32 fw_resource_count_max;
1744 u64 fw_resource_version;
1745 struct efi_system_resource_entry entries[];
1746} __packed;
1747
AKASHI Takahiro454568b2019-02-25 15:54:37 +09001748/* Boot manager load options */
1749#define LOAD_OPTION_ACTIVE 0x00000001
1750#define LOAD_OPTION_FORCE_RECONNECT 0x00000002
1751#define LOAD_OPTION_HIDDEN 0x00000008
1752/* All values 0x00000200-0x00001F00 are reserved */
1753#define LOAD_OPTION_CATEGORY 0x00001F00
1754#define LOAD_OPTION_CATEGORY_BOOT 0x00000000
1755#define LOAD_OPTION_CATEGORY_APP 0x00000100
1756
AKASHI Takahirob74d5682020-03-17 11:12:35 +09001757/*
1758 * System Resource Table
1759 */
1760/* Firmware Type Definitions */
1761#define ESRT_FW_TYPE_UNKNOWN 0x00000000
1762#define ESRT_FW_TYPE_SYSTEMFIRMWARE 0x00000001
1763#define ESRT_FW_TYPE_DEVICEFIRMWARE 0x00000002
1764#define ESRT_FW_TYPE_UEFIDRIVER 0x00000003
1765
Jose Marinho64a8aae2021-03-02 17:26:38 +00001766#define EFI_SYSTEM_RESOURCE_TABLE_GUID\
1767 EFI_GUID(0xb122a263, 0x3661, 0x4f68,\
1768 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80)
1769
AKASHI Takahirob74d5682020-03-17 11:12:35 +09001770/* Last Attempt Status Values */
1771#define LAST_ATTEMPT_STATUS_SUCCESS 0x00000000
1772#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL 0x00000001
1773#define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES 0x00000002
1774#define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION 0x00000003
1775#define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT 0x00000004
1776#define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR 0x00000005
1777#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC 0x00000006
1778#define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT 0x00000007
1779#define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES 0x00000008
1780
1781/*
1782 * The LastAttemptStatus values of 0x1000 - 0x4000 are reserved for vendor
1783 * usage.
1784 */
1785#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN 0x00001000
1786#define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX 0x00004000
1787
AKASHI Takahiro593e17d2020-04-14 11:51:39 +09001788/* Certificate types in signature database */
1789#define EFI_CERT_SHA256_GUID \
1790 EFI_GUID(0xc1c41626, 0x504c, 0x4092, 0xac, 0xa9, \
1791 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28)
1792#define EFI_CERT_RSA2048_GUID \
1793 EFI_GUID(0x3c5766e8, 0x269c, 0x4e34, 0xaa, 0x14, \
1794 0xed, 0x77, 0x6e, 0x85, 0xb3, 0xb6)
1795#define EFI_CERT_X509_GUID \
1796 EFI_GUID(0xa5c059a1, 0x94e4, 0x4aa7, 0x87, 0xb5, \
1797 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72)
1798#define EFI_CERT_X509_SHA256_GUID \
1799 EFI_GUID(0x3bd2a492, 0x96c0, 0x4079, 0xb4, 0x20, \
1800 0xfc, 0xf9, 0x8e, 0xf1, 0x03, 0xed)
1801#define EFI_CERT_TYPE_PKCS7_GUID \
1802 EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
1803 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
1804
1805/**
1806 * win_certificate_uefi_guid - A certificate that encapsulates
1807 * a GUID-specific signature
1808 *
1809 * @hdr: Windows certificate header
1810 * @cert_type: Certificate type
1811 * @cert_data: Certificate data
1812 */
1813struct win_certificate_uefi_guid {
1814 WIN_CERTIFICATE hdr;
1815 efi_guid_t cert_type;
1816 u8 cert_data[];
1817} __attribute__((__packed__));
1818
1819/**
1820 * efi_variable_authentication_2 - A time-based authentication method
1821 * descriptor
1822 *
1823 * This structure describes an authentication information for
1824 * a variable with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
1825 * and should be included as part of a variable's value.
1826 * Only EFI_CERT_TYPE_PKCS7_GUID is accepted.
1827 *
1828 * @time_stamp: Descriptor's time stamp
1829 * @auth_info: Authentication info
1830 */
1831struct efi_variable_authentication_2 {
1832 struct efi_time time_stamp;
1833 struct win_certificate_uefi_guid auth_info;
1834} __attribute__((__packed__));
1835
1836/**
Sughosh Ganu04be98b2020-12-30 19:27:09 +05301837 * efi_firmware_image_authentication - Capsule authentication method
1838 * descriptor
1839 *
1840 * This structure describes an authentication information for
1841 * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set
1842 * and should be included as part of the capsule.
1843 * Only EFI_CERT_TYPE_PKCS7_GUID is accepted.
1844 *
1845 * @monotonic_count: Count to prevent replay
1846 * @auth_info: Authentication info
1847 */
1848struct efi_firmware_image_authentication {
1849 uint64_t monotonic_count;
1850 struct win_certificate_uefi_guid auth_info;
1851} __attribute__((__packed__));
1852
1853
1854/**
AKASHI Takahiro593e17d2020-04-14 11:51:39 +09001855 * efi_signature_data - A format of signature
1856 *
1857 * This structure describes a single signature in signature database.
1858 *
1859 * @signature_owner: Signature owner
1860 * @signature_data: Signature data
1861 */
1862struct efi_signature_data {
1863 efi_guid_t signature_owner;
1864 u8 signature_data[];
1865} __attribute__((__packed__));
1866
1867/**
1868 * efi_signature_list - A format of signature database
1869 *
1870 * This structure describes a list of signatures with the same type.
1871 * An authenticated variable's value is a concatenation of one or more
1872 * efi_signature_list's.
1873 *
1874 * @signature_type: Signature type
1875 * @signature_list_size: Size of signature list
1876 * @signature_header_size: Size of signature header
1877 * @signature_size: Size of signature
1878 */
1879struct efi_signature_list {
1880 efi_guid_t signature_type;
1881 u32 signature_list_size;
1882 u32 signature_header_size;
1883 u32 signature_size;
1884/* u8 signature_header[signature_header_size]; */
1885/* struct efi_signature_data signatures[...][signature_size]; */
1886} __attribute__((__packed__));
1887
AKASHI Takahiro8d990262020-11-30 18:12:11 +09001888/*
1889 * Firmware management protocol
1890 */
1891#define EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID \
1892 EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \
1893 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7)
1894
AKASHI Takahirof27c2012020-11-30 18:12:12 +09001895#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
1896 EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
1897 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
1898
AKASHI Takahirobb7e71d2020-11-17 09:28:00 +09001899#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
1900 EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
1901 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
1902
AKASHI Takahiro8d990262020-11-30 18:12:11 +09001903#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001
1904#define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002
1905#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004
1906#define IMAGE_ATTRIBUTE_IN_USE 0x0000000000000008
1907#define IMAGE_ATTRIBUTE_UEFI_IMAGE 0x0000000000000010
1908#define IMAGE_ATTRIBUTE_DEPENDENCY 0x0000000000000020
1909
1910#define IMAGE_COMPATIBILITY_CHECK_SUPPORTED 0x0000000000000001
1911
1912#define IMAGE_UPDATABLE_VALID 0x0000000000000001
1913#define IMAGE_UPDATABLE_INVALID 0x0000000000000002
1914#define IMAGE_UPDATABLE_INVALID_TYPE 0x0000000000000004
1915#define IMAGE_UPDATABLE_INVALID_OLLD 0x0000000000000008
1916#define IMAGE_UPDATABLE_VALID_WITH_VENDOR_CODE 0x0000000000000010
1917
1918#define PACKAGE_ATTRIBUTE_VERSION_UPDATABLE 0x0000000000000001
1919#define PACKAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002
1920#define PACKAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004
1921
1922#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION 4
1923
1924typedef struct efi_firmware_image_dependencies {
1925 u8 dependencies[0];
1926} efi_firmware_image_dep_t;
1927
1928struct efi_firmware_image_descriptor {
1929 u8 image_index;
1930 efi_guid_t image_type_id;
1931 u64 image_id;
1932 u16 *image_id_name;
1933 u32 version;
1934 u16 *version_name;
1935 efi_uintn_t size;
1936 u64 attributes_supported;
1937 u64 attributes_setting;
1938 u64 compatibilities;
1939 u32 lowest_supported_image_version;
1940 u32 last_attempt_version;
1941 u32 last_attempt_status;
1942 u64 hardware_instance;
1943 efi_firmware_image_dep_t *dependencies;
1944};
1945
1946struct efi_firmware_management_protocol {
1947 efi_status_t (EFIAPI *get_image_info)(
1948 struct efi_firmware_management_protocol *this,
1949 efi_uintn_t *image_info_size,
1950 struct efi_firmware_image_descriptor *image_info,
1951 u32 *descriptor_version,
1952 u8 *descriptor_count,
1953 efi_uintn_t *descriptor_size,
1954 u32 *package_version,
1955 u16 **package_version_name);
1956 efi_status_t (EFIAPI *get_image)(
1957 struct efi_firmware_management_protocol *this,
1958 u8 image_index,
1959 void *image,
1960 efi_uintn_t *image_size);
1961 efi_status_t (EFIAPI *set_image)(
1962 struct efi_firmware_management_protocol *this,
1963 u8 image_index,
1964 const void *image,
1965 efi_uintn_t image_size,
1966 const void *vendor_code,
1967 efi_status_t (*progress)(efi_uintn_t completion),
1968 u16 **abort_reason);
1969 efi_status_t (EFIAPI *check_image)(
1970 struct efi_firmware_management_protocol *this,
1971 u8 image_index,
1972 const void *image,
1973 efi_uintn_t *image_size,
1974 u32 *image_updatable);
1975 efi_status_t (EFIAPI *get_package_info)(
1976 struct efi_firmware_management_protocol *this,
1977 u32 *package_version,
1978 u16 **package_version_name,
1979 u32 *package_version_name_maxlen,
1980 u64 *attributes_supported,
1981 u64 *attributes_setting);
1982 efi_status_t (EFIAPI *set_package_info)(
1983 struct efi_firmware_management_protocol *this,
1984 const void *image,
1985 efi_uintn_t *image_size,
1986 const void *vendor_code,
1987 u32 package_version,
1988 const u16 *package_version_name);
1989};
1990
Simon Glass867a6ac2015-07-31 09:31:36 -06001991#endif