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

4.104.114.84.95
Last change on this file since e79a1947 was e79a1947, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 10, 2004 at 11:51:17 PM

2004-11-10 Richard Campbell <richard.campbell@…>

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