1
2#ifndef _ASM_EFI_H
3#define _ASM_EFI_H
4
5#include <asm/boot.h>
6#include <asm/cpufeature.h>
7#include <asm/fpsimd.h>
8#include <asm/io.h>
9#include <asm/memory.h>
10#include <asm/mmu_context.h>
11#include <asm/neon.h>
12#include <asm/ptrace.h>
13#include <asm/tlbflush.h>
14
15#ifdef CONFIG_EFI
16extern void efi_init(void);
17extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt);
18#else
19#define efi_init()
20#endif
21
22int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
23int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
24
25#define arch_efi_call_virt_setup() \
26({ \
27 efi_virtmap_load(); \
28 __efi_fpsimd_begin(); \
29})
30
31#define arch_efi_call_virt(p, f, args...) \
32({ \
33 efi_##f##_t *__f; \
34 __f = p->f; \
35 __efi_rt_asm_wrapper(__f, #f, args); \
36})
37
38#define arch_efi_call_virt_teardown() \
39({ \
40 __efi_fpsimd_end(); \
41 efi_virtmap_unload(); \
42})
43
44efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...);
45
46#define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT)
47
48
49
50
51
52
53#define arch_efi_save_flags(state_flags) \
54 ((void)((state_flags) = read_sysreg(daif)))
55
56#define arch_efi_restore_flags(state_flags) write_sysreg(state_flags, daif)
57
58
59
60
61
62
63
64
65#define EFI_KIMG_ALIGN \
66 (SEGMENT_ALIGN > THREAD_ALIGN ? SEGMENT_ALIGN : THREAD_ALIGN)
67
68
69
70
71
72
73
74
75
76
77
78static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
79{
80 return (image_addr & ~(SZ_1G - 1UL)) + (1UL << (VA_BITS_MIN - 1));
81}
82
83#define alloc_screen_info(x...) &screen_info
84
85static inline void free_screen_info(struct screen_info *si)
86{
87}
88
89#define EFI_ALLOC_ALIGN SZ_64K
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104static inline void efi_set_pgd(struct mm_struct *mm)
105{
106 __switch_mm(mm);
107
108 if (system_uses_ttbr0_pan()) {
109 if (mm != current->active_mm) {
110
111
112
113
114
115
116
117 update_saved_ttbr0(current, mm);
118 uaccess_ttbr0_enable();
119 post_ttbr_update_workaround();
120 } else {
121
122
123
124
125
126 uaccess_ttbr0_disable();
127 update_saved_ttbr0(current, current->active_mm);
128 }
129 }
130}
131
132void efi_virtmap_load(void);
133void efi_virtmap_unload(void);
134
135static inline void efi_capsule_flush_cache_range(void *addr, int size)
136{
137 dcache_clean_inval_poc((unsigned long)addr, (unsigned long)addr + size);
138}
139
140#endif
141