Blame view

include/efi_api.h 53.3 KB
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
1
  /* SPDX-License-Identifier: GPL-2.0 */
867a6ac86   Simon Glass   efi: Add start-up...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  /*
   * Extensible Firmware Interface
   * Based on 'Extensible Firmware Interface Specification' version 0.9,
   * April 30, 1999
   *
   * Copyright (C) 1999 VA Linux Systems
   * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
   * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
   *	David Mosberger-Tang <davidm@hpl.hp.com>
   *	Stephane Eranian <eranian@hpl.hp.com>
   *
   * From include/linux/efi.h in kernel 4.1 with some additions/subtractions
   */
  
  #ifndef _EFI_API_H
  #define _EFI_API_H
  
  #include <efi.h>
c9bfb2229   Leif Lindholm   efi_loader: Initi...
20
  #include <charset.h>
867a6ac86   Simon Glass   efi: Add start-up...
21

a86aeaf22   Alexander Graf   efi_loader: Add e...
22
23
24
  #ifdef CONFIG_EFI_LOADER
  #include <asm/setjmp.h>
  #endif
c7308d6e2   Heinrich Schuchardt   efi_loader: bump ...
25
26
  /* UEFI spec version 2.8 */
  #define EFI_SPECIFICATION_VERSION (2 << 16 | 80)
112f24301   Heinrich Schuchardt   efi_loader: speci...
27

2bb9b79d6   Alexander Graf   include/efi_api.h...
28
  /* Types and defines for EFI CreateEvent */
b521d29eb   xypron.glpk@gmx.de   efi_loader: param...
29
  enum efi_timer_delay {
2bb9b79d6   Alexander Graf   include/efi_api.h...
30
31
32
33
  	EFI_TIMER_STOP = 0,
  	EFI_TIMER_PERIODIC = 1,
  	EFI_TIMER_RELATIVE = 2
  };
0bc4b0da7   Heinrich Schuchardt   efi_loader: EFI_U...
34
  #define efi_intn_t ssize_t
152cade32   Heinrich Schuchardt   efi_loader: repla...
35
  #define efi_uintn_t size_t
c9bfb2229   Leif Lindholm   efi_loader: Initi...
36
37
38
39
  typedef void *efi_hii_handle_t;
  typedef u16 *efi_string_t;
  typedef u16 efi_string_id_t;
  typedef u32 efi_hii_font_style_t;
cb728e51a   AKASHI Takahiro   efi: hii: add HII...
40
41
42
  typedef u16 efi_question_id_t;
  typedef u16 efi_image_id_t;
  typedef u16 efi_form_id_t;
503f26955   xypron.glpk@gmx.de   efi_loader: corre...
43

c68415922   xypron.glpk@gmx.de   efi_loader: imple...
44
45
46
47
48
49
50
51
52
53
54
  #define EVT_TIMER				0x80000000
  #define EVT_RUNTIME				0x40000000
  #define EVT_NOTIFY_WAIT				0x00000100
  #define EVT_NOTIFY_SIGNAL			0x00000200
  #define EVT_SIGNAL_EXIT_BOOT_SERVICES		0x00000201
  #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE	0x60000202
  
  #define TPL_APPLICATION		0x04
  #define TPL_CALLBACK		0x08
  #define TPL_NOTIFY		0x10
  #define TPL_HIGH_LEVEL		0x1F
37a980b3f   Jonathan Gray   efi_loader: run C...
55

2fd945fe7   xypron.glpk@gmx.de   efi_loader: use s...
56
  struct efi_event;
7cceef7bd   AKASHI Takahiro   efi_loader: defin...
57
58
59
60
61
62
63
64
65
  /* OsIndicationsSupported flags */
  #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI		    0x0000000000000001
  #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION		    0x0000000000000002
  #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED  0x0000000000000004
  #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED	    0x0000000000000008
  #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED	    0x0000000000000010
  #define EFI_OS_INDICATIONS_START_OS_RECOVERY		    0x0000000000000020
  #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY	    0x0000000000000040
  #define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH	    0x0000000000000080
867a6ac86   Simon Glass   efi: Add start-up...
66
  /* EFI Boot Services table */
112f24301   Heinrich Schuchardt   efi_loader: speci...
67
  #define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
867a6ac86   Simon Glass   efi: Add start-up...
68
69
  struct efi_boot_services {
  	struct efi_table_hdr hdr;
152cade32   Heinrich Schuchardt   efi_loader: repla...
70
71
  	efi_status_t (EFIAPI *raise_tpl)(efi_uintn_t new_tpl);
  	void (EFIAPI *restore_tpl)(efi_uintn_t old_tpl);
867a6ac86   Simon Glass   efi: Add start-up...
72

f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
73
  	efi_status_t (EFIAPI *allocate_pages)(int, int, efi_uintn_t,
867a6ac86   Simon Glass   efi: Add start-up...
74
  					      efi_physical_addr_t *);
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
75
76
77
78
79
80
81
  	efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, efi_uintn_t);
  	efi_status_t (EFIAPI *get_memory_map)(efi_uintn_t *memory_map_size,
  					      struct efi_mem_desc *desc,
  					      efi_uintn_t *key,
  					      efi_uintn_t *desc_size,
  					      u32 *desc_version);
  	efi_status_t (EFIAPI *allocate_pool)(int, efi_uintn_t, void **);
867a6ac86   Simon Glass   efi: Add start-up...
82
  	efi_status_t (EFIAPI *free_pool)(void *);
b521d29eb   xypron.glpk@gmx.de   efi_loader: param...
83
  	efi_status_t (EFIAPI *create_event)(uint32_t type,
152cade32   Heinrich Schuchardt   efi_loader: repla...
84
  			efi_uintn_t notify_tpl,
2fd945fe7   xypron.glpk@gmx.de   efi_loader: use s...
85
86
87
88
  			void (EFIAPI *notify_function) (
  					struct efi_event *event,
  					void *context),
  			void *notify_context, struct efi_event **event);
b521d29eb   xypron.glpk@gmx.de   efi_loader: param...
89
90
91
  	efi_status_t (EFIAPI *set_timer)(struct efi_event *event,
  					 enum efi_timer_delay type,
  					 uint64_t trigger_time);
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
92
93
94
  	efi_status_t (EFIAPI *wait_for_event)(efi_uintn_t number_of_events,
  					      struct efi_event **event,
  					      efi_uintn_t *index);
2fd945fe7   xypron.glpk@gmx.de   efi_loader: use s...
95
96
97
  	efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
  	efi_status_t (EFIAPI *close_event)(struct efi_event *event);
  	efi_status_t (EFIAPI *check_event)(struct efi_event *event);
e0549f8a1   xypron.glpk@gmx.de   efi_loader: imple...
98
  #define EFI_NATIVE_INTERFACE	0x00000000
2bb9b79d6   Alexander Graf   include/efi_api.h...
99
  	efi_status_t (EFIAPI *install_protocol_interface)(
faea10410   Heinrich Schuchardt   efi_loader: typed...
100
  			efi_handle_t *handle, const efi_guid_t *protocol,
2bb9b79d6   Alexander Graf   include/efi_api.h...
101
102
  			int protocol_interface_type, void *protocol_interface);
  	efi_status_t (EFIAPI *reinstall_protocol_interface)(
faea10410   Heinrich Schuchardt   efi_loader: typed...
103
  			efi_handle_t handle, const efi_guid_t *protocol,
2bb9b79d6   Alexander Graf   include/efi_api.h...
104
  			void *old_interface, void *new_interface);
2074f7006   Heinrich Schuchardt   efi_loader: consi...
105
106
107
108
109
110
  	efi_status_t (EFIAPI *uninstall_protocol_interface)(
  			efi_handle_t handle, const efi_guid_t *protocol,
  			void *protocol_interface);
  	efi_status_t (EFIAPI *handle_protocol)(
  			efi_handle_t handle, const efi_guid_t *protocol,
  			void **protocol_interface);
867a6ac86   Simon Glass   efi: Add start-up...
111
  	void *reserved;
2bb9b79d6   Alexander Graf   include/efi_api.h...
112
  	efi_status_t (EFIAPI *register_protocol_notify)(
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
113
  			const efi_guid_t *protocol, struct efi_event *event,
2bb9b79d6   Alexander Graf   include/efi_api.h...
114
  			void **registration);
867a6ac86   Simon Glass   efi: Add start-up...
115
116
  	efi_status_t (EFIAPI *locate_handle)(
  			enum efi_locate_search_type search_type,
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
117
  			const efi_guid_t *protocol, void *search_key,
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
118
  			efi_uintn_t *buffer_size, efi_handle_t *buffer);
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
119
  	efi_status_t (EFIAPI *locate_device_path)(const efi_guid_t *protocol,
867a6ac86   Simon Glass   efi: Add start-up...
120
121
  			struct efi_device_path **device_path,
  			efi_handle_t *device);
2bb9b79d6   Alexander Graf   include/efi_api.h...
122
123
  	efi_status_t (EFIAPI *install_configuration_table)(
  			efi_guid_t *guid, void *table);
867a6ac86   Simon Glass   efi: Add start-up...
124
125
126
127
  
  	efi_status_t (EFIAPI *load_image)(bool boot_policiy,
  			efi_handle_t parent_image,
  			struct efi_device_path *file_path, void *source_buffer,
7fb96a10b   Heinrich Schuchardt   efi_loader: use e...
128
  			efi_uintn_t source_size, efi_handle_t *image);
867a6ac86   Simon Glass   efi: Add start-up...
129
  	efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
cc8e34178   Heinrich Schuchardt   efi_loader: signa...
130
131
  					   efi_uintn_t *exitdata_size,
  					   u16 **exitdata);
867a6ac86   Simon Glass   efi: Add start-up...
132
133
  	efi_status_t (EFIAPI *exit)(efi_handle_t handle,
  				    efi_status_t exit_status,
cc8e34178   Heinrich Schuchardt   efi_loader: signa...
134
  				    efi_uintn_t exitdata_size, u16 *exitdata);
2074f7006   Heinrich Schuchardt   efi_loader: consi...
135
  	efi_status_t (EFIAPI *unload_image)(efi_handle_t image_handle);
b015ab57b   Heinrich Schuchardt   efi_loader: signa...
136
137
  	efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t image_handle,
  						  efi_uintn_t map_key);
867a6ac86   Simon Glass   efi: Add start-up...
138
139
140
  
  	efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
  	efi_status_t (EFIAPI *stall)(unsigned long usecs);
2bb9b79d6   Alexander Graf   include/efi_api.h...
141
142
143
  	efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
  			uint64_t watchdog_code, unsigned long data_size,
  			uint16_t *watchdog_data);
867a6ac86   Simon Glass   efi: Add start-up...
144
145
146
147
  	efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
  			efi_handle_t *driver_image_handle,
  			struct efi_device_path *remaining_device_path,
  			bool recursive);
3ebcd0071   Heinrich Schuchardt   efi_loader: fix s...
148
149
150
151
  	efi_status_t (EFIAPI *disconnect_controller)(
  			efi_handle_t controller_handle,
  			efi_handle_t driver_image_handle,
  			efi_handle_t child_handle);
867a6ac86   Simon Glass   efi: Add start-up...
152
153
154
155
156
157
158
  #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
  #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
  #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
  #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
  #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
  #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
  	efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
159
  			const efi_guid_t *protocol, void **interface,
867a6ac86   Simon Glass   efi: Add start-up...
160
161
  			efi_handle_t agent_handle,
  			efi_handle_t controller_handle, u32 attributes);
