ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5282 / MOTOROLA / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5282 ColdFire based MOTOROLA 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  *      Motorola M5282C3 ColdFire eval 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 /*****************************************************************************/
36
37 .global _start
38 .global _rambase
39 .global _ramvec
40 .global _ramstart
41 .global _ramend
42
43 /*****************************************************************************/
44
45 .data
46
47 /*
48  *      Set up the usable of RAM stuff. Size of RAM is determined then
49  *      an initial stack set up at the end.
50  */
51 _rambase:
52 .long   0
53 _ramvec:
54 .long   0
55 _ramstart:
56 .long   0
57 _ramend:
58 .long   0
59
60 /*****************************************************************************/
61
62 .text
63
64 /*
65  *      This is the codes first entry point. This is where it all
66  *      begins...
67  */
68
69 _start:
70         nop                                     /* Filler */
71         move.w  #0x2700, %sr                    /* No interrupts */
72
73         /*
74          * Setup VBR here, otherwise buserror remap will not work.
75          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
76          *
77          * bkr@cut.de 19990306
78          *
79          * Note: this is because dBUG points VBR to ROM, making vectors read
80          * only, so the bus trap can't be changed. (RS)
81          */
82         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
83         movec   %a7, %VBR
84         move.l  %a7, _ramvec                    /* Set up vector addr */
85         move.l  %a7, _rambase                   /* Set up base RAM addr */
86
87
88         /*
89          *      Set memory size.
90          */
91         move.l  #MEM_SIZE, %a0
92
93         move.l  %a0, %d0                        /* Mem end addr is in a0 */
94         move.l  %d0, %sp                        /* Set up initial stack ptr */
95         move.l  %d0, _ramend                    /* Set end ram addr */
96
97         /*
98          *      Enable CPU internal cache.
99          *
100          *      Cache is totally broken in first 5282 silicon.
101          *      No point enabling it for now.
102          */
103 #if 0
104         move.l  #0x01000000, %d0
105         movec   %d0, %CACR                      /* Invalidate cache */
106         nop
107
108         move.l  #0x0000c000, %d0                /* Set SDRAM cached only */
109         movec   %d0, %ACR0
110         move.l  #0x00000000, %d0                /* No other regions cached */
111         movec   %d0, %ACR1
112
113         move.l  #0x00000000, %d0                /* Setup cache mask */
114         movec   %d0, %CACR                      /* Enable cache */
115         nop
116 #endif
117
118
119 #ifdef CONFIG_ROMFS_FS
120         /*
121          *      Move ROM filesystem above bss :-)
122          */
123         lea.l   _sbss, %a0                      /* Get start of bss */
124         lea.l   _ebss, %a1                      /* Set up destination  */
125         move.l  %a0, %a2                        /* Copy of bss start */
126
127         move.l  8(%a0), %d0                     /* Get size of ROMFS */
128         addq.l  #8, %d0                         /* Allow for rounding */
129         and.l   #0xfffffffc, %d0                /* Whole words */
130
131         add.l   %d0, %a0                        /* Copy from end */
132         add.l   %d0, %a1                        /* Copy from end */
133         move.l  %a1, _ramstart                  /* Set start of ram */
134
135 _copy_romfs:
136         move.l  -(%a0), %d0                     /* Copy dword */
137         move.l  %d0, -(%a1)
138         cmp.l   %a0, %a2                        /* Check if at end */
139         bne     _copy_romfs
140 #else /* CONFIG_ROMFS_FS */
141         lea.l   _ebss, %a1
142         move.l  %a1, _ramstart
143 #endif /* CONFIG_ROMFS_FS */
144
145
146         /*
147          *      Zero out the bss region.
148          */
149         lea.l   _sbss, %a0                      /* Get start of bss */
150         lea.l   _ebss, %a1                      /* Get end of bss */
151         clr.l   %d0                             /* Set value */
152 _clear_bss:
153         move.l  %d0, (%a0)+                     /* Clear each word */
154         cmp.l   %a0, %a1                        /* Check if at end */
155         bne     _clear_bss
156
157         /*
158          *      Load the current thread pointer and stack.
159          */
160         lea     init_thread_union, %a0
161         lea     0x2000(%a0), %sp
162
163         /*
164          *      Assember start up done, start code proper.
165          */
166         jsr     start_kernel                    /* Start Linux kernel */
167
168 _exit:
169         jmp     _exit                           /* Should never get here */
170
171 /*****************************************************************************/