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