2074f7006   Heinrich Schuchardt   efi_loader: consi...
162
163
164
165
  	efi_status_t (EFIAPI *close_protocol)(
  			efi_handle_t handle, const efi_guid_t *protocol,
  			efi_handle_t agent_handle,
  			efi_handle_t controller_handle);
867a6ac86   Simon Glass   efi: Add start-up...
166
  	efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
167
  			const efi_guid_t *protocol,
867a6ac86   Simon Glass   efi: Add start-up...
168
  			struct efi_open_protocol_info_entry **entry_buffer,
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
169
  			efi_uintn_t *entry_count);
867a6ac86   Simon Glass   efi: Add start-up...
170
171
  	efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
  			efi_guid_t ***protocol_buffer,
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
172
  			efi_uintn_t *protocols_buffer_count);
867a6ac86   Simon Glass   efi: Add start-up...
173
174
  	efi_status_t (EFIAPI *locate_handle_buffer) (
  			enum efi_locate_search_type search_type,
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
175
  			const efi_guid_t *protocol, void *search_key,
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
176
  			efi_uintn_t *no_handles, efi_handle_t **buffer);
5a9682d0d   Heinrich Schuchardt   efi_loader: pass ...
177
  	efi_status_t (EFIAPI *locate_protocol)(const efi_guid_t *protocol,
2bb9b79d6   Alexander Graf   include/efi_api.h...
178
179
  			void *registration, void **protocol_interface);
  	efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
faea10410   Heinrich Schuchardt   efi_loader: typed...
180
  			efi_handle_t *handle, ...);
2bb9b79d6   Alexander Graf   include/efi_api.h...
181
  	efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
faea10410   Heinrich Schuchardt   efi_loader: typed...
182
  			efi_handle_t handle, ...);
8aa8360ec   Heinrich Schuchardt   efi_loader: corre...
183
184
185
  	efi_status_t (EFIAPI *calculate_crc32)(const void *data,
  					       efi_uintn_t data_size,
  					       u32 *crc32);
fc05a9590   Heinrich Schuchardt   efi_loader: param...
186
187
188
  	void (EFIAPI *copy_mem)(void *destination, const void *source,
  			size_t length);
  	void (EFIAPI *set_mem)(void *buffer, size_t size, uint8_t value);
9f0930e5d   Heinrich Schuchardt   efi_loader: creat...
189
190
191
192
193
194
195
196
  	efi_status_t (EFIAPI *create_event_ex)(
  				uint32_t type, efi_uintn_t notify_tpl,
  				void (EFIAPI *notify_function) (
  					struct efi_event *event,
  					void *context),
  				void *notify_context,
  				efi_guid_t *event_group,
  				struct efi_event **event);
867a6ac86   Simon Glass   efi: Add start-up...
197
198
199
200
201
202
  };
  
  /* Types and defines for EFI ResetSystem */
  enum efi_reset_type {
  	EFI_RESET_COLD = 0,
  	EFI_RESET_WARM = 1,
482fc90c0   Heinrich Schuchardt   efi_loader: add m...
203
204
  	EFI_RESET_SHUTDOWN = 2,
  	EFI_RESET_PLATFORM_SPECIFIC = 3,
867a6ac86   Simon Glass   efi: Add start-up...
205
206
207
  };
  
  /* EFI Runtime Services table */
bdfb894a3   Heinrich Schuchardt   efi_loader: corre...
208
  #define EFI_RUNTIME_SERVICES_SIGNATURE	0x56524553544e5552ULL
867a6ac86   Simon Glass   efi: Add start-up...
209

0c2307431   Heinrich Schuchardt   efi_loader: add m...
210
211
212
213
214
  #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET	0x00010000
  #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE	0x00020000
  #define CAPSULE_FLAGS_INITIATE_RESET		0x00040000
  
  struct efi_capsule_header {
74b448753   AKASHI Takahiro   efi_loader: corre...
215
  	efi_guid_t capsule_guid;
0c2307431   Heinrich Schuchardt   efi_loader: add m...
216
217
218
  	u32 header_size;
  	u32 flags;
  	u32 capsule_image_size;
74b448753   AKASHI Takahiro   efi_loader: corre...
219
  } __packed;
0c2307431   Heinrich Schuchardt   efi_loader: add m...
220

e771b4b39   AKASHI Takahiro   efi_loader: add R...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
  #define EFI_RT_SUPPORTED_GET_TIME			0x0001
  #define EFI_RT_SUPPORTED_SET_TIME			0x0002
  #define EFI_RT_SUPPORTED_GET_WAKEUP_TIME		0x0004
  #define EFI_RT_SUPPORTED_SET_WAKEUP_TIME		0x0008
  #define EFI_RT_SUPPORTED_GET_VARIABLE			0x0010
  #define EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME		0x0020
  #define EFI_RT_SUPPORTED_SET_VARIABLE			0x0040
  #define EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP	0x0080
  #define EFI_RT_SUPPORTED_CONVERT_POINTER		0x0100
  #define EFI_RT_SUPPORTED_GET_NEXT_HIGH_MONOTONIC_COUNT	0x0200
  #define EFI_RT_SUPPORTED_RESET_SYSTEM			0x0400
  #define EFI_RT_SUPPORTED_UPDATE_CAPSULE			0x0800
  #define EFI_RT_SUPPORTED_QUERY_CAPSULE_CAPABILITIES	0x1000
  #define EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO		0x2000
76be68728   Heinrich Schuchardt   efi_loader: imple...
235
236
237
238
239
240
241
242
243
244
245
  #define EFI_RT_PROPERTIES_TABLE_GUID \
  	EFI_GUID(0xeb66918a, 0x7eef, 0x402a, 0x84, 0x2e, \
  		 0x93, 0x1d, 0x21, 0xc3, 0x8a, 0xe9)
  
  #define EFI_RT_PROPERTIES_TABLE_VERSION	0x1
  
  struct efi_rt_properties_table {
  	u16 version;
  	u16 length;
  	u32 runtime_services_supported;
  };
867a6ac86   Simon Glass   efi: Add start-up...
246
247
  struct efi_runtime_services {
  	struct efi_table_hdr hdr;
2bb9b79d6   Alexander Graf   include/efi_api.h...
248
249
250
251
252
253
254
255
  	efi_status_t (EFIAPI *get_time)(struct efi_time *time,
  			struct efi_time_cap *capabilities);
  	efi_status_t (EFIAPI *set_time)(struct efi_time *time);
  	efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
  			struct efi_time *time);
  	efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
  			struct efi_time *time);
  	efi_status_t (EFIAPI *set_virtual_address_map)(
24e6722b8   Heinrich Schuchardt   efi_loader: defin...
256
257
  			efi_uintn_t memory_map_size,
  			efi_uintn_t descriptor_size,
2bb9b79d6   Alexander Graf   include/efi_api.h...
258
259
  			uint32_t descriptor_version,
  			struct efi_mem_desc *virtmap);
efcf0a1f5   Heinrich Schuchardt   efi_loader: corre...
260
261
  	efi_status_t (EFIAPI *convert_pointer)(
  			efi_uintn_t debug_disposition, void **address);
45c66f9cd   Heinrich Schuchardt   efi_loader: adjus...
262
  	efi_status_t (EFIAPI *get_variable)(u16 *variable_name,
0bda81bfd   Heinrich Schuchardt   efi_loader: use c...
263
264
  					    const efi_guid_t *vendor,
  					    u32 *attributes,
45c66f9cd   Heinrich Schuchardt   efi_loader: adjus...
265
266
267
  					    efi_uintn_t *data_size, void *data);
  	efi_status_t (EFIAPI *get_next_variable_name)(
  			efi_uintn_t *variable_name_size,
7a4e717b9   Heinrich Schuchardt   efi_loader: defin...
268
  			u16 *variable_name, efi_guid_t *vendor);
45c66f9cd   Heinrich Schuchardt   efi_loader: adjus...
269
  	efi_status_t (EFIAPI *set_variable)(u16 *variable_name,
0bda81bfd   Heinrich Schuchardt   efi_loader: use c...
270
271
  					    const efi_guid_t *vendor,
  					    u32 attributes,
452257a34   Heinrich Schuchardt   efi_loader: efi_s...
272
273
  					    efi_uintn_t data_size,
  					    const void *data);
2bb9b79d6   Alexander Graf   include/efi_api.h...
274
275
  	efi_status_t (EFIAPI *get_next_high_mono_count)(
  			uint32_t *high_count);
867a6ac86   Simon Glass   efi: Add start-up...
276
277
278
  	void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
  				    efi_status_t reset_status,
  				    unsigned long data_size, void *reset_data);
0c2307431   Heinrich Schuchardt   efi_loader: add m...
279
280
281
282
283
284
285
  	efi_status_t (EFIAPI *update_capsule)(
  			struct efi_capsule_header **capsule_header_array,
  			efi_uintn_t capsule_count,
  			u64 scatter_gather_list);
  	efi_status_t (EFIAPI *query_capsule_caps)(
  			struct efi_capsule_header **capsule_header_array,
  			efi_uintn_t capsule_count,
19dd90748   AKASHI Takahiro   efi_loader: corre...
286
287
  			u64 *maximum_capsule_size,
  			u32 *reset_type);
0c2307431   Heinrich Schuchardt   efi_loader: add m...
288
289
  	efi_status_t (EFIAPI *query_variable_info)(
  			u32 attributes,
45c66f9cd   Heinrich Schuchardt   efi_loader: adjus...
290
291
292
  			u64 *maximum_variable_storage_size,
  			u64 *remaining_variable_storage_size,
  			u64 *maximum_variable_size);
867a6ac86   Simon Glass   efi: Add start-up...
293
  };
a3a28f5f0   Heinrich Schuchardt   efi_loader: defin...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
  /* EFI event group GUID definitions */
  #define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \
  	EFI_GUID(0x27abf055, 0xb1b8, 0x4c26, 0x80, 0x48, \
  		 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf)
  
  #define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
  	EFI_GUID(0x13fa7698, 0xc831, 0x49c7, 0x87, 0xea, \
  		 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96)
  
  #define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \
  	EFI_GUID(0x78bee926, 0x692f, 0x48fd, 0x9e, 0xdb, \
  		 0x01, 0x42, 0x2e, 0xf0, 0xd7, 0xab)
  
  #define EFI_EVENT_GROUP_READY_TO_BOOT \
  	EFI_GUID(0x7ce88fb3, 0x4bd7, 0x4679, 0x87, 0xa8, \
  		 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b)
  
  #define EFI_EVENT_GROUP_RESET_SYSTEM \
  	EFI_GUID(0x62da6a56, 0x13fb, 0x485a, 0xa8, 0xda, \
  		 0xa3, 0xdd, 0x79, 0x12, 0xcb, 0x6b)
867a6ac86   Simon Glass   efi: Add start-up...
314
315
316
317
  /* EFI Configuration Table and GUID definitions */
  #define NULL_GUID \
  	EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
  		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
9975fe96b   Rob Clark   efi_loader: add b...
318
319
320
  #define EFI_GLOBAL_VARIABLE_GUID \
  	EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \
  		 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
2bb9b79d6   Alexander Graf   include/efi_api.h...
321
322
323
  #define EFI_FDT_GUID \
  	EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
  		 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
86df34d42   Bin Meng   efi_loader: Insta...
324
325
326
  #define EFI_ACPI_TABLE_GUID \
  	EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \
  		 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
e663b350f   Alexander Graf   smbios: Expose in...
327
328
329
  #define SMBIOS_TABLE_GUID \
  	EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3,  \
  		 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
