xref: /openbmc/linux/arch/arm/include/asm/fixmap.h (revision 5f0fbf9ecaf354fa4bbf266fffdea2ea3d14a0ed)
1*5f0fbf9eSNicolas Pitre #ifndef _ASM_FIXMAP_H
2*5f0fbf9eSNicolas Pitre #define _ASM_FIXMAP_H
3*5f0fbf9eSNicolas Pitre 
4*5f0fbf9eSNicolas Pitre /*
5*5f0fbf9eSNicolas Pitre  * Nothing too fancy for now.
6*5f0fbf9eSNicolas Pitre  *
7*5f0fbf9eSNicolas Pitre  * On ARM we already have well known fixed virtual addresses imposed by
8*5f0fbf9eSNicolas Pitre  * the architecture such as the vector page which is located at 0xffff0000,
9*5f0fbf9eSNicolas Pitre  * therefore a second level page table is already allocated covering
10*5f0fbf9eSNicolas Pitre  * 0xfff00000 upwards.
11*5f0fbf9eSNicolas Pitre  *
12*5f0fbf9eSNicolas Pitre  * The cache flushing code in proc-xscale.S uses the virtual area between
13*5f0fbf9eSNicolas Pitre  * 0xfffe0000 and 0xfffeffff.
14*5f0fbf9eSNicolas Pitre  */
15*5f0fbf9eSNicolas Pitre 
16*5f0fbf9eSNicolas Pitre #define FIXADDR_START		0xfff00000UL
17*5f0fbf9eSNicolas Pitre #define FIXADDR_TOP		0xfffe0000UL
18*5f0fbf9eSNicolas Pitre #define FIXADDR_SIZE		(FIXADDR_TOP - FIXADDR_START)
19*5f0fbf9eSNicolas Pitre 
20*5f0fbf9eSNicolas Pitre #define FIX_KMAP_BEGIN		0
21*5f0fbf9eSNicolas Pitre #define FIX_KMAP_END		(FIXADDR_SIZE >> PAGE_SHIFT)
22*5f0fbf9eSNicolas Pitre 
23*5f0fbf9eSNicolas Pitre #define __fix_to_virt(x)	(FIXADDR_START + ((x) << PAGE_SHIFT))
24*5f0fbf9eSNicolas Pitre #define __virt_to_fix(x)	(((x) - FIXADDR_START) >> PAGE_SHIFT)
25*5f0fbf9eSNicolas Pitre 
26*5f0fbf9eSNicolas Pitre extern void __this_fixmap_does_not_exist(void);
27*5f0fbf9eSNicolas Pitre 
28*5f0fbf9eSNicolas Pitre static inline unsigned long fix_to_virt(const unsigned int idx)
29*5f0fbf9eSNicolas Pitre {
30*5f0fbf9eSNicolas Pitre 	if (idx >= FIX_KMAP_END)
31*5f0fbf9eSNicolas Pitre 		__this_fixmap_does_not_exist();
32*5f0fbf9eSNicolas Pitre 	return __fix_to_virt(idx);
33*5f0fbf9eSNicolas Pitre }
34*5f0fbf9eSNicolas Pitre 
35*5f0fbf9eSNicolas Pitre static inline unsigned int virt_to_fix(const unsigned long vaddr)
36*5f0fbf9eSNicolas Pitre {
37*5f0fbf9eSNicolas Pitre 	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
38*5f0fbf9eSNicolas Pitre 	return __virt_to_fix(vaddr);
39*5f0fbf9eSNicolas Pitre }
40*5f0fbf9eSNicolas Pitre 
41*5f0fbf9eSNicolas Pitre #endif
42