xref: /openbmc/linux/arch/sparc/mm/srmmu_access.S (revision e639c869)
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Assembler variants of srmmu access functions.
3 * Implemented in assembler to allow run-time patching.
4 * LEON uses a different ASI for MMUREGS than SUN.
5 *
6 * The leon_1insn_patch infrastructure is used
7 * for the run-time patching.
8 */
9
10#include <linux/linkage.h>
11
12#include <asm/asmmacro.h>
13#include <asm/pgtsrmmu.h>
14#include <asm/asi.h>
15
16/* unsigned int srmmu_get_mmureg(void) */
17ENTRY(srmmu_get_mmureg)
18LEON_PI(lda	[%g0] ASI_LEON_MMUREGS, %o0)
19SUN_PI_(lda	[%g0] ASI_M_MMUREGS, %o0)
20	retl
21	 nop
22ENDPROC(srmmu_get_mmureg)
23
24/* void srmmu_set_mmureg(unsigned long regval) */
25ENTRY(srmmu_set_mmureg)
26LEON_PI(sta	%o0, [%g0] ASI_LEON_MMUREGS)
27SUN_PI_(sta	%o0, [%g0] ASI_M_MMUREGS)
28	retl
29	 nop
30ENDPROC(srmmu_set_mmureg)
31
32/* void srmmu_set_ctable_ptr(unsigned long paddr) */
33ENTRY(srmmu_set_ctable_ptr)
34	/* paddr = ((paddr >> 4) & SRMMU_CTX_PMASK); */
35	srl	%o0, 4, %g1
36	and	%g1, SRMMU_CTX_PMASK, %g1
37
38	mov	SRMMU_CTXTBL_PTR, %g2
39LEON_PI(sta	%g1, [%g2] ASI_LEON_MMUREGS)
40SUN_PI_(sta	%g1, [%g2] ASI_M_MMUREGS)
41	retl
42	 nop
43ENDPROC(srmmu_set_ctable_ptr)
44
45
46/* void srmmu_set_context(int context) */
47ENTRY(srmmu_set_context)
48	mov	SRMMU_CTX_REG, %g1
49LEON_PI(sta	%o0, [%g1] ASI_LEON_MMUREGS)
50SUN_PI_(sta	%o0, [%g1] ASI_M_MMUREGS)
51	retl
52	 nop
53ENDPROC(srmmu_set_context)
54
55
56/* int srmmu_get_context(void) */
57ENTRY(srmmu_get_context)
58	mov	SRMMU_CTX_REG, %o0
59LEON_PI(lda     [%o0] ASI_LEON_MMUREGS, %o0)
60SUN_PI_(lda	[%o0] ASI_M_MMUREGS, %o0)
61	retl
62	 nop
63ENDPROC(srmmu_get_context)
64
65
66/* unsigned int srmmu_get_fstatus(void) */
67ENTRY(srmmu_get_fstatus)
68	mov	SRMMU_FAULT_STATUS, %o0
69LEON_PI(lda     [%o0] ASI_LEON_MMUREGS, %o0)
70SUN_PI_(lda	[%o0] ASI_M_MMUREGS, %o0)
71	retl
72	 nop
73ENDPROC(srmmu_get_fstatus)
74
75
76/* unsigned int srmmu_get_faddr(void) */
77ENTRY(srmmu_get_faddr)
78	mov	SRMMU_FAULT_ADDR, %o0
79LEON_PI(lda     [%o0] ASI_LEON_MMUREGS, %o0)
80SUN_PI_(lda	[%o0] ASI_M_MMUREGS, %o0)
81	retl
82	 nop
83ENDPROC(srmmu_get_faddr)
84