head_32.S 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. /*
  2. * head.S: The initial boot code for the Sparc port of Linux.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1995,1999 Pete Zaitcev (zaitcev@yahoo.com)
  6. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  7. * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  8. * Copyright (C) 1997 Michael A. Griffith (grif@acm.org)
  9. *
  10. * CompactPCI platform by Eric Brower, 1999.
  11. */
  12. #include <linux/version.h>
  13. #include <linux/init.h>
  14. #include <asm/head.h>
  15. #include <asm/asi.h>
  16. #include <asm/contregs.h>
  17. #include <asm/ptrace.h>
  18. #include <asm/psr.h>
  19. #include <asm/page.h>
  20. #include <asm/kdebug.h>
  21. #include <asm/winmacro.h>
  22. #include <asm/thread_info.h> /* TI_UWINMASK */
  23. #include <asm/errno.h>
  24. #include <asm/pgtsrmmu.h> /* SRMMU_PGDIR_SHIFT */
  25. .data
  26. /* The following are used with the prom_vector node-ops to figure out
  27. * the cpu-type
  28. */
  29. .align 4
  30. cputyp:
  31. .word 1
  32. .align 4
  33. .globl cputypval
  34. cputypval:
  35. .asciz "sun4m"
  36. .ascii " "
  37. /* Tested on SS-5, SS-10 */
  38. .align 4
  39. cputypvar:
  40. .asciz "compatible"
  41. .align 4
  42. notsup:
  43. .asciz "Sparc-Linux sun4/sun4c or MMU-less not supported\n\n"
  44. .align 4
  45. sun4e_notsup:
  46. .asciz "Sparc-Linux sun4e support does not exist\n\n"
  47. .align 4
  48. /* The trap-table - located in the __HEAD section */
  49. #include "ttable_32.S"
  50. .align PAGE_SIZE
  51. /* This was the only reasonable way I could think of to properly align
  52. * these page-table data structures.
  53. */
  54. .globl swapper_pg_dir
  55. swapper_pg_dir: .skip PAGE_SIZE
  56. .globl empty_zero_page
  57. empty_zero_page: .skip PAGE_SIZE
  58. .global root_flags
  59. .global ram_flags
  60. .global root_dev
  61. .global sparc_ramdisk_image
  62. .global sparc_ramdisk_size
  63. /* This stuff has to be in sync with SILO and other potential boot loaders
  64. * Fields should be kept upward compatible and whenever any change is made,
  65. * HdrS version should be incremented.
  66. */
  67. .ascii "HdrS"
  68. .word LINUX_VERSION_CODE
  69. .half 0x0203 /* HdrS version */
  70. root_flags:
  71. .half 1
  72. root_dev:
  73. .half 0
  74. ram_flags:
  75. .half 0
  76. sparc_ramdisk_image:
  77. .word 0
  78. sparc_ramdisk_size:
  79. .word 0
  80. .word reboot_command
  81. .word 0, 0, 0
  82. .word _end
  83. /* Cool, here we go. Pick up the romvec pointer in %o0 and stash it in
  84. * %g7 and at prom_vector_p. And also quickly check whether we are on
  85. * a v0, v2, or v3 prom.
  86. */
  87. gokernel:
  88. /* Ok, it's nice to know, as early as possible, if we
  89. * are already mapped where we expect to be in virtual
  90. * memory. The Solaris /boot elf format bootloader
  91. * will peek into our elf header and load us where
  92. * we want to be, otherwise we have to re-map.
  93. *
  94. * Some boot loaders don't place the jmp'rs address
  95. * in %o7, so we do a pc-relative call to a local
  96. * label, then see what %o7 has.
  97. */
  98. mov %o7, %g4 ! Save %o7
  99. /* Jump to it, and pray... */
  100. current_pc:
  101. call 1f
  102. nop
  103. 1:
  104. mov %o7, %g3
  105. tst %o0
  106. be no_sun4u_here
  107. mov %g4, %o7 /* Previous %o7. */
  108. mov %o0, %l0 ! stash away romvec
  109. mov %o0, %g7 ! put it here too
  110. mov %o1, %l1 ! stash away debug_vec too
  111. /* Ok, let's check out our run time program counter. */
  112. set current_pc, %g5
  113. cmp %g3, %g5
  114. be already_mapped
  115. nop
  116. /* %l6 will hold the offset we have to subtract
  117. * from absolute symbols in order to access areas
  118. * in our own image. If already mapped this is
  119. * just plain zero, else it is KERNBASE.
  120. */
  121. set KERNBASE, %l6
  122. b copy_prom_lvl14
  123. nop
  124. already_mapped:
  125. mov 0, %l6
  126. /* Copy over the Prom's level 14 clock handler. */
  127. copy_prom_lvl14:
  128. #if 1
  129. /* DJHR
  130. * preserve our linked/calculated instructions
  131. */
  132. set lvl14_save, %g1
  133. set t_irq14, %g3
  134. sub %g1, %l6, %g1 ! translate to physical
  135. sub %g3, %l6, %g3 ! translate to physical
  136. ldd [%g3], %g4
  137. std %g4, [%g1]
  138. ldd [%g3+8], %g4
  139. std %g4, [%g1+8]
  140. #endif
  141. rd %tbr, %g1
  142. andn %g1, 0xfff, %g1 ! proms trap table base
  143. or %g0, (0x1e<<4), %g2 ! offset to lvl14 intr
  144. or %g1, %g2, %g2
  145. set t_irq14, %g3
  146. sub %g3, %l6, %g3
  147. ldd [%g2], %g4
  148. std %g4, [%g3]
  149. ldd [%g2 + 0x8], %g4
  150. std %g4, [%g3 + 0x8] ! Copy proms handler
  151. /* DON'T TOUCH %l0 thru %l5 in these remapping routines,
  152. * we need their values afterwards!
  153. */
  154. /* Now check whether we are already mapped, if we
  155. * are we can skip all this garbage coming up.
  156. */
  157. copy_prom_done:
  158. cmp %l6, 0
  159. be go_to_highmem ! this will be a nop then
  160. nop
  161. /* Validate that we are in fact running on an
  162. * SRMMU based cpu.
  163. */
  164. set 0x4000, %g6
  165. cmp %g7, %g6
  166. bne not_a_sun4
  167. nop
  168. halt_sun4_or_sun4c:
  169. ld [%g7 + 0x68], %o1
  170. set notsup, %o0
  171. sub %o0, %l6, %o0
  172. call %o1
  173. nop
  174. ba halt_me
  175. nop
  176. not_a_sun4:
  177. lda [%g0] ASI_M_MMUREGS, %g1
  178. andcc %g1, 1, %g0
  179. be halt_sun4_or_sun4c
  180. nop
  181. srmmu_remap:
  182. /* First, check for a viking (TI) module. */
  183. set 0x40000000, %g2
  184. rd %psr, %g3
  185. and %g2, %g3, %g3
  186. subcc %g3, 0x0, %g0
  187. bz srmmu_nviking
  188. nop
  189. /* Figure out what kind of viking we are on.
  190. * We need to know if we have to play with the
  191. * AC bit and disable traps or not.
  192. */
  193. /* I've only seen MicroSparc's on SparcClassics with this
  194. * bit set.
  195. */
  196. set 0x800, %g2
  197. lda [%g0] ASI_M_MMUREGS, %g3 ! peek in the control reg
  198. and %g2, %g3, %g3
  199. subcc %g3, 0x0, %g0
  200. bnz srmmu_nviking ! is in mbus mode
  201. nop
  202. rd %psr, %g3 ! DO NOT TOUCH %g3
  203. andn %g3, PSR_ET, %g2
  204. wr %g2, 0x0, %psr
  205. WRITE_PAUSE
  206. /* Get context table pointer, then convert to
  207. * a physical address, which is 36 bits.
  208. */
  209. set AC_M_CTPR, %g4
  210. lda [%g4] ASI_M_MMUREGS, %g4
  211. sll %g4, 0x4, %g4 ! We use this below
  212. ! DO NOT TOUCH %g4
  213. /* Set the AC bit in the Viking's MMU control reg. */
  214. lda [%g0] ASI_M_MMUREGS, %g5 ! DO NOT TOUCH %g5
  215. set 0x8000, %g6 ! AC bit mask
  216. or %g5, %g6, %g6 ! Or it in...
  217. sta %g6, [%g0] ASI_M_MMUREGS ! Close your eyes...
  218. /* Grrr, why does it seem like every other load/store
  219. * on the sun4m is in some ASI space...
  220. * Fine with me, let's get the pointer to the level 1
  221. * page table directory and fetch its entry.
  222. */
  223. lda [%g4] ASI_M_BYPASS, %o1 ! This is a level 1 ptr
  224. srl %o1, 0x4, %o1 ! Clear low 4 bits
  225. sll %o1, 0x8, %o1 ! Make physical
  226. /* Ok, pull in the PTD. */
  227. lda [%o1] ASI_M_BYPASS, %o2 ! This is the 0x0 16MB pgd
  228. /* Calculate to KERNBASE entry. */
  229. add %o1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %o3
  230. /* Poke the entry into the calculated address. */
  231. sta %o2, [%o3] ASI_M_BYPASS
  232. /* I don't get it Sun, if you engineered all these
  233. * boot loaders and the PROM (thank you for the debugging
  234. * features btw) why did you not have them load kernel
  235. * images up in high address space, since this is necessary
  236. * for ABI compliance anyways? Does this low-mapping provide
  237. * enhanced interoperability?
  238. *
  239. * "The PROM is the computer."
  240. */
  241. /* Ok, restore the MMU control register we saved in %g5 */
  242. sta %g5, [%g0] ASI_M_MMUREGS ! POW... ouch
  243. /* Turn traps back on. We saved it in %g3 earlier. */
  244. wr %g3, 0x0, %psr ! tick tock, tick tock
  245. /* Now we burn precious CPU cycles due to bad engineering. */
  246. WRITE_PAUSE
  247. /* Wow, all that just to move a 32-bit value from one
  248. * place to another... Jump to high memory.
  249. */
  250. b go_to_highmem
  251. nop
  252. /* This works on viking's in Mbus mode and all
  253. * other MBUS modules. It is virtually the same as
  254. * the above madness sans turning traps off and flipping
  255. * the AC bit.
  256. */
  257. srmmu_nviking:
  258. set AC_M_CTPR, %g1
  259. lda [%g1] ASI_M_MMUREGS, %g1 ! get ctx table ptr
  260. sll %g1, 0x4, %g1 ! make physical addr
  261. lda [%g1] ASI_M_BYPASS, %g1 ! ptr to level 1 pg_table
  262. srl %g1, 0x4, %g1
  263. sll %g1, 0x8, %g1 ! make phys addr for l1 tbl
  264. lda [%g1] ASI_M_BYPASS, %g2 ! get level1 entry for 0x0
  265. add %g1, KERNBASE >> (SRMMU_PGDIR_SHIFT - 2), %g3
  266. sta %g2, [%g3] ASI_M_BYPASS ! place at KERNBASE entry
  267. b go_to_highmem
  268. nop ! wheee....
  269. /* Now do a non-relative jump so that PC is in high-memory */
  270. go_to_highmem:
  271. set execute_in_high_mem, %g1
  272. jmpl %g1, %g0
  273. nop
  274. /* The code above should be at beginning and we have to take care about
  275. * short jumps, as branching to .init.text section from .text is usually
  276. * impossible */
  277. __INIT
  278. /* Acquire boot time privileged register values, this will help debugging.
  279. * I figure out and store nwindows and nwindowsm1 later on.
  280. */
  281. execute_in_high_mem:
  282. mov %l0, %o0 ! put back romvec
  283. mov %l1, %o1 ! and debug_vec
  284. sethi %hi(prom_vector_p), %g1
  285. st %o0, [%g1 + %lo(prom_vector_p)]
  286. sethi %hi(linux_dbvec), %g1
  287. st %o1, [%g1 + %lo(linux_dbvec)]
  288. /* Get the machine type via the mysterious romvec node operations. */
  289. add %g7, 0x1c, %l1
  290. ld [%l1], %l0
  291. ld [%l0], %l0
  292. call %l0
  293. or %g0, %g0, %o0 ! next_node(0) = first_node
  294. or %o0, %g0, %g6
  295. sethi %hi(cputypvar), %o1 ! First node has cpu-arch
  296. or %o1, %lo(cputypvar), %o1
  297. sethi %hi(cputypval), %o2 ! information, the string
  298. or %o2, %lo(cputypval), %o2
  299. ld [%l1], %l0 ! 'compatible' tells
  300. ld [%l0 + 0xc], %l0 ! that we want 'sun4x' where
  301. call %l0 ! x is one of 'm', 'd' or 'e'.
  302. nop ! %o2 holds pointer
  303. ! to a buf where above string
  304. ! will get stored by the prom.
  305. #ifdef CONFIG_SPARC_LEON
  306. /* no cpu-type check is needed, it is a SPARC-LEON */
  307. sethi %hi(boot_cpu_id), %g2 ! boot-cpu index
  308. #ifdef CONFIG_SMP
  309. ldub [%g2 + %lo(boot_cpu_id)], %g1
  310. cmp %g1, 0xff ! unset means first CPU
  311. bne leon_smp_cpu_startup ! continue only with master
  312. nop
  313. #endif
  314. /* Get CPU-ID from most significant 4-bit of ASR17 */
  315. rd %asr17, %g1
  316. srl %g1, 28, %g1
  317. /* Update boot_cpu_id only on boot cpu */
  318. stub %g1, [%g2 + %lo(boot_cpu_id)]
  319. ba continue_boot
  320. nop
  321. #endif
  322. /* Check to cputype. We may be booted on a sun4u (64 bit box),
  323. * and sun4d needs special treatment.
  324. */
  325. set cputypval, %o2
  326. ldub [%o2 + 0x4], %l1
  327. cmp %l1, 'm'
  328. be sun4m_init
  329. cmp %l1, 's'
  330. be sun4m_init
  331. cmp %l1, 'd'
  332. be sun4d_init
  333. cmp %l1, 'e'
  334. be no_sun4e_here ! Could be a sun4e.
  335. nop
  336. b no_sun4u_here ! AIEEE, a V9 sun4u... Get our BIG BROTHER kernel :))
  337. nop
  338. /* CPUID in bootbus can be found at PA 0xff0140000 */
  339. #define SUN4D_BOOTBUS_CPUID 0xf0140000
  340. sun4d_init:
  341. /* Need to patch call to handler_irq */
  342. set patch_handler_irq, %g4
  343. set sun4d_handler_irq, %g5
  344. sethi %hi(0x40000000), %g3 ! call
  345. sub %g5, %g4, %g5
  346. srl %g5, 2, %g5
  347. or %g5, %g3, %g5
  348. st %g5, [%g4]
  349. #ifdef CONFIG_SMP
  350. /* Get our CPU id out of bootbus */
  351. set SUN4D_BOOTBUS_CPUID, %g3
  352. lduba [%g3] ASI_M_CTL, %g3
  353. and %g3, 0xf8, %g3
  354. srl %g3, 3, %g4
  355. sta %g4, [%g0] ASI_M_VIKING_TMP1
  356. sethi %hi(boot_cpu_id), %g5
  357. stb %g4, [%g5 + %lo(boot_cpu_id)]
  358. #endif
  359. /* Fall through to sun4m_init */
  360. sun4m_init:
  361. /* Ok, the PROM could have done funny things and apple cider could still
  362. * be sitting in the fault status/address registers. Read them all to
  363. * clear them so we don't get magic faults later on.
  364. */
  365. /* This sucks, apparently this makes Vikings call prom panic, will fix later */
  366. 2:
  367. rd %psr, %o1
  368. srl %o1, 28, %o1 ! Get a type of the CPU
  369. subcc %o1, 4, %g0 ! TI: Viking or MicroSPARC
  370. be continue_boot
  371. nop
  372. set AC_M_SFSR, %o0
  373. lda [%o0] ASI_M_MMUREGS, %g0
  374. set AC_M_SFAR, %o0
  375. lda [%o0] ASI_M_MMUREGS, %g0
  376. /* Fujitsu MicroSPARC-II has no asynchronous flavors of FARs */
  377. subcc %o1, 0, %g0
  378. be continue_boot
  379. nop
  380. set AC_M_AFSR, %o0
  381. lda [%o0] ASI_M_MMUREGS, %g0
  382. set AC_M_AFAR, %o0
  383. lda [%o0] ASI_M_MMUREGS, %g0
  384. nop
  385. continue_boot:
  386. /* Aieee, now set PC and nPC, enable traps, give ourselves a stack and it's
  387. * show-time!
  388. */
  389. sethi %hi(cputyp), %o0
  390. st %g4, [%o0 + %lo(cputyp)]
  391. /* Turn on Supervisor, EnableFloating, and all the PIL bits.
  392. * Also puts us in register window zero with traps off.
  393. */
  394. set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
  395. wr %g2, 0x0, %psr
  396. WRITE_PAUSE
  397. /* I want a kernel stack NOW! */
  398. set init_thread_union, %g1
  399. set (THREAD_SIZE - STACKFRAME_SZ), %g2
  400. add %g1, %g2, %sp
  401. mov 0, %fp /* And for good luck */
  402. /* Zero out our BSS section. */
  403. set __bss_start , %o0 ! First address of BSS
  404. set _end , %o1 ! Last address of BSS
  405. add %o0, 0x1, %o0
  406. 1:
  407. stb %g0, [%o0]
  408. subcc %o0, %o1, %g0
  409. bl 1b
  410. add %o0, 0x1, %o0
  411. /* If boot_cpu_id has not been setup by machine specific
  412. * init-code above we default it to zero.
  413. */
  414. sethi %hi(boot_cpu_id), %g2
  415. ldub [%g2 + %lo(boot_cpu_id)], %g3
  416. cmp %g3, 0xff
  417. bne 1f
  418. nop
  419. mov %g0, %g3
  420. stub %g3, [%g2 + %lo(boot_cpu_id)]
  421. 1: sll %g3, 2, %g3
  422. /* Initialize the uwinmask value for init task just in case.
  423. * But first make current_set[boot_cpu_id] point to something useful.
  424. */
  425. set init_thread_union, %g6
  426. set current_set, %g2
  427. #ifdef CONFIG_SMP
  428. st %g6, [%g2]
  429. add %g2, %g3, %g2
  430. #endif
  431. st %g6, [%g2]
  432. st %g0, [%g6 + TI_UWINMASK]
  433. /* Compute NWINDOWS and stash it away. Now uses %wim trick explained
  434. * in the V8 manual. Ok, this method seems to work, Sparc is cool...
  435. * No, it doesn't work, have to play the save/readCWP/restore trick.
  436. */
  437. wr %g0, 0x0, %wim ! so we do not get a trap
  438. WRITE_PAUSE
  439. save
  440. rd %psr, %g3
  441. restore
  442. and %g3, 0x1f, %g3
  443. add %g3, 0x1, %g3
  444. mov 2, %g1
  445. wr %g1, 0x0, %wim ! make window 1 invalid
  446. WRITE_PAUSE
  447. cmp %g3, 0x7
  448. bne 2f
  449. nop
  450. /* Adjust our window handling routines to
  451. * do things correctly on 7 window Sparcs.
  452. */
  453. #define PATCH_INSN(src, dest) \
  454. set src, %g5; \
  455. set dest, %g2; \
  456. ld [%g5], %g4; \
  457. st %g4, [%g2];
  458. /* Patch for window spills... */
  459. PATCH_INSN(spnwin_patch1_7win, spnwin_patch1)
  460. PATCH_INSN(spnwin_patch2_7win, spnwin_patch2)
  461. PATCH_INSN(spnwin_patch3_7win, spnwin_patch3)
  462. /* Patch for window fills... */
  463. PATCH_INSN(fnwin_patch1_7win, fnwin_patch1)
  464. PATCH_INSN(fnwin_patch2_7win, fnwin_patch2)
  465. /* Patch for trap entry setup... */
  466. PATCH_INSN(tsetup_7win_patch1, tsetup_patch1)
  467. PATCH_INSN(tsetup_7win_patch2, tsetup_patch2)
  468. PATCH_INSN(tsetup_7win_patch3, tsetup_patch3)
  469. PATCH_INSN(tsetup_7win_patch4, tsetup_patch4)
  470. PATCH_INSN(tsetup_7win_patch5, tsetup_patch5)
  471. PATCH_INSN(tsetup_7win_patch6, tsetup_patch6)
  472. /* Patch for returning from traps... */
  473. PATCH_INSN(rtrap_7win_patch1, rtrap_patch1)
  474. PATCH_INSN(rtrap_7win_patch2, rtrap_patch2)
  475. PATCH_INSN(rtrap_7win_patch3, rtrap_patch3)
  476. PATCH_INSN(rtrap_7win_patch4, rtrap_patch4)
  477. PATCH_INSN(rtrap_7win_patch5, rtrap_patch5)
  478. /* Patch for killing user windows from the register file. */
  479. PATCH_INSN(kuw_patch1_7win, kuw_patch1)
  480. /* Now patch the kernel window flush sequences.
  481. * This saves 2 traps on every switch and fork.
  482. */
  483. set 0x01000000, %g4
  484. set flush_patch_one, %g5
  485. st %g4, [%g5 + 0x18]
  486. st %g4, [%g5 + 0x1c]
  487. set flush_patch_two, %g5
  488. st %g4, [%g5 + 0x18]
  489. st %g4, [%g5 + 0x1c]
  490. set flush_patch_three, %g5
  491. st %g4, [%g5 + 0x18]
  492. st %g4, [%g5 + 0x1c]
  493. set flush_patch_four, %g5
  494. st %g4, [%g5 + 0x18]
  495. st %g4, [%g5 + 0x1c]
  496. set flush_patch_exception, %g5
  497. st %g4, [%g5 + 0x18]
  498. st %g4, [%g5 + 0x1c]
  499. set flush_patch_switch, %g5
  500. st %g4, [%g5 + 0x18]
  501. st %g4, [%g5 + 0x1c]
  502. 2:
  503. sethi %hi(nwindows), %g4
  504. st %g3, [%g4 + %lo(nwindows)] ! store final value
  505. sub %g3, 0x1, %g3
  506. sethi %hi(nwindowsm1), %g4
  507. st %g3, [%g4 + %lo(nwindowsm1)]
  508. /* Here we go, start using Linux's trap table... */
  509. set trapbase, %g3
  510. wr %g3, 0x0, %tbr
  511. WRITE_PAUSE
  512. /* Finally, turn on traps so that we can call c-code. */
  513. rd %psr, %g3
  514. wr %g3, 0x0, %psr
  515. WRITE_PAUSE
  516. wr %g3, PSR_ET, %psr
  517. WRITE_PAUSE
  518. /* First we call prom_init() to set up PROMLIB, then
  519. * off to start_kernel().
  520. */
  521. sethi %hi(prom_vector_p), %g5
  522. ld [%g5 + %lo(prom_vector_p)], %o0
  523. call prom_init
  524. nop
  525. call start_kernel
  526. nop
  527. /* We should not get here. */
  528. call halt_me
  529. nop
  530. no_sun4e_here:
  531. ld [%g7 + 0x68], %o1
  532. set sun4e_notsup, %o0
  533. call %o1
  534. nop
  535. b halt_me
  536. nop
  537. __INITDATA
  538. sun4u_1:
  539. .asciz "finddevice"
  540. .align 4
  541. sun4u_2:
  542. .asciz "/chosen"
  543. .align 4
  544. sun4u_3:
  545. .asciz "getprop"
  546. .align 4
  547. sun4u_4:
  548. .asciz "stdout"
  549. .align 4
  550. sun4u_5:
  551. .asciz "write"
  552. .align 4
  553. sun4u_6:
  554. .asciz "\n\rOn sun4u you have to use sparc64 kernel\n\rand not a sparc32 version\n\r\n\r"
  555. sun4u_6e:
  556. .align 4
  557. sun4u_7:
  558. .asciz "exit"
  559. .align 8
  560. sun4u_a1:
  561. .word 0, sun4u_1, 0, 1, 0, 1, 0, sun4u_2, 0
  562. sun4u_r1:
  563. .word 0
  564. sun4u_a2:
  565. .word 0, sun4u_3, 0, 4, 0, 1, 0
  566. sun4u_i2:
  567. .word 0, 0, sun4u_4, 0, sun4u_1, 0, 8, 0
  568. sun4u_r2:
  569. .word 0
  570. sun4u_a3:
  571. .word 0, sun4u_5, 0, 3, 0, 1, 0
  572. sun4u_i3:
  573. .word 0, 0, sun4u_6, 0, sun4u_6e - sun4u_6 - 1, 0
  574. sun4u_r3:
  575. .word 0
  576. sun4u_a4:
  577. .word 0, sun4u_7, 0, 0, 0, 0
  578. sun4u_r4:
  579. __INIT
  580. no_sun4u_here:
  581. set sun4u_a1, %o0
  582. set current_pc, %l2
  583. cmp %l2, %g3
  584. be 1f
  585. mov %o4, %l0
  586. sub %g3, %l2, %l6
  587. add %o0, %l6, %o0
  588. mov %o0, %l4
  589. mov sun4u_r4 - sun4u_a1, %l3
  590. ld [%l4], %l5
  591. 2:
  592. add %l4, 4, %l4
  593. cmp %l5, %l2
  594. add %l5, %l6, %l5
  595. bgeu,a 3f
  596. st %l5, [%l4 - 4]
  597. 3:
  598. subcc %l3, 4, %l3
  599. bne 2b
  600. ld [%l4], %l5
  601. 1:
  602. call %l0
  603. mov %o0, %l1
  604. ld [%l1 + (sun4u_r1 - sun4u_a1)], %o1
  605. add %l1, (sun4u_a2 - sun4u_a1), %o0
  606. call %l0
  607. st %o1, [%o0 + (sun4u_i2 - sun4u_a2)]
  608. ld [%l1 + (sun4u_1 - sun4u_a1)], %o1
  609. add %l1, (sun4u_a3 - sun4u_a1), %o0
  610. call %l0
  611. st %o1, [%o0 + (sun4u_i3 - sun4u_a3)]
  612. call %l0
  613. add %l1, (sun4u_a4 - sun4u_a1), %o0
  614. /* Not reached */
  615. halt_me:
  616. ld [%g7 + 0x74], %o0
  617. call %o0 ! Get us out of here...
  618. nop ! Apparently Solaris is better.
  619. /* Ok, now we continue in the .data/.text sections */
  620. .data
  621. .align 4
  622. /*
  623. * Fill up the prom vector, note in particular the kind first element,
  624. * no joke. I don't need all of them in here as the entire prom vector
  625. * gets initialized in c-code so all routines can use it.
  626. */
  627. prom_vector_p:
  628. .word 0
  629. /* We calculate the following at boot time, window fills/spills and trap entry
  630. * code uses these to keep track of the register windows.
  631. */
  632. .align 4
  633. .globl nwindows
  634. .globl nwindowsm1
  635. nwindows:
  636. .word 8
  637. nwindowsm1:
  638. .word 7
  639. /* Boot time debugger vector value. We need this later on. */
  640. .align 4
  641. .globl linux_dbvec
  642. linux_dbvec:
  643. .word 0
  644. .word 0
  645. .align 8
  646. .globl lvl14_save
  647. lvl14_save:
  648. .word 0
  649. .word 0
  650. .word 0
  651. .word 0
  652. .word t_irq14
  653. .section ".fixup",#alloc,#execinstr
  654. .globl __ret_efault
  655. __ret_efault:
  656. ret
  657. restore %g0, -EFAULT, %o0