head.S 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /* $Id: head.S,v 1.87 2002/02/09 19:49:31 davem Exp $
  2. * head.S: Initial boot code for the Sparc64 port of Linux.
  3. *
  4. * Copyright (C) 1996,1997 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1996 David Sitsky (David.Sitsky@anu.edu.au)
  6. * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  7. * Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx)
  8. */
  9. #include <linux/version.h>
  10. #include <linux/errno.h>
  11. #include <linux/threads.h>
  12. #include <asm/thread_info.h>
  13. #include <asm/asi.h>
  14. #include <asm/pstate.h>
  15. #include <asm/ptrace.h>
  16. #include <asm/spitfire.h>
  17. #include <asm/page.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/errno.h>
  20. #include <asm/signal.h>
  21. #include <asm/processor.h>
  22. #include <asm/lsu.h>
  23. #include <asm/dcr.h>
  24. #include <asm/dcu.h>
  25. #include <asm/head.h>
  26. #include <asm/ttable.h>
  27. #include <asm/mmu.h>
  28. #include <asm/cpudata.h>
  29. /* This section from from _start to sparc64_boot_end should fit into
  30. * 0x0000000000404000 to 0x0000000000408000.
  31. */
  32. .text
  33. .globl start, _start, stext, _stext
  34. _start:
  35. start:
  36. _stext:
  37. stext:
  38. ! 0x0000000000404000
  39. b sparc64_boot
  40. flushw /* Flush register file. */
  41. /* This stuff has to be in sync with SILO and other potential boot loaders
  42. * Fields should be kept upward compatible and whenever any change is made,
  43. * HdrS version should be incremented.
  44. */
  45. .global root_flags, ram_flags, root_dev
  46. .global sparc_ramdisk_image, sparc_ramdisk_size
  47. .global sparc_ramdisk_image64
  48. .ascii "HdrS"
  49. .word LINUX_VERSION_CODE
  50. /* History:
  51. *
  52. * 0x0300 : Supports being located at other than 0x4000
  53. * 0x0202 : Supports kernel params string
  54. * 0x0201 : Supports reboot_command
  55. */
  56. .half 0x0301 /* HdrS version */
  57. root_flags:
  58. .half 1
  59. root_dev:
  60. .half 0
  61. ram_flags:
  62. .half 0
  63. sparc_ramdisk_image:
  64. .word 0
  65. sparc_ramdisk_size:
  66. .word 0
  67. .xword reboot_command
  68. .xword bootstr_info
  69. sparc_ramdisk_image64:
  70. .xword 0
  71. .word _end
  72. /* PROM cif handler code address is in %o4. */
  73. sparc64_boot:
  74. mov %o4, %l7
  75. /* We need to remap the kernel. Use position independant
  76. * code to remap us to KERNBASE.
  77. *
  78. * SILO can invoke us with 32-bit address masking enabled,
  79. * so make sure that's clear.
  80. */
  81. rdpr %pstate, %g1
  82. andn %g1, PSTATE_AM, %g1
  83. wrpr %g1, 0x0, %pstate
  84. ba,a,pt %xcc, 1f
  85. .globl prom_finddev_name, prom_chosen_path, prom_root_node
  86. .globl prom_getprop_name, prom_mmu_name, prom_peer_name
  87. .globl prom_callmethod_name, prom_translate_name, prom_root_compatible
  88. .globl prom_map_name, prom_unmap_name, prom_mmu_ihandle_cache
  89. .globl prom_boot_mapped_pc, prom_boot_mapping_mode
  90. .globl prom_boot_mapping_phys_high, prom_boot_mapping_phys_low
  91. .globl is_sun4v
  92. prom_peer_name:
  93. .asciz "peer"
  94. prom_compatible_name:
  95. .asciz "compatible"
  96. prom_finddev_name:
  97. .asciz "finddevice"
  98. prom_chosen_path:
  99. .asciz "/chosen"
  100. prom_getprop_name:
  101. .asciz "getprop"
  102. prom_mmu_name:
  103. .asciz "mmu"
  104. prom_callmethod_name:
  105. .asciz "call-method"
  106. prom_translate_name:
  107. .asciz "translate"
  108. prom_map_name:
  109. .asciz "map"
  110. prom_unmap_name:
  111. .asciz "unmap"
  112. prom_sun4v_name:
  113. .asciz "sun4v"
  114. .align 4
  115. prom_root_compatible:
  116. .skip 64
  117. prom_root_node:
  118. .word 0
  119. prom_mmu_ihandle_cache:
  120. .word 0
  121. prom_boot_mapped_pc:
  122. .word 0
  123. prom_boot_mapping_mode:
  124. .word 0
  125. .align 8
  126. prom_boot_mapping_phys_high:
  127. .xword 0
  128. prom_boot_mapping_phys_low:
  129. .xword 0
  130. is_sun4v:
  131. .word 0
  132. 1:
  133. rd %pc, %l0
  134. mov (1b - prom_peer_name), %l1
  135. sub %l0, %l1, %l1
  136. mov 0, %l2
  137. /* prom_root_node = prom_peer(0) */
  138. stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "peer"
  139. mov 1, %l3
  140. stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 1
  141. stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
  142. stx %l2, [%sp + 2047 + 128 + 0x18] ! arg1, 0
  143. stx %g0, [%sp + 2047 + 128 + 0x20] ! ret1
  144. call %l7
  145. add %sp, (2047 + 128), %o0 ! argument array
  146. ldx [%sp + 2047 + 128 + 0x20], %l4 ! prom root node
  147. mov (1b - prom_root_node), %l1
  148. sub %l0, %l1, %l1
  149. stw %l4, [%l1]
  150. mov (1b - prom_getprop_name), %l1
  151. mov (1b - prom_compatible_name), %l2
  152. mov (1b - prom_root_compatible), %l5
  153. sub %l0, %l1, %l1
  154. sub %l0, %l2, %l2
  155. sub %l0, %l5, %l5
  156. /* prom_getproperty(prom_root_node, "compatible",
  157. * &prom_root_compatible, 64)
  158. */
  159. stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "getprop"
  160. mov 4, %l3
  161. stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 4
  162. mov 1, %l3
  163. stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
  164. stx %l4, [%sp + 2047 + 128 + 0x18] ! arg1, prom_root_node
  165. stx %l2, [%sp + 2047 + 128 + 0x20] ! arg2, "compatible"
  166. stx %l5, [%sp + 2047 + 128 + 0x28] ! arg3, &prom_root_compatible
  167. mov 64, %l3
  168. stx %l3, [%sp + 2047 + 128 + 0x30] ! arg4, size
  169. stx %g0, [%sp + 2047 + 128 + 0x38] ! ret1
  170. call %l7
  171. add %sp, (2047 + 128), %o0 ! argument array
  172. mov (1b - prom_finddev_name), %l1
  173. mov (1b - prom_chosen_path), %l2
  174. mov (1b - prom_boot_mapped_pc), %l3
  175. sub %l0, %l1, %l1
  176. sub %l0, %l2, %l2
  177. sub %l0, %l3, %l3
  178. stw %l0, [%l3]
  179. sub %sp, (192 + 128), %sp
  180. /* chosen_node = prom_finddevice("/chosen") */
  181. stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "finddevice"
  182. mov 1, %l3
  183. stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 1
  184. stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
  185. stx %l2, [%sp + 2047 + 128 + 0x18] ! arg1, "/chosen"
  186. stx %g0, [%sp + 2047 + 128 + 0x20] ! ret1
  187. call %l7
  188. add %sp, (2047 + 128), %o0 ! argument array
  189. ldx [%sp + 2047 + 128 + 0x20], %l4 ! chosen device node
  190. mov (1b - prom_getprop_name), %l1
  191. mov (1b - prom_mmu_name), %l2
  192. mov (1b - prom_mmu_ihandle_cache), %l5
  193. sub %l0, %l1, %l1
  194. sub %l0, %l2, %l2
  195. sub %l0, %l5, %l5
  196. /* prom_mmu_ihandle_cache = prom_getint(chosen_node, "mmu") */
  197. stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "getprop"
  198. mov 4, %l3
  199. stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 4
  200. mov 1, %l3
  201. stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
  202. stx %l4, [%sp + 2047 + 128 + 0x18] ! arg1, chosen_node
  203. stx %l2, [%sp + 2047 + 128 + 0x20] ! arg2, "mmu"
  204. stx %l5, [%sp + 2047 + 128 + 0x28] ! arg3, &prom_mmu_ihandle_cache
  205. mov 4, %l3
  206. stx %l3, [%sp + 2047 + 128 + 0x30] ! arg4, sizeof(arg3)
  207. stx %g0, [%sp + 2047 + 128 + 0x38] ! ret1
  208. call %l7
  209. add %sp, (2047 + 128), %o0 ! argument array
  210. mov (1b - prom_callmethod_name), %l1
  211. mov (1b - prom_translate_name), %l2
  212. sub %l0, %l1, %l1
  213. sub %l0, %l2, %l2
  214. lduw [%l5], %l5 ! prom_mmu_ihandle_cache
  215. stx %l1, [%sp + 2047 + 128 + 0x00] ! service, "call-method"
  216. mov 3, %l3
  217. stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 3
  218. mov 5, %l3
  219. stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 5
  220. stx %l2, [%sp + 2047 + 128 + 0x18] ! arg1: "translate"
  221. stx %l5, [%sp + 2047 + 128 + 0x20] ! arg2: prom_mmu_ihandle_cache
  222. /* PAGE align */
  223. srlx %l0, 13, %l3
  224. sllx %l3, 13, %l3
  225. stx %l3, [%sp + 2047 + 128 + 0x28] ! arg3: vaddr, our PC
  226. stx %g0, [%sp + 2047 + 128 + 0x30] ! res1
  227. stx %g0, [%sp + 2047 + 128 + 0x38] ! res2
  228. stx %g0, [%sp + 2047 + 128 + 0x40] ! res3
  229. stx %g0, [%sp + 2047 + 128 + 0x48] ! res4
  230. stx %g0, [%sp + 2047 + 128 + 0x50] ! res5
  231. call %l7
  232. add %sp, (2047 + 128), %o0 ! argument array
  233. ldx [%sp + 2047 + 128 + 0x40], %l1 ! translation mode
  234. mov (1b - prom_boot_mapping_mode), %l4
  235. sub %l0, %l4, %l4
  236. stw %l1, [%l4]
  237. mov (1b - prom_boot_mapping_phys_high), %l4
  238. sub %l0, %l4, %l4
  239. ldx [%sp + 2047 + 128 + 0x48], %l2 ! physaddr high
  240. stx %l2, [%l4 + 0x0]
  241. ldx [%sp + 2047 + 128 + 0x50], %l3 ! physaddr low
  242. /* 4MB align */
  243. srlx %l3, 22, %l3
  244. sllx %l3, 22, %l3
  245. stx %l3, [%l4 + 0x8]
  246. /* Leave service as-is, "call-method" */
  247. mov 7, %l3
  248. stx %l3, [%sp + 2047 + 128 + 0x08] ! num_args, 7
  249. mov 1, %l3
  250. stx %l3, [%sp + 2047 + 128 + 0x10] ! num_rets, 1
  251. mov (1b - prom_map_name), %l3
  252. sub %l0, %l3, %l3
  253. stx %l3, [%sp + 2047 + 128 + 0x18] ! arg1: "map"
  254. /* Leave arg2 as-is, prom_mmu_ihandle_cache */
  255. mov -1, %l3
  256. stx %l3, [%sp + 2047 + 128 + 0x28] ! arg3: mode (-1 default)
  257. sethi %hi(8 * 1024 * 1024), %l3
  258. stx %l3, [%sp + 2047 + 128 + 0x30] ! arg4: size (8MB)
  259. sethi %hi(KERNBASE), %l3
  260. stx %l3, [%sp + 2047 + 128 + 0x38] ! arg5: vaddr (KERNBASE)
  261. stx %g0, [%sp + 2047 + 128 + 0x40] ! arg6: empty
  262. mov (1b - prom_boot_mapping_phys_low), %l3
  263. sub %l0, %l3, %l3
  264. ldx [%l3], %l3
  265. stx %l3, [%sp + 2047 + 128 + 0x48] ! arg7: phys addr
  266. call %l7
  267. add %sp, (2047 + 128), %o0 ! argument array
  268. add %sp, (192 + 128), %sp
  269. sethi %hi(prom_root_compatible), %g1
  270. or %g1, %lo(prom_root_compatible), %g1
  271. sethi %hi(prom_sun4v_name), %g7
  272. or %g7, %lo(prom_sun4v_name), %g7
  273. mov 5, %g3
  274. 1: ldub [%g7], %g2
  275. ldub [%g1], %g4
  276. cmp %g2, %g4
  277. bne,pn %icc, 2f
  278. add %g7, 1, %g7
  279. subcc %g3, 1, %g3
  280. bne,pt %xcc, 1b
  281. add %g1, 1, %g1
  282. sethi %hi(is_sun4v), %g1
  283. or %g1, %lo(is_sun4v), %g1
  284. mov 1, %g7
  285. stw %g7, [%g1]
  286. 2:
  287. BRANCH_IF_SUN4V(g1, jump_to_sun4u_init)
  288. BRANCH_IF_CHEETAH_BASE(g1,g7,cheetah_boot)
  289. BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,cheetah_plus_boot)
  290. ba,pt %xcc, spitfire_boot
  291. nop
  292. cheetah_plus_boot:
  293. /* Preserve OBP chosen DCU and DCR register settings. */
  294. ba,pt %xcc, cheetah_generic_boot
  295. nop
  296. cheetah_boot:
  297. mov DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1
  298. wr %g1, %asr18
  299. sethi %uhi(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g7
  300. or %g7, %ulo(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g7
  301. sllx %g7, 32, %g7
  302. or %g7, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g7
  303. stxa %g7, [%g0] ASI_DCU_CONTROL_REG
  304. membar #Sync
  305. cheetah_generic_boot:
  306. mov TSB_EXTENSION_P, %g3
  307. stxa %g0, [%g3] ASI_DMMU
  308. stxa %g0, [%g3] ASI_IMMU
  309. membar #Sync
  310. mov TSB_EXTENSION_S, %g3
  311. stxa %g0, [%g3] ASI_DMMU
  312. membar #Sync
  313. mov TSB_EXTENSION_N, %g3
  314. stxa %g0, [%g3] ASI_DMMU
  315. stxa %g0, [%g3] ASI_IMMU
  316. membar #Sync
  317. ba,a,pt %xcc, jump_to_sun4u_init
  318. spitfire_boot:
  319. /* Typically PROM has already enabled both MMU's and both on-chip
  320. * caches, but we do it here anyway just to be paranoid.
  321. */
  322. mov (LSU_CONTROL_IC|LSU_CONTROL_DC|LSU_CONTROL_IM|LSU_CONTROL_DM), %g1
  323. stxa %g1, [%g0] ASI_LSU_CONTROL
  324. membar #Sync
  325. jump_to_sun4u_init:
  326. /*
  327. * Make sure we are in privileged mode, have address masking,
  328. * using the ordinary globals and have enabled floating
  329. * point.
  330. *
  331. * Again, typically PROM has left %pil at 13 or similar, and
  332. * (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE) in %pstate.
  333. */
  334. wrpr %g0, (PSTATE_PRIV|PSTATE_PEF|PSTATE_IE), %pstate
  335. wr %g0, 0, %fprs
  336. set sun4u_init, %g2
  337. jmpl %g2 + %g0, %g0
  338. nop
  339. sun4u_init:
  340. BRANCH_IF_SUN4V(g1, sun4v_init)
  341. /* Set ctx 0 */
  342. mov PRIMARY_CONTEXT, %g7
  343. stxa %g0, [%g7] ASI_DMMU
  344. membar #Sync
  345. mov SECONDARY_CONTEXT, %g7
  346. stxa %g0, [%g7] ASI_DMMU
  347. membar #Sync
  348. ba,pt %xcc, sun4u_continue
  349. nop
  350. sun4v_init:
  351. /* Set ctx 0 */
  352. mov PRIMARY_CONTEXT, %g7
  353. stxa %g0, [%g7] ASI_MMU
  354. membar #Sync
  355. mov SECONDARY_CONTEXT, %g7
  356. stxa %g0, [%g7] ASI_MMU
  357. membar #Sync
  358. ba,pt %xcc, niagara_tlb_fixup
  359. nop
  360. sun4u_continue:
  361. BRANCH_IF_ANY_CHEETAH(g1, g7, cheetah_tlb_fixup)
  362. ba,pt %xcc, spitfire_tlb_fixup
  363. nop
  364. niagara_tlb_fixup:
  365. mov 3, %g2 /* Set TLB type to hypervisor. */
  366. sethi %hi(tlb_type), %g1
  367. stw %g2, [%g1 + %lo(tlb_type)]
  368. /* Patch copy/clear ops. */
  369. call niagara_patch_copyops
  370. nop
  371. call niagara_patch_bzero
  372. nop
  373. call niagara_patch_pageops
  374. nop
  375. /* Patch TLB/cache ops. */
  376. call hypervisor_patch_cachetlbops
  377. nop
  378. ba,pt %xcc, tlb_fixup_done
  379. nop
  380. cheetah_tlb_fixup:
  381. mov 2, %g2 /* Set TLB type to cheetah+. */
  382. BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g7,1f)
  383. mov 1, %g2 /* Set TLB type to cheetah. */
  384. 1: sethi %hi(tlb_type), %g1
  385. stw %g2, [%g1 + %lo(tlb_type)]
  386. /* Patch copy/page operations to cheetah optimized versions. */
  387. call cheetah_patch_copyops
  388. nop
  389. call cheetah_patch_copy_page
  390. nop
  391. call cheetah_patch_cachetlbops
  392. nop
  393. ba,pt %xcc, tlb_fixup_done
  394. nop
  395. spitfire_tlb_fixup:
  396. /* Set TLB type to spitfire. */
  397. mov 0, %g2
  398. sethi %hi(tlb_type), %g1
  399. stw %g2, [%g1 + %lo(tlb_type)]
  400. tlb_fixup_done:
  401. sethi %hi(init_thread_union), %g6
  402. or %g6, %lo(init_thread_union), %g6
  403. ldx [%g6 + TI_TASK], %g4
  404. mov %sp, %l6
  405. mov %o4, %l7
  406. wr %g0, ASI_P, %asi
  407. mov 1, %g1
  408. sllx %g1, THREAD_SHIFT, %g1
  409. sub %g1, (STACKFRAME_SZ + STACK_BIAS), %g1
  410. add %g6, %g1, %sp
  411. mov 0, %fp
  412. /* Set per-cpu pointer initially to zero, this makes
  413. * the boot-cpu use the in-kernel-image per-cpu areas
  414. * before setup_per_cpu_area() is invoked.
  415. */
  416. clr %g5
  417. wrpr %g0, 0, %wstate
  418. wrpr %g0, 0x0, %tl
  419. /* Clear the bss */
  420. sethi %hi(__bss_start), %o0
  421. or %o0, %lo(__bss_start), %o0
  422. sethi %hi(_end), %o1
  423. or %o1, %lo(_end), %o1
  424. call __bzero
  425. sub %o1, %o0, %o1
  426. #ifdef CONFIG_LOCKDEP
  427. /* We have this call this super early, as even prom_init can grab
  428. * spinlocks and thus call into the lockdep code.
  429. */
  430. call lockdep_init
  431. nop
  432. #endif
  433. mov %l6, %o1 ! OpenPROM stack
  434. call prom_init
  435. mov %l7, %o0 ! OpenPROM cif handler
  436. /* Initialize current_thread_info()->cpu as early as possible.
  437. * In order to do that accurately we have to patch up the get_cpuid()
  438. * assembler sequences. And that, in turn, requires that we know
  439. * if we are on a Starfire box or not. While we're here, patch up
  440. * the sun4v sequences as well.
  441. */
  442. call check_if_starfire
  443. nop
  444. call per_cpu_patch
  445. nop
  446. call sun4v_patch
  447. nop
  448. #ifdef CONFIG_SMP
  449. call hard_smp_processor_id
  450. nop
  451. cmp %o0, NR_CPUS
  452. blu,pt %xcc, 1f
  453. nop
  454. call boot_cpu_id_too_large
  455. nop
  456. /* Not reached... */
  457. 1:
  458. #else
  459. mov 0, %o0
  460. #endif
  461. stb %o0, [%g6 + TI_CPU]
  462. /* Off we go.... */
  463. call start_kernel
  464. nop
  465. /* Not reached... */
  466. /* This is meant to allow the sharing of this code between
  467. * boot processor invocation (via setup_tba() below) and
  468. * secondary processor startup (via trampoline.S). The
  469. * former does use this code, the latter does not yet due
  470. * to some complexities. That should be fixed up at some
  471. * point.
  472. *
  473. * There used to be enormous complexity wrt. transferring
  474. * over from the firwmare's trap table to the Linux kernel's.
  475. * For example, there was a chicken & egg problem wrt. building
  476. * the OBP page tables, yet needing to be on the Linux kernel
  477. * trap table (to translate PAGE_OFFSET addresses) in order to
  478. * do that.
  479. *
  480. * We now handle OBP tlb misses differently, via linear lookups
  481. * into the prom_trans[] array. So that specific problem no
  482. * longer exists. Yet, unfortunately there are still some issues
  483. * preventing trampoline.S from using this code... ho hum.
  484. */
  485. .globl setup_trap_table
  486. setup_trap_table:
  487. save %sp, -192, %sp
  488. /* Force interrupts to be disabled. */
  489. rdpr %pstate, %l0
  490. andn %l0, PSTATE_IE, %o1
  491. wrpr %o1, 0x0, %pstate
  492. rdpr %pil, %l1
  493. wrpr %g0, 15, %pil
  494. /* Make the firmware call to jump over to the Linux trap table. */
  495. sethi %hi(is_sun4v), %o0
  496. lduw [%o0 + %lo(is_sun4v)], %o0
  497. brz,pt %o0, 1f
  498. nop
  499. TRAP_LOAD_TRAP_BLOCK(%g2, %g3)
  500. add %g2, TRAP_PER_CPU_FAULT_INFO, %g2
  501. stxa %g2, [%g0] ASI_SCRATCHPAD
  502. /* Compute physical address:
  503. *
  504. * paddr = kern_base + (mmfsa_vaddr - KERNBASE)
  505. */
  506. sethi %hi(KERNBASE), %g3
  507. sub %g2, %g3, %g2
  508. sethi %hi(kern_base), %g3
  509. ldx [%g3 + %lo(kern_base)], %g3
  510. add %g2, %g3, %o1
  511. call prom_set_trap_table_sun4v
  512. sethi %hi(sparc64_ttable_tl0), %o0
  513. ba,pt %xcc, 2f
  514. nop
  515. 1: call prom_set_trap_table
  516. sethi %hi(sparc64_ttable_tl0), %o0
  517. /* Start using proper page size encodings in ctx register. */
  518. 2: sethi %hi(sparc64_kern_pri_context), %g3
  519. ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
  520. mov PRIMARY_CONTEXT, %g1
  521. 661: stxa %g2, [%g1] ASI_DMMU
  522. .section .sun4v_1insn_patch, "ax"
  523. .word 661b
  524. stxa %g2, [%g1] ASI_MMU
  525. .previous
  526. membar #Sync
  527. /* Kill PROM timer */
  528. sethi %hi(0x80000000), %o2
  529. sllx %o2, 32, %o2
  530. wr %o2, 0, %tick_cmpr
  531. BRANCH_IF_SUN4V(o2, 1f)
  532. BRANCH_IF_ANY_CHEETAH(o2, o3, 1f)
  533. ba,pt %xcc, 2f
  534. nop
  535. /* Disable STICK_INT interrupts. */
  536. 1:
  537. sethi %hi(0x80000000), %o2
  538. sllx %o2, 32, %o2
  539. wr %o2, %asr25
  540. 2:
  541. wrpr %g0, %g0, %wstate
  542. call init_irqwork_curcpu
  543. nop
  544. /* Now we can restore interrupt state. */
  545. wrpr %l0, 0, %pstate
  546. wrpr %l1, 0x0, %pil
  547. ret
  548. restore
  549. .globl setup_tba
  550. setup_tba:
  551. save %sp, -192, %sp
  552. /* The boot processor is the only cpu which invokes this
  553. * routine, the other cpus set things up via trampoline.S.
  554. * So save the OBP trap table address here.
  555. */
  556. rdpr %tba, %g7
  557. sethi %hi(prom_tba), %o1
  558. or %o1, %lo(prom_tba), %o1
  559. stx %g7, [%o1]
  560. call setup_trap_table
  561. nop
  562. ret
  563. restore
  564. sparc64_boot_end:
  565. #include "ktlb.S"
  566. #include "tsb.S"
  567. #include "etrap.S"
  568. #include "rtrap.S"
  569. #include "winfixup.S"
  570. #include "entry.S"
  571. #include "sun4v_tlb_miss.S"
  572. #include "sun4v_ivec.S"
  573. /*
  574. * The following skip makes sure the trap table in ttable.S is aligned
  575. * on a 32K boundary as required by the v9 specs for TBA register.
  576. *
  577. * We align to a 32K boundary, then we have the 32K kernel TSB,
  578. * then the 32K aligned trap table.
  579. */
  580. 1:
  581. .skip 0x4000 + _start - 1b
  582. .globl swapper_tsb
  583. swapper_tsb:
  584. .skip (32 * 1024)
  585. ! 0x0000000000408000
  586. #include "ttable.S"
  587. #include "systbls.S"
  588. .data
  589. .align 8
  590. .globl prom_tba, tlb_type
  591. prom_tba: .xword 0
  592. tlb_type: .word 0 /* Must NOT end up in BSS */
  593. .section ".fixup",#alloc,#execinstr
  594. .globl __ret_efault, __retl_efault
  595. __ret_efault:
  596. ret
  597. restore %g0, -EFAULT, %o0
  598. __retl_efault:
  599. retl
  600. mov -EFAULT, %o0