blob: 472c93db5dac50b31d75e854b48b69cb4748284a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -04002#ifndef _ASM_FIXMAP_H
3#define _ASM_FIXMAP_H
4
Liu Huaa05e54c2014-04-18 09:43:32 +01005#define FIXADDR_START 0xffc00000UL
Rob Herring836a2412014-07-02 02:01:15 -05006#define FIXADDR_END 0xfff00000UL
Mark Salterb615bbb2014-08-13 09:04:49 -07007#define FIXADDR_TOP (FIXADDR_END - PAGE_SIZE)
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -04008
Mark Salterb615bbb2014-08-13 09:04:49 -07009#include <asm/kmap_types.h>
Stefan Agnera5f4c562015-08-13 00:01:52 +010010#include <asm/pgtable.h>
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -040011
Mark Salterb615bbb2014-08-13 09:04:49 -070012enum fixed_addresses {
Stefan Agnera5f4c562015-08-13 00:01:52 +010013 FIX_EARLYCON_MEM_BASE,
14 __end_of_permanent_fixed_addresses,
15
16 FIX_KMAP_BEGIN = __end_of_permanent_fixed_addresses,
Mark Salterb615bbb2014-08-13 09:04:49 -070017 FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -040018
Rabin Vincentab0615e2014-04-24 23:28:57 +020019 /* Support writing RO kernel text via kprobes, jump labels, etc. */
20 FIX_TEXT_POKE0,
21 FIX_TEXT_POKE1,
22
Ard Biesheuvel29373672015-09-01 08:59:28 +020023 __end_of_fixmap_region,
24
25 /*
26 * Share the kmap() region with early_ioremap(): this is guaranteed
27 * not to clash since early_ioremap() is only available before
28 * paging_init(), and kmap() only after.
29 */
30#define NR_FIX_BTMAPS 32
31#define FIX_BTMAPS_SLOTS 7
32#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
33
34 FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
35 FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
36 __end_of_early_ioremap_region
Mark Salterb615bbb2014-08-13 09:04:49 -070037};
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -040038
Ard Biesheuvel29373672015-09-01 08:59:28 +020039static const enum fixed_addresses __end_of_fixed_addresses =
40 __end_of_fixmap_region > __end_of_early_ioremap_region ?
41 __end_of_fixmap_region : __end_of_early_ioremap_region;
42
Stefan Agnera5f4c562015-08-13 00:01:52 +010043#define FIXMAP_PAGE_COMMON (L_PTE_YOUNG | L_PTE_PRESENT | L_PTE_XN | L_PTE_DIRTY)
44
Jon Medhurstb089c312017-04-10 11:13:59 +010045#define FIXMAP_PAGE_NORMAL (pgprot_kernel | L_PTE_XN)
Ard Biesheuvel29373672015-09-01 08:59:28 +020046#define FIXMAP_PAGE_RO (FIXMAP_PAGE_NORMAL | L_PTE_RDONLY)
Stefan Agnera5f4c562015-08-13 00:01:52 +010047
48/* Used by set_fixmap_(io|nocache), both meant for mapping a device */
49#define FIXMAP_PAGE_IO (FIXMAP_PAGE_COMMON | L_PTE_MT_DEV_SHARED | L_PTE_SHARED)
50#define FIXMAP_PAGE_NOCACHE FIXMAP_PAGE_IO
51
Ard Biesheuvel29373672015-09-01 08:59:28 +020052#define __early_set_fixmap __set_fixmap
53
54#ifdef CONFIG_MMU
55
Kees Cook99b4ac92014-04-04 23:27:49 +020056void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
Stefan Agnera5f4c562015-08-13 00:01:52 +010057void __init early_fixmap_init(void);
Kees Cook99b4ac92014-04-04 23:27:49 +020058
Mark Salterb615bbb2014-08-13 09:04:49 -070059#include <asm-generic/fixmap.h>
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -040060
Ard Biesheuvel29373672015-09-01 08:59:28 +020061#else
62
63static inline void early_fixmap_init(void) { }
64
65#endif
Nicolas Pitre5f0fbf92008-09-16 13:05:53 -040066#endif