xref: /linux/arch/riscv/include/asm/efi.h (revision 03c11eb3b16dc0058589751dfd91f254be2be613)
1d7071743SAtish Patra /* SPDX-License-Identifier: GPL-2.0 */
2d7071743SAtish Patra /*
3d7071743SAtish Patra  * Copyright (C) 2020 Western Digital Corporation or its affiliates.
4d7071743SAtish Patra  */
5d7071743SAtish Patra #ifndef _ASM_EFI_H
6d7071743SAtish Patra #define _ASM_EFI_H
7d7071743SAtish Patra 
8b91540d5SAtish Patra #include <asm/csr.h>
9d7071743SAtish Patra #include <asm/io.h>
10d7071743SAtish Patra #include <asm/mmu_context.h>
11d7071743SAtish Patra #include <asm/ptrace.h>
12d7071743SAtish Patra #include <asm/tlbflush.h>
133f105a74SAlexandre Ghiti #include <asm/pgalloc.h>
14d7071743SAtish Patra 
15b91540d5SAtish Patra #ifdef CONFIG_EFI
16b91540d5SAtish Patra extern void efi_init(void);
17b91540d5SAtish Patra #else
18b91540d5SAtish Patra #define efi_init()
19b91540d5SAtish Patra #endif
20b91540d5SAtish Patra 
21b91540d5SAtish Patra int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
22cf1d2ffcSArd Biesheuvel int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md, bool);
23b91540d5SAtish Patra 
24b91540d5SAtish Patra #define ARCH_EFI_IRQ_FLAGS_MASK (SR_IE | SR_SPIE)
25b91540d5SAtish Patra 
26c79e89ecSHeinrich Schuchardt /* Load initrd anywhere in system RAM */
efi_get_max_initrd_addr(unsigned long image_addr)27d7071743SAtish Patra static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
28d7071743SAtish Patra {
29c79e89ecSHeinrich Schuchardt 	return ULONG_MAX;
30d7071743SAtish Patra }
31d7071743SAtish Patra 
efi_get_kimg_min_align(void)32895bc3a1SArd Biesheuvel static inline unsigned long efi_get_kimg_min_align(void)
33895bc3a1SArd Biesheuvel {
34895bc3a1SArd Biesheuvel 	/*
35895bc3a1SArd Biesheuvel 	 * RISC-V requires the kernel image to placed 2 MB aligned base for 64
36895bc3a1SArd Biesheuvel 	 * bit and 4MB for 32 bit.
37895bc3a1SArd Biesheuvel 	 */
38895bc3a1SArd Biesheuvel 	return IS_ENABLED(CONFIG_64BIT) ? SZ_2M : SZ_4M;
39895bc3a1SArd Biesheuvel }
40895bc3a1SArd Biesheuvel 
41895bc3a1SArd Biesheuvel #define EFI_KIMG_PREFERRED_ADDRESS	efi_get_kimg_min_align()
42895bc3a1SArd Biesheuvel 
43d8ea2ffdSArd Biesheuvel void arch_efi_call_virt_setup(void);
44d8ea2ffdSArd Biesheuvel void arch_efi_call_virt_teardown(void);
45b91540d5SAtish Patra 
46f1a116c0SArd Biesheuvel unsigned long stext_offset(void);
47f1a116c0SArd Biesheuvel 
48*b7ac4b8eSAlexandre Ghiti void efi_icache_sync(unsigned long start, unsigned long end);
49*b7ac4b8eSAlexandre Ghiti 
50d7071743SAtish Patra #endif /* _ASM_EFI_H */
51