xref: /rk3399_rockchip-uboot/include/efi_api.h (revision c68415922b340c6b26f94326a6899977a67d61c9)
1867a6ac8SSimon Glass /*
2867a6ac8SSimon Glass  * Extensible Firmware Interface
3867a6ac8SSimon Glass  * Based on 'Extensible Firmware Interface Specification' version 0.9,
4867a6ac8SSimon Glass  * April 30, 1999
5867a6ac8SSimon Glass  *
6867a6ac8SSimon Glass  * Copyright (C) 1999 VA Linux Systems
7867a6ac8SSimon Glass  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
8867a6ac8SSimon Glass  * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
9867a6ac8SSimon Glass  *	David Mosberger-Tang <davidm@hpl.hp.com>
10867a6ac8SSimon Glass  *	Stephane Eranian <eranian@hpl.hp.com>
11867a6ac8SSimon Glass  *
12867a6ac8SSimon Glass  * From include/linux/efi.h in kernel 4.1 with some additions/subtractions
13867a6ac8SSimon Glass  */
14867a6ac8SSimon Glass 
15867a6ac8SSimon Glass #ifndef _EFI_API_H
16867a6ac8SSimon Glass #define _EFI_API_H
17867a6ac8SSimon Glass 
18867a6ac8SSimon Glass #include <efi.h>
19867a6ac8SSimon Glass 
20a86aeaf2SAlexander Graf #ifdef CONFIG_EFI_LOADER
21a86aeaf2SAlexander Graf #include <asm/setjmp.h>
22a86aeaf2SAlexander Graf #endif
23a86aeaf2SAlexander Graf 
242bb9b79dSAlexander Graf /* Types and defines for EFI CreateEvent */
252bb9b79dSAlexander Graf enum efi_event_type {
262bb9b79dSAlexander Graf 	EFI_TIMER_STOP = 0,
272bb9b79dSAlexander Graf 	EFI_TIMER_PERIODIC = 1,
282bb9b79dSAlexander Graf 	EFI_TIMER_RELATIVE = 2
292bb9b79dSAlexander Graf };
302bb9b79dSAlexander Graf 
31*c6841592Sxypron.glpk@gmx.de #define EVT_TIMER				0x80000000
32*c6841592Sxypron.glpk@gmx.de #define EVT_RUNTIME				0x40000000
3337a980b3SJonathan Gray #define EVT_NOTIFY_WAIT				0x00000100
3437a980b3SJonathan Gray #define EVT_NOTIFY_SIGNAL			0x00000200
35*c6841592Sxypron.glpk@gmx.de #define EVT_SIGNAL_EXIT_BOOT_SERVICES		0x00000201
36*c6841592Sxypron.glpk@gmx.de #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE	0x60000202
37*c6841592Sxypron.glpk@gmx.de 
38*c6841592Sxypron.glpk@gmx.de #define TPL_APPLICATION		0x04
39*c6841592Sxypron.glpk@gmx.de #define TPL_CALLBACK		0x08
40*c6841592Sxypron.glpk@gmx.de #define TPL_NOTIFY		0x10
41*c6841592Sxypron.glpk@gmx.de #define TPL_HIGH_LEVEL		0x1F
4237a980b3SJonathan Gray 
432fd945feSxypron.glpk@gmx.de struct efi_event;
442fd945feSxypron.glpk@gmx.de 
45867a6ac8SSimon Glass /* EFI Boot Services table */
46867a6ac8SSimon Glass struct efi_boot_services {
47867a6ac8SSimon Glass 	struct efi_table_hdr hdr;
482bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *raise_tpl)(unsigned long new_tpl);
492bb9b79dSAlexander Graf 	void (EFIAPI *restore_tpl)(unsigned long old_tpl);
50867a6ac8SSimon Glass 
51867a6ac8SSimon Glass 	efi_status_t (EFIAPI *allocate_pages)(int, int, unsigned long,
52867a6ac8SSimon Glass 					      efi_physical_addr_t *);
53867a6ac8SSimon Glass 	efi_status_t (EFIAPI *free_pages)(efi_physical_addr_t, unsigned long);
54867a6ac8SSimon Glass 	efi_status_t (EFIAPI *get_memory_map)(unsigned long *memory_map_size,
55867a6ac8SSimon Glass 			struct efi_mem_desc *desc, unsigned long *key,
56867a6ac8SSimon Glass 			unsigned long *desc_size, u32 *desc_version);
57867a6ac8SSimon Glass 	efi_status_t (EFIAPI *allocate_pool)(int, unsigned long, void **);
58867a6ac8SSimon Glass 	efi_status_t (EFIAPI *free_pool)(void *);
59867a6ac8SSimon Glass 
602bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *create_event)(enum efi_event_type type,
612bb9b79dSAlexander Graf 			unsigned long notify_tpl,
622fd945feSxypron.glpk@gmx.de 			void (EFIAPI *notify_function) (
632fd945feSxypron.glpk@gmx.de 					struct efi_event *event,
642bb9b79dSAlexander Graf 					void *context),
652fd945feSxypron.glpk@gmx.de 			void *notify_context, struct efi_event **event);
662fd945feSxypron.glpk@gmx.de 	efi_status_t (EFIAPI *set_timer)(struct efi_event *event, int type,
672bb9b79dSAlexander Graf 			uint64_t trigger_time);
68867a6ac8SSimon Glass 	efi_status_t (EFIAPI *wait_for_event)(unsigned long number_of_events,
692fd945feSxypron.glpk@gmx.de 			struct efi_event **event, unsigned long *index);
702fd945feSxypron.glpk@gmx.de 	efi_status_t (EFIAPI *signal_event)(struct efi_event *event);
712fd945feSxypron.glpk@gmx.de 	efi_status_t (EFIAPI *close_event)(struct efi_event *event);
722fd945feSxypron.glpk@gmx.de 	efi_status_t (EFIAPI *check_event)(struct efi_event *event);
73e0549f8aSxypron.glpk@gmx.de #define EFI_NATIVE_INTERFACE	0x00000000
742bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *install_protocol_interface)(
752bb9b79dSAlexander Graf 			void **handle, efi_guid_t *protocol,
762bb9b79dSAlexander Graf 			int protocol_interface_type, void *protocol_interface);
772bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *reinstall_protocol_interface)(
782bb9b79dSAlexander Graf 			void *handle, efi_guid_t *protocol,
792bb9b79dSAlexander Graf 			void *old_interface, void *new_interface);
802bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *uninstall_protocol_interface)(void *handle,
812bb9b79dSAlexander Graf 			efi_guid_t *protocol, void *protocol_interface);
82867a6ac8SSimon Glass 	efi_status_t (EFIAPI *handle_protocol)(efi_handle_t, efi_guid_t *,
83867a6ac8SSimon Glass 					       void **);
84867a6ac8SSimon Glass 	void *reserved;
852bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *register_protocol_notify)(
862fd945feSxypron.glpk@gmx.de 			efi_guid_t *protocol, struct efi_event *event,
872bb9b79dSAlexander Graf 			void **registration);
88867a6ac8SSimon Glass 	efi_status_t (EFIAPI *locate_handle)(
89867a6ac8SSimon Glass 			enum efi_locate_search_type search_type,
90867a6ac8SSimon Glass 			efi_guid_t *protocol, void *search_key,
91867a6ac8SSimon Glass 			unsigned long *buffer_size, efi_handle_t *buffer);
92867a6ac8SSimon Glass 	efi_status_t (EFIAPI *locate_device_path)(efi_guid_t *protocol,
93867a6ac8SSimon Glass 			struct efi_device_path **device_path,
94867a6ac8SSimon Glass 			efi_handle_t *device);
952bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *install_configuration_table)(
962bb9b79dSAlexander Graf 			efi_guid_t *guid, void *table);
97867a6ac8SSimon Glass 
98867a6ac8SSimon Glass 	efi_status_t (EFIAPI *load_image)(bool boot_policiy,
99867a6ac8SSimon Glass 			efi_handle_t parent_image,
100867a6ac8SSimon Glass 			struct efi_device_path *file_path, void *source_buffer,
101867a6ac8SSimon Glass 			unsigned long source_size, efi_handle_t *image);
102867a6ac8SSimon Glass 	efi_status_t (EFIAPI *start_image)(efi_handle_t handle,
103867a6ac8SSimon Glass 					   unsigned long *exitdata_size,
104867a6ac8SSimon Glass 					   s16 **exitdata);
105867a6ac8SSimon Glass 	efi_status_t (EFIAPI *exit)(efi_handle_t handle,
106867a6ac8SSimon Glass 				    efi_status_t exit_status,
107867a6ac8SSimon Glass 				    unsigned long exitdata_size, s16 *exitdata);
1082bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *unload_image)(void *image_handle);
109867a6ac8SSimon Glass 	efi_status_t (EFIAPI *exit_boot_services)(efi_handle_t, unsigned long);
110867a6ac8SSimon Glass 
111867a6ac8SSimon Glass 	efi_status_t (EFIAPI *get_next_monotonic_count)(u64 *count);
112867a6ac8SSimon Glass 	efi_status_t (EFIAPI *stall)(unsigned long usecs);
1132bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *set_watchdog_timer)(unsigned long timeout,
1142bb9b79dSAlexander Graf 			uint64_t watchdog_code, unsigned long data_size,
1152bb9b79dSAlexander Graf 			uint16_t *watchdog_data);
116867a6ac8SSimon Glass 	efi_status_t(EFIAPI *connect_controller)(efi_handle_t controller_handle,
117867a6ac8SSimon Glass 			efi_handle_t *driver_image_handle,
118867a6ac8SSimon Glass 			struct efi_device_path *remaining_device_path,
119867a6ac8SSimon Glass 			bool recursive);
1202bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *disconnect_controller)(void *controller_handle,
1212bb9b79dSAlexander Graf 			void *driver_image_handle, void *child_handle);
122867a6ac8SSimon Glass #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL  0x00000001
123867a6ac8SSimon Glass #define EFI_OPEN_PROTOCOL_GET_PROTOCOL        0x00000002
124867a6ac8SSimon Glass #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL       0x00000004
125867a6ac8SSimon Glass #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
126867a6ac8SSimon Glass #define EFI_OPEN_PROTOCOL_BY_DRIVER           0x00000010
127867a6ac8SSimon Glass #define EFI_OPEN_PROTOCOL_EXCLUSIVE           0x00000020
128867a6ac8SSimon Glass 	efi_status_t (EFIAPI *open_protocol)(efi_handle_t handle,
129867a6ac8SSimon Glass 			efi_guid_t *protocol, void **interface,
130867a6ac8SSimon Glass 			efi_handle_t agent_handle,
131867a6ac8SSimon Glass 			efi_handle_t controller_handle, u32 attributes);
1322bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *close_protocol)(void *handle,
1332bb9b79dSAlexander Graf 			efi_guid_t *protocol, void *agent_handle,
1342bb9b79dSAlexander Graf 			void *controller_handle);
135867a6ac8SSimon Glass 	efi_status_t(EFIAPI *open_protocol_information)(efi_handle_t handle,
136867a6ac8SSimon Glass 			efi_guid_t *protocol,
137867a6ac8SSimon Glass 			struct efi_open_protocol_info_entry **entry_buffer,
138867a6ac8SSimon Glass 			unsigned long *entry_count);
139867a6ac8SSimon Glass 	efi_status_t (EFIAPI *protocols_per_handle)(efi_handle_t handle,
140867a6ac8SSimon Glass 			efi_guid_t ***protocol_buffer,
141867a6ac8SSimon Glass 			unsigned long *protocols_buffer_count);
142867a6ac8SSimon Glass 	efi_status_t (EFIAPI *locate_handle_buffer) (
143867a6ac8SSimon Glass 			enum efi_locate_search_type search_type,
144867a6ac8SSimon Glass 			efi_guid_t *protocol, void *search_key,
145867a6ac8SSimon Glass 			unsigned long *no_handles, efi_handle_t **buffer);
1462bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *locate_protocol)(efi_guid_t *protocol,
1472bb9b79dSAlexander Graf 			void *registration, void **protocol_interface);
1482bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *install_multiple_protocol_interfaces)(
1492bb9b79dSAlexander Graf 			void **handle, ...);
1502bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *uninstall_multiple_protocol_interfaces)(
1512bb9b79dSAlexander Graf 			void *handle, ...);
1522bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *calculate_crc32)(void *data,
1532bb9b79dSAlexander Graf 			unsigned long data_size, uint32_t *crc32);
1542bb9b79dSAlexander Graf 	void (EFIAPI *copy_mem)(void *destination, void *source,
1552bb9b79dSAlexander Graf 			unsigned long length);
1562bb9b79dSAlexander Graf 	void (EFIAPI *set_mem)(void *buffer, unsigned long size,
1572bb9b79dSAlexander Graf 			uint8_t value);
158867a6ac8SSimon Glass 	void *create_event_ex;
159867a6ac8SSimon Glass };
160867a6ac8SSimon Glass 
161867a6ac8SSimon Glass /* Types and defines for EFI ResetSystem */
162867a6ac8SSimon Glass enum efi_reset_type {
163867a6ac8SSimon Glass 	EFI_RESET_COLD = 0,
164867a6ac8SSimon Glass 	EFI_RESET_WARM = 1,
165867a6ac8SSimon Glass 	EFI_RESET_SHUTDOWN = 2
166867a6ac8SSimon Glass };
167867a6ac8SSimon Glass 
168867a6ac8SSimon Glass /* EFI Runtime Services table */
169867a6ac8SSimon Glass #define EFI_RUNTIME_SERVICES_SIGNATURE	0x5652453544e5552ULL
170867a6ac8SSimon Glass #define EFI_RUNTIME_SERVICES_REVISION	0x00010000
171867a6ac8SSimon Glass 
172867a6ac8SSimon Glass struct efi_runtime_services {
173867a6ac8SSimon Glass 	struct efi_table_hdr hdr;
1742bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *get_time)(struct efi_time *time,
1752bb9b79dSAlexander Graf 			struct efi_time_cap *capabilities);
1762bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *set_time)(struct efi_time *time);
1772bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *get_wakeup_time)(char *enabled, char *pending,
1782bb9b79dSAlexander Graf 			struct efi_time *time);
1792bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *set_wakeup_time)(char enabled,
1802bb9b79dSAlexander Graf 			struct efi_time *time);
1812bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *set_virtual_address_map)(
1822bb9b79dSAlexander Graf 			unsigned long memory_map_size,
1832bb9b79dSAlexander Graf 			unsigned long descriptor_size,
1842bb9b79dSAlexander Graf 			uint32_t descriptor_version,
1852bb9b79dSAlexander Graf 			struct efi_mem_desc *virtmap);
1862bb9b79dSAlexander Graf 	efi_status_t (*convert_pointer)(unsigned long dbg, void **address);
187867a6ac8SSimon Glass 	efi_status_t (EFIAPI *get_variable)(s16 *variable_name,
188867a6ac8SSimon Glass 			efi_guid_t *vendor, u32 *attributes,
189867a6ac8SSimon Glass 			unsigned long *data_size, void *data);
190867a6ac8SSimon Glass 	efi_status_t (EFIAPI *get_next_variable)(
191867a6ac8SSimon Glass 			unsigned long *variable_name_size,
192867a6ac8SSimon Glass 			s16 *variable_name, efi_guid_t *vendor);
193867a6ac8SSimon Glass 	efi_status_t (EFIAPI *set_variable)(s16 *variable_name,
194867a6ac8SSimon Glass 			efi_guid_t *vendor, u32 attributes,
195867a6ac8SSimon Glass 			unsigned long data_size, void *data);
1962bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *get_next_high_mono_count)(
1972bb9b79dSAlexander Graf 			uint32_t *high_count);
198867a6ac8SSimon Glass 	void (EFIAPI *reset_system)(enum efi_reset_type reset_type,
199867a6ac8SSimon Glass 				    efi_status_t reset_status,
200867a6ac8SSimon Glass 				    unsigned long data_size, void *reset_data);
201867a6ac8SSimon Glass 	void *update_capsule;
202867a6ac8SSimon Glass 	void *query_capsule_caps;
203867a6ac8SSimon Glass 	void *query_variable_info;
204867a6ac8SSimon Glass };
205867a6ac8SSimon Glass 
206867a6ac8SSimon Glass /* EFI Configuration Table and GUID definitions */
207867a6ac8SSimon Glass #define NULL_GUID \
208867a6ac8SSimon Glass 	EFI_GUID(0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
209867a6ac8SSimon Glass 		 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
210867a6ac8SSimon Glass 
211867a6ac8SSimon Glass #define LOADED_IMAGE_PROTOCOL_GUID \
212867a6ac8SSimon Glass 	EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \
213867a6ac8SSimon Glass 		 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
214867a6ac8SSimon Glass 
2152bb9b79dSAlexander Graf #define EFI_FDT_GUID \
2162bb9b79dSAlexander Graf 	EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
2172bb9b79dSAlexander Graf 		 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
2182bb9b79dSAlexander Graf 
219e663b350SAlexander Graf #define SMBIOS_TABLE_GUID \
220e663b350SAlexander Graf 	EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3,  \
221e663b350SAlexander Graf 		 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
222e663b350SAlexander Graf 
2232bb9b79dSAlexander Graf struct efi_configuration_table
2242bb9b79dSAlexander Graf {
2252bb9b79dSAlexander Graf 	efi_guid_t guid;
2262bb9b79dSAlexander Graf 	void *table;
2272bb9b79dSAlexander Graf };
2282bb9b79dSAlexander Graf 
2292bb9b79dSAlexander Graf #define EFI_SYSTEM_TABLE_SIGNATURE ((u64)0x5453595320494249ULL)
2302bb9b79dSAlexander Graf 
231867a6ac8SSimon Glass struct efi_system_table {
232867a6ac8SSimon Glass 	struct efi_table_hdr hdr;
233867a6ac8SSimon Glass 	unsigned long fw_vendor;   /* physical addr of wchar_t vendor string */
234867a6ac8SSimon Glass 	u32 fw_revision;
235867a6ac8SSimon Glass 	unsigned long con_in_handle;
236867a6ac8SSimon Glass 	struct efi_simple_input_interface *con_in;
237867a6ac8SSimon Glass 	unsigned long con_out_handle;
238867a6ac8SSimon Glass 	struct efi_simple_text_output_protocol *con_out;
239867a6ac8SSimon Glass 	unsigned long stderr_handle;
2402bb9b79dSAlexander Graf 	struct efi_simple_text_output_protocol *std_err;
241867a6ac8SSimon Glass 	struct efi_runtime_services *runtime;
242867a6ac8SSimon Glass 	struct efi_boot_services *boottime;
243867a6ac8SSimon Glass 	unsigned long nr_tables;
2442bb9b79dSAlexander Graf 	struct efi_configuration_table *tables;
245867a6ac8SSimon Glass };
246867a6ac8SSimon Glass 
2472bb9b79dSAlexander Graf #define LOADED_IMAGE_GUID \
2482bb9b79dSAlexander Graf 	EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
2492bb9b79dSAlexander Graf 		 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
2502bb9b79dSAlexander Graf 
251867a6ac8SSimon Glass struct efi_loaded_image {
252867a6ac8SSimon Glass 	u32 revision;
253867a6ac8SSimon Glass 	void *parent_handle;
254867a6ac8SSimon Glass 	struct efi_system_table *system_table;
255867a6ac8SSimon Glass 	void *device_handle;
256867a6ac8SSimon Glass 	void *file_path;
257867a6ac8SSimon Glass 	void *reserved;
258867a6ac8SSimon Glass 	u32 load_options_size;
259867a6ac8SSimon Glass 	void *load_options;
260867a6ac8SSimon Glass 	void *image_base;
261867a6ac8SSimon Glass 	aligned_u64 image_size;
262867a6ac8SSimon Glass 	unsigned int image_code_type;
263867a6ac8SSimon Glass 	unsigned int image_data_type;
264867a6ac8SSimon Glass 	unsigned long unload;
265a86aeaf2SAlexander Graf 
266a86aeaf2SAlexander Graf 	/* Below are efi loader private fields */
267a86aeaf2SAlexander Graf #ifdef CONFIG_EFI_LOADER
268a86aeaf2SAlexander Graf 	efi_status_t exit_status;
269a86aeaf2SAlexander Graf 	struct jmp_buf_data exit_jmp;
270a86aeaf2SAlexander Graf #endif
271867a6ac8SSimon Glass };
272867a6ac8SSimon Glass 
2732bb9b79dSAlexander Graf #define DEVICE_PATH_GUID \
2742bb9b79dSAlexander Graf 	EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
2752bb9b79dSAlexander Graf 		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
2762bb9b79dSAlexander Graf 
2772bb9b79dSAlexander Graf #define DEVICE_PATH_TYPE_END			0x7f
2782bb9b79dSAlexander Graf #  define DEVICE_PATH_SUB_TYPE_END		0xff
2792bb9b79dSAlexander Graf 
280867a6ac8SSimon Glass struct efi_device_path {
281867a6ac8SSimon Glass 	u8 type;
282867a6ac8SSimon Glass 	u8 sub_type;
283867a6ac8SSimon Glass 	u16 length;
284867a6ac8SSimon Glass };
285867a6ac8SSimon Glass 
286d7608abaSOleksandr Tymoshenko struct efi_mac_addr {
287d7608abaSOleksandr Tymoshenko 	u8 addr[32];
288d7608abaSOleksandr Tymoshenko };
289d7608abaSOleksandr Tymoshenko 
290d7608abaSOleksandr Tymoshenko #define DEVICE_PATH_TYPE_MESSAGING_DEVICE	0x03
291d7608abaSOleksandr Tymoshenko #  define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR	0x0b
292d7608abaSOleksandr Tymoshenko 
293d7608abaSOleksandr Tymoshenko struct efi_device_path_mac_addr {
294d7608abaSOleksandr Tymoshenko 	struct efi_device_path dp;
295d7608abaSOleksandr Tymoshenko 	struct efi_mac_addr mac;
296d7608abaSOleksandr Tymoshenko 	u8 if_type;
297d7608abaSOleksandr Tymoshenko };
298d7608abaSOleksandr Tymoshenko 
2992bb9b79dSAlexander Graf #define DEVICE_PATH_TYPE_MEDIA_DEVICE		0x04
3002bb9b79dSAlexander Graf #  define DEVICE_PATH_SUB_TYPE_FILE_PATH	0x04
3012bb9b79dSAlexander Graf 
3022bb9b79dSAlexander Graf struct efi_device_path_file_path {
3032bb9b79dSAlexander Graf 	struct efi_device_path dp;
304ecbe1a07SAlexander Graf 	u16 str[32];
3052bb9b79dSAlexander Graf };
3062bb9b79dSAlexander Graf 
3072bb9b79dSAlexander Graf #define BLOCK_IO_GUID \
3082bb9b79dSAlexander Graf 	EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \
3092bb9b79dSAlexander Graf 		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
3102bb9b79dSAlexander Graf 
3112bb9b79dSAlexander Graf struct efi_block_io_media
3122bb9b79dSAlexander Graf {
3132bb9b79dSAlexander Graf 	u32 media_id;
3142bb9b79dSAlexander Graf 	char removable_media;
3152bb9b79dSAlexander Graf 	char media_present;
3162bb9b79dSAlexander Graf 	char logical_partition;
3172bb9b79dSAlexander Graf 	char read_only;
3182bb9b79dSAlexander Graf 	char write_caching;
3192bb9b79dSAlexander Graf 	u8 pad[3];
3202bb9b79dSAlexander Graf 	u32 block_size;
3212bb9b79dSAlexander Graf 	u32 io_align;
3222bb9b79dSAlexander Graf 	u8 pad2[4];
3232bb9b79dSAlexander Graf 	u64 last_block;
3242bb9b79dSAlexander Graf };
3252bb9b79dSAlexander Graf 
3262bb9b79dSAlexander Graf struct efi_block_io {
3272bb9b79dSAlexander Graf 	u64 revision;
3282bb9b79dSAlexander Graf 	struct efi_block_io_media *media;
3292bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *reset)(struct efi_block_io *this,
3302bb9b79dSAlexander Graf 			char extended_verification);
3312bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *read_blocks)(struct efi_block_io *this,
3322bb9b79dSAlexander Graf 			u32 media_id, u64 lba, unsigned long buffer_size,
3332bb9b79dSAlexander Graf 			void *buffer);
3342bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *write_blocks)(struct efi_block_io *this,
3352bb9b79dSAlexander Graf 			u32 media_id, u64 lba, unsigned long buffer_size,
3362bb9b79dSAlexander Graf 			void *buffer);
3372bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *flush_blocks)(struct efi_block_io *this);
3382bb9b79dSAlexander Graf };
3392bb9b79dSAlexander Graf 
340867a6ac8SSimon Glass struct simple_text_output_mode {
341867a6ac8SSimon Glass 	s32 max_mode;
342867a6ac8SSimon Glass 	s32 mode;
343867a6ac8SSimon Glass 	s32 attribute;
344867a6ac8SSimon Glass 	s32 cursor_column;
345867a6ac8SSimon Glass 	s32 cursor_row;
346867a6ac8SSimon Glass 	bool cursor_visible;
347867a6ac8SSimon Glass };
348867a6ac8SSimon Glass 
349867a6ac8SSimon Glass struct efi_simple_text_output_protocol {
350867a6ac8SSimon Glass 	void *reset;
351867a6ac8SSimon Glass 	efi_status_t (EFIAPI *output_string)(
352867a6ac8SSimon Glass 			struct efi_simple_text_output_protocol *this,
353867a6ac8SSimon Glass 			const unsigned short *str);
3542bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *test_string)(
3552bb9b79dSAlexander Graf 			struct efi_simple_text_output_protocol *this,
3562bb9b79dSAlexander Graf 			const unsigned short *str);
357867a6ac8SSimon Glass 	efi_status_t(EFIAPI *query_mode)(
358867a6ac8SSimon Glass 			struct efi_simple_text_output_protocol *this,
359867a6ac8SSimon Glass 			unsigned long mode_number, unsigned long *columns,
360867a6ac8SSimon Glass 			unsigned long *rows);
361867a6ac8SSimon Glass 	efi_status_t(EFIAPI *set_mode)(
362867a6ac8SSimon Glass 			struct efi_simple_text_output_protocol *this,
363867a6ac8SSimon Glass 			unsigned long mode_number);
364867a6ac8SSimon Glass 	efi_status_t(EFIAPI *set_attribute)(
365867a6ac8SSimon Glass 			struct efi_simple_text_output_protocol *this,
366867a6ac8SSimon Glass 			unsigned long attribute);
367867a6ac8SSimon Glass 	efi_status_t(EFIAPI *clear_screen) (
368867a6ac8SSimon Glass 			struct efi_simple_text_output_protocol *this);
369867a6ac8SSimon Glass 	efi_status_t(EFIAPI *set_cursor_position) (
370867a6ac8SSimon Glass 			struct efi_simple_text_output_protocol *this,
371867a6ac8SSimon Glass 			unsigned long column, unsigned long row);
3722bb9b79dSAlexander Graf 	efi_status_t(EFIAPI *enable_cursor)(
3732bb9b79dSAlexander Graf 			struct efi_simple_text_output_protocol *this,
3742bb9b79dSAlexander Graf 			bool enable);
375867a6ac8SSimon Glass 	struct simple_text_output_mode *mode;
376867a6ac8SSimon Glass };
377867a6ac8SSimon Glass 
378867a6ac8SSimon Glass struct efi_input_key {
379867a6ac8SSimon Glass 	u16 scan_code;
380867a6ac8SSimon Glass 	s16 unicode_char;
381867a6ac8SSimon Glass };
382867a6ac8SSimon Glass 
383867a6ac8SSimon Glass struct efi_simple_input_interface {
384867a6ac8SSimon Glass 	efi_status_t(EFIAPI *reset)(struct efi_simple_input_interface *this,
385867a6ac8SSimon Glass 			bool ExtendedVerification);
386867a6ac8SSimon Glass 	efi_status_t(EFIAPI *read_key_stroke)(
387867a6ac8SSimon Glass 			struct efi_simple_input_interface *this,
388867a6ac8SSimon Glass 			struct efi_input_key *key);
3892fd945feSxypron.glpk@gmx.de 	struct efi_event *wait_for_key;
390867a6ac8SSimon Glass };
391867a6ac8SSimon Glass 
3922bb9b79dSAlexander Graf #define CONSOLE_CONTROL_GUID \
3932bb9b79dSAlexander Graf 	EFI_GUID(0xf42f7782, 0x12e, 0x4c12, \
3942bb9b79dSAlexander Graf 		 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21)
3952bb9b79dSAlexander Graf #define EFI_CONSOLE_MODE_TEXT	0
3962bb9b79dSAlexander Graf #define EFI_CONSOLE_MODE_GFX	1
3972bb9b79dSAlexander Graf 
3982bb9b79dSAlexander Graf struct efi_console_control_protocol
3992bb9b79dSAlexander Graf {
4002bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *get_mode)(
4012bb9b79dSAlexander Graf 			struct efi_console_control_protocol *this, int *mode,
4022bb9b79dSAlexander Graf 			char *uga_exists, char *std_in_locked);
4032bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *set_mode)(
4042bb9b79dSAlexander Graf 			struct efi_console_control_protocol *this, int mode);
4052bb9b79dSAlexander Graf 	efi_status_t (EFIAPI *lock_std_in)(
4062bb9b79dSAlexander Graf 			struct efi_console_control_protocol *this,
4072bb9b79dSAlexander Graf 			uint16_t *password);
4082bb9b79dSAlexander Graf };
4092bb9b79dSAlexander Graf 
410cc5b7081Sxypron.glpk@gmx.de #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
411cc5b7081Sxypron.glpk@gmx.de 	EFI_GUID(0x8b843e20, 0x8132, 0x4852, \
412cc5b7081Sxypron.glpk@gmx.de 		 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c)
413cc5b7081Sxypron.glpk@gmx.de 
414cc5b7081Sxypron.glpk@gmx.de struct efi_device_path_protocol
415cc5b7081Sxypron.glpk@gmx.de {
416cc5b7081Sxypron.glpk@gmx.de 	uint8_t type;
417cc5b7081Sxypron.glpk@gmx.de 	uint8_t sub_type;
418cc5b7081Sxypron.glpk@gmx.de 	uint16_t length;
419cc5b7081Sxypron.glpk@gmx.de 	uint8_t data[];
420cc5b7081Sxypron.glpk@gmx.de };
421cc5b7081Sxypron.glpk@gmx.de 
422cc5b7081Sxypron.glpk@gmx.de struct efi_device_path_to_text_protocol
423cc5b7081Sxypron.glpk@gmx.de {
424cc5b7081Sxypron.glpk@gmx.de 	uint16_t *(EFIAPI *convert_device_node_to_text)(
425cc5b7081Sxypron.glpk@gmx.de 			struct efi_device_path_protocol *device_node,
426cc5b7081Sxypron.glpk@gmx.de 			bool display_only,
427cc5b7081Sxypron.glpk@gmx.de 			bool allow_shortcuts);
428cc5b7081Sxypron.glpk@gmx.de 	uint16_t *(EFIAPI *convert_device_path_to_text)(
429cc5b7081Sxypron.glpk@gmx.de 			struct efi_device_path_protocol *device_path,
430cc5b7081Sxypron.glpk@gmx.de 			bool display_only,
431cc5b7081Sxypron.glpk@gmx.de 			bool allow_shortcuts);
432cc5b7081Sxypron.glpk@gmx.de };
433cc5b7081Sxypron.glpk@gmx.de 
434be8d3241SAlexander Graf #define EFI_GOP_GUID \
435be8d3241SAlexander Graf 	EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
436be8d3241SAlexander Graf 		 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
437be8d3241SAlexander Graf 
438be8d3241SAlexander Graf #define EFI_GOT_RGBA8		0
439be8d3241SAlexander Graf #define EFI_GOT_BGRA8		1
440be8d3241SAlexander Graf #define EFI_GOT_BITMASK		2
441be8d3241SAlexander Graf 
442be8d3241SAlexander Graf struct efi_gop_mode_info
443be8d3241SAlexander Graf {
444be8d3241SAlexander Graf 	u32 version;
445be8d3241SAlexander Graf 	u32 width;
446be8d3241SAlexander Graf 	u32 height;
447be8d3241SAlexander Graf 	u32 pixel_format;
448be8d3241SAlexander Graf 	u32 pixel_bitmask[4];
449be8d3241SAlexander Graf 	u32 pixels_per_scanline;
450be8d3241SAlexander Graf };
451be8d3241SAlexander Graf 
452be8d3241SAlexander Graf struct efi_gop_mode
453be8d3241SAlexander Graf {
454be8d3241SAlexander Graf 	u32 max_mode;
455be8d3241SAlexander Graf 	u32 mode;
456be8d3241SAlexander Graf 	struct efi_gop_mode_info *info;
457be8d3241SAlexander Graf 	unsigned long info_size;
458be8d3241SAlexander Graf 	efi_physical_addr_t fb_base;
459be8d3241SAlexander Graf 	unsigned long fb_size;
460be8d3241SAlexander Graf };
461be8d3241SAlexander Graf 
462be8d3241SAlexander Graf #define EFI_BLT_VIDEO_FILL		0
463be8d3241SAlexander Graf #define EFI_BLT_VIDEO_TO_BLT_BUFFER	1
464be8d3241SAlexander Graf #define EFI_BLT_BUFFER_TO_VIDEO		2
465be8d3241SAlexander Graf #define EFI_BLT_VIDEO_TO_VIDEO		3
466be8d3241SAlexander Graf 
467be8d3241SAlexander Graf struct efi_gop
468be8d3241SAlexander Graf {
469be8d3241SAlexander Graf 	efi_status_t (EFIAPI *query_mode)(struct efi_gop *this, u32 mode_number,
470be8d3241SAlexander Graf 					  unsigned long *size_of_info,
471be8d3241SAlexander Graf 					  struct efi_gop_mode_info **info);
472be8d3241SAlexander Graf 	efi_status_t (EFIAPI *set_mode)(struct efi_gop *this, u32 mode_number);
473be8d3241SAlexander Graf 	efi_status_t (EFIAPI *blt)(struct efi_gop *this, void *buffer,
474be8d3241SAlexander Graf 				   unsigned long operation, unsigned long sx,
475be8d3241SAlexander Graf 				   unsigned long sy, unsigned long dx,
476be8d3241SAlexander Graf 				   unsigned long dy, unsigned long width,
477be8d3241SAlexander Graf 				   unsigned long height, unsigned long delta);
478be8d3241SAlexander Graf 	struct efi_gop_mode *mode;
479be8d3241SAlexander Graf };
480be8d3241SAlexander Graf 
4810efe1bcfSAlexander Graf #define EFI_SIMPLE_NETWORK_GUID \
4820efe1bcfSAlexander Graf 	EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \
4830efe1bcfSAlexander Graf 		 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
4840efe1bcfSAlexander Graf 
4850efe1bcfSAlexander Graf struct efi_mac_address {
4860efe1bcfSAlexander Graf 	char mac_addr[32];
4870efe1bcfSAlexander Graf };
4880efe1bcfSAlexander Graf 
4890efe1bcfSAlexander Graf struct efi_ip_address {
4900efe1bcfSAlexander Graf 	u8 ip_addr[16];
4910efe1bcfSAlexander Graf };
4920efe1bcfSAlexander Graf 
4930efe1bcfSAlexander Graf enum efi_simple_network_state {
4940efe1bcfSAlexander Graf 	EFI_NETWORK_STOPPED,
4950efe1bcfSAlexander Graf 	EFI_NETWORK_STARTED,
4960efe1bcfSAlexander Graf 	EFI_NETWORK_INITIALIZED,
4970efe1bcfSAlexander Graf };
4980efe1bcfSAlexander Graf 
4990efe1bcfSAlexander Graf struct efi_simple_network_mode {
5000efe1bcfSAlexander Graf 	enum efi_simple_network_state state;
5010efe1bcfSAlexander Graf 	u32 hwaddr_size;
5020efe1bcfSAlexander Graf 	u32 media_header_size;
5030efe1bcfSAlexander Graf 	u32 max_packet_size;
5040efe1bcfSAlexander Graf 	u32 nvram_size;
5050efe1bcfSAlexander Graf 	u32 nvram_access_size;
5060efe1bcfSAlexander Graf 	u32 receive_filter_mask;
5070efe1bcfSAlexander Graf 	u32 receive_filter_setting;
5080efe1bcfSAlexander Graf 	u32 max_mcast_filter_count;
5090efe1bcfSAlexander Graf 	u32 mcast_filter_count;
5100efe1bcfSAlexander Graf 	struct efi_mac_address mcast_filter[16];
5110efe1bcfSAlexander Graf 	struct efi_mac_address current_address;
5120efe1bcfSAlexander Graf 	struct efi_mac_address broadcast_address;
5130efe1bcfSAlexander Graf 	struct efi_mac_address permanent_address;
5140efe1bcfSAlexander Graf 	u8 if_type;
5150efe1bcfSAlexander Graf 	u8 mac_changeable;
5160efe1bcfSAlexander Graf 	u8 multitx_supported;
5170efe1bcfSAlexander Graf 	u8 media_present_supported;
5180efe1bcfSAlexander Graf 	u8 media_present;
5190efe1bcfSAlexander Graf };
5200efe1bcfSAlexander Graf 
5210efe1bcfSAlexander Graf #define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST               0x01,
5220efe1bcfSAlexander Graf #define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST             0x02,
5230efe1bcfSAlexander Graf #define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST             0x04,
5240efe1bcfSAlexander Graf #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS           0x08,
5250efe1bcfSAlexander Graf #define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10,
5260efe1bcfSAlexander Graf 
5270efe1bcfSAlexander Graf struct efi_simple_network
5280efe1bcfSAlexander Graf {
5290efe1bcfSAlexander Graf 	u64 revision;
5300efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *start)(struct efi_simple_network *this);
5310efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *stop)(struct efi_simple_network *this);
5320efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *initialize)(struct efi_simple_network *this,
5330efe1bcfSAlexander Graf 			ulong extra_rx, ulong extra_tx);
5340efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *reset)(struct efi_simple_network *this,
5350efe1bcfSAlexander Graf 			int extended_verification);
5360efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *shutdown)(struct efi_simple_network *this);
5370efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *receive_filters)(struct efi_simple_network *this,
5380efe1bcfSAlexander Graf 			u32 enable, u32 disable, int reset_mcast_filter,
5390efe1bcfSAlexander Graf 			ulong mcast_filter_count,
5400efe1bcfSAlexander Graf 			struct efi_mac_address *mcast_filter);
5410efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *station_address)(struct efi_simple_network *this,
5420efe1bcfSAlexander Graf 			int reset, struct efi_mac_address *new_mac);
5430efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *statistics)(struct efi_simple_network *this,
5440efe1bcfSAlexander Graf 			int reset, ulong *stat_size, void *stat_table);
5450efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *mcastiptomac)(struct efi_simple_network *this,
5460efe1bcfSAlexander Graf 			int ipv6, struct efi_ip_address *ip,
5470efe1bcfSAlexander Graf 			struct efi_mac_address *mac);
5480efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *nvdata)(struct efi_simple_network *this,
5490efe1bcfSAlexander Graf 			int read_write, ulong offset, ulong buffer_size,
5500efe1bcfSAlexander Graf 			char *buffer);
5510efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *get_status)(struct efi_simple_network *this,
5520efe1bcfSAlexander Graf 			u32 *int_status, void **txbuf);
5530efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *transmit)(struct efi_simple_network *this,
5540efe1bcfSAlexander Graf 			ulong header_size, ulong buffer_size, void *buffer,
5550efe1bcfSAlexander Graf 			struct efi_mac_address *src_addr,
5560efe1bcfSAlexander Graf 			struct efi_mac_address *dest_addr, u16 *protocol);
5570efe1bcfSAlexander Graf 	efi_status_t (EFIAPI *receive)(struct efi_simple_network *this,
5580efe1bcfSAlexander Graf 			ulong *header_size, ulong *buffer_size, void *buffer,
5590efe1bcfSAlexander Graf 			struct efi_mac_address *src_addr,
5600efe1bcfSAlexander Graf 			struct efi_mac_address *dest_addr, u16 *protocol);
5610efe1bcfSAlexander Graf 	void (EFIAPI *waitforpacket)(void);
5620efe1bcfSAlexander Graf 	struct efi_simple_network_mode *mode;
5630efe1bcfSAlexander Graf };
5640efe1bcfSAlexander Graf 
5650efe1bcfSAlexander Graf #define EFI_PXE_GUID \
5660efe1bcfSAlexander Graf 	EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \
5670efe1bcfSAlexander Graf 		 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
5680efe1bcfSAlexander Graf 
5690efe1bcfSAlexander Graf struct efi_pxe_packet {
5700efe1bcfSAlexander Graf 	u8 packet[1472];
5710efe1bcfSAlexander Graf };
5720efe1bcfSAlexander Graf 
5730efe1bcfSAlexander Graf struct efi_pxe_mode
5740efe1bcfSAlexander Graf {
5750efe1bcfSAlexander Graf 	u8 unused[52];
5760efe1bcfSAlexander Graf 	struct efi_pxe_packet dhcp_discover;
5770efe1bcfSAlexander Graf 	struct efi_pxe_packet dhcp_ack;
5780efe1bcfSAlexander Graf 	struct efi_pxe_packet proxy_offer;
5790efe1bcfSAlexander Graf 	struct efi_pxe_packet pxe_discover;
5800efe1bcfSAlexander Graf 	struct efi_pxe_packet pxe_reply;
5810efe1bcfSAlexander Graf };
5820efe1bcfSAlexander Graf 
5830efe1bcfSAlexander Graf struct efi_pxe {
5840efe1bcfSAlexander Graf 	u64 rev;
5850efe1bcfSAlexander Graf 	void (EFIAPI *start)(void);
5860efe1bcfSAlexander Graf 	void (EFIAPI *stop)(void);
5870efe1bcfSAlexander Graf 	void (EFIAPI *dhcp)(void);
5880efe1bcfSAlexander Graf 	void (EFIAPI *discover)(void);
5890efe1bcfSAlexander Graf 	void (EFIAPI *mftp)(void);
5900efe1bcfSAlexander Graf 	void (EFIAPI *udpwrite)(void);
5910efe1bcfSAlexander Graf 	void (EFIAPI *udpread)(void);
5920efe1bcfSAlexander Graf 	void (EFIAPI *setipfilter)(void);
5930efe1bcfSAlexander Graf 	void (EFIAPI *arp)(void);
5940efe1bcfSAlexander Graf 	void (EFIAPI *setparams)(void);
5950efe1bcfSAlexander Graf 	void (EFIAPI *setstationip)(void);
5960efe1bcfSAlexander Graf 	void (EFIAPI *setpackets)(void);
5970efe1bcfSAlexander Graf 	struct efi_pxe_mode *mode;
5980efe1bcfSAlexander Graf };
5990efe1bcfSAlexander Graf 
600867a6ac8SSimon Glass #endif
601