source: rtems/c/src/lib/libbsp/powerpc/shared/start/start.S @ ec58ea04

4.104.114.84.95
Last change on this file since ec58ea04 was ec58ea04, checked in by Till Straumann <strauman@…>, on 11/03/05 at 01:57:27

2005-11-02 straumanatslacdotstanford.edu

  • mvme5500/start/start.S, shared/start/start.S, shared/startup/bspstart.c: moved assembly code to C; setdbat now supports high bats on 7450 CPUs; added argument checking to setdbat; added getdbat; moved early initialization code (clear_bats) from BSP to libcpu (CPU_clear_bats_early)
  • 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 *  The license and distribution terms for this file may be
7 *  found in found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id$
11 *
12 */
13
14#include <rtems/asm.h>
15#include <rtems/score/cpu.h>
16#include <rtems/powerpc/powerpc.h>
17
18#include <libcpu/io.h>
19#include <libcpu/bat.h>
20#include <bspopts.h>
21
22#define SYNC \
23        sync; \
24        isync
25
26#define KERNELBASE      0x0
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        .text
36        .globl  __rtems_entry_point
37        .type   __rtems_entry_point,@function
38__rtems_entry_point:
39#ifdef DEBUG_EARLY_START
40        MONITOR_ENTER
41#endif
42
43/*
44 * PREP
45 * This is jumped to on prep systems right after the kernel is relocated
46 * to its proper place in memory by the boot loader.  The expected layout
47 * of the regs is:
48 *   r3: ptr to residual data
49 *   r4: initrd_start or if no initrd then 0
50 *   r5: initrd_end - unused if r4 is 0
51 *   r6: Start of command line string
52 *   r7: End of command line string
53 *
54 *   The Prep boot loader insure that the MMU is currently off...
55 *
56 */
57
58        mr      r31,r3                  /* save parameters */
59        mr      r30,r4
60        mr      r29,r5
61        mr      r28,r6
62        mr      r27,r7
63        /*
64         * Make sure we have nothing in BATS and TLB
65         */
66        bl      CPU_clear_bats_early
67        bl      flush_tlbs
68/*
69 * Use the first pair of BAT registers to map the 1st 256MB
70 * of RAM to KERNELBASE.
71 */
72        lis     r11,KERNELBASE@h
73/* set up BAT registers for 604 */
74        ori     r11,r11,0x1ffe         
75        li      r8,2                    /* R/W access */
76        isync
77#if defined(mvme2100)
78        /* BSP_vme_config() wants to use BAT0, this board will use the
79         * available BAT1 to map RAM.
80         */
81        mtspr   DBAT1L,r8               /* N.B. 6xx (not 601) have valid */
82        mtspr   DBAT1U,r11              /* bit in upper BAT register */
83        mtspr   IBAT1L,r8
84        mtspr   IBAT1U,r11
85#else
86        mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
87        mtspr   DBAT0U,r11              /* bit in upper BAT register */
88        mtspr   IBAT0L,r8
89        mtspr   IBAT0U,r11
90#endif
91        isync
92
93/*
94 * we now have the 1st 256M of ram mapped with the bats. We are still
95 * running on the bootloader stack and cannot switch to an RTEMS allocated
96 * init stack before copying the residual data that may have been set just after
97 * rtems_end address. This bug has been experienced on MVME2304. Thank to
98 * Till Straumann <strauman@SLAC.Stanford.EDU> for hunting it and suggesting
99 * the appropriate code.
100 */
101
102enter_C_code:
103        bl      MMUon
104        bl      __eabi  /* setup EABI and SYSV environment */
105        bl      zero_bss
106        /*
107         * restore prep boot params
108         */
109        mr      r3,r31
110        mr      r4,r30
111        mr      r5,r29
112        mr      r6,r28
113        mr      r7,r27
114        bl      save_boot_params
115        /*
116         * stack = &__rtems_end + 4096
117         */
118        addis   r9,r0, __rtems_end+(4096-PPC_MINIMUM_STACK_FRAME_SIZE)@ha
119        addi    r9,r9, __rtems_end+(4096-PPC_MINIMUM_STACK_FRAME_SIZE)@l
120        mr      r1, r9
121        /*
122         * We are now in a environment that is totally independent from
123         * bootloader setup.
124         */
125        lis     r5,environ@ha
126        la      r5,environ@l(r5)        /* environp */
127        li      r4, 0                   /* argv */
128        li      r3, 0                   /* argc */
129        bl      boot_card
130        bl      _return_to_ppcbug
131
132        .globl  MMUon
133        .type   MMUon,@function
134MMUon:
135        mfmsr   r0
136        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
137#if defined(mvme2100)
138        /* Data addr translation is broken for the mvme2100, disable it here */
139        xori    r0,r0, MSR_DR
140#endif
141#if (PPC_HAS_FPU == 0)
142        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
143#else
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_return_to_ppcbug:
168        mflr    r30
169        bl      MMUoff
170        MONITOR_ENTER
171        bl      MMUon
172        mtctr   r30
173        bctr
174
175flush_tlbs:
176        lis     r20, 0x1000
1771:      addic.  r20, r20, -0x1000
178        tlbie   r20
179        bgt     1b
180        sync
181        blr
Note: See TracBrowser for help on using the repository browser.