xref: /openbmc/linux/arch/sh/include/asm/mmu.h (revision b34e08d5)
1 #ifndef __MMU_H
2 #define __MMU_H
3 
4 /*
5  * Privileged Space Mapping Buffer (PMB) definitions
6  */
7 #define PMB_PASCR		0xff000070
8 #define PMB_IRMCR		0xff000078
9 
10 #define PASCR_SE		0x80000000
11 
12 #define PMB_ADDR		0xf6100000
13 #define PMB_DATA		0xf7100000
14 
15 #define NR_PMB_ENTRIES		16
16 
17 #define PMB_E_MASK		0x0000000f
18 #define PMB_E_SHIFT		8
19 
20 #define PMB_PFN_MASK		0xff000000
21 
22 #define PMB_SZ_16M		0x00000000
23 #define PMB_SZ_64M		0x00000010
24 #define PMB_SZ_128M		0x00000080
25 #define PMB_SZ_512M		0x00000090
26 #define PMB_SZ_MASK		PMB_SZ_512M
27 #define PMB_C			0x00000008
28 #define PMB_WT			0x00000001
29 #define PMB_UB			0x00000200
30 #define PMB_CACHE_MASK		(PMB_C | PMB_WT | PMB_UB)
31 #define PMB_V			0x00000100
32 
33 #define PMB_NO_ENTRY		(-1)
34 
35 #ifndef __ASSEMBLY__
36 #include <linux/errno.h>
37 #include <linux/threads.h>
38 #include <asm/page.h>
39 
40 /* Default "unsigned long" context */
41 typedef unsigned long mm_context_id_t[NR_CPUS];
42 
43 typedef struct {
44 #ifdef CONFIG_MMU
45 	mm_context_id_t		id;
46 	void			*vdso;
47 #else
48 	unsigned long		end_brk;
49 #endif
50 #ifdef CONFIG_BINFMT_ELF_FDPIC
51 	unsigned long		exec_fdpic_loadmap;
52 	unsigned long		interp_fdpic_loadmap;
53 #endif
54 } mm_context_t;
55 
56 #ifdef CONFIG_PMB
57 /* arch/sh/mm/pmb.c */
58 bool __in_29bit_mode(void);
59 
60 void pmb_init(void);
61 int pmb_bolt_mapping(unsigned long virt, phys_addr_t phys,
62 		     unsigned long size, pgprot_t prot);
63 void __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size,
64 			       pgprot_t prot, void *caller);
65 int pmb_unmap(void __iomem *addr);
66 
67 #else
68 
69 static inline int
70 pmb_bolt_mapping(unsigned long virt, phys_addr_t phys,
71 		 unsigned long size, pgprot_t prot)
72 {
73 	return -EINVAL;
74 }
75 
76 static inline void __iomem *
77 pmb_remap_caller(phys_addr_t phys, unsigned long size,
78 		 pgprot_t prot, void *caller)
79 {
80 	return NULL;
81 }
82 
83 static inline int pmb_unmap(void __iomem *addr)
84 {
85 	return -EINVAL;
86 }
87 
88 #define pmb_init(addr)		do { } while (0)
89 
90 #ifdef CONFIG_29BIT
91 #define __in_29bit_mode()	(1)
92 #else
93 #define __in_29bit_mode()	(0)
94 #endif
95 
96 #endif /* CONFIG_PMB */
97 
98 static inline void __iomem *
99 pmb_remap(phys_addr_t phys, unsigned long size, pgprot_t prot)
100 {
101 	return pmb_remap_caller(phys, size, prot, __builtin_return_address(0));
102 }
103 
104 #endif /* __ASSEMBLY__ */
105 
106 #endif /* __MMU_H */
107