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

4.104.114.84.95
Last change on this file since a097bd1 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

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