ec80b4735   Ilias Apalodimas   efi_loader: Imple...
330
331
332
333
334
335
336
  #define EFI_LOAD_FILE_PROTOCOL_GUID \
  	EFI_GUID(0x56ec3091, 0x954c, 0x11d2, \
  		 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  
  #define EFI_LOAD_FILE2_PROTOCOL_GUID \
  	EFI_GUID(0x4006c0c1, 0xfcb3, 0x403e, \
  		 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d)
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
337
  struct efi_configuration_table {
2bb9b79d6   Alexander Graf   include/efi_api.h...
338
339
  	efi_guid_t guid;
  	void *table;
2859f446b   Heinrich Schuchardt   efi_loader: struc...
340
  } __packed;
2bb9b79d6   Alexander Graf   include/efi_api.h...
341
342
  
  #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
867a6ac86   Simon Glass   efi: Add start-up...
343
344
  struct efi_system_table {
  	struct efi_table_hdr hdr;
0b386537a   Heinrich Schuchardt   efi_loader: provi...
345
  	u16 *fw_vendor;   /* physical addr of wchar_t vendor string */
867a6ac86   Simon Glass   efi: Add start-up...
346
  	u32 fw_revision;
cc20ed03f   Heinrich Schuchardt   efi_loader: fix E...
347
  	efi_handle_t con_in_handle;
3e603ec75   Heinrich Schuchardt   efi_loader: struc...
348
  	struct efi_simple_text_input_protocol *con_in;
cc20ed03f   Heinrich Schuchardt   efi_loader: fix E...
349
  	efi_handle_t con_out_handle;
867a6ac86   Simon Glass   efi: Add start-up...
350
  	struct efi_simple_text_output_protocol *con_out;
cc20ed03f   Heinrich Schuchardt   efi_loader: fix E...
351
  	efi_handle_t stderr_handle;
2bb9b79d6   Alexander Graf   include/efi_api.h...
352
  	struct efi_simple_text_output_protocol *std_err;
867a6ac86   Simon Glass   efi: Add start-up...
353
354
  	struct efi_runtime_services *runtime;
  	struct efi_boot_services *boottime;
f5a2a9389   Heinrich Schuchardt   efi_loader: consi...
355
  	efi_uintn_t nr_tables;
2bb9b79d6   Alexander Graf   include/efi_api.h...
356
  	struct efi_configuration_table *tables;
867a6ac86   Simon Glass   efi: Add start-up...
357
  };
dec88e41e   Heinrich Schuchardt   efi_loader: consi...
358
  #define EFI_LOADED_IMAGE_PROTOCOL_GUID \
2bb9b79d6   Alexander Graf   include/efi_api.h...
359
360
  	EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
  		 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
dec88e41e   Heinrich Schuchardt   efi_loader: consi...
361
  #define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
bc8fc3285   AKASHI Takahiro   efi_loader: boott...
362
363
  	EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \
  		 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf)
95147313a   Heinrich Schuchardt   efi_loader: set r...
364
  #define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
867a6ac86   Simon Glass   efi: Add start-up...
365
366
367
368
  struct efi_loaded_image {
  	u32 revision;
  	void *parent_handle;
  	struct efi_system_table *system_table;
43dace5d8   Heinrich Schuchardt   efi_loader: corre...
369
370
  	efi_handle_t device_handle;
  	struct efi_device_path *file_path;
867a6ac86   Simon Glass   efi: Add start-up...
371
372
373
374
375
376
377
  	void *reserved;
  	u32 load_options_size;
  	void *load_options;
  	void *image_base;
  	aligned_u64 image_size;
  	unsigned int image_code_type;
  	unsigned int image_data_type;
df116e81e   Heinrich Schuchardt   efi_loader: imple...
378
  	efi_status_t (EFIAPI *unload)(efi_handle_t image_handle);
867a6ac86   Simon Glass   efi: Add start-up...
379
  };
dec88e41e   Heinrich Schuchardt   efi_loader: consi...
380
  #define EFI_DEVICE_PATH_PROTOCOL_GUID \
2bb9b79d6   Alexander Graf   include/efi_api.h...
381
  	EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
382
  		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
2bb9b79d6   Alexander Graf   include/efi_api.h...
383
384
  
  #define DEVICE_PATH_TYPE_END			0x7f
3acef5da4   Heinrich Schuchardt   efi_loader: compl...
385
  #  define DEVICE_PATH_SUB_TYPE_INSTANCE_END	0x01
2bb9b79d6   Alexander Graf   include/efi_api.h...
386
  #  define DEVICE_PATH_SUB_TYPE_END		0xff
867a6ac86   Simon Glass   efi: Add start-up...
387
388
389
390
  struct efi_device_path {
  	u8 type;
  	u8 sub_type;
  	u16 length;
a8606ef07   Rob Clark   efi: add some mis...
391
  } __packed;
867a6ac86   Simon Glass   efi: Add start-up...
392

d7608aba3   Oleksandr Tymoshenko   efi: Use device d...
393
394
  struct efi_mac_addr {
  	u8 addr[32];
a8606ef07   Rob Clark   efi: add some mis...
395
  } __packed;
d7608aba3   Oleksandr Tymoshenko   efi: Use device d...
396

c80214ce1   Peter Jones   efi: add some mor...
397
  #define DEVICE_PATH_TYPE_HARDWARE_DEVICE	0x01
bf19273e8   Rob Clark   efi_loader: Add m...
398
  #  define DEVICE_PATH_SUB_TYPE_MEMORY		0x03
c80214ce1   Peter Jones   efi: add some mor...
399
  #  define DEVICE_PATH_SUB_TYPE_VENDOR		0x04
bf19273e8   Rob Clark   efi_loader: Add m...
400
401
402
403
404
405
  struct efi_device_path_memory {
  	struct efi_device_path dp;
  	u32 memory_type;
  	u64 start_address;
  	u64 end_address;
  } __packed;
c80214ce1   Peter Jones   efi: add some mor...
406
407
408
409
410
411
412
413
414
415
416
  struct efi_device_path_vendor {
  	struct efi_device_path dp;
  	efi_guid_t guid;
  	u8 vendor_data[];
  } __packed;
  
  #define DEVICE_PATH_TYPE_ACPI_DEVICE		0x02
  #  define DEVICE_PATH_SUB_TYPE_ACPI_DEVICE	0x01
  
  #define EFI_PNP_ID(ID)				(u32)(((ID) << 16) | 0x41D0)
  #define EISA_PNP_ID(ID)				EFI_PNP_ID(ID)
adae4313c   Rob Clark   efi_loader: flesh...
417
  #define EISA_PNP_NUM(ID)			((ID) >> 16)
c80214ce1   Peter Jones   efi: add some mor...
418
419
420
421
422
423
  
  struct efi_device_path_acpi_path {
  	struct efi_device_path dp;
  	u32 hid;
  	u32 uid;
  } __packed;
d7608aba3   Oleksandr Tymoshenko   efi: Use device d...
424
  #define DEVICE_PATH_TYPE_MESSAGING_DEVICE	0x03
af3106a12   Heinrich Schuchardt   efi_loader: suppo...
425
426
  #  define DEVICE_PATH_SUB_TYPE_MSG_ATAPI	0x01
  #  define DEVICE_PATH_SUB_TYPE_MSG_SCSI		0x02
c80214ce1   Peter Jones   efi: add some mor...
427
  #  define DEVICE_PATH_SUB_TYPE_MSG_USB		0x05
d7608aba3   Oleksandr Tymoshenko   efi: Use device d...
428
  #  define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR	0x0b
b66c60dde   Rob Clark   efi_loader: add d...
429
  #  define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS	0x0f
f2d247df5   Patrick Wildt   efi: device path ...
430
  #  define DEVICE_PATH_SUB_TYPE_MSG_NVME		0x17
c80214ce1   Peter Jones   efi: add some mor...
431
432
  #  define DEVICE_PATH_SUB_TYPE_MSG_SD		0x1a
  #  define DEVICE_PATH_SUB_TYPE_MSG_MMC		0x1d
af3106a12   Heinrich Schuchardt   efi_loader: suppo...
433
434
435
436
437
438
439
440
441
442
443
444
  struct efi_device_path_atapi {
  	struct efi_device_path dp;
  	u8 primary_secondary;
  	u8 slave_master;
  	u16 logical_unit_number;
  } __packed;
  
  struct efi_device_path_scsi {
  	struct efi_device_path dp;
  	u16 target_id;
  	u16 logical_unit_number;
  } __packed;
c80214ce1   Peter Jones   efi: add some mor...
445
446
447
448
449
  struct efi_device_path_usb {
  	struct efi_device_path dp;
  	u8 parent_port_number;
  	u8 usb_interface;
  } __packed;
d7608aba3   Oleksandr Tymoshenko   efi: Use device d...
450
451
452
453
454
  
  struct efi_device_path_mac_addr {
  	struct efi_device_path dp;
  	struct efi_mac_addr mac;
  	u8 if_type;
a8606ef07   Rob Clark   efi: add some mis...
455
  } __packed;
d7608aba3   Oleksandr Tymoshenko   efi: Use device d...
456

b66c60dde   Rob Clark   efi_loader: add d...
457
458
459
460
461
462
463
464
  struct efi_device_path_usb_class {
  	struct efi_device_path dp;
  	u16 vendor_id;
  	u16 product_id;
  	u8 device_class;
  	u8 device_subclass;
  	u8 device_protocol;
  } __packed;
c80214ce1   Peter Jones   efi: add some mor...
465
466
467
468
  struct efi_device_path_sd_mmc_path {
  	struct efi_device_path dp;
  	u8 slot_number;
  } __packed;
f2d247df5   Patrick Wildt   efi: device path ...
469
470
471
472
473
  struct efi_device_path_nvme {
  	struct efi_device_path dp;
  	u32 ns_id;
  	u8 eui64[8];
  } __packed;
2bb9b79d6   Alexander Graf   include/efi_api.h...
474
  #define DEVICE_PATH_TYPE_MEDIA_DEVICE		0x04
c80214ce1   Peter Jones   efi: add some mor...
475
476
  #  define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH	0x01
  #  define DEVICE_PATH_SUB_TYPE_CDROM_PATH	0x02
ec80b4735   Ilias Apalodimas   efi_loader: Imple...
477
  #  define DEVICE_PATH_SUB_TYPE_VENDOR_PATH	0x03
2bb9b79d6   Alexander Graf   include/efi_api.h...
478
  #  define DEVICE_PATH_SUB_TYPE_FILE_PATH	0x04
c80214ce1   Peter Jones   efi: add some mor...
479
480
481
482
483
484
485
486
487
488
489
490
491
492
  struct efi_device_path_hard_drive_path {
  	struct efi_device_path dp;
  	u32 partition_number;
  	u64 partition_start;
  	u64 partition_end;
  	u8 partition_signature[16];
  	u8 partmap_type;
  	u8 signature_type;
  } __packed;
  
  struct efi_device_path_cdrom_path {
  	struct efi_device_path dp;
  	u32 boot_entry;
  	u64 partition_start;
d0384d516   Heinrich Schuchardt   efi_loader: corre...
493
  	u64 partition_size;
c80214ce1   Peter Jones   efi: add some mor...
494
  } __packed;
2bb9b79d6   Alexander Graf   include/efi_api.h...
495
496
  struct efi_device_path_file_path {
  	struct efi_device_path dp;
61b7e2247   Rob Clark   efi_loader: file_...
497
  	u16 str[];
a8606ef07   Rob Clark   efi: add some mis...
498
  } __packed;
2bb9b79d6   Alexander Graf   include/efi_api.h...
499

