ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5407 / CLEOPATRA / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for Feith Cleopatra 2 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 #define MEM_SIZE        0x01000000      /* Memory size 16Mb */
27
28 /*****************************************************************************/
29
30 .global _start
31 .global _rambase
32 .global _ramvec
33 .global _ramstart
34 .global _ramend
35
36 /*****************************************************************************/
37
38 .data
39
40 /*
41  *      Set up the usable of RAM stuff. Size of RAM is determined then
42  *      an initial stack set up at the end.
43  */
44 _rambase:
45 .long   0
46 _ramvec:
47 .long   0
48 _ramstart:
49 .long   0
50 _ramend:
51 .long   0
52
53 /*****************************************************************************/
54
55 .text
56
57 /*
58  *      This is the codes first entry point. This is where it all
59  *      begins...
60  */
61
62 _start:
63         nop                                     /* Filler */
64         move.w  #0x2700, %sr                    /* No interrupts */
65
66
67         /*
68          * Setup VBR here, otherwise buserror remap will not work.
69          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
70          *
71          * bkr@cut.de 19990306
72          *
73          * Note: this is because dBUG points VBR to ROM, making vectors read
74          * only, so the bus trap can't be changed. (RS)
75          */
76         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
77         movec   %a7, %VBR
78         move.l  %a7, _ramvec                    /* Set up vector addr */
79         move.l  %a7, _rambase                   /* Set up base RAM addr */
80
81         /*
82          *      Determine size of RAM, then set up initial stack.
83          */
84 /*
85  * The current version of the 5307 processor
86  * SWT does not work. Probing invalid addresses
87  * will hang the system.
88  *
89  * For now, set the memory size to 8 meg
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         /*
99          *      Enable CPU internal cache.
100          */
101         move.l  #0x01040100, %d0                /* Invalidate whole cache */
102         movec   %d0,%CACR
103         nop
104
105         /* make region ROM cachable (turn off for flash programming?) */
106         /* 0xff000000 - 0xffffffff */
107         move.l #(0xff<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_CP+ACR_WPROTECT,%d0
108         movec  %d0,%ACR0
109
110         /* make region RAM cachable */
111         /* 0x00000000 - 0x00ffffffff */
112         move.l #(0x00<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_CP,%d0
113    movec  %d0,%ACR1
114
115         move.l #(0xff<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_CP+ACR_WPROTECT,%d0
116         movec  %d0,%ACR2
117
118         move.l #(0x00<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_CP,%d0
119    movec  %d0,%ACR3
120  
121         /* Enable cache */
122         move.l  #0xa4098400, %d0                /* Write buffer, dflt precise */
123         movec   %d0,%CACR
124         nop
125
126
127 #ifdef CONFIG_ROMFS_FS
128         /*
129          *      Move ROM filesystem above bss :-)
130          */
131         lea.l   _sbss, %a0                      /* Get start of bss */
132         lea.l   _ebss, %a1                      /* Set up destination  */
133         move.l  %a0, %a2                        /* Copy of bss start */
134
135         move.l  8(%a0), %d0                     /* Get size of ROMFS */
136         addq.l  #8, %d0                         /* Allow for rounding */
137         and.l   #0xfffffffc, %d0                /* Whole words */
138
139         add.l   %d0, %a0                        /* Copy from end */
140         add.l   %d0, %a1                        /* Copy from end */
141         move.l  %a1, _ramstart                  /* Set start of ram */
142
143 _copy_romfs:
144         move.l  -(%a0), %d0                     /* Copy dword */
145         move.l  %d0, -(%a1)
146         cmp.l   %a0, %a2                        /* Check if at end */
147         bne     _copy_romfs
148
149 #else /* CONFIG_ROMFS_FS */
150         lea.l   _ebss, %a1
151         move.l  %a1, _ramstart
152 #endif /* CONFIG_ROMFS_FS */
153
154
155         /*
156          *      Zero out the bss region.
157          */
158         lea.l   _sbss, %a0                      /* Get start of bss */
159         lea.l   _ebss, %a1                      /* Get end of bss */
160         clr.l   %d0                             /* Set value */
161 _clear_bss:
162         move.l  %d0, (%a0)+                     /* Clear each word */
163         cmp.l   %a0, %a1                        /* Check if at end */
164         bne     _clear_bss
165
166         /*
167          *      Load the current task pointer and stack.
168          */
169         lea     init_thread_union, %a0
170         lea     0x2000(%a0), %sp
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 /*****************************************************************************/