efi.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef _ASM_X86_EFI_H
  2. #define _ASM_X86_EFI_H
  3. #ifdef CONFIG_X86_32
  4. #define EFI_LOADER_SIGNATURE "EL32"
  5. extern unsigned long asmlinkage efi_call_phys(void *, ...);
  6. #define efi_call_phys0(f) efi_call_phys(f)
  7. #define efi_call_phys1(f, a1) efi_call_phys(f, a1)
  8. #define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2)
  9. #define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3)
  10. #define efi_call_phys4(f, a1, a2, a3, a4) \
  11. efi_call_phys(f, a1, a2, a3, a4)
  12. #define efi_call_phys5(f, a1, a2, a3, a4, a5) \
  13. efi_call_phys(f, a1, a2, a3, a4, a5)
  14. #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
  15. efi_call_phys(f, a1, a2, a3, a4, a5, a6)
  16. /*
  17. * Wrap all the virtual calls in a way that forces the parameters on the stack.
  18. */
  19. #define efi_call_virt(f, args...) \
  20. ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
  21. #define efi_call_virt0(f) efi_call_virt(f)
  22. #define efi_call_virt1(f, a1) efi_call_virt(f, a1)
  23. #define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2)
  24. #define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3)
  25. #define efi_call_virt4(f, a1, a2, a3, a4) \
  26. efi_call_virt(f, a1, a2, a3, a4)
  27. #define efi_call_virt5(f, a1, a2, a3, a4, a5) \
  28. efi_call_virt(f, a1, a2, a3, a4, a5)
  29. #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
  30. efi_call_virt(f, a1, a2, a3, a4, a5, a6)
  31. #define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size)
  32. #else /* !CONFIG_X86_32 */
  33. #define EFI_LOADER_SIGNATURE "EL64"
  34. extern u64 efi_call0(void *fp);
  35. extern u64 efi_call1(void *fp, u64 arg1);
  36. extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
  37. extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
  38. extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
  39. extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
  40. u64 arg4, u64 arg5);
  41. extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
  42. u64 arg4, u64 arg5, u64 arg6);
  43. #define efi_call_phys0(f) \
  44. efi_call0((void *)(f))
  45. #define efi_call_phys1(f, a1) \
  46. efi_call1((void *)(f), (u64)(a1))
  47. #define efi_call_phys2(f, a1, a2) \
  48. efi_call2((void *)(f), (u64)(a1), (u64)(a2))
  49. #define efi_call_phys3(f, a1, a2, a3) \
  50. efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3))
  51. #define efi_call_phys4(f, a1, a2, a3, a4) \
  52. efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
  53. (u64)(a4))
  54. #define efi_call_phys5(f, a1, a2, a3, a4, a5) \
  55. efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
  56. (u64)(a4), (u64)(a5))
  57. #define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
  58. efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
  59. (u64)(a4), (u64)(a5), (u64)(a6))
  60. extern unsigned long efi_call_virt_prelog(void);
  61. extern void efi_call_virt_epilog(unsigned long);
  62. #define efi_callx(x, func, ...) \
  63. ({ \
  64. efi_status_t __status; \
  65. unsigned long __pgd; \
  66. \
  67. __pgd = efi_call_virt_prelog(); \
  68. __status = efi_call##x(func, __VA_ARGS__); \
  69. efi_call_virt_epilog(__pgd); \
  70. __status; \
  71. })
  72. #define efi_call_virt0(f) \
  73. efi_callx(0, (void *)(efi.systab->runtime->f))
  74. #define efi_call_virt1(f, a1) \
  75. efi_callx(1, (void *)(efi.systab->runtime->f), (u64)(a1))
  76. #define efi_call_virt2(f, a1, a2) \
  77. efi_callx(2, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
  78. #define efi_call_virt3(f, a1, a2, a3) \
  79. efi_callx(3, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
  80. (u64)(a3))
  81. #define efi_call_virt4(f, a1, a2, a3, a4) \
  82. efi_callx(4, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
  83. (u64)(a3), (u64)(a4))
  84. #define efi_call_virt5(f, a1, a2, a3, a4, a5) \
  85. efi_callx(5, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
  86. (u64)(a3), (u64)(a4), (u64)(a5))
  87. #define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
  88. efi_callx(6, (void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
  89. (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
  90. extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
  91. u32 type, u64 attribute);
  92. #endif /* CONFIG_X86_32 */
  93. extern int add_efi_memmap;
  94. extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
  95. extern int efi_memblock_x86_reserve_range(void);
  96. extern void efi_call_phys_prelog(void);
  97. extern void efi_call_phys_epilog(void);
  98. extern void efi_unmap_memmap(void);
  99. extern void efi_memory_uc(u64 addr, unsigned long size);
  100. #ifndef CONFIG_EFI
  101. /*
  102. * IF EFI is not configured, have the EFI calls return -ENOSYS.
  103. */
  104. #define efi_call0(_f) (-ENOSYS)
  105. #define efi_call1(_f, _a1) (-ENOSYS)
  106. #define efi_call2(_f, _a1, _a2) (-ENOSYS)
  107. #define efi_call3(_f, _a1, _a2, _a3) (-ENOSYS)
  108. #define efi_call4(_f, _a1, _a2, _a3, _a4) (-ENOSYS)
  109. #define efi_call5(_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS)
  110. #define efi_call6(_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS)
  111. #endif /* CONFIG_EFI */
  112. #endif /* _ASM_X86_EFI_H */