dec88e41e   Heinrich Schuchardt   efi_loader: consi...
500
  #define EFI_BLOCK_IO_PROTOCOL_GUID \
2bb9b79d6   Alexander Graf   include/efi_api.h...
501
502
  	EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
  		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
503
  struct efi_block_io_media {
2bb9b79d6   Alexander Graf   include/efi_api.h...
504
505
506
507
508
509
510
511
512
513
514
  	u32 media_id;
  	char removable_media;
  	char media_present;
  	char logical_partition;
  	char read_only;
  	char write_caching;
  	u8 pad[3];
  	u32 block_size;
  	u32 io_align;
  	u8 pad2[4];
  	u64 last_block;
4f94865b3   Heinrich Schuchardt   efi_loader: corre...
515
516
517
518
519
  	/* Added in revision 2 of the protocol */
  	u64 lowest_aligned_lba;
  	u32 logical_blocks_per_physical_block;
  	/* Added in revision 3 of the protocol */
  	u32 optimal_transfer_length_granualarity;
2bb9b79d6   Alexander Graf   include/efi_api.h...
520
  };
4f94865b3   Heinrich Schuchardt   efi_loader: corre...
521
522
  #define EFI_BLOCK_IO_PROTOCOL_REVISION2	0x00020001
  #define EFI_BLOCK_IO_PROTOCOL_REVISION3	0x0002001f
2bb9b79d6   Alexander Graf   include/efi_api.h...
523
524
525
526
527
528
  struct efi_block_io {
  	u64 revision;
  	struct efi_block_io_media *media;
  	efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
  			char extended_verification);
  	efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
4f94865b3   Heinrich Schuchardt   efi_loader: corre...
529
  			u32 media_id, u64 lba, efi_uintn_t buffer_size,
2bb9b79d6   Alexander Graf   include/efi_api.h...
530
531
  			void *buffer);
  	efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
4f94865b3   Heinrich Schuchardt   efi_loader: corre...
532
  			u32 media_id, u64 lba, efi_uintn_t buffer_size,
2bb9b79d6   Alexander Graf   include/efi_api.h...
533
534
535
  			void *buffer);
  	efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
  };
867a6ac86   Simon Glass   efi: Add start-up...
536
537
538
539
540
541
542
543
  struct simple_text_output_mode {
  	s32 max_mode;
  	s32 mode;
  	s32 attribute;
  	s32 cursor_column;
  	s32 cursor_row;
  	bool cursor_visible;
  };
