head_64.S 18 KB

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