Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 2 | * PowerPC version |
| 3 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
| 4 | * |
| 5 | * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP |
| 6 | * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu> |
| 7 | * Adapted for Power Macintosh by Paul Mackerras. |
| 8 | * Low-level exception handlers and MMU support |
| 9 | * rewritten by Paul Mackerras. |
| 10 | * Copyright (C) 1996 Paul Mackerras. |
| 11 | * |
| 12 | * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and |
| 13 | * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com |
| 14 | * |
| 15 | * This file contains the low-level support and setup for the |
| 16 | * PowerPC-64 platform, including trap and interrupt dispatch. |
| 17 | * |
| 18 | * This program is free software; you can redistribute it and/or |
| 19 | * modify it under the terms of the GNU General Public License |
| 20 | * as published by the Free Software Foundation; either version |
| 21 | * 2 of the License, or (at your option) any later version. |
| 22 | */ |
| 23 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 24 | #include <linux/threads.h> |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 25 | #include <asm/reg.h> |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 26 | #include <asm/page.h> |
| 27 | #include <asm/mmu.h> |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 28 | #include <asm/ppc_asm.h> |
| 29 | #include <asm/asm-offsets.h> |
| 30 | #include <asm/bug.h> |
| 31 | #include <asm/cputable.h> |
| 32 | #include <asm/setup.h> |
| 33 | #include <asm/hvcall.h> |
Kelly Daly | c43a55f | 2005-11-02 15:02:47 +1100 | [diff] [blame] | 34 | #include <asm/iseries/lpar_map.h> |
David Gibson | 6cb7bfe | 2005-10-21 15:45:50 +1000 | [diff] [blame] | 35 | #include <asm/thread_info.h> |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 36 | #include <asm/firmware.h> |
Stephen Rothwell | 16a15a3 | 2007-08-20 14:58:36 +1000 | [diff] [blame] | 37 | #include <asm/page_64.h> |
Stephen Rothwell | f9ff0f3 | 2007-08-22 13:46:44 +1000 | [diff] [blame] | 38 | #include <asm/exception.h> |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 39 | #include <asm/irqflags.h> |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * We layout physical memory as follows: |
| 43 | * 0x0000 - 0x00ff : Secondary processor spin code |
| 44 | * 0x0100 - 0x2fff : pSeries Interrupt prologs |
| 45 | * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs |
| 46 | * 0x6000 - 0x6fff : Initial (CPU0) segment table |
| 47 | * 0x7000 - 0x7fff : FWNMI data area |
| 48 | * 0x8000 - : Early init and support code |
| 49 | */ |
| 50 | |
| 51 | /* |
| 52 | * SPRG Usage |
| 53 | * |
| 54 | * Register Definition |
| 55 | * |
| 56 | * SPRG0 reserved for hypervisor |
| 57 | * SPRG1 temp - used to save gpr |
| 58 | * SPRG2 temp - used to save gpr |
| 59 | * SPRG3 virt addr of paca |
| 60 | */ |
| 61 | |
| 62 | /* |
| 63 | * Entering into this code we make the following assumptions: |
| 64 | * For pSeries: |
| 65 | * 1. The MMU is off & open firmware is running in real mode. |
| 66 | * 2. The kernel is entered at __start |
| 67 | * |
| 68 | * For iSeries: |
| 69 | * 1. The MMU is on (as it always is for iSeries) |
| 70 | * 2. The kernel is entered at system_reset_iSeries |
| 71 | */ |
| 72 | |
| 73 | .text |
| 74 | .globl _stext |
| 75 | _stext: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 76 | _GLOBAL(__start) |
| 77 | /* NOP this out unconditionally */ |
| 78 | BEGIN_FTR_SECTION |
Paul Mackerras | b85a046 | 2005-10-06 10:59:19 +1000 | [diff] [blame] | 79 | b .__start_initialization_multiplatform |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 80 | END_FTR_SECTION(0, 1) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 81 | |
| 82 | /* Catch branch to 0 in real mode */ |
| 83 | trap |
| 84 | |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 85 | /* Secondary processors spin on this value until it becomes nonzero. |
| 86 | * When it does it contains the real address of the descriptor |
| 87 | * of the function that the cpu should jump to to continue |
| 88 | * initialization. |
| 89 | */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 90 | .globl __secondary_hold_spinloop |
| 91 | __secondary_hold_spinloop: |
| 92 | .llong 0x0 |
| 93 | |
| 94 | /* Secondary processors write this value with their cpu # */ |
| 95 | /* after they enter the spin loop immediately below. */ |
| 96 | .globl __secondary_hold_acknowledge |
| 97 | __secondary_hold_acknowledge: |
| 98 | .llong 0x0 |
| 99 | |
Michael Ellerman | 1dce0e3 | 2006-06-23 18:15:37 +1000 | [diff] [blame] | 100 | #ifdef CONFIG_PPC_ISERIES |
| 101 | /* |
| 102 | * At offset 0x20, there is a pointer to iSeries LPAR data. |
| 103 | * This is required by the hypervisor |
| 104 | */ |
| 105 | . = 0x20 |
| 106 | .llong hvReleaseData-KERNELBASE |
| 107 | #endif /* CONFIG_PPC_ISERIES */ |
| 108 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 109 | . = 0x60 |
| 110 | /* |
Geoff Levand | 75423b7 | 2007-06-16 08:06:23 +1000 | [diff] [blame] | 111 | * The following code is used to hold secondary processors |
| 112 | * in a spin loop after they have entered the kernel, but |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 113 | * before the bulk of the kernel has been relocated. This code |
| 114 | * is relocated to physical address 0x60 before prom_init is run. |
| 115 | * All of it must fit below the first exception vector at 0x100. |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 116 | * Use .globl here not _GLOBAL because we want __secondary_hold |
| 117 | * to be the actual text address, not a descriptor. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 118 | */ |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 119 | .globl __secondary_hold |
| 120 | __secondary_hold: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 121 | mfmsr r24 |
| 122 | ori r24,r24,MSR_RI |
| 123 | mtmsrd r24 /* RI on */ |
| 124 | |
Anton Blanchard | f1870f7 | 2006-02-13 18:11:13 +1100 | [diff] [blame] | 125 | /* Grab our physical cpu number */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 126 | mr r24,r3 |
| 127 | |
| 128 | /* Tell the master cpu we're here */ |
| 129 | /* Relocation is off & we are located at an address less */ |
| 130 | /* than 0x100, so only need to grab low order offset. */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 131 | std r24,__secondary_hold_acknowledge-_stext(0) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 132 | sync |
| 133 | |
| 134 | /* All secondary cpus wait here until told to start. */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 135 | 100: ld r4,__secondary_hold_spinloop-_stext(0) |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 136 | cmpdi 0,r4,0 |
| 137 | beq 100b |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 138 | |
Anton Blanchard | f1870f7 | 2006-02-13 18:11:13 +1100 | [diff] [blame] | 139 | #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 140 | ld r4,0(r4) /* deref function descriptor */ |
Michael Ellerman | 758438a | 2005-12-05 15:49:00 -0600 | [diff] [blame] | 141 | mtctr r4 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 142 | mr r3,r24 |
Michael Ellerman | 758438a | 2005-12-05 15:49:00 -0600 | [diff] [blame] | 143 | bctr |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 144 | #else |
| 145 | BUG_OPCODE |
| 146 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 147 | |
| 148 | /* This value is used to mark exception frames on the stack. */ |
| 149 | .section ".toc","aw" |
| 150 | exception_marker: |
| 151 | .tc ID_72656773_68657265[TC],0x7265677368657265 |
| 152 | .text |
| 153 | |
| 154 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 155 | * This is the start of the interrupt handlers for pSeries |
| 156 | * This code runs with relocation off. |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 157 | * Code from here to __end_interrupts gets copied down to real |
| 158 | * address 0x100 when we are running a relocatable kernel. |
| 159 | * Therefore any relative branches in this section must only |
| 160 | * branch to labels in this section. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 161 | */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 162 | . = 0x100 |
| 163 | .globl __start_interrupts |
| 164 | __start_interrupts: |
| 165 | |
| 166 | STD_EXCEPTION_PSERIES(0x100, system_reset) |
| 167 | |
| 168 | . = 0x200 |
| 169 | _machine_check_pSeries: |
| 170 | HMT_MEDIUM |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 171 | mtspr SPRN_SPRG1,r13 /* save r13 */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 172 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common) |
| 173 | |
| 174 | . = 0x300 |
| 175 | .globl data_access_pSeries |
| 176 | data_access_pSeries: |
| 177 | HMT_MEDIUM |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 178 | mtspr SPRN_SPRG1,r13 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 179 | BEGIN_FTR_SECTION |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 180 | mtspr SPRN_SPRG2,r12 |
| 181 | mfspr r13,SPRN_DAR |
| 182 | mfspr r12,SPRN_DSISR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 183 | srdi r13,r13,60 |
| 184 | rlwimi r13,r12,16,0x20 |
| 185 | mfcr r12 |
| 186 | cmpwi r13,0x2c |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 187 | beq do_stab_bolted_pSeries |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 188 | mtcrf 0x80,r12 |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 189 | mfspr r12,SPRN_SPRG2 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 190 | END_FTR_SECTION_IFCLR(CPU_FTR_SLB) |
| 191 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common) |
| 192 | |
| 193 | . = 0x380 |
| 194 | .globl data_access_slb_pSeries |
| 195 | data_access_slb_pSeries: |
| 196 | HMT_MEDIUM |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 197 | mtspr SPRN_SPRG1,r13 |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 198 | mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 199 | std r3,PACA_EXSLB+EX_R3(r13) |
| 200 | mfspr r3,SPRN_DAR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 201 | std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 202 | mfcr r9 |
| 203 | #ifdef __DISABLED__ |
| 204 | /* Keep that around for when we re-implement dynamic VSIDs */ |
| 205 | cmpdi r3,0 |
| 206 | bge slb_miss_user_pseries |
| 207 | #endif /* __DISABLED__ */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 208 | std r10,PACA_EXSLB+EX_R10(r13) |
| 209 | std r11,PACA_EXSLB+EX_R11(r13) |
| 210 | std r12,PACA_EXSLB+EX_R12(r13) |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 211 | mfspr r10,SPRN_SPRG1 |
| 212 | std r10,PACA_EXSLB+EX_R13(r13) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 213 | mfspr r12,SPRN_SRR1 /* and SRR1 */ |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 214 | #ifndef CONFIG_RELOCATABLE |
| 215 | b .slb_miss_realmode |
| 216 | #else |
| 217 | /* |
| 218 | * We can't just use a direct branch to .slb_miss_realmode |
| 219 | * because the distance from here to there depends on where |
| 220 | * the kernel ends up being put. |
| 221 | */ |
| 222 | mfctr r11 |
| 223 | ld r10,PACAKBASE(r13) |
| 224 | LOAD_HANDLER(r10, .slb_miss_realmode) |
| 225 | mtctr r10 |
| 226 | bctr |
| 227 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 228 | |
| 229 | STD_EXCEPTION_PSERIES(0x400, instruction_access) |
| 230 | |
| 231 | . = 0x480 |
| 232 | .globl instruction_access_slb_pSeries |
| 233 | instruction_access_slb_pSeries: |
| 234 | HMT_MEDIUM |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 235 | mtspr SPRN_SPRG1,r13 |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 236 | mfspr r13,SPRN_SPRG3 /* get paca address into r13 */ |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 237 | std r3,PACA_EXSLB+EX_R3(r13) |
| 238 | mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 239 | std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */ |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 240 | mfcr r9 |
| 241 | #ifdef __DISABLED__ |
| 242 | /* Keep that around for when we re-implement dynamic VSIDs */ |
| 243 | cmpdi r3,0 |
| 244 | bge slb_miss_user_pseries |
| 245 | #endif /* __DISABLED__ */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 246 | std r10,PACA_EXSLB+EX_R10(r13) |
| 247 | std r11,PACA_EXSLB+EX_R11(r13) |
| 248 | std r12,PACA_EXSLB+EX_R12(r13) |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 249 | mfspr r10,SPRN_SPRG1 |
| 250 | std r10,PACA_EXSLB+EX_R13(r13) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 251 | mfspr r12,SPRN_SRR1 /* and SRR1 */ |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 252 | #ifndef CONFIG_RELOCATABLE |
| 253 | b .slb_miss_realmode |
| 254 | #else |
| 255 | mfctr r11 |
| 256 | ld r10,PACAKBASE(r13) |
| 257 | LOAD_HANDLER(r10, .slb_miss_realmode) |
| 258 | mtctr r10 |
| 259 | bctr |
| 260 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 261 | |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 262 | MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 263 | STD_EXCEPTION_PSERIES(0x600, alignment) |
| 264 | STD_EXCEPTION_PSERIES(0x700, program_check) |
| 265 | STD_EXCEPTION_PSERIES(0x800, fp_unavailable) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 266 | MASKABLE_EXCEPTION_PSERIES(0x900, decrementer) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 267 | STD_EXCEPTION_PSERIES(0xa00, trap_0a) |
| 268 | STD_EXCEPTION_PSERIES(0xb00, trap_0b) |
| 269 | |
| 270 | . = 0xc00 |
| 271 | .globl system_call_pSeries |
| 272 | system_call_pSeries: |
| 273 | HMT_MEDIUM |
Paul Mackerras | 745a14c | 2008-04-28 13:52:31 +1000 | [diff] [blame] | 274 | BEGIN_FTR_SECTION |
| 275 | cmpdi r0,0x1ebe |
| 276 | beq- 1f |
| 277 | END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 278 | mr r9,r13 |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 279 | mfspr r13,SPRN_SPRG3 |
| 280 | mfspr r11,SPRN_SRR0 |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 281 | ld r12,PACAKBASE(r13) |
| 282 | ld r10,PACAKMSR(r13) |
| 283 | LOAD_HANDLER(r12, system_call_entry) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 284 | mtspr SPRN_SRR0,r12 |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 285 | mfspr r12,SPRN_SRR1 |
| 286 | mtspr SPRN_SRR1,r10 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 287 | rfid |
| 288 | b . /* prevent speculative execution */ |
| 289 | |
Paul Mackerras | 745a14c | 2008-04-28 13:52:31 +1000 | [diff] [blame] | 290 | /* Fast LE/BE switch system call */ |
| 291 | 1: mfspr r12,SPRN_SRR1 |
| 292 | xori r12,r12,MSR_LE |
| 293 | mtspr SPRN_SRR1,r12 |
| 294 | rfid /* return to userspace */ |
| 295 | b . |
| 296 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 297 | STD_EXCEPTION_PSERIES(0xd00, single_step) |
| 298 | STD_EXCEPTION_PSERIES(0xe00, trap_0e) |
| 299 | |
| 300 | /* We need to deal with the Altivec unavailable exception |
| 301 | * here which is at 0xf20, thus in the middle of the |
| 302 | * prolog code of the PerformanceMonitor one. A little |
| 303 | * trickery is thus necessary |
| 304 | */ |
| 305 | . = 0xf00 |
| 306 | b performance_monitor_pSeries |
| 307 | |
Michael Neuling | 10e3439 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 308 | . = 0xf20 |
| 309 | b altivec_unavailable_pSeries |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 310 | |
Michael Neuling | ce48b21 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 311 | . = 0xf40 |
| 312 | b vsx_unavailable_pSeries |
| 313 | |
Benjamin Herrenschmidt | acf7d76 | 2006-06-19 20:33:16 +0200 | [diff] [blame] | 314 | #ifdef CONFIG_CBE_RAS |
| 315 | HSTD_EXCEPTION_PSERIES(0x1200, cbe_system_error) |
| 316 | #endif /* CONFIG_CBE_RAS */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 317 | STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint) |
Benjamin Herrenschmidt | acf7d76 | 2006-06-19 20:33:16 +0200 | [diff] [blame] | 318 | #ifdef CONFIG_CBE_RAS |
| 319 | HSTD_EXCEPTION_PSERIES(0x1600, cbe_maintenance) |
| 320 | #endif /* CONFIG_CBE_RAS */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 321 | STD_EXCEPTION_PSERIES(0x1700, altivec_assist) |
Benjamin Herrenschmidt | acf7d76 | 2006-06-19 20:33:16 +0200 | [diff] [blame] | 322 | #ifdef CONFIG_CBE_RAS |
| 323 | HSTD_EXCEPTION_PSERIES(0x1800, cbe_thermal) |
| 324 | #endif /* CONFIG_CBE_RAS */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 325 | |
| 326 | . = 0x3000 |
| 327 | |
| 328 | /*** pSeries interrupt support ***/ |
| 329 | |
| 330 | /* moved from 0xf00 */ |
Livio Soares | 449d846 | 2007-02-07 12:51:36 +1100 | [diff] [blame] | 331 | STD_EXCEPTION_PSERIES(., performance_monitor) |
Michael Neuling | 10e3439 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 332 | STD_EXCEPTION_PSERIES(., altivec_unavailable) |
Michael Neuling | ce48b21 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 333 | STD_EXCEPTION_PSERIES(., vsx_unavailable) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 334 | |
| 335 | /* |
| 336 | * An interrupt came in while soft-disabled; clear EE in SRR1, |
| 337 | * clear paca->hard_enabled and return. |
| 338 | */ |
| 339 | masked_interrupt: |
| 340 | stb r10,PACAHARDIRQEN(r13) |
| 341 | mtcrf 0x80,r9 |
| 342 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 343 | mfspr r10,SPRN_SRR1 |
| 344 | rldicl r10,r10,48,1 /* clear MSR_EE */ |
| 345 | rotldi r10,r10,16 |
| 346 | mtspr SPRN_SRR1,r10 |
| 347 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 348 | mfspr r13,SPRN_SPRG1 |
| 349 | rfid |
| 350 | b . |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 351 | |
| 352 | .align 7 |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 353 | do_stab_bolted_pSeries: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 354 | mtcrf 0x80,r12 |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 355 | mfspr r12,SPRN_SPRG2 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 356 | EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted) |
| 357 | |
Paul Mackerras | 9a95516 | 2008-08-30 11:39:26 +1000 | [diff] [blame] | 358 | #ifdef CONFIG_PPC_PSERIES |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 359 | /* |
Paul Mackerras | 9a95516 | 2008-08-30 11:39:26 +1000 | [diff] [blame] | 360 | * Vectors for the FWNMI option. Share common code. |
| 361 | */ |
| 362 | .globl system_reset_fwnmi |
| 363 | .align 7 |
| 364 | system_reset_fwnmi: |
| 365 | HMT_MEDIUM |
| 366 | mtspr SPRN_SPRG1,r13 /* save r13 */ |
| 367 | EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common) |
| 368 | |
| 369 | .globl machine_check_fwnmi |
| 370 | .align 7 |
| 371 | machine_check_fwnmi: |
| 372 | HMT_MEDIUM |
| 373 | mtspr SPRN_SPRG1,r13 /* save r13 */ |
| 374 | EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common) |
| 375 | |
| 376 | #endif /* CONFIG_PPC_PSERIES */ |
| 377 | |
| 378 | #ifdef __DISABLED__ |
| 379 | /* |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 380 | * This is used for when the SLB miss handler has to go virtual, |
| 381 | * which doesn't happen for now anymore but will once we re-implement |
| 382 | * dynamic VSIDs for shared page tables |
| 383 | */ |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 384 | slb_miss_user_pseries: |
| 385 | std r10,PACA_EXGEN+EX_R10(r13) |
| 386 | std r11,PACA_EXGEN+EX_R11(r13) |
| 387 | std r12,PACA_EXGEN+EX_R12(r13) |
| 388 | mfspr r10,SPRG1 |
| 389 | ld r11,PACA_EXSLB+EX_R9(r13) |
| 390 | ld r12,PACA_EXSLB+EX_R3(r13) |
| 391 | std r10,PACA_EXGEN+EX_R13(r13) |
| 392 | std r11,PACA_EXGEN+EX_R9(r13) |
| 393 | std r12,PACA_EXGEN+EX_R3(r13) |
| 394 | clrrdi r12,r13,32 |
| 395 | mfmsr r10 |
| 396 | mfspr r11,SRR0 /* save SRR0 */ |
| 397 | ori r12,r12,slb_miss_user_common@l /* virt addr of handler */ |
| 398 | ori r10,r10,MSR_IR|MSR_DR|MSR_RI |
| 399 | mtspr SRR0,r12 |
| 400 | mfspr r12,SRR1 /* and SRR1 */ |
| 401 | mtspr SRR1,r10 |
| 402 | rfid |
| 403 | b . /* prevent spec. execution */ |
| 404 | #endif /* __DISABLED__ */ |
| 405 | |
Paul Mackerras | 9a95516 | 2008-08-30 11:39:26 +1000 | [diff] [blame] | 406 | .align 7 |
| 407 | .globl __end_interrupts |
| 408 | __end_interrupts: |
| 409 | |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 410 | /* |
Paul Mackerras | 9a95516 | 2008-08-30 11:39:26 +1000 | [diff] [blame] | 411 | * Code from here down to __end_handlers is invoked from the |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 412 | * exception prologs above. Because the prologs assemble the |
| 413 | * addresses of these handlers using the LOAD_HANDLER macro, |
| 414 | * which uses an addi instruction, these handlers must be in |
| 415 | * the first 32k of the kernel image. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 416 | */ |
Stephen Rothwell | 9e4859e | 2007-09-18 17:25:12 +1000 | [diff] [blame] | 417 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 418 | /*** Common interrupt handlers ***/ |
| 419 | |
| 420 | STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception) |
| 421 | |
| 422 | /* |
| 423 | * Machine check is different because we use a different |
| 424 | * save area: PACA_EXMC instead of PACA_EXGEN. |
| 425 | */ |
| 426 | .align 7 |
| 427 | .globl machine_check_common |
| 428 | machine_check_common: |
| 429 | EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 430 | FINISH_NAP |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 431 | DISABLE_INTS |
| 432 | bl .save_nvgprs |
| 433 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 434 | bl .machine_check_exception |
| 435 | b .ret_from_except |
| 436 | |
| 437 | STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt) |
| 438 | STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception) |
| 439 | STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception) |
| 440 | STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception) |
| 441 | STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception) |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 442 | STD_EXCEPTION_COMMON_IDLE(0xf00, performance_monitor, .performance_monitor_exception) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 443 | STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) |
| 444 | #ifdef CONFIG_ALTIVEC |
| 445 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception) |
| 446 | #else |
| 447 | STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception) |
| 448 | #endif |
Benjamin Herrenschmidt | acf7d76 | 2006-06-19 20:33:16 +0200 | [diff] [blame] | 449 | #ifdef CONFIG_CBE_RAS |
| 450 | STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception) |
| 451 | STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception) |
| 452 | STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) |
| 453 | #endif /* CONFIG_CBE_RAS */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 454 | |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 455 | .align 7 |
| 456 | system_call_entry: |
| 457 | b system_call_common |
| 458 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 459 | /* |
| 460 | * Here we have detected that the kernel stack pointer is bad. |
| 461 | * R9 contains the saved CR, r13 points to the paca, |
| 462 | * r10 contains the (bad) kernel stack pointer, |
| 463 | * r11 and r12 contain the saved SRR0 and SRR1. |
| 464 | * We switch to using an emergency stack, save the registers there, |
| 465 | * and call kernel_bad_stack(), which panics. |
| 466 | */ |
| 467 | bad_stack: |
| 468 | ld r1,PACAEMERGSP(r13) |
| 469 | subi r1,r1,64+INT_FRAME_SIZE |
| 470 | std r9,_CCR(r1) |
| 471 | std r10,GPR1(r1) |
| 472 | std r11,_NIP(r1) |
| 473 | std r12,_MSR(r1) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 474 | mfspr r11,SPRN_DAR |
| 475 | mfspr r12,SPRN_DSISR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 476 | std r11,_DAR(r1) |
| 477 | std r12,_DSISR(r1) |
| 478 | mflr r10 |
| 479 | mfctr r11 |
| 480 | mfxer r12 |
| 481 | std r10,_LINK(r1) |
| 482 | std r11,_CTR(r1) |
| 483 | std r12,_XER(r1) |
| 484 | SAVE_GPR(0,r1) |
| 485 | SAVE_GPR(2,r1) |
| 486 | SAVE_4GPRS(3,r1) |
| 487 | SAVE_2GPRS(7,r1) |
| 488 | SAVE_10GPRS(12,r1) |
| 489 | SAVE_10GPRS(22,r1) |
Olof Johansson | 6873040 | 2007-04-24 01:11:55 +1000 | [diff] [blame] | 490 | lhz r12,PACA_TRAP_SAVE(r13) |
| 491 | std r12,_TRAP(r1) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 492 | addi r11,r1,INT_FRAME_SIZE |
| 493 | std r11,0(r1) |
| 494 | li r12,0 |
| 495 | std r12,0(r11) |
| 496 | ld r2,PACATOC(r13) |
| 497 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 498 | bl .kernel_bad_stack |
| 499 | b 1b |
| 500 | |
| 501 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 502 | * Here r13 points to the paca, r9 contains the saved CR, |
| 503 | * SRR0 and SRR1 are saved in r11 and r12, |
| 504 | * r9 - r13 are saved in paca->exgen. |
| 505 | */ |
| 506 | .align 7 |
| 507 | .globl data_access_common |
| 508 | data_access_common: |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 509 | mfspr r10,SPRN_DAR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 510 | std r10,PACA_EXGEN+EX_DAR(r13) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 511 | mfspr r10,SPRN_DSISR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 512 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 513 | EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN) |
| 514 | ld r3,PACA_EXGEN+EX_DAR(r13) |
| 515 | lwz r4,PACA_EXGEN+EX_DSISR(r13) |
| 516 | li r5,0x300 |
| 517 | b .do_hash_page /* Try to handle as hpte fault */ |
| 518 | |
| 519 | .align 7 |
| 520 | .globl instruction_access_common |
| 521 | instruction_access_common: |
| 522 | EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN) |
| 523 | ld r3,_NIP(r1) |
| 524 | andis. r4,r12,0x5820 |
| 525 | li r5,0x400 |
| 526 | b .do_hash_page /* Try to handle as hpte fault */ |
| 527 | |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 528 | /* |
| 529 | * Here is the common SLB miss user that is used when going to virtual |
| 530 | * mode for SLB misses, that is currently not used |
| 531 | */ |
| 532 | #ifdef __DISABLED__ |
| 533 | .align 7 |
| 534 | .globl slb_miss_user_common |
| 535 | slb_miss_user_common: |
| 536 | mflr r10 |
| 537 | std r3,PACA_EXGEN+EX_DAR(r13) |
| 538 | stw r9,PACA_EXGEN+EX_CCR(r13) |
| 539 | std r10,PACA_EXGEN+EX_LR(r13) |
| 540 | std r11,PACA_EXGEN+EX_SRR0(r13) |
| 541 | bl .slb_allocate_user |
| 542 | |
| 543 | ld r10,PACA_EXGEN+EX_LR(r13) |
| 544 | ld r3,PACA_EXGEN+EX_R3(r13) |
| 545 | lwz r9,PACA_EXGEN+EX_CCR(r13) |
| 546 | ld r11,PACA_EXGEN+EX_SRR0(r13) |
| 547 | mtlr r10 |
| 548 | beq- slb_miss_fault |
| 549 | |
| 550 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
| 551 | beq- unrecov_user_slb |
| 552 | mfmsr r10 |
| 553 | |
| 554 | .machine push |
| 555 | .machine "power4" |
| 556 | mtcrf 0x80,r9 |
| 557 | .machine pop |
| 558 | |
| 559 | clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */ |
| 560 | mtmsrd r10,1 |
| 561 | |
| 562 | mtspr SRR0,r11 |
| 563 | mtspr SRR1,r12 |
| 564 | |
| 565 | ld r9,PACA_EXGEN+EX_R9(r13) |
| 566 | ld r10,PACA_EXGEN+EX_R10(r13) |
| 567 | ld r11,PACA_EXGEN+EX_R11(r13) |
| 568 | ld r12,PACA_EXGEN+EX_R12(r13) |
| 569 | ld r13,PACA_EXGEN+EX_R13(r13) |
| 570 | rfid |
| 571 | b . |
| 572 | |
| 573 | slb_miss_fault: |
| 574 | EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN) |
| 575 | ld r4,PACA_EXGEN+EX_DAR(r13) |
| 576 | li r5,0 |
| 577 | std r4,_DAR(r1) |
| 578 | std r5,_DSISR(r1) |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 579 | b handle_page_fault |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 580 | |
| 581 | unrecov_user_slb: |
| 582 | EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) |
| 583 | DISABLE_INTS |
| 584 | bl .save_nvgprs |
| 585 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 586 | bl .unrecoverable_exception |
| 587 | b 1b |
| 588 | |
| 589 | #endif /* __DISABLED__ */ |
| 590 | |
| 591 | |
| 592 | /* |
| 593 | * r13 points to the PACA, r9 contains the saved CR, |
| 594 | * r12 contain the saved SRR1, SRR0 is still ready for return |
| 595 | * r3 has the faulting address |
| 596 | * r9 - r13 are saved in paca->exslb. |
| 597 | * r3 is saved in paca->slb_r3 |
| 598 | * We assume we aren't going to take any exceptions during this procedure. |
| 599 | */ |
| 600 | _GLOBAL(slb_miss_realmode) |
| 601 | mflr r10 |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 602 | #ifdef CONFIG_RELOCATABLE |
| 603 | mtctr r11 |
| 604 | #endif |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 605 | |
| 606 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
| 607 | std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ |
| 608 | |
| 609 | bl .slb_allocate_realmode |
| 610 | |
| 611 | /* All done -- return from exception. */ |
| 612 | |
| 613 | ld r10,PACA_EXSLB+EX_LR(r13) |
| 614 | ld r3,PACA_EXSLB+EX_R3(r13) |
| 615 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ |
| 616 | #ifdef CONFIG_PPC_ISERIES |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 617 | BEGIN_FW_FTR_SECTION |
David Gibson | 3356bb9 | 2006-01-13 10:26:42 +1100 | [diff] [blame] | 618 | ld r11,PACALPPACAPTR(r13) |
| 619 | ld r11,LPPACASRR0(r11) /* get SRR0 value */ |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 620 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 621 | #endif /* CONFIG_PPC_ISERIES */ |
| 622 | |
| 623 | mtlr r10 |
| 624 | |
| 625 | andi. r10,r12,MSR_RI /* check for unrecoverable exception */ |
Paul Mackerras | 320787c | 2008-04-14 13:59:02 +1000 | [diff] [blame] | 626 | beq- 2f |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 627 | |
| 628 | .machine push |
| 629 | .machine "power4" |
| 630 | mtcrf 0x80,r9 |
| 631 | mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ |
| 632 | .machine pop |
| 633 | |
| 634 | #ifdef CONFIG_PPC_ISERIES |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 635 | BEGIN_FW_FTR_SECTION |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 636 | mtspr SPRN_SRR0,r11 |
| 637 | mtspr SPRN_SRR1,r12 |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 638 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 639 | #endif /* CONFIG_PPC_ISERIES */ |
| 640 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 641 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 642 | ld r11,PACA_EXSLB+EX_R11(r13) |
| 643 | ld r12,PACA_EXSLB+EX_R12(r13) |
| 644 | ld r13,PACA_EXSLB+EX_R13(r13) |
| 645 | rfid |
| 646 | b . /* prevent speculative execution */ |
| 647 | |
Paul Mackerras | 320787c | 2008-04-14 13:59:02 +1000 | [diff] [blame] | 648 | 2: |
| 649 | #ifdef CONFIG_PPC_ISERIES |
| 650 | BEGIN_FW_FTR_SECTION |
| 651 | b unrecov_slb |
| 652 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
| 653 | #endif /* CONFIG_PPC_ISERIES */ |
| 654 | mfspr r11,SPRN_SRR0 |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 655 | ld r10,PACAKBASE(r13) |
Paul Mackerras | 320787c | 2008-04-14 13:59:02 +1000 | [diff] [blame] | 656 | LOAD_HANDLER(r10,unrecov_slb) |
| 657 | mtspr SPRN_SRR0,r10 |
Paul Mackerras | 1f6a93e | 2008-08-30 11:40:24 +1000 | [diff] [blame] | 658 | ld r10,PACAKMSR(r13) |
Paul Mackerras | 320787c | 2008-04-14 13:59:02 +1000 | [diff] [blame] | 659 | mtspr SPRN_SRR1,r10 |
| 660 | rfid |
| 661 | b . |
| 662 | |
Benjamin Herrenschmidt | 3c726f8 | 2005-11-07 11:06:55 +1100 | [diff] [blame] | 663 | unrecov_slb: |
| 664 | EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB) |
| 665 | DISABLE_INTS |
| 666 | bl .save_nvgprs |
| 667 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 668 | bl .unrecoverable_exception |
| 669 | b 1b |
| 670 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 671 | .align 7 |
| 672 | .globl hardware_interrupt_common |
| 673 | .globl hardware_interrupt_entry |
| 674 | hardware_interrupt_common: |
| 675 | EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN) |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 676 | FINISH_NAP |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 677 | hardware_interrupt_entry: |
| 678 | DISABLE_INTS |
Olof Johansson | a416561 | 2007-09-05 12:42:30 +1000 | [diff] [blame] | 679 | BEGIN_FTR_SECTION |
Anton Blanchard | cb2c9b2 | 2006-02-13 14:48:35 +1100 | [diff] [blame] | 680 | bl .ppc64_runlatch_on |
Olof Johansson | a416561 | 2007-09-05 12:42:30 +1000 | [diff] [blame] | 681 | END_FTR_SECTION_IFSET(CPU_FTR_CTRL) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 682 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 683 | bl .do_IRQ |
| 684 | b .ret_from_except_lite |
| 685 | |
Paul Mackerras | f39224a | 2006-04-18 21:49:11 +1000 | [diff] [blame] | 686 | #ifdef CONFIG_PPC_970_NAP |
| 687 | power4_fixup_nap: |
| 688 | andc r9,r9,r10 |
| 689 | std r9,TI_LOCAL_FLAGS(r11) |
| 690 | ld r10,_LINK(r1) /* make idle task do the */ |
| 691 | std r10,_NIP(r1) /* equivalent of a blr */ |
| 692 | blr |
| 693 | #endif |
| 694 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 695 | .align 7 |
| 696 | .globl alignment_common |
| 697 | alignment_common: |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 698 | mfspr r10,SPRN_DAR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 699 | std r10,PACA_EXGEN+EX_DAR(r13) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 700 | mfspr r10,SPRN_DSISR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 701 | stw r10,PACA_EXGEN+EX_DSISR(r13) |
| 702 | EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN) |
| 703 | ld r3,PACA_EXGEN+EX_DAR(r13) |
| 704 | lwz r4,PACA_EXGEN+EX_DSISR(r13) |
| 705 | std r3,_DAR(r1) |
| 706 | std r4,_DSISR(r1) |
| 707 | bl .save_nvgprs |
| 708 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 709 | ENABLE_INTS |
| 710 | bl .alignment_exception |
| 711 | b .ret_from_except |
| 712 | |
| 713 | .align 7 |
| 714 | .globl program_check_common |
| 715 | program_check_common: |
| 716 | EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN) |
| 717 | bl .save_nvgprs |
| 718 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 719 | ENABLE_INTS |
| 720 | bl .program_check_exception |
| 721 | b .ret_from_except |
| 722 | |
| 723 | .align 7 |
| 724 | .globl fp_unavailable_common |
| 725 | fp_unavailable_common: |
| 726 | EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 727 | bne 1f /* if from user, just load it up */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 728 | bl .save_nvgprs |
| 729 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 730 | ENABLE_INTS |
| 731 | bl .kernel_fp_unavailable_exception |
| 732 | BUG_OPCODE |
Michael Neuling | 6f3d8e6 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 733 | 1: bl .load_up_fpu |
| 734 | b fast_exception_return |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 735 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 736 | .align 7 |
| 737 | .globl altivec_unavailable_common |
| 738 | altivec_unavailable_common: |
| 739 | EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN) |
| 740 | #ifdef CONFIG_ALTIVEC |
| 741 | BEGIN_FTR_SECTION |
Michael Neuling | 6f3d8e6 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 742 | beq 1f |
| 743 | bl .load_up_altivec |
| 744 | b fast_exception_return |
| 745 | 1: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 746 | END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) |
| 747 | #endif |
| 748 | bl .save_nvgprs |
| 749 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 750 | ENABLE_INTS |
| 751 | bl .altivec_unavailable_exception |
| 752 | b .ret_from_except |
| 753 | |
Paul Mackerras | 9a95516 | 2008-08-30 11:39:26 +1000 | [diff] [blame] | 754 | .align 7 |
| 755 | .globl vsx_unavailable_common |
| 756 | vsx_unavailable_common: |
| 757 | EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN) |
| 758 | #ifdef CONFIG_VSX |
| 759 | BEGIN_FTR_SECTION |
| 760 | bne .load_up_vsx |
| 761 | 1: |
| 762 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) |
| 763 | #endif |
| 764 | bl .save_nvgprs |
| 765 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 766 | ENABLE_INTS |
| 767 | bl .vsx_unavailable_exception |
| 768 | b .ret_from_except |
| 769 | |
| 770 | .align 7 |
| 771 | .globl __end_handlers |
| 772 | __end_handlers: |
| 773 | |
| 774 | /* |
| 775 | * Return from an exception with minimal checks. |
| 776 | * The caller is assumed to have done EXCEPTION_PROLOG_COMMON. |
| 777 | * If interrupts have been enabled, or anything has been |
| 778 | * done that might have changed the scheduling status of |
| 779 | * any task or sent any task a signal, you should use |
| 780 | * ret_from_except or ret_from_except_lite instead of this. |
| 781 | */ |
| 782 | fast_exc_return_irq: /* restores irq state too */ |
| 783 | ld r3,SOFTE(r1) |
| 784 | TRACE_AND_RESTORE_IRQ(r3); |
| 785 | ld r12,_MSR(r1) |
| 786 | rldicl r4,r12,49,63 /* get MSR_EE to LSB */ |
| 787 | stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */ |
| 788 | b 1f |
| 789 | |
| 790 | .globl fast_exception_return |
| 791 | fast_exception_return: |
| 792 | ld r12,_MSR(r1) |
| 793 | 1: ld r11,_NIP(r1) |
| 794 | andi. r3,r12,MSR_RI /* check if RI is set */ |
| 795 | beq- unrecov_fer |
| 796 | |
| 797 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
| 798 | andi. r3,r12,MSR_PR |
| 799 | beq 2f |
| 800 | ACCOUNT_CPU_USER_EXIT(r3, r4) |
| 801 | 2: |
| 802 | #endif |
| 803 | |
| 804 | ld r3,_CCR(r1) |
| 805 | ld r4,_LINK(r1) |
| 806 | ld r5,_CTR(r1) |
| 807 | ld r6,_XER(r1) |
| 808 | mtcr r3 |
| 809 | mtlr r4 |
| 810 | mtctr r5 |
| 811 | mtxer r6 |
| 812 | REST_GPR(0, r1) |
| 813 | REST_8GPRS(2, r1) |
| 814 | |
| 815 | mfmsr r10 |
| 816 | rldicl r10,r10,48,1 /* clear EE */ |
| 817 | rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */ |
| 818 | mtmsrd r10,1 |
| 819 | |
| 820 | mtspr SPRN_SRR1,r12 |
| 821 | mtspr SPRN_SRR0,r11 |
| 822 | REST_4GPRS(10, r1) |
| 823 | ld r1,GPR1(r1) |
| 824 | rfid |
| 825 | b . /* prevent speculative execution */ |
| 826 | |
| 827 | unrecov_fer: |
| 828 | bl .save_nvgprs |
| 829 | 1: addi r3,r1,STACK_FRAME_OVERHEAD |
| 830 | bl .unrecoverable_exception |
| 831 | b 1b |
| 832 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 833 | #ifdef CONFIG_ALTIVEC |
| 834 | /* |
| 835 | * load_up_altivec(unused, unused, tsk) |
| 836 | * Disable VMX for the task which had it previously, |
| 837 | * and save its vector registers in its thread_struct. |
| 838 | * Enables the VMX for use in the kernel on return. |
| 839 | * On SMP we know the VMX is free, since we give it up every |
| 840 | * switch (ie, no lazy save of the vector registers). |
| 841 | * On entry: r13 == 'current' && last_task_used_altivec != 'current' |
| 842 | */ |
| 843 | _STATIC(load_up_altivec) |
| 844 | mfmsr r5 /* grab the current MSR */ |
| 845 | oris r5,r5,MSR_VEC@h |
| 846 | mtmsrd r5 /* enable use of VMX now */ |
| 847 | isync |
| 848 | |
| 849 | /* |
| 850 | * For SMP, we don't do lazy VMX switching because it just gets too |
| 851 | * horrendously complex, especially when a task switches from one CPU |
| 852 | * to another. Instead we call giveup_altvec in switch_to. |
| 853 | * VRSAVE isn't dealt with here, that is done in the normal context |
| 854 | * switch code. Note that we could rely on vrsave value to eventually |
| 855 | * avoid saving all of the VREGs here... |
| 856 | */ |
| 857 | #ifndef CONFIG_SMP |
| 858 | ld r3,last_task_used_altivec@got(r2) |
| 859 | ld r4,0(r3) |
| 860 | cmpdi 0,r4,0 |
| 861 | beq 1f |
| 862 | /* Save VMX state to last_task_used_altivec's THREAD struct */ |
| 863 | addi r4,r4,THREAD |
| 864 | SAVE_32VRS(0,r5,r4) |
| 865 | mfvscr vr0 |
| 866 | li r10,THREAD_VSCR |
| 867 | stvx vr0,r10,r4 |
| 868 | /* Disable VMX for last_task_used_altivec */ |
| 869 | ld r5,PT_REGS(r4) |
| 870 | ld r4,_MSR-STACK_FRAME_OVERHEAD(r5) |
| 871 | lis r6,MSR_VEC@h |
| 872 | andc r4,r4,r6 |
| 873 | std r4,_MSR-STACK_FRAME_OVERHEAD(r5) |
| 874 | 1: |
| 875 | #endif /* CONFIG_SMP */ |
| 876 | /* Hack: if we get an altivec unavailable trap with VRSAVE |
| 877 | * set to all zeros, we assume this is a broken application |
| 878 | * that fails to set it properly, and thus we switch it to |
| 879 | * all 1's |
| 880 | */ |
| 881 | mfspr r4,SPRN_VRSAVE |
| 882 | cmpdi 0,r4,0 |
| 883 | bne+ 1f |
| 884 | li r4,-1 |
| 885 | mtspr SPRN_VRSAVE,r4 |
| 886 | 1: |
| 887 | /* enable use of VMX after return */ |
| 888 | ld r4,PACACURRENT(r13) |
| 889 | addi r5,r4,THREAD /* Get THREAD */ |
| 890 | oris r12,r12,MSR_VEC@h |
| 891 | std r12,_MSR(r1) |
| 892 | li r4,1 |
| 893 | li r10,THREAD_VSCR |
| 894 | stw r4,THREAD_USED_VR(r5) |
| 895 | lvx vr0,r10,r5 |
| 896 | mtvscr vr0 |
| 897 | REST_32VRS(0,r4,r5) |
| 898 | #ifndef CONFIG_SMP |
| 899 | /* Update last_task_used_math to 'current' */ |
| 900 | subi r4,r5,THREAD /* Back to 'current' */ |
| 901 | std r4,0(r3) |
| 902 | #endif /* CONFIG_SMP */ |
| 903 | /* restore registers and return */ |
Michael Neuling | 6f3d8e6 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 904 | blr |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 905 | #endif /* CONFIG_ALTIVEC */ |
| 906 | |
Michael Neuling | ce48b21 | 2008-06-25 14:07:18 +1000 | [diff] [blame] | 907 | #ifdef CONFIG_VSX |
| 908 | /* |
| 909 | * load_up_vsx(unused, unused, tsk) |
| 910 | * Disable VSX for the task which had it previously, |
| 911 | * and save its vector registers in its thread_struct. |
| 912 | * Reuse the fp and vsx saves, but first check to see if they have |
| 913 | * been saved already. |
| 914 | * On entry: r13 == 'current' && last_task_used_vsx != 'current' |
| 915 | */ |
| 916 | _STATIC(load_up_vsx) |
| 917 | /* Load FP and VSX registers if they haven't been done yet */ |
| 918 | andi. r5,r12,MSR_FP |
| 919 | beql+ load_up_fpu /* skip if already loaded */ |
| 920 | andis. r5,r12,MSR_VEC@h |
| 921 | beql+ load_up_altivec /* skip if already loaded */ |
| 922 | |
| 923 | #ifndef CONFIG_SMP |
| 924 | ld r3,last_task_used_vsx@got(r2) |
| 925 | ld r4,0(r3) |
| 926 | cmpdi 0,r4,0 |
| 927 | beq 1f |
| 928 | /* Disable VSX for last_task_used_vsx */ |
| 929 | addi r4,r4,THREAD |
| 930 | ld r5,PT_REGS(r4) |
| 931 | ld r4,_MSR-STACK_FRAME_OVERHEAD(r5) |
| 932 | lis r6,MSR_VSX@h |
| 933 | andc r6,r4,r6 |
| 934 | std r6,_MSR-STACK_FRAME_OVERHEAD(r5) |
| 935 | 1: |
| 936 | #endif /* CONFIG_SMP */ |
| 937 | ld r4,PACACURRENT(r13) |
| 938 | addi r4,r4,THREAD /* Get THREAD */ |
| 939 | li r6,1 |
| 940 | stw r6,THREAD_USED_VSR(r4) /* ... also set thread used vsr */ |
| 941 | /* enable use of VSX after return */ |
| 942 | oris r12,r12,MSR_VSX@h |
| 943 | std r12,_MSR(r1) |
| 944 | #ifndef CONFIG_SMP |
| 945 | /* Update last_task_used_math to 'current' */ |
| 946 | ld r4,PACACURRENT(r13) |
| 947 | std r4,0(r3) |
| 948 | #endif /* CONFIG_SMP */ |
| 949 | b fast_exception_return |
| 950 | #endif /* CONFIG_VSX */ |
| 951 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 952 | /* |
| 953 | * Hash table stuff |
| 954 | */ |
| 955 | .align 7 |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 956 | _STATIC(do_hash_page) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 957 | std r3,_DAR(r1) |
| 958 | std r4,_DSISR(r1) |
| 959 | |
| 960 | andis. r0,r4,0xa450 /* weird error? */ |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 961 | bne- handle_page_fault /* if not, try to insert a HPTE */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 962 | BEGIN_FTR_SECTION |
| 963 | andis. r0,r4,0x0020 /* Is it a segment table fault? */ |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 964 | bne- do_ste_alloc /* If so handle it */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 965 | END_FTR_SECTION_IFCLR(CPU_FTR_SLB) |
| 966 | |
| 967 | /* |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 968 | * On iSeries, we soft-disable interrupts here, then |
| 969 | * hard-enable interrupts so that the hash_page code can spin on |
| 970 | * the hash_table_lock without problems on a shared processor. |
| 971 | */ |
| 972 | DISABLE_INTS |
| 973 | |
| 974 | /* |
| 975 | * Currently, trace_hardirqs_off() will be called by DISABLE_INTS |
| 976 | * and will clobber volatile registers when irq tracing is enabled |
| 977 | * so we need to reload them. It may be possible to be smarter here |
| 978 | * and move the irq tracing elsewhere but let's keep it simple for |
| 979 | * now |
| 980 | */ |
| 981 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 982 | ld r3,_DAR(r1) |
| 983 | ld r4,_DSISR(r1) |
| 984 | ld r5,_TRAP(r1) |
| 985 | ld r12,_MSR(r1) |
| 986 | clrrdi r5,r5,4 |
| 987 | #endif /* CONFIG_TRACE_IRQFLAGS */ |
| 988 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 989 | * We need to set the _PAGE_USER bit if MSR_PR is set or if we are |
| 990 | * accessing a userspace segment (even from the kernel). We assume |
| 991 | * kernel addresses always have the high bit set. |
| 992 | */ |
| 993 | rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */ |
| 994 | rotldi r0,r3,15 /* Move high bit into MSR_PR posn */ |
| 995 | orc r0,r12,r0 /* MSR_PR | ~high_bit */ |
| 996 | rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */ |
| 997 | ori r4,r4,1 /* add _PAGE_PRESENT */ |
| 998 | rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */ |
| 999 | |
| 1000 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1001 | * r3 contains the faulting address |
| 1002 | * r4 contains the required access permissions |
| 1003 | * r5 contains the trap number |
| 1004 | * |
| 1005 | * at return r3 = 0 for success |
| 1006 | */ |
| 1007 | bl .hash_page /* build HPTE if possible */ |
| 1008 | cmpdi r3,0 /* see if hash_page succeeded */ |
| 1009 | |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 1010 | BEGIN_FW_FTR_SECTION |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1011 | /* |
| 1012 | * If we had interrupts soft-enabled at the point where the |
| 1013 | * DSI/ISI occurred, and an interrupt came in during hash_page, |
| 1014 | * handle it now. |
| 1015 | * We jump to ret_from_except_lite rather than fast_exception_return |
| 1016 | * because ret_from_except_lite will check for and handle pending |
| 1017 | * interrupts if necessary. |
| 1018 | */ |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 1019 | beq 13f |
Paul Mackerras | b0a779d | 2006-10-18 10:11:22 +1000 | [diff] [blame] | 1020 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 1021 | |
Paul Mackerras | b0a779d | 2006-10-18 10:11:22 +1000 | [diff] [blame] | 1022 | BEGIN_FW_FTR_SECTION |
| 1023 | /* |
| 1024 | * Here we have interrupts hard-disabled, so it is sufficient |
| 1025 | * to restore paca->{soft,hard}_enable and get out. |
| 1026 | */ |
| 1027 | beq fast_exc_return_irq /* Return from exception on success */ |
| 1028 | END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES) |
| 1029 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1030 | /* For a hash failure, we don't bother re-enabling interrupts */ |
| 1031 | ble- 12f |
| 1032 | |
| 1033 | /* |
| 1034 | * hash_page couldn't handle it, set soft interrupt enable back |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 1035 | * to what it was before the trap. Note that .raw_local_irq_restore |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1036 | * handles any interrupts pending at this point. |
| 1037 | */ |
| 1038 | ld r3,SOFTE(r1) |
Benjamin Herrenschmidt | 945feb1 | 2008-04-17 14:35:01 +1000 | [diff] [blame] | 1039 | TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f) |
| 1040 | bl .raw_local_irq_restore |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1041 | b 11f |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1042 | |
| 1043 | /* Here we have a page fault that hash_page can't handle. */ |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 1044 | handle_page_fault: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1045 | ENABLE_INTS |
| 1046 | 11: ld r4,_DAR(r1) |
| 1047 | ld r5,_DSISR(r1) |
| 1048 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1049 | bl .do_page_fault |
| 1050 | cmpdi r3,0 |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 1051 | beq+ 13f |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1052 | bl .save_nvgprs |
| 1053 | mr r5,r3 |
| 1054 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 1055 | lwz r4,_DAR(r1) |
| 1056 | bl .bad_page_fault |
| 1057 | b .ret_from_except |
| 1058 | |
Paul Mackerras | 79acbb3 | 2006-12-04 15:59:07 +1100 | [diff] [blame] | 1059 | 13: b .ret_from_except_lite |
| 1060 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1061 | /* We have a page fault that hash_page could handle but HV refused |
| 1062 | * the PTE insertion |
| 1063 | */ |
| 1064 | 12: bl .save_nvgprs |
Paul Mackerras | fa28237 | 2008-01-24 08:35:13 +1100 | [diff] [blame] | 1065 | mr r5,r3 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1066 | addi r3,r1,STACK_FRAME_OVERHEAD |
Benjamin Herrenschmidt | a792e75 | 2007-11-07 17:17:02 +1100 | [diff] [blame] | 1067 | ld r4,_DAR(r1) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1068 | bl .low_hash_fault |
| 1069 | b .ret_from_except |
| 1070 | |
| 1071 | /* here we have a segment miss */ |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 1072 | do_ste_alloc: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1073 | bl .ste_allocate /* try to insert stab entry */ |
| 1074 | cmpdi r3,0 |
Paul Mackerras | 3ccfc65 | 2006-11-02 09:44:37 +1100 | [diff] [blame] | 1075 | bne- handle_page_fault |
| 1076 | b fast_exception_return |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1077 | |
| 1078 | /* |
| 1079 | * r13 points to the PACA, r9 contains the saved CR, |
| 1080 | * r11 and r12 contain the saved SRR0 and SRR1. |
| 1081 | * r9 - r13 are saved in paca->exslb. |
| 1082 | * We assume we aren't going to take any exceptions during this procedure. |
| 1083 | * We assume (DAR >> 60) == 0xc. |
| 1084 | */ |
| 1085 | .align 7 |
| 1086 | _GLOBAL(do_stab_bolted) |
| 1087 | stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ |
| 1088 | std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */ |
| 1089 | |
| 1090 | /* Hash to the primary group */ |
| 1091 | ld r10,PACASTABVIRT(r13) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 1092 | mfspr r11,SPRN_DAR |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1093 | srdi r11,r11,28 |
| 1094 | rldimi r10,r11,7,52 /* r10 = first ste of the group */ |
| 1095 | |
| 1096 | /* Calculate VSID */ |
| 1097 | /* This is a kernel address, so protovsid = ESID */ |
Paul Mackerras | 1189be6 | 2007-10-11 20:37:10 +1000 | [diff] [blame] | 1098 | ASM_VSID_SCRAMBLE(r11, r9, 256M) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1099 | rldic r9,r11,12,16 /* r9 = vsid << 12 */ |
| 1100 | |
| 1101 | /* Search the primary group for a free entry */ |
| 1102 | 1: ld r11,0(r10) /* Test valid bit of the current ste */ |
| 1103 | andi. r11,r11,0x80 |
| 1104 | beq 2f |
| 1105 | addi r10,r10,16 |
| 1106 | andi. r11,r10,0x70 |
| 1107 | bne 1b |
| 1108 | |
| 1109 | /* Stick for only searching the primary group for now. */ |
| 1110 | /* At least for now, we use a very simple random castout scheme */ |
| 1111 | /* Use the TB as a random number ; OR in 1 to avoid entry 0 */ |
| 1112 | mftb r11 |
| 1113 | rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */ |
| 1114 | ori r11,r11,0x10 |
| 1115 | |
| 1116 | /* r10 currently points to an ste one past the group of interest */ |
| 1117 | /* make it point to the randomly selected entry */ |
| 1118 | subi r10,r10,128 |
| 1119 | or r10,r10,r11 /* r10 is the entry to invalidate */ |
| 1120 | |
| 1121 | isync /* mark the entry invalid */ |
| 1122 | ld r11,0(r10) |
| 1123 | rldicl r11,r11,56,1 /* clear the valid bit */ |
| 1124 | rotldi r11,r11,8 |
| 1125 | std r11,0(r10) |
| 1126 | sync |
| 1127 | |
| 1128 | clrrdi r11,r11,28 /* Get the esid part of the ste */ |
| 1129 | slbie r11 |
| 1130 | |
| 1131 | 2: std r9,8(r10) /* Store the vsid part of the ste */ |
| 1132 | eieio |
| 1133 | |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 1134 | mfspr r11,SPRN_DAR /* Get the new esid */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1135 | clrrdi r11,r11,28 /* Permits a full 32b of ESID */ |
| 1136 | ori r11,r11,0x90 /* Turn on valid and kp */ |
| 1137 | std r11,0(r10) /* Put new entry back into the stab */ |
| 1138 | |
| 1139 | sync |
| 1140 | |
| 1141 | /* All done -- return from exception. */ |
| 1142 | lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ |
| 1143 | ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */ |
| 1144 | |
| 1145 | andi. r10,r12,MSR_RI |
| 1146 | beq- unrecov_slb |
| 1147 | |
| 1148 | mtcrf 0x80,r9 /* restore CR */ |
| 1149 | |
| 1150 | mfmsr r10 |
| 1151 | clrrdi r10,r10,2 |
| 1152 | mtmsrd r10,1 |
| 1153 | |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 1154 | mtspr SPRN_SRR0,r11 |
| 1155 | mtspr SPRN_SRR1,r12 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1156 | ld r9,PACA_EXSLB+EX_R9(r13) |
| 1157 | ld r10,PACA_EXSLB+EX_R10(r13) |
| 1158 | ld r11,PACA_EXSLB+EX_R11(r13) |
| 1159 | ld r12,PACA_EXSLB+EX_R12(r13) |
| 1160 | ld r13,PACA_EXSLB+EX_R13(r13) |
| 1161 | rfid |
| 1162 | b . /* prevent speculative execution */ |
| 1163 | |
| 1164 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1165 | * Space for CPU0's segment table. |
| 1166 | * |
| 1167 | * On iSeries, the hypervisor must fill in at least one entry before |
Stephen Rothwell | 16a15a3 | 2007-08-20 14:58:36 +1000 | [diff] [blame] | 1168 | * we get control (with relocate on). The address is given to the hv |
| 1169 | * as a page number (see xLparMap below), so this must be at a |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1170 | * fixed address (the linker can't compute (u64)&initial_stab >> |
| 1171 | * PAGE_SHIFT). |
| 1172 | */ |
Michael Ellerman | 758438a | 2005-12-05 15:49:00 -0600 | [diff] [blame] | 1173 | . = STAB0_OFFSET /* 0x6000 */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1174 | .globl initial_stab |
| 1175 | initial_stab: |
| 1176 | .space 4096 |
| 1177 | |
Stephen Rothwell | 9e4859e | 2007-09-18 17:25:12 +1000 | [diff] [blame] | 1178 | #ifdef CONFIG_PPC_PSERIES |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1179 | /* |
| 1180 | * Data area reserved for FWNMI option. |
| 1181 | * This address (0x7000) is fixed by the RPA. |
| 1182 | */ |
| 1183 | .= 0x7000 |
| 1184 | .globl fwnmi_data_area |
| 1185 | fwnmi_data_area: |
Stephen Rothwell | 9e4859e | 2007-09-18 17:25:12 +1000 | [diff] [blame] | 1186 | #endif /* CONFIG_PPC_PSERIES */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1187 | |
| 1188 | /* iSeries does not use the FWNMI stuff, so it is safe to put |
| 1189 | * this here, even if we later allow kernels that will boot on |
| 1190 | * both pSeries and iSeries */ |
| 1191 | #ifdef CONFIG_PPC_ISERIES |
| 1192 | . = LPARMAP_PHYS |
Stephen Rothwell | 16a15a3 | 2007-08-20 14:58:36 +1000 | [diff] [blame] | 1193 | .globl xLparMap |
| 1194 | xLparMap: |
| 1195 | .quad HvEsidsToMap /* xNumberEsids */ |
| 1196 | .quad HvRangesToMap /* xNumberRanges */ |
| 1197 | .quad STAB0_PAGE /* xSegmentTableOffs */ |
| 1198 | .zero 40 /* xRsvd */ |
| 1199 | /* xEsids (HvEsidsToMap entries of 2 quads) */ |
| 1200 | .quad PAGE_OFFSET_ESID /* xKernelEsid */ |
| 1201 | .quad PAGE_OFFSET_VSID /* xKernelVsid */ |
| 1202 | .quad VMALLOC_START_ESID /* xKernelEsid */ |
| 1203 | .quad VMALLOC_START_VSID /* xKernelVsid */ |
| 1204 | /* xRanges (HvRangesToMap entries of 3 quads) */ |
| 1205 | .quad HvPagesToMap /* xPages */ |
| 1206 | .quad 0 /* xOffset */ |
| 1207 | .quad PAGE_OFFSET_VSID << (SID_SHIFT - HW_PAGE_SHIFT) /* xVPN */ |
| 1208 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1209 | #endif /* CONFIG_PPC_ISERIES */ |
| 1210 | |
Stephen Rothwell | 9e4859e | 2007-09-18 17:25:12 +1000 | [diff] [blame] | 1211 | #ifdef CONFIG_PPC_PSERIES |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1212 | . = 0x8000 |
Stephen Rothwell | 9e4859e | 2007-09-18 17:25:12 +1000 | [diff] [blame] | 1213 | #endif /* CONFIG_PPC_PSERIES */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1214 | |
| 1215 | /* |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1216 | * On pSeries and most other platforms, secondary processors spin |
| 1217 | * in the following code. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1218 | * At entry, r3 = this processor's number (physical cpu id) |
| 1219 | */ |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1220 | _GLOBAL(generic_secondary_smp_init) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1221 | mr r24,r3 |
| 1222 | |
| 1223 | /* turn on 64-bit mode */ |
| 1224 | bl .enable_64b_mode |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1225 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1226 | /* get the TOC pointer (real address) */ |
| 1227 | bl .relative_toc |
| 1228 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1229 | /* Set up a paca value for this processor. Since we have the |
| 1230 | * physical cpu id in r24, we need to search the pacas to find |
| 1231 | * which logical id maps to our physical one. |
| 1232 | */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1233 | LOAD_REG_ADDR(r13, paca) /* Get base vaddr of paca array */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1234 | li r5,0 /* logical cpu id */ |
| 1235 | 1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */ |
| 1236 | cmpw r6,r24 /* Compare to our id */ |
| 1237 | beq 2f |
| 1238 | addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */ |
| 1239 | addi r5,r5,1 |
| 1240 | cmpwi r5,NR_CPUS |
| 1241 | blt 1b |
| 1242 | |
| 1243 | mr r3,r24 /* not found, copy phys to r3 */ |
| 1244 | b .kexec_wait /* next kernel might do better */ |
| 1245 | |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 1246 | 2: mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1247 | /* From now on, r24 is expected to be logical cpuid */ |
| 1248 | mr r24,r5 |
| 1249 | 3: HMT_LOW |
| 1250 | lbz r23,PACAPROCSTART(r13) /* Test if this processor should */ |
| 1251 | /* start. */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1252 | |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1253 | #ifndef CONFIG_SMP |
| 1254 | b 3b /* Never go on non-SMP */ |
| 1255 | #else |
| 1256 | cmpwi 0,r23,0 |
| 1257 | beq 3b /* Loop until told to go */ |
| 1258 | |
Sonny Rao | b6f6b98 | 2008-07-12 09:00:26 +1000 | [diff] [blame] | 1259 | sync /* order paca.run and cur_cpu_spec */ |
| 1260 | |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1261 | /* See if we need to call a cpu state restore handler */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1262 | LOAD_REG_ADDR(r23, cur_cpu_spec) |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1263 | ld r23,0(r23) |
| 1264 | ld r23,CPU_SPEC_RESTORE(r23) |
| 1265 | cmpdi 0,r23,0 |
| 1266 | beq 4f |
| 1267 | ld r23,0(r23) |
| 1268 | mtctr r23 |
| 1269 | bctrl |
| 1270 | |
| 1271 | 4: /* Create a temp kernel stack for use before relocation is on. */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1272 | ld r1,PACAEMERGSP(r13) |
| 1273 | subi r1,r1,STACK_FRAME_OVERHEAD |
| 1274 | |
Stephen Rothwell | c705677 | 2006-11-27 14:59:50 +1100 | [diff] [blame] | 1275 | b __secondary_start |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1276 | #endif |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1277 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1278 | /* |
| 1279 | * Turn the MMU off. |
| 1280 | * Assumes we're mapped EA == RA if the MMU is on. |
| 1281 | */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1282 | _STATIC(__mmu_off) |
| 1283 | mfmsr r3 |
| 1284 | andi. r0,r3,MSR_IR|MSR_DR |
| 1285 | beqlr |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1286 | mflr r4 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1287 | andc r3,r3,r0 |
| 1288 | mtspr SPRN_SRR0,r4 |
| 1289 | mtspr SPRN_SRR1,r3 |
| 1290 | sync |
| 1291 | rfid |
| 1292 | b . /* prevent speculative execution */ |
| 1293 | |
| 1294 | |
| 1295 | /* |
| 1296 | * Here is our main kernel entry point. We support currently 2 kind of entries |
| 1297 | * depending on the value of r5. |
| 1298 | * |
| 1299 | * r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content |
| 1300 | * in r3...r7 |
| 1301 | * |
| 1302 | * r5 == NULL -> kexec style entry. r3 is a physical pointer to the |
| 1303 | * DT block, r4 is a physical pointer to the kernel itself |
| 1304 | * |
| 1305 | */ |
| 1306 | _GLOBAL(__start_initialization_multiplatform) |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1307 | /* Make sure we are running in 64 bits mode */ |
| 1308 | bl .enable_64b_mode |
| 1309 | |
| 1310 | /* Get TOC pointer (current runtime address) */ |
| 1311 | bl .relative_toc |
| 1312 | |
| 1313 | /* find out where we are now */ |
| 1314 | bcl 20,31,$+4 |
| 1315 | 0: mflr r26 /* r26 = runtime addr here */ |
| 1316 | addis r26,r26,(_stext - 0b)@ha |
| 1317 | addi r26,r26,(_stext - 0b)@l /* current runtime base addr */ |
| 1318 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1319 | /* |
| 1320 | * Are we booted from a PROM Of-type client-interface ? |
| 1321 | */ |
| 1322 | cmpldi cr0,r5,0 |
Stephen Rothwell | 939e60f6 | 2007-07-31 16:44:13 +1000 | [diff] [blame] | 1323 | beq 1f |
| 1324 | b .__boot_from_prom /* yes -> prom */ |
| 1325 | 1: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1326 | /* Save parameters */ |
| 1327 | mr r31,r3 |
| 1328 | mr r30,r4 |
| 1329 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1330 | /* Setup some critical 970 SPRs before switching MMU off */ |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1331 | mfspr r0,SPRN_PVR |
| 1332 | srwi r0,r0,16 |
| 1333 | cmpwi r0,0x39 /* 970 */ |
| 1334 | beq 1f |
| 1335 | cmpwi r0,0x3c /* 970FX */ |
| 1336 | beq 1f |
| 1337 | cmpwi r0,0x44 /* 970MP */ |
Olof Johansson | 190a24f | 2006-10-25 17:32:40 -0500 | [diff] [blame] | 1338 | beq 1f |
| 1339 | cmpwi r0,0x45 /* 970GX */ |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1340 | bne 2f |
| 1341 | 1: bl .__cpu_preinit_ppc970 |
| 1342 | 2: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1343 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1344 | /* Switch off MMU if not already off */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1345 | bl .__mmu_off |
| 1346 | b .__after_prom_start |
| 1347 | |
Stephen Rothwell | 939e60f6 | 2007-07-31 16:44:13 +1000 | [diff] [blame] | 1348 | _INIT_STATIC(__boot_from_prom) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1349 | /* Save parameters */ |
| 1350 | mr r31,r3 |
| 1351 | mr r30,r4 |
| 1352 | mr r29,r5 |
| 1353 | mr r28,r6 |
| 1354 | mr r27,r7 |
| 1355 | |
Olaf Hering | 6088857 | 2006-03-23 21:50:59 +0100 | [diff] [blame] | 1356 | /* |
| 1357 | * Align the stack to 16-byte boundary |
| 1358 | * Depending on the size and layout of the ELF sections in the initial |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1359 | * boot binary, the stack pointer may be unaligned on PowerMac |
Olaf Hering | 6088857 | 2006-03-23 21:50:59 +0100 | [diff] [blame] | 1360 | */ |
Linus Torvalds | c05b477 | 2006-03-04 15:00:45 -0800 | [diff] [blame] | 1361 | rldicr r1,r1,0,59 |
| 1362 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1363 | /* Restore parameters */ |
| 1364 | mr r3,r31 |
| 1365 | mr r4,r30 |
| 1366 | mr r5,r29 |
| 1367 | mr r6,r28 |
| 1368 | mr r7,r27 |
| 1369 | |
| 1370 | /* Do all of the interaction with OF client interface */ |
| 1371 | bl .prom_init |
| 1372 | /* We never return */ |
| 1373 | trap |
| 1374 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1375 | _STATIC(__after_prom_start) |
| 1376 | |
| 1377 | /* |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1378 | * We need to run with _stext at physical address PHYSICAL_START. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1379 | * This will leave some code in the first 256B of |
| 1380 | * real memory, which are reserved for software use. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1381 | * |
| 1382 | * Note: This process overwrites the OF exception vectors. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1383 | */ |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 1384 | LOAD_REG_IMMEDIATE(r3, PHYSICAL_START) /* target addr */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1385 | cmpd r3,r26 /* In some cases the loader may */ |
| 1386 | beq 9f /* have already put us at zero */ |
| 1387 | mr r4,r26 /* source address */ |
| 1388 | lis r5,(copy_to_here - _stext)@ha |
| 1389 | addi r5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1390 | li r6,0x100 /* Start offset, the first 0x100 */ |
| 1391 | /* bytes were copied earlier. */ |
| 1392 | |
| 1393 | bl .copy_and_flush /* copy the first n bytes */ |
| 1394 | /* this includes the code being */ |
| 1395 | /* executed here. */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1396 | addis r8,r3,(4f - _stext)@ha /* Jump to the copy of this code */ |
| 1397 | addi r8,r8,(4f - _stext)@l /* that we just made */ |
| 1398 | mtctr r8 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1399 | bctr |
| 1400 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1401 | 4: /* Now copy the rest of the kernel up to _end */ |
| 1402 | addis r5,r26,(p_end - _stext)@ha |
| 1403 | ld r5,(p_end - _stext)@l(r5) /* get _end */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1404 | bl .copy_and_flush /* copy the rest */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1405 | |
| 1406 | 9: b .start_here_multiplatform |
| 1407 | |
| 1408 | p_end: .llong _end - _stext |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1409 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1410 | /* |
| 1411 | * Copy routine used to copy the kernel to start at physical address 0 |
| 1412 | * and flush and invalidate the caches as needed. |
| 1413 | * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset |
| 1414 | * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5. |
| 1415 | * |
| 1416 | * Note: this routine *only* clobbers r0, r6 and lr |
| 1417 | */ |
| 1418 | _GLOBAL(copy_and_flush) |
| 1419 | addi r5,r5,-8 |
| 1420 | addi r6,r6,-8 |
Olof Johansson | 5a2fe38 | 2006-09-06 14:34:41 -0500 | [diff] [blame] | 1421 | 4: li r0,8 /* Use the smallest common */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1422 | /* denominator cache line */ |
| 1423 | /* size. This results in */ |
| 1424 | /* extra cache line flushes */ |
| 1425 | /* but operation is correct. */ |
| 1426 | /* Can't get cache line size */ |
| 1427 | /* from NACA as it is being */ |
| 1428 | /* moved too. */ |
| 1429 | |
| 1430 | mtctr r0 /* put # words/line in ctr */ |
| 1431 | 3: addi r6,r6,8 /* copy a cache line */ |
| 1432 | ldx r0,r6,r4 |
| 1433 | stdx r0,r6,r3 |
| 1434 | bdnz 3b |
| 1435 | dcbst r6,r3 /* write it to memory */ |
| 1436 | sync |
| 1437 | icbi r6,r3 /* flush the icache line */ |
| 1438 | cmpld 0,r6,r5 |
| 1439 | blt 4b |
| 1440 | sync |
| 1441 | addi r5,r5,8 |
| 1442 | addi r6,r6,8 |
| 1443 | blr |
| 1444 | |
| 1445 | .align 8 |
| 1446 | copy_to_here: |
| 1447 | |
| 1448 | #ifdef CONFIG_SMP |
| 1449 | #ifdef CONFIG_PPC_PMAC |
| 1450 | /* |
| 1451 | * On PowerMac, secondary processors starts from the reset vector, which |
| 1452 | * is temporarily turned into a call to one of the functions below. |
| 1453 | */ |
| 1454 | .section ".text"; |
| 1455 | .align 2 ; |
| 1456 | |
Paul Mackerras | 35499c0 | 2005-10-22 16:02:39 +1000 | [diff] [blame] | 1457 | .globl __secondary_start_pmac_0 |
| 1458 | __secondary_start_pmac_0: |
| 1459 | /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */ |
| 1460 | li r24,0 |
| 1461 | b 1f |
| 1462 | li r24,1 |
| 1463 | b 1f |
| 1464 | li r24,2 |
| 1465 | b 1f |
| 1466 | li r24,3 |
| 1467 | 1: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1468 | |
| 1469 | _GLOBAL(pmac_secondary_start) |
| 1470 | /* turn on 64-bit mode */ |
| 1471 | bl .enable_64b_mode |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1472 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1473 | /* get TOC pointer (real address) */ |
| 1474 | bl .relative_toc |
| 1475 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1476 | /* Copy some CPU settings from CPU 0 */ |
Olof Johansson | f39b7a5 | 2006-08-11 00:07:08 -0500 | [diff] [blame] | 1477 | bl .__restore_cpu_ppc970 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1478 | |
| 1479 | /* pSeries do that early though I don't think we really need it */ |
| 1480 | mfmsr r3 |
| 1481 | ori r3,r3,MSR_RI |
| 1482 | mtmsrd r3 /* RI on */ |
| 1483 | |
| 1484 | /* Set up a paca value for this processor. */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1485 | LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */ |
| 1486 | mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1487 | add r13,r13,r4 /* for this processor. */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1488 | mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1489 | |
| 1490 | /* Create a temp kernel stack for use before relocation is on. */ |
| 1491 | ld r1,PACAEMERGSP(r13) |
| 1492 | subi r1,r1,STACK_FRAME_OVERHEAD |
| 1493 | |
Stephen Rothwell | c705677 | 2006-11-27 14:59:50 +1100 | [diff] [blame] | 1494 | b __secondary_start |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1495 | |
| 1496 | #endif /* CONFIG_PPC_PMAC */ |
| 1497 | |
| 1498 | /* |
| 1499 | * This function is called after the master CPU has released the |
| 1500 | * secondary processors. The execution environment is relocation off. |
| 1501 | * The paca for this processor has the following fields initialized at |
| 1502 | * this point: |
| 1503 | * 1. Processor number |
| 1504 | * 2. Segment table pointer (virtual address) |
| 1505 | * On entry the following are set: |
| 1506 | * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries |
| 1507 | * r24 = cpu# (in Linux terms) |
| 1508 | * r13 = paca virtual address |
| 1509 | * SPRG3 = paca virtual address |
| 1510 | */ |
Stephen Rothwell | fc68e86 | 2007-08-22 13:44:58 +1000 | [diff] [blame] | 1511 | .globl __secondary_start |
Stephen Rothwell | c705677 | 2006-11-27 14:59:50 +1100 | [diff] [blame] | 1512 | __secondary_start: |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 1513 | /* Set thread priority to MEDIUM */ |
| 1514 | HMT_MEDIUM |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1515 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 1516 | /* Do early setup for that CPU (stab, slb, hash table pointer) */ |
| 1517 | bl .early_setup_secondary |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1518 | |
| 1519 | /* Initialize the kernel stack. Just a repeat for iSeries. */ |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 1520 | LOAD_REG_ADDR(r3, current_set) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1521 | sldi r28,r24,3 /* get current_set[cpu#] */ |
| 1522 | ldx r1,r3,r28 |
| 1523 | addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD |
| 1524 | std r1,PACAKSAVE(r13) |
| 1525 | |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 1526 | /* Clear backchain so we get nice backtraces */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1527 | li r7,0 |
| 1528 | mtlr r7 |
| 1529 | |
| 1530 | /* enable MMU and jump to start_secondary */ |
David Gibson | e58c349 | 2006-01-13 14:56:25 +1100 | [diff] [blame] | 1531 | LOAD_REG_ADDR(r3, .start_secondary_prolog) |
| 1532 | LOAD_REG_IMMEDIATE(r4, MSR_KERNEL) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 1533 | #ifdef CONFIG_PPC_ISERIES |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 1534 | BEGIN_FW_FTR_SECTION |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1535 | ori r4,r4,MSR_EE |
Benjamin Herrenschmidt | ff3da2e | 2008-04-02 15:58:40 +1100 | [diff] [blame] | 1536 | li r8,1 |
| 1537 | stb r8,PACAHARDIRQEN(r13) |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 1538 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1539 | #endif |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 1540 | BEGIN_FW_FTR_SECTION |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 1541 | stb r7,PACAHARDIRQEN(r13) |
| 1542 | END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES) |
Benjamin Herrenschmidt | ff3da2e | 2008-04-02 15:58:40 +1100 | [diff] [blame] | 1543 | stb r7,PACASOFTIRQEN(r13) |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 1544 | |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 1545 | mtspr SPRN_SRR0,r3 |
| 1546 | mtspr SPRN_SRR1,r4 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1547 | rfid |
| 1548 | b . /* prevent speculative execution */ |
| 1549 | |
| 1550 | /* |
| 1551 | * Running with relocation on at this point. All we want to do is |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1552 | * zero the stack back-chain pointer and get the TOC virtual address |
| 1553 | * before going into C code. |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1554 | */ |
| 1555 | _GLOBAL(start_secondary_prolog) |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1556 | ld r2,PACATOC(r13) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1557 | li r3,0 |
| 1558 | std r3,0(r1) /* Zero the stack frame pointer */ |
| 1559 | bl .start_secondary |
Paul Mackerras | 799d604 | 2005-11-10 13:37:51 +1100 | [diff] [blame] | 1560 | b . |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1561 | #endif |
| 1562 | |
| 1563 | /* |
| 1564 | * This subroutine clobbers r11 and r12 |
| 1565 | */ |
| 1566 | _GLOBAL(enable_64b_mode) |
| 1567 | mfmsr r11 /* grab the current MSR */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1568 | li r12,(MSR_SF | MSR_ISF)@highest |
| 1569 | sldi r12,r12,48 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1570 | or r11,r11,r12 |
| 1571 | mtmsrd r11 |
| 1572 | isync |
| 1573 | blr |
| 1574 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1575 | /* |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1576 | * This puts the TOC pointer into r2, offset by 0x8000 (as expected |
| 1577 | * by the toolchain). It computes the correct value for wherever we |
| 1578 | * are running at the moment, using position-independent code. |
| 1579 | */ |
| 1580 | _GLOBAL(relative_toc) |
| 1581 | mflr r0 |
| 1582 | bcl 20,31,$+4 |
| 1583 | 0: mflr r9 |
| 1584 | ld r2,(p_toc - 0b)(r9) |
| 1585 | add r2,r2,r9 |
| 1586 | mtlr r0 |
| 1587 | blr |
| 1588 | |
| 1589 | p_toc: .llong __toc_start + 0x8000 - 0b |
| 1590 | |
| 1591 | /* |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1592 | * This is where the main kernel code starts. |
| 1593 | */ |
Stephen Rothwell | 939e60f6 | 2007-07-31 16:44:13 +1000 | [diff] [blame] | 1594 | _INIT_STATIC(start_here_multiplatform) |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1595 | /* set up the TOC (real address) */ |
| 1596 | bl .relative_toc |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1597 | |
| 1598 | /* Clear out the BSS. It may have been done in prom_init, |
| 1599 | * already but that's irrelevant since prom_init will soon |
| 1600 | * be detached from the kernel completely. Besides, we need |
| 1601 | * to clear it now for kexec-style entry. |
| 1602 | */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1603 | LOAD_REG_ADDR(r11,__bss_stop) |
| 1604 | LOAD_REG_ADDR(r8,__bss_start) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1605 | sub r11,r11,r8 /* bss size */ |
| 1606 | addi r11,r11,7 /* round up to an even double word */ |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1607 | srdi. r11,r11,3 /* shift right by 3 */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1608 | beq 4f |
| 1609 | addi r8,r8,-8 |
| 1610 | li r0,0 |
| 1611 | mtctr r11 /* zero this many doublewords */ |
| 1612 | 3: stdu r0,8(r8) |
| 1613 | bdnz 3b |
| 1614 | 4: |
| 1615 | |
| 1616 | mfmsr r6 |
| 1617 | ori r6,r6,MSR_RI |
| 1618 | mtmsrd r6 /* RI on */ |
| 1619 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1620 | /* The following gets the stack set up with the regs */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1621 | /* pointing to the real addr of the kernel stack. This is */ |
| 1622 | /* all done to support the C function call below which sets */ |
| 1623 | /* up the htab. This is done because we have relocated the */ |
| 1624 | /* kernel but are still running in real mode. */ |
| 1625 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1626 | LOAD_REG_ADDR(r3,init_thread_union) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1627 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1628 | /* set up a stack pointer */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1629 | addi r1,r3,THREAD_SIZE |
| 1630 | li r0,0 |
| 1631 | stdu r0,-STACK_FRAME_OVERHEAD(r1) |
| 1632 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1633 | /* Do very early kernel initializations, including initial hash table, |
| 1634 | * stab and slb setup before we turn on relocation. */ |
| 1635 | |
| 1636 | /* Restore parameters passed from prom_init/kexec */ |
| 1637 | mr r3,r31 |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1638 | bl .early_setup /* also sets r13 and SPRG3 */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1639 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1640 | LOAD_REG_ADDR(r3, .start_here_common) |
| 1641 | ld r4,PACAKMSR(r13) |
Paul Mackerras | b5bbeb2 | 2005-10-10 14:01:07 +1000 | [diff] [blame] | 1642 | mtspr SPRN_SRR0,r3 |
| 1643 | mtspr SPRN_SRR1,r4 |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1644 | rfid |
| 1645 | b . /* prevent speculative execution */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1646 | |
| 1647 | /* This is where all platforms converge execution */ |
Stephen Rothwell | fc68e86 | 2007-08-22 13:44:58 +1000 | [diff] [blame] | 1648 | _INIT_GLOBAL(start_here_common) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1649 | /* relocation is on at this point */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1650 | std r1,PACAKSAVE(r13) |
| 1651 | |
Paul Mackerras | e31aa45 | 2008-08-30 11:41:12 +1000 | [diff] [blame^] | 1652 | /* Load the TOC (virtual address) */ |
| 1653 | ld r2,PACATOC(r13) |
| 1654 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1655 | bl .setup_system |
| 1656 | |
| 1657 | /* Load up the kernel context */ |
| 1658 | 5: |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1659 | li r5,0 |
Paul Mackerras | d04c56f | 2006-10-04 16:47:49 +1000 | [diff] [blame] | 1660 | stb r5,PACASOFTIRQEN(r13) /* Soft Disabled */ |
| 1661 | #ifdef CONFIG_PPC_ISERIES |
| 1662 | BEGIN_FW_FTR_SECTION |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1663 | mfmsr r5 |
Benjamin Herrenschmidt | ff3da2e | 2008-04-02 15:58:40 +1100 | [diff] [blame] | 1664 | ori r5,r5,MSR_EE /* Hard Enabled on iSeries*/ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1665 | mtmsrd r5 |
Benjamin Herrenschmidt | ff3da2e | 2008-04-02 15:58:40 +1100 | [diff] [blame] | 1666 | li r5,1 |
Stephen Rothwell | 3f639ee | 2006-09-25 18:19:00 +1000 | [diff] [blame] | 1667 | END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1668 | #endif |
Benjamin Herrenschmidt | ff3da2e | 2008-04-02 15:58:40 +1100 | [diff] [blame] | 1669 | stb r5,PACAHARDIRQEN(r13) /* Hard Disabled on others */ |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1670 | |
Benjamin Herrenschmidt | ff3da2e | 2008-04-02 15:58:40 +1100 | [diff] [blame] | 1671 | bl .start_kernel |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1672 | |
Anton Blanchard | f1870f7 | 2006-02-13 18:11:13 +1100 | [diff] [blame] | 1673 | /* Not reached */ |
| 1674 | BUG_OPCODE |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1675 | |
Paul Mackerras | 14cf11a | 2005-09-26 16:04:21 +1000 | [diff] [blame] | 1676 | /* |
| 1677 | * We put a few things here that have to be page-aligned. |
| 1678 | * This stuff goes at the beginning of the bss, which is page-aligned. |
| 1679 | */ |
| 1680 | .section ".bss" |
| 1681 | |
| 1682 | .align PAGE_SHIFT |
| 1683 | |
| 1684 | .globl empty_zero_page |
| 1685 | empty_zero_page: |
| 1686 | .space PAGE_SIZE |
| 1687 | |
| 1688 | .globl swapper_pg_dir |
| 1689 | swapper_pg_dir: |
Stephen Rothwell | ee7a76d | 2007-09-18 17:22:59 +1000 | [diff] [blame] | 1690 | .space PGD_TABLE_SIZE |