a17e62cc5   Rob Clark   efi_loader: expos...
544
545
546
  #define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \
  	EFI_GUID(0x387477c2, 0x69c7, 0x11d2, \
  		 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
2d5dc2a52   Rob Clark   efi_loader: conso...
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
  #define EFI_BLACK                0x00
  #define EFI_BLUE                 0x01
  #define EFI_GREEN                0x02
  #define EFI_CYAN                 0x03
  #define EFI_RED                  0x04
  #define EFI_MAGENTA              0x05
  #define EFI_BROWN                0x06
  #define EFI_LIGHTGRAY            0x07
  #define EFI_BRIGHT               0x08
  #define EFI_DARKGRAY             0x08
  #define EFI_LIGHTBLUE            0x09
  #define EFI_LIGHTGREEN           0x0a
  #define EFI_LIGHTCYAN            0x0b
  #define EFI_LIGHTRED             0x0c
  #define EFI_LIGHTMAGENTA         0x0d
  #define EFI_YELLOW               0x0e
  #define EFI_WHITE                0x0f
  #define EFI_BACKGROUND_BLACK     0x00
  #define EFI_BACKGROUND_BLUE      0x10
  #define EFI_BACKGROUND_GREEN     0x20
  #define EFI_BACKGROUND_CYAN      0x30
  #define EFI_BACKGROUND_RED       0x40
  #define EFI_BACKGROUND_MAGENTA   0x50
  #define EFI_BACKGROUND_BROWN     0x60
  #define EFI_BACKGROUND_LIGHTGRAY 0x70
  
  /* extract foreground color from EFI attribute */
  #define EFI_ATTR_FG(attr)        ((attr) & 0x07)
  /* treat high bit of FG as bright/bold (similar to edk2) */
  #define EFI_ATTR_BOLD(attr)      (((attr) >> 3) & 0x01)
  /* extract background color from EFI attribute */
  #define EFI_ATTR_BG(attr)        (((attr) >> 4) & 0x7)
867a6ac86   Simon Glass   efi: Add start-up...
579
  struct efi_simple_text_output_protocol {
21b6b540d   Heinrich Schuchardt   efi_loader: EFI_S...
580
581
582
  	efi_status_t (EFIAPI *reset)(
  			struct efi_simple_text_output_protocol *this,
  			char extended_verification);
867a6ac86   Simon Glass   efi: Add start-up...
583
584
  	efi_status_t (EFIAPI *output_string)(
  			struct efi_simple_text_output_protocol *this,
3a45bc7fa   Rob Clark   efi_loader: Some ...
585
  			const efi_string_t str);
2bb9b79d6   Alexander Graf   include/efi_api.h...
586
587
  	efi_status_t (EFIAPI *test_string)(
  			struct efi_simple_text_output_protocol *this,
3a45bc7fa   Rob Clark   efi_loader: Some ...
588
  			const efi_string_t str);
867a6ac86   Simon Glass   efi: Add start-up...
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
  	efi_status_t(EFIAPI *query_mode)(
  			struct efi_simple_text_output_protocol *this,
  			unsigned long mode_number, unsigned long *columns,
  			unsigned long *rows);
  	efi_status_t(EFIAPI *set_mode)(
  			struct efi_simple_text_output_protocol *this,
  			unsigned long mode_number);
  	efi_status_t(EFIAPI *set_attribute)(
  			struct efi_simple_text_output_protocol *this,
  			unsigned long attribute);
  	efi_status_t(EFIAPI *clear_screen) (
  			struct efi_simple_text_output_protocol *this);
  	efi_status_t(EFIAPI *set_cursor_position) (
  			struct efi_simple_text_output_protocol *this,
  			unsigned long column, unsigned long row);
2bb9b79d6   Alexander Graf   include/efi_api.h...
604
605
606
  	efi_status_t(EFIAPI *enable_cursor)(
  			struct efi_simple_text_output_protocol *this,
  			bool enable);
867a6ac86   Simon Glass   efi: Add start-up...
607
608
  	struct simple_text_output_mode *mode;
  };
110c62805   Heinrich Schuchardt   efi_loader: EFI_S...
609
610
611
  #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
  	EFI_GUID(0xdd9e7534, 0x7762, 0x4698, \
  		 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa)
867a6ac86   Simon Glass   efi: Add start-up...
612
613
614
615
  struct efi_input_key {
  	u16 scan_code;
  	s16 unicode_char;
  };
110c62805   Heinrich Schuchardt   efi_loader: EFI_S...
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
  #define EFI_SHIFT_STATE_INVALID		0x00000000
  #define EFI_RIGHT_SHIFT_PRESSED		0x00000001
  #define EFI_LEFT_SHIFT_PRESSED		0x00000002
  #define EFI_RIGHT_CONTROL_PRESSED	0x00000004
  #define EFI_LEFT_CONTROL_PRESSED	0x00000008
  #define EFI_RIGHT_ALT_PRESSED		0x00000010
  #define EFI_LEFT_ALT_PRESSED		0x00000020
  #define EFI_RIGHT_LOGO_PRESSED		0x00000040
  #define EFI_LEFT_LOGO_PRESSED		0x00000080
  #define EFI_MENU_KEY_PRESSED		0x00000100
  #define EFI_SYS_REQ_PRESSED		0x00000200
  #define EFI_SHIFT_STATE_VALID		0x80000000
  
  #define EFI_TOGGLE_STATE_INVALID	0x00
  #define EFI_SCROLL_LOCK_ACTIVE		0x01
  #define EFI_NUM_LOCK_ACTIVE		0x02
  #define EFI_CAPS_LOCK_ACTIVE		0x04
  #define EFI_KEY_STATE_EXPOSED		0x40
  #define EFI_TOGGLE_STATE_VALID		0x80
  
  struct efi_key_state {
  	u32 key_shift_state;
  	u8 key_toggle_state;
  };
  
  struct efi_key_data {
  	struct efi_input_key key;
  	struct efi_key_state key_state;
  };
  
  struct efi_simple_text_input_ex_protocol {
  	efi_status_t (EFIAPI *reset) (
  		struct efi_simple_text_input_ex_protocol *this,
  		bool extended_verification);
  	efi_status_t (EFIAPI *read_key_stroke_ex) (
  		struct efi_simple_text_input_ex_protocol *this,
  		struct efi_key_data *key_data);
  	struct efi_event *wait_for_key_ex;
  	efi_status_t (EFIAPI *set_state) (
  		struct efi_simple_text_input_ex_protocol *this,
acee96526   Heinrich Schuchardt   efi_loader: EFI_S...
656
  		u8 *key_toggle_state);
110c62805   Heinrich Schuchardt   efi_loader: EFI_S...
657
658
659
660
661
662
663
664
665
666
  	efi_status_t (EFIAPI *register_key_notify) (
  		struct efi_simple_text_input_ex_protocol *this,
  		struct efi_key_data *key_data,
  		efi_status_t (EFIAPI *key_notify_function)(
  			struct efi_key_data *key_data),
  		void **notify_handle);
  	efi_status_t (EFIAPI *unregister_key_notify) (
  		struct efi_simple_text_input_ex_protocol *this,
  		void *notification_handle);
  };
a17e62cc5   Rob Clark   efi_loader: expos...
667
668
669
  #define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \
  	EFI_GUID(0x387477c1, 0x69c7, 0x11d2, \
  		 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
3e603ec75   Heinrich Schuchardt   efi_loader: struc...
670
671
672
  struct efi_simple_text_input_protocol {
  	efi_status_t(EFIAPI *reset)(struct efi_simple_text_input_protocol *this,
  				    bool extended_verification);
867a6ac86   Simon Glass   efi: Add start-up...
673
  	efi_status_t(EFIAPI *read_key_stroke)(
3e603ec75   Heinrich Schuchardt   efi_loader: struc...
674
  			struct efi_simple_text_input_protocol *this,
867a6ac86   Simon Glass   efi: Add start-up...
675
  			struct efi_input_key *key);
2fd945fe7   xypron.glpk@gmx.de   efi_loader: use s...
676
  	struct efi_event *wait_for_key;
867a6ac86   Simon Glass   efi: Add start-up...
677
  };
cc5b70812   xypron.glpk@gmx.de   efi_loader: imple...
678
679
680
  #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
  	EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
  		 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
681
  struct efi_device_path_to_text_protocol {
cc5b70812   xypron.glpk@gmx.de   efi_loader: imple...
682
  	uint16_t *(EFIAPI *convert_device_node_to_text)(
9309a1b76   Rob Clark   efi_loader: drop ...
683
  			struct efi_device_path *device_node,
cc5b70812   xypron.glpk@gmx.de   efi_loader: imple...
684
685
686
  			bool display_only,
  			bool allow_shortcuts);
  	uint16_t *(EFIAPI *convert_device_path_to_text)(
9309a1b76   Rob Clark   efi_loader: drop ...
687
  			struct efi_device_path *device_path,
cc5b70812   xypron.glpk@gmx.de   efi_loader: imple...
688
689
690
  			bool display_only,
  			bool allow_shortcuts);
  };
e70f8dfa2   Leif Lindholm   efi_loader: Initi...
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
  #define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
  	EFI_GUID(0x0379be4e, 0xd706, 0x437d, \
  		 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4)
  
  struct efi_device_path_utilities_protocol {
  	efi_uintn_t (EFIAPI *get_device_path_size)(
  		const struct efi_device_path *device_path);
  	struct efi_device_path *(EFIAPI *duplicate_device_path)(
  		const struct efi_device_path *device_path);
  	struct efi_device_path *(EFIAPI *append_device_path)(
  		const struct efi_device_path *src1,
  		const struct efi_device_path *src2);
  	struct efi_device_path *(EFIAPI *append_device_node)(
  		const struct efi_device_path *device_path,
  		const struct efi_device_path *device_node);
  	struct efi_device_path *(EFIAPI *append_device_path_instance)(
  		const struct efi_device_path *device_path,
  		const struct efi_device_path *device_path_instance);
  	struct efi_device_path *(EFIAPI *get_next_device_path_instance)(
  		struct efi_device_path **device_path_instance,
  		efi_uintn_t *device_path_instance_size);
  	bool (EFIAPI *is_device_path_multi_instance)(
  		const struct efi_device_path *device_path);
  	struct efi_device_path *(EFIAPI *create_device_node)(
  		uint8_t node_type,
  		uint8_t node_sub_type,
  		uint16_t node_length);
  };
c9bfb2229   Leif Lindholm   efi_loader: Initi...
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
  /*
   * Human Interface Infrastructure (HII)
   */
  struct efi_hii_package_list_header {
  	efi_guid_t package_list_guid;
  	u32 package_length;
  } __packed;
  
  /**
   * struct efi_hii_package_header - EFI HII package header
   *
   * @fields:	'fields' replaces the bit-fields defined in the EFI
   *		specification to to avoid possible compiler incompatibilities::
   *
   *		u32 length:24;
   *		u32 type:8;
   */
  struct efi_hii_package_header {
  	u32 fields;
  } __packed;
  
  #define __EFI_HII_PACKAGE_LEN_SHIFT	0
  #define __EFI_HII_PACKAGE_TYPE_SHIFT	24
  #define __EFI_HII_PACKAGE_LEN_MASK	0xffffff
  #define __EFI_HII_PACKAGE_TYPE_MASK	0xff
  
  #define EFI_HII_PACKAGE_TYPE_ALL          0x00
  #define EFI_HII_PACKAGE_TYPE_GUID         0x01
  #define EFI_HII_PACKAGE_FORMS             0x02
  #define EFI_HII_PACKAGE_STRINGS           0x04
  #define EFI_HII_PACKAGE_FONTS             0x05
  #define EFI_HII_PACKAGE_IMAGES            0x06
  #define EFI_HII_PACKAGE_SIMPLE_FONTS      0x07
  #define EFI_HII_PACKAGE_DEVICE_PATH       0x08
  #define EFI_HII_PACKAGE_KEYBOARD_LAYOUT   0x09
  #define EFI_HII_PACKAGE_ANIMATIONS        0x0A
  #define EFI_HII_PACKAGE_END               0xDF
  #define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
  #define EFI_HII_PACKAGE_TYPE_SYSTEM_END   0xFF
  
  /*
9ab0bdd9f   AKASHI Takahiro   efi: hii: add gui...
760
761
762
763
764
765
766
767
768
   * HII GUID package
   */
  struct efi_hii_guid_package {
  	struct efi_hii_package_header header;
  	efi_guid_t guid;
  	char data[];
  } __packed;
  
  /*
c9bfb2229   Leif Lindholm   efi_loader: Initi...
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
   * HII string package
   */
  struct efi_hii_strings_package {
  	struct efi_hii_package_header header;
  	u32 header_size;
  	u32 string_info_offset;
  	u16 language_window[16];
  	efi_string_id_t language_name;
  	u8  language[];
  } __packed;
  
  struct efi_hii_string_block {
  	u8 block_type;
  	/* u8 block_body[]; */
  } __packed;
  
  #define EFI_HII_SIBT_END               0x00
  #define EFI_HII_SIBT_STRING_SCSU       0x10
  #define EFI_HII_SIBT_STRING_SCSU_FONT  0x11
  #define EFI_HII_SIBT_STRINGS_SCSU      0x12
  #define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13
  #define EFI_HII_SIBT_STRING_UCS2       0x14
  #define EFI_HII_SIBT_STRING_UCS2_FONT  0x15
  #define EFI_HII_SIBT_STRINGS_UCS2      0x16
  #define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17
  #define EFI_HII_SIBT_DUPLICATE         0x20
  #define EFI_HII_SIBT_SKIP2             0x21
  #define EFI_HII_SIBT_SKIP1             0x22
  #define EFI_HII_SIBT_EXT1              0x30
  #define EFI_HII_SIBT_EXT2              0x31
  #define EFI_HII_SIBT_EXT4              0x32
  #define EFI_HII_SIBT_FONT              0x40
  
  struct efi_hii_sibt_string_ucs2_block {
  	struct efi_hii_string_block header;
  	u16 string_text[];
  } __packed;
  
  static inline struct efi_hii_string_block *
  efi_hii_sibt_string_ucs2_block_next(struct efi_hii_sibt_string_ucs2_block *blk)
  {
  	return ((void *)blk) + sizeof(*blk) +
  		(u16_strlen(blk->string_text) + 1) * 2;
  }
  
  /*
cb728e51a   AKASHI Takahiro   efi: hii: add HII...
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
   * HII forms package
   * TODO: full scope of definitions
   */
  struct efi_hii_time {
  	u8 hour;
  	u8 minute;
  	u8 second;
  };
  
  struct efi_hii_date {
  	u16 year;
  	u8 month;
  	u8 day;
  };
  
  struct efi_hii_ref {
  	efi_question_id_t question_id;
  	efi_form_id_t form_id;
  	efi_guid_t form_set_guid;
  	efi_string_id_t device_path;
  };
  
  union efi_ifr_type_value {
  	u8 u8;				// EFI_IFR_TYPE_NUM_SIZE_8
  	u16 u16;			// EFI_IFR_TYPE_NUM_SIZE_16
  	u32 u32;			// EFI_IFR_TYPE_NUM_SIZE_32
  	u64 u64;			// EFI_IFR_TYPE_NUM_SIZE_64
  	bool b;				// EFI_IFR_TYPE_BOOLEAN
  	struct efi_hii_time time;	// EFI_IFR_TYPE_TIME
  	struct efi_hii_date date;	// EFI_IFR_TYPE_DATE
  	efi_string_id_t string;	// EFI_IFR_TYPE_STRING, EFI_IFR_TYPE_ACTION
  	struct efi_hii_ref ref;		// EFI_IFR_TYPE_REF
  	// u8 buffer[];			// EFI_IFR_TYPE_BUFFER
  };
  
  #define EFI_IFR_TYPE_NUM_SIZE_8		0x00
  #define EFI_IFR_TYPE_NUM_SIZE_16	0x01
  #define EFI_IFR_TYPE_NUM_SIZE_32	0x02
  #define EFI_IFR_TYPE_NUM_SIZE_64	0x03
  #define EFI_IFR_TYPE_BOOLEAN		0x04
  #define EFI_IFR_TYPE_TIME		0x05
  #define EFI_IFR_TYPE_DATE		0x06
  #define EFI_IFR_TYPE_STRING		0x07
  #define EFI_IFR_TYPE_OTHER		0x08
  #define EFI_IFR_TYPE_UNDEFINED		0x09
  #define EFI_IFR_TYPE_ACTION		0x0A
  #define EFI_IFR_TYPE_BUFFER		0x0B
  #define EFI_IFR_TYPE_REF		0x0C
  #define EFI_IFR_OPTION_DEFAULT		0x10
  #define EFI_IFR_OPTION_DEFAULT_MFG	0x20
  
  #define EFI_IFR_ONE_OF_OPTION_OP	0x09
  
  struct efi_ifr_op_header {
  	u8 opCode;
  	u8 length:7;
  	u8 scope:1;
  };
  
  struct efi_ifr_one_of_option {
  	struct efi_ifr_op_header header;
  	efi_string_id_t option;
  	u8 flags;
  	u8 type;
  	union efi_ifr_type_value value;
  };
  
  typedef efi_uintn_t efi_browser_action_t;
  
  #define EFI_BROWSER_ACTION_REQUEST_NONE			0
  #define EFI_BROWSER_ACTION_REQUEST_RESET		1
  #define EFI_BROWSER_ACTION_REQUEST_SUBMIT		2
  #define EFI_BROWSER_ACTION_REQUEST_EXIT			3
  #define EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT	4
  #define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT	5
  #define EFI_BROWSER_ACTION_REQUEST_FORM_APPLY		6
  #define EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD		7
  #define EFI_BROWSER_ACTION_REQUEST_RECONNECT		8
  
  typedef efi_uintn_t efi_browser_action_request_t;
  
  #define EFI_BROWSER_ACTION_CHANGING			0
  #define EFI_BROWSER_ACTION_CHANGED			1
  #define EFI_BROWSER_ACTION_RETRIEVE			2
  #define EFI_BROWSER_ACTION_FORM_OPEN			3
  #define EFI_BROWSER_ACTION_FORM_CLOSE			4
  #define EFI_BROWSER_ACTION_SUBMITTED			5
  #define EFI_BROWSER_ACTION_DEFAULT_STANDARD		0x1000
  #define EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING	0x1001
  #define EFI_BROWSER_ACTION_DEFAULT_SAFE			0x1002
  #define EFI_BROWSER_ACTION_DEFAULT_PLATFORM		0x2000
  #define EFI_BROWSER_ACTION_DEFAULT_HARDWARE		0x3000
  #define EFI_BROWSER_ACTION_DEFAULT_FIRMWARE		0x4000
  
  /*
c9bfb2229   Leif Lindholm   efi_loader: Initi...
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
   * HII keyboard package
   */
  typedef enum {
  	EFI_KEY_LCTRL, EFI_KEY_A0, EFI_KEY_LALT, EFI_KEY_SPACE_BAR,
  	EFI_KEY_A2, EFI_KEY_A3, EFI_KEY_A4, EFI_KEY_RCTRL, EFI_KEY_LEFT_ARROW,
  	EFI_KEY_DOWN_ARROW, EFI_KEY_RIGHT_ARROW, EFI_KEY_ZERO,
  	EFI_KEY_PERIOD, EFI_KEY_ENTER, EFI_KEY_LSHIFT, EFI_KEY_B0,
  	EFI_KEY_B1, EFI_KEY_B2, EFI_KEY_B3, EFI_KEY_B4, EFI_KEY_B5, EFI_KEY_B6,
  	EFI_KEY_B7, EFI_KEY_B8, EFI_KEY_B9, EFI_KEY_B10, EFI_KEY_RSHIFT,
  	EFI_KEY_UP_ARROW, EFI_KEY_ONE, EFI_KEY_TWO, EFI_KEY_THREE,
  	EFI_KEY_CAPS_LOCK, EFI_KEY_C1, EFI_KEY_C2, EFI_KEY_C3, EFI_KEY_C4,
  	EFI_KEY_C5, EFI_KEY_C6, EFI_KEY_C7, EFI_KEY_C8, EFI_KEY_C9,
  	EFI_KEY_C10, EFI_KEY_C11, EFI_KEY_C12, EFI_KEY_FOUR, EFI_KEY_FIVE,
  	EFI_KEY_SIX, EFI_KEY_PLUS, EFI_KEY_TAB, EFI_KEY_D1, EFI_KEY_D2,
  	EFI_KEY_D3, EFI_KEY_D4, EFI_KEY_D5, EFI_KEY_D6, EFI_KEY_D7, EFI_KEY_D8,
  	EFI_KEY_D9, EFI_KEY_D10, EFI_KEY_D11, EFI_KEY_D12, EFI_KEY_D13,
  	EFI_KEY_DEL, EFI_KEY_END, EFI_KEY_PG_DN, EFI_KEY_SEVEN, EFI_KEY_EIGHT,
  	EFI_KEY_NINE, EFI_KEY_E0, EFI_KEY_E1, EFI_KEY_E2, EFI_KEY_E3,
  	EFI_KEY_E4, EFI_KEY_E5, EFI_KEY_E6, EFI_KEY_E7, EFI_KEY_E8, EFI_KEY_E9,
  	EFI_KEY_E10, EFI_KEY_E11, EFI_KEY_E12, EFI_KEY_BACK_SPACE,
  	EFI_KEY_INS, EFI_KEY_HOME, EFI_KEY_PG_UP, EFI_KEY_NLCK, EFI_KEY_SLASH,
  	EFI_KEY_ASTERISK, EFI_KEY_MINUS, EFI_KEY_ESC, EFI_KEY_F1, EFI_KEY_F2,
  	EFI_KEY_F3, EFI_KEY_F4, EFI_KEY_F5, EFI_KEY_F6, EFI_KEY_F7, EFI_KEY_F8,
  	EFI_KEY_F9, EFI_KEY_F10, EFI_KEY_F11, EFI_KEY_F12, EFI_KEY_PRINT,
  	EFI_KEY_SLCK, EFI_KEY_PAUSE,
  } efi_key;
  
  struct efi_key_descriptor {
  	u32 key;
  	u16 unicode;
  	u16 shifted_unicode;
  	u16 alt_gr_unicode;
  	u16 shifted_alt_gr_unicode;
  	u16 modifier;
  	u16 affected_attribute;
  } __packed;
  
  struct efi_hii_keyboard_layout {
  	u16 layout_length;
  	efi_guid_t guid;
  	u32 layout_descriptor_string_offset;
  	u8 descriptor_count;
  	struct efi_key_descriptor descriptors[];
  } __packed;
8d3b77e36   AKASHI Takahiro   efi: hii: add key...
954
955
956
957
958
  struct efi_hii_keyboard_package {
  	struct efi_hii_package_header header;
  	u16 layout_count;
  	struct efi_hii_keyboard_layout layout[];
  } __packed;
c9bfb2229   Leif Lindholm   efi_loader: Initi...
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
  /*
   * HII protocols
   */
  #define EFI_HII_STRING_PROTOCOL_GUID \
  	EFI_GUID(0x0fd96974, 0x23aa, 0x4cdc, \
  		 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a)
  
  struct efi_font_info {
  	efi_hii_font_style_t font_style;
  	u16 font_size;
  	u16 font_name[1];
  };
  
  struct efi_hii_string_protocol {
  	efi_status_t(EFIAPI *new_string)(
  		const struct efi_hii_string_protocol *this,
  		efi_hii_handle_t package_list,
  		efi_string_id_t *string_id,
  		const u8 *language,
  		const u16 *language_name,
  		const efi_string_t string,
  		const struct efi_font_info *string_font_info);
  	efi_status_t(EFIAPI *get_string)(
  		const struct efi_hii_string_protocol *this,
  		const u8 *language,
  		efi_hii_handle_t package_list,
  		efi_string_id_t string_id,
  		efi_string_t string,
  		efi_uintn_t *string_size,
  		struct efi_font_info **string_font_info);
  	efi_status_t(EFIAPI *set_string)(
  		const struct efi_hii_string_protocol *this,
  		efi_hii_handle_t package_list,
  		efi_string_id_t string_id,
  		const u8 *language,
  		const efi_string_t string,
  		const struct efi_font_info *string_font_info);
  	efi_status_t(EFIAPI *get_languages)(
  		const struct efi_hii_string_protocol *this,
  		efi_hii_handle_t package_list,
  		u8 *languages,
  		efi_uintn_t *languages_size);
  	efi_status_t(EFIAPI *get_secondary_languages)(
  		const struct efi_hii_string_protocol *this,
  		efi_hii_handle_t package_list,
  		const u8 *primary_language,
  		u8 *secondary_languages,
  		efi_uintn_t *secondary_languages_size);
  };
  
  #define EFI_HII_DATABASE_PROTOCOL_GUID	     \
  	EFI_GUID(0xef9fc172, 0xa1b2, 0x4693, \
  		 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42)
  
  struct efi_hii_database_protocol {
  	efi_status_t(EFIAPI *new_package_list)(
  		const struct efi_hii_database_protocol *this,
  		const struct efi_hii_package_list_header *package_list,
  		const efi_handle_t driver_handle,
  		efi_hii_handle_t *handle);
  	efi_status_t(EFIAPI *remove_package_list)(
  		const struct efi_hii_database_protocol *this,
  		efi_hii_handle_t handle);
  	efi_status_t(EFIAPI *update_package_list)(
  		const struct efi_hii_database_protocol *this,
  		efi_hii_handle_t handle,
  		const struct efi_hii_package_list_header *package_list);
  	efi_status_t(EFIAPI *list_package_lists)(
  		const struct efi_hii_database_protocol *this,
  		u8 package_type,
  		const efi_guid_t *package_guid,
  		efi_uintn_t *handle_buffer_length,
  		efi_hii_handle_t *handle);
  	efi_status_t(EFIAPI *export_package_lists)(
  		const struct efi_hii_database_protocol *this,
  		efi_hii_handle_t handle,
  		efi_uintn_t *buffer_size,
  		struct efi_hii_package_list_header *buffer);
  	efi_status_t(EFIAPI *register_package_notify)(
  		const struct efi_hii_database_protocol *this,
  		u8 package_type,
  		const efi_guid_t *package_guid,
  		const void *package_notify_fn,
  		efi_uintn_t notify_type,
  		efi_handle_t *notify_handle);
  	efi_status_t(EFIAPI *unregister_package_notify)(
  		const struct efi_hii_database_protocol *this,
  		efi_handle_t notification_handle
  		);
  	efi_status_t(EFIAPI *find_keyboard_layouts)(
  		const struct efi_hii_database_protocol *this,
  		u16 *key_guid_buffer_length,
  		efi_guid_t *key_guid_buffer);
  	efi_status_t(EFIAPI *get_keyboard_layout)(
  		const struct efi_hii_database_protocol *this,
  		efi_guid_t *key_guid,
  		u16 *keyboard_layout_length,
  		struct efi_hii_keyboard_layout *keyboard_layout);
  	efi_status_t(EFIAPI *set_keyboard_layout)(
  		const struct efi_hii_database_protocol *this,
  		efi_guid_t *key_guid);
  	efi_status_t(EFIAPI *get_package_list_handle)(
  		const struct efi_hii_database_protocol *this,
  		efi_hii_handle_t package_list_handle,
  		efi_handle_t *driver_handle);
  };
cb728e51a   AKASHI Takahiro   efi: hii: add HII...
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
  #define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
  	EFI_GUID(0x587e72d7, 0xcc50, 0x4f79, \
  		 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f)
  
  struct efi_hii_config_routing_protocol {
  	efi_status_t(EFIAPI *extract_config)(
  		const struct efi_hii_config_routing_protocol *this,
  		const efi_string_t request,
  		efi_string_t *progress,
  		efi_string_t *results);
  	efi_status_t(EFIAPI *export_config)(
  		const struct efi_hii_config_routing_protocol *this,
  		efi_string_t *results);
  	efi_status_t(EFIAPI *route_config)(
  		const struct efi_hii_config_routing_protocol *this,
  		const efi_string_t configuration,
  		efi_string_t *progress);
  	efi_status_t(EFIAPI *block_to_config)(
  		const struct efi_hii_config_routing_protocol *this,
  		const efi_string_t config_request,
  		const uint8_t *block,
  		const efi_uintn_t block_size,
  		efi_string_t *config,
  		efi_string_t *progress);
  	efi_status_t(EFIAPI *config_to_block)(
  		const struct efi_hii_config_routing_protocol *this,
  		const efi_string_t config_resp,
  		const uint8_t *block,
  		const efi_uintn_t *block_size,
  		efi_string_t *progress);
  	efi_status_t(EFIAPI *get_alt_config)(
  		const struct efi_hii_config_routing_protocol *this,
  		const efi_string_t config_resp,
  		const efi_guid_t *guid,
  		const efi_string_t name,
  		const struct efi_device_path *device_path,
  		const efi_string_t alt_cfg_id,
  		efi_string_t *alt_cfg_resp);
  };
  
  #define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
  	EFI_GUID(0x330d4706, 0xf2a0, 0x4e4f, \
  		 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85)
  
  struct efi_hii_config_access_protocol {
  	efi_status_t(EFIAPI *extract_config_access)(
  		const struct efi_hii_config_access_protocol *this,
  		const efi_string_t request,
  		efi_string_t *progress,
  		efi_string_t *results);
  	efi_status_t(EFIAPI *route_config_access)(
  		const struct efi_hii_config_access_protocol *this,
  		const efi_string_t configuration,
  		efi_string_t *progress);
  	efi_status_t(EFIAPI *form_callback)(
  		const struct efi_hii_config_access_protocol *this,
  		efi_browser_action_t action,
  		efi_question_id_t question_id,
  		u8 type,
  		union efi_ifr_type_value *value,
  		efi_browser_action_request_t *action_request);
  };
dec88e41e   Heinrich Schuchardt   efi_loader: consi...
1127
  #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
be8d32419   Alexander Graf   efi_loader: Add G...
1128
1129
1130
1131
1132
1133
  	EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
  		 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
  
  #define EFI_GOT_RGBA8		0
  #define EFI_GOT_BGRA8		1
  #define EFI_GOT_BITMASK		2
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
1134
  struct efi_gop_mode_info {
be8d32419   Alexander Graf   efi_loader: Add G...
1135
1136
1137
1138
1139
1140
1141
  	u32 version;
  	u32 width;
  	u32 height;
  	u32 pixel_format;
  	u32 pixel_bitmask[4];
  	u32 pixels_per_scanline;
  };
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
1142
  struct efi_gop_mode {
be8d32419   Alexander Graf   efi_loader: Add G...
1143
1144
1145
1146
1147
1148
1149
  	u32 max_mode;
  	u32 mode;
  	struct efi_gop_mode_info *info;
  	unsigned long info_size;
  	efi_physical_addr_t fb_base;
  	unsigned long fb_size;
  };
0e0a3ceb5   Heinrich Schuchardt   efi_loader: imple...
1150
1151
1152
1153
1154
1155
  struct efi_gop_pixel {
  	u8 blue;
  	u8 green;
  	u8 red;
  	u8 reserved;
  };
be8d32419   Alexander Graf   efi_loader: Add G...
1156
1157
1158
1159
  #define EFI_BLT_VIDEO_FILL		0
  #define EFI_BLT_VIDEO_TO_BLT_BUFFER	1
  #define EFI_BLT_BUFFER_TO_VIDEO		2
  #define EFI_BLT_VIDEO_TO_VIDEO		3
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
1160
  struct efi_gop {
be8d32419   Alexander Graf   efi_loader: Add G...
1161
  	efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
1c38a7741   Heinrich Schuchardt   efi_loader: efi_g...
1162
  					  efi_uintn_t *size_of_info,
be8d32419   Alexander Graf   efi_loader: Add G...
1163
1164
  					  struct efi_gop_mode_info **info);
  	efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
0e0a3ceb5   Heinrich Schuchardt   efi_loader: imple...
1165
1166
  	efi_status_t (EFIAPI *blt)(struct efi_gop *this,
  				   struct efi_gop_pixel *buffer,
1c38a7741   Heinrich Schuchardt   efi_loader: efi_g...
1167
1168
1169
1170
  				   u32 operation, efi_uintn_t sx,
  				   efi_uintn_t sy, efi_uintn_t dx,
  				   efi_uintn_t dy, efi_uintn_t width,
  				   efi_uintn_t height, efi_uintn_t delta);
be8d32419   Alexander Graf   efi_loader: Add G...
1171
1172
  	struct efi_gop_mode *mode;
  };
dec88e41e   Heinrich Schuchardt   efi_loader: consi...
1173
  #define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1174
1175
1176
1177
1178
1179
1180
1181
1182
  	EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
  		 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  
  struct efi_mac_address {
  	char mac_addr[32];
  };
  
  struct efi_ip_address {
  	u8 ip_addr[16];
e27423586   Patrick Wildt   efi_loader: compl...
1183
  } __attribute__((aligned(4)));
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
  
  enum efi_simple_network_state {
  	EFI_NETWORK_STOPPED,
  	EFI_NETWORK_STARTED,
  	EFI_NETWORK_INITIALIZED,
  };
  
  struct efi_simple_network_mode {
  	enum efi_simple_network_state state;
  	u32 hwaddr_size;
  	u32 media_header_size;
  	u32 max_packet_size;
  	u32 nvram_size;
  	u32 nvram_access_size;
  	u32 receive_filter_mask;
  	u32 receive_filter_setting;
  	u32 max_mcast_filter_count;
  	u32 mcast_filter_count;
  	struct efi_mac_address mcast_filter[16];
  	struct efi_mac_address current_address;
  	struct efi_mac_address broadcast_address;
  	struct efi_mac_address permanent_address;
  	u8 if_type;
  	u8 mac_changeable;
  	u8 multitx_supported;
  	u8 media_present_supported;
  	u8 media_present;
  };
2e0864a47   Heinrich Schuchardt   efi_loader: corre...
1212
1213
1214
1215
1216
1217
  /* receive_filters bit mask */
  #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST               0x01
  #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST             0x02
  #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST             0x04
  #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS           0x08
  #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1218

891b3d905   Heinrich Schuchardt   efi_loader: fix e...
1219
1220
1221
1222
1223
  /* interrupt status bit mask */
  #define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT	0x01
  #define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT	0x02
  #define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT	0x04
  #define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT	0x08
bdecf974f   Heinrich Schuchardt   efi_loader: fill ...
1224
1225
  /* revision of the simple network protocol */
  #define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION	0x00010000
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
1226
  struct efi_simple_network {
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
  	u64 revision;
  	efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
  	efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
  	efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
  			ulong extra_rx, ulong extra_tx);
  	efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
  			int extended_verification);
  	efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
  	efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
  			u32 enable, u32 disable, int reset_mcast_filter,
  			ulong mcast_filter_count,
  			struct efi_mac_address *mcast_filter);
  	efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
  			int reset, struct efi_mac_address *new_mac);
  	efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
  			int reset, ulong *stat_size, void *stat_table);
  	efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
  			int ipv6, struct efi_ip_address *ip,
  			struct efi_mac_address *mac);
  	efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
  			int read_write, ulong offset, ulong buffer_size,
  			char *buffer);
  	efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
  			u32 *int_status, void **txbuf);
  	efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
