This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / m68knommu / platform / 5272 / CANCam / crt0_ram.S
1 /*****************************************************************************/
2
3 /*
4  *      crt0_ram.S -- startup code for Feith CANCan board.
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  *      Feith ColdFire CANCam, 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 #define MEM_SIZE  0x04000000      /* Memory size 64Mb */
28
29
30 /*****************************************************************************/
31
32 .global _start
33 .global _rambase
34 .global _ramvec
35 .global _ramstart
36 .global _ramend
37
38 /*****************************************************************************/
39
40 .data
41
42 /*
43  *      Set up the usable of RAM stuff. Size of RAM is determined then
44  *      an initial stack set up at the end.
45  */
46 _rambase:
47 .long   0
48 _ramvec:
49 .long   0
50 _ramstart:
51 .long   0
52 _ramend:
53 .long   0
54
55 /*****************************************************************************/
56
57 .text
58
59 /*
60  *      This is the codes first entry point. This is where it all
61  *      begins...
62  */
63
64 _start:
65         nop                                     /* Filler */
66         move.w  #0x2700, %sr                    /* No interrupts */
67
68         /*
69          * Setup VBR here, otherwise buserror remap will not work.
70          * if dBug was active before (on my SBC with dBug 1.1 of Dec 16 1996)
71          *
72          * bkr@cut.de 19990306
73          *
74          * Note: this is because dBUG points VBR to ROM, making vectors read
75          * only, so the bus trap can't be changed. (RS)
76          */
77         move.l  #VBR_BASE, %a7                  /* Note VBR can't be read */
78         movec   %a7, %VBR
79         move.l  %a7, _ramvec                    /* Set up vector addr */
80         move.l  %a7, _rambase                   /* Set up base RAM addr */
81
82
83         /*
84          *      Set memory size.
85          */
86         move.l  #MEM_SIZE, %a0
87
88         move.l  %a0, %d0                        /* Mem end addr is in a0 */
89         move.l  %d0, %sp                        /* Set up initial stack ptr */
90         move.l  %d0, _ramend                    /* Set end ram addr */
91
92         /*
93          *      Enable CPU internal cache.
94          */
95         move.l  #0x01000000, %d0                /* Invalidate cache cmd */
96         movec   %d0, %CACR                      /* Invalidate cache */
97         move.l  #0x80000100, %d0                /* Setup cache mask */
98         movec   %d0, %CACR                      /* Enable cache */
99         nop
100
101 #ifdef CONFIG_ROMFS_FS
102         /*
103          *      Move ROM filesystem above bss :-)
104          */
105         lea.l   _sbss, %a0                      /* Get start of bss */
106         lea.l   _ebss, %a1                      /* Set up destination  */
107         move.l  %a0, %a2                        /* Copy of bss start */
108
109         move.l  8(%a0), %d0                     /* Get size of ROMFS */
110         addq.l  #8, %d0                         /* Allow for rounding */
111         and.l   #0xfffffffc, %d0                /* Whole words */
112
113         add.l   %d0, %a0                        /* Copy from end */
114         add.l   %d0, %a1                        /* Copy from end */
115         move.l  %a1, _ramstart                  /* Set start of ram */
116
117 _copy_romfs:
118         move.l  -(%a0), %d0                     /* Copy dword */
119         move.l  %d0, -(%a1)
120         cmp.l   %a0, %a2                        /* Check if at end */
121         bne     _copy_romfs
122
123 #else /* CONFIG_ROMFS_FS */
124         lea.l   _ebss, %a1
125         move.l  %a1, _ramstart
126 #endif /* CONFIG_ROMFS_FS */
127
128
129         /*
130          *      Zero out the bss region.
131          */
132         lea.l   _sbss, %a0                      /* Get start of bss */
133         lea.l   _ebss, %a1                      /* Get end of bss */
134         clr.l   %d0                             /* Set value */
135 _clear_bss:
136         move.l  %d0, (%a0)+                     /* Clear each word */
137         cmp.l   %a0, %a1                        /* Check if at end */
138         bne     _clear_bss
139
140         /*
141          *      Load the current thread pointer and stack.
142          */
143         lea     init_thread_union, %a0
144         lea     0x2000(%a0), %sp
145
146         /*
147          *      Assember start up done, start code proper.
148          */
149         jsr     start_kernel                    /* Start Linux kernel */
150
151 _exit:
152         jmp     _exit                           /* Should never get here */
153
154 /*****************************************************************************/