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