1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H
4 #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H
5 
6 #include <linux/efi.h>
7 #include <linux/kernel.h>
8 #include <linux/types.h>
9 #include <asm/efi.h>
10 
11 /* error code which can't be mistaken for valid address */
12 #define EFI_ERROR	(~0UL)
13 
14 /*
15  * __init annotations should not be used in the EFI stub, since the code is
16  * either included in the decompressor (x86, ARM) where they have no effect,
17  * or the whole stub is __init annotated at the section level (arm64), by
18  * renaming the sections, in which case the __init annotation will be
19  * redundant, and will result in section names like .init.init.text, and our
20  * linker script does not expect that.
21  */
22 #undef __init
23 
24 /*
25  * Allow the platform to override the allocation granularity: this allows
26  * systems that have the capability to run with a larger page size to deal
27  * with the allocations for initrd and fdt more efficiently.
28  */
29 #ifndef EFI_ALLOC_ALIGN
30 #define EFI_ALLOC_ALIGN		EFI_PAGE_SIZE
31 #endif
32 
33 extern bool efi_nochunk;
34 extern bool efi_nokaslr;
35 extern bool efi_noinitrd;
36 extern bool efi_quiet;
37 extern bool efi_novamap;
38 
39 extern const efi_system_table_t *efi_system_table;
40 
41 #ifndef ARCH_HAS_EFISTUB_WRAPPERS
42 
43 #define efi_is_native()		(true)
44 #define efi_bs_call(func, ...)	efi_system_table->boottime->func(__VA_ARGS__)
45 #define efi_rt_call(func, ...)	efi_system_table->runtime->func(__VA_ARGS__)
46 #define efi_table_attr(inst, attr)	(inst->attr)
47 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
48 
49 #endif
50 
51 #define efi_info(msg)		do {			\
52 	if (!efi_quiet) efi_puts("EFI stub: "msg);	\
53 } while (0)
54 
55 #define efi_err(msg) efi_puts("EFI stub: ERROR: "msg)
56 
57 /* Helper macros for the usual case of using simple C variables: */
58 #ifndef fdt_setprop_inplace_var
59 #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
60 	fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var))
61 #endif
62 
63 #ifndef fdt_setprop_var
64 #define fdt_setprop_var(fdt, node_offset, name, var) \
65 	fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var))
66 #endif
67 
68 #define get_efi_var(name, vendor, ...)				\
69 	efi_rt_call(get_variable, (efi_char16_t *)(name),	\
70 		    (efi_guid_t *)(vendor), __VA_ARGS__)
71 
72 #define set_efi_var(name, vendor, ...)				\
73 	efi_rt_call(set_variable, (efi_char16_t *)(name),	\
74 		    (efi_guid_t *)(vendor), __VA_ARGS__)
75 
76 #define efi_get_handle_at(array, idx)					\
77 	(efi_is_native() ? (array)[idx] 				\
78 		: (efi_handle_t)(unsigned long)((u32 *)(array))[idx])
79 
80 #define efi_get_handle_num(size)					\
81 	((size) / (efi_is_native() ? sizeof(efi_handle_t) : sizeof(u32)))
82 
83 #define for_each_efi_handle(handle, array, size, i)			\
84 	for (i = 0;							\
85 	     i < efi_get_handle_num(size) &&				\
86 		((handle = efi_get_handle_at((array), i)) || true);	\
87 	     i++)
88 
89 static inline
90 void efi_set_u64_split(u64 data, u32 *lo, u32 *hi)
91 {
92 	*lo = lower_32_bits(data);
93 	*hi = upper_32_bits(data);
94 }
95 
96 /*
97  * Allocation types for calls to boottime->allocate_pages.
98  */
99 #define EFI_ALLOCATE_ANY_PAGES		0
100 #define EFI_ALLOCATE_MAX_ADDRESS	1
101 #define EFI_ALLOCATE_ADDRESS		2
102 #define EFI_MAX_ALLOCATE_TYPE		3
103 
104 /*
105  * The type of search to perform when calling boottime->locate_handle
106  */
107 #define EFI_LOCATE_ALL_HANDLES			0
108 #define EFI_LOCATE_BY_REGISTER_NOTIFY		1
109 #define EFI_LOCATE_BY_PROTOCOL			2
110 
111 struct efi_boot_memmap {
112 	efi_memory_desc_t	**map;
113 	unsigned long		*map_size;
114 	unsigned long		*desc_size;
115 	u32			*desc_ver;
116 	unsigned long		*key_ptr;
117 	unsigned long		*buff_size;
118 };
119 
120 typedef struct efi_generic_dev_path efi_device_path_protocol_t;
121 
122 /*
123  * EFI Boot Services table
124  */
125 union efi_boot_services {
126 	struct {
127 		efi_table_hdr_t hdr;
128 		void *raise_tpl;
129 		void *restore_tpl;
130 		efi_status_t (__efiapi *allocate_pages)(int, int, unsigned long,
131 							efi_physical_addr_t *);
132 		efi_status_t (__efiapi *free_pages)(efi_physical_addr_t,
133 						    unsigned long);
134 		efi_status_t (__efiapi *get_memory_map)(unsigned long *, void *,
135 							unsigned long *,
136 							unsigned long *, u32 *);
137 		efi_status_t (__efiapi *allocate_pool)(int, unsigned long,
138 						       void **);
139 		efi_status_t (__efiapi *free_pool)(void *);
140 		void *create_event;
141 		void *set_timer;
142 		void *wait_for_event;
143 		void *signal_event;
144 		void *close_event;
145 		void *check_event;
146 		void *install_protocol_interface;
147 		void *reinstall_protocol_interface;
148 		void *uninstall_protocol_interface;
149 		efi_status_t (__efiapi *handle_protocol)(efi_handle_t,
150 							 efi_guid_t *, void **);
151 		void *__reserved;
152 		void *register_protocol_notify;
153 		efi_status_t (__efiapi *locate_handle)(int, efi_guid_t *,
154 						       void *, unsigned long *,
155 						       efi_handle_t *);
156 		efi_status_t (__efiapi *locate_device_path)(efi_guid_t *,
157 							    efi_device_path_protocol_t **,
158 							    efi_handle_t *);
159 		efi_status_t (__efiapi *install_configuration_table)(efi_guid_t *,
160 								     void *);
161 		void *load_image;
162 		void *start_image;
163 		efi_status_t __noreturn (__efiapi *exit)(efi_handle_t,
164 							 efi_status_t,
165 							 unsigned long,
166 							 efi_char16_t *);
167 		void *unload_image;
168 		efi_status_t (__efiapi *exit_boot_services)(efi_handle_t,
169 							    unsigned long);
170 		void *get_next_monotonic_count;
171 		void *stall;
172 		void *set_watchdog_timer;
173 		void *connect_controller;
174 		efi_status_t (__efiapi *disconnect_controller)(efi_handle_t,
175 							       efi_handle_t,
176 							       efi_handle_t);
177 		void *open_protocol;
178 		void *close_protocol;
179 		void *open_protocol_information;
180 		void *protocols_per_handle;
181 		void *locate_handle_buffer;
182 		efi_status_t (__efiapi *locate_protocol)(efi_guid_t *, void *,
183 							 void **);
184 		void *install_multiple_protocol_interfaces;
185 		void *uninstall_multiple_protocol_interfaces;
186 		void *calculate_crc32;
187 		void *copy_mem;
188 		void *set_mem;
189 		void *create_event_ex;
190 	};
191 	struct {
192 		efi_table_hdr_t hdr;
193 		u32 raise_tpl;
194 		u32 restore_tpl;
195 		u32 allocate_pages;
196 		u32 free_pages;
197 		u32 get_memory_map;
198 		u32 allocate_pool;
199 		u32 free_pool;
200 		u32 create_event;
201 		u32 set_timer;
202 		u32 wait_for_event;
203 		u32 signal_event;
204 		u32 close_event;
205 		u32 check_event;
206 		u32 install_protocol_interface;
207 		u32 reinstall_protocol_interface;
208 		u32 uninstall_protocol_interface;
209 		u32 handle_protocol;
210 		u32 __reserved;
211 		u32 register_protocol_notify;
212 		u32 locate_handle;
213 		u32 locate_device_path;
214 		u32 install_configuration_table;
215 		u32 load_image;
216 		u32 start_image;
217 		u32 exit;
218 		u32 unload_image;
219 		u32 exit_boot_services;
220 		u32 get_next_monotonic_count;
221 		u32 stall;
222 		u32 set_watchdog_timer;
223 		u32 connect_controller;
224 		u32 disconnect_controller;
225 		u32 open_protocol;
226 		u32 close_protocol;
227 		u32 open_protocol_information;
228 		u32 protocols_per_handle;
229 		u32 locate_handle_buffer;
230 		u32 locate_protocol;
231 		u32 install_multiple_protocol_interfaces;
232 		u32 uninstall_multiple_protocol_interfaces;
233 		u32 calculate_crc32;
234 		u32 copy_mem;
235 		u32 set_mem;
236 		u32 create_event_ex;
237 	} mixed_mode;
238 };
239 
240 typedef union efi_uga_draw_protocol efi_uga_draw_protocol_t;
241 
242 union efi_uga_draw_protocol {
243 	struct {
244 		efi_status_t (__efiapi *get_mode)(efi_uga_draw_protocol_t *,
245 						  u32*, u32*, u32*, u32*);
246 		void *set_mode;
247 		void *blt;
248 	};
249 	struct {
250 		u32 get_mode;
251 		u32 set_mode;
252 		u32 blt;
253 	} mixed_mode;
254 };
255 
256 union efi_simple_text_output_protocol {
257 	struct {
258 		void *reset;
259 		efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *,
260 						       efi_char16_t *);
261 		void *test_string;
262 	};
263 	struct {
264 		u32 reset;
265 		u32 output_string;
266 		u32 test_string;
267 	} mixed_mode;
268 };
269 
270 #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR		0
271 #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR		1
272 #define PIXEL_BIT_MASK					2
273 #define PIXEL_BLT_ONLY					3
274 #define PIXEL_FORMAT_MAX				4
275 
276 typedef struct {
277 	u32 red_mask;
278 	u32 green_mask;
279 	u32 blue_mask;
280 	u32 reserved_mask;
281 } efi_pixel_bitmask_t;
282 
283 typedef struct {
284 	u32 version;
285 	u32 horizontal_resolution;
286 	u32 vertical_resolution;
287 	int pixel_format;
288 	efi_pixel_bitmask_t pixel_information;
289 	u32 pixels_per_scan_line;
290 } efi_graphics_output_mode_info_t;
291 
292 typedef union efi_graphics_output_protocol_mode efi_graphics_output_protocol_mode_t;
293 
294 union efi_graphics_output_protocol_mode {
295 	struct {
296 		u32 max_mode;
297 		u32 mode;
298 		efi_graphics_output_mode_info_t *info;
299 		unsigned long size_of_info;
300 		efi_physical_addr_t frame_buffer_base;
301 		unsigned long frame_buffer_size;
302 	};
303 	struct {
304 		u32 max_mode;
305 		u32 mode;
306 		u32 info;
307 		u32 size_of_info;
308 		u64 frame_buffer_base;
309 		u32 frame_buffer_size;
310 	} mixed_mode;
311 };
312 
313 typedef union efi_graphics_output_protocol efi_graphics_output_protocol_t;
314 
315 union efi_graphics_output_protocol {
316 	struct {
317 		efi_status_t (__efiapi *query_mode)(efi_graphics_output_protocol_t *,
318 						    u32, unsigned long *,
319 						    efi_graphics_output_mode_info_t **);
320 		efi_status_t (__efiapi *set_mode)  (efi_graphics_output_protocol_t *, u32);
321 		void *blt;
322 		efi_graphics_output_protocol_mode_t *mode;
323 	};
324 	struct {
325 		u32 query_mode;
326 		u32 set_mode;
327 		u32 blt;
328 		u32 mode;
329 	} mixed_mode;
330 };
331 
332 typedef union {
333 	struct {
334 		u32			revision;
335 		efi_handle_t		parent_handle;
336 		efi_system_table_t	*system_table;
337 		efi_handle_t		device_handle;
338 		void			*file_path;
339 		void			*reserved;
340 		u32			load_options_size;
341 		void			*load_options;
342 		void			*image_base;
343 		__aligned_u64		image_size;
344 		unsigned int		image_code_type;
345 		unsigned int		image_data_type;
346 		efi_status_t		(__efiapi *unload)(efi_handle_t image_handle);
347 	};
348 	struct {
349 		u32		revision;
350 		u32		parent_handle;
351 		u32		system_table;
352 		u32		device_handle;
353 		u32		file_path;
354 		u32		reserved;
355 		u32		load_options_size;
356 		u32		load_options;
357 		u32		image_base;
358 		__aligned_u64	image_size;
359 		u32		image_code_type;
360 		u32		image_data_type;
361 		u32		unload;
362 	} mixed_mode;
363 } efi_loaded_image_t;
364 
365 typedef struct {
366 	u64			size;
367 	u64			file_size;
368 	u64			phys_size;
369 	efi_time_t		create_time;
370 	efi_time_t		last_access_time;
371 	efi_time_t		modification_time;
372 	__aligned_u64		attribute;
373 	efi_char16_t		filename[];
374 } efi_file_info_t;
375 
376 typedef struct efi_file_protocol efi_file_protocol_t;
377 
378 struct efi_file_protocol {
379 	u64		revision;
380 	efi_status_t	(__efiapi *open)	(efi_file_protocol_t *,
381 						 efi_file_protocol_t **,
382 						 efi_char16_t *, u64, u64);
383 	efi_status_t	(__efiapi *close)	(efi_file_protocol_t *);
384 	efi_status_t	(__efiapi *delete)	(efi_file_protocol_t *);
385 	efi_status_t	(__efiapi *read)	(efi_file_protocol_t *,
386 						 unsigned long *, void *);
387 	efi_status_t	(__efiapi *write)	(efi_file_protocol_t *,
388 						 unsigned long, void *);
389 	efi_status_t	(__efiapi *get_position)(efi_file_protocol_t *, u64 *);
390 	efi_status_t	(__efiapi *set_position)(efi_file_protocol_t *, u64);
391 	efi_status_t	(__efiapi *get_info)	(efi_file_protocol_t *,
392 						 efi_guid_t *, unsigned long *,
393 						 void *);
394 	efi_status_t	(__efiapi *set_info)	(efi_file_protocol_t *,
395 						 efi_guid_t *, unsigned long,
396 						 void *);
397 	efi_status_t	(__efiapi *flush)	(efi_file_protocol_t *);
398 };
399 
400 typedef struct efi_simple_file_system_protocol efi_simple_file_system_protocol_t;
401 
402 struct efi_simple_file_system_protocol {
403 	u64	revision;
404 	int	(__efiapi *open_volume)(efi_simple_file_system_protocol_t *,
405 					efi_file_protocol_t **);
406 };
407 
408 #define EFI_FILE_MODE_READ	0x0000000000000001
409 #define EFI_FILE_MODE_WRITE	0x0000000000000002
410 #define EFI_FILE_MODE_CREATE	0x8000000000000000
411 
412 typedef enum {
413 	EfiPciIoWidthUint8,
414 	EfiPciIoWidthUint16,
415 	EfiPciIoWidthUint32,
416 	EfiPciIoWidthUint64,
417 	EfiPciIoWidthFifoUint8,
418 	EfiPciIoWidthFifoUint16,
419 	EfiPciIoWidthFifoUint32,
420 	EfiPciIoWidthFifoUint64,
421 	EfiPciIoWidthFillUint8,
422 	EfiPciIoWidthFillUint16,
423 	EfiPciIoWidthFillUint32,
424 	EfiPciIoWidthFillUint64,
425 	EfiPciIoWidthMaximum
426 } EFI_PCI_IO_PROTOCOL_WIDTH;
427 
428 typedef enum {
429 	EfiPciIoAttributeOperationGet,
430 	EfiPciIoAttributeOperationSet,
431 	EfiPciIoAttributeOperationEnable,
432 	EfiPciIoAttributeOperationDisable,
433 	EfiPciIoAttributeOperationSupported,
434     EfiPciIoAttributeOperationMaximum
435 } EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
436 
437 typedef struct {
438 	u32 read;
439 	u32 write;
440 } efi_pci_io_protocol_access_32_t;
441 
442 typedef union efi_pci_io_protocol efi_pci_io_protocol_t;
443 
444 typedef
445 efi_status_t (__efiapi *efi_pci_io_protocol_cfg_t)(efi_pci_io_protocol_t *,
446 						   EFI_PCI_IO_PROTOCOL_WIDTH,
447 						   u32 offset,
448 						   unsigned long count,
449 						   void *buffer);
450 
451 typedef struct {
452 	void *read;
453 	void *write;
454 } efi_pci_io_protocol_access_t;
455 
456 typedef struct {
457 	efi_pci_io_protocol_cfg_t read;
458 	efi_pci_io_protocol_cfg_t write;
459 } efi_pci_io_protocol_config_access_t;
460 
461 union efi_pci_io_protocol {
462 	struct {
463 		void *poll_mem;
464 		void *poll_io;
465 		efi_pci_io_protocol_access_t mem;
466 		efi_pci_io_protocol_access_t io;
467 		efi_pci_io_protocol_config_access_t pci;
468 		void *copy_mem;
469 		void *map;
470 		void *unmap;
471 		void *allocate_buffer;
472 		void *free_buffer;
473 		void *flush;
474 		efi_status_t (__efiapi *get_location)(efi_pci_io_protocol_t *,
475 						      unsigned long *segment_nr,
476 						      unsigned long *bus_nr,
477 						      unsigned long *device_nr,
478 						      unsigned long *func_nr);
479 		void *attributes;
480 		void *get_bar_attributes;
481 		void *set_bar_attributes;
482 		uint64_t romsize;
483 		void *romimage;
484 	};
485 	struct {
486 		u32 poll_mem;
487 		u32 poll_io;
488 		efi_pci_io_protocol_access_32_t mem;
489 		efi_pci_io_protocol_access_32_t io;
490 		efi_pci_io_protocol_access_32_t pci;
491 		u32 copy_mem;
492 		u32 map;
493 		u32 unmap;
494 		u32 allocate_buffer;
495 		u32 free_buffer;
496 		u32 flush;
497 		u32 get_location;
498 		u32 attributes;
499 		u32 get_bar_attributes;
500 		u32 set_bar_attributes;
501 		u64 romsize;
502 		u32 romimage;
503 	} mixed_mode;
504 };
505 
506 #define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
507 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002
508 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004
509 #define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008
510 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010
511 #define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
512 #define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
513 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
514 #define EFI_PCI_IO_ATTRIBUTE_IO 0x0100
515 #define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200
516 #define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400
517 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800
518 #define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000
519 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000
520 #define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000
521 #define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
522 #define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000
523 #define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
524 #define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000
525 
526 struct efi_dev_path;
527 
528 typedef union apple_properties_protocol apple_properties_protocol_t;
529 
530 union apple_properties_protocol {
531 	struct {
532 		unsigned long version;
533 		efi_status_t (__efiapi *get)(apple_properties_protocol_t *,
534 					     struct efi_dev_path *,
535 					     efi_char16_t *, void *, u32 *);
536 		efi_status_t (__efiapi *set)(apple_properties_protocol_t *,
537 					     struct efi_dev_path *,
538 					     efi_char16_t *, void *, u32);
539 		efi_status_t (__efiapi *del)(apple_properties_protocol_t *,
540 					     struct efi_dev_path *,
541 					     efi_char16_t *);
542 		efi_status_t (__efiapi *get_all)(apple_properties_protocol_t *,
543 						 void *buffer, u32 *);
544 	};
545 	struct {
546 		u32 version;
547 		u32 get;
548 		u32 set;
549 		u32 del;
550 		u32 get_all;
551 	} mixed_mode;
552 };
553 
554 typedef u32 efi_tcg2_event_log_format;
555 
556 typedef union efi_tcg2_protocol efi_tcg2_protocol_t;
557 
558 union efi_tcg2_protocol {
559 	struct {
560 		void *get_capability;
561 		efi_status_t (__efiapi *get_event_log)(efi_handle_t,
562 						       efi_tcg2_event_log_format,
563 						       efi_physical_addr_t *,
564 						       efi_physical_addr_t *,
565 						       efi_bool_t *);
566 		void *hash_log_extend_event;
567 		void *submit_command;
568 		void *get_active_pcr_banks;
569 		void *set_active_pcr_banks;
570 		void *get_result_of_set_active_pcr_banks;
571 	};
572 	struct {
573 		u32 get_capability;
574 		u32 get_event_log;
575 		u32 hash_log_extend_event;
576 		u32 submit_command;
577 		u32 get_active_pcr_banks;
578 		u32 set_active_pcr_banks;
579 		u32 get_result_of_set_active_pcr_banks;
580 	} mixed_mode;
581 };
582 
583 typedef union efi_load_file_protocol efi_load_file_protocol_t;
584 typedef union efi_load_file_protocol efi_load_file2_protocol_t;
585 
586 union efi_load_file_protocol {
587 	struct {
588 		efi_status_t (__efiapi *load_file)(efi_load_file_protocol_t *,
589 						   efi_device_path_protocol_t *,
590 						   bool, unsigned long *, void *);
591 	};
592 	struct {
593 		u32 load_file;
594 	} mixed_mode;
595 };
596 
597 void efi_pci_disable_bridge_busmaster(void);
598 
599 typedef efi_status_t (*efi_exit_boot_map_processing)(
600 	struct efi_boot_memmap *map,
601 	void *priv);
602 
603 efi_status_t efi_exit_boot_services(void *handle,
604 				    struct efi_boot_memmap *map,
605 				    void *priv,
606 				    efi_exit_boot_map_processing priv_func);
607 
608 efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
609 					    unsigned long *new_fdt_addr,
610 					    unsigned long max_addr,
611 					    u64 initrd_addr, u64 initrd_size,
612 					    char *cmdline_ptr,
613 					    unsigned long fdt_addr,
614 					    unsigned long fdt_size);
615 
616 void *get_fdt(unsigned long *fdt_size);
617 
618 void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
619 		     unsigned long desc_size, efi_memory_desc_t *runtime_map,
620 		     int *count);
621 
622 efi_status_t efi_get_random_bytes(unsigned long size, u8 *out);
623 
624 efi_status_t efi_random_alloc(unsigned long size, unsigned long align,
625 			      unsigned long *addr, unsigned long random_seed);
626 
627 efi_status_t check_platform_features(void);
628 
629 void *get_efi_config_table(efi_guid_t guid);
630 
631 /* NOTE: These functions do not print a trailing newline after the string */
632 void efi_char16_puts(efi_char16_t *);
633 void efi_puts(const char *str);
634 
635 void efi_free(unsigned long size, unsigned long addr);
636 
637 char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len,
638 			  unsigned long max_addr);
639 
640 efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
641 
642 efi_status_t efi_allocate_pages(unsigned long size, unsigned long *addr,
643 				unsigned long max);
644 
645 efi_status_t efi_allocate_pages_aligned(unsigned long size, unsigned long *addr,
646 					unsigned long max, unsigned long align);
647 
648 efi_status_t efi_relocate_kernel(unsigned long *image_addr,
649 				 unsigned long image_size,
650 				 unsigned long alloc_size,
651 				 unsigned long preferred_addr,
652 				 unsigned long alignment,
653 				 unsigned long min_addr);
654 
655 efi_status_t efi_parse_options(char const *cmdline);
656 
657 void efi_parse_option_graphics(char *option);
658 
659 efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
660 			   unsigned long size);
661 
662 efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
663 				  const efi_char16_t *optstr,
664 				  int optstr_size,
665 				  unsigned long soft_limit,
666 				  unsigned long hard_limit,
667 				  unsigned long *load_addr,
668 				  unsigned long *load_size);
669 
670 
671 static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image,
672 					unsigned long *load_addr,
673 					unsigned long *load_size)
674 {
675 	return handle_cmdline_files(image, L"dtb=", sizeof(L"dtb=") - 2,
676 				    ULONG_MAX, ULONG_MAX, load_addr, load_size);
677 }
678 
679 efi_status_t efi_load_initrd(efi_loaded_image_t *image,
680 			     unsigned long *load_addr,
681 			     unsigned long *load_size,
682 			     unsigned long soft_limit,
683 			     unsigned long hard_limit);
684 
685 #endif
686