blob: 7667826b93f12d6cde2e151b6fa17372a1d1c3a6 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Ard Biesheuvelda58fb62015-09-24 13:49:52 -07002/*
3 * Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
Ard Biesheuvelda58fb62015-09-24 13:49:52 -07004 */
5
6#ifndef __ASM_ARM_EFI_H
7#define __ASM_ARM_EFI_H
8
9#include <asm/cacheflush.h>
10#include <asm/cachetype.h>
11#include <asm/early_ioremap.h>
12#include <asm/fixmap.h>
13#include <asm/highmem.h>
14#include <asm/mach/map.h>
15#include <asm/mmu_context.h>
16#include <asm/pgtable.h>
Mark Rutland207a90e2016-04-25 21:07:10 +010017#include <asm/ptrace.h>
Ard Biesheuvelda58fb62015-09-24 13:49:52 -070018
19#ifdef CONFIG_EFI
20void efi_init(void);
21
22int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
Ard Biesheuvel9fc68b72016-04-25 21:06:42 +010023int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
Ard Biesheuvelda58fb62015-09-24 13:49:52 -070024
Mark Rutland819fc122016-04-25 21:07:05 +010025#define arch_efi_call_virt_setup() efi_virtmap_load()
26#define arch_efi_call_virt_teardown() efi_virtmap_unload()
Ard Biesheuvelda58fb62015-09-24 13:49:52 -070027
Alex Thorlton80e75592016-06-25 08:20:27 +010028#define arch_efi_call_virt(p, f, args...) \
Ard Biesheuvelda58fb62015-09-24 13:49:52 -070029({ \
30 efi_##f##_t *__f; \
Alex Thorlton80e75592016-06-25 08:20:27 +010031 __f = p->f; \
Mark Rutland819fc122016-04-25 21:07:05 +010032 __f(args); \
Ard Biesheuvelda58fb62015-09-24 13:49:52 -070033})
34
Mark Rutland207a90e2016-04-25 21:07:10 +010035#define ARCH_EFI_IRQ_FLAGS_MASK \
36 (PSR_J_BIT | PSR_E_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | \
37 PSR_T_BIT | MODE_MASK)
38
Ard Biesheuvelda58fb62015-09-24 13:49:52 -070039static inline void efi_set_pgd(struct mm_struct *mm)
40{
41 check_and_switch_context(mm, NULL);
42}
43
44void efi_virtmap_load(void);
45void efi_virtmap_unload(void);
46
47#else
48#define efi_init()
49#endif /* CONFIG_EFI */
50
Roy Franz81a0bc32015-09-23 20:17:54 -070051/* arch specific definitions used by the stub code */
52
Ard Biesheuvelfc372062016-04-25 21:06:49 +010053#define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
54#define __efi_call_early(f, ...) f(__VA_ARGS__)
David Howells6d0ca4a2017-02-06 11:22:41 +000055#define efi_call_runtime(f, ...) sys_table_arg->runtime->f(__VA_ARGS__)
Ard Biesheuvelfc372062016-04-25 21:06:49 +010056#define efi_is_64bit() (false)
Roy Franz81a0bc32015-09-23 20:17:54 -070057
Lukas Wunnerc4db9c12018-07-20 10:47:23 +090058#define efi_table_attr(table, attr, instance) \
59 ((table##_t *)instance)->attr
60
Lukas Wunner3552fdf2016-11-12 21:32:35 +000061#define efi_call_proto(protocol, f, instance, ...) \
62 ((protocol##_t *)instance)->f(instance, ##__VA_ARGS__)
63
Ard Biesheuvel801820b2016-04-25 21:06:53 +010064struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg);
65void free_screen_info(efi_system_table_t *sys_table, struct screen_info *si);
66
Ard Biesheuvel98225042016-04-25 21:06:56 +010067static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
68{
69}
70
Roy Franz81a0bc32015-09-23 20:17:54 -070071/*
72 * A reasonable upper bound for the uncompressed kernel size is 32 MBytes,
73 * so we will reserve that amount of memory. We have no easy way to tell what
74 * the actuall size of code + data the uncompressed kernel will use.
75 * If this is insufficient, the decompressor will relocate itself out of the
76 * way before performing the decompression.
77 */
78#define MAX_UNCOMP_KERNEL_SIZE SZ_32M
79
80/*
81 * The kernel zImage should preferably be located between 32 MB and 128 MB
82 * from the base of DRAM. The min address leaves space for a maximal size
83 * uncompressed image, and the max address is due to how the zImage decompressor
84 * picks a destination address.
85 */
86#define ZIMAGE_OFFSET_LIMIT SZ_128M
87#define MIN_ZIMAGE_OFFSET MAX_UNCOMP_KERNEL_SIZE
Ard Biesheuvel138728dd2017-04-04 17:02:37 +010088
89/* on ARM, the FDT should be located in the first 128 MB of RAM */
90static inline unsigned long efi_get_max_fdt_addr(unsigned long dram_base)
91{
92 return dram_base + ZIMAGE_OFFSET_LIMIT;
93}
94
95/* on ARM, the initrd should be loaded in a lowmem region */
96static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
97 unsigned long image_addr)
98{
99 return dram_base + SZ_512M;
100}
Roy Franz81a0bc32015-09-23 20:17:54 -0700101
Ard Biesheuvelda58fb62015-09-24 13:49:52 -0700102#endif /* _ASM_ARM_EFI_H */