ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5272 / senTec / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5272 ColdFire based boards.
5  *
6  *      (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
7  *      (C) Copyright 2000, Lineo (www.lineo.com).
8  */
9
10 /*****************************************************************************/
11
12 #include <linux/config.h>
13 #include <linux/threads.h>
14 #include <linux/linkage.h>
15 #include <asm/segment.h>
16 #include <asm/coldfire.h>
17 #include <asm/mcfsim.h>
18
19 /*****************************************************************************/
20
21 /*
22  *      senTec COBRA5272 board, chip select and memory setup.
23  */
24
25 #define MEM_BASE        0x00000000      /* Memory base at address 0 */
26 #define VBR_BASE        MEM_BASE        /* Vector address */
27
28 #if defined(CONFIG_RAM16MB)
29 #define MEM_SIZE        0x01000000      /* Memory size 16Mb */
30 #elif defined(CONFIG_RAM8MB)
31 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
32 #else
33 #define MEM_SIZE        0x00400000      /* Memory size 4Mb */
34 #endif
35
36 /*****************************************************************************/
37
38 .global _start
39 .global _rambase
40 .global _ramvec
41 .global _ramstart
42 .global _ramend
43
44 /*****************************************************************************/
45
46 .data
47
48 /*
49  *      Set up the usable of RAM stuff. Size of RAM is determined then
50  *      an initial stack set up at the end.
51  */
52 _rambase:
53 .long   0
54 _ramvec:
55 .long   0
56 _ramstart:
57 .long   0
58 _ramend:
59 .long   0
60
61 /*****************************************************************************/
62
63 .text
64
65 /*
66  *      This is the codes first entry point. This is where it all
67  *      begins...
68  */
69
70 _start:
71         nop                                     /* Filler */
72         move.w  #0x2700, %sr                    /* No interrupts */
73
74         /*
75          * Setup VBR here, otherwise buserror remap will not work.
76          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
77          *
78          * bkr@cut.de 19990306
79          *
80          * Note: this is because dBUG points VBR to ROM, making vectors read
81          * only, so the bus trap can't be changed. (RS)
82          */
83         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
84         movec   %a7, %VBR
85         move.l  %a7, _ramvec                    /* Set up vector addr */
86         move.l  %a7, _rambase                   /* Set up base RAM addr */
87
88
89         /*
90          *      Set memory size.
91          */
92         move.l  #MEM_SIZE, %a0
93
94         move.l  %a0, %d0                        /* Mem end addr is in a0 */
95         move.l  %d0, %sp                        /* Set up initial stack ptr */
96         move.l  %d0, _ramend                    /* Set end ram addr */
97
98         /*
99          *      Enable CPU internal cache.
100          */
101         move.l  #0x01000000, %d0                /* Invalidate cache cmd */
102         movec   %d0, %CACR                      /* Invalidate cache */
103         move.l  #0x80000100, %d0                /* Setup cache mask */
104         movec   %d0, %CACR                      /* Enable cache */
105
106 #ifdef CONFIG_ROMFS_FS
107         /*
108          *      Move ROM filesystem above bss :-)
109          */
110         lea.l   _sbss, %a0                      /* Get start of bss */
111         lea.l   _ebss, %a1                      /* Set up destination  */
112         move.l  %a0, %a2                        /* Copy of bss start */
113
114         move.l  8(%a0), %d0                     /* Get size of ROMFS */
115         addq.l  #8, %d0                         /* Allow for rounding */
116         and.l   #0xfffffffc, %d0                /* Whole words */
117
118         add.l   %d0, %a0                        /* Copy from end */
119         add.l   %d0, %a1                        /* Copy from end */
120         move.l  %a1, _ramstart                  /* Set start of ram */
121
122 _copy_romfs:
123         move.l  -(%a0), %d0                     /* Copy dword */
124         move.l  %d0, -(%a1)
125         cmp.l   %a0, %a2                        /* Check if at end */
126         bne     _copy_romfs
127
128 #else /* CONFIG_ROMFS_FS */
129         lea.l   _ebss, %a1
130         move.l  %a1, _ramstart
131 #endif /* CONFIG_ROMFS_FS */
132
133
134         /*
135          *      Zero out the bss region.
136          */
137         lea.l   _sbss, %a0                      /* Get start of bss */
138         lea.l   _ebss, %a1                      /* Get end of bss */
139         clr.l   %d0                             /* Set value */
140 _clear_bss:
141         move.l  %d0, (%a0)+                     /* Clear each word */
142         cmp.l   %a0, %a1                        /* Check if at end */
143         bne     _clear_bss
144
145         /*
146          *      Load the current thread pointer and stack.
147          */
148         lea     init_thread_union, %a0
149         lea     0x2000(%a0), %sp
150
151         /*
152          *      Assember start up done, start code proper.
153          */
154         jsr     start_kernel                    /* Start Linux kernel */
155
156 _exit:
157         jmp     _exit                           /* Should never get here */
158
159 /*****************************************************************************/