2 * Code that sets up the DRAM registers, calls the
3 * decompressor to unpack the piggybacked kernel, and jumps.
5 * Copyright (C) 1999 - 2006, Axis Communications AB
8 #define ASSEMBLER_MACROS_ONLY
9 #include <hwregs/asm/reg_map_asm.h>
10 #include <asm/arch/mach/startup.inc>
12 #define RAM_INIT_MAGIC 0x56902387
13 #define COMMAND_LINE_MAGIC 0x87109563
23 ;; Start clocks for used blocks.
26 ;; Initialize the DRAM registers.
27 cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
28 beq dram_init_finished
31 #include "../../mach/dram_init.S"
36 ;; Setup the stack to a suitably high address.
37 ;; We assume 8 MB is the minimum DRAM and put
38 ;; the SP at the top for now.
40 move.d 0x40800000, $sp
42 ;; Figure out where the compressed piggyback image is.
43 ;; It is either in [NOR] flash (we don't want to copy it
44 ;; to DRAM before unpacking), or copied to DRAM
45 ;; by the [NAND] flash boot loader.
46 ;; The piggyback image is at _edata, but relative to where the
47 ;; image is actually located in memory, not where it is linked
48 ;; (the decompressor is linked at 0x40700000+ and runs there).
49 ;; Use (_edata - herami) as offset to the current PC.
53 and.d 0x7fffffff, $r5 ; strip any non-cache bit
54 move.d $r5, $r0 ; source address of 'herami'
56 sub.d hereami, $r5 ; r5 = flash address of '_edata'
57 move.d hereami, $r1 ; destination
59 ;; Copy text+data to DRAM
61 move.d _edata, $r2 ; end destination
62 1: move.w [$r0+], $r3 ; from herami+ source
63 move.w $r3, [$r1+] ; to hereami+ destination (linked address)
64 cmp.d $r2, $r1 ; finish when destination == _edata
67 move.d input_data, $r0 ; for the decompressor
68 move.d $r5, [$r0] ; for the decompressor
70 ;; Clear the decompressors BSS (between _edata and _end)
80 ;; Save command line magic and address.
81 move.d _cmd_line_magic, $r0
83 move.d _cmd_line_addr, $r0
86 ;; Save boot source indicator
87 move.d _boot_source, $r0
90 ;; Do the decompression and save compressed size in _inptr
95 ;; Restore boot source indicator
96 move.d _boot_source, $r12
99 ;; Restore command line magic and address.
100 move.d _cmd_line_magic, $r10
102 move.d _cmd_line_addr, $r11
105 ;; Put start address of root partition in r9 so the kernel can use it
106 ;; when mounting from flash
107 move.d input_data, $r0
108 move.d [$r0], $r9 ; flash address of compressed kernel
110 add.d [$r0], $r9 ; size of compressed kernel
111 cmp.d 0x40000000, $r9 ; image in DRAM ?
112 blo enter_kernel ; no, must be [NOR] flash, jump
114 and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M
117 ;; Enter the decompressed kernel
118 move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized
119 jump 0x40004000 ; kernel is linked to this address
125 .dword 0 ; used by the decompressor
133 #include "../../mach/hw_settings.S"