1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Extensible Firmware Interface
4  * Based on 'Extensible Firmware Interface Specification' version 0.9,
5  * April 30, 1999
6  *
7  * Copyright (C) 1999 VA Linux Systems
8  * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
9  * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
10  *	David Mosberger-Tang <davidm@hpl.hp.com>
11  *	Stephane Eranian <eranian@hpl.hp.com>
12  *
13  * From include/linux/efi.h in kernel 4.1 with some additions/subtractions
14  */
15 
16 #ifndef _EFI_H
17 #define _EFI_H
18 
19 #include <linux/linkage.h>
20 #include <linux/string.h>
21 #include <linux/types.h>
22 
23 /* Type INTN in UEFI specification */
24 #define efi_intn_t ssize_t
25 /* Type UINTN in UEFI specification*/
26 #define efi_uintn_t size_t
27 
28 /*
29  * EFI on x86_64 uses the Microsoft ABI which is not the default for GCC.
30  *
31  * There are two scenarios for EFI on x86_64: building a 64-bit EFI stub
32  * codes (CONFIG_EFI_STUB_64BIT) and building a 64-bit U-Boot (CONFIG_X86_64).
33  * Either needs to be properly built with the '-m64' compiler flag, and hence
34  * it is enough to only check the compiler provided define __x86_64__ here.
35  */
36 #ifdef __x86_64__
37 #define EFIAPI __attribute__((ms_abi))
38 #define efi_va_list __builtin_ms_va_list
39 #define efi_va_start __builtin_ms_va_start
40 #define efi_va_copy __builtin_ms_va_copy
41 #define efi_va_arg __builtin_va_arg
42 #define efi_va_end __builtin_ms_va_end
43 #else
44 #define EFIAPI asmlinkage
45 #define efi_va_list va_list
46 #define efi_va_start va_start
47 #define efi_va_copy va_copy
48 #define efi_va_arg va_arg
49 #define efi_va_end va_end
50 #endif /* __x86_64__ */
51 
52 #define EFI32_LOADER_SIGNATURE	"EL32"
53 #define EFI64_LOADER_SIGNATURE	"EL64"
54 
55 /**
56  * struct efi_device_path - device path protocol
57  *
58  * @type:	device path type
59  * @sub_type:	device path sub-type
60  * @length:	length of the device path node including the header
61  */
62 struct efi_device_path {
63 	u8 type;
64 	u8 sub_type;
65 	u16 length;
66 } __packed;
67 
68 /*
69  * The EFI spec defines the EFI_GUID as
70  * "128-bit buffer containing a unique identifier value. Unless otherwise specified,
71  * aligned on a 64-bit boundary".
72  * Page 163 of the UEFI specification v2.10 and
73  * EDK2 reference implementation both define EFI_GUID as
74  * struct { u32 a; u16; b; u16 c; u8 d[8]; }; which is 4-byte
75  * aligned.
76  */
77 typedef struct {
78 	u8 b[16];
79 } efi_guid_t __attribute__((aligned(4)));
80 
81 #define EFI_BITS_PER_LONG	(sizeof(long) * 8)
82 
83 /* Bit mask for EFI status code with error */
84 #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1))
85 /* Status codes returned by EFI protocols */
86 #define EFI_SUCCESS			0
87 #define EFI_LOAD_ERROR			(EFI_ERROR_MASK | 1)
88 #define EFI_INVALID_PARAMETER		(EFI_ERROR_MASK | 2)
89 #define EFI_UNSUPPORTED			(EFI_ERROR_MASK | 3)
90 #define EFI_BAD_BUFFER_SIZE		(EFI_ERROR_MASK | 4)
91 #define EFI_BUFFER_TOO_SMALL		(EFI_ERROR_MASK | 5)
92 #define EFI_NOT_READY			(EFI_ERROR_MASK | 6)
93 #define EFI_DEVICE_ERROR		(EFI_ERROR_MASK | 7)
94 #define EFI_WRITE_PROTECTED		(EFI_ERROR_MASK | 8)
95 #define EFI_OUT_OF_RESOURCES		(EFI_ERROR_MASK | 9)
96 #define EFI_VOLUME_CORRUPTED		(EFI_ERROR_MASK | 10)
97 #define EFI_VOLUME_FULL			(EFI_ERROR_MASK | 11)
98 #define EFI_NO_MEDIA			(EFI_ERROR_MASK | 12)
99 #define EFI_MEDIA_CHANGED		(EFI_ERROR_MASK | 13)
100 #define EFI_NOT_FOUND			(EFI_ERROR_MASK | 14)
101 #define EFI_ACCESS_DENIED		(EFI_ERROR_MASK | 15)
102 #define EFI_NO_RESPONSE			(EFI_ERROR_MASK | 16)
103 #define EFI_NO_MAPPING			(EFI_ERROR_MASK | 17)
104 #define EFI_TIMEOUT			(EFI_ERROR_MASK | 18)
105 #define EFI_NOT_STARTED			(EFI_ERROR_MASK | 19)
106 #define EFI_ALREADY_STARTED		(EFI_ERROR_MASK | 20)
107 #define EFI_ABORTED			(EFI_ERROR_MASK | 21)
108 #define EFI_ICMP_ERROR			(EFI_ERROR_MASK | 22)
109 #define EFI_TFTP_ERROR			(EFI_ERROR_MASK | 23)
110 #define EFI_PROTOCOL_ERROR		(EFI_ERROR_MASK | 24)
111 #define EFI_INCOMPATIBLE_VERSION	(EFI_ERROR_MASK | 25)
112 #define EFI_SECURITY_VIOLATION		(EFI_ERROR_MASK | 26)
113 #define EFI_CRC_ERROR			(EFI_ERROR_MASK | 27)
114 #define EFI_END_OF_MEDIA		(EFI_ERROR_MASK | 28)
115 #define EFI_END_OF_FILE			(EFI_ERROR_MASK | 31)
116 #define EFI_INVALID_LANGUAGE		(EFI_ERROR_MASK | 32)
117 #define EFI_COMPROMISED_DATA		(EFI_ERROR_MASK | 33)
118 #define EFI_IP_ADDRESS_CONFLICT		(EFI_ERROR_MASK | 34)
119 #define EFI_HTTP_ERROR			(EFI_ERROR_MASK | 35)
120 
121 #define EFI_WARN_UNKNOWN_GLYPH		1
122 #define EFI_WARN_DELETE_FAILURE		2
123 #define EFI_WARN_WRITE_FAILURE		3
124 #define EFI_WARN_BUFFER_TOO_SMALL	4
125 #define EFI_WARN_STALE_DATA		5
126 #define EFI_WARN_FILE_SYSTEM		6
127 #define EFI_WARN_RESET_REQUIRED		7
128 
129 typedef unsigned long efi_status_t;
130 typedef u64 efi_physical_addr_t;
131 typedef u64 efi_virtual_addr_t;
132 typedef struct efi_object *efi_handle_t;
133 
134 #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
135 	{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
136 		((a) >> 24) & 0xff, \
137 		(b) & 0xff, ((b) >> 8) & 0xff, \
138 		(c) & 0xff, ((c) >> 8) & 0xff, \
139 		(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }
140 
141 /* Generic EFI table header */
142 struct efi_table_hdr {
143 	u64 signature;
144 	u32 revision;
145 	u32 headersize;
146 	u32 crc32;
147 	u32 reserved;
148 };
149 
150 /* Allocation types for calls to boottime->allocate_pages*/
151 /**
152  * enum efi_allocate_type - address restriction for memory allocation
153  */
154 enum efi_allocate_type {
155 	/**
156 	 * @EFI_ALLOCATE_ANY_PAGES:
157 	 * Allocate any block of sufficient size. Ignore memory address.
158 	 */
159 	EFI_ALLOCATE_ANY_PAGES,
160 	/**
161 	 * @EFI_ALLOCATE_MAX_ADDRESS:
162 	 * Allocate a memory block with an uppermost address less or equal
163 	 * to the indicated address.
164 	 */
165 	EFI_ALLOCATE_MAX_ADDRESS,
166 	/**
167 	 * @EFI_ALLOCATE_ADDRESS:
168 	 * Allocate a memory block starting at the indicatged adress.
169 	 */
170 	EFI_ALLOCATE_ADDRESS,
171 	/**
172 	 * @EFI_MAX_ALLOCATE_TYPE:
173 	 * Value use for range checking.
174 	 */
175 	EFI_MAX_ALLOCATE_TYPE,
176 };
177 
178 /* Enumeration of memory types introduced in UEFI */
179 enum efi_memory_type {
180 	EFI_RESERVED_MEMORY_TYPE,
181 	/*
182 	 * The code portions of a loaded application.
183 	 * (Note that UEFI OS loaders are UEFI applications.)
184 	 */
185 	EFI_LOADER_CODE,
186 	/*
187 	 * The data portions of a loaded application and
188 	 * the default data allocation type used by an application
189 	 * to allocate pool memory.
190 	 */
191 	EFI_LOADER_DATA,
192 	/* The code portions of a loaded Boot Services Driver */
193 	EFI_BOOT_SERVICES_CODE,
194 	/*
195 	 * The data portions of a loaded Boot Services Driver and
196 	 * the default data allocation type used by a Boot Services
197 	 * Driver to allocate pool memory.
198 	 */
199 	EFI_BOOT_SERVICES_DATA,
200 	/* The code portions of a loaded Runtime Services Driver */
201 	EFI_RUNTIME_SERVICES_CODE,
202 	/*
203 	 * The data portions of a loaded Runtime Services Driver and
204 	 * the default data allocation type used by a Runtime Services
205 	 * Driver to allocate pool memory.
206 	 */
207 	EFI_RUNTIME_SERVICES_DATA,
208 	/* Free (unallocated) memory */
209 	EFI_CONVENTIONAL_MEMORY,
210 	/* Memory in which errors have been detected */
211 	EFI_UNUSABLE_MEMORY,
212 	/* Memory that holds the ACPI tables */
213 	EFI_ACPI_RECLAIM_MEMORY,
214 	/* Address space reserved for use by the firmware */
215 	EFI_ACPI_MEMORY_NVS,
216 	/*
217 	 * Used by system firmware to request that a memory-mapped IO region
218 	 * be mapped by the OS to a virtual address so it can be accessed by
219 	 * EFI runtime services.
220 	 */
221 	EFI_MMAP_IO,
222 	/*
223 	 * System memory-mapped IO region that is used to translate
224 	 * memory cycles to IO cycles by the processor.
225 	 */
226 	EFI_MMAP_IO_PORT,
227 	/*
228 	 * Address space reserved by the firmware for code that is
229 	 * part of the processor.
230 	 */
231 	EFI_PAL_CODE,
232 	/*
233 	 * Byte addressable non-volatile memory.
234 	 */
235 	EFI_PERSISTENT_MEMORY_TYPE,
236 	/*
237 	 * Unaccepted memory must be accepted by boot target before usage.
238 	 */
239 	EFI_UNACCEPTED_MEMORY_TYPE,
240 
241 	EFI_MAX_MEMORY_TYPE,
242 };
243 
244 /* Attribute values */
245 #define EFI_MEMORY_UC		((u64)0x0000000000000001ULL)	/* uncached */
246 #define EFI_MEMORY_WC		((u64)0x0000000000000002ULL)	/* write-coalescing */
247 #define EFI_MEMORY_WT		((u64)0x0000000000000004ULL)	/* write-through */
248 #define EFI_MEMORY_WB		((u64)0x0000000000000008ULL)	/* write-back */
249 #define EFI_MEMORY_UCE		((u64)0x0000000000000010ULL)	/* uncached, exported */
250 #define EFI_MEMORY_WP		((u64)0x0000000000001000ULL)	/* write-protect */
251 #define EFI_MEMORY_RP		((u64)0x0000000000002000ULL)	/* read-protect */
252 #define EFI_MEMORY_XP		((u64)0x0000000000004000ULL)	/* execute-protect */
253 #define EFI_MEMORY_NV		((u64)0x0000000000008000ULL)	/* non-volatile */
254 #define EFI_MEMORY_MORE_RELIABLE \
255 				((u64)0x0000000000010000ULL)	/* higher reliability */
256 #define EFI_MEMORY_RO		((u64)0x0000000000020000ULL)	/* read-only */
257 #define EFI_MEMORY_SP		((u64)0x0000000000040000ULL)	/* specific-purpose memory (SPM) */
258 #define EFI_MEMORY_CPU_CRYPTO	((u64)0x0000000000080000ULL)	/* cryptographically protectable */
259 #define EFI_MEMORY_RUNTIME	((u64)0x8000000000000000ULL)	/* range requires runtime mapping */
260 #define EFI_MEM_DESC_VERSION	1
261 
262 #define EFI_PAGE_SHIFT		12
263 #define EFI_PAGE_SIZE		(1ULL << EFI_PAGE_SHIFT)
264 #define EFI_PAGE_MASK		(EFI_PAGE_SIZE - 1)
265 
266 struct efi_mem_desc {
267 	u32 type;
268 	u32 reserved;
269 	efi_physical_addr_t physical_start;
270 	efi_virtual_addr_t virtual_start;
271 	u64 num_pages;
272 	u64 attribute;
273 };
274 
275 #define EFI_MEMORY_DESCRIPTOR_VERSION 1
276 
277 /* Types and defines for Time Services */
278 #define EFI_TIME_ADJUST_DAYLIGHT 0x1
279 #define EFI_TIME_IN_DAYLIGHT     0x2
280 #define EFI_UNSPECIFIED_TIMEZONE 0x07ff
281 
282 struct efi_time {
283 	u16 year;
284 	u8 month;
285 	u8 day;
286 	u8 hour;
287 	u8 minute;
288 	u8 second;
289 	u8 pad1;
290 	u32 nanosecond;
291 	s16 timezone;
292 	u8 daylight;
293 	u8 pad2;
294 };
295 
296 struct efi_time_cap {
297 	u32 resolution;
298 	u32 accuracy;
299 	u8 sets_to_zero;
300 };
301 
302 enum efi_locate_search_type {
303 	ALL_HANDLES,
304 	BY_REGISTER_NOTIFY,
305 	BY_PROTOCOL
306 };
307 
308 struct efi_open_protocol_info_entry {
309 	efi_handle_t agent_handle;
310 	efi_handle_t controller_handle;
311 	u32 attributes;
312 	u32 open_count;
313 };
314 
315 enum efi_entry_t {
316 	EFIET_END,	/* Signals this is the last (empty) entry */
317 	EFIET_MEMORY_MAP,
318 	EFIET_GOP_MODE,
319 	EFIET_SYS_TABLE,
320 
321 	/* Number of entries */
322 	EFIET_MEMORY_COUNT,
323 };
324 
325 #define EFI_TABLE_VERSION	1
326 
327 /**
328  * struct efi_info_hdr - Header for the EFI info table
329  *
330  * @version:	EFI_TABLE_VERSION
331  * @hdr_size:	Size of this struct in bytes
332  * @total_size:	Total size of this header plus following data
333  * @spare:	Spare space for expansion
334  */
335 struct efi_info_hdr {
336 	u32 version;
337 	u32 hdr_size;
338 	u32 total_size;
339 	u32 spare[5];
340 };
341 
342 /**
343  * struct efi_entry_hdr - Header for a table entry
344  *
345  * @type:	enum eft_entry_t
346  * @size:	size of entry bytes excluding header and padding
347  * @addr:	address of this entry (0 if it follows the header )
348  * @link:	size of entry including header and padding
349  * @spare1:	Spare space for expansion
350  * @spare2:	Spare space for expansion
351  */
352 struct efi_entry_hdr {
353 	u32 type;
354 	u32 size;
355 	u64 addr;
356 	u32 link;
357 	u32 spare1;
358 	u64 spare2;
359 };
360 
361 /**
362  * struct efi_entry_memmap - a memory map table passed to U-Boot
363  *
364  * @version:	EFI's memory map table version
365  * @desc_size:	EFI's size of each memory descriptor
366  * @spare:	Spare space for expansion
367  * @desc:	An array of descriptors, each @desc_size bytes apart
368  */
369 struct efi_entry_memmap {
370 	u32 version;
371 	u32 desc_size;
372 	u64 spare;
373 	struct efi_mem_desc desc[];
374 };
375 
376 /**
377  * struct efi_entry_gopmode - a GOP mode table passed to U-Boot
378  *
379  * @fb_base:	EFI's framebuffer base address
380  * @fb_size:	EFI's framebuffer size
381  * @info_size:	GOP mode info structure size
382  * @info:	Start address of the GOP mode info structure
383  */
384 struct efi_entry_gopmode {
385 	efi_physical_addr_t fb_base;
386 	/*
387 	 * Not like the ones in 'struct efi_gop_mode' which are 'unsigned
388 	 * long', @fb_size and @info_size have to be 'u64' here. As the EFI
389 	 * stub codes may have different bit size from the U-Boot payload,
390 	 * using 'long' will cause mismatch between the producer (stub) and
391 	 * the consumer (payload).
392 	 */
393 	u64 fb_size;
394 	u64 info_size;
395 	/*
396 	 * We cannot directly use 'struct efi_gop_mode_info info[]' here as
397 	 * it causes compiler to complain: array type has incomplete element
398 	 * type 'struct efi_gop_mode_info'.
399 	 */
400 	struct /* efi_gop_mode_info */ {
401 		u32 version;
402 		u32 width;
403 		u32 height;
404 		u32 pixel_format;
405 		u32 pixel_bitmask[4];
406 		u32 pixels_per_scanline;
407 	} info[];
408 };
409 
410 /**
411  * struct efi_entry_systable - system table passed to U-Boot
412  *
413  * @sys_table:	EFI system table address
414  */
415 struct efi_entry_systable {
416 	efi_physical_addr_t sys_table;
417 };
418 
efi_get_next_mem_desc(struct efi_mem_desc * desc,int desc_size)419 static inline struct efi_mem_desc *efi_get_next_mem_desc(
420 		struct efi_mem_desc *desc, int desc_size)
421 {
422 	return (struct efi_mem_desc *)((ulong)desc + desc_size);
423 }
424 
425 /**
426  * struct efi_priv - Information about the environment provided by EFI
427  *
428  * @parent_image: image passed into the EFI app or stub
429  * @sys_table: Pointer to system table
430  * @boot: Pointer to boot-services table
431  * @run: Pointer to runtime-services table
432  * @memmap_key: Key returned from get_memory_map()
433  * @memmap_desc: List of memory-map records
434  * @memmap_alloc: Amount of memory allocated for memory map list
435  * @memmap_size Size of memory-map list in bytes
436  * @memmap_desc_size: Size of an individual memory-map record, in bytes
437  * @memmap_version: Memory-map version
438  *
439  * @use_pool_for_malloc: true if all allocation should go through the EFI 'pool'
440  *	methods allocate_pool() and free_pool(); false to use 'pages' methods
441  *	allocate_pages() and free_pages()
442  * @ram_base: Base address of RAM (size CONFIG_EFI_RAM_SIZE)
443  * @image_data_type: Type of the loaded image (e.g. EFI_LOADER_CODE)
444  *
445  * @info: Header of the info list, holding info collected by the stub and passed
446  *	to U-Boot
447  * @info_size: Size of the info list @info in bytes
448  * @next_hdr: Pointer to where to put the next header when adding to the list
449  */
450 struct efi_priv {
451 	efi_handle_t parent_image;
452 	struct efi_system_table *sys_table;
453 	struct efi_boot_services *boot;
454 	struct efi_runtime_services *run;
455 	efi_uintn_t memmap_key;
456 	struct efi_mem_desc *memmap_desc;
457 	efi_uintn_t memmap_alloc;
458 	efi_uintn_t memmap_size;
459 	efi_uintn_t memmap_desc_size;
460 	u32 memmap_version;
461 
462 	/* app: */
463 	bool use_pool_for_malloc;
464 	unsigned long ram_base;
465 	unsigned int image_data_type;
466 
467 	/* stub: */
468 	struct efi_info_hdr *info;
469 	unsigned int info_size;
470 	void *next_hdr;
471 };
472 
473 /*
474  * EFI attributes of the udevice handled by efi_media driver
475  *
476  * @handle: handle of the controller on which this driver is installed
477  * @blkio: block io protocol proxied by this driver
478  * @device_path: EFI path to the device
479  */
480 struct efi_media_plat {
481 	efi_handle_t handle;
482 	struct efi_block_io *blkio;
483 	struct efi_device_path *device_path;
484 };
485 
486 /* Base address of the EFI image */
487 extern char image_base[];
488 
489 /* Start and end of U-Boot image (for payload) */
490 extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[];
491 
492 /*
493  * Variable Attributes
494  */
495 #define EFI_VARIABLE_NON_VOLATILE       0x0000000000000001
496 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x0000000000000002
497 #define EFI_VARIABLE_RUNTIME_ACCESS     0x0000000000000004
498 #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x0000000000000008
499 #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x0000000000000010
500 #define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x0000000000000020
501 #define EFI_VARIABLE_APPEND_WRITE	0x0000000000000040
502 
503 #define EFI_VARIABLE_MASK	(EFI_VARIABLE_NON_VOLATILE | \
504 				EFI_VARIABLE_BOOTSERVICE_ACCESS | \
505 				EFI_VARIABLE_RUNTIME_ACCESS | \
506 				EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
507 				EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \
508 				EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
509 				EFI_VARIABLE_APPEND_WRITE)
510 
511 /**
512  * efi_get_priv() - Get access to the EFI-private information
513  *
514  * This struct it used by both the stub and the app to record things about the
515  * EFI environment. It is not available in U-Boot proper after the stub has
516  * jumped there. Use efi_info_get() to obtain info in that case.
517  *
518  * Return: pointer to private info
519  */
520 struct efi_priv *efi_get_priv(void);
521 
522 /**
523  * efi_set_priv() - Set up a pointer to the EFI-private information
524  *
525  * This is called in the stub and app to record the location of this
526  * information.
527  *
528  * @priv: New location of private data
529  */
530 void efi_set_priv(struct efi_priv *priv);
531 
532 /**
533  * efi_get_sys_table() - Get access to the main EFI system table
534  *
535  * Returns: pointer to EFI system table
536  */
537 struct efi_system_table *efi_get_sys_table(void);
538 
539 /**
540  * efi_get_boot() - Get access to the EFI boot services table
541  *
542  * Returns: pointer to EFI boot services table
543  */
544 struct efi_boot_services *efi_get_boot(void);
545 
546 /**
547  * efi_get_ram_base() - Find the base of RAM
548  *
549  * This is used when U-Boot is built as an EFI application.
550  *
551  * Returns: the base of RAM as known to U-Boot
552  */
553 unsigned long efi_get_ram_base(void);
554 
555 /**
556  * efi_init() - Set up ready for use of EFI boot services
557  *
558  * @priv:	Pointer to our private EFI structure to fill in
559  * @banner:	Banner to display when starting
560  * @image:	The image handle passed to efi_main()
561  * @sys_table:	The EFI system table pointer passed to efi_main()
562  * Return: 0 on succcess, EFI error code on failure
563  */
564 int efi_init(struct efi_priv *priv, const char *banner, efi_handle_t image,
565 	     struct efi_system_table *sys_table);
566 
567 /**
568  * efi_malloc() - Allocate some memory from EFI
569  *
570  * @priv:	Pointer to private EFI structure
571  * @size:	Number of bytes to allocate
572  * @retp:	Return EFI status result
573  * Returns: pointer to memory allocated, or NULL on error
574  */
575 void *efi_malloc(struct efi_priv *priv, int size, efi_status_t *retp);
576 
577 /**
578  * efi_free() - Free memory allocated from EFI
579  *
580  * @priv:	Pointer to private EFI structure
581  * @ptr:	Pointer to memory to free
582  */
583 void efi_free(struct efi_priv *priv, void *ptr);
584 
585 /**
586  * efi_puts() - Write out a string to the EFI console
587  *
588  * @priv:	Pointer to private EFI structure
589  * @str:	String to write (note this is a ASCII, not unicode)
590  */
591 void efi_puts(struct efi_priv *priv, const char *str);
592 
593 /**
594  * efi_putc() - Write out a character to the EFI console
595  *
596  * @priv:	Pointer to private EFI structure
597  * @ch:		Character to write (note this is not unicode)
598  */
599 void efi_putc(struct efi_priv *priv, const char ch);
600 
601 /**
602  * efi_info_get() - get an entry from an EFI table
603  *
604  * This function is called from U-Boot proper to read information set up by the
605  * EFI stub. It can only be used when running from the EFI stub, not when U-Boot
606  * is running as an app.
607  *
608  * @type:	Entry type to search for
609  * @datap:	Returns pointer to entry data
610  * @sizep:	Returns entry size
611  * Return: 0 if OK, -ENODATA if there is no table, -ENOENT if there is no entry
612  * of the requested type, -EPROTONOSUPPORT if the table has the wrong version
613  */
614 int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
615 
616 /**
617  * efi_store_memory_map() - Collect the memory-map info from EFI
618  *
619  * Collect the memory info and store it for later use, e.g. in calling
620  * exit_boot_services()
621  *
622  * @priv:	Pointer to private EFI structure
623  * Returns: 0 if OK, non-zero on error
624  */
625 int efi_store_memory_map(struct efi_priv *priv);
626 
627 /**
628  * efi_call_exit_boot_services() - Handle the exit-boot-service procedure
629  *
630  * Tell EFI we don't want their boot services anymore
631  *
632  * Return: 0 if OK, non-zero on error
633  */
634 int efi_call_exit_boot_services(void);
635 
636 /**
637  * efi_get_mmap() - Get the memory map from EFI
638  *
639  * This is used in the app. The caller must free *@descp when done
640  *
641  * @descp:	Returns allocated pointer to EFI memory map table
642  * @sizep:	Returns size of table in bytes
643  * @keyp:	Returns memory-map key
644  * @desc_sizep:	Returns size of each @desc_base record
645  * @versionp:	Returns version number of memory map
646  * Returns: 0 on success, -ve on error
647  */
648 int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
649 		 int *desc_sizep, uint *versionp);
650 
651 /**
652  * efi_show_tables() - Show a list of available tables
653  *
654  * Shows the address, GUID (and name where known) for each table
655  *
656  * @systab: System table containing the list of tables
657  */
658 void efi_show_tables(struct efi_system_table *systab);
659 
660 #endif /* _LINUX_EFI_H */
661