xref: /OK3568_Linux_fs/kernel/arch/arm/include/asm/efi.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #ifndef __ASM_ARM_EFI_H
7*4882a593Smuzhiyun #define __ASM_ARM_EFI_H
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <asm/cacheflush.h>
10*4882a593Smuzhiyun #include <asm/cachetype.h>
11*4882a593Smuzhiyun #include <asm/early_ioremap.h>
12*4882a593Smuzhiyun #include <asm/fixmap.h>
13*4882a593Smuzhiyun #include <asm/highmem.h>
14*4882a593Smuzhiyun #include <asm/mach/map.h>
15*4882a593Smuzhiyun #include <asm/mmu_context.h>
16*4882a593Smuzhiyun #include <asm/ptrace.h>
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #ifdef CONFIG_EFI
19*4882a593Smuzhiyun void efi_init(void);
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
22*4882a593Smuzhiyun int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #define arch_efi_call_virt_setup()	efi_virtmap_load()
25*4882a593Smuzhiyun #define arch_efi_call_virt_teardown()	efi_virtmap_unload()
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #define arch_efi_call_virt(p, f, args...)				\
28*4882a593Smuzhiyun ({									\
29*4882a593Smuzhiyun 	efi_##f##_t *__f;						\
30*4882a593Smuzhiyun 	__f = p->f;							\
31*4882a593Smuzhiyun 	__f(args);							\
32*4882a593Smuzhiyun })
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define ARCH_EFI_IRQ_FLAGS_MASK \
35*4882a593Smuzhiyun 	(PSR_J_BIT | PSR_E_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | \
36*4882a593Smuzhiyun 	 PSR_T_BIT | MODE_MASK)
37*4882a593Smuzhiyun 
efi_set_pgd(struct mm_struct * mm)38*4882a593Smuzhiyun static inline void efi_set_pgd(struct mm_struct *mm)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun 	check_and_switch_context(mm, NULL);
41*4882a593Smuzhiyun }
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun void efi_virtmap_load(void);
44*4882a593Smuzhiyun void efi_virtmap_unload(void);
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #else
47*4882a593Smuzhiyun #define efi_init()
48*4882a593Smuzhiyun #endif /* CONFIG_EFI */
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /* arch specific definitions used by the stub code */
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun struct screen_info *alloc_screen_info(void);
53*4882a593Smuzhiyun void free_screen_info(struct screen_info *si);
54*4882a593Smuzhiyun 
efifb_setup_from_dmi(struct screen_info * si,const char * opt)55*4882a593Smuzhiyun static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
56*4882a593Smuzhiyun {
57*4882a593Smuzhiyun }
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /*
60*4882a593Smuzhiyun  * A reasonable upper bound for the uncompressed kernel size is 32 MBytes,
61*4882a593Smuzhiyun  * so we will reserve that amount of memory. We have no easy way to tell what
62*4882a593Smuzhiyun  * the actuall size of code + data the uncompressed kernel will use.
63*4882a593Smuzhiyun  * If this is insufficient, the decompressor will relocate itself out of the
64*4882a593Smuzhiyun  * way before performing the decompression.
65*4882a593Smuzhiyun  */
66*4882a593Smuzhiyun #define MAX_UNCOMP_KERNEL_SIZE	SZ_32M
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun /*
69*4882a593Smuzhiyun  * phys-to-virt patching requires that the physical to virtual offset fits
70*4882a593Smuzhiyun  * into the immediate field of an add/sub instruction, which comes down to the
71*4882a593Smuzhiyun  * 24 least significant bits being zero, and so the offset should be a multiple
72*4882a593Smuzhiyun  * of 16 MB. Since PAGE_OFFSET itself is a multiple of 16 MB, the physical
73*4882a593Smuzhiyun  * base should be aligned to 16 MB as well.
74*4882a593Smuzhiyun  */
75*4882a593Smuzhiyun #define EFI_PHYS_ALIGN		SZ_16M
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /* on ARM, the FDT should be located in a lowmem region */
efi_get_max_fdt_addr(unsigned long image_addr)78*4882a593Smuzhiyun static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
79*4882a593Smuzhiyun {
80*4882a593Smuzhiyun 	return round_down(image_addr, EFI_PHYS_ALIGN) + SZ_512M;
81*4882a593Smuzhiyun }
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun /* on ARM, the initrd should be loaded in a lowmem region */
efi_get_max_initrd_addr(unsigned long image_addr)84*4882a593Smuzhiyun static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
85*4882a593Smuzhiyun {
86*4882a593Smuzhiyun 	return round_down(image_addr, EFI_PHYS_ALIGN) + SZ_512M;
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun struct efi_arm_entry_state {
90*4882a593Smuzhiyun 	u32	cpsr_before_ebs;
91*4882a593Smuzhiyun 	u32	sctlr_before_ebs;
92*4882a593Smuzhiyun 	u32	cpsr_after_ebs;
93*4882a593Smuzhiyun 	u32	sctlr_after_ebs;
94*4882a593Smuzhiyun };
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #endif /* _ASM_ARM_EFI_H */
97