2 * arch/arm/mm/proc-v7-3level.S
4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
5 * Copyright (C) 2011 ARM Ltd.
6 * Author: Catalin Marinas <catalin.marinas@arm.com>
7 * based on arch/arm/mm/proc-v7-2level.S
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <asm/assembler.h>
24 #define TTB_IRGN_NC (0 << 8)
25 #define TTB_IRGN_WBWA (1 << 8)
26 #define TTB_IRGN_WT (2 << 8)
27 #define TTB_IRGN_WB (3 << 8)
28 #define TTB_RGN_NC (0 << 10)
29 #define TTB_RGN_OC_WBWA (1 << 10)
30 #define TTB_RGN_OC_WT (2 << 10)
31 #define TTB_RGN_OC_WB (3 << 10)
32 #define TTB_S (3 << 12)
33 #define TTB_EAE (1 << 31)
35 /* PTWs cacheable, inner WB not shareable, outer WB not shareable */
36 #define TTB_FLAGS_UP (TTB_IRGN_WB|TTB_RGN_OC_WB)
37 #define PMD_FLAGS_UP (PMD_SECT_WB)
39 /* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */
40 #define TTB_FLAGS_SMP (TTB_IRGN_WBWA|TTB_S|TTB_RGN_OC_WBWA)
41 #define PMD_FLAGS_SMP (PMD_SECT_WBWA|PMD_SECT_S)
52 * cpu_v7_switch_mm(pgd_phys, tsk)
54 * Set the translation table base pointer to be pgd_phys (physical address of
57 ENTRY(cpu_v7_switch_mm)
61 orr rpgdh, rpgdh, r2, lsl #(48 - 32) @ upper 32-bits of pgd
62 mcrr p15, 0, rpgdl, rpgdh, c2 @ set TTB 0
66 ENDPROC(cpu_v7_switch_mm)
77 * cpu_v7_set_pte_ext(ptep, pte)
79 * Set a level 2 translation table entry.
80 * - ptep - pointer to level 3 translation table entry
81 * - pte - PTE value to store (64-bit in r2 and r3)
83 ENTRY(cpu_v7_set_pte_ext)
87 tst rh, #1 << (57 - 32) @ L_PTE_NONE
88 bicne rl, #L_PTE_VALID
91 eor ip, rh, #1 << (55 - 32) @ toggle L_PTE_DIRTY in temp reg to
92 @ test for !L_PTE_DIRTY || L_PTE_RDONLY
93 tst ip, #1 << (55 - 32) | 1 << (58 - 32)
99 ALT_UP (mcr p15, 0, r0, c7, c10, 1) @ flush_pte
102 ENDPROC(cpu_v7_set_pte_ext)
105 * Memory region attributes for LPAE (defined in pgtable-3level.h):
110 * UNCACHED 000 00000000
111 * BUFFERABLE 001 01000100
112 * DEV_WC 001 01000100
113 * WRITETHROUGH 010 10101010
114 * WRITEBACK 011 11101110
115 * DEV_CACHED 011 11101110
116 * DEV_SHARED 100 00000100
117 * DEV_NONSHARED 100 00000100
120 * WRITEALLOC 111 11111111
122 .equ PRRR, 0xeeaa4400 @ MAIR0
123 .equ NMRR, 0xff000004 @ MAIR1
126 * Macro for setting up the TTBRx and TTBCR registers.
129 .macro v7_ttb_setup, zero, ttbr0l, ttbr0h, ttbr1, tmp
130 ldr \tmp, =swapper_pg_dir @ swapper_pg_dir virtual address
131 cmp \ttbr1, \tmp, lsr #12 @ PHYS_OFFSET > PAGE_OFFSET?
132 mov \tmp, #TTB_EAE @ for TTB control egister
133 ALT_SMP(orr \tmp, \tmp, #TTB_FLAGS_SMP)
134 ALT_UP(orr \tmp, \tmp, #TTB_FLAGS_UP)
135 ALT_SMP(orr \tmp, \tmp, #TTB_FLAGS_SMP << 16)
136 ALT_UP(orr \tmp, \tmp, #TTB_FLAGS_UP << 16)
138 * Only use split TTBRs if PHYS_OFFSET <= PAGE_OFFSET (cmp above),
139 * otherwise booting secondary CPUs would end up using TTBR1 for the
140 * identity mapping set up in TTBR0.
142 orrls \tmp, \tmp, #TTBR1_SIZE @ TTBCR.T1SZ
143 mcr p15, 0, \tmp, c2, c0, 2 @ TTBCR
144 mov \tmp, \ttbr1, lsr #20
145 mov \ttbr1, \ttbr1, lsl #12
146 addls \ttbr1, \ttbr1, #TTBR1_OFFSET
147 mcrr p15, 1, \ttbr1, \tmp, c2 @ load TTBR1
152 * TFR EV X F IHD LR S
153 * .EEE ..EE PUI. .TAT 4RVI ZWRS BLDP WCAM
154 * rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced
155 * 11 0 110 0 0011 1100 .111 1101 < we want
158 .type v7_crval, #object
160 crval clear=0x0122c302, mmuset=0x30c03c7d, ucset=0x00c01c7c