8db174d65   Heinrich Schuchardt   efi_loader: size ...
1252
  			size_t header_size, size_t buffer_size, void *buffer,
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1253
1254
1255
  			struct efi_mac_address *src_addr,
  			struct efi_mac_address *dest_addr, u16 *protocol);
  	efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
8db174d65   Heinrich Schuchardt   efi_loader: size ...
1256
  			size_t *header_size, size_t *buffer_size, void *buffer,
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1257
1258
  			struct efi_mac_address *src_addr,
  			struct efi_mac_address *dest_addr, u16 *protocol);
84a12ce64   Heinrich Schuchardt   efi_loader: incor...
1259
  	struct efi_event *wait_for_packet;
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1260
  	struct efi_simple_network_mode *mode;
7f6d874d1   Heinrich Schuchardt   efi_loader: inter...
1261
1262
  	/* private fields */
  	u32 int_status;
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1263
  };
dec88e41e   Heinrich Schuchardt   efi_loader: consi...
1264
  #define EFI_PXE_BASE_CODE_PROTOCOL_GUID \
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1265
1266
  	EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
  		 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
a6d37098b   Heinrich Schuchardt   efi_loader: EFI_P...
1267
1268
  #define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000
  #define EFI_PXE_BASE_CODE_MAX_IPCNT 8
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1269
1270
1271
  struct efi_pxe_packet {
  	u8 packet[1472];
  };
