blob: d0a67b2c2383c725ab4ca11dc72b03436d399da1 [file] [log] [blame]
Sam Ravnborg6729cf72012-05-25 21:20:17 +00001/* 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)