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

5
Last change on this file since 5d44981c was 814bd6e3, checked in by Sebastian Huber <sebastian.huber@…>, on 07/12/16 at 08:02:40

bsps/powerpc: Fix AltiVec? enable

There must be an isync after the mtmsr to ensure that the AltiVec? is
enabled for subsequent instructions.

  • 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 the file LICENSE in this distribution or at
8 *  http://www.rtems.org/license/LICENSE.
9 *
10 */
11
12#include <rtems/asm.h>
13#include <rtems/score/cpu.h>
14#include <rtems/powerpc/powerpc.h>
15
16#include <libcpu/io.h>
17#include <libcpu/bat.h>
18#include <bspopts.h>
19
20#define SYNC \
21        sync; \
22        isync
23
24#define KERNELBASE      0x0
25
26#define MONITOR_ENTER                   \
27        mfmsr   r10             ;       \
28        ori     r10,r10,MSR_IP  ;       \
29        mtmsr   r10             ;       \
30        li      r10,0x63        ;       \
31        sc
32
33        .text
34        .globl  __rtems_entry_point
35        .type   __rtems_entry_point,@function
36__rtems_entry_point:
37#ifdef DEBUG_EARLY_START
38        MONITOR_ENTER
39#endif
40
41/*
42 * PREP
43 * This is jumped to on prep systems right after the kernel is relocated
44 * to its proper place in memory by the boot loader.  The expected layout
45 * of the regs is:
46 *   r3: ptr to residual data
47 *   r4: initrd_start or if no initrd then 0
48 *   r5: initrd_end - unused if r4 is 0
49 *   r6: Start of command line string
50 *   r7: End of command line string
51 *
52 *   The Prep boot loader insure that the MMU is currently off...
53 *
54 */
55
56        mr      r31,r3                  /* save parameters */
57        mr      r30,r4
58        mr      r29,r5
59        mr      r28,r6
60        mr      r27,r7
61
62#ifdef __ALTIVEC__
63        /* enable altivec; gcc may use it! */
64        mfmsr r0
65        oris  r0, r0, (1<<(31-16-6))
66        mtmsr r0
67        isync
68        /*
69         * set vscr and vrsave to known values
70         */
71        li    r0, 0
72        mtvrsave r0
73        vxor   0,0,0
74        mtvscr 0
75#endif
76
77        /*
78         * Make sure we have nothing in BATS and TLB
79         */
80        bl      CPU_clear_bats_early
81        bl      flush_tlbs
82/*
83 * Use the first pair of BAT registers to map the 1st 256MB
84 * of RAM to KERNELBASE.
85 */
86        lis     r11,KERNELBASE@h
87/* set up BAT registers for 604 */
88        ori     r11,r11,0x1ffe
89        li      r8,2                    /* R/W access */
90        isync
91        mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
92        mtspr   DBAT0U,r11              /* bit in upper BAT register */
93        mtspr   IBAT0L,r8
94        mtspr   IBAT0U,r11
95        isync
96
97/*
98 * we now have the 1st 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 after
101 * rtems_end address. This bug has been experienced on MVME2304. Thank to
102 * Till Straumann <strauman@SLAC.Stanford.EDU> for hunting it and suggesting
103 * 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, __stack-PPC_MINIMUM_STACK_FRAME_SIZE@ha
123        addi    r9,r9, __stack-PPC_MINIMUM_STACK_FRAME_SIZE@l
124        /*
125         * align initial stack
126         * (we hope that the bootloader stack was 16-byte aligned
127         * or we haven't used altivec yet...)
128         */
129        li   r0, (CPU_STACK_ALIGNMENT-1)
130        andc r1, r9, r0
131        /*
132         * Tag TOS with a NULL (terminator for stack dump)
133         */
134        li   r0, 0
135        stw  r0, 0(r1)
136       
137        /*
138         * We are now in a environment that is totally independent from
139         * bootloader setup.
140         */
141    /* pass result of 'save_boot_params' to 'boot_card' in R3 */
142        bl      boot_card
143        bl      _return_to_ppcbug
144
145        .globl  MMUon
146        .type   MMUon,@function
147MMUon:
148        mfmsr   r0
149        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
150#if (PPC_HAS_FPU == 0)
151        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
152#else
153        xori    r0, r0, MSR_EE | MSR_IP | MSR_FE0 | MSR_FE1
154#endif
155        mflr    r11
156        mtsrr0  r11
157        mtsrr1  r0
158        SYNC
159        rfi
160
161        .globl  MMUoff
162        .type   MMUoff,@function
163MMUoff:
164        mfmsr   r0
165        ori     r0,r0,MSR_IR| MSR_DR | MSR_IP
166        mflr    r11
167        xori    r0,r0,MSR_IR|MSR_DR
168        mtsrr0  r11
169        mtsrr1  r0
170        SYNC
171        rfi
172
173        .globl  _return_to_ppcbug
174        .type   _return_to_ppcbug,@function
175
176_return_to_ppcbug:
177        mflr    r30
178        bl      MMUoff
179        MONITOR_ENTER
180        bl      MMUon
181        mtctr   r30
182        bctr
183
184flush_tlbs:
185        lis     r20, 0x1000
1861:      addic.  r20, r20, -0x1000
187        tlbie   r20
188        bgt     1b
189        sync
190        blr
Note: See TracBrowser for help on using the repository browser.