mca_asm.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * File: mca_asm.h
  3. * Purpose: Machine check handling specific defines
  4. *
  5. * Copyright (C) 1999 Silicon Graphics, Inc.
  6. * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
  7. * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
  8. * Copyright (C) 2000 Hewlett-Packard Co.
  9. * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
  10. * Copyright (C) 2002 Intel Corp.
  11. * Copyright (C) 2002 Jenna Hall <jenna.s.hall@intel.com>
  12. * Copyright (C) 2005 Silicon Graphics, Inc
  13. * Copyright (C) 2005 Keith Owens <kaos@sgi.com>
  14. */
  15. #ifndef _ASM_IA64_MCA_ASM_H
  16. #define _ASM_IA64_MCA_ASM_H
  17. #define PSR_IC 13
  18. #define PSR_I 14
  19. #define PSR_DT 17
  20. #define PSR_RT 27
  21. #define PSR_MC 35
  22. #define PSR_IT 36
  23. #define PSR_BN 44
  24. /*
  25. * This macro converts a instruction virtual address to a physical address
  26. * Right now for simulation purposes the virtual addresses are
  27. * direct mapped to physical addresses.
  28. * 1. Lop off bits 61 thru 63 in the virtual address
  29. */
  30. #define INST_VA_TO_PA(addr) \
  31. dep addr = 0, addr, 61, 3
  32. /*
  33. * This macro converts a data virtual address to a physical address
  34. * Right now for simulation purposes the virtual addresses are
  35. * direct mapped to physical addresses.
  36. * 1. Lop off bits 61 thru 63 in the virtual address
  37. */
  38. #define DATA_VA_TO_PA(addr) \
  39. tpa addr = addr
  40. /*
  41. * This macro converts a data physical address to a virtual address
  42. * Right now for simulation purposes the virtual addresses are
  43. * direct mapped to physical addresses.
  44. * 1. Put 0x7 in bits 61 thru 63.
  45. */
  46. #define DATA_PA_TO_VA(addr,temp) \
  47. mov temp = 0x7 ;; \
  48. dep addr = temp, addr, 61, 3
  49. #define GET_THIS_PADDR(reg, var) \
  50. mov reg = IA64_KR(PER_CPU_DATA);; \
  51. addl reg = THIS_CPU(var), reg
  52. /*
  53. * This macro jumps to the instruction at the given virtual address
  54. * and starts execution in physical mode with all the address
  55. * translations turned off.
  56. * 1. Save the current psr
  57. * 2. Make sure that all the upper 32 bits are off
  58. *
  59. * 3. Clear the interrupt enable and interrupt state collection bits
  60. * in the psr before updating the ipsr and iip.
  61. *
  62. * 4. Turn off the instruction, data and rse translation bits of the psr
  63. * and store the new value into ipsr
  64. * Also make sure that the interrupts are disabled.
  65. * Ensure that we are in little endian mode.
  66. * [psr.{rt, it, dt, i, be} = 0]
  67. *
  68. * 5. Get the physical address corresponding to the virtual address
  69. * of the next instruction bundle and put it in iip.
  70. * (Using magic numbers 24 and 40 in the deposint instruction since
  71. * the IA64_SDK code directly maps to lower 24bits as physical address
  72. * from a virtual address).
  73. *
  74. * 6. Do an rfi to move the values from ipsr to psr and iip to ip.
  75. */
  76. #define PHYSICAL_MODE_ENTER(temp1, temp2, start_addr, old_psr) \
  77. mov old_psr = psr; \
  78. ;; \
  79. dep old_psr = 0, old_psr, 32, 32; \
  80. \
  81. mov ar.rsc = 0 ; \
  82. ;; \
  83. srlz.d; \
  84. mov temp2 = ar.bspstore; \
  85. ;; \
  86. DATA_VA_TO_PA(temp2); \
  87. ;; \
  88. mov temp1 = ar.rnat; \
  89. ;; \
  90. mov ar.bspstore = temp2; \
  91. ;; \
  92. mov ar.rnat = temp1; \
  93. mov temp1 = psr; \
  94. mov temp2 = psr; \
  95. ;; \
  96. \
  97. dep temp2 = 0, temp2, PSR_IC, 2; \
  98. ;; \
  99. mov psr.l = temp2; \
  100. ;; \
  101. srlz.d; \
  102. dep temp1 = 0, temp1, 32, 32; \
  103. ;; \
  104. dep temp1 = 0, temp1, PSR_IT, 1; \
  105. ;; \
  106. dep temp1 = 0, temp1, PSR_DT, 1; \
  107. ;; \
  108. dep temp1 = 0, temp1, PSR_RT, 1; \
  109. ;; \
  110. dep temp1 = 0, temp1, PSR_I, 1; \
  111. ;; \
  112. dep temp1 = 0, temp1, PSR_IC, 1; \
  113. ;; \
  114. dep temp1 = -1, temp1, PSR_MC, 1; \
  115. ;; \
  116. mov cr.ipsr = temp1; \
  117. ;; \
  118. LOAD_PHYSICAL(p0, temp2, start_addr); \
  119. ;; \
  120. mov cr.iip = temp2; \
  121. mov cr.ifs = r0; \
  122. DATA_VA_TO_PA(sp); \
  123. DATA_VA_TO_PA(gp); \
  124. ;; \
  125. srlz.i; \
  126. ;; \
  127. nop 1; \
  128. nop 2; \
  129. nop 1; \
  130. nop 2; \
  131. rfi; \
  132. ;;
  133. /*
  134. * This macro jumps to the instruction at the given virtual address
  135. * and starts execution in virtual mode with all the address
  136. * translations turned on.
  137. * 1. Get the old saved psr
  138. *
  139. * 2. Clear the interrupt state collection bit in the current psr.
  140. *
  141. * 3. Set the instruction translation bit back in the old psr
  142. * Note we have to do this since we are right now saving only the
  143. * lower 32-bits of old psr.(Also the old psr has the data and
  144. * rse translation bits on)
  145. *
  146. * 4. Set ipsr to this old_psr with "it" bit set and "bn" = 1.
  147. *
  148. * 5. Reset the current thread pointer (r13).
  149. *
  150. * 6. Set iip to the virtual address of the next instruction bundle.
  151. *
  152. * 7. Do an rfi to move ipsr to psr and iip to ip.
  153. */
  154. #define VIRTUAL_MODE_ENTER(temp1, temp2, start_addr, old_psr) \
  155. mov temp2 = psr; \
  156. ;; \
  157. mov old_psr = temp2; \
  158. ;; \
  159. dep temp2 = 0, temp2, PSR_IC, 2; \
  160. ;; \
  161. mov psr.l = temp2; \
  162. mov ar.rsc = 0; \
  163. ;; \
  164. srlz.d; \
  165. mov r13 = ar.k6; \
  166. mov temp2 = ar.bspstore; \
  167. ;; \
  168. DATA_PA_TO_VA(temp2,temp1); \
  169. ;; \
  170. mov temp1 = ar.rnat; \
  171. ;; \
  172. mov ar.bspstore = temp2; \
  173. ;; \
  174. mov ar.rnat = temp1; \
  175. ;; \
  176. mov temp1 = old_psr; \
  177. ;; \
  178. mov temp2 = 1; \
  179. ;; \
  180. dep temp1 = temp2, temp1, PSR_IC, 1; \
  181. ;; \
  182. dep temp1 = temp2, temp1, PSR_IT, 1; \
  183. ;; \
  184. dep temp1 = temp2, temp1, PSR_DT, 1; \
  185. ;; \
  186. dep temp1 = temp2, temp1, PSR_RT, 1; \
  187. ;; \
  188. dep temp1 = temp2, temp1, PSR_BN, 1; \
  189. ;; \
  190. \
  191. mov cr.ipsr = temp1; \
  192. movl temp2 = start_addr; \
  193. ;; \
  194. mov cr.iip = temp2; \
  195. movl gp = __gp \
  196. ;; \
  197. DATA_PA_TO_VA(sp, temp1); \
  198. srlz.i; \
  199. ;; \
  200. nop 1; \
  201. nop 2; \
  202. nop 1; \
  203. rfi \
  204. ;;
  205. /*
  206. * The MCA and INIT stacks in struct ia64_mca_cpu look like normal kernel
  207. * stacks, except that the SAL/OS state and a switch_stack are stored near the
  208. * top of the MCA/INIT stack. To support concurrent entry to MCA or INIT, as
  209. * well as MCA over INIT, each event needs its own SAL/OS state. All entries
  210. * are 16 byte aligned.
  211. *
  212. * +---------------------------+
  213. * | pt_regs |
  214. * +---------------------------+
  215. * | switch_stack |
  216. * +---------------------------+
  217. * | SAL/OS state |
  218. * +---------------------------+
  219. * | 16 byte scratch area |
  220. * +---------------------------+ <-------- SP at start of C MCA handler
  221. * | ..... |
  222. * +---------------------------+
  223. * | RBS for MCA/INIT handler |
  224. * +---------------------------+
  225. * | struct task for MCA/INIT |
  226. * +---------------------------+ <-------- Bottom of MCA/INIT stack
  227. */
  228. #define ALIGN16(x) ((x)&~15)
  229. #define MCA_PT_REGS_OFFSET ALIGN16(KERNEL_STACK_SIZE-IA64_PT_REGS_SIZE)
  230. #define MCA_SWITCH_STACK_OFFSET ALIGN16(MCA_PT_REGS_OFFSET-IA64_SWITCH_STACK_SIZE)
  231. #define MCA_SOS_OFFSET ALIGN16(MCA_SWITCH_STACK_OFFSET-IA64_SAL_OS_STATE_SIZE)
  232. #define MCA_SP_OFFSET ALIGN16(MCA_SOS_OFFSET-16)
  233. #endif /* _ASM_IA64_MCA_ASM_H */