head64.S 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * arch/s390/kernel/head64.S
  3. *
  4. * Copyright (C) IBM Corp. 1999,2006
  5. *
  6. * Author(s): Hartmut Penner <hp@de.ibm.com>
  7. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  8. * Rob van der Heij <rvdhei@iae.nl>
  9. * Heiko Carstens <heiko.carstens@de.ibm.com>
  10. *
  11. */
  12. #
  13. # startup-code at 0x10000, running in absolute addressing mode
  14. # this is called either by the ipl loader or directly by PSW restart
  15. # or linload or SALIPL
  16. #
  17. .org 0x10000
  18. startup:basr %r13,0 # get base
  19. .LPG0: l %r13,0f-.LPG0(%r13)
  20. b 0(%r13)
  21. 0: .long startup_continue
  22. #
  23. # params at 10400 (setup.h)
  24. #
  25. .org PARMAREA
  26. .quad 0 # IPL_DEVICE
  27. .quad 0 # INITRD_START
  28. .quad 0 # INITRD_SIZE
  29. .org COMMAND_LINE
  30. .byte "root=/dev/ram0 ro"
  31. .byte 0
  32. .org 0x11000
  33. startup_continue:
  34. basr %r13,0 # get base
  35. .LPG1: sll %r13,1 # remove high order bit
  36. srl %r13,1
  37. lhi %r1,1 # mode 1 = esame
  38. mvi __LC_AR_MODE_ID,1 # set esame flag
  39. slr %r0,%r0 # set cpuid to zero
  40. sigp %r1,%r0,0x12 # switch to esame mode
  41. sam64 # switch to 64 bit mode
  42. lctlg %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
  43. lg %r12,.Lparmaddr-.LPG1(%r13) # pointer to parameter area
  44. # move IPL device to lowcore
  45. mvc __LC_IPLDEV(4),IPL_DEVICE+4-PARMAREA(%r12)
  46. #
  47. # Setup stack
  48. #
  49. larl %r15,init_thread_union
  50. lg %r14,__TI_task(%r15) # cache current in lowcore
  51. stg %r14,__LC_CURRENT
  52. aghi %r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union + THREAD_SIZE
  53. stg %r15,__LC_KERNEL_STACK # set end of kernel stack
  54. aghi %r15,-160
  55. xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear backchain
  56. #
  57. # Save ipl parameters, clear bss memory, initialize storage key for kernel pages,
  58. # and create a kernel NSS if the SAVESYS= parm is defined
  59. #
  60. brasl %r14,startup_init
  61. # set program check new psw mask
  62. mvc __LC_PGM_NEW_PSW(8),.Lpcmsk-.LPG1(%r13)
  63. larl %r12,machine_flags
  64. #
  65. # find out if we have the MVPG instruction
  66. #
  67. la %r1,0f-.LPG1(%r13) # set program check address
  68. stg %r1,__LC_PGM_NEW_PSW+8
  69. sgr %r0,%r0
  70. lghi %r1,0
  71. lghi %r2,0
  72. mvpg %r1,%r2 # test MVPG instruction
  73. oi 7(%r12),16 # set MVPG flag
  74. 0:
  75. #
  76. # find out if the diag 0x44 works in 64 bit mode
  77. #
  78. la %r1,0f-.LPG1(%r13) # set program check address
  79. stg %r1,__LC_PGM_NEW_PSW+8
  80. diag 0,0,0x44 # test diag 0x44
  81. oi 7(%r12),32 # set diag44 flag
  82. 0:
  83. #
  84. # find out if we have the IDTE instruction
  85. #
  86. la %r1,0f-.LPG1(%r13) # set program check address
  87. stg %r1,__LC_PGM_NEW_PSW+8
  88. .long 0xb2b10000 # store facility list
  89. tm 0xc8,0x08 # check bit for clearing-by-ASCE
  90. bno 0f-.LPG1(%r13)
  91. lhi %r1,2094
  92. lhi %r2,0
  93. .long 0xb98e2001
  94. oi 7(%r12),0x80 # set IDTE flag
  95. 0:
  96. #
  97. # find out if the diag 0x9c is available
  98. #
  99. la %r1,0f-.LPG1(%r13) # set program check address
  100. stg %r1,__LC_PGM_NEW_PSW+8
  101. stap __LC_CPUID+4 # store cpu address
  102. lh %r1,__LC_CPUID+4
  103. diag %r1,0,0x9c # test diag 0x9c
  104. oi 6(%r12),1 # set diag9c flag
  105. 0:
  106. #
  107. # find out if we have the MVCOS instruction
  108. #
  109. la %r1,0f-.LPG1(%r13) # set program check address
  110. stg %r1,__LC_PGM_NEW_PSW+8
  111. .short 0xc800 # mvcos 0(%r0),0(%r0),%r0
  112. .short 0x0000
  113. .short 0x0000
  114. 0: tm 0x8f,0x13 # special-operation exception?
  115. bno 1f-.LPG1(%r13) # if yes, MVCOS is present
  116. oi 6(%r12),2 # set MVCOS flag
  117. 1:
  118. lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space,
  119. # virtual and never return ...
  120. .align 16
  121. .Lentry:.quad 0x0000000180000000,_stext
  122. .Lctl: .quad 0x04b50002 # cr0: various things
  123. .quad 0 # cr1: primary space segment table
  124. .quad .Lduct # cr2: dispatchable unit control table
  125. .quad 0 # cr3: instruction authorization
  126. .quad 0 # cr4: instruction authorization
  127. .quad 0xffffffffffffffff # cr5: primary-aste origin
  128. .quad 0 # cr6: I/O interrupts
  129. .quad 0 # cr7: secondary space segment table
  130. .quad 0 # cr8: access registers translation
  131. .quad 0 # cr9: tracing off
  132. .quad 0 # cr10: tracing off
  133. .quad 0 # cr11: tracing off
  134. .quad 0 # cr12: tracing off
  135. .quad 0 # cr13: home space segment table
  136. .quad 0xc0000000 # cr14: machine check handling off
  137. .quad 0 # cr15: linkage stack operations
  138. .Lduct: .long 0,0,0,0,0,0,0,0
  139. .long 0,0,0,0,0,0,0,0
  140. .Lpcmsk:.quad 0x0000000180000000
  141. .L4malign:.quad 0xffffffffffc00000
  142. .Lscan2g:.quad 0x80000000 + 0x20000 - 8 # 2GB + 128K - 8
  143. .Lnop: .long 0x07000700
  144. .Lparmaddr:
  145. .quad PARMAREA
  146. .globl ipl_schib
  147. ipl_schib:
  148. .rept 13
  149. .long 0
  150. .endr
  151. .globl ipl_flags
  152. ipl_flags:
  153. .long 0
  154. .globl ipl_devno
  155. ipl_devno:
  156. .word 0
  157. .org 0x12000
  158. #ifdef CONFIG_SHARED_KERNEL
  159. .org 0x100000
  160. #endif
  161. #
  162. # startup-code, running in absolute addressing mode
  163. #
  164. .globl _stext
  165. _stext: basr %r13,0 # get base
  166. .LPG3:
  167. # check control registers
  168. stctg %c0,%c15,0(%r15)
  169. oi 6(%r15),0x40 # enable sigp emergency signal
  170. oi 4(%r15),0x10 # switch on low address proctection
  171. lctlg %c0,%c15,0(%r15)
  172. lam 0,15,.Laregs-.LPG3(%r13) # load acrs needed by uaccess
  173. brasl %r14,start_kernel # go to C code
  174. #
  175. # We returned from start_kernel ?!? PANIK
  176. #
  177. basr %r13,0
  178. lpswe .Ldw-.(%r13) # load disabled wait psw
  179. .align 8
  180. .Ldw: .quad 0x0002000180000000,0x0000000000000000
  181. .Laregs:.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0