ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5307 / CLEOPATRA / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for Feith CLEOPATRA board.
5  *
6  *      (C) Copyright 2001, Roman Wagner.
7  *
8  *      1999/02/24 Modified for the 5307 processor David W. Miller
9  */
10
11 /*****************************************************************************/
12
13 #include "linux/autoconf.h"
14 #include "asm/coldfire.h"
15 #include "asm/mcfsim.h"
16
17 /*****************************************************************************/
18
19 /*
20  *      Feith CLEOPATRA board, chip select and memory setup.
21 */
22
23 #define MEM_BASE        0x00000000      /* Memory base at address 0 */
24 #define VBR_BASE        MEM_BASE        /* Vector address */
25
26 #if defined(CONFIG_RAM16MB)
27 #define MEM_SIZE        0x01000000      /* Memory size 16Mb */
28 #else
29 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
30 #endif
31
32 /*****************************************************************************/
33
34 .global _start
35 .global _rambase
36 .global _ramvec
37 .global _ramstart
38 .global _ramend
39
40 /*****************************************************************************/
41
42 .data
43
44 /*
45  *      Set up the usable of RAM stuff. Size of RAM is determined then
46  *      an initial stack set up at the end.
47  */
48 _rambase:
49 .long   0
50 _ramvec:
51 .long   0
52 _ramstart:
53 .long   0
54 _ramend:
55 .long   0
56
57 /*****************************************************************************/
58
59 .text
60
61 /*
62  *      This is the codes first entry point. This is where it all
63  *      begins...
64  */
65
66 _start:
67         nop                                     /* Filler */
68         move.w  #0x2700, %sr                    /* No interrupts */
69
70
71         /*
72          * Setup VBR here, otherwise buserror remap will not work.
73          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
74          *
75          * bkr@cut.de 19990306
76          *
77          * Note: this is because dBUG points VBR to ROM, making vectors read
78          * only, so the bus trap can't be changed. (RS)
79          */
80         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
81         movec   %a7, %VBR
82         move.l  %a7, _ramvec                    /* Set up vector addr */
83         move.l  %a7, _rambase                   /* Set up base RAM addr */
84
85
86         /*
87          *      Determine size of RAM, then set up initial stack.
88          */
89 /*
90  * The current version of the 5307 processor
91  * SWT does not work. Probing invalid addresses
92  * will hang the system.
93  *
94  * For now, set the memory size to 8 meg
95  */
96         move.l  #MEM_SIZE, %a0
97
98         move.l  %a0, %d0                        /* Mem end addr is in a0 */
99         move.l  %d0, %sp                        /* Set up initial stack ptr */
100         move.l  %d0, _ramend                    /* Set end ram addr */
101
102
103         /* now fire off the cache, remember to invalidate it first */
104         movl  #0,%d0
105         movc  %d0,%CACR
106         nop
107         movc  %d0,%CACR                         /* cache is off */
108
109         movl  #CACR_CINVA,%d0                   /* invalidate whole cache */
110         movc  %d0,%CACR
111         nop
112         movc  %d0,%CACR
113         nop                                    
114
115         /* make region ROM cachable (turn off for flash programming?) */
116         /* 0xff000000 - 0xffffffff */
117         movl #(0xff<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_WBACK+ACR_WPROTECT,%d0
118         movc  %d0,%ACR0
119
120         /* make region RAM cachable *
121         /* 0x00000000 - 0x00ffffffff */
122         movl #(0x00<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_WBACK,%d0
123         movc  %d0,%ACR1
124
125         /* make the default cache mode precise */
126         movl  #CACR_EC+CACR_ESB+CACR_DCM_OFF_PRE,%d0 /* enable cache */
127         movc  %d0,%CACR
128
129
130 #ifdef CONFIG_ROMFS_FS
131         /*
132          *      Move ROM filesystem above bss :-)
133          */
134         lea.l   _sbss, %a0                      /* Get start of bss */
135         lea.l   _ebss, %a1                      /* Set up destination  */
136         move.l  %a0, %a2                        /* Copy of bss start */
137
138         move.l  8(%a0), %d0                     /* Get size of ROMFS */
139         addq.l  #8, %d0                         /* Allow for rounding */
140         and.l   #0xfffffffc, %d0                /* Whole words */
141
142         add.l   %d0, %a0                        /* Copy from end */
143         add.l   %d0, %a1                        /* Copy from end */
144         move.l  %a1, _ramstart                  /* Set start of ram */
145
146 _copy_romfs:
147         move.l  -(%a0), %d0                     /* Copy dword */
148         move.l  %d0, -(%a1)
149         cmp.l   %a0, %a2                        /* Check if at end */
150         bne     _copy_romfs
151
152 #else /* CONFIG_ROMFS_FS */
153         lea.l   _ebss, %a1
154         move.l  %a1, _ramstart
155 #endif /* CONFIG_ROMFS_FS */
156
157
158         /*
159          *      Zero out the bss region.
160          */
161         lea.l   _sbss, %a0                      /* Get start of bss */
162         lea.l   _ebss, %a1                      /* Get end of bss */
163         clr.l   %d0                             /* Set value */
164 _clear_bss:
165         move.l  %d0, (%a0)+                     /* Clear each word */
166         cmp.l   %a0, %a1                        /* Check if at end */
167         bne     _clear_bss
168
169         /*
170          * load the current task pointer and stack
171          */
172         lea     init_thread_union, %a0
173         lea     0x2000(%a0), %sp
174
175         /*
176          *      Assember start up done, start code proper.
177          */
178         jsr     start_kernel                    /* Start Linux kernel */
179
180 _exit:
181         jmp     _exit                           /* Should never get here */
182
183 /*****************************************************************************/