2e0d79a08   Heinrich Schuchardt   efi_loader: SPDX-...
1272
  struct efi_pxe_mode {
e27423586   Patrick Wildt   efi_loader: compl...
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
  	u8 started;
  	u8 ipv6_available;
  	u8 ipv6_supported;
  	u8 using_ipv6;
  	u8 bis_supported;
  	u8 bis_detected;
  	u8 auto_arp;
  	u8 send_guid;
  	u8 dhcp_discover_valid;
  	u8 dhcp_ack_received;
  	u8 proxy_offer_received;
  	u8 pxe_discover_valid;
  	u8 pxe_reply_received;
  	u8 pxe_bis_reply_received;
  	u8 icmp_error_received;
  	u8 tftp_error_received;
  	u8 make_callbacks;
  	u8 ttl;
  	u8 tos;
  	u8 pad;
  	struct efi_ip_address station_ip;
  	struct efi_ip_address subnet_mask;
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1295
1296
1297
1298
1299
1300
  	struct efi_pxe_packet dhcp_discover;
  	struct efi_pxe_packet dhcp_ack;
  	struct efi_pxe_packet proxy_offer;
  	struct efi_pxe_packet pxe_discover;
  	struct efi_pxe_packet pxe_reply;
  };
a6d37098b   Heinrich Schuchardt   efi_loader: EFI_P...
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
  struct efi_pxe_base_code_srvlist {
  	u16 type;
  	u8 accept_any_response;
  	u8 reserved;
  	struct efi_ip_address ip_addr;
  };
  
  struct efi_pxe_base_code_discover_info {
  	u8 use_m_cast;
  	u8 use_b_cast;
  	u8 use_u_cast;
  	u8 must_use_list;
  	struct efi_ip_address server_m_cast_ip;
  	u16 ip_cnt;
  	struct efi_pxe_base_code_srvlist srv_list[];
  };
  
  struct efi_pxe_base_code_mtftp_info {
  	struct efi_ip_address m_cast_ip;
  	u16 cport;
  	u16 sport;
  	u16 listen_timeout;
  	u16 transit_timeout;
  };
  
  struct efi_pxe_base_code_filter {
  	u8 filters;
  	u8 ip_cnt;
  	u16 reserved;
  	struct efi_ip_address ip_list[EFI_PXE_BASE_CODE_MAX_IPCNT];
  };
  
  struct efi_pxe_base_code_dhcpv4_packet {
  	u8 bootp_op_code;
  	u8 bootp_hw_type;
  	u8 bootp_addr_len;
  	u8 bootp_gate_hops;
  	u32 bootp_ident;
  	u16 bootp_seconds;
  	u16 bootp_flags;
  	u8 bootp_ci_addr[4];
  	u8 bootp_yi_addr[4];
  	u8 bootp_si_addr[4];
  	u8 bootp_gi_addr[4];
  	u8 bootp_hw_addr[16];
  	u8 bootp_srv_name[64];
  	u8 bootp_boot_file[128];
  	u32 dhcp_magick;
  	u8 dhcp_options[56];
  };
  
  struct efi_pxe_base_code_dhcpv6_packet {
  	u8 message_type;
  	u8 transaction_id[3];
  	u8 dhcp_options[1024];
  };
  
  typedef union {
  	u8 raw[1472];
  	struct efi_pxe_base_code_dhcpv4_packet dhcpv4;
  	struct efi_pxe_base_code_dhcpv6_packet dhcpv6;
  } EFI_PXE_BASE_CODE_PACKET;
  
  struct efi_pxe_base_code_protocol {
  	u64 revision;
  	efi_status_t (EFIAPI *start)(struct efi_pxe_base_code_protocol *this,
  				     u8 use_ipv6);
  	efi_status_t (EFIAPI *stop)(struct efi_pxe_base_code_protocol *this);
  	efi_status_t (EFIAPI *dhcp)(struct efi_pxe_base_code_protocol *this,
  				    u8 sort_offers);
  	efi_status_t (EFIAPI *discover)(
  				struct efi_pxe_base_code_protocol *this,
  				u16 type, u16 *layer, u8 bis,
  				struct efi_pxe_base_code_discover_info *info);
  	efi_status_t (EFIAPI *mtftp)(
  				struct efi_pxe_base_code_protocol *this,
  				u32 operation, void *buffer_ptr,
  				u8 overwrite, efi_uintn_t *buffer_size,
  				struct efi_ip_address server_ip, char *filename,
  				struct efi_pxe_base_code_mtftp_info *info,
  				u8 dont_use_buffer);
  	efi_status_t (EFIAPI *udp_write)(
  				struct efi_pxe_base_code_protocol *this,
  				u16 op_flags, struct efi_ip_address *dest_ip,
  				u16 *dest_port,
  				struct efi_ip_address *gateway_ip,
  				struct efi_ip_address *src_ip, u16 *src_port,
  				efi_uintn_t *header_size, void *header_ptr,
  				efi_uintn_t *buffer_size, void *buffer_ptr);
  	efi_status_t (EFIAPI *udp_read)(
  				struct efi_pxe_base_code_protocol *this,
  				u16 op_flags, struct efi_ip_address *dest_ip,
  				u16 *dest_port, struct efi_ip_address *src_ip,
  				u16 *src_port, efi_uintn_t *header_size,
  				void *header_ptr, efi_uintn_t *buffer_size,
  				void *buffer_ptr);
  	efi_status_t (EFIAPI *set_ip_filter)(
  				struct efi_pxe_base_code_protocol *this,
  				struct efi_pxe_base_code_filter *new_filter);
  	efi_status_t (EFIAPI *arp)(struct efi_pxe_base_code_protocol *this,
  				   struct efi_ip_address *ip_addr,
  				   struct efi_mac_address *mac_addr);
  	efi_status_t (EFIAPI *set_parameters)(
  				struct efi_pxe_base_code_protocol *this,
  				u8 *new_auto_arp, u8 *new_send_guid,
  				u8 *new_ttl, u8 *new_tos,
  				u8 *new_make_callback);
  	efi_status_t (EFIAPI *set_station_ip)(
  				struct efi_pxe_base_code_protocol *this,
  				struct efi_ip_address *new_station_ip,
  				struct efi_ip_address *new_subnet_mask);
  	efi_status_t (EFIAPI *set_packets)(
  				struct efi_pxe_base_code_protocol *this,
  				u8 *new_dhcp_discover_valid,
  				u8 *new_dhcp_ack_received,
  				u8 *new_proxy_offer_received,
  				u8 *new_pxe_discover_valid,
  				u8 *new_pxe_reply_received,
  				u8 *new_pxe_bis_reply_received,
  				EFI_PXE_BASE_CODE_PACKET *new_dchp_discover,
  				EFI_PXE_BASE_CODE_PACKET *new_dhcp_acc,
  				EFI_PXE_BASE_CODE_PACKET *new_proxy_offer,
  				EFI_PXE_BASE_CODE_PACKET *new_pxe_discover,
  				EFI_PXE_BASE_CODE_PACKET *new_pxe_reply,
  				EFI_PXE_BASE_CODE_PACKET *new_pxe_bis_reply);
0efe1bcf5   Alexander Graf   efi_loader: Add n...
1426
1427
  	struct efi_pxe_mode *mode;
  };
