aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2012-05-25 17:20:17 -0400
committerDavid S. Miller <davem@davemloft.net>2012-05-28 02:52:49 -0400
commit6729cf7967f6c11f6de6a0b43ec277905a00c146 (patch)
tree7e0b3a10176185c302f5ebc7d6e7f8a0d74eb00c
parent1ec8cf62338b950fdbf76bbdfa3064bc1c0b7a81 (diff)
sparc32: introduce run-time patching of srmmu access functions
LEON uses a different ASI than SUN for MMUREGS Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Daniel Hellstrom <daniel@gaisler.com> Cc: Konrad Eisele <konrad@gaisler.com>
-rw-r--r--arch/sparc/include/asm/pgtsrmmu.h68
-rw-r--r--arch/sparc/mm/Makefile1
-rw-r--r--arch/sparc/mm/srmmu_access.S82
3 files changed, 90 insertions, 61 deletions
diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
index 394fe25e79d1..72f71214ef87 100644
--- a/arch/sparc/include/asm/pgtsrmmu.h
+++ b/arch/sparc/include/asm/pgtsrmmu.h
@@ -149,67 +149,13 @@ extern void *srmmu_nocache_pool;
149#define __nocache_fix(VADDR) __va(__nocache_pa(VADDR)) 149#define __nocache_fix(VADDR) __va(__nocache_pa(VADDR))
150 150
151/* Accessing the MMU control register. */ 151/* Accessing the MMU control register. */
152static inline unsigned int srmmu_get_mmureg(void) 152unsigned int srmmu_get_mmureg(void);
153{ 153void srmmu_set_mmureg(unsigned long regval);
154 unsigned int retval; 154void srmmu_set_ctable_ptr(unsigned long paddr);
155 __asm__ __volatile__("lda [%%g0] %1, %0\n\t" : 155void srmmu_set_context(int context);
156 "=r" (retval) : 156int srmmu_get_context(void);
157 "i" (ASI_M_MMUREGS)); 157unsigned int srmmu_get_fstatus(void);
158 return retval; 158unsigned int srmmu_get_faddr(void);
159}
160
161static inline void srmmu_set_mmureg(unsigned long regval)
162{
163 __asm__ __volatile__("sta %0, [%%g0] %1\n\t" : :
164 "r" (regval), "i" (ASI_M_MMUREGS) : "memory");
165
166}
167
168static inline void srmmu_set_ctable_ptr(unsigned long paddr)
169{
170 paddr = ((paddr >> 4) & SRMMU_CTX_PMASK);
171 __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
172 "r" (paddr), "r" (SRMMU_CTXTBL_PTR),
173 "i" (ASI_M_MMUREGS) :
174 "memory");
175}
176
177static inline void srmmu_set_context(int context)
178{
179 __asm__ __volatile__("sta %0, [%1] %2\n\t" : :
180 "r" (context), "r" (SRMMU_CTX_REG),
181 "i" (ASI_M_MMUREGS) : "memory");
182}
183
184static inline int srmmu_get_context(void)
185{
186 register int retval;
187 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
188 "=r" (retval) :
189 "r" (SRMMU_CTX_REG),
190 "i" (ASI_M_MMUREGS));
191 return retval;
192}
193
194static inline unsigned int srmmu_get_fstatus(void)
195{
196 unsigned int retval;
197
198 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
199 "=r" (retval) :
200 "r" (SRMMU_FAULT_STATUS), "i" (ASI_M_MMUREGS));
201 return retval;
202}
203
204static inline unsigned int srmmu_get_faddr(void)
205{
206 unsigned int retval;
207
208 __asm__ __volatile__("lda [%1] %2, %0\n\t" :
209 "=r" (retval) :
210 "r" (SRMMU_FAULT_ADDR), "i" (ASI_M_MMUREGS));
211 return retval;
212}
213 159
214/* This is guaranteed on all SRMMU's. */ 160/* This is guaranteed on all SRMMU's. */
215static inline void srmmu_flush_whole_tlb(void) 161static inline void srmmu_flush_whole_tlb(void)
diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
index 389aebd720bc..30c3eccfdf5a 100644
--- a/arch/sparc/mm/Makefile
+++ b/arch/sparc/mm/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
8obj-y += fault_$(BITS).o 8obj-y += fault_$(BITS).o
9obj-y += init_$(BITS).o 9obj-y += init_$(BITS).o
10obj-$(CONFIG_SPARC32) += extable.o srmmu.o iommu.o io-unit.o 10obj-$(CONFIG_SPARC32) += extable.o srmmu.o iommu.o io-unit.o
11obj-$(CONFIG_SPARC32) += srmmu_access.o
11obj-$(CONFIG_SPARC32) += hypersparc.o viking.o tsunami.o swift.o 12obj-$(CONFIG_SPARC32) += hypersparc.o viking.o tsunami.o swift.o
12obj-$(CONFIG_SPARC32) += leon_mm.o 13obj-$(CONFIG_SPARC32) += leon_mm.o
13 14
diff --git a/arch/sparc/mm/srmmu_access.S b/arch/sparc/mm/srmmu_access.S
new file mode 100644
index 000000000000..d0a67b2c2383
--- /dev/null
+++ b/arch/sparc/mm/srmmu_access.S
@@ -0,0 +1,82 @@
1/* Assembler variants of srmmu access functions.
2 * Implemented in assembler to allow run-time patching.
3 * LEON uses a different ASI for MMUREGS than SUN.
4 *
5 * The leon_1insn_patch infrastructure is used
6 * for the run-time patching.
7 */
8
9#include <linux/linkage.h>
10
11#include <asm/asmmacro.h>
12#include <asm/pgtsrmmu.h>
13#include <asm/asi.h>
14
15/* unsigned int srmmu_get_mmureg(void) */
16ENTRY(srmmu_get_mmureg)
17LEON_PI(lda [%g0] ASI_LEON_MMUREGS, %o0)
18SUN_PI_(lda [%g0] ASI_M_MMUREGS, %o0)
19 retl
20 nop
21ENDPROC(srmmu_get_mmureg)
22
23/* void srmmu_set_mmureg(unsigned long regval) */
24ENTRY(srmmu_set_mmureg)
25LEON_PI(sta %o0, [%g0] ASI_LEON_MMUREGS)
26SUN_PI_(sta %o0, [%g0] ASI_M_MMUREGS)
27 retl
28 nop
29ENDPROC(srmmu_set_mmureg)
30
31/* void srmmu_set_ctable_ptr(unsigned long paddr) */
32ENTRY(srmmu_set_ctable_ptr)
33 /* paddr = ((paddr >> 4) & SRMMU_CTX_PMASK); */
34 srl %o0, 4, %g1
35 and %g1, SRMMU_CTX_PMASK, %g1
36
37 mov SRMMU_CTXTBL_PTR, %g2
38LEON_PI(sta %g1, [%g2] ASI_LEON_MMUREGS)
39SUN_PI_(sta %g1, [%g2] ASI_M_MMUREGS)
40 retl
41 nop
42ENDPROC(srmmu_set_ctable_ptr)
43
44
45/* void srmmu_set_context(int context) */
46ENTRY(srmmu_set_context)
47 mov SRMMU_CTX_REG, %g1
48LEON_PI(sta %o0, [%g1] ASI_LEON_MMUREGS)
49SUN_PI_(sta %o0, [%g1] ASI_M_MMUREGS)
50 retl
51 nop
52ENDPROC(srmmu_set_context)
53
54
55/* int srmmu_get_context(void) */
56ENTRY(srmmu_get_context)
57 mov SRMMU_CTX_REG, %o0
58LEON_PI(lda [%o0] ASI_LEON_MMUREGS, %o0)
59SUN_PI_(lda [%o0] ASI_M_MMUREGS, %o0)
60 retl
61 nop
62ENDPROC(srmmu_get_context)
63
64
65/* unsigned int srmmu_get_fstatus(void) */
66ENTRY(srmmu_get_fstatus)
67 mov SRMMU_FAULT_STATUS, %o0
68LEON_PI(lda [%o0] ASI_LEON_MMUREGS, %o0)
69SUN_PI_(lda [%o0] ASI_M_MMUREGS, %o0)
70 retl
71 nop
72ENDPROC(srmmu_get_fstatus)
73
74
75/* unsigned int srmmu_get_faddr(void) */
76ENTRY(srmmu_get_faddr)
77 mov SRMMU_FAULT_ADDR, %o0
78LEON_PI(lda [%o0] ASI_LEON_MMUREGS, %o0)
79SUN_PI_(lda [%o0] ASI_M_MMUREGS, %o0)
80 retl
81 nop
82ENDPROC(srmmu_get_faddr)