]>
Commit | Line | Data |
---|---|---|
51533b61 MS |
1 | /* |
2 | * Code that sets up the DRAM registers, calls the | |
3 | * decompressor to unpack the piggybacked kernel, and jumps. | |
4 | * | |
247c3c95 | 5 | * Copyright (C) 1999 - 2006, Axis Communications AB |
51533b61 MS |
6 | */ |
7 | ||
51533b61 | 8 | #define ASSEMBLER_MACROS_ONLY |
247c3c95 JN |
9 | #include <hwregs/asm/reg_map_asm.h> |
10 | #include <asm/arch/mach/startup.inc> | |
51533b61 MS |
11 | |
12 | #define RAM_INIT_MAGIC 0x56902387 | |
13 | #define COMMAND_LINE_MAGIC 0x87109563 | |
14 | ||
15 | ;; Exported symbols | |
16 | ||
17 | .globl input_data | |
18 | ||
19 | .text | |
20 | start: | |
21 | di | |
22 | ||
23 | ;; Start clocks for used blocks. | |
247c3c95 JN |
24 | START_CLOCKS |
25 | ||
26 | ;; Initialize the DRAM registers. | |
51533b61 MS |
27 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? |
28 | beq dram_init_finished | |
29 | nop | |
30 | ||
247c3c95 | 31 | #include "../../mach/dram_init.S" |
51533b61 MS |
32 | |
33 | dram_init_finished: | |
51533b61 | 34 | |
247c3c95 | 35 | GIO_INIT |
51533b61 MS |
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. | |
39 | ||
40 | move.d 0x40800000, $sp | |
41 | ||
247c3c95 JN |
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). | |
51533b61 MS |
49 | ;; Use (_edata - herami) as offset to the current PC. |
50 | ||
51533b61 MS |
51 | hereami: |
52 | lapcq ., $r5 ; get PC | |
53 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | |
247c3c95 | 54 | move.d $r5, $r0 ; source address of 'herami' |
51533b61 MS |
55 | add.d _edata, $r5 |
56 | sub.d hereami, $r5 ; r5 = flash address of '_edata' | |
57 | move.d hereami, $r1 ; destination | |
247c3c95 | 58 | |
51533b61 MS |
59 | ;; Copy text+data to DRAM |
60 | ||
61 | move.d _edata, $r2 ; end destination | |
247c3c95 JN |
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 | |
51533b61 MS |
65 | bcs 1b |
66 | nop | |
51533b61 MS |
67 | move.d input_data, $r0 ; for the decompressor |
68 | move.d $r5, [$r0] ; for the decompressor | |
69 | ||
70 | ;; Clear the decompressors BSS (between _edata and _end) | |
71 | ||
72 | moveq 0, $r0 | |
73 | move.d _edata, $r1 | |
74 | move.d _end, $r2 | |
75 | 1: move.w $r0, [$r1+] | |
76 | cmp.d $r2, $r1 | |
77 | bcs 1b | |
78 | nop | |
79 | ||
80 | ;; Save command line magic and address. | |
247c3c95 JN |
81 | move.d _cmd_line_magic, $r0 |
82 | move.d $r10, [$r0] | |
83 | move.d _cmd_line_addr, $r0 | |
84 | move.d $r11, [$r0] | |
85 | ||
86 | ;; Save boot source indicator | |
87 | move.d _boot_source, $r0 | |
88 | move.d $r12, [$r0] | |
51533b61 MS |
89 | |
90 | ;; Do the decompression and save compressed size in _inptr | |
91 | ||
92 | jsr decompress_kernel | |
93 | nop | |
94 | ||
247c3c95 JN |
95 | ;; Restore boot source indicator |
96 | move.d _boot_source, $r12 | |
97 | move.d [$r12], $r12 | |
98 | ||
51533b61 MS |
99 | ;; Restore command line magic and address. |
100 | move.d _cmd_line_magic, $r10 | |
101 | move.d [$r10], $r10 | |
102 | move.d _cmd_line_addr, $r11 | |
103 | move.d [$r11], $r11 | |
104 | ||
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 | |
109 | move.d inptr, $r0 | |
110 | add.d [$r0], $r9 ; size of compressed kernel | |
247c3c95 JN |
111 | cmp.d 0x40000000, $r9 ; image in DRAM ? |
112 | blo enter_kernel ; no, must be [NOR] flash, jump | |
113 | nop ; delay slot | |
114 | and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M | |
51533b61 MS |
115 | |
116 | enter_kernel: | |
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 | |
120 | nop | |
121 | ||
122 | .data | |
123 | ||
124 | input_data: | |
125 | .dword 0 ; used by the decompressor | |
126 | _cmd_line_magic: | |
127 | .dword 0 | |
128 | _cmd_line_addr: | |
129 | .dword 0 | |
247c3c95 JN |
130 | _boot_source: |
131 | .dword 0 | |
51533b61 | 132 | |
247c3c95 | 133 | #include "../../mach/hw_settings.S" |