Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * arch/cris/boot/compressed/head.S | |
4 | * | |
5 | * Copyright (C) 1999, 2001 Axis Communications AB | |
6 | * | |
7 | * Code that sets up the DRAM registers, calls the | |
8 | * decompressor to unpack the piggybacked kernel, and jumps. | |
9 | * | |
10 | */ | |
11 | ||
1da177e4 | 12 | #define ASSEMBLER_MACROS_ONLY |
556dcee7 | 13 | #include <arch/sv_addr_ag.h> |
1da177e4 LT |
14 | |
15 | #define RAM_INIT_MAGIC 0x56902387 | |
7cf32cad MS |
16 | #define COMMAND_LINE_MAGIC 0x87109563 |
17 | ||
1da177e4 | 18 | ;; Exported symbols |
1da177e4 | 19 | |
bdb144b6 JN |
20 | .globl input_data |
21 | ||
22 | ||
1da177e4 LT |
23 | .text |
24 | ||
25 | nop | |
26 | di | |
27 | ||
28 | ;; We need to initialze DRAM registers before we start using the DRAM | |
bdb144b6 JN |
29 | |
30 | cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized? | |
1da177e4 LT |
31 | beq dram_init_finished |
32 | nop | |
bdb144b6 | 33 | |
66ab3a74 | 34 | #include "../../arch-v10/lib/dram_init.S" |
bdb144b6 JN |
35 | |
36 | dram_init_finished: | |
37 | ||
1da177e4 LT |
38 | ;; Initiate the PA and PB ports |
39 | ||
bdb144b6 JN |
40 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA, $r0 |
41 | move.b $r0, [R_PORT_PA_DATA] | |
1da177e4 | 42 | |
bdb144b6 JN |
43 | move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR, $r0 |
44 | move.b $r0, [R_PORT_PA_DIR] | |
1da177e4 | 45 | |
bdb144b6 JN |
46 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA, $r0 |
47 | move.b $r0, [R_PORT_PB_DATA] | |
1da177e4 | 48 | |
bdb144b6 JN |
49 | move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR, $r0 |
50 | move.b $r0, [R_PORT_PB_DIR] | |
1da177e4 LT |
51 | |
52 | ;; Setup the stack to a suitably high address. | |
53 | ;; We assume 8 MB is the minimum DRAM in an eLinux | |
54 | ;; product and put the sp at the top for now. | |
55 | ||
bdb144b6 | 56 | move.d 0x40800000, $sp |
1da177e4 LT |
57 | |
58 | ;; Figure out where the compressed piggyback image is | |
59 | ;; in the flash (since we wont try to copy it to DRAM | |
60 | ;; before unpacking). It is at _edata, but in flash. | |
61 | ;; Use (_edata - basse) as offset to the current PC. | |
bdb144b6 JN |
62 | |
63 | basse: move.d $pc, $r5 | |
64 | and.d 0x7fffffff, $r5 ; strip any non-cache bit | |
65 | subq 2, $r5 ; compensate for the move.d $pc instr | |
66 | move.d $r5, $r0 ; save for later - flash address of 'basse' | |
67 | add.d _edata, $r5 | |
68 | sub.d basse, $r5 ; $r5 = flash address of '_edata' | |
69 | ||
1da177e4 | 70 | ;; Copy text+data to DRAM |
bdb144b6 JN |
71 | |
72 | move.d basse, $r1 ; destination | |
73 | move.d _edata, $r2 ; end destination | |
74 | 1: move.w [$r0+], $r3 | |
75 | move.w $r3, [$r1+] | |
76 | cmp.d $r2, $r1 | |
1da177e4 LT |
77 | bcs 1b |
78 | nop | |
79 | ||
bdb144b6 | 80 | move.d $r5, [input_data] ; for the decompressor |
1da177e4 LT |
81 | |
82 | ||
83 | ;; Clear the decompressors BSS (between _edata and _end) | |
bdb144b6 JN |
84 | |
85 | moveq 0, $r0 | |
86 | move.d _edata, $r1 | |
87 | move.d _end, $r2 | |
88 | 1: move.w $r0, [$r1+] | |
89 | cmp.d $r2, $r1 | |
1da177e4 LT |
90 | bcs 1b |
91 | nop | |
7cf32cad MS |
92 | |
93 | ;; Save command line magic and address. | |
94 | move.d _cmd_line_magic, $r12 | |
95 | move.d $r10, [$r12] | |
96 | move.d _cmd_line_addr, $r12 | |
97 | move.d $r11, [$r12] | |
1da177e4 | 98 | |
bdb144b6 JN |
99 | ;; Do the decompression and save compressed size in inptr |
100 | ||
101 | jsr decompress_kernel | |
102 | ||
103 | ;; Put start address of root partition in $r9 so the kernel can use it | |
1da177e4 LT |
104 | ;; when mounting from flash |
105 | ||
bdb144b6 JN |
106 | move.d [input_data], $r9 ; flash address of compressed kernel |
107 | add.d [inptr], $r9 ; size of compressed kernel | |
7cf32cad MS |
108 | |
109 | ;; Restore command line magic and address. | |
110 | move.d _cmd_line_magic, $r10 | |
111 | move.d [$r10], $r10 | |
112 | move.d _cmd_line_addr, $r11 | |
113 | move.d [$r11], $r11 | |
114 | ||
1da177e4 | 115 | ;; Enter the decompressed kernel |
bdb144b6 | 116 | move.d RAM_INIT_MAGIC, $r8 ; Tell kernel that DRAM is initialized |
1da177e4 | 117 | jump 0x40004000 ; kernel is linked to this address |
bdb144b6 | 118 | |
1da177e4 LT |
119 | .data |
120 | ||
bdb144b6 | 121 | input_data: |
1da177e4 | 122 | .dword 0 ; used by the decompressor |
7cf32cad MS |
123 | _cmd_line_magic: |
124 | .dword 0 | |
125 | _cmd_line_addr: | |
126 | .dword 0 | |
66ab3a74 | 127 | #include "../../arch-v10/lib/hw_settings.S" |