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