efi.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _ASM_EFI_H
  2. #define _ASM_EFI_H
  3. #include <asm/io.h>
  4. #include <asm/mmu_context.h>
  5. #include <asm/neon.h>
  6. #include <asm/tlbflush.h>
  7. #ifdef CONFIG_EFI
  8. extern void efi_init(void);
  9. #else
  10. #define efi_init()
  11. #endif
  12. int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
  13. #define efi_set_mapping_permissions efi_create_mapping
  14. #define efi_call_virt(f, ...) \
  15. ({ \
  16. efi_##f##_t *__f; \
  17. efi_status_t __s; \
  18. \
  19. kernel_neon_begin(); \
  20. efi_virtmap_load(); \
  21. __f = efi.systab->runtime->f; \
  22. __s = __f(__VA_ARGS__); \
  23. efi_virtmap_unload(); \
  24. kernel_neon_end(); \
  25. __s; \
  26. })
  27. #define __efi_call_virt(f, ...) \
  28. ({ \
  29. efi_##f##_t *__f; \
  30. \
  31. kernel_neon_begin(); \
  32. efi_virtmap_load(); \
  33. __f = efi.systab->runtime->f; \
  34. __f(__VA_ARGS__); \
  35. efi_virtmap_unload(); \
  36. kernel_neon_end(); \
  37. })
  38. /* arch specific definitions used by the stub code */
  39. /*
  40. * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from
  41. * start of kernel and may not cross a 2MiB boundary. We set alignment to
  42. * 2MiB so we know it won't cross a 2MiB boundary.
  43. */
  44. #define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */
  45. #define MAX_FDT_OFFSET SZ_512M
  46. #define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
  47. #define __efi_call_early(f, ...) f(__VA_ARGS__)
  48. #define efi_is_64bit() (true)
  49. #define alloc_screen_info(x...) &screen_info
  50. #define free_screen_info(x...)
  51. #define EFI_ALLOC_ALIGN SZ_64K
  52. /*
  53. * On ARM systems, virtually remapped UEFI runtime services are set up in two
  54. * distinct stages:
  55. * - The stub retrieves the final version of the memory map from UEFI, populates
  56. * the virt_addr fields and calls the SetVirtualAddressMap() [SVAM] runtime
  57. * service to communicate the new mapping to the firmware (Note that the new
  58. * mapping is not live at this time)
  59. * - During an early initcall(), the EFI system table is permanently remapped
  60. * and the virtual remapping of the UEFI Runtime Services regions is loaded
  61. * into a private set of page tables. If this all succeeds, the Runtime
  62. * Services are enabled and the EFI_RUNTIME_SERVICES bit set.
  63. */
  64. static inline void efi_set_pgd(struct mm_struct *mm)
  65. {
  66. switch_mm(NULL, mm, NULL);
  67. }
  68. void efi_virtmap_load(void);
  69. void efi_virtmap_unload(void);
  70. #endif /* _ASM_EFI_H */