head.S 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. /* This file is subject to the terms and conditions of the GNU General Public
  2. * License. See the file "COPYING" in the main directory of this archive
  3. * for more details.
  4. *
  5. * Copyright (C) 1999-2007 by Helge Deller <deller@gmx.de>
  6. * Copyright 1999 SuSE GmbH (Philipp Rumpf)
  7. * Copyright 1999 Philipp Rumpf (prumpf@tux.org)
  8. * Copyright 2000 Hewlett Packard (Paul Bame, bame@puffin.external.hp.com)
  9. * Copyright (C) 2001 Grant Grundler (Hewlett Packard)
  10. * Copyright (C) 2004 Kyle McMartin <kyle@debian.org>
  11. *
  12. * Initial Version 04-23-1999 by Helge Deller <deller@gmx.de>
  13. */
  14. #include <asm/asm-offsets.h>
  15. #include <asm/psw.h>
  16. #include <asm/pdc.h>
  17. #include <asm/assembly.h>
  18. #include <asm/pgtable.h>
  19. #include <linux/linkage.h>
  20. #include <linux/init.h>
  21. .level LEVEL
  22. __INITDATA
  23. ENTRY(boot_args)
  24. .word 0 /* arg0 */
  25. .word 0 /* arg1 */
  26. .word 0 /* arg2 */
  27. .word 0 /* arg3 */
  28. END(boot_args)
  29. __HEAD
  30. .align 4
  31. .import init_thread_union,data
  32. .import fault_vector_20,code /* IVA parisc 2.0 32 bit */
  33. #ifndef CONFIG_64BIT
  34. .import fault_vector_11,code /* IVA parisc 1.1 32 bit */
  35. .import $global$ /* forward declaration */
  36. #endif /*!CONFIG_64BIT*/
  37. .export _stext,data /* Kernel want it this way! */
  38. _stext:
  39. ENTRY(stext)
  40. .proc
  41. .callinfo
  42. /* Make sure sr4-sr7 are set to zero for the kernel address space */
  43. mtsp %r0,%sr4
  44. mtsp %r0,%sr5
  45. mtsp %r0,%sr6
  46. mtsp %r0,%sr7
  47. /* Clear BSS (shouldn't the boot loader do this?) */
  48. .import __bss_start,data
  49. .import __bss_stop,data
  50. load32 PA(__bss_start),%r3
  51. load32 PA(__bss_stop),%r4
  52. $bss_loop:
  53. cmpb,<<,n %r3,%r4,$bss_loop
  54. stw,ma %r0,4(%r3)
  55. /* Save away the arguments the boot loader passed in (32 bit args) */
  56. load32 PA(boot_args),%r1
  57. stw,ma %arg0,4(%r1)
  58. stw,ma %arg1,4(%r1)
  59. stw,ma %arg2,4(%r1)
  60. stw,ma %arg3,4(%r1)
  61. /* Initialize startup VM. Just map first 8/16 MB of memory */
  62. load32 PA(swapper_pg_dir),%r4
  63. mtctl %r4,%cr24 /* Initialize kernel root pointer */
  64. mtctl %r4,%cr25 /* Initialize user root pointer */
  65. #if PT_NLEVELS == 3
  66. /* Set pmd in pgd */
  67. load32 PA(pmd0),%r5
  68. shrd %r5,PxD_VALUE_SHIFT,%r3
  69. ldo (PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3
  70. stw %r3,ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4)
  71. ldo ASM_PMD_ENTRY*ASM_PMD_ENTRY_SIZE(%r5),%r4
  72. #else
  73. /* 2-level page table, so pmd == pgd */
  74. ldo ASM_PGD_ENTRY*ASM_PGD_ENTRY_SIZE(%r4),%r4
  75. #endif
  76. /* Fill in pmd with enough pte directories */
  77. load32 PA(pg0),%r1
  78. SHRREG %r1,PxD_VALUE_SHIFT,%r3
  79. ldo (PxD_FLAG_PRESENT+PxD_FLAG_VALID)(%r3),%r3
  80. ldi ASM_PT_INITIAL,%r1
  81. 1:
  82. stw %r3,0(%r4)
  83. ldo (PAGE_SIZE >> PxD_VALUE_SHIFT)(%r3),%r3
  84. addib,> -1,%r1,1b
  85. #if PT_NLEVELS == 3
  86. ldo ASM_PMD_ENTRY_SIZE(%r4),%r4
  87. #else
  88. ldo ASM_PGD_ENTRY_SIZE(%r4),%r4
  89. #endif
  90. /* Now initialize the PTEs themselves */
  91. ldo 0+_PAGE_KERNEL(%r0),%r3 /* Hardwired 0 phys addr start */
  92. ldi (1<<(KERNEL_INITIAL_ORDER-PAGE_SHIFT)),%r11 /* PFN count */
  93. load32 PA(pg0),%r1
  94. $pgt_fill_loop:
  95. STREGM %r3,ASM_PTE_ENTRY_SIZE(%r1)
  96. ldo (1<<PFN_PTE_SHIFT)(%r3),%r3 /* add one PFN */
  97. addib,> -1,%r11,$pgt_fill_loop
  98. nop
  99. /* Load the return address...er...crash 'n burn */
  100. copy %r0,%r2
  101. /* And the RFI Target address too */
  102. load32 start_kernel,%r11
  103. /* And the initial task pointer */
  104. load32 init_thread_union,%r6
  105. mtctl %r6,%cr30
  106. /* And the stack pointer too */
  107. ldo THREAD_SZ_ALGN(%r6),%sp
  108. #ifdef CONFIG_SMP
  109. /* Set the smp rendevous address into page zero.
  110. ** It would be safer to do this in init_smp_config() but
  111. ** it's just way easier to deal with here because
  112. ** of 64-bit function ptrs and the address is local to this file.
  113. */
  114. load32 PA(smp_slave_stext),%r10
  115. stw %r10,0x10(%r0) /* MEM_RENDEZ */
  116. stw %r0,0x28(%r0) /* MEM_RENDEZ_HI - assume addr < 4GB */
  117. /* FALLTHROUGH */
  118. .procend
  119. /*
  120. ** Code Common to both Monarch and Slave processors.
  121. ** Entry:
  122. **
  123. ** 1.1:
  124. ** %r11 must contain RFI target address.
  125. ** %r25/%r26 args to pass to target function
  126. ** %r2 in case rfi target decides it didn't like something
  127. **
  128. ** 2.0w:
  129. ** %r3 PDCE_PROC address
  130. ** %r11 RFI target address
  131. **
  132. ** Caller must init: SR4-7, %sp, %r10, %cr24/25,
  133. */
  134. common_stext:
  135. .proc
  136. .callinfo
  137. #else
  138. /* Clear PDC entry point - we won't use it */
  139. stw %r0,0x10(%r0) /* MEM_RENDEZ */
  140. stw %r0,0x28(%r0) /* MEM_RENDEZ_HI */
  141. #endif /*CONFIG_SMP*/
  142. #ifdef CONFIG_64BIT
  143. tophys_r1 %sp
  144. /* Save the rfi target address */
  145. ldd TI_TASK-THREAD_SZ_ALGN(%sp), %r10
  146. tophys_r1 %r10
  147. std %r11, TASK_PT_GR11(%r10)
  148. /* Switch to wide mode Superdome doesn't support narrow PDC
  149. ** calls.
  150. */
  151. 1: mfia %rp /* clear upper part of pcoq */
  152. ldo 2f-1b(%rp),%rp
  153. depdi 0,31,32,%rp
  154. bv (%rp)
  155. ssm PSW_SM_W,%r0
  156. /* Set Wide mode as the "Default" (eg for traps)
  157. ** First trap occurs *right* after (or part of) rfi for slave CPUs.
  158. ** Someday, palo might not do this for the Monarch either.
  159. */
  160. 2:
  161. #define MEM_PDC_LO 0x388
  162. #define MEM_PDC_HI 0x35C
  163. ldw MEM_PDC_LO(%r0),%r3
  164. ldw MEM_PDC_HI(%r0),%r6
  165. depd %r6, 31, 32, %r3 /* move to upper word */
  166. ldo PDC_PSW(%r0),%arg0 /* 21 */
  167. ldo PDC_PSW_SET_DEFAULTS(%r0),%arg1 /* 2 */
  168. ldo PDC_PSW_WIDE_BIT(%r0),%arg2 /* 2 */
  169. load32 PA(stext_pdc_ret), %rp
  170. bv (%r3)
  171. copy %r0,%arg3
  172. stext_pdc_ret:
  173. /* restore rfi target address*/
  174. ldd TI_TASK-THREAD_SZ_ALGN(%sp), %r10
  175. tophys_r1 %r10
  176. ldd TASK_PT_GR11(%r10), %r11
  177. tovirt_r1 %sp
  178. #endif
  179. /* PARANOID: clear user scratch/user space SR's */
  180. mtsp %r0,%sr0
  181. mtsp %r0,%sr1
  182. mtsp %r0,%sr2
  183. mtsp %r0,%sr3
  184. /* Initialize Protection Registers */
  185. mtctl %r0,%cr8
  186. mtctl %r0,%cr9
  187. mtctl %r0,%cr12
  188. mtctl %r0,%cr13
  189. /* Initialize the global data pointer */
  190. loadgp
  191. /* Set up our interrupt table. HPMCs might not work after this!
  192. *
  193. * We need to install the correct iva for PA1.1 or PA2.0. The
  194. * following short sequence of instructions can determine this
  195. * (without being illegal on a PA1.1 machine).
  196. */
  197. #ifndef CONFIG_64BIT
  198. ldi 32,%r10
  199. mtctl %r10,%cr11
  200. .level 2.0
  201. mfctl,w %cr11,%r10
  202. .level 1.1
  203. comib,<>,n 0,%r10,$is_pa20
  204. ldil L%PA(fault_vector_11),%r10
  205. b $install_iva
  206. ldo R%PA(fault_vector_11)(%r10),%r10
  207. $is_pa20:
  208. .level LEVEL /* restore 1.1 || 2.0w */
  209. #endif /*!CONFIG_64BIT*/
  210. load32 PA(fault_vector_20),%r10
  211. $install_iva:
  212. mtctl %r10,%cr14
  213. b aligned_rfi /* Prepare to RFI! Man all the cannons! */
  214. nop
  215. .align 128
  216. aligned_rfi:
  217. pcxt_ssm_bug
  218. rsm PSW_SM_QUIET,%r0 /* off troublesome PSW bits */
  219. /* Don't need NOPs, have 8 compliant insn before rfi */
  220. mtctl %r0,%cr17 /* Clear IIASQ tail */
  221. mtctl %r0,%cr17 /* Clear IIASQ head */
  222. /* Load RFI target into PC queue */
  223. mtctl %r11,%cr18 /* IIAOQ head */
  224. ldo 4(%r11),%r11
  225. mtctl %r11,%cr18 /* IIAOQ tail */
  226. load32 KERNEL_PSW,%r10
  227. mtctl %r10,%ipsw
  228. /* Jump through hyperspace to Virt Mode */
  229. rfi
  230. nop
  231. .procend
  232. #ifdef CONFIG_SMP
  233. .import smp_init_current_idle_task,data
  234. .import smp_callin,code
  235. #ifndef CONFIG_64BIT
  236. smp_callin_rtn:
  237. .proc
  238. .callinfo
  239. break 1,1 /* Break if returned from start_secondary */
  240. nop
  241. nop
  242. .procend
  243. #endif /*!CONFIG_64BIT*/
  244. /***************************************************************************
  245. * smp_slave_stext is executed by all non-monarch Processors when the Monarch
  246. * pokes the slave CPUs in smp.c:smp_boot_cpus().
  247. *
  248. * Once here, registers values are initialized in order to branch to virtual
  249. * mode. Once all available/eligible CPUs are in virtual mode, all are
  250. * released and start out by executing their own idle task.
  251. *****************************************************************************/
  252. smp_slave_stext:
  253. .proc
  254. .callinfo
  255. /*
  256. ** Initialize Space registers
  257. */
  258. mtsp %r0,%sr4
  259. mtsp %r0,%sr5
  260. mtsp %r0,%sr6
  261. mtsp %r0,%sr7
  262. /* Initialize the SP - monarch sets up smp_init_current_idle_task */
  263. load32 PA(smp_init_current_idle_task),%sp
  264. LDREG 0(%sp),%sp /* load task address */
  265. tophys_r1 %sp
  266. LDREG TASK_THREAD_INFO(%sp),%sp
  267. mtctl %sp,%cr30 /* store in cr30 */
  268. ldo THREAD_SZ_ALGN(%sp),%sp
  269. /* point CPU to kernel page tables */
  270. load32 PA(swapper_pg_dir),%r4
  271. mtctl %r4,%cr24 /* Initialize kernel root pointer */
  272. mtctl %r4,%cr25 /* Initialize user root pointer */
  273. #ifdef CONFIG_64BIT
  274. /* Setup PDCE_PROC entry */
  275. copy %arg0,%r3
  276. #else
  277. /* Load RFI *return* address in case smp_callin bails */
  278. load32 smp_callin_rtn,%r2
  279. #endif
  280. /* Load RFI target address. */
  281. load32 smp_callin,%r11
  282. /* ok...common code can handle the rest */
  283. b common_stext
  284. nop
  285. .procend
  286. #endif /* CONFIG_SMP */
  287. ENDPROC(stext)
  288. #ifndef CONFIG_64BIT
  289. .section .data.read_mostly
  290. .align 4
  291. .export $global$,data
  292. .type $global$,@object
  293. .size $global$,4
  294. $global$:
  295. .word 0
  296. #endif /*!CONFIG_64BIT*/