source: rtems/c/src/lib/libbsp/powerpc/mvme5500/start/start.S @ 46a6fa91

4.104.114.84.95
Last change on this file since 46a6fa91 was 2195ccf3, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/17/05 at 04:28:21

2005-02-17 Ralf Corsepius <ralf.corsepius@…>

  • start/start.S: include <rtems/powerpc/powerpc.h>. Use PPC_MINIMUM_STACK_FRAME_SIZE instead of CPU_MINIMUM_STACK_FRAME_SIZE.
  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 *  start.S :     RTEMS entry point
3 *
4 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
5 *
6 *  S. Kate Feng <feng1@bnl.gov>, April 2004
7 *  Mapped the 2nd 256MB of RAM to support the MVME5500 boards.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *
14 */
15
16#include <rtems/asm.h>
17#include <rtems/score/cpu.h>
18#include <rtems/powerpc/powerpc.h>
19#include <libcpu/io.h>
20
21#define SYNC \
22        sync; \
23        isync
24
25#define KERNELBASE      0x0
26#define MEM256MB        0x10000000
27       
28#define MONITOR_ENTER                   \
29        mfmsr   r10             ;       \
30        ori     r10,r10,MSR_IP  ;       \
31        mtmsr   r10             ;       \
32        li      r10,0x63        ;       \
33        sc
34
35               
36        .text
37        .globl  __rtems_entry_point
38        .type   __rtems_entry_point,@function
39__rtems_entry_point:
40#ifdef DEBUG_EARLY_START
41        MONITOR_ENTER
42#endif 
43               
44/*
45 * PREP
46 * This is jumped to on prep systems right after the kernel is relocated
47 * to its proper place in memory by the boot loader.  The expected layout
48 * of the regs is:     
49 *   r3: ptr to residual data
50 *   r4: initrd_start or if no initrd then 0
51 *   r5: initrd_end - unused if r4 is 0
52 *   r6: Start of command line string
53 *   r7: End of command line string
54 *
55 *   The Prep boot loader insure that the MMU is currently off...
56 *
57 */
58       
59        mr      r31,r3                  /* save parameters */
60        mr      r30,r4
61        mr      r29,r5
62        mr      r28,r6
63        mr      r27,r7
64        /*
65         * Make sure we have nothing in BATS and TLB
66         */
67        bl      clear_bats
68        bl      flush_tlbs
69/*
70 * Use the first pair of BAT registers to map the 1st 256MB
71 * of RAM to KERNELBASE.
72 */
73        lis     r11,KERNELBASE@h
74        ori     r11,r11,0x1ffe          /* set up BAT0 registers for 604+ */
75        li      r8,2                    /* R/W access */
76        isync
77        mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
78        mtspr   DBAT0U,r11              /* bit in upper BAT register */
79        mtspr   IBAT0L,r8
80        mtspr   IBAT0U,r11
81        isync
82/*
83 * Use the 2nd pair of BAT registers to map the 2nd 256MB
84 * of RAM to 0x10000000. <SKF>
85 */
86        lis     r11,MEM256MB@h
87        ori     r11,r11,0x1ffe          /* set up BAT1 registers for 604+ */
88        lis     r8,MEM256MB@h
89        ori     r8,r8,2
90        isync
91        mtspr   DBAT1L,r8               /* N.B. 6xx (not 601) have valid */
92        mtspr   DBAT1U,r11              /* bit in upper BAT register */
93        mtspr   IBAT1L,r8
94        mtspr   IBAT1U,r11     
95        isync
96
97/*
98 * we now have the two 256M of ram mapped with the bats. We are still
99 * running on the bootloader stack and cannot switch to an RTEMS allocated
100 * init stack before copying the residual data that may have been set just
101 * after rtems_end address. This bug has been experienced on MVME2304. Thank
102 * to Till Straumann <strauman@SLAC.Stanford.EDU> for hunting it and
103 * suggesting the appropriate code.
104 */
105       
106enter_C_code:
107        bl      MMUon
108        bl  __eabi      /* setup EABI and SYSV environment */
109        bl      zero_bss
110        /*
111         * restore prep boot params
112         */
113        mr      r3,r31
114        mr      r4,r30
115        mr      r5,r29
116        mr      r6,r28
117        mr      r7,r27
118        bl      save_boot_params
119        /*
120         * stack = &__rtems_end + 4096
121         */
122        addis   r9,r0, __rtems_end+(4096-PPC_MINIMUM_STACK_FRAME_SIZE)@ha
123        addi    r9,r9, __rtems_end+(4096-PPC_MINIMUM_STACK_FRAME_SIZE)@l
124        mr      r1, r9
125        /*
126         * We are know in a environment that is totally independent from bootloader setup.
127         */
128        lis     r5,environ@ha
129        la      r5,environ@l(r5)        /* environp */
130        li      r4, 0                   /* argv */
131        li      r3, 0                   /* argc */
132        bl      boot_card
133        bl      _return_to_ppcbug
134       
135        .globl  MMUon
136        .type   MMUon,@function
137MMUon: 
138        mfmsr   r0
139#if (PPC_HAS_FPU == 0)
140        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
141        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
142#else
143        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
144        xori    r0, r0, MSR_EE | MSR_IP | MSR_FE0 | MSR_FE1
145#endif
146        mflr    r11
147        mtsrr0  r11
148        mtsrr1  r0
149        SYNC
150        rfi
151       
152        .globl  MMUoff
153        .type   MMUoff,@function
154MMUoff:
155        mfmsr   r0
156        ori     r0,r0,MSR_IR| MSR_DR | MSR_IP
157        mflr    r11
158        xori    r0,r0,MSR_IR|MSR_DR
159        mtsrr0  r11
160        mtsrr1  r0
161        SYNC
162        rfi
163
164        .globl  _return_to_ppcbug
165        .type   _return_to_ppcbug,@function
166
167       
168_return_to_ppcbug:
169        mflr    r30
170        bl      MMUoff
171        MONITOR_ENTER
172        bl      MMUon
173        mtctr   r30
174        bctr   
175
176/*
177 * An undocumented "feature" of 604e requires that the v bit
178 * be cleared before changing BAT values.
179 *
180 * Also, newer IBM firmware does not clear bat3 and 4 so
181 * this makes sure it's done.
182 *  -- Cort
183 */
184clear_bats:
185        li      r20,0
186        mfspr   r9,PVR
187        rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
188        cmpwi   r9, 1
189        SYNC
190        beq     1f
191        mtspr   DBAT0U,r20
192        mtspr   DBAT0L,r20     
193        mtspr   DBAT1U,r20
194        mtspr   DBAT1L,r20
195        mtspr   DBAT2U,r20
196        mtspr   DBAT2L,r20     
197        mtspr   DBAT3U,r20
198        mtspr   DBAT3L,r20
1991:     
200        mtspr   IBAT0U,r20
201        mtspr   IBAT0L,r20
202        mtspr   IBAT1U,r20
203        mtspr   IBAT1L,r20
204        mtspr   IBAT2U,r20
205        mtspr   IBAT2L,r20
206        mtspr   IBAT3U,r20
207        mtspr   IBAT3L,r20
208        SYNC   
209        blr
210
211flush_tlbs:
212        lis     r20, 0x1000
2131:      addic.  r20, r20, -0x1000
214        tlbie   r20
215        bgt     1b
216        sync
217        blr
Note: See TracBrowser for help on using the repository browser.