1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Code that sets up the DRAM registers, calls the
4 * decompressor to unpack the piggybacked kernel, and jumps.
6 * Copyright (C) 1999 - 2006, Axis Communications AB
9 #define ASSEMBLER_MACROS_ONLY
10 #include <hwregs/asm/reg_map_asm.h>
11 #include <mach/startup.inc>
13 #define RAM_INIT_MAGIC 0x56902387
14 #define COMMAND_LINE_MAGIC 0x87109563
24 ;; Start clocks for used blocks.
27 ;; Initialize the DRAM registers.
28 cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
29 beq dram_init_finished
32 #if defined CONFIG_ETRAXFS
33 #include "../../arch-v32/mach-fs/dram_init.S"
34 #elif defined CONFIG_CRIS_MACH_ARTPEC3
35 #include "../../arch-v32/mach-a3/dram_init.S"
37 #error Only ETRAXFS and ARTPEC-3 supported!
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.
47 move.d 0x40800000, $sp
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).
56 ;; Use (_edata - herami) as offset to the current PC.
60 and.d 0x7fffffff, $r5 ; strip any non-cache bit
61 move.d $r5, $r0 ; source address of 'herami'
63 sub.d hereami, $r5 ; r5 = flash address of '_edata'
64 move.d hereami, $r1 ; destination
66 ;; Copy text+data to DRAM
68 move.d _edata, $r2 ; end destination
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
74 move.d input_data, $r0 ; for the decompressor
75 move.d $r5, [$r0] ; for the decompressor
77 ;; Clear the decompressors BSS (between _edata and _end)
87 ;; Save command line magic and address.
88 move.d _cmd_line_magic, $r0
90 move.d _cmd_line_addr, $r0
93 ;; Save boot source indicator
94 move.d _boot_source, $r0
97 ;; Do the decompression and save compressed size in _inptr
102 ;; Restore boot source indicator
103 move.d _boot_source, $r12
106 ;; Restore command line magic and address.
107 move.d _cmd_line_magic, $r10
109 move.d _cmd_line_addr, $r11
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
117 add.d [$r0], $r9 ; size of compressed kernel
118 cmp.d 0x40000000, $r9 ; image in DRAM ?
119 blo enter_kernel ; no, must be [NOR] flash, jump
121 and.d 0x001fffff, $r9 ; assume compressed kernel was < 2M
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
132 .dword 0 ; used by the decompressor
140 #if defined CONFIG_ETRAXFS
141 #include "../../arch-v32/mach-fs/hw_settings.S"
142 #elif defined CONFIG_CRIS_MACH_ARTPEC3
143 #include "../../arch-v32/mach-a3/hw_settings.S"
145 #error Only ETRAXFS and ARTPEC-3 supported!