head.S 16 KB

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