blob: 622db3c6474e2d5c51b3a1689869534cf16019ee [file] [log] [blame]
Mark Salterf84d0272014-04-15 21:59:30 -04001#ifndef _ASM_EFI_H
2#define _ASM_EFI_H
3
4#include <asm/io.h>
Ard Biesheuvelf7d92482015-11-30 13:28:19 +01005#include <asm/mmu_context.h>
Ard Biesheuvele15dd492014-07-04 19:41:53 +02006#include <asm/neon.h>
Mark Rutlandee6cab52016-04-25 21:07:09 +01007#include <asm/ptrace.h>
Ard Biesheuvelf7d92482015-11-30 13:28:19 +01008#include <asm/tlbflush.h>
Mark Salterf84d0272014-04-15 21:59:30 -04009
10#ifdef CONFIG_EFI
11extern void efi_init(void);
Mark Salterf84d0272014-04-15 21:59:30 -040012#else
13#define efi_init()
Mark Salterf84d0272014-04-15 21:59:30 -040014#endif
15
Ard Biesheuvelf7d92482015-11-30 13:28:19 +010016int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
17
Ard Biesheuvel789957e2016-04-25 21:06:46 +010018#define efi_set_mapping_permissions efi_create_mapping
19
Mark Rutland489f80f2016-04-25 21:07:04 +010020#define arch_efi_call_virt_setup() \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020021({ \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020022 kernel_neon_begin(); \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020023 efi_virtmap_load(); \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020024})
25
Mark Rutland489f80f2016-04-25 21:07:04 +010026#define arch_efi_call_virt(f, args...) \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020027({ \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020028 efi_##f##_t *__f; \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020029 __f = efi.systab->runtime->f; \
Mark Rutland489f80f2016-04-25 21:07:04 +010030 __f(args); \
31})
32
33#define arch_efi_call_virt_teardown() \
34({ \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020035 efi_virtmap_unload(); \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020036 kernel_neon_end(); \
37})
38
Mark Rutlandee6cab52016-04-25 21:07:09 +010039#define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT)
40
Ard Biesheuvela13b0072014-07-02 14:54:41 +020041/* arch specific definitions used by the stub code */
42
43/*
44 * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from
45 * start of kernel and may not cross a 2MiB boundary. We set alignment to
46 * 2MiB so we know it won't cross a 2MiB boundary.
47 */
48#define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */
49#define MAX_FDT_OFFSET SZ_512M
50
Ard Biesheuvelfc372062016-04-25 21:06:49 +010051#define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
52#define __efi_call_early(f, ...) f(__VA_ARGS__)
53#define efi_is_64bit() (true)
Ard Biesheuvela13b0072014-07-02 14:54:41 +020054
Ard Biesheuvel57fdb89a2016-04-25 21:06:52 +010055#define alloc_screen_info(x...) &screen_info
56#define free_screen_info(x...)
57
Ard Biesheuvel98225042016-04-25 21:06:56 +010058static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
59{
60}
61
Ard Biesheuvel1bd0abb2014-11-17 13:50:21 +010062#define EFI_ALLOC_ALIGN SZ_64K
63
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020064/*
Ard Biesheuvel60305db2015-01-22 10:01:40 +000065 * On ARM systems, virtually remapped UEFI runtime services are set up in two
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020066 * distinct stages:
67 * - The stub retrieves the final version of the memory map from UEFI, populates
68 * the virt_addr fields and calls the SetVirtualAddressMap() [SVAM] runtime
69 * service to communicate the new mapping to the firmware (Note that the new
70 * mapping is not live at this time)
Ard Biesheuvel60305db2015-01-22 10:01:40 +000071 * - During an early initcall(), the EFI system table is permanently remapped
72 * and the virtual remapping of the UEFI Runtime Services regions is loaded
73 * into a private set of page tables. If this all succeeds, the Runtime
74 * Services are enabled and the EFI_RUNTIME_SERVICES bit set.
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020075 */
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020076
Ard Biesheuvelf7d92482015-11-30 13:28:19 +010077static inline void efi_set_pgd(struct mm_struct *mm)
78{
79 switch_mm(NULL, mm, NULL);
80}
81
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020082void efi_virtmap_load(void);
83void efi_virtmap_unload(void);
84
Mark Salterf84d0272014-04-15 21:59:30 -040085#endif /* _ASM_EFI_H */