ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5307 / MOTOROLA / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5307C3 Cadre-III ColdFire board.
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  *      SnapGear/NETtel board memory setup.
23  */
24 #define MEM_BASE        0x00000000      /* Memory base at address 0 */
25 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
26 #define VBR_BASE        MEM_BASE        /* Vector address */
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          * Setup VBR here, otherwise buserror remap will not work.
68          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
69          *
70          * bkr@cut.de 19990306
71          *
72          * Note: this is because dBUG points VBR to ROM, making vectors read
73          * only, so the bus trap can't be changed. (RS)
74          */
75         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
76         movec   %a7, %VBR
77         move.l  %a7, _ramvec                    /* Set up vector addr */
78         move.l  %a7, _rambase                   /* Set up base RAM addr */
79
80
81         /*
82          *      Determine size of RAM, then set up initial stack.
83          */
84         move.l  #MEM_SIZE, %a0
85
86         move.l  %a0, %d0                        /* Mem end addr is in a0 */
87         move.l  %d0, %sp                        /* Set up initial stack ptr */
88         move.l  %d0, _ramend                    /* Set end ram addr */
89
90         /* make region ROM cachable (turn off for flash programming?) */
91         /* 0xff000000 - 0xffffffff */
92 #ifdef DEBUGGER_COMPATIBLE_CACHE
93         movl #(0xff<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_WTHRU+ACR_WPROTECT,%d0
94 #else
95         movl #(0xff<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_WBACK+ACR_WPROTECT,%d0
96 #endif
97         movc  %d0,%ACR0
98
99         /* make region RAM cachable *
100         /* 0x00000000 - 0x00ffffffff */
101 #ifdef DEBUGGER_COMPATIBLE_CACHE
102         movl #(0x00<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_WTHRU,%d0
103 #else
104         movl #(0x00<<ACR_BASE_POS)+(0<<ACR_MASK_POS)+ACR_ENABLE+ACR_ANY+ACR_CM_WBACK,%d0
105 #endif
106         movc  %d0,%ACR1
107
108         /* make the default cache mode precise */
109         movl  #CACR_EC+CACR_ESB+CACR_DCM_OFF_PRE,%d0 /* enable cache */
110         movc  %d0,%CACR
111         nop
112
113
114 #ifdef CONFIG_ROMFS_FS
115         /*
116          *      Move ROM filesystem above bss :-)
117          */
118         lea.l   _sbss, %a0                      /* Get start of bss */
119         lea.l   _ebss, %a1                      /* Set up destination  */
120         move.l  %a0, %a2                        /* Copy of bss start */
121
122         move.l  8(%a0), %d0                     /* Get size of ROMFS */
123         addq.l  #8, %d0                         /* Allow for rounding */
124         and.l   #0xfffffffc, %d0                /* Whole words */
125
126         add.l   %d0, %a0                        /* Copy from end */
127         add.l   %d0, %a1                        /* Copy from end */
128         move.l  %a1, _ramstart                  /* Set start of ram */
129
130 _copy_romfs:
131         move.l  -(%a0), %d0                     /* Copy dword */
132         move.l  %d0, -(%a1)
133         cmp.l   %a0, %a2                        /* Check if at end */
134         bne     _copy_romfs
135
136 #else /* CONFIG_ROMFS_FS */
137         lea.l   _ebss, %a1
138         move.l  %a1, _ramstart
139 #endif /* CONFIG_ROMFS_FS */
140
141
142         /*
143          *      Zero out the bss region.
144          */
145         lea.l   _sbss, %a0                      /* Get start of bss */
146         lea.l   _ebss, %a1                      /* Get end of bss */
147         clr.l   %d0                             /* Set value */
148 _clear_bss:
149         move.l  %d0, (%a0)+                     /* Clear each word */
150         cmp.l   %a0, %a1                        /* Check if at end */
151         bne     _clear_bss
152
153         /*
154          * load the current task pointer and stack
155          */
156         lea     init_thread_union, %a0
157         lea     0x2000(%a0), %sp
158
159         /*
160          *      Assember start up done, start code proper.
161          */
162         jsr     start_kernel                    /* Start Linux kernel */
163
164 _exit:
165         jmp     _exit                           /* Should never get here */
166
167 /*****************************************************************************/