]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
51533b61 MS |
2 | /* |
3 | * Code that sets up the DRAM registers, calls the | |
4 | * decompressor to unpack the piggybacked kernel, and jumps. | |
5 | * | |
247c3c95 | 6 | * Copyright (C) 1999 - 2006, Axis Communications AB |
51533b61 MS |
7 | */ |
8 | ||
51533b61 | 9 | #define ASSEMBLER_MACROS_ONLY |
247c3c95 | 10 | #include <hwregs/asm/reg_map_asm.h> |
556dcee7 | 11 | #include <mach/startup.inc> |
51533b61 MS |
12 | |
13 | #define RAM_INIT_MAGIC 0x56902387 | |
14 | #define COMMAND_LINE_MAGIC 0x87109563 | |
15 | ||
16 | ;; Exported symbols | |
17 | ||
18 | .globl input_data | |
19 | ||
20 | .text | |
66ab3a74 | 21 | start: |
51533b61 MS |
22 | di |
23 | ||
24 | ;; Start clocks for used blocks. | |
247c3c95 JN |
25 | START_CLOCKS |
26 | ||
27 | ;; Initialize the DRAM registers. | |
51533b61 MS |
28 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? |
29 | beq dram_init_finished | |
30 | nop | |
31 | ||
c5ec6fb0 | 32 | #if defined CONFIG_ETRAXFS |
66ab3a74 | 33 | #include "../../arch-v32/mach-fs/dram_init.S" |
c5ec6fb0 | 34 | #elif defined CONFIG_CRIS_MACH_ARTPEC3 |
66ab3a74 | 35 | #include "../../arch-v32/mach-a3/dram_init.S" |
c5ec6fb0 JN |
36 | #else |
37 | #error Only ETRAXFS and ARTPEC-3 supported! | |
38 | #endif | |
51533b61 MS |
39 | |
40 | dram_init_finished: | |
51533b61 | 41 | |
247c3c95 | 42 | GIO_INIT |
51533b61 MS |
43 | ;; Setup the stack to a suitably high address. |
44 | ;; We assume 8 MB is the minimum DRAM and put | |
45 | ;; the SP at the top for now. | |
46 | ||
47 | move.d 0x40800000, $sp | |
48 | ||
247c3c95 JN |
49 | ;; Figure out where the compressed piggyback image is. |
50 | ;; It is either in [NOR] flash (we don't want to copy it | |
51 | ;; to DRAM before unpacking), or copied to DRAM | |
52 | ;; by the [NAND] flash boot loader. | |
53 | ;; The piggyback image is at _edata, but relative to where the | |
54 | ;; image is actually located in memory, not where it is linked | |
55 | ;; (the decompressor is linked at 0x40700000+ and runs there). | |
51533b61 MS |
56 | ;; Use (_edata - herami) as offset to the current PC. |
57 | ||
51533b61 MS |
58 | hereami: |
59 | lapcq ., $r5 ; get PC | |
60 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | |
247c3c95 | 61 | move.d $r5, $r0 ; source address of 'herami' |
51533b61 MS |
62 | add.d _edata, $r5 |
63 | sub.d hereami, $r5 ; r5 = flash address of '_edata' | |
64 | move.d hereami, $r1 ; destination | |
247c3c95 | 65 | |
51533b61 MS |
66 | ;; Copy text+data to DRAM |
67 | ||
68 | move.d _edata, $r2 ; end destination | |
247c3c95 JN |
69 | 1: move.w [$r0+], $r3 ; from herami+ source |
70 | move.w $r3, [$r1+] ; to hereami+ destination (linked address) | |
71 | cmp.d $r2, $r1 ; finish when destination == _edata | |
51533b61 MS |
72 | bcs 1b |
73 | nop | |
51533b61 MS |
74 | move.d input_data, $r0 ; for the decompressor |
75 | move.d $r5, [$r0] ; for the decompressor | |
76 | ||
77 | ;; Clear the decompressors BSS (between _edata and _end) | |
78 | ||
79 | moveq 0, $r0 | |
80 | move.d _edata, $r1 | |
81 | move.d _end, $r2 | |
82 | 1: move.w $r0, [$r1+] | |
83 | cmp.d $r2, $r1 | |
84 | bcs 1b | |
85 | nop | |
86 | ||
87 | ;; Save command line magic and address. | |
247c3c95 JN |
88 | move.d _cmd_line_magic, $r0 |
89 | move.d $r10, [$r0] | |
90 | move.d _cmd_line_addr, $r0 | |
91 | move.d $r11, [$r0] | |
92 | ||
93 | ;; Save boot source indicator | |
94 | move.d _boot_source, $r0 | |
95 | move.d $r12, [$r0] | |
51533b61 MS |
96 | |
97 | ;; Do the decompression and save compressed size in _inptr | |
98 | ||
99 | jsr decompress_kernel | |
100 | nop | |
101 | ||
247c3c95 JN |
102 | ;; Restore boot source indicator |
103 | move.d _boot_source, $r12 | |
104 | move.d [$r12], $r12 | |
105 | ||
51533b61 MS |
106 | ;; Restore command line magic and address. |
107 | move.d _cmd_line_magic, $r10 | |
108 | move.d [$r10], $r10 | |
109 | move.d _cmd_line_addr, $r11 | |
110 | move.d [$r11], $r11 | |
111 | ||
112 | ;; Put start address of root partition in r9 so the kernel can use it | |
113 | ;; when mounting from flash | |
114 | move.d input_data, $r0 | |
115 | move.d [$r0], $r9 ; flash address of compressed kernel | |
116 | move.d inptr, $r0 | |
117 | add.d [$r0], $r9 ; size of compressed kernel | |
247c3c95 JN |
118 | cmp.d 0x40000000, $r9 ; image in DRAM ? |
119 | blo enter_kernel ; no, must be [NOR] flash, jump | |
120 | nop ; delay slot | |
121 | and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M | |
51533b61 MS |
122 | |
123 | enter_kernel: | |
124 | ;; Enter the decompressed kernel | |
125 | move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized | |
126 | jump 0x40004000 ; kernel is linked to this address | |
127 | nop | |
128 | ||
129 | .data | |
130 | ||
131 | input_data: | |
132 | .dword 0 ; used by the decompressor | |
133 | _cmd_line_magic: | |
134 | .dword 0 | |
135 | _cmd_line_addr: | |
136 | .dword 0 | |
247c3c95 JN |
137 | _boot_source: |
138 | .dword 0 | |
51533b61 | 139 | |
c5ec6fb0 | 140 | #if defined CONFIG_ETRAXFS |
66ab3a74 | 141 | #include "../../arch-v32/mach-fs/hw_settings.S" |
c5ec6fb0 | 142 | #elif defined CONFIG_CRIS_MACH_ARTPEC3 |
66ab3a74 | 143 | #include "../../arch-v32/mach-a3/hw_settings.S" |
c5ec6fb0 JN |
144 | #else |
145 | #error Only ETRAXFS and ARTPEC-3 supported! | |
146 | #endif |