efistub.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _DRIVERS_FIRMWARE_EFI_EFISTUB_H
  3. #define _DRIVERS_FIRMWARE_EFI_EFISTUB_H
  4. /* error code which can't be mistaken for valid address */
  5. #define EFI_ERROR (~0UL)
  6. /*
  7. * __init annotations should not be used in the EFI stub, since the code is
  8. * either included in the decompressor (x86, ARM) where they have no effect,
  9. * or the whole stub is __init annotated at the section level (arm64), by
  10. * renaming the sections, in which case the __init annotation will be
  11. * redundant, and will result in section names like .init.init.text, and our
  12. * linker script does not expect that.
  13. */
  14. #undef __init
  15. /*
  16. * Allow the platform to override the allocation granularity: this allows
  17. * systems that have the capability to run with a larger page size to deal
  18. * with the allocations for initrd and fdt more efficiently.
  19. */
  20. #ifndef EFI_ALLOC_ALIGN
  21. #define EFI_ALLOC_ALIGN EFI_PAGE_SIZE
  22. #endif
  23. extern int __pure nokaslr(void);
  24. extern int __pure is_quiet(void);
  25. extern int __pure novamap(void);
  26. #define pr_efi(sys_table, msg) do { \
  27. if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \
  28. } while (0)
  29. #define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg)
  30. void efi_char16_printk(efi_system_table_t *, efi_char16_t *);
  31. unsigned long get_dram_base(efi_system_table_t *sys_table_arg);
  32. efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
  33. void *handle,
  34. unsigned long *new_fdt_addr,
  35. unsigned long max_addr,
  36. u64 initrd_addr, u64 initrd_size,
  37. char *cmdline_ptr,
  38. unsigned long fdt_addr,
  39. unsigned long fdt_size);
  40. void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size);
  41. void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
  42. unsigned long desc_size, efi_memory_desc_t *runtime_map,
  43. int *count);
  44. efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table,
  45. unsigned long size, u8 *out);
  46. efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
  47. unsigned long size, unsigned long align,
  48. unsigned long *addr, unsigned long random_seed);
  49. efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
  50. efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
  51. #endif