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

4.104.115
Last change on this file since ac7af4a was ac7af4a, checked in by Ralf Corsepius <ralf.corsepius@…>, on Nov 30, 2009 at 4:37:44 AM

Whitespace removal.

  • Property mode set to 100644
File size: 3.8 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#include <libcpu/bat.h>
21
22#define SYNC \
23        sync; \
24        isync
25
26#define KERNELBASE      0x0
27#define MEM256MB        0x10000000
28
29#define MONITOR_ENTER                   \
30        mfmsr   r10             ;       \
31        ori     r10,r10,MSR_IP  ;       \
32        mtmsr   r10             ;       \
33        li      r10,0x63        ;       \
34        sc
35
36
37        .text
38        .globl  __rtems_entry_point
39        .type   __rtems_entry_point,@function
40__rtems_entry_point:
41#ifdef DEBUG_EARLY_START
42        MONITOR_ENTER
43#endif
44
45/*
46 * PREP
47 * This is jumped to on prep systems right after the kernel is relocated
48 * to its proper place in memory by the boot loader.  The expected layout
49 * of the regs is:
50 *   r3: ptr to residual data
51 *   r4: initrd_start or if no initrd then 0
52 *   r5: initrd_end - unused if r4 is 0
53 *   r6: Start of command line string
54 *   r7: End of command line string
55 *
56 *   The Prep boot loader insure that the MMU is currently off...
57 *
58 */
59
60        mr      r31,r3                  /* save parameters */
61        mr      r30,r4
62        mr      r29,r5
63        mr      r28,r6
64        mr      r27,r7
65        /*
66         * Make sure we have nothing in BATS and TLB
67         */
68        bl      CPU_clear_bats_early
69        bl      flush_tlbs
70/*
71 * Use the first pair of BAT registers to map the 1st 256MB
72 * of RAM to KERNELBASE.
73 */
74        lis     r11,KERNELBASE@h
75        ori     r11,r11,0x1ffe          /* set up BAT0 registers for 604+ */
76        li      r8,2                    /* R/W access */
77        isync
78        mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
79        mtspr   DBAT0U,r11              /* bit in upper BAT register */
80        mtspr   IBAT0L,r8
81        mtspr   IBAT0U,r11
82        isync
83/*
84 * Use the 2nd pair of BAT registers to map the 2nd 256MB
85 * of RAM to 0x10000000. <SKF>
86 */
87        lis     r11,MEM256MB@h
88        ori     r11,r11,0x1ffe          /* set up BAT1 registers for 604+ */
89        lis     r8,MEM256MB@h
90        ori     r8,r8,2
91        isync
92        mtspr   DBAT1L,r8               /* N.B. 6xx (not 601) have valid */
93        mtspr   DBAT1U,r11              /* bit in upper BAT register */
94        mtspr   IBAT1L,r8
95        mtspr   IBAT1U,r11
96        isync
97
98/*
99 * we now have the two 256M of ram mapped with the bats. We are still
100 * running on the bootloader stack and cannot switch to an RTEMS allocated
101 * init stack before copying the residual data that may have been set just
102 * after rtems_end address. This bug has been experienced on MVME2304. Thank
103 * to Till Straumann <strauman@SLAC.Stanford.EDU> for hunting it and
104 * suggesting the appropriate code.
105 */
106
107enter_C_code:
108        bl      MMUon
109        bl  __eabi      /* setup EABI and SYSV environment */
110        bl      zero_bss
111        /*
112         * restore prep boot params
113         */
114        mr      r3,r31
115        mr      r4,r30
116        mr      r5,r29
117        mr      r6,r28
118        mr      r7,r27
119        bl      save_boot_params
120        /*
121         * stack = &__rtems_end + 4096
122         */
123        addis   r9,r0, __stack-PPC_MINIMUM_STACK_FRAME_SIZE@ha
124        addi    r9,r9, __stack-PPC_MINIMUM_STACK_FRAME_SIZE@l
125        mr      r1, r9
126        /*
127         * We are know in a environment that is totally independent from bootloader setup.
128         */
129    /* pass result of 'save_boot_params' to 'boot_card' in R3 */
130        bl      boot_card
131        bl      _return_to_ppcbug
132
133        .globl  MMUon
134        .type   MMUon,@function
135MMUon:
136        mfmsr   r0
137        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
138#if (PPC_HAS_FPU == 0)
139        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
140#else
141        xori    r0, r0, MSR_EE | MSR_IP | MSR_FE0 | MSR_FE1
142#endif
143        mflr    r11
144        mtsrr0  r11
145        mtsrr1  r0
146        SYNC
147        rfi
148
149        .globl  MMUoff
150        .type   MMUoff,@function
151MMUoff:
152        mfmsr   r0
153        ori     r0,r0,MSR_IR| MSR_DR | MSR_IP
154        mflr    r11
155        xori    r0,r0,MSR_IR|MSR_DR
156        mtsrr0  r11
157        mtsrr1  r0
158        SYNC
159        rfi
160
161        .globl  _return_to_ppcbug
162        .type   _return_to_ppcbug,@function
163
164
165_return_to_ppcbug:
166        mflr    r30
167        bl      MMUoff
168        MONITOR_ENTER
169        bl      MMUon
170        mtctr   r30
171        bctr
172
173flush_tlbs:
174        lis     r20, 0x1000
1751:      addic.  r20, r20, -0x1000
176        tlbie   r20
177        bgt     1b
178        sync
179        blr
Note: See TracBrowser for help on using the repository browser.