2a92080d8   Rob Clark   efi_loader: add f...
1428
1429
1430
  #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
  	EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
  		 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
17394f9a6   Heinrich Schuchardt   efi_loader: TODO ...
1431
1432
1433
  #define EFI_FILE_PROTOCOL_REVISION	0x00010000
  #define EFI_FILE_PROTOCOL_REVISION2	0x00020000
  #define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2
2a92080d8   Rob Clark   efi_loader: add f...
1434

e692ed1d5   Heinrich Schuchardt   efi_loader: EFI_F...
1435
1436
1437
1438
1439
  struct efi_file_io_token {
  	struct efi_event *event;
  	efi_status_t status;
  	efi_uintn_t buffer_size;
  	void *buffer;};
2a92080d8   Rob Clark   efi_loader: add f...
1440
1441
1442
1443
  struct efi_file_handle {
  	u64 rev;
  	efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
  			struct efi_file_handle **new_handle,
c82f8f600   Heinrich Schuchardt   efi_loader: use u...
1444
  			u16 *file_name, u64 open_mode, u64 attributes);
2a92080d8   Rob Clark   efi_loader: add f...
1445
1446
1447
  	efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
  	efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
  	efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
b6dd57773   Heinrich Schuchardt   efi_loader: use c...
1448
  			efi_uintn_t *buffer_size, void *buffer);
2a92080d8   Rob Clark   efi_loader: add f...
1449
  	efi_status_t (EFIAPI *write)(struct efi_file_handle *file,
b6dd57773   Heinrich Schuchardt   efi_loader: use c...
1450
  			efi_uintn_t *buffer_size, void *buffer);
2a92080d8   Rob Clark   efi_loader: add f...
1451
  	efi_status_t (EFIAPI *getpos)(struct efi_file_handle *file,
0801d4d2f   Heinrich Schuchardt   efi_loader: corre...
1452
  				      u64 *pos);
2a92080d8   Rob Clark   efi_loader: add f...
1453
  	efi_status_t (EFIAPI *setpos)(struct efi_file_handle *file,
0801d4d2f   Heinrich Schuchardt   efi_loader: corre...
1454
  				      u64 pos);
2a92080d8   Rob Clark   efi_loader: add f...
1455
  	efi_status_t (EFIAPI *getinfo)(struct efi_file_handle *file,
9c9021e24   Heinrich Schuchardt   efi_loader: use c...
1456
  			const efi_guid_t *info_type, efi_uintn_t *buffer_size,
b6dd57773   Heinrich Schuchardt   efi_loader: use c...
1457
  			void *buffer);
2a92080d8   Rob Clark   efi_loader: add f...
1458
  	efi_status_t (EFIAPI *setinfo)(struct efi_file_handle *file,
9c9021e24   Heinrich Schuchardt   efi_loader: use c...
1459
  			const efi_guid_t *info_type, efi_uintn_t buffer_size,
b6dd57773   Heinrich Schuchardt   efi_loader: use c...
1460
  			void *buffer);
2a92080d8   Rob Clark   efi_loader: add f...
1461
  	efi_status_t (EFIAPI *flush)(struct efi_file_handle *file);
e692ed1d5   Heinrich Schuchardt   efi_loader: EFI_F...
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
  	efi_status_t (EFIAPI *open_ex)(struct efi_file_handle *file,
  			struct efi_file_handle **new_handle,
  			u16 *file_name, u64 open_mode, u64 attributes,
  			struct efi_file_io_token *token);
  	efi_status_t (EFIAPI *read_ex)(struct efi_file_handle *file,
  			struct efi_file_io_token *token);
  	efi_status_t (EFIAPI *write_ex)(struct efi_file_handle *file,
  			struct efi_file_io_token *token);
  	efi_status_t (EFIAPI *flush_ex)(struct efi_file_handle *file,
  			struct efi_file_io_token *token);
2a92080d8   Rob Clark   efi_loader: add f...
1472
  };
2a92080d8   Rob Clark   efi_loader: add f...
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
  #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
  
  struct efi_simple_file_system_protocol {
  	u64 rev;
  	efi_status_t (EFIAPI *open_volume)(struct efi_simple_file_system_protocol *this,
  			struct efi_file_handle **root);
  };
  
  #define EFI_FILE_INFO_GUID \
  	EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
  		 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
9e6835e6b   Heinrich Schuchardt   efi_loader: imple...
1484
1485
1486
  #define EFI_FILE_SYSTEM_INFO_GUID \
  	EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \
  		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
632834ce6   Heinrich Schuchardt   efi_loader: volum...
1487
1488
1489
  #define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \
  	EFI_GUID(0xdb47d7d3, 0xfe81, 0x11d3, \
  		 0x9a, 0x35, 0x00, 0x90, 0x27, 0x3f, 0xC1, 0x4d)
2a92080d8   Rob Clark   efi_loader: add f...
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
  #define EFI_FILE_MODE_READ	0x0000000000000001
  #define EFI_FILE_MODE_WRITE	0x0000000000000002
  #define EFI_FILE_MODE_CREATE	0x8000000000000000
  
  #define EFI_FILE_READ_ONLY	0x0000000000000001
  #define EFI_FILE_HIDDEN		0x0000000000000002
  #define EFI_FILE_SYSTEM		0x0000000000000004
  #define EFI_FILE_RESERVED	0x0000000000000008
  #define EFI_FILE_DIRECTORY	0x0000000000000010
  #define EFI_FILE_ARCHIVE	0x0000000000000020
  #define EFI_FILE_VALID_ATTR	0x0000000000000037
  
  struct efi_file_info {
  	u64 size;
  	u64 file_size;
  	u64 physical_size;
  	struct efi_time create_time;
  	struct efi_time last_access_time;
  	struct efi_time modification_time;
  	u64 attribute;
02c2f0298   Heinrich Schuchardt   efi_loader: use u...
1510
  	u16 file_name[0];
2a92080d8   Rob Clark   efi_loader: add f...
1511
  };
9e6835e6b   Heinrich Schuchardt   efi_loader: imple...
1512
1513
1514
1515
1516
1517
1518
1519
  struct efi_file_system_info {
  	u64 size;
  	u8 read_only;
  	u64 volume_size;
  	u64 free_space;
  	u32 block_size;
  	u16 volume_label[0];
  };
f0959dbee   Heinrich Schuchardt   efi_loader: imple...
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
  #define EFI_DRIVER_BINDING_PROTOCOL_GUID \
  	EFI_GUID(0x18a031ab, 0xb443, 0x4d1a,\
  		 0xa5, 0xc0, 0x0c, 0x09, 0x26, 0x1e, 0x9f, 0x71)
  struct efi_driver_binding_protocol {
  	efi_status_t (EFIAPI * supported)(
  			struct efi_driver_binding_protocol *this,
  			efi_handle_t controller_handle,
  			struct efi_device_path *remaining_device_path);
  	efi_status_t (EFIAPI * start)(
  			struct efi_driver_binding_protocol *this,
  			efi_handle_t controller_handle,
  			struct efi_device_path *remaining_device_path);
  	efi_status_t (EFIAPI * stop)(
  			struct efi_driver_binding_protocol *this,
  			efi_handle_t controller_handle,
  			efi_uintn_t number_of_children,
  			efi_handle_t *child_handle_buffer);
  	u32 version;
  	efi_handle_t image_handle;
  	efi_handle_t driver_binding_handle;
  };
b1b782d30   Heinrich Schuchardt   efi_loader: imple...
1541
1542
1543
1544
1545
  /* Deprecated version of the Unicode collation protocol */
  #define EFI_UNICODE_COLLATION_PROTOCOL_GUID \
  	EFI_GUID(0x1d85cd7f, 0xf43d, 0x11d2, \
  		 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  /* Current version of the Unicode collation protocol */
0bc4b0da7   Heinrich Schuchardt   efi_loader: EFI_U...
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
  #define EFI_UNICODE_COLLATION_PROTOCOL2_GUID \
  	EFI_GUID(0xa4c751fc, 0x23ae, 0x4c3e, \
  		 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49)
  struct efi_unicode_collation_protocol {
  	efi_intn_t (EFIAPI *stri_coll)(
  		struct efi_unicode_collation_protocol *this, u16 *s1, u16 *s2);
  	bool (EFIAPI *metai_match)(struct efi_unicode_collation_protocol *this,
  				   const u16 *string, const u16 *patter);
  	void (EFIAPI *str_lwr)(struct efi_unicode_collation_protocol
  			       *this, u16 *string);
  	void (EFIAPI *str_upr)(struct efi_unicode_collation_protocol *this,
  			       u16 *string);
  	void (EFIAPI *fat_to_str)(struct efi_unicode_collation_protocol *this,
  				  efi_uintn_t fat_size, char *fat, u16 *string);
  	bool (EFIAPI *str_to_fat)(struct efi_unicode_collation_protocol *this,
  				  const u16 *string, efi_uintn_t fat_size,
  				  char *fat);
  	char *supported_languages;
  };
ec80b4735   Ilias Apalodimas   efi_loader: Imple...
1565
1566
1567
1568
1569
1570
1571
  struct efi_load_file_protocol {
  	efi_status_t (EFIAPI *load_file)(struct efi_load_file_protocol *this,
  					 struct efi_device_path *file_path,
  					 bool boot_policy,
  					 efi_uintn_t *buffer_size,
  					 void *buffer);
  };
454568b4f   AKASHI Takahiro   efi_loader: defin...
1572
1573
1574
1575
1576
1577
1578
1579
  /* Boot manager load options */
  #define LOAD_OPTION_ACTIVE		0x00000001
  #define LOAD_OPTION_FORCE_RECONNECT	0x00000002
  #define LOAD_OPTION_HIDDEN		0x00000008
  /* All values 0x00000200-0x00001F00 are reserved */
  #define LOAD_OPTION_CATEGORY		0x00001F00
  #define LOAD_OPTION_CATEGORY_BOOT	0x00000000
  #define LOAD_OPTION_CATEGORY_APP	0x00000100
b74d568d8   AKASHI Takahiro   efi_loader: defin...
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
  /*
   * System Resource Table
   */
  /* Firmware Type Definitions */
  #define ESRT_FW_TYPE_UNKNOWN		0x00000000
  #define ESRT_FW_TYPE_SYSTEMFIRMWARE	0x00000001
  #define ESRT_FW_TYPE_DEVICEFIRMWARE	0x00000002
  #define ESRT_FW_TYPE_UEFIDRIVER		0x00000003
  
  /* Last Attempt Status Values */
  #define LAST_ATTEMPT_STATUS_SUCCESS			0x00000000
  #define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL		0x00000001
  #define LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES 0x00000002
  #define LAST_ATTEMPT_STATUS_ERROR_INCORRECT_VERSION	0x00000003
  #define LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT	0x00000004
  #define LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR		0x00000005
  #define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_AC		0x00000006
  #define LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT		0x00000007
  #define LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES 0x00000008
  
  /*
   * The LastAttemptStatus values of 0x1000 - 0x4000 are reserved for vendor
   * usage.
   */
  #define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MIN 0x00001000
  #define LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX 0x00004000
867a6ac86   Simon Glass   efi: Add start-up...
1606
  #endif