18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_FIXMAP_H
38c2ecf20Sopenharmony_ci#define _ASM_FIXMAP_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#define FIXADDR_START		0xffc80000UL
68c2ecf20Sopenharmony_ci#define FIXADDR_END		0xfff00000UL
78c2ecf20Sopenharmony_ci#define FIXADDR_TOP		(FIXADDR_END - PAGE_SIZE)
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/pgtable.h>
108c2ecf20Sopenharmony_ci#include <asm/kmap_types.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cienum fixed_addresses {
138c2ecf20Sopenharmony_ci	FIX_EARLYCON_MEM_BASE,
148c2ecf20Sopenharmony_ci	__end_of_permanent_fixed_addresses,
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci	FIX_KMAP_BEGIN = __end_of_permanent_fixed_addresses,
178c2ecf20Sopenharmony_ci	FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci	/* Support writing RO kernel text via kprobes, jump labels, etc. */
208c2ecf20Sopenharmony_ci	FIX_TEXT_POKE0,
218c2ecf20Sopenharmony_ci	FIX_TEXT_POKE1,
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	__end_of_fixmap_region,
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	/*
268c2ecf20Sopenharmony_ci	 * Share the kmap() region with early_ioremap(): this is guaranteed
278c2ecf20Sopenharmony_ci	 * not to clash since early_ioremap() is only available before
288c2ecf20Sopenharmony_ci	 * paging_init(), and kmap() only after.
298c2ecf20Sopenharmony_ci	 */
308c2ecf20Sopenharmony_ci#define NR_FIX_BTMAPS		32
318c2ecf20Sopenharmony_ci#define FIX_BTMAPS_SLOTS	7
328c2ecf20Sopenharmony_ci#define TOTAL_FIX_BTMAPS	(NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
358c2ecf20Sopenharmony_ci	FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
368c2ecf20Sopenharmony_ci	__end_of_early_ioremap_region
378c2ecf20Sopenharmony_ci};
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistatic const enum fixed_addresses __end_of_fixed_addresses =
408c2ecf20Sopenharmony_ci	__end_of_fixmap_region > __end_of_early_ioremap_region ?
418c2ecf20Sopenharmony_ci	__end_of_fixmap_region : __end_of_early_ioremap_region;
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_COMMON	(L_PTE_YOUNG | L_PTE_PRESENT | L_PTE_XN | L_PTE_DIRTY)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_NORMAL	(pgprot_kernel | L_PTE_XN)
468c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_RO		(FIXMAP_PAGE_NORMAL | L_PTE_RDONLY)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/* Used by set_fixmap_(io|nocache), both meant for mapping a device */
498c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_IO		(FIXMAP_PAGE_COMMON | L_PTE_MT_DEV_SHARED | L_PTE_SHARED)
508c2ecf20Sopenharmony_ci#define FIXMAP_PAGE_NOCACHE	FIXMAP_PAGE_IO
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define __early_set_fixmap	__set_fixmap
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#ifdef CONFIG_MMU
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_civoid __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
578c2ecf20Sopenharmony_civoid __init early_fixmap_init(void);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#include <asm-generic/fixmap.h>
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#else
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cistatic inline void early_fixmap_init(void) { }
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#endif
668c2ecf20Sopenharmony_ci#endif
67