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

4.104.114.84.95
Last change on this file since df49c60 was df49c60, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/00 at 15:00:15

Merged from 4.5.0-beta3a

  • Property mode set to 100644
File size: 3.5 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.OARcorp.com/rtems/license.html.
9 *
10 *  $Id$
11 *
12 */
13
14#include <libcpu/cpu.h>
15#include <libcpu/io.h>
16#include <rtems/score/targopts.h>
17#include <rtems/score/cpu.h>
18#include "asm.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         * Make sure we have nothing in BATS and TLB
63         */
64        bl      clear_bats
65        bl      flush_tlbs
66/*
67 * Use the first pair of BAT registers to map the 1st 64MB
68 * of RAM to KERNELBASE.
69 */
70        lis     r11,KERNELBASE@h
71        ori     r11,r11,0x7fe           /* set up BAT registers for 604 */
72        li      r8,2                    /* R/W access */
73        isync
74        mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
75        mtspr   DBAT0U,r11              /* bit in upper BAT register */
76        mtspr   IBAT0L,r8
77        mtspr   IBAT0U,r11
78        isync
79
80/*
81 * we now have the 1st 64M of ram mapped with the bats.
82 */
83       
84enter_C_code:
85        bl      MMUon
86        /*
87         * stack = &__rtems_end + 4096
88         */
89        addis   r9,r0, __rtems_end+(4096-CPU_MINIMUM_STACK_FRAME_SIZE)@ha
90        addi    r9,r9, __rtems_end+(4096-CPU_MINIMUM_STACK_FRAME_SIZE)@l
91        mr      r1, r9
92        bl      zero_bss
93        /*
94         * restore prep boot params
95         */
96        mr      r3,r31
97        mr      r4,r30
98        mr      r5,r29
99        mr      r6,r28
100        mr      r7,r27
101        bl      save_boot_params
102        bl      boot_card
103        bl      _return_to_ppcbug
104       
105        .globl  MMUon
106        .type   MMUon,@function
107MMUon: 
108        mfmsr   r0
109#if (PPC_HAS_FPU == 0)
110        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
111        xori    r0, r0, MSR_EE | MSR_IP | MSR_FP
112#else
113        ori     r0,r0, MSR_IP | MSR_RI | MSR_IR | MSR_DR | MSR_EE | MSR_FE0 | MSR_FE1 | MSR_FP
114        xori    r0, r0, MSR_EE | MSR_IP | MSR_FE0 | MSR_FE1
115#endif
116        mflr    r11
117        mtsrr0  r11
118        mtsrr1  r0
119        SYNC
120        rfi
121       
122        .globl  MMUoff
123        .type   MMUoff,@function
124MMUoff:
125        mfmsr   r0
126        ori     r0,r0,MSR_IR| MSR_DR | MSR_IP
127        mflr    r11
128        xori    r0,r0,MSR_IR|MSR_DR
129        mtsrr0  r11
130        mtsrr1  r0
131        SYNC
132        rfi
133
134        .globl  _return_to_ppcbug
135        .type   _return_to_ppcbug,@function
136
137       
138_return_to_ppcbug:
139        mflr    r30
140        bl      MMUoff
141        MONITOR_ENTER
142        bl      MMUon
143        mtctr   r30
144        bctr   
145
146/*
147 * An undocumented "feature" of 604e requires that the v bit
148 * be cleared before changing BAT values.
149 *
150 * Also, newer IBM firmware does not clear bat3 and 4 so
151 * this makes sure it's done.
152 *  -- Cort
153 */
154clear_bats:
155        li      r20,0
156        mfspr   r9,PVR
157        rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
158        cmpwi   r9, 1
159        SYNC
160        beq     1f
161        mtspr   DBAT0U,r20
162        mtspr   DBAT0L,r20     
163        mtspr   DBAT1U,r20
164        mtspr   DBAT1L,r20
165        mtspr   DBAT2U,r20
166        mtspr   DBAT2L,r20     
167        mtspr   DBAT3U,r20
168        mtspr   DBAT3L,r20
1691:     
170        mtspr   IBAT0U,r20
171        mtspr   IBAT0L,r20
172        mtspr   IBAT1U,r20
173        mtspr   IBAT1L,r20
174        mtspr   IBAT2U,r20
175        mtspr   IBAT2L,r20
176        mtspr   IBAT3U,r20
177        mtspr   IBAT3L,r20
178        SYNC   
179        blr
180
181flush_tlbs:
182        lis     r20, 0x1000
1831:      addic.  r20, r20, -0x1000
184        tlbie   r20
185        blt     1b
186        sync
187        blr
188       
Note: See TracBrowser for help on using the repository browser.