start.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  2. * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
  3. * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
  4. * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. /* U-Boot - Startup Code for PowerPC based Embedded Boards
  25. *
  26. *
  27. * The processor starts at 0x00000100 and the code is executed
  28. * from flash. The code is organized to be at an other address
  29. * in memory, but as long we don't jump around before relocating,
  30. * board_init lies at a quite high address and when the cpu has
  31. * jumped there, everything is ok.
  32. * This works because the cpu gives the FLASH (CS0) the whole
  33. * address space at startup, and board_init lies as a echo of
  34. * the flash somewhere up there in the memory map.
  35. *
  36. * board_init will change CS0 to be positioned at the correct
  37. * address and (s)dram will be positioned at address 0
  38. */
  39. #include <config.h>
  40. #include <mpc8xx.h>
  41. #include <timestamp.h>
  42. #include <version.h>
  43. #define CONFIG_8xx 1 /* needed for Linux kernel header files */
  44. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  45. #include <ppc_asm.tmpl>
  46. #include <ppc_defs.h>
  47. #include <asm/cache.h>
  48. #include <asm/mmu.h>
  49. #include <asm/u-boot.h>
  50. #ifndef CONFIG_IDENT_STRING
  51. #define CONFIG_IDENT_STRING ""
  52. #endif
  53. /* We don't want the MMU yet.
  54. */
  55. #undef MSR_KERNEL
  56. #define MSR_KERNEL ( MSR_ME | MSR_RI ) /* Machine Check and Recoverable Interr. */
  57. /*
  58. * Set up GOT: Global Offset Table
  59. *
  60. * Use r12 to access the GOT
  61. */
  62. START_GOT
  63. GOT_ENTRY(_GOT2_TABLE_)
  64. GOT_ENTRY(_FIXUP_TABLE_)
  65. GOT_ENTRY(_start)
  66. GOT_ENTRY(_start_of_vectors)
  67. GOT_ENTRY(_end_of_vectors)
  68. GOT_ENTRY(transfer_to_handler)
  69. GOT_ENTRY(__init_end)
  70. GOT_ENTRY(_end)
  71. GOT_ENTRY(__bss_start)
  72. END_GOT
  73. /*
  74. * r3 - 1st arg to board_init(): IMMP pointer
  75. * r4 - 2nd arg to board_init(): boot flag
  76. */
  77. .text
  78. .long 0x27051956 /* U-Boot Magic Number */
  79. .globl version_string
  80. version_string:
  81. .ascii U_BOOT_VERSION
  82. .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
  83. .ascii CONFIG_IDENT_STRING, "\0"
  84. . = EXC_OFF_SYS_RESET
  85. .globl _start
  86. _start:
  87. lis r3, CONFIG_SYS_IMMR@h /* position IMMR */
  88. mtspr 638, r3
  89. /* Initialize machine status; enable machine check interrupt */
  90. /*----------------------------------------------------------------------*/
  91. li r3, MSR_KERNEL /* Set ME, RI flags */
  92. mtmsr r3
  93. mtspr SRR1, r3 /* Make SRR1 match MSR */
  94. mfspr r3, ICR /* clear Interrupt Cause Register */
  95. /* Initialize debug port registers */
  96. /*----------------------------------------------------------------------*/
  97. xor r0, r0, r0 /* Clear R0 */
  98. mtspr LCTRL1, r0 /* Initialize debug port regs */
  99. mtspr LCTRL2, r0
  100. mtspr COUNTA, r0
  101. mtspr COUNTB, r0
  102. /* Reset the caches */
  103. /*----------------------------------------------------------------------*/
  104. mfspr r3, IC_CST /* Clear error bits */
  105. mfspr r3, DC_CST
  106. lis r3, IDC_UNALL@h /* Unlock all */
  107. mtspr IC_CST, r3
  108. mtspr DC_CST, r3
  109. lis r3, IDC_INVALL@h /* Invalidate all */
  110. mtspr IC_CST, r3
  111. mtspr DC_CST, r3
  112. lis r3, IDC_DISABLE@h /* Disable data cache */
  113. mtspr DC_CST, r3
  114. #if !defined(CONFIG_SYS_DELAYED_ICACHE)
  115. /* On IP860 and PCU E,
  116. * we cannot enable IC yet
  117. */
  118. lis r3, IDC_ENABLE@h /* Enable instruction cache */
  119. #endif
  120. mtspr IC_CST, r3
  121. /* invalidate all tlb's */
  122. /*----------------------------------------------------------------------*/
  123. tlbia
  124. isync
  125. /*
  126. * Calculate absolute address in FLASH and jump there
  127. *----------------------------------------------------------------------*/
  128. lis r3, CONFIG_SYS_MONITOR_BASE@h
  129. ori r3, r3, CONFIG_SYS_MONITOR_BASE@l
  130. addi r3, r3, in_flash - _start + EXC_OFF_SYS_RESET
  131. mtlr r3
  132. blr
  133. in_flash:
  134. /* initialize some SPRs that are hard to access from C */
  135. /*----------------------------------------------------------------------*/
  136. lis r3, CONFIG_SYS_IMMR@h /* pass IMMR as arg1 to C routine */
  137. ori r1, r3, CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in internal DPRAM */
  138. /* Note: R0 is still 0 here */
  139. stwu r0, -4(r1) /* clear final stack frame so that */
  140. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  141. /*
  142. * Disable serialized ifetch and show cycles
  143. * (i.e. set processor to normal mode).
  144. * This is also a silicon bug workaround, see errata
  145. */
  146. li r2, 0x0007
  147. mtspr ICTRL, r2
  148. /* Set up debug mode entry */
  149. lis r2, CONFIG_SYS_DER@h
  150. ori r2, r2, CONFIG_SYS_DER@l
  151. mtspr DER, r2
  152. /* let the C-code set up the rest */
  153. /* */
  154. /* Be careful to keep code relocatable ! */
  155. /*----------------------------------------------------------------------*/
  156. GET_GOT /* initialize GOT access */
  157. /* r3: IMMR */
  158. bl cpu_init_f /* run low-level CPU init code (from Flash) */
  159. bl board_init_f /* run 1st part of board init code (from Flash) */
  160. /* NOTREACHED - board_init_f() does not return */
  161. .globl _start_of_vectors
  162. _start_of_vectors:
  163. /* Machine check */
  164. STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  165. /* Data Storage exception. "Never" generated on the 860. */
  166. STD_EXCEPTION(0x300, DataStorage, UnknownException)
  167. /* Instruction Storage exception. "Never" generated on the 860. */
  168. STD_EXCEPTION(0x400, InstStorage, UnknownException)
  169. /* External Interrupt exception. */
  170. STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
  171. /* Alignment exception. */
  172. . = 0x600
  173. Alignment:
  174. EXCEPTION_PROLOG(SRR0, SRR1)
  175. mfspr r4,DAR
  176. stw r4,_DAR(r21)
  177. mfspr r5,DSISR
  178. stw r5,_DSISR(r21)
  179. addi r3,r1,STACK_FRAME_OVERHEAD
  180. EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
  181. /* Program check exception */
  182. . = 0x700
  183. ProgramCheck:
  184. EXCEPTION_PROLOG(SRR0, SRR1)
  185. addi r3,r1,STACK_FRAME_OVERHEAD
  186. EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
  187. MSR_KERNEL, COPY_EE)
  188. /* No FPU on MPC8xx. This exception is not supposed to happen.
  189. */
  190. STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
  191. /* I guess we could implement decrementer, and may have
  192. * to someday for timekeeping.
  193. */
  194. STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
  195. STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
  196. STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
  197. STD_EXCEPTION(0xc00, SystemCall, UnknownException)
  198. STD_EXCEPTION(0xd00, SingleStep, UnknownException)
  199. STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
  200. STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
  201. /* On the MPC8xx, this is a software emulation interrupt. It occurs
  202. * for all unimplemented and illegal instructions.
  203. */
  204. STD_EXCEPTION(0x1000, SoftEmu, SoftEmuException)
  205. STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
  206. STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
  207. STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
  208. STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
  209. STD_EXCEPTION(0x1500, Reserved5, UnknownException)
  210. STD_EXCEPTION(0x1600, Reserved6, UnknownException)
  211. STD_EXCEPTION(0x1700, Reserved7, UnknownException)
  212. STD_EXCEPTION(0x1800, Reserved8, UnknownException)
  213. STD_EXCEPTION(0x1900, Reserved9, UnknownException)
  214. STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
  215. STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
  216. STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
  217. STD_EXCEPTION(0x1d00, InstructionBreakpoint, DebugException)
  218. STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
  219. STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
  220. .globl _end_of_vectors
  221. _end_of_vectors:
  222. . = 0x2000
  223. /*
  224. * This code finishes saving the registers to the exception frame
  225. * and jumps to the appropriate handler for the exception.
  226. * Register r21 is pointer into trap frame, r1 has new stack pointer.
  227. */
  228. .globl transfer_to_handler
  229. transfer_to_handler:
  230. stw r22,_NIP(r21)
  231. lis r22,MSR_POW@h
  232. andc r23,r23,r22
  233. stw r23,_MSR(r21)
  234. SAVE_GPR(7, r21)
  235. SAVE_4GPRS(8, r21)
  236. SAVE_8GPRS(12, r21)
  237. SAVE_8GPRS(24, r21)
  238. mflr r23
  239. andi. r24,r23,0x3f00 /* get vector offset */
  240. stw r24,TRAP(r21)
  241. li r22,0
  242. stw r22,RESULT(r21)
  243. mtspr SPRG2,r22 /* r1 is now kernel sp */
  244. lwz r24,0(r23) /* virtual address of handler */
  245. lwz r23,4(r23) /* where to go when done */
  246. mtspr SRR0,r24
  247. mtspr SRR1,r20
  248. mtlr r23
  249. SYNC
  250. rfi /* jump to handler, enable MMU */
  251. int_return:
  252. mfmsr r28 /* Disable interrupts */
  253. li r4,0
  254. ori r4,r4,MSR_EE
  255. andc r28,r28,r4
  256. SYNC /* Some chip revs need this... */
  257. mtmsr r28
  258. SYNC
  259. lwz r2,_CTR(r1)
  260. lwz r0,_LINK(r1)
  261. mtctr r2
  262. mtlr r0
  263. lwz r2,_XER(r1)
  264. lwz r0,_CCR(r1)
  265. mtspr XER,r2
  266. mtcrf 0xFF,r0
  267. REST_10GPRS(3, r1)
  268. REST_10GPRS(13, r1)
  269. REST_8GPRS(23, r1)
  270. REST_GPR(31, r1)
  271. lwz r2,_NIP(r1) /* Restore environment */
  272. lwz r0,_MSR(r1)
  273. mtspr SRR0,r2
  274. mtspr SRR1,r0
  275. lwz r0,GPR0(r1)
  276. lwz r2,GPR2(r1)
  277. lwz r1,GPR1(r1)
  278. SYNC
  279. rfi
  280. /* Cache functions.
  281. */
  282. .globl icache_enable
  283. icache_enable:
  284. SYNC
  285. lis r3, IDC_INVALL@h
  286. mtspr IC_CST, r3
  287. lis r3, IDC_ENABLE@h
  288. mtspr IC_CST, r3
  289. blr
  290. .globl icache_disable
  291. icache_disable:
  292. SYNC
  293. lis r3, IDC_DISABLE@h
  294. mtspr IC_CST, r3
  295. blr
  296. .globl icache_status
  297. icache_status:
  298. mfspr r3, IC_CST
  299. srwi r3, r3, 31 /* >>31 => select bit 0 */
  300. blr
  301. .globl dcache_enable
  302. dcache_enable:
  303. #if 0
  304. SYNC
  305. #endif
  306. #if 1
  307. lis r3, 0x0400 /* Set cache mode with MMU off */
  308. mtspr MD_CTR, r3
  309. #endif
  310. lis r3, IDC_INVALL@h
  311. mtspr DC_CST, r3
  312. #if 0
  313. lis r3, DC_SFWT@h
  314. mtspr DC_CST, r3
  315. #endif
  316. lis r3, IDC_ENABLE@h
  317. mtspr DC_CST, r3
  318. blr
  319. .globl dcache_disable
  320. dcache_disable:
  321. SYNC
  322. lis r3, IDC_DISABLE@h
  323. mtspr DC_CST, r3
  324. lis r3, IDC_INVALL@h
  325. mtspr DC_CST, r3
  326. blr
  327. .globl dcache_status
  328. dcache_status:
  329. mfspr r3, DC_CST
  330. srwi r3, r3, 31 /* >>31 => select bit 0 */
  331. blr
  332. .globl dc_read
  333. dc_read:
  334. mtspr DC_ADR, r3
  335. mfspr r3, DC_DAT
  336. blr
  337. /*
  338. * unsigned int get_immr (unsigned int mask)
  339. *
  340. * return (mask ? (IMMR & mask) : IMMR);
  341. */
  342. .globl get_immr
  343. get_immr:
  344. mr r4,r3 /* save mask */
  345. mfspr r3, IMMR /* IMMR */
  346. cmpwi 0,r4,0 /* mask != 0 ? */
  347. beq 4f
  348. and r3,r3,r4 /* IMMR & mask */
  349. 4:
  350. blr
  351. .globl get_pvr
  352. get_pvr:
  353. mfspr r3, PVR
  354. blr
  355. .globl wr_ic_cst
  356. wr_ic_cst:
  357. mtspr IC_CST, r3
  358. blr
  359. .globl rd_ic_cst
  360. rd_ic_cst:
  361. mfspr r3, IC_CST
  362. blr
  363. .globl wr_ic_adr
  364. wr_ic_adr:
  365. mtspr IC_ADR, r3
  366. blr
  367. .globl wr_dc_cst
  368. wr_dc_cst:
  369. mtspr DC_CST, r3
  370. blr
  371. .globl rd_dc_cst
  372. rd_dc_cst:
  373. mfspr r3, DC_CST
  374. blr
  375. .globl wr_dc_adr
  376. wr_dc_adr:
  377. mtspr DC_ADR, r3
  378. blr
  379. /*------------------------------------------------------------------------------*/
  380. /*
  381. * void relocate_code (addr_sp, gd, addr_moni)
  382. *
  383. * This "function" does not return, instead it continues in RAM
  384. * after relocating the monitor code.
  385. *
  386. * r3 = dest
  387. * r4 = src
  388. * r5 = length in bytes
  389. * r6 = cachelinesize
  390. */
  391. .globl relocate_code
  392. relocate_code:
  393. mr r1, r3 /* Set new stack pointer */
  394. mr r9, r4 /* Save copy of Global Data pointer */
  395. mr r10, r5 /* Save copy of Destination Address */
  396. GET_GOT
  397. mr r3, r5 /* Destination Address */
  398. lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
  399. ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
  400. lwz r5, GOT(__init_end)
  401. sub r5, r5, r4
  402. li r6, CONFIG_SYS_CACHELINE_SIZE /* Cache Line Size */
  403. /*
  404. * Fix GOT pointer:
  405. *
  406. * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
  407. *
  408. * Offset:
  409. */
  410. sub r15, r10, r4
  411. /* First our own GOT */
  412. add r12, r12, r15
  413. /* then the one used by the C code */
  414. add r30, r30, r15
  415. /*
  416. * Now relocate code
  417. */
  418. cmplw cr1,r3,r4
  419. addi r0,r5,3
  420. srwi. r0,r0,2
  421. beq cr1,4f /* In place copy is not necessary */
  422. beq 7f /* Protect against 0 count */
  423. mtctr r0
  424. bge cr1,2f
  425. la r8,-4(r4)
  426. la r7,-4(r3)
  427. 1: lwzu r0,4(r8)
  428. stwu r0,4(r7)
  429. bdnz 1b
  430. b 4f
  431. 2: slwi r0,r0,2
  432. add r8,r4,r0
  433. add r7,r3,r0
  434. 3: lwzu r0,-4(r8)
  435. stwu r0,-4(r7)
  436. bdnz 3b
  437. /*
  438. * Now flush the cache: note that we must start from a cache aligned
  439. * address. Otherwise we might miss one cache line.
  440. */
  441. 4: cmpwi r6,0
  442. add r5,r3,r5
  443. beq 7f /* Always flush prefetch queue in any case */
  444. subi r0,r6,1
  445. andc r3,r3,r0
  446. mr r4,r3
  447. 5: dcbst 0,r4
  448. add r4,r4,r6
  449. cmplw r4,r5
  450. blt 5b
  451. sync /* Wait for all dcbst to complete on bus */
  452. mr r4,r3
  453. 6: icbi 0,r4
  454. add r4,r4,r6
  455. cmplw r4,r5
  456. blt 6b
  457. 7: sync /* Wait for all icbi to complete on bus */
  458. isync
  459. /*
  460. * We are done. Do not return, instead branch to second part of board
  461. * initialization, now running from RAM.
  462. */
  463. addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
  464. mtlr r0
  465. blr
  466. in_ram:
  467. /*
  468. * Relocation Function, r12 point to got2+0x8000
  469. *
  470. * Adjust got2 pointers, no need to check for 0, this code
  471. * already puts a few entries in the table.
  472. */
  473. li r0,__got2_entries@sectoff@l
  474. la r3,GOT(_GOT2_TABLE_)
  475. lwz r11,GOT(_GOT2_TABLE_)
  476. mtctr r0
  477. sub r11,r3,r11
  478. addi r3,r3,-4
  479. 1: lwzu r0,4(r3)
  480. cmpwi r0,0
  481. beq- 2f
  482. add r0,r0,r11
  483. stw r0,0(r3)
  484. 2: bdnz 1b
  485. /*
  486. * Now adjust the fixups and the pointers to the fixups
  487. * in case we need to move ourselves again.
  488. */
  489. li r0,__fixup_entries@sectoff@l
  490. lwz r3,GOT(_FIXUP_TABLE_)
  491. cmpwi r0,0
  492. mtctr r0
  493. addi r3,r3,-4
  494. beq 4f
  495. 3: lwzu r4,4(r3)
  496. lwzux r0,r4,r11
  497. cmpwi r0,0
  498. add r0,r0,r11
  499. stw r10,0(r3)
  500. beq- 5f
  501. stw r0,0(r4)
  502. 5: bdnz 3b
  503. 4:
  504. clear_bss:
  505. /*
  506. * Now clear BSS segment
  507. */
  508. lwz r3,GOT(__bss_start)
  509. lwz r4,GOT(_end)
  510. cmplw 0, r3, r4
  511. beq 6f
  512. li r0, 0
  513. 5:
  514. stw r0, 0(r3)
  515. addi r3, r3, 4
  516. cmplw 0, r3, r4
  517. bne 5b
  518. 6:
  519. mr r3, r9 /* Global Data pointer */
  520. mr r4, r10 /* Destination Address */
  521. bl board_init_r
  522. /*
  523. * Copy exception vector code to low memory
  524. *
  525. * r3: dest_addr
  526. * r7: source address, r8: end address, r9: target address
  527. */
  528. .globl trap_init
  529. trap_init:
  530. mflr r4 /* save link register */
  531. GET_GOT
  532. lwz r7, GOT(_start)
  533. lwz r8, GOT(_end_of_vectors)
  534. li r9, 0x100 /* reset vector always at 0x100 */
  535. cmplw 0, r7, r8
  536. bgelr /* return if r7>=r8 - just in case */
  537. 1:
  538. lwz r0, 0(r7)
  539. stw r0, 0(r9)
  540. addi r7, r7, 4
  541. addi r9, r9, 4
  542. cmplw 0, r7, r8
  543. bne 1b
  544. /*
  545. * relocate `hdlr' and `int_return' entries
  546. */
  547. li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
  548. li r8, Alignment - _start + EXC_OFF_SYS_RESET
  549. 2:
  550. bl trap_reloc
  551. addi r7, r7, 0x100 /* next exception vector */
  552. cmplw 0, r7, r8
  553. blt 2b
  554. li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
  555. bl trap_reloc
  556. li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
  557. bl trap_reloc
  558. li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
  559. li r8, SystemCall - _start + EXC_OFF_SYS_RESET
  560. 3:
  561. bl trap_reloc
  562. addi r7, r7, 0x100 /* next exception vector */
  563. cmplw 0, r7, r8
  564. blt 3b
  565. li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
  566. li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
  567. 4:
  568. bl trap_reloc
  569. addi r7, r7, 0x100 /* next exception vector */
  570. cmplw 0, r7, r8
  571. blt 4b
  572. mtlr r4 /* restore link register */
  573. blr