head_64.S 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*
  2. * PowerPC version
  3. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  4. *
  5. * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
  6. * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
  7. * Adapted for Power Macintosh by Paul Mackerras.
  8. * Low-level exception handlers and MMU support
  9. * rewritten by Paul Mackerras.
  10. * Copyright (C) 1996 Paul Mackerras.
  11. *
  12. * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
  13. * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
  14. *
  15. * This file contains the entry point for the 64-bit kernel along
  16. * with some early initialization code common to all 64-bit powerpc
  17. * variants.
  18. *
  19. * This program is free software; you can redistribute it and/or
  20. * modify it under the terms of the GNU General Public License
  21. * as published by the Free Software Foundation; either version
  22. * 2 of the License, or (at your option) any later version.
  23. */
  24. #include <linux/threads.h>
  25. #include <asm/reg.h>
  26. #include <asm/page.h>
  27. #include <asm/mmu.h>
  28. #include <asm/ppc_asm.h>
  29. #include <asm/asm-offsets.h>
  30. #include <asm/bug.h>
  31. #include <asm/cputable.h>
  32. #include <asm/setup.h>
  33. #include <asm/hvcall.h>
  34. #include <asm/iseries/lpar_map.h>
  35. #include <asm/thread_info.h>
  36. #include <asm/firmware.h>
  37. #include <asm/page_64.h>
  38. #include <asm/irqflags.h>
  39. /* The physical memory is layed out such that the secondary processor
  40. * spin code sits at 0x0000...0x00ff. On server, the vectors follow
  41. * using the layout described in exceptions-64s.S
  42. */
  43. /*
  44. * Entering into this code we make the following assumptions:
  45. *
  46. * For pSeries or server processors:
  47. * 1. The MMU is off & open firmware is running in real mode.
  48. * 2. The kernel is entered at __start
  49. *
  50. * For iSeries:
  51. * 1. The MMU is on (as it always is for iSeries)
  52. * 2. The kernel is entered at system_reset_iSeries
  53. *
  54. * For Book3E processors:
  55. * 1. The MMU is on running in AS0 in a state defined in ePAPR
  56. * 2. The kernel is entered at __start
  57. */
  58. .text
  59. .globl _stext
  60. _stext:
  61. _GLOBAL(__start)
  62. /* NOP this out unconditionally */
  63. BEGIN_FTR_SECTION
  64. b .__start_initialization_multiplatform
  65. END_FTR_SECTION(0, 1)
  66. /* Catch branch to 0 in real mode */
  67. trap
  68. /* Secondary processors spin on this value until it becomes nonzero.
  69. * When it does it contains the real address of the descriptor
  70. * of the function that the cpu should jump to to continue
  71. * initialization.
  72. */
  73. .globl __secondary_hold_spinloop
  74. __secondary_hold_spinloop:
  75. .llong 0x0
  76. /* Secondary processors write this value with their cpu # */
  77. /* after they enter the spin loop immediately below. */
  78. .globl __secondary_hold_acknowledge
  79. __secondary_hold_acknowledge:
  80. .llong 0x0
  81. #ifdef CONFIG_PPC_ISERIES
  82. /*
  83. * At offset 0x20, there is a pointer to iSeries LPAR data.
  84. * This is required by the hypervisor
  85. */
  86. . = 0x20
  87. .llong hvReleaseData-KERNELBASE
  88. #endif /* CONFIG_PPC_ISERIES */
  89. #ifdef CONFIG_CRASH_DUMP
  90. /* This flag is set to 1 by a loader if the kernel should run
  91. * at the loaded address instead of the linked address. This
  92. * is used by kexec-tools to keep the the kdump kernel in the
  93. * crash_kernel region. The loader is responsible for
  94. * observing the alignment requirement.
  95. */
  96. /* Do not move this variable as kexec-tools knows about it. */
  97. . = 0x5c
  98. .globl __run_at_load
  99. __run_at_load:
  100. .long 0x72756e30 /* "run0" -- relocate to 0 by default */
  101. #endif
  102. . = 0x60
  103. /*
  104. * The following code is used to hold secondary processors
  105. * in a spin loop after they have entered the kernel, but
  106. * before the bulk of the kernel has been relocated. This code
  107. * is relocated to physical address 0x60 before prom_init is run.
  108. * All of it must fit below the first exception vector at 0x100.
  109. * Use .globl here not _GLOBAL because we want __secondary_hold
  110. * to be the actual text address, not a descriptor.
  111. */
  112. .globl __secondary_hold
  113. __secondary_hold:
  114. mfmsr r24
  115. ori r24,r24,MSR_RI
  116. mtmsrd r24 /* RI on */
  117. /* Grab our physical cpu number */
  118. mr r24,r3
  119. /* Tell the master cpu we're here */
  120. /* Relocation is off & we are located at an address less */
  121. /* than 0x100, so only need to grab low order offset. */
  122. std r24,__secondary_hold_acknowledge-_stext(0)
  123. sync
  124. /* All secondary cpus wait here until told to start. */
  125. 100: ld r4,__secondary_hold_spinloop-_stext(0)
  126. cmpdi 0,r4,0
  127. beq 100b
  128. #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
  129. ld r4,0(r4) /* deref function descriptor */
  130. mtctr r4
  131. mr r3,r24
  132. bctr
  133. #else
  134. BUG_OPCODE
  135. #endif
  136. /* This value is used to mark exception frames on the stack. */
  137. .section ".toc","aw"
  138. exception_marker:
  139. .tc ID_72656773_68657265[TC],0x7265677368657265
  140. .text
  141. /*
  142. * On server, we include the exception vectors code here as it
  143. * relies on absolute addressing which is only possible within
  144. * this compilation unit
  145. */
  146. #ifdef CONFIG_PPC_BOOK3S
  147. #include "exceptions-64s.S"
  148. #endif
  149. /*
  150. * On pSeries and most other platforms, secondary processors spin
  151. * in the following code.
  152. * At entry, r3 = this processor's number (physical cpu id)
  153. */
  154. _GLOBAL(generic_secondary_smp_init)
  155. mr r24,r3
  156. /* turn on 64-bit mode */
  157. bl .enable_64b_mode
  158. /* get the TOC pointer (real address) */
  159. bl .relative_toc
  160. /* Set up a paca value for this processor. Since we have the
  161. * physical cpu id in r24, we need to search the pacas to find
  162. * which logical id maps to our physical one.
  163. */
  164. LOAD_REG_ADDR(r13, paca) /* Get base vaddr of paca array */
  165. li r5,0 /* logical cpu id */
  166. 1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */
  167. cmpw r6,r24 /* Compare to our id */
  168. beq 2f
  169. addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */
  170. addi r5,r5,1
  171. cmpwi r5,NR_CPUS
  172. blt 1b
  173. mr r3,r24 /* not found, copy phys to r3 */
  174. b .kexec_wait /* next kernel might do better */
  175. 2: mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
  176. /* From now on, r24 is expected to be logical cpuid */
  177. mr r24,r5
  178. 3: HMT_LOW
  179. lbz r23,PACAPROCSTART(r13) /* Test if this processor should */
  180. /* start. */
  181. #ifndef CONFIG_SMP
  182. b 3b /* Never go on non-SMP */
  183. #else
  184. cmpwi 0,r23,0
  185. beq 3b /* Loop until told to go */
  186. sync /* order paca.run and cur_cpu_spec */
  187. /* See if we need to call a cpu state restore handler */
  188. LOAD_REG_ADDR(r23, cur_cpu_spec)
  189. ld r23,0(r23)
  190. ld r23,CPU_SPEC_RESTORE(r23)
  191. cmpdi 0,r23,0
  192. beq 4f
  193. ld r23,0(r23)
  194. mtctr r23
  195. bctrl
  196. 4: /* Create a temp kernel stack for use before relocation is on. */
  197. ld r1,PACAEMERGSP(r13)
  198. subi r1,r1,STACK_FRAME_OVERHEAD
  199. b __secondary_start
  200. #endif
  201. /*
  202. * Turn the MMU off.
  203. * Assumes we're mapped EA == RA if the MMU is on.
  204. */
  205. _STATIC(__mmu_off)
  206. mfmsr r3
  207. andi. r0,r3,MSR_IR|MSR_DR
  208. beqlr
  209. mflr r4
  210. andc r3,r3,r0
  211. mtspr SPRN_SRR0,r4
  212. mtspr SPRN_SRR1,r3
  213. sync
  214. rfid
  215. b . /* prevent speculative execution */
  216. /*
  217. * Here is our main kernel entry point. We support currently 2 kind of entries
  218. * depending on the value of r5.
  219. *
  220. * r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content
  221. * in r3...r7
  222. *
  223. * r5 == NULL -> kexec style entry. r3 is a physical pointer to the
  224. * DT block, r4 is a physical pointer to the kernel itself
  225. *
  226. */
  227. _GLOBAL(__start_initialization_multiplatform)
  228. /* Make sure we are running in 64 bits mode */
  229. bl .enable_64b_mode
  230. /* Get TOC pointer (current runtime address) */
  231. bl .relative_toc
  232. /* find out where we are now */
  233. bcl 20,31,$+4
  234. 0: mflr r26 /* r26 = runtime addr here */
  235. addis r26,r26,(_stext - 0b)@ha
  236. addi r26,r26,(_stext - 0b)@l /* current runtime base addr */
  237. /*
  238. * Are we booted from a PROM Of-type client-interface ?
  239. */
  240. cmpldi cr0,r5,0
  241. beq 1f
  242. b .__boot_from_prom /* yes -> prom */
  243. 1:
  244. /* Save parameters */
  245. mr r31,r3
  246. mr r30,r4
  247. /* Setup some critical 970 SPRs before switching MMU off */
  248. mfspr r0,SPRN_PVR
  249. srwi r0,r0,16
  250. cmpwi r0,0x39 /* 970 */
  251. beq 1f
  252. cmpwi r0,0x3c /* 970FX */
  253. beq 1f
  254. cmpwi r0,0x44 /* 970MP */
  255. beq 1f
  256. cmpwi r0,0x45 /* 970GX */
  257. bne 2f
  258. 1: bl .__cpu_preinit_ppc970
  259. 2:
  260. /* Switch off MMU if not already off */
  261. bl .__mmu_off
  262. b .__after_prom_start
  263. _INIT_STATIC(__boot_from_prom)
  264. #ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
  265. /* Save parameters */
  266. mr r31,r3
  267. mr r30,r4
  268. mr r29,r5
  269. mr r28,r6
  270. mr r27,r7
  271. /*
  272. * Align the stack to 16-byte boundary
  273. * Depending on the size and layout of the ELF sections in the initial
  274. * boot binary, the stack pointer may be unaligned on PowerMac
  275. */
  276. rldicr r1,r1,0,59
  277. #ifdef CONFIG_RELOCATABLE
  278. /* Relocate code for where we are now */
  279. mr r3,r26
  280. bl .relocate
  281. #endif
  282. /* Restore parameters */
  283. mr r3,r31
  284. mr r4,r30
  285. mr r5,r29
  286. mr r6,r28
  287. mr r7,r27
  288. /* Do all of the interaction with OF client interface */
  289. mr r8,r26
  290. bl .prom_init
  291. #endif /* #CONFIG_PPC_OF_BOOT_TRAMPOLINE */
  292. /* We never return. We also hit that trap if trying to boot
  293. * from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */
  294. trap
  295. _STATIC(__after_prom_start)
  296. #ifdef CONFIG_RELOCATABLE
  297. /* process relocations for the final address of the kernel */
  298. lis r25,PAGE_OFFSET@highest /* compute virtual base of kernel */
  299. sldi r25,r25,32
  300. #ifdef CONFIG_CRASH_DUMP
  301. lwz r7,__run_at_load-_stext(r26)
  302. cmplwi cr0,r7,1 /* kdump kernel ? - stay where we are */
  303. bne 1f
  304. add r25,r25,r26
  305. #endif
  306. 1: mr r3,r25
  307. bl .relocate
  308. #endif
  309. /*
  310. * We need to run with _stext at physical address PHYSICAL_START.
  311. * This will leave some code in the first 256B of
  312. * real memory, which are reserved for software use.
  313. *
  314. * Note: This process overwrites the OF exception vectors.
  315. */
  316. li r3,0 /* target addr */
  317. mr. r4,r26 /* In some cases the loader may */
  318. beq 9f /* have already put us at zero */
  319. li r6,0x100 /* Start offset, the first 0x100 */
  320. /* bytes were copied earlier. */
  321. #ifdef CONFIG_CRASH_DUMP
  322. /*
  323. * Check if the kernel has to be running as relocatable kernel based on the
  324. * variable __run_at_load, if it is set the kernel is treated as relocatable
  325. * kernel, otherwise it will be moved to PHYSICAL_START
  326. */
  327. lwz r7,__run_at_load-_stext(r26)
  328. cmplwi cr0,r7,1
  329. bne 3f
  330. li r5,__end_interrupts - _stext /* just copy interrupts */
  331. b 5f
  332. 3:
  333. #endif
  334. lis r5,(copy_to_here - _stext)@ha
  335. addi r5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */
  336. bl .copy_and_flush /* copy the first n bytes */
  337. /* this includes the code being */
  338. /* executed here. */
  339. addis r8,r3,(4f - _stext)@ha /* Jump to the copy of this code */
  340. addi r8,r8,(4f - _stext)@l /* that we just made */
  341. mtctr r8
  342. bctr
  343. p_end: .llong _end - _stext
  344. 4: /* Now copy the rest of the kernel up to _end */
  345. addis r5,r26,(p_end - _stext)@ha
  346. ld r5,(p_end - _stext)@l(r5) /* get _end */
  347. 5: bl .copy_and_flush /* copy the rest */
  348. 9: b .start_here_multiplatform
  349. /*
  350. * Copy routine used to copy the kernel to start at physical address 0
  351. * and flush and invalidate the caches as needed.
  352. * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset
  353. * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5.
  354. *
  355. * Note: this routine *only* clobbers r0, r6 and lr
  356. */
  357. _GLOBAL(copy_and_flush)
  358. addi r5,r5,-8
  359. addi r6,r6,-8
  360. 4: li r0,8 /* Use the smallest common */
  361. /* denominator cache line */
  362. /* size. This results in */
  363. /* extra cache line flushes */
  364. /* but operation is correct. */
  365. /* Can't get cache line size */
  366. /* from NACA as it is being */
  367. /* moved too. */
  368. mtctr r0 /* put # words/line in ctr */
  369. 3: addi r6,r6,8 /* copy a cache line */
  370. ldx r0,r6,r4
  371. stdx r0,r6,r3
  372. bdnz 3b
  373. dcbst r6,r3 /* write it to memory */
  374. sync
  375. icbi r6,r3 /* flush the icache line */
  376. cmpld 0,r6,r5
  377. blt 4b
  378. sync
  379. addi r5,r5,8
  380. addi r6,r6,8
  381. blr
  382. .align 8
  383. copy_to_here:
  384. #ifdef CONFIG_SMP
  385. #ifdef CONFIG_PPC_PMAC
  386. /*
  387. * On PowerMac, secondary processors starts from the reset vector, which
  388. * is temporarily turned into a call to one of the functions below.
  389. */
  390. .section ".text";
  391. .align 2 ;
  392. .globl __secondary_start_pmac_0
  393. __secondary_start_pmac_0:
  394. /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */
  395. li r24,0
  396. b 1f
  397. li r24,1
  398. b 1f
  399. li r24,2
  400. b 1f
  401. li r24,3
  402. 1:
  403. _GLOBAL(pmac_secondary_start)
  404. /* turn on 64-bit mode */
  405. bl .enable_64b_mode
  406. li r0,0
  407. mfspr r3,SPRN_HID4
  408. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  409. sync
  410. mtspr SPRN_HID4,r3
  411. isync
  412. sync
  413. slbia
  414. /* get TOC pointer (real address) */
  415. bl .relative_toc
  416. /* Copy some CPU settings from CPU 0 */
  417. bl .__restore_cpu_ppc970
  418. /* pSeries do that early though I don't think we really need it */
  419. mfmsr r3
  420. ori r3,r3,MSR_RI
  421. mtmsrd r3 /* RI on */
  422. /* Set up a paca value for this processor. */
  423. LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */
  424. mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */
  425. add r13,r13,r4 /* for this processor. */
  426. mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
  427. /* Create a temp kernel stack for use before relocation is on. */
  428. ld r1,PACAEMERGSP(r13)
  429. subi r1,r1,STACK_FRAME_OVERHEAD
  430. b __secondary_start
  431. #endif /* CONFIG_PPC_PMAC */
  432. /*
  433. * This function is called after the master CPU has released the
  434. * secondary processors. The execution environment is relocation off.
  435. * The paca for this processor has the following fields initialized at
  436. * this point:
  437. * 1. Processor number
  438. * 2. Segment table pointer (virtual address)
  439. * On entry the following are set:
  440. * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries
  441. * r24 = cpu# (in Linux terms)
  442. * r13 = paca virtual address
  443. * SPRG3 = paca virtual address
  444. */
  445. .globl __secondary_start
  446. __secondary_start:
  447. /* Set thread priority to MEDIUM */
  448. HMT_MEDIUM
  449. /* Do early setup for that CPU (stab, slb, hash table pointer) */
  450. bl .early_setup_secondary
  451. /* Initialize the kernel stack. Just a repeat for iSeries. */
  452. LOAD_REG_ADDR(r3, current_set)
  453. sldi r28,r24,3 /* get current_set[cpu#] */
  454. ldx r1,r3,r28
  455. addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
  456. std r1,PACAKSAVE(r13)
  457. /* Clear backchain so we get nice backtraces */
  458. li r7,0
  459. mtlr r7
  460. /* enable MMU and jump to start_secondary */
  461. LOAD_REG_ADDR(r3, .start_secondary_prolog)
  462. LOAD_REG_IMMEDIATE(r4, MSR_KERNEL)
  463. #ifdef CONFIG_PPC_ISERIES
  464. BEGIN_FW_FTR_SECTION
  465. ori r4,r4,MSR_EE
  466. li r8,1
  467. stb r8,PACAHARDIRQEN(r13)
  468. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  469. #endif
  470. BEGIN_FW_FTR_SECTION
  471. stb r7,PACAHARDIRQEN(r13)
  472. END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
  473. stb r7,PACASOFTIRQEN(r13)
  474. mtspr SPRN_SRR0,r3
  475. mtspr SPRN_SRR1,r4
  476. rfid
  477. b . /* prevent speculative execution */
  478. /*
  479. * Running with relocation on at this point. All we want to do is
  480. * zero the stack back-chain pointer and get the TOC virtual address
  481. * before going into C code.
  482. */
  483. _GLOBAL(start_secondary_prolog)
  484. ld r2,PACATOC(r13)
  485. li r3,0
  486. std r3,0(r1) /* Zero the stack frame pointer */
  487. bl .start_secondary
  488. b .
  489. #endif
  490. /*
  491. * This subroutine clobbers r11 and r12
  492. */
  493. _GLOBAL(enable_64b_mode)
  494. mfmsr r11 /* grab the current MSR */
  495. li r12,(MSR_SF | MSR_ISF)@highest
  496. sldi r12,r12,48
  497. or r11,r11,r12
  498. mtmsrd r11
  499. isync
  500. blr
  501. /*
  502. * This puts the TOC pointer into r2, offset by 0x8000 (as expected
  503. * by the toolchain). It computes the correct value for wherever we
  504. * are running at the moment, using position-independent code.
  505. */
  506. _GLOBAL(relative_toc)
  507. mflr r0
  508. bcl 20,31,$+4
  509. 0: mflr r9
  510. ld r2,(p_toc - 0b)(r9)
  511. add r2,r2,r9
  512. mtlr r0
  513. blr
  514. p_toc: .llong __toc_start + 0x8000 - 0b
  515. /*
  516. * This is where the main kernel code starts.
  517. */
  518. _INIT_STATIC(start_here_multiplatform)
  519. /* set up the TOC (real address) */
  520. bl .relative_toc
  521. /* Clear out the BSS. It may have been done in prom_init,
  522. * already but that's irrelevant since prom_init will soon
  523. * be detached from the kernel completely. Besides, we need
  524. * to clear it now for kexec-style entry.
  525. */
  526. LOAD_REG_ADDR(r11,__bss_stop)
  527. LOAD_REG_ADDR(r8,__bss_start)
  528. sub r11,r11,r8 /* bss size */
  529. addi r11,r11,7 /* round up to an even double word */
  530. srdi. r11,r11,3 /* shift right by 3 */
  531. beq 4f
  532. addi r8,r8,-8
  533. li r0,0
  534. mtctr r11 /* zero this many doublewords */
  535. 3: stdu r0,8(r8)
  536. bdnz 3b
  537. 4:
  538. mfmsr r6
  539. ori r6,r6,MSR_RI
  540. mtmsrd r6 /* RI on */
  541. #ifdef CONFIG_RELOCATABLE
  542. /* Save the physical address we're running at in kernstart_addr */
  543. LOAD_REG_ADDR(r4, kernstart_addr)
  544. clrldi r0,r25,2
  545. std r0,0(r4)
  546. #endif
  547. /* The following gets the stack set up with the regs */
  548. /* pointing to the real addr of the kernel stack. This is */
  549. /* all done to support the C function call below which sets */
  550. /* up the htab. This is done because we have relocated the */
  551. /* kernel but are still running in real mode. */
  552. LOAD_REG_ADDR(r3,init_thread_union)
  553. /* set up a stack pointer */
  554. addi r1,r3,THREAD_SIZE
  555. li r0,0
  556. stdu r0,-STACK_FRAME_OVERHEAD(r1)
  557. /* Do very early kernel initializations, including initial hash table,
  558. * stab and slb setup before we turn on relocation. */
  559. /* Restore parameters passed from prom_init/kexec */
  560. mr r3,r31
  561. bl .early_setup /* also sets r13 and SPRG3 */
  562. LOAD_REG_ADDR(r3, .start_here_common)
  563. ld r4,PACAKMSR(r13)
  564. mtspr SPRN_SRR0,r3
  565. mtspr SPRN_SRR1,r4
  566. rfid
  567. b . /* prevent speculative execution */
  568. /* This is where all platforms converge execution */
  569. _INIT_GLOBAL(start_here_common)
  570. /* relocation is on at this point */
  571. std r1,PACAKSAVE(r13)
  572. /* Load the TOC (virtual address) */
  573. ld r2,PACATOC(r13)
  574. bl .setup_system
  575. /* Load up the kernel context */
  576. 5:
  577. li r5,0
  578. stb r5,PACASOFTIRQEN(r13) /* Soft Disabled */
  579. #ifdef CONFIG_PPC_ISERIES
  580. BEGIN_FW_FTR_SECTION
  581. mfmsr r5
  582. ori r5,r5,MSR_EE /* Hard Enabled on iSeries*/
  583. mtmsrd r5
  584. li r5,1
  585. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  586. #endif
  587. stb r5,PACAHARDIRQEN(r13) /* Hard Disabled on others */
  588. bl .start_kernel
  589. /* Not reached */
  590. BUG_OPCODE
  591. /*
  592. * We put a few things here that have to be page-aligned.
  593. * This stuff goes at the beginning of the bss, which is page-aligned.
  594. */
  595. .section ".bss"
  596. .align PAGE_SHIFT
  597. .globl empty_zero_page
  598. empty_zero_page:
  599. .space PAGE_SIZE
  600. .globl swapper_pg_dir
  601. swapper_pg_dir:
  602. .space PGD_TABLE_SIZE