Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input
[pandora-kernel.git] / arch / cris / arch-v10 / boot / compressed / head.S
1 /*
2  *  arch/cris/boot/compressed/head.S
3  *
4  *  Copyright (C) 1999, 2001 Axis Communications AB
5  *
6  *  Code that sets up the DRAM registers, calls the
7  *  decompressor to unpack the piggybacked kernel, and jumps.
8  *
9  */
10
11 #include <linux/config.h>
12 #define ASSEMBLER_MACROS_ONLY
13 #include <asm/arch/sv_addr_ag.h>
14
15 #define RAM_INIT_MAGIC 0x56902387
16 #define COMMAND_LINE_MAGIC 0x87109563
17
18         ;; Exported symbols
19         
20         .globl  _input_data
21
22         
23         .text
24
25         nop
26         di
27
28 ;; We need to initialze DRAM registers before we start using the DRAM
29         
30         cmp.d   RAM_INIT_MAGIC, r8      ; Already initialized?
31         beq     dram_init_finished
32         nop
33         
34 #include "../../lib/dram_init.S"
35         
36 dram_init_finished:     
37                 
38         ;; Initiate the PA and PB ports
39
40         move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DATA, r0
41         move.b   r0, [R_PORT_PA_DATA]
42
43         move.b   CONFIG_ETRAX_DEF_R_PORT_PA_DIR, r0
44         move.b   r0, [R_PORT_PA_DIR]
45
46         move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DATA, r0
47         move.b   r0, [R_PORT_PB_DATA]
48
49         move.b   CONFIG_ETRAX_DEF_R_PORT_PB_DIR, r0
50         move.b   r0, [R_PORT_PB_DIR]
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
56         move.d  0x40800000, sp
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.
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         
70         ;; Copy text+data to DRAM
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
77         bcs     1b
78         nop
79
80         move.d  r5, [_input_data] ; for the decompressor
81
82
83         ;; Clear the decompressors BSS (between _edata and _end)
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
90         bcs     1b
91         nop
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]
98         
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
104         ;; when mounting from flash
105
106         move.d  [_input_data], r9       ; flash address of compressed kernel
107         add.d   [_inptr], r9            ; size of compressed kernel
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
115         ;; Enter the decompressed kernel
116         move.d  RAM_INIT_MAGIC, r8      ; Tell kernel that DRAM is initialized
117         jump    0x40004000      ; kernel is linked to this address
118         
119         .data
120
121 _input_data:
122         .dword  0               ; used by the decompressor
123 _cmd_line_magic:
124         .dword 0
125 _cmd_line_addr:
126         .dword 0
127 #include "../../lib/hw_settings.S"