diff options
Diffstat (limited to 'arch/cris/arch-v32/boot/compressed/head.S')
-rw-r--r-- | arch/cris/arch-v32/boot/compressed/head.S | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/arch/cris/arch-v32/boot/compressed/head.S b/arch/cris/arch-v32/boot/compressed/head.S new file mode 100644 index 000000000000..0c55b83b8287 --- /dev/null +++ b/arch/cris/arch-v32/boot/compressed/head.S | |||
@@ -0,0 +1,193 @@ | |||
1 | /* | ||
2 | * Code that sets up the DRAM registers, calls the | ||
3 | * decompressor to unpack the piggybacked kernel, and jumps. | ||
4 | * | ||
5 | * Copyright (C) 1999 - 2003, Axis Communications AB | ||
6 | */ | ||
7 | |||
8 | #include <linux/config.h> | ||
9 | #define ASSEMBLER_MACROS_ONLY | ||
10 | #include <asm/arch/hwregs/asm/reg_map_asm.h> | ||
11 | #include <asm/arch/hwregs/asm/gio_defs_asm.h> | ||
12 | #include <asm/arch/hwregs/asm/config_defs_asm.h> | ||
13 | |||
14 | #define RAM_INIT_MAGIC 0x56902387 | ||
15 | #define COMMAND_LINE_MAGIC 0x87109563 | ||
16 | |||
17 | ;; Exported symbols | ||
18 | |||
19 | .globl input_data | ||
20 | |||
21 | .text | ||
22 | start: | ||
23 | di | ||
24 | |||
25 | ;; Start clocks for used blocks. | ||
26 | move.d REG_ADDR(config, regi_config, rw_clk_ctrl), $r1 | ||
27 | move.d [$r1], $r0 | ||
28 | or.d REG_STATE(config, rw_clk_ctrl, cpu, yes) | \ | ||
29 | REG_STATE(config, rw_clk_ctrl, bif, yes) | \ | ||
30 | REG_STATE(config, rw_clk_ctrl, fix_io, yes), $r0 | ||
31 | move.d $r0, [$r1] | ||
32 | |||
33 | ;; If booting from NAND flash we first have to copy some | ||
34 | ;; data from NAND flash to internal RAM to get the code | ||
35 | ;; that initializes the SDRAM. Lets copy 20 KB. This | ||
36 | ;; code executes at 0x38010000 if booting from NAND and | ||
37 | ;; we are guaranted that at least 0x200 bytes are good so | ||
38 | ;; lets start from there. The first 8192 bytes in the nand | ||
39 | ;; flash is spliced with zeroes and is thus 16384 bytes. | ||
40 | move.d 0x38010200, $r10 | ||
41 | move.d 0x14200, $r11 ; Start offset in NAND flash 0x10200 + 16384 | ||
42 | move.d 0x5000, $r12 ; Length of copy | ||
43 | |||
44 | ;; Before this code the tools add a partitiontable so the PC | ||
45 | ;; has an offset from the linked address. | ||
46 | offset1: | ||
47 | lapcq ., $r13 ; get PC | ||
48 | add.d first_copy_complete-offset1, $r13 | ||
49 | |||
50 | #include "../../lib/nand_init.S" | ||
51 | |||
52 | first_copy_complete: | ||
53 | ;; Initialze the DRAM registers. | ||
54 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? | ||
55 | beq dram_init_finished | ||
56 | nop | ||
57 | |||
58 | #include "../../lib/dram_init.S" | ||
59 | |||
60 | dram_init_finished: | ||
61 | lapcq ., $r13 ; get PC | ||
62 | add.d second_copy_complete-dram_init_finished, $r13 | ||
63 | |||
64 | move.d REG_ADDR(config, regi_config, r_bootsel), $r0 | ||
65 | move.d [$r0], $r0 | ||
66 | and.d REG_MASK(config, r_bootsel, boot_mode), $r0 | ||
67 | cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0 | ||
68 | bne second_copy_complete ; No NAND boot | ||
69 | nop | ||
70 | |||
71 | ;; Copy 2MB from NAND flash to SDRAM (at 2-4MB into the SDRAM) | ||
72 | move.d 0x40204000, $r10 | ||
73 | move.d 0x8000, $r11 | ||
74 | move.d 0x200000, $r12 | ||
75 | ba copy_nand_to_ram | ||
76 | nop | ||
77 | second_copy_complete: | ||
78 | |||
79 | ;; Initiate the PA port. | ||
80 | move.d CONFIG_ETRAX_DEF_GIO_PA_OUT, $r0 | ||
81 | move.d REG_ADDR(gio, regi_gio, rw_pa_dout), $r1 | ||
82 | move.d $r0, [$r1] | ||
83 | |||
84 | move.d CONFIG_ETRAX_DEF_GIO_PA_OE, $r0 | ||
85 | move.d REG_ADDR(gio, regi_gio, rw_pa_oe), $r1 | ||
86 | move.d $r0, [$r1] | ||
87 | |||
88 | ;; Setup the stack to a suitably high address. | ||
89 | ;; We assume 8 MB is the minimum DRAM and put | ||
90 | ;; the SP at the top for now. | ||
91 | |||
92 | move.d 0x40800000, $sp | ||
93 | |||
94 | ;; Figure out where the compressed piggyback image is | ||
95 | ;; in the flash (since we wont try to copy it to DRAM | ||
96 | ;; before unpacking). It is at _edata, but in flash. | ||
97 | ;; Use (_edata - herami) as offset to the current PC. | ||
98 | |||
99 | move.d REG_ADDR(config, regi_config, r_bootsel), $r0 | ||
100 | move.d [$r0], $r0 | ||
101 | and.d REG_MASK(config, r_bootsel, boot_mode), $r0 | ||
102 | cmp.d REG_STATE(config, r_bootsel, boot_mode, nand), $r0 | ||
103 | beq hereami2 | ||
104 | nop | ||
105 | hereami: | ||
106 | lapcq ., $r5 ; get PC | ||
107 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | ||
108 | move.d $r5, $r0 ; save for later - flash address of 'herami' | ||
109 | add.d _edata, $r5 | ||
110 | sub.d hereami, $r5 ; r5 = flash address of '_edata' | ||
111 | move.d hereami, $r1 ; destination | ||
112 | ba 2f | ||
113 | nop | ||
114 | hereami2: | ||
115 | lapcq ., $r5 ; get PC | ||
116 | and.d 0x00ffffff, $r5 ; strip any non-cache bit | ||
117 | move.d $r5, $r6 | ||
118 | or.d 0x40200000, $r6 | ||
119 | move.d $r6, $r0 ; save for later - flash address of 'herami' | ||
120 | add.d _edata, $r5 | ||
121 | sub.d hereami2, $r5 ; r5 = flash address of '_edata' | ||
122 | add.d 0x40200000, $r5 | ||
123 | move.d hereami2, $r1 ; destination | ||
124 | 2: | ||
125 | ;; Copy text+data to DRAM | ||
126 | |||
127 | move.d _edata, $r2 ; end destination | ||
128 | 1: move.w [$r0+], $r3 | ||
129 | move.w $r3, [$r1+] | ||
130 | cmp.d $r2, $r1 | ||
131 | bcs 1b | ||
132 | nop | ||
133 | |||
134 | move.d input_data, $r0 ; for the decompressor | ||
135 | move.d $r5, [$r0] ; for the decompressor | ||
136 | |||
137 | ;; Clear the decompressors BSS (between _edata and _end) | ||
138 | |||
139 | moveq 0, $r0 | ||
140 | move.d _edata, $r1 | ||
141 | move.d _end, $r2 | ||
142 | 1: move.w $r0, [$r1+] | ||
143 | cmp.d $r2, $r1 | ||
144 | bcs 1b | ||
145 | nop | ||
146 | |||
147 | ;; Save command line magic and address. | ||
148 | move.d _cmd_line_magic, $r12 | ||
149 | move.d $r10, [$r12] | ||
150 | move.d _cmd_line_addr, $r12 | ||
151 | move.d $r11, [$r12] | ||
152 | |||
153 | ;; Do the decompression and save compressed size in _inptr | ||
154 | |||
155 | jsr decompress_kernel | ||
156 | nop | ||
157 | |||
158 | ;; Restore command line magic and address. | ||
159 | move.d _cmd_line_magic, $r10 | ||
160 | move.d [$r10], $r10 | ||
161 | move.d _cmd_line_addr, $r11 | ||
162 | move.d [$r11], $r11 | ||
163 | |||
164 | ;; Put start address of root partition in r9 so the kernel can use it | ||
165 | ;; when mounting from flash | ||
166 | move.d input_data, $r0 | ||
167 | move.d [$r0], $r9 ; flash address of compressed kernel | ||
168 | move.d inptr, $r0 | ||
169 | add.d [$r0], $r9 ; size of compressed kernel | ||
170 | cmp.d 0x40200000, $r9 | ||
171 | blo enter_kernel | ||
172 | nop | ||
173 | sub.d 0x40200000, $r9 | ||
174 | add.d 0x4000, $r9 | ||
175 | |||
176 | enter_kernel: | ||
177 | ;; Enter the decompressed kernel | ||
178 | move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized | ||
179 | jump 0x40004000 ; kernel is linked to this address | ||
180 | nop | ||
181 | |||
182 | .data | ||
183 | |||
184 | input_data: | ||
185 | .dword 0 ; used by the decompressor | ||
186 | _cmd_line_magic: | ||
187 | .dword 0 | ||
188 | _cmd_line_addr: | ||
189 | .dword 0 | ||
190 | is_nand_boot: | ||
191 | .dword 0 | ||
192 | |||
193 | #include "../../lib/hw_settings.S" | ||