exception.S 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. bl .relative_toc
  38. mfspr r13,SPRN_SPRG3 /* Get alpaca address */
  39. LOAD_REG_ADDR(r23, alpaca)
  40. li r0,ALPACA_SIZE
  41. sub r23,r13,r23
  42. divdu r23,r23,r0 /* r23 has cpu number */
  43. LOAD_REG_ADDR(r13, paca)
  44. mulli r0,r23,PACA_SIZE
  45. add r13,r13,r0
  46. mtspr SPRN_SPRG_PACA,r13 /* Save it away for the future */
  47. mfmsr r24
  48. ori r24,r24,MSR_RI
  49. mtmsrd r24 /* RI on */
  50. mr r24,r23
  51. cmpwi 0,r24,0 /* Are we processor 0? */
  52. bne 1f
  53. b .__start_initialization_iSeries /* Start up the first processor */
  54. 1: mfspr r4,SPRN_CTRLF
  55. li r5,CTRL_RUNLATCH /* Turn off the run light */
  56. andc r4,r4,r5
  57. mtspr SPRN_CTRLT,r4
  58. /* Spin on __secondary_hold_spinloop until it is updated by the boot cpu. */
  59. /* In the UP case we'll yield() later, and we will not access the paca anyway */
  60. #ifdef CONFIG_SMP
  61. 1:
  62. HMT_LOW
  63. LOAD_REG_ADDR(r23, __secondary_hold_spinloop)
  64. ld r23,0(r23)
  65. sync
  66. LOAD_REG_ADDR(r3,current_set)
  67. sldi r28,r24,3 /* get current_set[cpu#] */
  68. ldx r3,r3,r28
  69. addi r1,r3,THREAD_SIZE
  70. subi r1,r1,STACK_FRAME_OVERHEAD
  71. cmpwi 0,r23,0 /* Keep poking the Hypervisor until */
  72. bne 2f /* we're released */
  73. /* Let the Hypervisor know we are alive */
  74. /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
  75. lis r3,0x8002
  76. rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */
  77. li r0,-1 /* r0=-1 indicates a Hypervisor call */
  78. sc /* Invoke the hypervisor via a system call */
  79. b 1b
  80. #endif
  81. 2:
  82. HMT_LOW
  83. #ifdef CONFIG_SMP
  84. lbz r23,PACAPROCSTART(r13) /* Test if this processor
  85. * should start */
  86. sync
  87. LOAD_REG_ADDR(r3,current_set)
  88. sldi r28,r24,3 /* get current_set[cpu#] */
  89. ldx r3,r3,r28
  90. addi r1,r3,THREAD_SIZE
  91. subi r1,r1,STACK_FRAME_OVERHEAD
  92. cmpwi 0,r23,0
  93. beq iSeries_secondary_smp_loop /* Loop until told to go */
  94. b __secondary_start /* Loop until told to go */
  95. iSeries_secondary_smp_loop:
  96. /* Let the Hypervisor know we are alive */
  97. /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
  98. lis r3,0x8002
  99. rldicr r3,r3,32,15 /* r0 = (r3 << 32) & 0xffff000000000000 */
  100. #else /* CONFIG_SMP */
  101. /* Yield the processor. This is required for non-SMP kernels
  102. which are running on multi-threaded machines. */
  103. lis r3,0x8000
  104. rldicr r3,r3,32,15 /* r3 = (r3 << 32) & 0xffff000000000000 */
  105. addi r3,r3,18 /* r3 = 0x8000000000000012 which is "yield" */
  106. li r4,0 /* "yield timed" */
  107. li r5,-1 /* "yield forever" */
  108. #endif /* CONFIG_SMP */
  109. li r0,-1 /* r0=-1 indicates a Hypervisor call */
  110. sc /* Invoke the hypervisor via a system call */
  111. mfspr r13,SPRN_SPRG_PACA /* Put r13 back ???? */
  112. b 2b /* If SMP not configured, secondaries
  113. * loop forever */
  114. /*** ISeries-LPAR interrupt handlers ***/
  115. STD_EXCEPTION_ISERIES(machine_check, PACA_EXMC)
  116. .globl data_access_iSeries
  117. data_access_iSeries:
  118. mtspr SPRN_SPRG_SCRATCH0,r13
  119. BEGIN_FTR_SECTION
  120. mfspr r13,SPRN_SPRG_PACA
  121. std r9,PACA_EXSLB+EX_R9(r13)
  122. std r10,PACA_EXSLB+EX_R10(r13)
  123. mfspr r10,SPRN_DAR
  124. mfspr r9,SPRN_DSISR
  125. srdi r10,r10,60
  126. rlwimi r10,r9,16,0x20
  127. mfcr r9
  128. cmpwi r10,0x2c
  129. beq .do_stab_bolted_iSeries
  130. ld r10,PACA_EXSLB+EX_R10(r13)
  131. std r11,PACA_EXGEN+EX_R11(r13)
  132. ld r11,PACA_EXSLB+EX_R9(r13)
  133. std r12,PACA_EXGEN+EX_R12(r13)
  134. mfspr r12,SPRN_SPRG_SCRATCH0
  135. std r10,PACA_EXGEN+EX_R10(r13)
  136. std r11,PACA_EXGEN+EX_R9(r13)
  137. std r12,PACA_EXGEN+EX_R13(r13)
  138. EXCEPTION_PROLOG_ISERIES_1
  139. FTR_SECTION_ELSE
  140. EXCEPTION_PROLOG_1(PACA_EXGEN)
  141. EXCEPTION_PROLOG_ISERIES_1
  142. ALT_FTR_SECTION_END_IFCLR(CPU_FTR_SLB)
  143. b data_access_common
  144. .do_stab_bolted_iSeries:
  145. std r11,PACA_EXSLB+EX_R11(r13)
  146. std r12,PACA_EXSLB+EX_R12(r13)
  147. mfspr r10,SPRN_SPRG_SCRATCH0
  148. std r10,PACA_EXSLB+EX_R13(r13)
  149. EXCEPTION_PROLOG_ISERIES_1
  150. b .do_stab_bolted
  151. .globl data_access_slb_iSeries
  152. data_access_slb_iSeries:
  153. mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
  154. mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
  155. std r3,PACA_EXSLB+EX_R3(r13)
  156. mfspr r3,SPRN_DAR
  157. std r9,PACA_EXSLB+EX_R9(r13)
  158. mfcr r9
  159. #ifdef __DISABLED__
  160. cmpdi r3,0
  161. bge slb_miss_user_iseries
  162. #endif
  163. std r10,PACA_EXSLB+EX_R10(r13)
  164. std r11,PACA_EXSLB+EX_R11(r13)
  165. std r12,PACA_EXSLB+EX_R12(r13)
  166. mfspr r10,SPRN_SPRG_SCRATCH0
  167. std r10,PACA_EXSLB+EX_R13(r13)
  168. ld r12,PACALPPACAPTR(r13)
  169. ld r12,LPPACASRR1(r12)
  170. b .slb_miss_realmode
  171. STD_EXCEPTION_ISERIES(instruction_access, PACA_EXGEN)
  172. .globl instruction_access_slb_iSeries
  173. instruction_access_slb_iSeries:
  174. mtspr SPRN_SPRG_SCRATCH0,r13 /* save r13 */
  175. mfspr r13,SPRN_SPRG_PACA /* get paca address into r13 */
  176. std r3,PACA_EXSLB+EX_R3(r13)
  177. ld r3,PACALPPACAPTR(r13)
  178. ld r3,LPPACASRR0(r3) /* get SRR0 value */
  179. std r9,PACA_EXSLB+EX_R9(r13)
  180. mfcr r9
  181. #ifdef __DISABLED__
  182. cmpdi r3,0
  183. bge slb_miss_user_iseries
  184. #endif
  185. std r10,PACA_EXSLB+EX_R10(r13)
  186. std r11,PACA_EXSLB+EX_R11(r13)
  187. std r12,PACA_EXSLB+EX_R12(r13)
  188. mfspr r10,SPRN_SPRG_SCRATCH0
  189. std r10,PACA_EXSLB+EX_R13(r13)
  190. ld r12,PACALPPACAPTR(r13)
  191. ld r12,LPPACASRR1(r12)
  192. b .slb_miss_realmode
  193. #ifdef __DISABLED__
  194. slb_miss_user_iseries:
  195. std r10,PACA_EXGEN+EX_R10(r13)
  196. std r11,PACA_EXGEN+EX_R11(r13)
  197. std r12,PACA_EXGEN+EX_R12(r13)
  198. mfspr r10,SPRG_SCRATCH0
  199. ld r11,PACA_EXSLB+EX_R9(r13)
  200. ld r12,PACA_EXSLB+EX_R3(r13)
  201. std r10,PACA_EXGEN+EX_R13(r13)
  202. std r11,PACA_EXGEN+EX_R9(r13)
  203. std r12,PACA_EXGEN+EX_R3(r13)
  204. EXCEPTION_PROLOG_ISERIES_1
  205. b slb_miss_user_common
  206. #endif
  207. MASKABLE_EXCEPTION_ISERIES(hardware_interrupt)
  208. STD_EXCEPTION_ISERIES(alignment, PACA_EXGEN)
  209. STD_EXCEPTION_ISERIES(program_check, PACA_EXGEN)
  210. STD_EXCEPTION_ISERIES(fp_unavailable, PACA_EXGEN)
  211. MASKABLE_EXCEPTION_ISERIES(decrementer)
  212. STD_EXCEPTION_ISERIES(trap_0a, PACA_EXGEN)
  213. STD_EXCEPTION_ISERIES(trap_0b, PACA_EXGEN)
  214. .globl system_call_iSeries
  215. system_call_iSeries:
  216. mr r9,r13
  217. mfspr r13,SPRN_SPRG_PACA
  218. EXCEPTION_PROLOG_ISERIES_1
  219. b system_call_common
  220. STD_EXCEPTION_ISERIES(single_step, PACA_EXGEN)
  221. STD_EXCEPTION_ISERIES(trap_0e, PACA_EXGEN)
  222. STD_EXCEPTION_ISERIES(performance_monitor, PACA_EXGEN)
  223. decrementer_iSeries_masked:
  224. /* We may not have a valid TOC pointer in here. */
  225. li r11,1
  226. ld r12,PACALPPACAPTR(r13)
  227. stb r11,LPPACADECRINT(r12)
  228. LOAD_REG_IMMEDIATE(r12, tb_ticks_per_jiffy)
  229. lwz r12,0(r12)
  230. mtspr SPRN_DEC,r12
  231. /* fall through */
  232. hardware_interrupt_iSeries_masked:
  233. mtcrf 0x80,r9 /* Restore regs */
  234. ld r12,PACALPPACAPTR(r13)
  235. ld r11,LPPACASRR0(r12)
  236. ld r12,LPPACASRR1(r12)
  237. mtspr SPRN_SRR0,r11
  238. mtspr SPRN_SRR1,r12
  239. ld r9,PACA_EXGEN+EX_R9(r13)
  240. ld r10,PACA_EXGEN+EX_R10(r13)
  241. ld r11,PACA_EXGEN+EX_R11(r13)
  242. ld r12,PACA_EXGEN+EX_R12(r13)
  243. ld r13,PACA_EXGEN+EX_R13(r13)
  244. rfid
  245. b . /* prevent speculative execution */
  246. _INIT_STATIC(__start_initialization_iSeries)
  247. /* Clear out the BSS */
  248. LOAD_REG_ADDR(r11,__bss_stop)
  249. LOAD_REG_ADDR(r8,__bss_start)
  250. sub r11,r11,r8 /* bss size */
  251. addi r11,r11,7 /* round up to an even double word */
  252. rldicl. r11,r11,61,3 /* shift right by 3 */
  253. beq 4f
  254. addi r8,r8,-8
  255. li r0,0
  256. mtctr r11 /* zero this many doublewords */
  257. 3: stdu r0,8(r8)
  258. bdnz 3b
  259. 4:
  260. LOAD_REG_ADDR(r1,init_thread_union)
  261. addi r1,r1,THREAD_SIZE
  262. li r0,0
  263. stdu r0,-STACK_FRAME_OVERHEAD(r1)
  264. bl .iSeries_early_setup
  265. bl .early_setup
  266. /* relocation is on at this point */
  267. b .start_here_common