exception.S 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Low level routines for legacy iSeries support.
  3. *
  4. * Extracted from head_64.S
  5. *
  6. * PowerPC version
  7. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  8. *
  9. * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
  10. * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
  11. * Adapted for Power Macintosh by Paul Mackerras.
  12. * Low-level exception handlers and MMU support
  13. * rewritten by Paul Mackerras.
  14. * Copyright (C) 1996 Paul Mackerras.
  15. *
  16. * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
  17. * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
  18. *
  19. * This file contains the low-level support and setup for the
  20. * PowerPC-64 platform, including trap and interrupt dispatch.
  21. *
  22. * This program is free software; you can redistribute it and/or
  23. * modify it under the terms of the GNU General Public License
  24. * as published by the Free Software Foundation; either version
  25. * 2 of the License, or (at your option) any later version.
  26. */
  27. #include <asm/reg.h>
  28. #include <asm/ppc_asm.h>
  29. #include <asm/asm-offsets.h>
  30. #include <asm/thread_info.h>
  31. #include <asm/ptrace.h>
  32. #include <asm/cputable.h>
  33. #include "exception.h"
  34. .text
  35. .globl system_reset_iSeries
  36. system_reset_iSeries:
  37. mfspr r13,SPRN_SPRG3 /* Get alpaca address */
  38. LOAD_REG_IMMEDIATE(r23, alpaca)
  39. li r0,ALPACA_SIZE
  40. sub r23,r13,r23
  41. divdu r23,r23,r0 /* r23 has cpu number */
  42. LOAD_REG_IMMEDIATE(r13, paca)
  43. mulli r0,r23,PACA_SIZE
  44. add r13,r13,r0
  45. mtspr SPRN_SPRG3,r13 /* Save it away for the future */
  46. mfmsr r24
  47. ori r24,r24,MSR_RI
  48. mtmsrd r24 /* RI on */
  49. mr r24,r23
  50. cmpwi 0,r24,0 /* Are we processor 0? */
  51. bne 1f
  52. b .__start_initialization_iSeries /* Start up the first processor */
  53. 1: mfspr r4,SPRN_CTRLF
  54. li r5,CTRL_RUNLATCH /* Turn off the run light */
  55. andc r4,r4,r5
  56. mtspr SPRN_CTRLT,r4
  57. /* Spin on __secondary_hold_spinloop until it is updated by the boot cpu. */
  58. /* In the UP case we'll yeild() later, and we will not access the paca anyway */
  59. #ifdef CONFIG_SMP
  60. 1:
  61. HMT_LOW
  62. LOAD_REG_IMMEDIATE(r23, __secondary_hold_spinloop)
  63. ld r23,0(r23)
  64. sync
  65. LOAD_REG_IMMEDIATE(r3,current_set)
  66. sldi r28,r24,3 /* get current_set[cpu#] */
  67. ldx r3,r3,r28
  68. addi r1,r3,THREAD_SIZE
  69. subi r1,r1,STACK_FRAME_OVERHEAD
  70. cmpwi 0,r23,0 /* Keep poking the Hypervisor until */
  71. bne 2f /* we're released */
  72. /* Let the Hypervisor know we are alive */
  73. /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
  74. lis r3,0x8002
  75. rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */
  76. li r0,-1 /* r0=-1 indicates a Hypervisor call */
  77. sc /* Invoke the hypervisor via a system call */
  78. b 1b
  79. #endif
  80. 2:
  81. HMT_LOW
  82. #ifdef CONFIG_SMP
  83. lbz r23,PACAPROCSTART(r13) /* Test if this processor
  84. * should start */
  85. sync
  86. LOAD_REG_IMMEDIATE(r3,current_set)
  87. sldi r28,r24,3 /* get current_set[cpu#] */
  88. ldx r3,r3,r28
  89. addi r1,r3,THREAD_SIZE
  90. subi r1,r1,STACK_FRAME_OVERHEAD
  91. cmpwi 0,r23,0
  92. beq iSeries_secondary_smp_loop /* Loop until told to go */
  93. b __secondary_start /* Loop until told to go */
  94. iSeries_secondary_smp_loop:
  95. /* Let the Hypervisor know we are alive */
  96. /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
  97. lis r3,0x8002
  98. rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */
  99. #else /* CONFIG_SMP */
  100. /* Yield the processor. This is required for non-SMP kernels
  101. which are running on multi-threaded machines. */
  102. lis r3,0x8000
  103. rldicr r3,r3,32,15 /* r3 = (r3 << 32) & 0xffff000000000000 */
  104. addi r3,r3,18 /* r3 = 0x8000000000000012 which is "yield" */
  105. li r4,0 /* "yield timed" */
  106. li r5,-1 /* "yield forever" */
  107. #endif /* CONFIG_SMP */
  108. li r0,-1 /* r0=-1 indicates a Hypervisor call */
  109. sc /* Invoke the hypervisor via a system call */
  110. mfspr r13,SPRN_SPRG3 /* Put r13 back ???? */
  111. b 2b /* If SMP not configured, secondaries
  112. * loop forever */
  113. /*** ISeries-LPAR interrupt handlers ***/
  114. STD_EXCEPTION_ISERIES(machine_check, PACA_EXMC)
  115. .globl data_access_iSeries
  116. data_access_iSeries:
  117. mtspr SPRN_SPRG1,r13
  118. BEGIN_FTR_SECTION
  119. mtspr SPRN_SPRG2,r12
  120. mfspr r13,SPRN_DAR
  121. mfspr r12,SPRN_DSISR
  122. srdi r13,r13,60
  123. rlwimi r13,r12,16,0x20
  124. mfcr r12
  125. cmpwi r13,0x2c
  126. beq .do_stab_bolted_iSeries
  127. mtcrf 0x80,r12
  128. mfspr r12,SPRN_SPRG2
  129. END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
  130. EXCEPTION_PROLOG_1(PACA_EXGEN)
  131. EXCEPTION_PROLOG_ISERIES_1
  132. b data_access_common
  133. .do_stab_bolted_iSeries:
  134. mtcrf 0x80,r12
  135. mfspr r12,SPRN_SPRG2
  136. EXCEPTION_PROLOG_1(PACA_EXSLB)
  137. EXCEPTION_PROLOG_ISERIES_1
  138. b .do_stab_bolted
  139. .globl data_access_slb_iSeries
  140. data_access_slb_iSeries:
  141. mtspr SPRN_SPRG1,r13 /* save r13 */
  142. mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
  143. std r3,PACA_EXSLB+EX_R3(r13)
  144. mfspr r3,SPRN_DAR
  145. std r9,PACA_EXSLB+EX_R9(r13)
  146. mfcr r9
  147. #ifdef __DISABLED__
  148. cmpdi r3,0
  149. bge slb_miss_user_iseries
  150. #endif
  151. std r10,PACA_EXSLB+EX_R10(r13)
  152. std r11,PACA_EXSLB+EX_R11(r13)
  153. std r12,PACA_EXSLB+EX_R12(r13)
  154. mfspr r10,SPRN_SPRG1
  155. std r10,PACA_EXSLB+EX_R13(r13)
  156. ld r12,PACALPPACAPTR(r13)
  157. ld r12,LPPACASRR1(r12)
  158. b .slb_miss_realmode
  159. STD_EXCEPTION_ISERIES(instruction_access, PACA_EXGEN)
  160. .globl instruction_access_slb_iSeries
  161. instruction_access_slb_iSeries:
  162. mtspr SPRN_SPRG1,r13 /* save r13 */
  163. mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
  164. std r3,PACA_EXSLB+EX_R3(r13)
  165. ld r3,PACALPPACAPTR(r13)
  166. ld r3,LPPACASRR0(r3) /* get SRR0 value */
  167. std r9,PACA_EXSLB+EX_R9(r13)
  168. mfcr r9
  169. #ifdef __DISABLED__
  170. cmpdi r3,0
  171. bge slb_miss_user_iseries
  172. #endif
  173. std r10,PACA_EXSLB+EX_R10(r13)
  174. std r11,PACA_EXSLB+EX_R11(r13)
  175. std r12,PACA_EXSLB+EX_R12(r13)
  176. mfspr r10,SPRN_SPRG1
  177. std r10,PACA_EXSLB+EX_R13(r13)
  178. ld r12,PACALPPACAPTR(r13)
  179. ld r12,LPPACASRR1(r12)
  180. b .slb_miss_realmode
  181. #ifdef __DISABLED__
  182. slb_miss_user_iseries:
  183. std r10,PACA_EXGEN+EX_R10(r13)
  184. std r11,PACA_EXGEN+EX_R11(r13)
  185. std r12,PACA_EXGEN+EX_R12(r13)
  186. mfspr r10,SPRG1
  187. ld r11,PACA_EXSLB+EX_R9(r13)
  188. ld r12,PACA_EXSLB+EX_R3(r13)
  189. std r10,PACA_EXGEN+EX_R13(r13)
  190. std r11,PACA_EXGEN+EX_R9(r13)
  191. std r12,PACA_EXGEN+EX_R3(r13)
  192. EXCEPTION_PROLOG_ISERIES_1
  193. b slb_miss_user_common
  194. #endif
  195. MASKABLE_EXCEPTION_ISERIES(hardware_interrupt)
  196. STD_EXCEPTION_ISERIES(alignment, PACA_EXGEN)
  197. STD_EXCEPTION_ISERIES(program_check, PACA_EXGEN)
  198. STD_EXCEPTION_ISERIES(fp_unavailable, PACA_EXGEN)
  199. MASKABLE_EXCEPTION_ISERIES(decrementer)
  200. STD_EXCEPTION_ISERIES(trap_0a, PACA_EXGEN)
  201. STD_EXCEPTION_ISERIES(trap_0b, PACA_EXGEN)
  202. .globl system_call_iSeries
  203. system_call_iSeries:
  204. mr r9,r13
  205. mfspr r13,SPRN_SPRG3
  206. EXCEPTION_PROLOG_ISERIES_1
  207. b system_call_common
  208. STD_EXCEPTION_ISERIES(single_step, PACA_EXGEN)
  209. STD_EXCEPTION_ISERIES(trap_0e, PACA_EXGEN)
  210. STD_EXCEPTION_ISERIES(performance_monitor, PACA_EXGEN)
  211. decrementer_iSeries_masked:
  212. /* We may not have a valid TOC pointer in here. */
  213. li r11,1
  214. ld r12,PACALPPACAPTR(r13)
  215. stb r11,LPPACADECRINT(r12)
  216. LOAD_REG_IMMEDIATE(r12, tb_ticks_per_jiffy)
  217. lwz r12,0(r12)
  218. mtspr SPRN_DEC,r12
  219. /* fall through */
  220. hardware_interrupt_iSeries_masked:
  221. mtcrf 0x80,r9 /* Restore regs */
  222. ld r12,PACALPPACAPTR(r13)
  223. ld r11,LPPACASRR0(r12)
  224. ld r12,LPPACASRR1(r12)
  225. mtspr SPRN_SRR0,r11
  226. mtspr SPRN_SRR1,r12
  227. ld r9,PACA_EXGEN+EX_R9(r13)
  228. ld r10,PACA_EXGEN+EX_R10(r13)
  229. ld r11,PACA_EXGEN+EX_R11(r13)
  230. ld r12,PACA_EXGEN+EX_R12(r13)
  231. ld r13,PACA_EXGEN+EX_R13(r13)
  232. rfid
  233. b . /* prevent speculative execution */
  234. _INIT_STATIC(__start_initialization_iSeries)
  235. /* Clear out the BSS */
  236. LOAD_REG_IMMEDIATE(r11,__bss_stop)
  237. LOAD_REG_IMMEDIATE(r8,__bss_start)
  238. sub r11,r11,r8 /* bss size */
  239. addi r11,r11,7 /* round up to an even double word */
  240. rldicl. r11,r11,61,3 /* shift right by 3 */
  241. beq 4f
  242. addi r8,r8,-8
  243. li r0,0
  244. mtctr r11 /* zero this many doublewords */
  245. 3: stdu r0,8(r8)
  246. bdnz 3b
  247. 4:
  248. LOAD_REG_IMMEDIATE(r1,init_thread_union)
  249. addi r1,r1,THREAD_SIZE
  250. li r0,0
  251. stdu r0,-STACK_FRAME_OVERHEAD(r1)
  252. LOAD_REG_IMMEDIATE(r2,__toc_start)
  253. addi r2,r2,0x4000
  254. addi r2,r2,0x4000
  255. bl .iSeries_early_setup
  256. bl .early_setup
  257. /* relocation is on at this point */
  258. b .start_here_common