diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2008-04-15 15:52:23 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-04-16 17:46:13 -0400 |
commit | 0aef996b37d08757562ecf0bb0c1f6998e634c8b (patch) | |
tree | aaf590eeabc3c6bf0bcfa4ea1402e9c27a164213 /arch/powerpc | |
parent | d7917ba7051e3fd12ebe2d5a09b29fb3a2b38190 (diff) |
[POWERPC] 85xx: Cleanup TLB initialization
* Determine the RPN we are running the kernel at runtime rather
than using compile time constant for initial TLB
* Cleanup adjust_total_lowmem() to respect memstart_addr and
be a bit more clear on variables that are sizes vs addresses.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/head_fsl_booke.S | 34 | ||||
-rw-r--r-- | arch/powerpc/mm/fsl_booke_mmu.c | 37 |
2 files changed, 43 insertions, 28 deletions
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index d9cc2c288d9e..9f40b3e77100 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S | |||
@@ -68,7 +68,9 @@ _ENTRY(_start); | |||
68 | mr r29,r5 | 68 | mr r29,r5 |
69 | mr r28,r6 | 69 | mr r28,r6 |
70 | mr r27,r7 | 70 | mr r27,r7 |
71 | li r25,0 /* phys kernel start (low) */ | ||
71 | li r24,0 /* CPU number */ | 72 | li r24,0 /* CPU number */ |
73 | li r23,0 /* phys kernel start (high) */ | ||
72 | 74 | ||
73 | /* We try to not make any assumptions about how the boot loader | 75 | /* We try to not make any assumptions about how the boot loader |
74 | * setup or used the TLBs. We invalidate all mappings from the | 76 | * setup or used the TLBs. We invalidate all mappings from the |
@@ -167,7 +169,28 @@ skpinv: addi r6,r6,1 /* Increment */ | |||
167 | mtspr SPRN_MAS0,r7 | 169 | mtspr SPRN_MAS0,r7 |
168 | tlbre | 170 | tlbre |
169 | 171 | ||
170 | /* Just modify the entry ID, EPN and RPN for the temp mapping */ | 172 | /* grab and fixup the RPN */ |
173 | mfspr r6,SPRN_MAS1 /* extract MAS1[SIZE] */ | ||
174 | rlwinm r6,r6,25,27,30 | ||
175 | li r8,-1 | ||
176 | addi r6,r6,10 | ||
177 | slw r6,r8,r6 /* convert to mask */ | ||
178 | |||
179 | bl 1f /* Find our address */ | ||
180 | 1: mflr r7 | ||
181 | |||
182 | mfspr r8,SPRN_MAS3 | ||
183 | #ifdef CONFIG_PHYS_64BIT | ||
184 | mfspr r23,SPRN_MAS7 | ||
185 | #endif | ||
186 | and r8,r6,r8 | ||
187 | subfic r9,r6,-4096 | ||
188 | and r9,r9,r7 | ||
189 | |||
190 | or r25,r8,r9 | ||
191 | ori r8,r25,(MAS3_SX|MAS3_SW|MAS3_SR) | ||
192 | |||
193 | /* Just modify the entry ID and EPN for the temp mapping */ | ||
171 | lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */ | 194 | lis r7,0x1000 /* Set MAS0(TLBSEL) = 1 */ |
172 | rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */ | 195 | rlwimi r7,r5,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r5) */ |
173 | mtspr SPRN_MAS0,r7 | 196 | mtspr SPRN_MAS0,r7 |
@@ -177,12 +200,10 @@ skpinv: addi r6,r6,1 /* Increment */ | |||
177 | ori r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_4K))@l | 200 | ori r6,r6,(MAS1_TSIZE(BOOKE_PAGESZ_4K))@l |
178 | mtspr SPRN_MAS1,r6 | 201 | mtspr SPRN_MAS1,r6 |
179 | mfspr r6,SPRN_MAS2 | 202 | mfspr r6,SPRN_MAS2 |
180 | lis r7,PHYSICAL_START@h | 203 | li r7,0 /* temp EPN = 0 */ |
181 | rlwimi r7,r6,0,20,31 | 204 | rlwimi r7,r6,0,20,31 |
182 | mtspr SPRN_MAS2,r7 | 205 | mtspr SPRN_MAS2,r7 |
183 | mfspr r6,SPRN_MAS3 | 206 | mtspr SPRN_MAS3,r8 |
184 | rlwimi r7,r6,0,20,31 | ||
185 | mtspr SPRN_MAS3,r7 | ||
186 | tlbwe | 207 | tlbwe |
187 | 208 | ||
188 | xori r6,r4,1 | 209 | xori r6,r4,1 |
@@ -232,8 +253,7 @@ skpinv: addi r6,r6,1 /* Increment */ | |||
232 | ori r6,r6,PAGE_OFFSET@l | 253 | ori r6,r6,PAGE_OFFSET@l |
233 | rlwimi r6,r7,0,20,31 | 254 | rlwimi r6,r7,0,20,31 |
234 | mtspr SPRN_MAS2,r6 | 255 | mtspr SPRN_MAS2,r6 |
235 | li r7,(MAS3_SX|MAS3_SW|MAS3_SR) | 256 | mtspr SPRN_MAS3,r8 |
236 | mtspr SPRN_MAS3,r7 | ||
237 | tlbwe | 257 | tlbwe |
238 | 258 | ||
239 | /* 7. Jump to KERNELBASE mapping */ | 259 | /* 7. Jump to KERNELBASE mapping */ |
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c index 3dd0c8189bae..59f6649ae42a 100644 --- a/arch/powerpc/mm/fsl_booke_mmu.c +++ b/arch/powerpc/mm/fsl_booke_mmu.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <asm/mmu.h> | 49 | #include <asm/mmu.h> |
50 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
51 | #include <asm/smp.h> | 51 | #include <asm/smp.h> |
52 | #include <asm/bootx.h> | ||
53 | #include <asm/machdep.h> | 52 | #include <asm/machdep.h> |
54 | #include <asm/setup.h> | 53 | #include <asm/setup.h> |
55 | 54 | ||
@@ -59,7 +58,6 @@ extern void loadcam_entry(unsigned int index); | |||
59 | unsigned int tlbcam_index; | 58 | unsigned int tlbcam_index; |
60 | unsigned int num_tlbcam_entries; | 59 | unsigned int num_tlbcam_entries; |
61 | static unsigned long __cam0, __cam1, __cam2; | 60 | static unsigned long __cam0, __cam1, __cam2; |
62 | #define MAX_LOW_MEM CONFIG_LOWMEM_SIZE | ||
63 | 61 | ||
64 | #define NUM_TLBCAMS (16) | 62 | #define NUM_TLBCAMS (16) |
65 | 63 | ||
@@ -195,35 +193,32 @@ unsigned long __init mmu_mapin_ram(void) | |||
195 | void __init | 193 | void __init |
196 | adjust_total_lowmem(void) | 194 | adjust_total_lowmem(void) |
197 | { | 195 | { |
198 | unsigned long max_low_mem = MAX_LOW_MEM; | 196 | phys_addr_t max_lowmem_size = __max_low_memory; |
199 | unsigned long cam_max = 0x10000000; | 197 | phys_addr_t cam_max_size = 0x10000000; |
200 | unsigned long ram; | 198 | phys_addr_t ram; |
201 | 199 | ||
202 | /* adjust CAM size to max_low_mem */ | 200 | /* adjust CAM size to max_lowmem_size */ |
203 | if (max_low_mem < cam_max) | 201 | if (max_lowmem_size < cam_max_size) |
204 | cam_max = max_low_mem; | 202 | cam_max_size = max_lowmem_size; |
205 | 203 | ||
206 | /* adjust lowmem size to max_low_mem */ | 204 | /* adjust lowmem size to max_lowmem_size */ |
207 | if (max_low_mem < total_lowmem) | 205 | ram = min(max_lowmem_size, total_lowmem); |
208 | ram = max_low_mem; | ||
209 | else | ||
210 | ram = total_lowmem; | ||
211 | 206 | ||
212 | /* Calculate CAM values */ | 207 | /* Calculate CAM values */ |
213 | __cam0 = 1UL << 2 * (__ilog2(ram) / 2); | 208 | __cam0 = 1UL << 2 * (__ilog2(ram) / 2); |
214 | if (__cam0 > cam_max) | 209 | if (__cam0 > cam_max_size) |
215 | __cam0 = cam_max; | 210 | __cam0 = cam_max_size; |
216 | ram -= __cam0; | 211 | ram -= __cam0; |
217 | if (ram) { | 212 | if (ram) { |
218 | __cam1 = 1UL << 2 * (__ilog2(ram) / 2); | 213 | __cam1 = 1UL << 2 * (__ilog2(ram) / 2); |
219 | if (__cam1 > cam_max) | 214 | if (__cam1 > cam_max_size) |
220 | __cam1 = cam_max; | 215 | __cam1 = cam_max_size; |
221 | ram -= __cam1; | 216 | ram -= __cam1; |
222 | } | 217 | } |
223 | if (ram) { | 218 | if (ram) { |
224 | __cam2 = 1UL << 2 * (__ilog2(ram) / 2); | 219 | __cam2 = 1UL << 2 * (__ilog2(ram) / 2); |
225 | if (__cam2 > cam_max) | 220 | if (__cam2 > cam_max_size) |
226 | __cam2 = cam_max; | 221 | __cam2 = cam_max_size; |
227 | ram -= __cam2; | 222 | ram -= __cam2; |
228 | } | 223 | } |
229 | 224 | ||
@@ -231,6 +226,6 @@ adjust_total_lowmem(void) | |||
231 | " CAM2=%ldMb residual: %ldMb\n", | 226 | " CAM2=%ldMb residual: %ldMb\n", |
232 | __cam0 >> 20, __cam1 >> 20, __cam2 >> 20, | 227 | __cam0 >> 20, __cam1 >> 20, __cam2 >> 20, |
233 | (total_lowmem - __cam0 - __cam1 - __cam2) >> 20); | 228 | (total_lowmem - __cam0 - __cam1 - __cam2) >> 20); |
234 | __max_low_memory = max_low_mem = __cam0 + __cam1 + __cam2; | 229 | __max_low_memory = __cam0 + __cam1 + __cam2; |
235 | __initial_memory_limit = __max_low_memory; | 230 | __initial_memory_limit = memstart_addr + __max_low_memory; |
236 | } | 231 | } |