38c2b6d5592abb9067bbfb141ce17c0b6a57c377
[linux-flexiantxendom0-3.2.10.git] / arch / m68knommu / platform / 5407 / MOTOROLA / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for Motorola 5407 eval board.
5  *
6  *      (C) Copyright 1999-2002, Greg Ungerer (gerg@snapgear.com).
7  *      (C) Copyright 2000, Lineo (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
18 /*****************************************************************************/
19
20 /*
21  *      Board setup info.
22  */
23 #define MEM_BASE        0x00000000      /* Memory base at address 0 */
24 #define VBR_BASE        MEM_BASE        /* Vector address */
25
26 #define MEM_SIZE        0x02000000      /* Memory size 32 */
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 as per eval board (really dBUG does this).
68          *      These settings must match it.
69          */
70         move.l  #VBR_BASE, %a0                  /* Note VBR can't be read */
71         movec   %a0, %VBR
72         move.l  %a0, _ramvec                    /* Set up vector addr */
73         move.l  %a0, _rambase                   /* Set up base RAM addr */
74
75
76         /*
77          *      Determine size of RAM, then set up initial stack.
78          */
79         move.l  #MEM_SIZE, %a0
80
81         move.l  %a0, %d0                        /* Mem end addr is in a0 */
82         move.l  %d0, %sp                        /* Set up initial stack ptr */
83         move.l  %d0, _ramend                    /* Set end ram addr */
84
85
86         /*
87          *      Enable CPU internal cache.
88          */
89         move.l  #0x01040100, %d0                /* Invalidate whole cache */
90         movec   %d0,%CACR
91         nop
92         move.l  #0x000fc000, %d0                /* Set SDRAM cached only */
93         movec   %d0, %ACR0
94         move.l  #0x00000000, %d0                /* No other regions cached */
95         movec   %d0, %ACR1
96         move.l  #0x000fc000, %d0                /* Set SDRAM cached only */
97         movec   %d0, %ACR2
98         move.l  #0x00000000, %d0                /* No other regions cached */
99         movec   %d0, %ACR3
100
101         /* Enable cache */
102         move.l  #0xa4098400, %d0                /* Write buffer, dflt precise */
103         movec   %d0,%CACR
104         nop
105
106         /*
107          *      Move ROM filesystem above bss :-)
108          */
109         lea.l   _sbss, %a0                      /* Get start of bss */
110         lea.l   _ebss, %a1                      /* Set up destination  */
111         move.l  %a0, %a2                        /* Copy of bss start */
112
113         move.l  8(%a0), %d0                     /* Get size of ROMFS */
114         addq.l  #8, %d0                         /* Allow for rounding */
115         and.l   #0xfffffffc, %d0                /* Whole words */
116
117         add.l   %d0, %a0                        /* Copy from end */
118         add.l   %d0, %a1                        /* Copy from end */
119         move.l  %a1, _ramstart                  /* Set start of ram */
120
121 _copy_romfs:
122         move.l  -(%a0), %d0                     /* Copy dword */
123         move.l  %d0, -(%a1)
124         cmp.l   %a0, %a2                        /* Check if at end */
125         bne     _copy_romfs
126
127         /*
128          *      Zero out the bss region.
129          */
130         lea.l   _sbss, %a0                      /* Get start of bss */
131         lea.l   _ebss, %a1                      /* Get end of bss */
132         clr.l   %d0                             /* Set value */
133 _clear_bss:
134         move.l  %d0, (%a0)+                     /* Clear each word */
135         cmp.l   %a0, %a1                        /* Check if at end */
136         bne     _clear_bss
137
138         /*
139          *      Load the current task pointer and stack.
140          */
141         lea     init_thread_union, %a0
142         lea     0x2000(%a0), %sp
143
144         /*
145          *      Assember start up done, start code proper.
146          */
147         jsr     start_kernel                    /* Start Linux kernel */
148
149 _exit:
150         jmp     _exit                           /* Should never get here */
151
152 /*****************************************************************************/