This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / m68knommu / platform / 528x / senTec / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for senTec COBRA5282 ColdFire based boards.
5  *
6  *      (C) Copyright 2003, Greg Ungerer (gerg@snapgear.com).
7  */
8
9 /*****************************************************************************/
10
11 #include <linux/config.h>
12 #include <linux/threads.h>
13 #include <linux/linkage.h>
14 #include <asm/segment.h>
15 #include <asm/coldfire.h>
16 #include <asm/mcfsim.h>
17
18 /*****************************************************************************/
19
20 /*
21  *      senTec COBRA5282 board, chip select and memory setup.
22  */
23
24 #define MEM_BASE        0x00000000      /* Memory base at address 0 */
25 #define VBR_BASE        MEM_BASE        /* Vector address */
26
27 #if defined(CONFIG_RAM16MB)
28 #define MEM_SIZE        0x01000000      /* Memory size 16Mb */
29 #elif defined(CONFIG_RAM8MB)
30 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
31 #else
32 #define MEM_SIZE        0x00400000      /* Memory size 4Mb */
33 #endif
34
35 #define IPSBAR 0x40000000
36 #define GPACR0 0x30
37 /*****************************************************************************/
38
39 .global _start
40 .global _rambase
41 .global _ramvec
42 .global _ramstart
43 .global _ramend
44
45 /*****************************************************************************/
46
47 .data
48
49 /*
50  *      Set up the usable of RAM stuff. Size of RAM is determined then
51  *      an initial stack set up at the end.
52  */
53 _rambase:
54 .long   0
55 _ramvec:
56 .long   0
57 _ramstart:
58 .long   0
59 _ramend:
60 .long   0
61
62 /*****************************************************************************/
63
64 .text
65
66 /*
67  *      This is the codes first entry point. This is where it all
68  *      begins...
69  */
70
71 _start:
72         nop                                                             /* Filler */
73         move.w  #0x2700, %sr                    /* No interrupts */
74
75         /*
76          * Setup VBR here, otherwise buserror remap will not work.
77          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
78          *
79          * bkr@cut.de 19990306
80          *
81          * Note: this is because dBUG points VBR to ROM, making vectors read
82          * only, so the bus trap can't be changed. (RS)
83          */
84         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
85         movec   %a7, %VBR
86         move.l  %a7, _ramvec                    /* Set up vector addr */
87         move.l  %a7, _rambase                   /* Set up base RAM addr */
88
89
90         /*
91          *      Set memory size.
92          */
93         move.l  #MEM_SIZE, %a0
94
95         move.l  %a0, %d0                        /* Mem end addr is in a0 */
96         move.l  %d0, %sp                        /* Set up initial stack ptr */
97         move.l  %d0, _ramend            /* Set end ram addr */
98
99         /*
100          *      Enable CPU internal cache.
101          *
102          *      Cache is totally broken in first 5282 silicon.
103          *      No point enabling it for now.
104          */
105 #if 0
106         move.l  #0x01000000, %d0
107         movec   %d0, %CACR                              /* Invalidate cache */
108         nop
109
110         move.l  #0x0000c000, %d0                /* Set SDRAM cached only */
111         movec   %d0, %ACR0
112         move.l  #0x00000000, %d0                /* No other regions cached */
113         movec   %d0, %ACR1
114
115         move.l  #0x00000000, %d0                /* Setup cache mask */
116         movec   %d0, %CACR                              /* Enable cache */
117         nop
118 #endif
119
120
121 #ifdef CONFIG_ROMFS_FS
122         /*
123          *      Move ROM filesystem above bss :-)
124          */
125         lea.l   _sbss, %a0                      /* Get start of bss */
126         lea.l   _ebss, %a1                      /* Set up destination  */
127         move.l  %a0, %a2                        /* Copy of bss start */
128
129         move.l  8(%a0), %d0                     /* Get size of ROMFS */
130         addq.l  #8, %d0                         /* Allow for rounding */
131         and.l   #0xfffffffc, %d0        /* Whole words */
132
133         add.l   %d0, %a0                        /* Copy from end */
134         add.l   %d0, %a1                        /* Copy from end */
135         move.l  %a1, _ramstart          /* Set start of ram */
136
137 _copy_romfs:
138         move.l  -(%a0), %d0                     /* Copy dword */
139         move.l  %d0, -(%a1)
140         cmp.l   %a0, %a2                        /* Check if at end */
141         bne     _copy_romfs
142 #else /* CONFIG_ROMFS_FS */
143         lea.l   _ebss, %a1
144         move.l  %a1, _ramstart
145 #endif /* CONFIG_ROMFS_FS */
146
147
148         /*
149          *      Zero out the bss region.
150          */
151         lea.l   _sbss, %a0                      /* Get start of bss */
152         lea.l   _ebss, %a1                      /* Get end of bss */
153         clr.l   %d0                                     /* Set value */
154 _clear_bss:
155         move.l  %d0, (%a0)+                     /* Clear each word */
156         cmp.l   %a0, %a1                        /* Check if at end */
157         bne     _clear_bss
158
159         /*
160          *      Load the current thread pointer and stack.
161          */
162         lea     init_thread_union, %a0
163         lea     0x2000(%a0), %sp
164
165    /*
166     * User mode port access
167     */
168    move.l   #0x0000000c, %d0
169    move.b   %d0, (IPSBAR+GPACR0)
170
171
172         /*
173          *      Assember start up done, start code proper.
174          */
175         jsr     start_kernel                    /* Start Linux kernel */
176
177 _exit:
178         jmp     _exit                           /* Should never get here */
179
180 /*****************************************************************************/