OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [powerpc/] [shared/] [start/] [start.S] - Blame information for rev 846

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: start.S,v 1.2 2001-09-27 12:01:07 chris Exp $
11
 *
12
 */
13
 
14
#include 
15
#include 
16
#include 
17
#include 
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
 
84
enter_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
107
MMUon:
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
124
MMUoff:
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
 */
154
clear_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
169
1:
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
 
181
flush_tlbs:
182
        lis     r20, 0x1000
183
1:      addic.  r20, r20, -0x1000
184
        tlbie   r20
185
        blt     1b
186
        sync
187
        blr
188
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.