misc_64.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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. .text
  27. #ifdef CONFIG_IRQSTACKS
  28. _GLOBAL(call_do_softirq)
  29. mflr r0
  30. std r0,16(r1)
  31. stdu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
  32. mr r1,r3
  33. bl .__do_softirq
  34. ld r1,0(r1)
  35. ld r0,16(r1)
  36. mtlr r0
  37. blr
  38. _GLOBAL(call_handle_irq)
  39. ld r8,0(r6)
  40. mflr r0
  41. std r0,16(r1)
  42. mtctr r8
  43. stdu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r5)
  44. mr r1,r5
  45. bctrl
  46. ld r1,0(r1)
  47. ld r0,16(r1)
  48. mtlr r0
  49. blr
  50. #endif /* CONFIG_IRQSTACKS */
  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. _KPROBE(__flush_icache_range)
  64. /*
  65. * Flush the data cache to memory
  66. *
  67. * Different systems have different cache line sizes
  68. * and in some cases i-cache and d-cache line sizes differ from
  69. * each other.
  70. */
  71. ld r10,PPC64_CACHES@toc(r2)
  72. lwz r7,DCACHEL1LINESIZE(r10)/* Get cache line size */
  73. addi r5,r7,-1
  74. andc r6,r3,r5 /* round low to line bdy */
  75. subf r8,r6,r4 /* compute length */
  76. add r8,r8,r5 /* ensure we get enough */
  77. lwz r9,DCACHEL1LOGLINESIZE(r10) /* Get log-2 of cache line size */
  78. srw. r8,r8,r9 /* compute line count */
  79. beqlr /* nothing to do? */
  80. mtctr r8
  81. 1: dcbst 0,r6
  82. add r6,r6,r7
  83. bdnz 1b
  84. sync
  85. /* Now invalidate the instruction cache */
  86. lwz r7,ICACHEL1LINESIZE(r10) /* Get Icache line size */
  87. addi r5,r7,-1
  88. andc r6,r3,r5 /* round low to line bdy */
  89. subf r8,r6,r4 /* compute length */
  90. add r8,r8,r5
  91. lwz r9,ICACHEL1LOGLINESIZE(r10) /* Get log-2 of Icache line size */
  92. srw. r8,r8,r9 /* compute line count */
  93. beqlr /* nothing to do? */
  94. mtctr r8
  95. 2: icbi 0,r6
  96. add r6,r6,r7
  97. bdnz 2b
  98. isync
  99. blr
  100. .previous .text
  101. /*
  102. * Like above, but only do the D-cache.
  103. *
  104. * flush_dcache_range(unsigned long start, unsigned long stop)
  105. *
  106. * flush all bytes from start to stop-1 inclusive
  107. */
  108. _GLOBAL(flush_dcache_range)
  109. /*
  110. * Flush the data cache to memory
  111. *
  112. * Different systems have different cache line sizes
  113. */
  114. ld r10,PPC64_CACHES@toc(r2)
  115. lwz r7,DCACHEL1LINESIZE(r10) /* Get dcache line size */
  116. addi r5,r7,-1
  117. andc r6,r3,r5 /* round low to line bdy */
  118. subf r8,r6,r4 /* compute length */
  119. add r8,r8,r5 /* ensure we get enough */
  120. lwz r9,DCACHEL1LOGLINESIZE(r10) /* Get log-2 of dcache line size */
  121. srw. r8,r8,r9 /* compute line count */
  122. beqlr /* nothing to do? */
  123. mtctr r8
  124. 0: dcbst 0,r6
  125. add r6,r6,r7
  126. bdnz 0b
  127. sync
  128. blr
  129. /*
  130. * Like above, but works on non-mapped physical addresses.
  131. * Use only for non-LPAR setups ! It also assumes real mode
  132. * is cacheable. Used for flushing out the DART before using
  133. * it as uncacheable memory
  134. *
  135. * flush_dcache_phys_range(unsigned long start, unsigned long stop)
  136. *
  137. * flush all bytes from start to stop-1 inclusive
  138. */
  139. _GLOBAL(flush_dcache_phys_range)
  140. ld r10,PPC64_CACHES@toc(r2)
  141. lwz r7,DCACHEL1LINESIZE(r10) /* Get dcache line size */
  142. addi r5,r7,-1
  143. andc r6,r3,r5 /* round low to line bdy */
  144. subf r8,r6,r4 /* compute length */
  145. add r8,r8,r5 /* ensure we get enough */
  146. lwz r9,DCACHEL1LOGLINESIZE(r10) /* Get log-2 of dcache line size */
  147. srw. r8,r8,r9 /* compute line count */
  148. beqlr /* nothing to do? */
  149. mfmsr r5 /* Disable MMU Data Relocation */
  150. ori r0,r5,MSR_DR
  151. xori r0,r0,MSR_DR
  152. sync
  153. mtmsr r0
  154. sync
  155. isync
  156. mtctr r8
  157. 0: dcbst 0,r6
  158. add r6,r6,r7
  159. bdnz 0b
  160. sync
  161. isync
  162. mtmsr r5 /* Re-enable MMU Data Relocation */
  163. sync
  164. isync
  165. blr
  166. _GLOBAL(flush_inval_dcache_range)
  167. ld r10,PPC64_CACHES@toc(r2)
  168. lwz r7,DCACHEL1LINESIZE(r10) /* Get dcache line size */
  169. addi r5,r7,-1
  170. andc r6,r3,r5 /* round low to line bdy */
  171. subf r8,r6,r4 /* compute length */
  172. add r8,r8,r5 /* ensure we get enough */
  173. lwz r9,DCACHEL1LOGLINESIZE(r10)/* Get log-2 of dcache line size */
  174. srw. r8,r8,r9 /* compute line count */
  175. beqlr /* nothing to do? */
  176. sync
  177. isync
  178. mtctr r8
  179. 0: dcbf 0,r6
  180. add r6,r6,r7
  181. bdnz 0b
  182. sync
  183. isync
  184. blr
  185. /*
  186. * Flush a particular page from the data cache to RAM.
  187. * Note: this is necessary because the instruction cache does *not*
  188. * snoop from the data cache.
  189. *
  190. * void __flush_dcache_icache(void *page)
  191. */
  192. _GLOBAL(__flush_dcache_icache)
  193. /*
  194. * Flush the data cache to memory
  195. *
  196. * Different systems have different cache line sizes
  197. */
  198. /* Flush the dcache */
  199. ld r7,PPC64_CACHES@toc(r2)
  200. clrrdi r3,r3,PAGE_SHIFT /* Page align */
  201. lwz r4,DCACHEL1LINESPERPAGE(r7) /* Get # dcache lines per page */
  202. lwz r5,DCACHEL1LINESIZE(r7) /* Get dcache line size */
  203. mr r6,r3
  204. mtctr r4
  205. 0: dcbst 0,r6
  206. add r6,r6,r5
  207. bdnz 0b
  208. sync
  209. /* Now invalidate the icache */
  210. lwz r4,ICACHEL1LINESPERPAGE(r7) /* Get # icache lines per page */
  211. lwz r5,ICACHEL1LINESIZE(r7) /* Get icache line size */
  212. mtctr r4
  213. 1: icbi 0,r3
  214. add r3,r3,r5
  215. bdnz 1b
  216. isync
  217. blr
  218. #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
  219. /*
  220. * Do an IO access in real mode
  221. */
  222. _GLOBAL(real_readb)
  223. mfmsr r7
  224. ori r0,r7,MSR_DR
  225. xori r0,r0,MSR_DR
  226. sync
  227. mtmsrd r0
  228. sync
  229. isync
  230. mfspr r6,SPRN_HID4
  231. rldicl r5,r6,32,0
  232. ori r5,r5,0x100
  233. rldicl r5,r5,32,0
  234. sync
  235. mtspr SPRN_HID4,r5
  236. isync
  237. slbia
  238. isync
  239. lbz r3,0(r3)
  240. sync
  241. mtspr SPRN_HID4,r6
  242. isync
  243. slbia
  244. isync
  245. mtmsrd r7
  246. sync
  247. isync
  248. blr
  249. /*
  250. * Do an IO access in real mode
  251. */
  252. _GLOBAL(real_writeb)
  253. mfmsr r7
  254. ori r0,r7,MSR_DR
  255. xori r0,r0,MSR_DR
  256. sync
  257. mtmsrd r0
  258. sync
  259. isync
  260. mfspr r6,SPRN_HID4
  261. rldicl r5,r6,32,0
  262. ori r5,r5,0x100
  263. rldicl r5,r5,32,0
  264. sync
  265. mtspr SPRN_HID4,r5
  266. isync
  267. slbia
  268. isync
  269. stb r3,0(r4)
  270. sync
  271. mtspr SPRN_HID4,r6
  272. isync
  273. slbia
  274. isync
  275. mtmsrd r7
  276. sync
  277. isync
  278. blr
  279. #endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */
  280. #ifdef CONFIG_PPC_PASEMI
  281. /* No support in all binutils for these yet, so use defines */
  282. #define LBZCIX(RT,RA,RB) .long (0x7c0006aa|(RT<<21)|(RA<<16)|(RB << 11))
  283. #define STBCIX(RS,RA,RB) .long (0x7c0007aa|(RS<<21)|(RA<<16)|(RB << 11))
  284. _GLOBAL(real_205_readb)
  285. mfmsr r7
  286. ori r0,r7,MSR_DR
  287. xori r0,r0,MSR_DR
  288. sync
  289. mtmsrd r0
  290. sync
  291. isync
  292. LBZCIX(r3,0,r3)
  293. isync
  294. mtmsrd r7
  295. sync
  296. isync
  297. blr
  298. _GLOBAL(real_205_writeb)
  299. mfmsr r7
  300. ori r0,r7,MSR_DR
  301. xori r0,r0,MSR_DR
  302. sync
  303. mtmsrd r0
  304. sync
  305. isync
  306. STBCIX(r3,0,r4)
  307. isync
  308. mtmsrd r7
  309. sync
  310. isync
  311. blr
  312. #endif /* CONFIG_PPC_PASEMI */
  313. #ifdef CONFIG_CPU_FREQ_PMAC64
  314. /*
  315. * SCOM access functions for 970 (FX only for now)
  316. *
  317. * unsigned long scom970_read(unsigned int address);
  318. * void scom970_write(unsigned int address, unsigned long value);
  319. *
  320. * The address passed in is the 24 bits register address. This code
  321. * is 970 specific and will not check the status bits, so you should
  322. * know what you are doing.
  323. */
  324. _GLOBAL(scom970_read)
  325. /* interrupts off */
  326. mfmsr r4
  327. ori r0,r4,MSR_EE
  328. xori r0,r0,MSR_EE
  329. mtmsrd r0,1
  330. /* rotate 24 bits SCOM address 8 bits left and mask out it's low 8 bits
  331. * (including parity). On current CPUs they must be 0'd,
  332. * and finally or in RW bit
  333. */
  334. rlwinm r3,r3,8,0,15
  335. ori r3,r3,0x8000
  336. /* do the actual scom read */
  337. sync
  338. mtspr SPRN_SCOMC,r3
  339. isync
  340. mfspr r3,SPRN_SCOMD
  341. isync
  342. mfspr r0,SPRN_SCOMC
  343. isync
  344. /* XXX: fixup result on some buggy 970's (ouch ! we lost a bit, bah
  345. * that's the best we can do). Not implemented yet as we don't use
  346. * the scom on any of the bogus CPUs yet, but may have to be done
  347. * ultimately
  348. */
  349. /* restore interrupts */
  350. mtmsrd r4,1
  351. blr
  352. _GLOBAL(scom970_write)
  353. /* interrupts off */
  354. mfmsr r5
  355. ori r0,r5,MSR_EE
  356. xori r0,r0,MSR_EE
  357. mtmsrd r0,1
  358. /* rotate 24 bits SCOM address 8 bits left and mask out it's low 8 bits
  359. * (including parity). On current CPUs they must be 0'd.
  360. */
  361. rlwinm r3,r3,8,0,15
  362. sync
  363. mtspr SPRN_SCOMD,r4 /* write data */
  364. isync
  365. mtspr SPRN_SCOMC,r3 /* write command */
  366. isync
  367. mfspr 3,SPRN_SCOMC
  368. isync
  369. /* restore interrupts */
  370. mtmsrd r5,1
  371. blr
  372. #endif /* CONFIG_CPU_FREQ_PMAC64 */
  373. /*
  374. * Create a kernel thread
  375. * kernel_thread(fn, arg, flags)
  376. */
  377. _GLOBAL(kernel_thread)
  378. std r29,-24(r1)
  379. std r30,-16(r1)
  380. stdu r1,-STACK_FRAME_OVERHEAD(r1)
  381. mr r29,r3
  382. mr r30,r4
  383. ori r3,r5,CLONE_VM /* flags */
  384. oris r3,r3,(CLONE_UNTRACED>>16)
  385. li r4,0 /* new sp (unused) */
  386. li r0,__NR_clone
  387. sc
  388. bns+ 1f /* did system call indicate error? */
  389. neg r3,r3 /* if so, make return code negative */
  390. 1: cmpdi 0,r3,0 /* parent or child? */
  391. bne 2f /* return if parent */
  392. li r0,0
  393. stdu r0,-STACK_FRAME_OVERHEAD(r1)
  394. ld r2,8(r29)
  395. ld r29,0(r29)
  396. mtlr r29 /* fn addr in lr */
  397. mr r3,r30 /* load arg and call fn */
  398. blrl
  399. li r0,__NR_exit /* exit after child exits */
  400. li r3,0
  401. sc
  402. 2: addi r1,r1,STACK_FRAME_OVERHEAD
  403. ld r29,-24(r1)
  404. ld r30,-16(r1)
  405. blr
  406. /*
  407. * disable_kernel_fp()
  408. * Disable the FPU.
  409. */
  410. _GLOBAL(disable_kernel_fp)
  411. mfmsr r3
  412. rldicl r0,r3,(63-MSR_FP_LG),1
  413. rldicl r3,r0,(MSR_FP_LG+1),0
  414. mtmsrd r3 /* disable use of fpu now */
  415. isync
  416. blr
  417. #ifdef CONFIG_ALTIVEC
  418. #if 0 /* this has no callers for now */
  419. /*
  420. * disable_kernel_altivec()
  421. * Disable the VMX.
  422. */
  423. _GLOBAL(disable_kernel_altivec)
  424. mfmsr r3
  425. rldicl r0,r3,(63-MSR_VEC_LG),1
  426. rldicl r3,r0,(MSR_VEC_LG+1),0
  427. mtmsrd r3 /* disable use of VMX now */
  428. isync
  429. blr
  430. #endif /* 0 */
  431. /*
  432. * giveup_altivec(tsk)
  433. * Disable VMX for the task given as the argument,
  434. * and save the vector registers in its thread_struct.
  435. * Enables the VMX for use in the kernel on return.
  436. */
  437. _GLOBAL(giveup_altivec)
  438. mfmsr r5
  439. oris r5,r5,MSR_VEC@h
  440. mtmsrd r5 /* enable use of VMX now */
  441. isync
  442. cmpdi 0,r3,0
  443. beqlr- /* if no previous owner, done */
  444. addi r3,r3,THREAD /* want THREAD of task */
  445. ld r5,PT_REGS(r3)
  446. cmpdi 0,r5,0
  447. SAVE_32VRS(0,r4,r3)
  448. mfvscr vr0
  449. li r4,THREAD_VSCR
  450. stvx vr0,r4,r3
  451. beq 1f
  452. ld r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  453. #ifdef CONFIG_VSX
  454. BEGIN_FTR_SECTION
  455. lis r3,(MSR_VEC|MSR_VSX)@h
  456. FTR_SECTION_ELSE
  457. lis r3,MSR_VEC@h
  458. ALT_FTR_SECTION_END_IFSET(CPU_FTR_VSX)
  459. #else
  460. lis r3,MSR_VEC@h
  461. #endif
  462. andc r4,r4,r3 /* disable FP for previous task */
  463. std r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  464. 1:
  465. #ifndef CONFIG_SMP
  466. li r5,0
  467. ld r4,last_task_used_altivec@got(r2)
  468. std r5,0(r4)
  469. #endif /* CONFIG_SMP */
  470. blr
  471. #endif /* CONFIG_ALTIVEC */
  472. #ifdef CONFIG_VSX
  473. /*
  474. * __giveup_vsx(tsk)
  475. * Disable VSX for the task given as the argument.
  476. * Does NOT save vsx registers.
  477. * Enables the VSX for use in the kernel on return.
  478. */
  479. _GLOBAL(__giveup_vsx)
  480. mfmsr r5
  481. oris r5,r5,MSR_VSX@h
  482. mtmsrd r5 /* enable use of VSX now */
  483. isync
  484. cmpdi 0,r3,0
  485. beqlr- /* if no previous owner, done */
  486. addi r3,r3,THREAD /* want THREAD of task */
  487. ld r5,PT_REGS(r3)
  488. cmpdi 0,r5,0
  489. beq 1f
  490. ld r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  491. lis r3,MSR_VSX@h
  492. andc r4,r4,r3 /* disable VSX for previous task */
  493. std r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  494. 1:
  495. #ifndef CONFIG_SMP
  496. li r5,0
  497. ld r4,last_task_used_vsx@got(r2)
  498. std r5,0(r4)
  499. #endif /* CONFIG_SMP */
  500. blr
  501. #endif /* CONFIG_VSX */
  502. /* kexec_wait(phys_cpu)
  503. *
  504. * wait for the flag to change, indicating this kernel is going away but
  505. * the slave code for the next one is at addresses 0 to 100.
  506. *
  507. * This is used by all slaves.
  508. *
  509. * Physical (hardware) cpu id should be in r3.
  510. */
  511. _GLOBAL(kexec_wait)
  512. bl 1f
  513. 1: mflr r5
  514. addi r5,r5,kexec_flag-1b
  515. 99: HMT_LOW
  516. #ifdef CONFIG_KEXEC /* use no memory without kexec */
  517. lwz r4,0(r5)
  518. cmpwi 0,r4,0
  519. bnea 0x60
  520. #endif
  521. b 99b
  522. /* this can be in text because we won't change it until we are
  523. * running in real anyways
  524. */
  525. kexec_flag:
  526. .long 0
  527. #ifdef CONFIG_KEXEC
  528. /* kexec_smp_wait(void)
  529. *
  530. * call with interrupts off
  531. * note: this is a terminal routine, it does not save lr
  532. *
  533. * get phys id from paca
  534. * set paca id to -1 to say we got here
  535. * switch to real mode
  536. * join other cpus in kexec_wait(phys_id)
  537. */
  538. _GLOBAL(kexec_smp_wait)
  539. lhz r3,PACAHWCPUID(r13)
  540. li r4,-1
  541. sth r4,PACAHWCPUID(r13) /* let others know we left */
  542. bl real_mode
  543. b .kexec_wait
  544. /*
  545. * switch to real mode (turn mmu off)
  546. * we use the early kernel trick that the hardware ignores bits
  547. * 0 and 1 (big endian) of the effective address in real mode
  548. *
  549. * don't overwrite r3 here, it is live for kexec_wait above.
  550. */
  551. real_mode: /* assume normal blr return */
  552. 1: li r9,MSR_RI
  553. li r10,MSR_DR|MSR_IR
  554. mflr r11 /* return address to SRR0 */
  555. mfmsr r12
  556. andc r9,r12,r9
  557. andc r10,r12,r10
  558. mtmsrd r9,1
  559. mtspr SPRN_SRR1,r10
  560. mtspr SPRN_SRR0,r11
  561. rfid
  562. /*
  563. * kexec_sequence(newstack, start, image, control, clear_all())
  564. *
  565. * does the grungy work with stack switching and real mode switches
  566. * also does simple calls to other code
  567. */
  568. _GLOBAL(kexec_sequence)
  569. mflr r0
  570. std r0,16(r1)
  571. /* switch stacks to newstack -- &kexec_stack.stack */
  572. stdu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
  573. mr r1,r3
  574. li r0,0
  575. std r0,16(r1)
  576. /* save regs for local vars on new stack.
  577. * yes, we won't go back, but ...
  578. */
  579. std r31,-8(r1)
  580. std r30,-16(r1)
  581. std r29,-24(r1)
  582. std r28,-32(r1)
  583. std r27,-40(r1)
  584. std r26,-48(r1)
  585. std r25,-56(r1)
  586. stdu r1,-STACK_FRAME_OVERHEAD-64(r1)
  587. /* save args into preserved regs */
  588. mr r31,r3 /* newstack (both) */
  589. mr r30,r4 /* start (real) */
  590. mr r29,r5 /* image (virt) */
  591. mr r28,r6 /* control, unused */
  592. mr r27,r7 /* clear_all() fn desc */
  593. mr r26,r8 /* spare */
  594. lhz r25,PACAHWCPUID(r13) /* get our phys cpu from paca */
  595. /* disable interrupts, we are overwriting kernel data next */
  596. mfmsr r3
  597. rlwinm r3,r3,0,17,15
  598. mtmsrd r3,1
  599. /* copy dest pages, flush whole dest image */
  600. mr r3,r29
  601. bl .kexec_copy_flush /* (image) */
  602. /* turn off mmu */
  603. bl real_mode
  604. /* copy 0x100 bytes starting at start to 0 */
  605. li r3,0
  606. mr r4,r30 /* start, aka phys mem offset */
  607. li r5,0x100
  608. li r6,0
  609. bl .copy_and_flush /* (dest, src, copy limit, start offset) */
  610. 1: /* assume normal blr return */
  611. /* release other cpus to the new kernel secondary start at 0x60 */
  612. mflr r5
  613. li r6,1
  614. stw r6,kexec_flag-1b(5)
  615. /* clear out hardware hash page table and tlb */
  616. ld r5,0(r27) /* deref function descriptor */
  617. mtctr r5
  618. bctrl /* ppc_md.hpte_clear_all(void); */
  619. /*
  620. * kexec image calling is:
  621. * the first 0x100 bytes of the entry point are copied to 0
  622. *
  623. * all slaves branch to slave = 0x60 (absolute)
  624. * slave(phys_cpu_id);
  625. *
  626. * master goes to start = entry point
  627. * start(phys_cpu_id, start, 0);
  628. *
  629. *
  630. * a wrapper is needed to call existing kernels, here is an approximate
  631. * description of one method:
  632. *
  633. * v2: (2.6.10)
  634. * start will be near the boot_block (maybe 0x100 bytes before it?)
  635. * it will have a 0x60, which will b to boot_block, where it will wait
  636. * and 0 will store phys into struct boot-block and load r3 from there,
  637. * copy kernel 0-0x100 and tell slaves to back down to 0x60 again
  638. *
  639. * v1: (2.6.9)
  640. * boot block will have all cpus scanning device tree to see if they
  641. * are the boot cpu ?????
  642. * other device tree differences (prop sizes, va vs pa, etc)...
  643. */
  644. mr r3,r25 # my phys cpu
  645. mr r4,r30 # start, aka phys mem offset
  646. mtlr 4
  647. li r5,0
  648. blr /* image->start(physid, image->start, 0); */
  649. #endif /* CONFIG_KEXEC */