blob: a9e54aad15ef401ae7e0badcdcbffadfe7a97d9f [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);
Ard Biesheuvelbd264d02016-06-29 14:51:27 +020017int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
Ard Biesheuvel789957e2016-04-25 21:06:46 +010018
Mark Rutland489f80f2016-04-25 21:07:04 +010019#define arch_efi_call_virt_setup() \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020020({ \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020021 kernel_neon_begin(); \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020022 efi_virtmap_load(); \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020023})
24
Alex Thorlton80e75592016-06-25 08:20:27 +010025#define arch_efi_call_virt(p, f, args...) \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020026({ \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020027 efi_##f##_t *__f; \
Alex Thorlton80e75592016-06-25 08:20:27 +010028 __f = p->f; \
Mark Rutland489f80f2016-04-25 21:07:04 +010029 __f(args); \
30})
31
32#define arch_efi_call_virt_teardown() \
33({ \
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020034 efi_virtmap_unload(); \
Ard Biesheuvele15dd492014-07-04 19:41:53 +020035 kernel_neon_end(); \
36})
37
Mark Rutlandee6cab52016-04-25 21:07:09 +010038#define ARCH_EFI_IRQ_FLAGS_MASK (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT)
39
Ard Biesheuvela13b0072014-07-02 14:54:41 +020040/* arch specific definitions used by the stub code */
41
42/*
43 * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from
44 * start of kernel and may not cross a 2MiB boundary. We set alignment to
45 * 2MiB so we know it won't cross a 2MiB boundary.
46 */
47#define EFI_FDT_ALIGN SZ_2M /* used by allocate_new_fdt_and_exit_boot() */
48#define MAX_FDT_OFFSET SZ_512M
49
Ard Biesheuvelfc372062016-04-25 21:06:49 +010050#define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
51#define __efi_call_early(f, ...) f(__VA_ARGS__)
52#define efi_is_64bit() (true)
Ard Biesheuvela13b0072014-07-02 14:54:41 +020053
Ard Biesheuvel57fdb89a2016-04-25 21:06:52 +010054#define alloc_screen_info(x...) &screen_info
55#define free_screen_info(x...)
56
Ard Biesheuvel98225042016-04-25 21:06:56 +010057static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
58{
59}
60
Ard Biesheuvel1bd0abb2014-11-17 13:50:21 +010061#define EFI_ALLOC_ALIGN SZ_64K
62
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020063/*
Ard Biesheuvel60305db2015-01-22 10:01:40 +000064 * On ARM systems, virtually remapped UEFI runtime services are set up in two
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020065 * distinct stages:
66 * - The stub retrieves the final version of the memory map from UEFI, populates
67 * the virt_addr fields and calls the SetVirtualAddressMap() [SVAM] runtime
68 * service to communicate the new mapping to the firmware (Note that the new
69 * mapping is not live at this time)
Ard Biesheuvel60305db2015-01-22 10:01:40 +000070 * - During an early initcall(), the EFI system table is permanently remapped
71 * and the virtual remapping of the UEFI Runtime Services regions is loaded
72 * into a private set of page tables. If this all succeeds, the Runtime
73 * Services are enabled and the EFI_RUNTIME_SERVICES bit set.
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020074 */
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020075
Ard Biesheuvelf7d92482015-11-30 13:28:19 +010076static inline void efi_set_pgd(struct mm_struct *mm)
77{
78 switch_mm(NULL, mm, NULL);
79}
80
Ard Biesheuvelf3cdfd22014-10-20 16:27:26 +020081void efi_virtmap_load(void);
82void efi_virtmap_unload(void);
83
Mark Salterf84d0272014-04-15 21:59:30 -040084#endif /* _ASM_EFI_H */