ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5272 / NETtel / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5307 ColdFire based NETtel.
5  *
6  *      (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
7  *      Copyright (C) 2000  Lineo Inc. (www.lineo.com) 
8  *
9  *      1999/02/24 Modified for the 5307 processor David W. Miller
10  */
11
12 /*****************************************************************************/
13
14 #include "linux/autoconf.h"
15 #include "asm/coldfire.h"
16 #include "asm/mcfsim.h"
17 #include "asm/nettel.h"
18
19 /*****************************************************************************/
20
21 /*
22  *      Lineo NETtel board memory setup.
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 /*
63  *      The NETtel platform has some funky LEDs!
64  */
65 .global ppdata
66 ppdata:
67 .short  0x0000
68
69 .global ledbank
70 ledbank:
71 .byte   0xff
72
73 /*****************************************************************************/
74
75 .text
76
77 /*
78  *      This is the codes first entry point. This is where it all
79  *      begins...
80  */
81
82 _start:
83         nop                                     /* Filler */
84         move.w  #0x2700, %sr                    /* No interrupts */
85
86         /*
87          * Setup VBR here, otherwise buserror remap will not work.
88          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
89          *
90          * bkr@cut.de 19990306
91          *
92          * Note: this is because dBUG points VBR to ROM, making vectors read
93          * only, so the bus trap can't be changed. (RS)
94          */
95         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
96         movec   %a7, %VBR
97         move.l  %a7, _ramvec                    /* Set up vector addr */
98         move.l  %a7, _rambase                   /* Set up base RAM addr */
99
100
101         /*
102          *      Determine size of RAM, then set up initial stack.
103          */
104         move.l  #MEM_SIZE, %a0
105
106         move.l  %a0, %d0                        /* Mem end addr is in a0 */
107         move.l  %d0, %sp                        /* Set up initial stack ptr */
108         move.l  %d0, _ramend                    /* Set end ram addr */
109
110         /*
111          *      Enable CPU internal cache.
112          */
113         move.l  #0x01000000, %d0                /* Invalidate cache cmd */
114         movec   %d0, %CACR                      /* Invalidate cache */
115         move.l  #0x80000100, %d0                /* Setup cache mask */
116         movec   %d0, %CACR                      /* Enable cache */
117         nop
118
119
120 #ifdef CONFIG_ROMFS_FS
121 #ifdef CONFIG_ROMFS_FROM_ROM
122         /*
123          *      check for an in RAM romfs
124          */
125         lea.l   _sbss, %a0                      /* Get start of bss */
126         mov.l   (%a0), %d0
127         cmp.l   #0x2d726f6d, %d0        /* check for "-rom" */
128         bne             use_xip_romfs
129         add.l   #4, %a0
130         mov.l   (%a0), %d0
131         cmp.l   #0x3166732d, %d0        /* check for "1fs-" */
132         bne             use_xip_romfs
133 #endif
134
135         /*
136          *      Move ROM filesystem above bss :-)
137          */
138         lea.l   _sbss, %a0                      /* Get start of bss */
139         lea.l   _ebss, %a1                      /* Set up destination  */
140         move.l  %a0, %a2                        /* Copy of bss start */
141
142         move.l  8(%a0), %d0                     /* Get size of ROMFS */
143         addq.l  #8, %d0                         /* Allow for rounding */
144         and.l   #0xfffffffc, %d0                /* Whole words */
145
146         add.l   %d0, %a0                        /* Copy from end */
147         add.l   %d0, %a1                        /* Copy from end */
148         move.l  %a1, _ramstart                  /* Set start of ram */
149
150 _copy_romfs:
151         move.l  -(%a0), %d0                     /* Copy dword */
152         move.l  %d0, -(%a1)
153         cmp.l   %a0, %a2                        /* Check if at end */
154         bne     _copy_romfs
155
156 #ifdef CONFIG_ROMFS_FROM_ROM
157         bra             done_romfs
158   use_xip_romfs:
159         lea.l   _ebss, %a1                      /* Set up destination  */
160         mov.l   #0, (%a1)                       /* make sure we don't use an old RAM version */
161         move.l  %a1, _ramstart          /* Set start of ram */
162   done_romfs:
163 #endif
164
165 #else /* CONFIG_ROMFS_FS */
166         lea.l   _ebss, %a1
167         move.l  %a1, _ramstart
168 #endif /* CONFIG_ROMFS_FS */
169
170
171         /*
172          *      Zero out the bss region.
173          */
174         lea.l   _sbss, %a0                      /* Get start of bss */
175         lea.l   _ebss, %a1                      /* Get end of bss */
176         clr.l   %d0                             /* Set value */
177 _clear_bss:
178         move.l  %d0, (%a0)+                     /* Clear each word */
179         cmp.l   %a0, %a1                        /* Check if at end */
180         bne     _clear_bss
181
182         /*
183          * load the current task pointer and stack
184          */
185         lea     init_thread_union, %a0
186         lea     0x2000(%a0), %sp
187
188         /*
189          *      Assember start up done, start code proper.
190          */
191         jsr     start_kernel                    /* Start Linux kernel */
192
193 _exit:
194         jmp     _exit                           /* Should never get here */
195
196 /*****************************************************************************/