2 /* 1. Find the index of the entry we're executing in */
3 bl invstr /* Find our address */
4 invstr: mflr r6 /* Make it accessible */
6 rlwinm r4,r7,27,31,31 /* extract MSR[IS] */
11 tlbsx 0,r6 /* search MSR[IS], SPID=PID0 */
13 andis. r7,r7,MAS1_VALID@h
17 rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
19 bne match_TLB /* skip if NPIDS != 3 */
25 tlbsx 0,r6 /* search MSR[IS], SPID=PID1 */
27 andis. r7,r7,MAS1_VALID@h
33 tlbsx 0,r6 /* Fall through, we had to match */
37 rlwinm r3,r7,16,20,31 /* Extract MAS0(Entry) */
39 mfspr r7,SPRN_MAS1 /* Insure IPROT set */
40 oris r7,r7,MAS1_IPROT@h
44 /* 2. Invalidate all entries except the entry we're executing in */
47 li r6,0 /* Set Entry counter to 0 */
48 1: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
49 rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */
53 rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */
55 beq skpinv /* Dont update the current execution TLB */
59 skpinv: addi r6,r6,1 /* Increment */
60 cmpw r6,r9 /* Are we done? */
61 bne 1b /* If not, repeat */
72 /* 3. Setup a temp mapping and jump to it */
73 andi. r5, r3, 0x1 /* Find an entry not used and is non-zero */
75 lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
76 rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
80 /* grab and fixup the RPN */
81 mfspr r6,SPRN_MAS1 /* extract MAS1[SIZE] */
85 slw r6,r8,r6 /* convert to mask */
87 bl 1f /* Find our address */
91 #ifdef CONFIG_PHYS_64BIT
99 ori r8,r25,(MAS3_SX|MAS3_SW|MAS3_SR)
101 /* Just modify the entry ID and EPN for the temp mapping */
102 lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
103 rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
105 xori r6,r4,1 /* Setup TMP mapping in the other Address space */
107 oris r6,r6,(MAS1_VALID|MAS1_IPROT)@h
108 ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_4K))@l
111 li r7,0 /* temp EPN = 0 */
118 slwi r6,r6,5 /* setup new context with other address space */
119 bl 1f /* Find our address */
127 /* 4. Clear out PIDs & Search info */
133 rlwinm r7,r7,21,28,31 /* extract MMUCFG[NPIDS] */
135 bne 2f /* skip if NPIDS != 3 */
140 /* 5. Invalidate mapping we started in */
142 lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
143 rlwimi r7,r3,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r3) */
147 rlwinm r6,r6,0,2,0 /* clear IPROT */
150 /* Invalidate TLB1 */
155 /* The mapping only needs to be cache-coherent on SMP */
157 #define M_IF_SMP MAS2_M
162 #if defined(ENTRY_MAPPING_BOOT_SETUP)
164 /* 6. Setup KERNELBASE mapping in TLB1[0] */
165 lis r6,0x1000 /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
167 lis r6,(MAS1_VALID|MAS1_IPROT)@h
168 ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_64M))@l
170 lis r6,MAS2_VAL(PAGE_OFFSET, BOOK3E_PAGESZ_64M, M_IF_SMP)@h
171 ori r6,r6,MAS2_VAL(PAGE_OFFSET, BOOK3E_PAGESZ_64M, M_IF_SMP)@l
176 /* 7. Jump to KERNELBASE mapping */
177 lis r6,(KERNELBASE & ~0xfff)@h
178 ori r6,r6,(KERNELBASE & ~0xfff)@l
179 rlwinm r7,r25,0,0x03ffffff
182 #elif defined(ENTRY_MAPPING_KEXEC_SETUP)
184 * 6. Setup a 1:1 mapping in TLB1. Esel 0 is unsued, 1 or 2 contains the tmp
185 * mapping so we start at 3. We setup 8 mappings, each 256MiB in size. This
186 * will cover the first 2GiB of memory.
189 lis r10, (MAS1_VALID|MAS1_IPROT)@h
190 ori r10,r10, (MAS1_TSIZE(BOOK3E_PAGESZ_256M))@l
197 rlwinm r0, r0, 16, 4, 15 // Compute esel
198 rlwinm r9, r11, 28, 0, 3 // Compute [ER]PN
199 oris r0, r0, (MAS0_TLBSEL(1))@h
203 ori r9, r9, (MAS3_SX|MAS3_SW|MAS3_SR)
209 /* 7. Jump to our 1:1 mapping */
212 #error You need to specify the mapping or not use this at all.
216 ori r7,r7,MSR_KERNEL@l
217 bl 1f /* Find our address */
223 rfi /* start execution out of TLB1[0] entry */
225 /* 8. Clear out the temp mapping */
226 2: lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */
227 rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */
231 rlwinm r8,r8,0,2,0 /* clear IPROT */
234 /* Invalidate TLB1 */