misc_64.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /*
  2. * This file contains miscellaneous low-level functions.
  3. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  4. *
  5. * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
  6. * and Paul Mackerras.
  7. * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
  8. * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. *
  15. */
  16. #include <linux/sys.h>
  17. #include <asm/unistd.h>
  18. #include <asm/errno.h>
  19. #include <asm/processor.h>
  20. #include <asm/page.h>
  21. #include <asm/cache.h>
  22. #include <asm/ppc_asm.h>
  23. #include <asm/asm-offsets.h>
  24. #include <asm/cputable.h>
  25. #include <asm/thread_info.h>
  26. #include <asm/kexec.h>
  27. #include <asm/ptrace.h>
  28. #include <asm/mmu.h>
  29. #include <asm/export.h>
  30. .text
  31. _GLOBAL(call_do_softirq)
  32. mflr r0
  33. std r0,16(r1)
  34. stdu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
  35. mr r1,r3
  36. bl __do_softirq
  37. ld r1,0(r1)
  38. ld r0,16(r1)
  39. mtlr r0
  40. blr
  41. _GLOBAL(call_do_irq)
  42. mflr r0
  43. std r0,16(r1)
  44. stdu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4)
  45. mr r1,r4
  46. bl __do_irq
  47. ld r1,0(r1)
  48. ld r0,16(r1)
  49. mtlr r0
  50. blr
  51. .section ".toc","aw"
  52. PPC64_CACHES:
  53. .tc ppc64_caches[TC],ppc64_caches
  54. .section ".text"
  55. /*
  56. * Write any modified data cache blocks out to memory
  57. * and invalidate the corresponding instruction cache blocks.
  58. *
  59. * flush_icache_range(unsigned long start, unsigned long stop)
  60. *
  61. * flush all bytes from start through stop-1 inclusive
  62. */
  63. _GLOBAL_TOC(flush_icache_range)
  64. BEGIN_FTR_SECTION
  65. PURGE_PREFETCHED_INS
  66. blr
  67. END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
  68. /*
  69. * Flush the data cache to memory
  70. *
  71. * Different systems have different cache line sizes
  72. * and in some cases i-cache and d-cache line sizes differ from
  73. * each other.
  74. */
  75. ld r10,PPC64_CACHES@toc(r2)
  76. lwz r7,DCACHEL1LINESIZE(r10)/* Get cache line size */
  77. addi r5,r7,-1
  78. andc r6,r3,r5 /* round low to line bdy */
  79. subf r8,r6,r4 /* compute length */
  80. add r8,r8,r5 /* ensure we get enough */
  81. lwz r9,DCACHEL1LOGLINESIZE(r10) /* Get log-2 of cache line size */
  82. srw. r8,r8,r9 /* compute line count */
  83. beqlr /* nothing to do? */
  84. mtctr r8
  85. 1: dcbst 0,r6
  86. add r6,r6,r7
  87. bdnz 1b
  88. sync
  89. /* Now invalidate the instruction cache */
  90. lwz r7,ICACHEL1LINESIZE(r10) /* Get Icache line size */
  91. addi r5,r7,-1
  92. andc r6,r3,r5 /* round low to line bdy */
  93. subf r8,r6,r4 /* compute length */
  94. add r8,r8,r5
  95. lwz r9,ICACHEL1LOGLINESIZE(r10) /* Get log-2 of Icache line size */
  96. srw. r8,r8,r9 /* compute line count */
  97. beqlr /* nothing to do? */
  98. mtctr r8
  99. 2: icbi 0,r6
  100. add r6,r6,r7
  101. bdnz 2b
  102. isync
  103. blr
  104. _ASM_NOKPROBE_SYMBOL(flush_icache_range)
  105. EXPORT_SYMBOL(flush_icache_range)
  106. /*
  107. * Like above, but only do the D-cache.
  108. *
  109. * flush_dcache_range(unsigned long start, unsigned long stop)
  110. *
  111. * flush all bytes from start to stop-1 inclusive
  112. */
  113. _GLOBAL_TOC(flush_dcache_range)
  114. /*
  115. * Flush the data cache to memory
  116. *
  117. * Different systems have different cache line sizes
  118. */
  119. ld r10,PPC64_CACHES@toc(r2)
  120. lwz r7,DCACHEL1LINESIZE(r10) /* Get dcache line size */
  121. addi r5,r7,-1
  122. andc r6,r3,r5 /* round low to line bdy */
  123. subf r8,r6,r4 /* compute length */
  124. add r8,r8,r5 /* ensure we get enough */
  125. lwz r9,DCACHEL1LOGLINESIZE(r10) /* Get log-2 of dcache line size */
  126. srw. r8,r8,r9 /* compute line count */
  127. beqlr /* nothing to do? */
  128. mtctr r8
  129. 0: dcbst 0,r6
  130. add r6,r6,r7
  131. bdnz 0b
  132. sync
  133. blr
  134. EXPORT_SYMBOL(flush_dcache_range)
  135. /*
  136. * Like above, but works on non-mapped physical addresses.
  137. * Use only for non-LPAR setups ! It also assumes real mode
  138. * is cacheable. Used for flushing out the DART before using
  139. * it as uncacheable memory
  140. *
  141. * flush_dcache_phys_range(unsigned long start, unsigned long stop)
  142. *
  143. * flush all bytes from start to stop-1 inclusive
  144. */
  145. _GLOBAL(flush_dcache_phys_range)
  146. ld r10,PPC64_CACHES@toc(r2)
  147. lwz r7,DCACHEL1LINESIZE(r10) /* Get dcache line size */
  148. addi r5,r7,-1
  149. andc r6,r3,r5 /* round low to line bdy */
  150. subf r8,r6,r4 /* compute length */
  151. add r8,r8,r5 /* ensure we get enough */
  152. lwz r9,DCACHEL1LOGLINESIZE(r10) /* Get log-2 of dcache line size */
  153. srw. r8,r8,r9 /* compute line count */
  154. beqlr /* nothing to do? */
  155. mfmsr r5 /* Disable MMU Data Relocation */
  156. ori r0,r5,MSR_DR
  157. xori r0,r0,MSR_DR
  158. sync
  159. mtmsr r0
  160. sync
  161. isync
  162. mtctr r8
  163. 0: dcbst 0,r6
  164. add r6,r6,r7
  165. bdnz 0b
  166. sync
  167. isync
  168. mtmsr r5 /* Re-enable MMU Data Relocation */
  169. sync
  170. isync
  171. blr
  172. _GLOBAL(flush_inval_dcache_range)
  173. ld r10,PPC64_CACHES@toc(r2)
  174. lwz r7,DCACHEL1LINESIZE(r10) /* Get dcache line size */
  175. addi r5,r7,-1
  176. andc r6,r3,r5 /* round low to line bdy */
  177. subf r8,r6,r4 /* compute length */
  178. add r8,r8,r5 /* ensure we get enough */
  179. lwz r9,DCACHEL1LOGLINESIZE(r10)/* Get log-2 of dcache line size */
  180. srw. r8,r8,r9 /* compute line count */
  181. beqlr /* nothing to do? */
  182. sync
  183. isync
  184. mtctr r8
  185. 0: dcbf 0,r6
  186. add r6,r6,r7
  187. bdnz 0b
  188. sync
  189. isync
  190. blr
  191. /*
  192. * Flush a particular page from the data cache to RAM.
  193. * Note: this is necessary because the instruction cache does *not*
  194. * snoop from the data cache.
  195. *
  196. * void __flush_dcache_icache(void *page)
  197. */
  198. _GLOBAL(__flush_dcache_icache)
  199. /*
  200. * Flush the data cache to memory
  201. *
  202. * Different systems have different cache line sizes
  203. */
  204. BEGIN_FTR_SECTION
  205. PURGE_PREFETCHED_INS
  206. blr
  207. END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
  208. /* Flush the dcache */
  209. ld r7,PPC64_CACHES@toc(r2)
  210. clrrdi r3,r3,PAGE_SHIFT /* Page align */
  211. lwz r4,DCACHEL1LINESPERPAGE(r7) /* Get # dcache lines per page */
  212. lwz r5,DCACHEL1LINESIZE(r7) /* Get dcache line size */
  213. mr r6,r3
  214. mtctr r4
  215. 0: dcbst 0,r6
  216. add r6,r6,r5
  217. bdnz 0b
  218. sync
  219. /* Now invalidate the icache */
  220. lwz r4,ICACHEL1LINESPERPAGE(r7) /* Get # icache lines per page */
  221. lwz r5,ICACHEL1LINESIZE(r7) /* Get icache line size */
  222. mtctr r4
  223. 1: icbi 0,r3
  224. add r3,r3,r5
  225. bdnz 1b
  226. isync
  227. blr
  228. _GLOBAL(__bswapdi2)
  229. EXPORT_SYMBOL(__bswapdi2)
  230. srdi r8,r3,32
  231. rlwinm r7,r3,8,0xffffffff
  232. rlwimi r7,r3,24,0,7
  233. rlwinm r9,r8,8,0xffffffff
  234. rlwimi r7,r3,24,16,23
  235. rlwimi r9,r8,24,0,7
  236. rlwimi r9,r8,24,16,23
  237. sldi r7,r7,32
  238. or r3,r7,r9
  239. blr
  240. #ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX
  241. _GLOBAL(rmci_on)
  242. sync
  243. isync
  244. li r3,0x100
  245. rldicl r3,r3,32,0
  246. mfspr r5,SPRN_HID4
  247. or r5,r5,r3
  248. sync
  249. mtspr SPRN_HID4,r5
  250. isync
  251. slbia
  252. isync
  253. sync
  254. blr
  255. _GLOBAL(rmci_off)
  256. sync
  257. isync
  258. li r3,0x100
  259. rldicl r3,r3,32,0
  260. mfspr r5,SPRN_HID4
  261. andc r5,r5,r3
  262. sync
  263. mtspr SPRN_HID4,r5
  264. isync
  265. slbia
  266. isync
  267. sync
  268. blr
  269. #endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
  270. #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
  271. /*
  272. * Do an IO access in real mode
  273. */
  274. _GLOBAL(real_readb)
  275. mfmsr r7
  276. ori r0,r7,MSR_DR
  277. xori r0,r0,MSR_DR
  278. sync
  279. mtmsrd r0
  280. sync
  281. isync
  282. mfspr r6,SPRN_HID4
  283. rldicl r5,r6,32,0
  284. ori r5,r5,0x100
  285. rldicl r5,r5,32,0
  286. sync
  287. mtspr SPRN_HID4,r5
  288. isync
  289. slbia
  290. isync
  291. lbz r3,0(r3)
  292. sync
  293. mtspr SPRN_HID4,r6
  294. isync
  295. slbia
  296. isync
  297. mtmsrd r7
  298. sync
  299. isync
  300. blr
  301. /*
  302. * Do an IO access in real mode
  303. */
  304. _GLOBAL(real_writeb)
  305. mfmsr r7
  306. ori r0,r7,MSR_DR
  307. xori r0,r0,MSR_DR
  308. sync
  309. mtmsrd r0
  310. sync
  311. isync
  312. mfspr r6,SPRN_HID4
  313. rldicl r5,r6,32,0
  314. ori r5,r5,0x100
  315. rldicl r5,r5,32,0
  316. sync
  317. mtspr SPRN_HID4,r5
  318. isync
  319. slbia
  320. isync
  321. stb r3,0(r4)
  322. sync
  323. mtspr SPRN_HID4,r6
  324. isync
  325. slbia
  326. isync
  327. mtmsrd r7
  328. sync
  329. isync
  330. blr
  331. #endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */
  332. #ifdef CONFIG_PPC_PASEMI
  333. _GLOBAL(real_205_readb)
  334. mfmsr r7
  335. ori r0,r7,MSR_DR
  336. xori r0,r0,MSR_DR
  337. sync
  338. mtmsrd r0
  339. sync
  340. isync
  341. LBZCIX(R3,R0,R3)
  342. isync
  343. mtmsrd r7
  344. sync
  345. isync
  346. blr
  347. _GLOBAL(real_205_writeb)
  348. mfmsr r7
  349. ori r0,r7,MSR_DR
  350. xori r0,r0,MSR_DR
  351. sync
  352. mtmsrd r0
  353. sync
  354. isync
  355. STBCIX(R3,R0,R4)
  356. isync
  357. mtmsrd r7
  358. sync
  359. isync
  360. blr
  361. #endif /* CONFIG_PPC_PASEMI */
  362. #if defined(CONFIG_CPU_FREQ_PMAC64) || defined(CONFIG_CPU_FREQ_MAPLE)
  363. /*
  364. * SCOM access functions for 970 (FX only for now)
  365. *
  366. * unsigned long scom970_read(unsigned int address);
  367. * void scom970_write(unsigned int address, unsigned long value);
  368. *
  369. * The address passed in is the 24 bits register address. This code
  370. * is 970 specific and will not check the status bits, so you should
  371. * know what you are doing.
  372. */
  373. _GLOBAL(scom970_read)
  374. /* interrupts off */
  375. mfmsr r4
  376. ori r0,r4,MSR_EE
  377. xori r0,r0,MSR_EE
  378. mtmsrd r0,1
  379. /* rotate 24 bits SCOM address 8 bits left and mask out it's low 8 bits
  380. * (including parity). On current CPUs they must be 0'd,
  381. * and finally or in RW bit
  382. */
  383. rlwinm r3,r3,8,0,15
  384. ori r3,r3,0x8000
  385. /* do the actual scom read */
  386. sync
  387. mtspr SPRN_SCOMC,r3
  388. isync
  389. mfspr r3,SPRN_SCOMD
  390. isync
  391. mfspr r0,SPRN_SCOMC
  392. isync
  393. /* XXX: fixup result on some buggy 970's (ouch ! we lost a bit, bah
  394. * that's the best we can do). Not implemented yet as we don't use
  395. * the scom on any of the bogus CPUs yet, but may have to be done
  396. * ultimately
  397. */
  398. /* restore interrupts */
  399. mtmsrd r4,1
  400. blr
  401. _GLOBAL(scom970_write)
  402. /* interrupts off */
  403. mfmsr r5
  404. ori r0,r5,MSR_EE
  405. xori r0,r0,MSR_EE
  406. mtmsrd r0,1
  407. /* rotate 24 bits SCOM address 8 bits left and mask out it's low 8 bits
  408. * (including parity). On current CPUs they must be 0'd.
  409. */
  410. rlwinm r3,r3,8,0,15
  411. sync
  412. mtspr SPRN_SCOMD,r4 /* write data */
  413. isync
  414. mtspr SPRN_SCOMC,r3 /* write command */
  415. isync
  416. mfspr 3,SPRN_SCOMC
  417. isync
  418. /* restore interrupts */
  419. mtmsrd r5,1
  420. blr
  421. #endif /* CONFIG_CPU_FREQ_PMAC64 || CONFIG_CPU_FREQ_MAPLE */
  422. /* kexec_wait(phys_cpu)
  423. *
  424. * wait for the flag to change, indicating this kernel is going away but
  425. * the slave code for the next one is at addresses 0 to 100.
  426. *
  427. * This is used by all slaves, even those that did not find a matching
  428. * paca in the secondary startup code.
  429. *
  430. * Physical (hardware) cpu id should be in r3.
  431. */
  432. _GLOBAL(kexec_wait)
  433. bl 1f
  434. 1: mflr r5
  435. addi r5,r5,kexec_flag-1b
  436. 99: HMT_LOW
  437. #ifdef CONFIG_KEXEC /* use no memory without kexec */
  438. lwz r4,0(r5)
  439. cmpwi 0,r4,0
  440. beq 99b
  441. #ifdef CONFIG_PPC_BOOK3S_64
  442. li r10,0x60
  443. mfmsr r11
  444. clrrdi r11,r11,1 /* Clear MSR_LE */
  445. mtsrr0 r10
  446. mtsrr1 r11
  447. rfid
  448. #else
  449. /* Create TLB entry in book3e_secondary_core_init */
  450. li r4,0
  451. ba 0x60
  452. #endif
  453. #endif
  454. /* this can be in text because we won't change it until we are
  455. * running in real anyways
  456. */
  457. kexec_flag:
  458. .long 0
  459. #ifdef CONFIG_KEXEC
  460. #ifdef CONFIG_PPC_BOOK3E
  461. /*
  462. * BOOK3E has no real MMU mode, so we have to setup the initial TLB
  463. * for a core to identity map v:0 to p:0. This current implementation
  464. * assumes that 1G is enough for kexec.
  465. */
  466. kexec_create_tlb:
  467. /*
  468. * Invalidate all non-IPROT TLB entries to avoid any TLB conflict.
  469. * IPROT TLB entries should be >= PAGE_OFFSET and thus not conflict.
  470. */
  471. PPC_TLBILX_ALL(0,R0)
  472. sync
  473. isync
  474. mfspr r10,SPRN_TLB1CFG
  475. andi. r10,r10,TLBnCFG_N_ENTRY /* Extract # entries */
  476. subi r10,r10,1 /* Last entry: no conflict with kernel text */
  477. lis r9,MAS0_TLBSEL(1)@h
  478. rlwimi r9,r10,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r9) */
  479. /* Set up a temp identity mapping v:0 to p:0 and return to it. */
  480. #if defined(CONFIG_SMP) || defined(CONFIG_PPC_E500MC)
  481. #define M_IF_NEEDED MAS2_M
  482. #else
  483. #define M_IF_NEEDED 0
  484. #endif
  485. mtspr SPRN_MAS0,r9
  486. lis r9,(MAS1_VALID|MAS1_IPROT)@h
  487. ori r9,r9,(MAS1_TSIZE(BOOK3E_PAGESZ_1GB))@l
  488. mtspr SPRN_MAS1,r9
  489. LOAD_REG_IMMEDIATE(r9, 0x0 | M_IF_NEEDED)
  490. mtspr SPRN_MAS2,r9
  491. LOAD_REG_IMMEDIATE(r9, 0x0 | MAS3_SR | MAS3_SW | MAS3_SX)
  492. mtspr SPRN_MAS3,r9
  493. li r9,0
  494. mtspr SPRN_MAS7,r9
  495. tlbwe
  496. isync
  497. blr
  498. #endif
  499. /* kexec_smp_wait(void)
  500. *
  501. * call with interrupts off
  502. * note: this is a terminal routine, it does not save lr
  503. *
  504. * get phys id from paca
  505. * switch to real mode
  506. * mark the paca as no longer used
  507. * join other cpus in kexec_wait(phys_id)
  508. */
  509. _GLOBAL(kexec_smp_wait)
  510. lhz r3,PACAHWCPUID(r13)
  511. bl real_mode
  512. li r4,KEXEC_STATE_REAL_MODE
  513. stb r4,PACAKEXECSTATE(r13)
  514. SYNC
  515. b kexec_wait
  516. /*
  517. * switch to real mode (turn mmu off)
  518. * we use the early kernel trick that the hardware ignores bits
  519. * 0 and 1 (big endian) of the effective address in real mode
  520. *
  521. * don't overwrite r3 here, it is live for kexec_wait above.
  522. */
  523. real_mode: /* assume normal blr return */
  524. #ifdef CONFIG_PPC_BOOK3E
  525. /* Create an identity mapping. */
  526. b kexec_create_tlb
  527. #else
  528. 1: li r9,MSR_RI
  529. li r10,MSR_DR|MSR_IR
  530. mflr r11 /* return address to SRR0 */
  531. mfmsr r12
  532. andc r9,r12,r9
  533. andc r10,r12,r10
  534. mtmsrd r9,1
  535. mtspr SPRN_SRR1,r10
  536. mtspr SPRN_SRR0,r11
  537. rfid
  538. #endif
  539. /*
  540. * kexec_sequence(newstack, start, image, control, clear_all(),
  541. copy_with_mmu_off)
  542. *
  543. * does the grungy work with stack switching and real mode switches
  544. * also does simple calls to other code
  545. */
  546. _GLOBAL(kexec_sequence)
  547. mflr r0
  548. std r0,16(r1)
  549. /* switch stacks to newstack -- &kexec_stack.stack */
  550. stdu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
  551. mr r1,r3
  552. li r0,0
  553. std r0,16(r1)
  554. /* save regs for local vars on new stack.
  555. * yes, we won't go back, but ...
  556. */
  557. std r31,-8(r1)
  558. std r30,-16(r1)
  559. std r29,-24(r1)
  560. std r28,-32(r1)
  561. std r27,-40(r1)
  562. std r26,-48(r1)
  563. std r25,-56(r1)
  564. stdu r1,-STACK_FRAME_OVERHEAD-64(r1)
  565. /* save args into preserved regs */
  566. mr r31,r3 /* newstack (both) */
  567. mr r30,r4 /* start (real) */
  568. mr r29,r5 /* image (virt) */
  569. mr r28,r6 /* control, unused */
  570. mr r27,r7 /* clear_all() fn desc */
  571. mr r26,r8 /* copy_with_mmu_off */
  572. lhz r25,PACAHWCPUID(r13) /* get our phys cpu from paca */
  573. /* disable interrupts, we are overwriting kernel data next */
  574. #ifdef CONFIG_PPC_BOOK3E
  575. wrteei 0
  576. #else
  577. mfmsr r3
  578. rlwinm r3,r3,0,17,15
  579. mtmsrd r3,1
  580. #endif
  581. /* We need to turn the MMU off unless we are in hash mode
  582. * under a hypervisor
  583. */
  584. cmpdi r26,0
  585. beq 1f
  586. bl real_mode
  587. 1:
  588. /* copy dest pages, flush whole dest image */
  589. mr r3,r29
  590. bl kexec_copy_flush /* (image) */
  591. /* turn off mmu now if not done earlier */
  592. cmpdi r26,0
  593. bne 1f
  594. bl real_mode
  595. /* copy 0x100 bytes starting at start to 0 */
  596. 1: li r3,0
  597. mr r4,r30 /* start, aka phys mem offset */
  598. li r5,0x100
  599. li r6,0
  600. bl copy_and_flush /* (dest, src, copy limit, start offset) */
  601. 1: /* assume normal blr return */
  602. /* release other cpus to the new kernel secondary start at 0x60 */
  603. mflr r5
  604. li r6,1
  605. stw r6,kexec_flag-1b(5)
  606. cmpdi r27,0
  607. beq 1f
  608. /* clear out hardware hash page table and tlb */
  609. #ifdef PPC64_ELF_ABI_v1
  610. ld r12,0(r27) /* deref function descriptor */
  611. #else
  612. mr r12,r27
  613. #endif
  614. mtctr r12
  615. bctrl /* mmu_hash_ops.hpte_clear_all(void); */
  616. /*
  617. * kexec image calling is:
  618. * the first 0x100 bytes of the entry point are copied to 0
  619. *
  620. * all slaves branch to slave = 0x60 (absolute)
  621. * slave(phys_cpu_id);
  622. *
  623. * master goes to start = entry point
  624. * start(phys_cpu_id, start, 0);
  625. *
  626. *
  627. * a wrapper is needed to call existing kernels, here is an approximate
  628. * description of one method:
  629. *
  630. * v2: (2.6.10)
  631. * start will be near the boot_block (maybe 0x100 bytes before it?)
  632. * it will have a 0x60, which will b to boot_block, where it will wait
  633. * and 0 will store phys into struct boot-block and load r3 from there,
  634. * copy kernel 0-0x100 and tell slaves to back down to 0x60 again
  635. *
  636. * v1: (2.6.9)
  637. * boot block will have all cpus scanning device tree to see if they
  638. * are the boot cpu ?????
  639. * other device tree differences (prop sizes, va vs pa, etc)...
  640. */
  641. 1: mr r3,r25 # my phys cpu
  642. mr r4,r30 # start, aka phys mem offset
  643. mtlr 4
  644. li r5,0
  645. blr /* image->start(physid, image->start, 0); */
  646. #endif /* CONFIG_KEXEC */