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