ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5272 / MOTOROLA / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for MCF5272 ColdFire based MOTOROLA 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  *      Motorola M5272C3 ColdFire eval 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 /*****************************************************************************/
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          *      Determine size of RAM, then set up initial stack.
82          */
83 #if defined(CONFIG_RAMAUTO)
84         move.l  MCF_MBAR+0x7c,%d0       /* get SDRAM address mask */
85         andi.l  #0xfffff000,%d0         /* mask out chip select options */
86         neg.l   %d0                     /* negate bits */
87 #else
88 #if defined(CONFIG_RAM16MB)
89 #define MEM_SIZE        0x01000000      /* Memory size 16Mb */
90 #elif defined(CONFIG_RAM8MB)
91 #define MEM_SIZE        0x00800000      /* Memory size 8Mb */
92 #else
93 #define MEM_SIZE        0x00400000      /* Memory size 4Mb */
94 #endif
95         /*
96          *      Set memory size.
97          */
98         move.l  #MEM_SIZE, %d0
99 #endif
100
101         move.l  %d0, %sp                        /* Set up initial stack ptr */
102         move.l  %d0, _ramend                    /* Set end ram addr */
103
104         /*
105          *      Enable CPU internal cache.
106          */
107         move.l  #0x01000000, %d0                /* Invalidate cache cmd */
108         movec   %d0, %CACR                      /* Invalidate cache */
109         move.l  #0x80000100, %d0                /* Setup cache mask */
110         movec   %d0, %CACR                      /* Enable cache */
111
112 #ifdef CONFIG_ROMFS_FS
113         /*
114          *      Move ROM filesystem above bss :-)
115          */
116         lea.l   _sbss, %a0                      /* Get start of bss */
117         lea.l   _ebss, %a1                      /* Set up destination  */
118         move.l  %a0, %a2                        /* Copy of bss start */
119
120         move.l  8(%a0), %d0                     /* Get size of ROMFS */
121         addq.l  #8, %d0                         /* Allow for rounding */
122         and.l   #0xfffffffc, %d0                /* Whole words */
123
124         add.l   %d0, %a0                        /* Copy from end */
125         add.l   %d0, %a1                        /* Copy from end */
126         move.l  %a1, _ramstart                  /* Set start of ram */
127
128 _copy_romfs:
129         move.l  -(%a0), %d0                     /* Copy dword */
130         move.l  %d0, -(%a1)
131         cmp.l   %a0, %a2                        /* Check if at end */
132         bne     _copy_romfs
133
134 #else /* CONFIG_ROMFS_FS */
135         lea.l   _ebss, %a1
136         move.l  %a1, _ramstart
137 #endif /* CONFIG_ROMFS_FS */
138
139
140         /*
141          *      Zero out the bss region.
142          */
143         lea.l   _sbss, %a0                      /* Get start of bss */
144         lea.l   _ebss, %a1                      /* Get end of bss */
145         clr.l   %d0                             /* Set value */
146 _clear_bss:
147         move.l  %d0, (%a0)+                     /* Clear each word */
148         cmp.l   %a0, %a1                        /* Check if at end */
149         bne     _clear_bss
150
151         /*
152          *      Load the current thread pointer and stack.
153          */
154         lea     init_thread_union, %a0
155         lea     0x2000(%a0), %sp
156
157         /*
158          *      Assember start up done, start code proper.
159          */
160         jsr     start_kernel                    /* Start Linux kernel */
161
162 _exit:
163         jmp     _exit                           /* Should never get here */
164
165 /*****************************************************************************/