Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:58

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsPowerPCQorIQMMU
0007  *
0008  * @brief qoriq_tlb1_write() and qoriq_tlb1_invalidate() implementation.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2011, 2017 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #include <bspopts.h>
0037 
0038 #include <libcpu/powerpc-utility.h>
0039 
0040     .global qoriq_tlb1_write
0041     .global qoriq_tlb1_invalidate
0042     .global qoriq_tlb1_invalidate_all_by_ts
0043 
0044     .section ".bsp_start_text", "ax"
0045 
0046 qoriq_tlb1_write:
0047     rlwinm  r3, r3, 16, 10, 15
0048 #ifdef __powerpc64__
0049     rldicr  r8, r8, 0, 51
0050 #else
0051     rlwinm  r8, r8, 0, 0, 19
0052 #endif
0053     oris    r3, r3, 0x1000
0054     mtspr   FSL_EIS_MAS0, r3
0055     oris    r4, r4, 0xc000
0056     rlwinm  r9, r9, 8, 20, 23
0057     or  r9, r4, r9
0058     mtspr   FSL_EIS_MAS1, r9
0059     or  r5, r8, r5
0060     mtspr   FSL_EIS_MAS2, r5
0061     or  r6, r8, r6
0062     mtspr   FSL_EIS_MAS3, r6
0063 #ifdef __powerpc64__
0064     srdi    r8, r8, 32
0065     or  r7, r7, r8
0066     mtspr   FSL_EIS_MAS7, r7
0067 #endif
0068     mtspr   FSL_EIS_MAS7, r7
0069 #if defined(QORIQ_HAS_HYPERVISOR_MODE) && !defined(QORIQ_IS_HYPERVISOR_GUEST)
0070     li  r0, 0
0071     mtspr   FSL_EIS_MAS8, r0
0072 #endif
0073     isync
0074     msync
0075     tlbwe
0076     isync
0077     blr
0078 
0079 qoriq_tlb1_invalidate:
0080     rlwinm  r3, r3, 16, 10, 15
0081     oris    r3, r3, 0x1000
0082     mtspr   FSL_EIS_MAS0, r3
0083     li  r0, 0
0084     mtspr   FSL_EIS_MAS1, r0
0085     mtspr   FSL_EIS_MAS2, r0
0086     mtspr   FSL_EIS_MAS3, r0
0087     mtspr   FSL_EIS_MAS7, r0
0088 #if defined(QORIQ_HAS_HYPERVISOR_MODE) && !defined(QORIQ_IS_HYPERVISOR_GUEST)
0089     mtspr   FSL_EIS_MAS8, r0
0090 #endif
0091     isync
0092     msync
0093     tlbwe
0094     isync
0095     blr
0096 
0097 /* r3 = 0 for TS0, 1 for TS1 */
0098 qoriq_tlb1_invalidate_all_by_ts:
0099     mflr    r12
0100     li  r11, QORIQ_TLB1_ENTRY_COUNT
0101     mtctr   r11
0102     li  r11, 0
0103     mr  r10, r3
0104 
0105 2:
0106     rlwinm  r0, r11, 16, 10, 15
0107     oris    r0, r0, (FSL_EIS_MAS0_TLBSEL >> 16)
0108     mtspr   FSL_EIS_MAS0, r0
0109     tlbre
0110     mfspr   r0, FSL_EIS_MAS1
0111     rlwinm  r0, r0, 20, 31, 31
0112     cmpw    r0, r10
0113     bne 1f
0114     mr  r3, r11
0115     bl  qoriq_tlb1_invalidate
0116 1:
0117     addi    r11, r11, 1
0118     bdnz    2b
0119     mtlr    r12
0120     blr