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

4.104.114.84.95
Last change on this file since a77cd066 was e831de8, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:38

2003-09-04 Joel Sherrill <joel@…>

  • bootloader/bootldr.h, bootloader/em86.c, bootloader/em86real.S, bootloader/exception.S, bootloader/head.S, bootloader/lib.c, bootloader/misc.c, bootloader/mm.c, bootloader/pci.c, clock/p_clock.c, console/console.c, console/consoleIo.h, console/inch.c, console/keyboard.h, console/polled_io.c, include/bsp.h, irq/i8259.c, irq/irq.c, irq/irq.h, irq/irq_asm.S, irq/irq_init.c, motorola/motorola.c, motorola/motorola.h, openpic/openpic.c, openpic/openpic.h, pci/pci.c, residual/residual.c, start/start.S, startup/bspstart.c, vectors/vectors.h, vectors/vectors_init.c: URL for license changed.
  • 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 <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               
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        ori     r11,r11,0x1ffe          /* set up BAT registers for 604 */
71        li      r8,2                    /* R/W access */
72        isync
73        mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
74        mtspr   DBAT0U,r11              /* bit in upper BAT register */
75        mtspr   IBAT0L,r8
76        mtspr   IBAT0U,r11
77        isync
78
79/*
80 * we now have the 1st 256M of ram mapped with the bats. We are still
81 * running on the bootloader stack and cannot switch to an RTEMS allocated
82 * init stack before copying the residual data that may have been set just after
83 * rtems_end address. This bug has been experienced on MVME2304. Thank to
84 * Till Straumann <strauman@SLAC.Stanford.EDU> for hunting it and suggesting
85 * the appropriate code.
86 */
87       
88enter_C_code:
89        bl      MMUon
90        bl  __eabi      /* setup EABI and SYSV environment */
91        bl      zero_bss
92        /*
93         * restore prep boot params
94         */
95        mr      r3,r31
96        mr      r4,r30
97        mr      r5,r29
98        mr      r6,r28
99        mr      r7,r27
100        bl      save_boot_params
101        /*
102         * stack = &__rtems_end + 4096
103         */
104        addis   r9,r0, __rtems_end+(4096-CPU_MINIMUM_STACK_FRAME_SIZE)@ha
105        addi    r9,r9, __rtems_end+(4096-CPU_MINIMUM_STACK_FRAME_SIZE)@l
106        mr      r1, r9
107        /*
108         * We are know in a environment that is totally independent from bootloader setup.
109         */
110        lis     r5,environ@ha
111        la      r5,environ@l(r5)        /* environp */
112        li      r4, 0                   /* argv */
113        li      r3, 0                   /* argc */
114        bl      boot_card
115        bl      _return_to_ppcbug
116       
117        .globl  MMUon
118        .type   MMUon,@function
119MMUon: 
120        mfmsr   r0
121#if (PPC_HAS_FPU == 0)
122        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
123        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
124#else
125        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
126        xori    r0, r0, MSR_EE | MSR_IP | MSR_FE0 | MSR_FE1
127#endif
128        mflr    r11
129        mtsrr0  r11
130        mtsrr1  r0
131        SYNC
132        rfi
133       
134        .globl  MMUoff
135        .type   MMUoff,@function
136MMUoff:
137        mfmsr   r0
138        ori     r0,r0,MSR_IR| MSR_DR | MSR_IP
139        mflr    r11
140        xori    r0,r0,MSR_IR|MSR_DR
141        mtsrr0  r11
142        mtsrr1  r0
143        SYNC
144        rfi
145
146        .globl  _return_to_ppcbug
147        .type   _return_to_ppcbug,@function
148
149       
150_return_to_ppcbug:
151        mflr    r30
152        bl      MMUoff
153        MONITOR_ENTER
154        bl      MMUon
155        mtctr   r30
156        bctr   
157
158/*
159 * An undocumented "feature" of 604e requires that the v bit
160 * be cleared before changing BAT values.
161 *
162 * Also, newer IBM firmware does not clear bat3 and 4 so
163 * this makes sure it's done.
164 *  -- Cort
165 */
166clear_bats:
167        li      r20,0
168        mfspr   r9,PVR
169        rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
170        cmpwi   r9, 1
171        SYNC
172        beq     1f
173        mtspr   DBAT0U,r20
174        mtspr   DBAT0L,r20     
175        mtspr   DBAT1U,r20
176        mtspr   DBAT1L,r20
177        mtspr   DBAT2U,r20
178        mtspr   DBAT2L,r20     
179        mtspr   DBAT3U,r20
180        mtspr   DBAT3L,r20
1811:     
182        mtspr   IBAT0U,r20
183        mtspr   IBAT0L,r20
184        mtspr   IBAT1U,r20
185        mtspr   IBAT1L,r20
186        mtspr   IBAT2U,r20
187        mtspr   IBAT2L,r20
188        mtspr   IBAT3U,r20
189        mtspr   IBAT3L,r20
190        SYNC   
191        blr
192
193flush_tlbs:
194        lis     r20, 0x1000
1951:      addic.  r20, r20, -0x1000
196        tlbie   r20
197        bgt     1b
198        sync
199        blr
200       
201
202        .comm   environ,4,4
Note: See TracBrowser for help on using the repository browser.