head.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. * linux/arch/arm/boot/compressed/head.S
  3. *
  4. * Copyright (C) 1996-2002 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/config.h>
  11. #include <linux/linkage.h>
  12. /*
  13. * Debugging stuff
  14. *
  15. * Note that these macros must not contain any code which is not
  16. * 100% relocatable. Any attempt to do so will result in a crash.
  17. * Please select one of the following when turning on debugging.
  18. */
  19. #ifdef DEBUG
  20. #if defined(CONFIG_DEBUG_ICEDCC)
  21. .macro loadsp, rb
  22. .endm
  23. .macro writeb, ch, rb
  24. mcr p14, 0, \ch, c0, c1, 0
  25. .endm
  26. #else
  27. #include <asm/arch/debug-macro.S>
  28. .macro writeb, ch, rb
  29. senduart \ch, \rb
  30. .endm
  31. #if defined(CONFIG_ARCH_SA1100)
  32. .macro loadsp, rb
  33. mov \rb, #0x80000000 @ physical base address
  34. #ifdef CONFIG_DEBUG_LL_SER3
  35. add \rb, \rb, #0x00050000 @ Ser3
  36. #else
  37. add \rb, \rb, #0x00010000 @ Ser1
  38. #endif
  39. .endm
  40. #elif defined(CONFIG_ARCH_IOP331)
  41. .macro loadsp, rb
  42. mov \rb, #0xff000000
  43. orr \rb, \rb, #0x00ff0000
  44. orr \rb, \rb, #0x0000f700 @ location of the UART
  45. .endm
  46. #elif defined(CONFIG_ARCH_S3C2410)
  47. .macro loadsp, rb
  48. mov \rb, #0x50000000
  49. add \rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT
  50. .endm
  51. #else
  52. .macro loadsp, rb
  53. addruart \rb
  54. .endm
  55. #endif
  56. #endif
  57. #endif
  58. .macro kputc,val
  59. mov r0, \val
  60. bl putc
  61. .endm
  62. .macro kphex,val,len
  63. mov r0, \val
  64. mov r1, #\len
  65. bl phex
  66. .endm
  67. .macro debug_reloc_start
  68. #ifdef DEBUG
  69. kputc #'\n'
  70. kphex r6, 8 /* processor id */
  71. kputc #':'
  72. kphex r7, 8 /* architecture id */
  73. kputc #':'
  74. mrc p15, 0, r0, c1, c0
  75. kphex r0, 8 /* control reg */
  76. kputc #'\n'
  77. kphex r5, 8 /* decompressed kernel start */
  78. kputc #'-'
  79. kphex r8, 8 /* decompressed kernel end */
  80. kputc #'>'
  81. kphex r4, 8 /* kernel execution address */
  82. kputc #'\n'
  83. #endif
  84. .endm
  85. .macro debug_reloc_end
  86. #ifdef DEBUG
  87. kphex r5, 8 /* end of kernel */
  88. kputc #'\n'
  89. mov r0, r4
  90. bl memdump /* dump 256 bytes at start of kernel */
  91. #endif
  92. .endm
  93. .section ".start", #alloc, #execinstr
  94. /*
  95. * sort out different calling conventions
  96. */
  97. .align
  98. start:
  99. .type start,#function
  100. .rept 8
  101. mov r0, r0
  102. .endr
  103. b 1f
  104. .word 0x016f2818 @ Magic numbers to help the loader
  105. .word start @ absolute load/run zImage address
  106. .word _edata @ zImage end address
  107. 1: mov r7, r1 @ save architecture ID
  108. mov r8, #0 @ save r0
  109. #ifndef __ARM_ARCH_2__
  110. /*
  111. * Booting from Angel - need to enter SVC mode and disable
  112. * FIQs/IRQs (numeric definitions from angel arm.h source).
  113. * We only do this if we were in user mode on entry.
  114. */
  115. mrs r2, cpsr @ get current mode
  116. tst r2, #3 @ not user?
  117. bne not_angel
  118. mov r0, #0x17 @ angel_SWIreason_EnterSVC
  119. swi 0x123456 @ angel_SWI_ARM
  120. not_angel:
  121. mrs r2, cpsr @ turn off interrupts to
  122. orr r2, r2, #0xc0 @ prevent angel from running
  123. msr cpsr_c, r2
  124. #else
  125. teqp pc, #0x0c000003 @ turn off interrupts
  126. #endif
  127. /*
  128. * Note that some cache flushing and other stuff may
  129. * be needed here - is there an Angel SWI call for this?
  130. */
  131. /*
  132. * some architecture specific code can be inserted
  133. * by the linker here, but it should preserve r7 and r8.
  134. */
  135. .text
  136. adr r0, LC0
  137. ldmia r0, {r1, r2, r3, r4, r5, r6, ip, sp}
  138. subs r0, r0, r1 @ calculate the delta offset
  139. @ if delta is zero, we are
  140. beq not_relocated @ running at the address we
  141. @ were linked at.
  142. /*
  143. * We're running at a different address. We need to fix
  144. * up various pointers:
  145. * r5 - zImage base address
  146. * r6 - GOT start
  147. * ip - GOT end
  148. */
  149. add r5, r5, r0
  150. add r6, r6, r0
  151. add ip, ip, r0
  152. #ifndef CONFIG_ZBOOT_ROM
  153. /*
  154. * If we're running fully PIC === CONFIG_ZBOOT_ROM = n,
  155. * we need to fix up pointers into the BSS region.
  156. * r2 - BSS start
  157. * r3 - BSS end
  158. * sp - stack pointer
  159. */
  160. add r2, r2, r0
  161. add r3, r3, r0
  162. add sp, sp, r0
  163. /*
  164. * Relocate all entries in the GOT table.
  165. */
  166. 1: ldr r1, [r6, #0] @ relocate entries in the GOT
  167. add r1, r1, r0 @ table. This fixes up the
  168. str r1, [r6], #4 @ C references.
  169. cmp r6, ip
  170. blo 1b
  171. #else
  172. /*
  173. * Relocate entries in the GOT table. We only relocate
  174. * the entries that are outside the (relocated) BSS region.
  175. */
  176. 1: ldr r1, [r6, #0] @ relocate entries in the GOT
  177. cmp r1, r2 @ entry < bss_start ||
  178. cmphs r3, r1 @ _end < entry
  179. addlo r1, r1, r0 @ table. This fixes up the
  180. str r1, [r6], #4 @ C references.
  181. cmp r6, ip
  182. blo 1b
  183. #endif
  184. not_relocated: mov r0, #0
  185. 1: str r0, [r2], #4 @ clear bss
  186. str r0, [r2], #4
  187. str r0, [r2], #4
  188. str r0, [r2], #4
  189. cmp r2, r3
  190. blo 1b
  191. /*
  192. * The C runtime environment should now be setup
  193. * sufficiently. Turn the cache on, set up some
  194. * pointers, and start decompressing.
  195. */
  196. bl cache_on
  197. mov r1, sp @ malloc space above stack
  198. add r2, sp, #0x10000 @ 64k max
  199. /*
  200. * Check to see if we will overwrite ourselves.
  201. * r4 = final kernel address
  202. * r5 = start of this image
  203. * r2 = end of malloc space (and therefore this image)
  204. * We basically want:
  205. * r4 >= r2 -> OK
  206. * r4 + image length <= r5 -> OK
  207. */
  208. cmp r4, r2
  209. bhs wont_overwrite
  210. add r0, r4, #4096*1024 @ 4MB largest kernel size
  211. cmp r0, r5
  212. bls wont_overwrite
  213. mov r5, r2 @ decompress after malloc space
  214. mov r0, r5
  215. mov r3, r7
  216. bl decompress_kernel
  217. add r0, r0, #127
  218. bic r0, r0, #127 @ align the kernel length
  219. /*
  220. * r0 = decompressed kernel length
  221. * r1-r3 = unused
  222. * r4 = kernel execution address
  223. * r5 = decompressed kernel start
  224. * r6 = processor ID
  225. * r7 = architecture ID
  226. * r8-r14 = unused
  227. */
  228. add r1, r5, r0 @ end of decompressed kernel
  229. adr r2, reloc_start
  230. ldr r3, LC1
  231. add r3, r2, r3
  232. 1: ldmia r2!, {r8 - r13} @ copy relocation code
  233. stmia r1!, {r8 - r13}
  234. ldmia r2!, {r8 - r13}
  235. stmia r1!, {r8 - r13}
  236. cmp r2, r3
  237. blo 1b
  238. bl cache_clean_flush
  239. add pc, r5, r0 @ call relocation code
  240. /*
  241. * We're not in danger of overwriting ourselves. Do this the simple way.
  242. *
  243. * r4 = kernel execution address
  244. * r7 = architecture ID
  245. */
  246. wont_overwrite: mov r0, r4
  247. mov r3, r7
  248. bl decompress_kernel
  249. b call_kernel
  250. .type LC0, #object
  251. LC0: .word LC0 @ r1
  252. .word __bss_start @ r2
  253. .word _end @ r3
  254. .word zreladdr @ r4
  255. .word _start @ r5
  256. .word _got_start @ r6
  257. .word _got_end @ ip
  258. .word user_stack+4096 @ sp
  259. LC1: .word reloc_end - reloc_start
  260. .size LC0, . - LC0
  261. #ifdef CONFIG_ARCH_RPC
  262. .globl params
  263. params: ldr r0, =params_phys
  264. mov pc, lr
  265. .ltorg
  266. .align
  267. #endif
  268. /*
  269. * Turn on the cache. We need to setup some page tables so that we
  270. * can have both the I and D caches on.
  271. *
  272. * We place the page tables 16k down from the kernel execution address,
  273. * and we hope that nothing else is using it. If we're using it, we
  274. * will go pop!
  275. *
  276. * On entry,
  277. * r4 = kernel execution address
  278. * r6 = processor ID
  279. * r7 = architecture number
  280. * r8 = run-time address of "start"
  281. * On exit,
  282. * r1, r2, r3, r8, r9, r12 corrupted
  283. * This routine must preserve:
  284. * r4, r5, r6, r7
  285. */
  286. .align 5
  287. cache_on: mov r3, #8 @ cache_on function
  288. b call_cache_fn
  289. __setup_mmu: sub r3, r4, #16384 @ Page directory size
  290. bic r3, r3, #0xff @ Align the pointer
  291. bic r3, r3, #0x3f00
  292. /*
  293. * Initialise the page tables, turning on the cacheable and bufferable
  294. * bits for the RAM area only.
  295. */
  296. mov r0, r3
  297. mov r8, r0, lsr #18
  298. mov r8, r8, lsl #18 @ start of RAM
  299. add r9, r8, #0x10000000 @ a reasonable RAM size
  300. mov r1, #0x12
  301. orr r1, r1, #3 << 10
  302. add r2, r3, #16384
  303. 1: cmp r1, r8 @ if virt > start of RAM
  304. orrhs r1, r1, #0x0c @ set cacheable, bufferable
  305. cmp r1, r9 @ if virt > end of RAM
  306. bichs r1, r1, #0x0c @ clear cacheable, bufferable
  307. str r1, [r0], #4 @ 1:1 mapping
  308. add r1, r1, #1048576
  309. teq r0, r2
  310. bne 1b
  311. /*
  312. * If ever we are running from Flash, then we surely want the cache
  313. * to be enabled also for our execution instance... We map 2MB of it
  314. * so there is no map overlap problem for up to 1 MB compressed kernel.
  315. * If the execution is in RAM then we would only be duplicating the above.
  316. */
  317. mov r1, #0x1e
  318. orr r1, r1, #3 << 10
  319. mov r2, pc, lsr #20
  320. orr r1, r1, r2, lsl #20
  321. add r0, r3, r2, lsl #2
  322. str r1, [r0], #4
  323. add r1, r1, #1048576
  324. str r1, [r0]
  325. mov pc, lr
  326. __armv4_cache_on:
  327. mov r12, lr
  328. bl __setup_mmu
  329. mov r0, #0
  330. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  331. mcr p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
  332. mrc p15, 0, r0, c1, c0, 0 @ read control reg
  333. orr r0, r0, #0x5000 @ I-cache enable, RR cache replacement
  334. orr r0, r0, #0x0030
  335. bl __common_cache_on
  336. mov r0, #0
  337. mcr p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
  338. mov pc, r12
  339. __arm6_cache_on:
  340. mov r12, lr
  341. bl __setup_mmu
  342. mov r0, #0
  343. mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
  344. mcr p15, 0, r0, c5, c0, 0 @ invalidate whole TLB v3
  345. mov r0, #0x30
  346. bl __common_cache_on
  347. mov r0, #0
  348. mcr p15, 0, r0, c5, c0, 0 @ invalidate whole TLB v3
  349. mov pc, r12
  350. __common_cache_on:
  351. #ifndef DEBUG
  352. orr r0, r0, #0x000d @ Write buffer, mmu
  353. #endif
  354. mov r1, #-1
  355. mcr p15, 0, r3, c2, c0, 0 @ load page table pointer
  356. mcr p15, 0, r1, c3, c0, 0 @ load domain access control
  357. mcr p15, 0, r0, c1, c0, 0 @ load control register
  358. mov pc, lr
  359. /*
  360. * All code following this line is relocatable. It is relocated by
  361. * the above code to the end of the decompressed kernel image and
  362. * executed there. During this time, we have no stacks.
  363. *
  364. * r0 = decompressed kernel length
  365. * r1-r3 = unused
  366. * r4 = kernel execution address
  367. * r5 = decompressed kernel start
  368. * r6 = processor ID
  369. * r7 = architecture ID
  370. * r8-r14 = unused
  371. */
  372. .align 5
  373. reloc_start: add r8, r5, r0
  374. debug_reloc_start
  375. mov r1, r4
  376. 1:
  377. .rept 4
  378. ldmia r5!, {r0, r2, r3, r9 - r13} @ relocate kernel
  379. stmia r1!, {r0, r2, r3, r9 - r13}
  380. .endr
  381. cmp r5, r8
  382. blo 1b
  383. debug_reloc_end
  384. call_kernel: bl cache_clean_flush
  385. bl cache_off
  386. mov r0, #0
  387. mov r1, r7 @ restore architecture number
  388. mov pc, r4 @ call kernel
  389. /*
  390. * Here follow the relocatable cache support functions for the
  391. * various processors. This is a generic hook for locating an
  392. * entry and jumping to an instruction at the specified offset
  393. * from the start of the block. Please note this is all position
  394. * independent code.
  395. *
  396. * r1 = corrupted
  397. * r2 = corrupted
  398. * r3 = block offset
  399. * r6 = corrupted
  400. * r12 = corrupted
  401. */
  402. call_cache_fn: adr r12, proc_types
  403. mrc p15, 0, r6, c0, c0 @ get processor ID
  404. 1: ldr r1, [r12, #0] @ get value
  405. ldr r2, [r12, #4] @ get mask
  406. eor r1, r1, r6 @ (real ^ match)
  407. tst r1, r2 @ & mask
  408. addeq pc, r12, r3 @ call cache function
  409. add r12, r12, #4*5
  410. b 1b
  411. /*
  412. * Table for cache operations. This is basically:
  413. * - CPU ID match
  414. * - CPU ID mask
  415. * - 'cache on' method instruction
  416. * - 'cache off' method instruction
  417. * - 'cache flush' method instruction
  418. *
  419. * We match an entry using: ((real_id ^ match) & mask) == 0
  420. *
  421. * Writethrough caches generally only need 'on' and 'off'
  422. * methods. Writeback caches _must_ have the flush method
  423. * defined.
  424. */
  425. .type proc_types,#object
  426. proc_types:
  427. .word 0x41560600 @ ARM6/610
  428. .word 0xffffffe0
  429. b __arm6_cache_off @ works, but slow
  430. b __arm6_cache_off
  431. mov pc, lr
  432. @ b __arm6_cache_on @ untested
  433. @ b __arm6_cache_off
  434. @ b __armv3_cache_flush
  435. .word 0x00000000 @ old ARM ID
  436. .word 0x0000f000
  437. mov pc, lr
  438. mov pc, lr
  439. mov pc, lr
  440. .word 0x41007000 @ ARM7/710
  441. .word 0xfff8fe00
  442. b __arm7_cache_off
  443. b __arm7_cache_off
  444. mov pc, lr
  445. .word 0x41807200 @ ARM720T (writethrough)
  446. .word 0xffffff00
  447. b __armv4_cache_on
  448. b __armv4_cache_off
  449. mov pc, lr
  450. .word 0x00007000 @ ARM7 IDs
  451. .word 0x0000f000
  452. mov pc, lr
  453. mov pc, lr
  454. mov pc, lr
  455. @ Everything from here on will be the new ID system.
  456. .word 0x4401a100 @ sa110 / sa1100
  457. .word 0xffffffe0
  458. b __armv4_cache_on
  459. b __armv4_cache_off
  460. b __armv4_cache_flush
  461. .word 0x6901b110 @ sa1110
  462. .word 0xfffffff0
  463. b __armv4_cache_on
  464. b __armv4_cache_off
  465. b __armv4_cache_flush
  466. @ These match on the architecture ID
  467. .word 0x00020000 @ ARMv4T
  468. .word 0x000f0000
  469. b __armv4_cache_on
  470. b __armv4_cache_off
  471. b __armv4_cache_flush
  472. .word 0x00050000 @ ARMv5TE
  473. .word 0x000f0000
  474. b __armv4_cache_on
  475. b __armv4_cache_off
  476. b __armv4_cache_flush
  477. .word 0x00060000 @ ARMv5TEJ
  478. .word 0x000f0000
  479. b __armv4_cache_on
  480. b __armv4_cache_off
  481. b __armv4_cache_flush
  482. .word 0x00070000 @ ARMv6
  483. .word 0x000f0000
  484. b __armv4_cache_on
  485. b __armv4_cache_off
  486. b __armv6_cache_flush
  487. .word 0 @ unrecognised type
  488. .word 0
  489. mov pc, lr
  490. mov pc, lr
  491. mov pc, lr
  492. .size proc_types, . - proc_types
  493. /*
  494. * Turn off the Cache and MMU. ARMv3 does not support
  495. * reading the control register, but ARMv4 does.
  496. *
  497. * On entry, r6 = processor ID
  498. * On exit, r0, r1, r2, r3, r12 corrupted
  499. * This routine must preserve: r4, r6, r7
  500. */
  501. .align 5
  502. cache_off: mov r3, #12 @ cache_off function
  503. b call_cache_fn
  504. __armv4_cache_off:
  505. mrc p15, 0, r0, c1, c0
  506. bic r0, r0, #0x000d
  507. mcr p15, 0, r0, c1, c0 @ turn MMU and cache off
  508. mov r0, #0
  509. mcr p15, 0, r0, c7, c7 @ invalidate whole cache v4
  510. mcr p15, 0, r0, c8, c7 @ invalidate whole TLB v4
  511. mov pc, lr
  512. __arm6_cache_off:
  513. mov r0, #0x00000030 @ ARM6 control reg.
  514. b __armv3_cache_off
  515. __arm7_cache_off:
  516. mov r0, #0x00000070 @ ARM7 control reg.
  517. b __armv3_cache_off
  518. __armv3_cache_off:
  519. mcr p15, 0, r0, c1, c0, 0 @ turn MMU and cache off
  520. mov r0, #0
  521. mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
  522. mcr p15, 0, r0, c5, c0, 0 @ invalidate whole TLB v3
  523. mov pc, lr
  524. /*
  525. * Clean and flush the cache to maintain consistency.
  526. *
  527. * On entry,
  528. * r6 = processor ID
  529. * On exit,
  530. * r1, r2, r3, r11, r12 corrupted
  531. * This routine must preserve:
  532. * r0, r4, r5, r6, r7
  533. */
  534. .align 5
  535. cache_clean_flush:
  536. mov r3, #16
  537. b call_cache_fn
  538. __armv6_cache_flush:
  539. mov r1, #0
  540. mcr p15, 0, r1, c7, c14, 0 @ clean+invalidate D
  541. mcr p15, 0, r1, c7, c5, 0 @ invalidate I+BTB
  542. mcr p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
  543. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  544. mov pc, lr
  545. __armv4_cache_flush:
  546. mov r2, #64*1024 @ default: 32K dcache size (*2)
  547. mov r11, #32 @ default: 32 byte line size
  548. mrc p15, 0, r3, c0, c0, 1 @ read cache type
  549. teq r3, r6 @ cache ID register present?
  550. beq no_cache_id
  551. mov r1, r3, lsr #18
  552. and r1, r1, #7
  553. mov r2, #1024
  554. mov r2, r2, lsl r1 @ base dcache size *2
  555. tst r3, #1 << 14 @ test M bit
  556. addne r2, r2, r2, lsr #1 @ +1/2 size if M == 1
  557. mov r3, r3, lsr #12
  558. and r3, r3, #3
  559. mov r11, #8
  560. mov r11, r11, lsl r3 @ cache line size in bytes
  561. no_cache_id:
  562. bic r1, pc, #63 @ align to longest cache line
  563. add r2, r1, r2
  564. 1: ldr r3, [r1], r11 @ s/w flush D cache
  565. teq r1, r2
  566. bne 1b
  567. mcr p15, 0, r1, c7, c5, 0 @ flush I cache
  568. mcr p15, 0, r1, c7, c6, 0 @ flush D cache
  569. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  570. mov pc, lr
  571. __armv3_cache_flush:
  572. mov r1, #0
  573. mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
  574. mov pc, lr
  575. /*
  576. * Various debugging routines for printing hex characters and
  577. * memory, which again must be relocatable.
  578. */
  579. #ifdef DEBUG
  580. .type phexbuf,#object
  581. phexbuf: .space 12
  582. .size phexbuf, . - phexbuf
  583. phex: adr r3, phexbuf
  584. mov r2, #0
  585. strb r2, [r3, r1]
  586. 1: subs r1, r1, #1
  587. movmi r0, r3
  588. bmi puts
  589. and r2, r0, #15
  590. mov r0, r0, lsr #4
  591. cmp r2, #10
  592. addge r2, r2, #7
  593. add r2, r2, #'0'
  594. strb r2, [r3, r1]
  595. b 1b
  596. puts: loadsp r3
  597. 1: ldrb r2, [r0], #1
  598. teq r2, #0
  599. moveq pc, lr
  600. 2: writeb r2, r3
  601. mov r1, #0x00020000
  602. 3: subs r1, r1, #1
  603. bne 3b
  604. teq r2, #'\n'
  605. moveq r2, #'\r'
  606. beq 2b
  607. teq r0, #0
  608. bne 1b
  609. mov pc, lr
  610. putc:
  611. mov r2, r0
  612. mov r0, #0
  613. loadsp r3
  614. b 2b
  615. memdump: mov r12, r0
  616. mov r10, lr
  617. mov r11, #0
  618. 2: mov r0, r11, lsl #2
  619. add r0, r0, r12
  620. mov r1, #8
  621. bl phex
  622. mov r0, #':'
  623. bl putc
  624. 1: mov r0, #' '
  625. bl putc
  626. ldr r0, [r12, r11, lsl #2]
  627. mov r1, #8
  628. bl phex
  629. and r0, r11, #7
  630. teq r0, #3
  631. moveq r0, #' '
  632. bleq putc
  633. and r0, r11, #7
  634. add r11, r11, #1
  635. teq r0, #7
  636. bne 1b
  637. mov r0, #'\n'
  638. bl putc
  639. cmp r11, #64
  640. blt 2b
  641. mov pc, r10
  642. #endif
  643. reloc_end:
  644. .align
  645. .section ".stack", "w"
  646. user_stack: .space 4096