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

4.104.114.84.95
Last change on this file since bb7bef4e was bb7bef4e, checked in by Eric Norum <WENorum@…>, on 10/26/04 at 14:12:06

Remove environ common declaration -- it broke newlib.

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[acc25ee]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
[e831de8]8 *  http://www.rtems.com/license/LICENSE.
[acc25ee]9 *
10 *  $Id$
11 *
12 */
13
[b7768c55]14#include <rtems/asm.h>
[cd35cf9]15#include <rtems/score/cpu.h>
[acc25ee]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
[64f8ae4]30
[acc25ee]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
[6128a4a]37#endif
38
39/*
[acc25ee]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
[6128a4a]43 * of the regs is:
[acc25ee]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 *
[95273a6]50 *   The Prep boot loader insure that the MMU is currently off...
51 *
[acc25ee]52 */
[6128a4a]53
[acc25ee]54        mr      r31,r3                  /* save parameters */
55        mr      r30,r4
56        mr      r29,r5
57        mr      r28,r6
58        mr      r27,r7
[95273a6]59        /*
60         * Make sure we have nothing in BATS and TLB
61         */
62        bl      clear_bats
63        bl      flush_tlbs
[acc25ee]64/*
[9a23bf64]65 * Use the first pair of BAT registers to map the 1st 256MB
[6128a4a]66 * of RAM to KERNELBASE.
[acc25ee]67 */
68        lis     r11,KERNELBASE@h
[9a23bf64]69        ori     r11,r11,0x1ffe          /* set up BAT registers for 604 */
[acc25ee]70        li      r8,2                    /* R/W access */
[95273a6]71        isync
[acc25ee]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/*
[6128a4a]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
[7d5077c]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
[6128a4a]83 * Till Straumann <strauman@SLAC.Stanford.EDU> for hunting it and suggesting
[7d5077c]84 * the appropriate code.
[acc25ee]85 */
[6128a4a]86
[acc25ee]87enter_C_code:
88        bl      MMUon
[64f8ae4]89        bl  __eabi      /* setup EABI and SYSV environment */
[acc25ee]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
[6128a4a]98        mr      r7,r27
[acc25ee]99        bl      save_boot_params
[7d5077c]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         */
[15c48f4c]109        lis     r5,environ@ha
110        la      r5,environ@l(r5)        /* environp */
111        li      r4, 0                   /* argv */
112        li      r3, 0                   /* argc */
[acc25ee]113        bl      boot_card
114        bl      _return_to_ppcbug
[6128a4a]115
[acc25ee]116        .globl  MMUon
117        .type   MMUon,@function
[6128a4a]118MMUon:
[acc25ee]119        mfmsr   r0
[df49c60]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
[acc25ee]122        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
[df49c60]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
[acc25ee]127        mflr    r11
128        mtsrr0  r11
129        mtsrr1  r0
130        SYNC
131        rfi
[6128a4a]132
[acc25ee]133        .globl  MMUoff
134        .type   MMUoff,@function
[6128a4a]135MMUoff:
[acc25ee]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
[6128a4a]154        bctr
[95273a6]155
[6128a4a]156/*
[95273a6]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.
[6128a4a]162 *  -- Cort
[95273a6]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
[6128a4a]172        mtspr   DBAT0L,r20
[95273a6]173        mtspr   DBAT1U,r20
174        mtspr   DBAT1L,r20
175        mtspr   DBAT2U,r20
[6128a4a]176        mtspr   DBAT2L,r20
[95273a6]177        mtspr   DBAT3U,r20
178        mtspr   DBAT3L,r20
[6128a4a]1791:
[95273a6]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
[6128a4a]188        SYNC
[95273a6]189        blr
190
191flush_tlbs:
192        lis     r20, 0x1000
1931:      addic.  r20, r20, -0x1000
194        tlbie   r20
[69ed59f]195        bgt     1b
[95273a6]196        sync
197        blr
Note: See TracBrowser for help on using the repository browser.