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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [mpc8xx/] [v2_0/] [include/] [variant.inc] - Blame information for rev 27

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

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_VARIANT_INC
2
#define CYGONCE_HAL_VARIANT_INC
3
##=============================================================================
4
##
5
##      variant.inc
6
##
7
##      MPC8xx family assembler header file
8
##
9
##=============================================================================
10
#####ECOSGPLCOPYRIGHTBEGIN####
11
## -------------------------------------------
12
## This file is part of eCos, the Embedded Configurable Operating System.
13
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
##
15
## eCos is free software; you can redistribute it and/or modify it under
16
## the terms of the GNU General Public License as published by the Free
17
## Software Foundation; either version 2 or (at your option) any later version.
18
##
19
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
## for more details.
23
##
24
## You should have received a copy of the GNU General Public License along
25
## with eCos; if not, write to the Free Software Foundation, Inc.,
26
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
##
28
## As a special exception, if other files instantiate templates or use macros
29
## or inline functions from this file, or you compile this file and link it
30
## with other works to produce a work based on this file, this file does not
31
## by itself cause the resulting work to be covered by the GNU General Public
32
## License. However the source code for this file must still be made available
33
## in accordance with section (3) of the GNU General Public License.
34
##
35
## This exception does not invalidate any other reasons why a work based on
36
## this file might be covered by the GNU General Public License.
37
##
38
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
## at http://sources.redhat.com/ecos/ecos-license/
40
## -------------------------------------------
41
#####ECOSGPLCOPYRIGHTEND####
42
##=============================================================================
43
#######DESCRIPTIONBEGIN####
44
##
45
## Author(s):   jskov
46
## Contributors:jskov
47
## Date:        2000-02-04
48
## Purpose:     MPC8xx family definitions.
49
## Description: This file contains various definitions and macros that are
50
##              useful for writing assembly code for the MPC8xx CPU family.
51
## Usage:
52
##              #include 
53
##              ...
54
##
55
##
56
######DESCRIPTIONEND####
57
##
58
##=============================================================================
59
 
60
#include 
61
 
62
#include 
63
 
64
##-----------------------------------------------------------------------------
65
## MPC8xx defined vectors
66
 
67
        .macro hal_extra_vectors
68
        # MPC8xx vectors
69
        exception_vector        software_emu
70
        exception_vector        instruction_tlb_miss
71
        exception_vector        data_tlb_miss
72
        exception_vector        instruction_tlb_error
73
        exception_vector        data_tlb_error
74
        exception_vector        reserved_01500
75
        exception_vector        reserved_01600
76
        exception_vector        reserved_01700
77
        exception_vector        reserved_01800
78
        exception_vector        reserved_01900
79
        exception_vector        reserved_01A00
80
        exception_vector        reserved_01B00
81
        exception_vector        data_breakpoint
82
        exception_vector        instruction_breakpoint
83
        exception_vector        peripheral_breakpoint
84
        exception_vector        NMI_port
85
        .endm
86
 
87
##-----------------------------------------------------------------------------
88
## MPC8xx CPU initialization
89
##
90
## Initialize CPU to a post-reset state, ensuring the ground doesn''t
91
## shift under us while we try to set things up.
92
 
93
        .macro hal_cpu_init
94
        # Disable special MPC8xx "development support" which
95
        # suppresses trace exceptions. The CPU seems to hang, not
96
        # executing from offset 0x1e00(?) as expected.
97
        lwi     r3,0x00000007
98
        mtspr   ICTRL,r3
99
        li      r3,0
100
        mtspr   DER, r3
101
 
102
        # Disable caches
103
        lwi     r3,CYGARC_REG_DC_CMD_CD
104
        sync
105
        mtspr   CYGARC_REG_DC_CST,r3
106
        lwi     r3,CYGARC_REG_IC_CMD_CD
107
        isync
108
        mtspr   CYGARC_REG_IC_CST,r3
109
        isync
110
 
111
        # Default caching to off when MMU is disabled
112
        mfspr   r3,CYGARC_REG_MI_CTR
113
        oris    r3,r3,(CYGARC_REG_MI_CTR_CIDEF)@h
114
        mtspr   CYGARC_REG_MI_CTR,r3
115
        mfspr   r3,CYGARC_REG_MD_CTR
116
        oris    r3,r3,(CYGARC_REG_MD_CTR_CIDEF)@h
117
        mtspr   CYGARC_REG_MD_CTR,r3
118
 
119
        # Set up MSR (disable MMU for now)
120
        lwi     r3,(CYG_MSR & ~(MSR_IR | MSR_DR))
121
        sync
122
        mtmsr   r3
123
        sync
124
        .endm
125
 
126
##-----------------------------------------------------------------------------
127
## MPC8xx exception state handling
128
        .macro  hal_variant_save regs
129
        .endm
130
 
131
        .macro  hal_variant_load regs
132
        .endm
133
 
134
##-----------------------------------------------------------------------------
135
## MPC8xx monitor initialization
136
 
137
#ifndef CYGPKG_HAL_PPC_MON_DEFINED
138
 
139
#if     defined(CYG_HAL_STARTUP_ROM) ||                 \
140
        defined(CYG_HAL_STARTUP_ROMRAM) ||                 \
141
        (       defined(CYG_HAL_STARTUP_RAM) &&         \
142
                !defined(CYGSEM_HAL_USE_ROM_MONITOR))
143
 
144
        .macro  hal_mon_init
145
#ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS
146
        # If we are starting up from ROM and want vectors in RAM
147
        # or we are starting in RAM and NOT using a ROM monitor,
148
        # copy exception handler code to 0.
149
        lwi     r3,rom_vectors          # r3 = rom start
150
        lwi     r4,0                    # r4 = ram start
151
        lwi     r5,rom_vectors_end      # r5 = rom end
152
        cmplw   r3,r5                   # skip if no vectors
153
        beq     2f
154
 
155
        subi    r3,r3,4
156
        subi    r4,r4,4
157
        subi    r5,r5,4
158
1:
159
        lwzu    r0,4(r3)                # get word from ROM
160
        stwu    r0,4(r4)                # store in RAM
161
        cmplw   r3,r5                   # compare
162
        blt     1b                      # loop if not yet done
163
2:
164
#endif
165
 
166
        # Next initialize the VSR table. This happens whether the
167
        # vectors were copied to RAM or not.
168
 
169
        # First fill with exception handlers
170
        lwi     r3,cyg_hal_default_exception_vsr
171
        lwi     r4,hal_vsr_table
172
        subi    r4,r4,4
173
        li      r5,CYGNUM_HAL_VSR_COUNT
174
1:      stwu    r3,4(r4)
175
        subi    r5,r5,1
176
        cmpwi   r5,0
177
        bne     1b
178
 
179
        # Then fill in the special vectors
180
        lwi     r3,cyg_hal_default_interrupt_vsr
181
        lwi     r4,hal_vsr_table
182
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
183
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
184
        .endm
185
 
186
#elif defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR)
187
 
188
        # Initialize the VSR table entries
189
        # We only take control of the interrupt vectors,
190
        # the rest are left to the ROM for now...
191
 
192
        .macro  hal_mon_init
193
        lwi     r3,cyg_hal_default_interrupt_vsr
194
        lwi     r4,hal_vsr_table
195
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
196
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
197
        .endm
198
 
199
 
200
#else
201
 
202
        .macro  hal_mon_init
203
 
204
        .endm
205
 
206
#endif
207
 
208
 
209
#define CYGPKG_HAL_PPC_MON_DEFINED
210
 
211
#endif // CYGPKG_HAL_PPC_MON_DEFINED
212
 
213
 
214
 
215
 
216
##-----------------------------------------------------------------------------
217
## Indicate that the ISR tables are defined in variant.S
218
 
219
#define CYG_HAL_PPC_ISR_TABLES_DEFINED
220
 
221
##-----------------------------------------------------------------------------
222
## MPC8xx interrupt handling.
223
 
224
#ifndef CYGPKG_HAL_POWERPC_INTC_DEFINED
225
 
226
## First level decoding of MPC8xx SIU interrupt controller.
227
 
228
        # decode the interrupt
229
        .macro  hal_intc_decode dreg,state
230
        lwz     \dreg,CYGARC_PPCREG_VECTOR(\state) # retrieve vector number,
231
        rlwinm. \dreg,\dreg,22,31,31            # isolate bit 21
232
        beq     0f                              # done if decrementer (vec 0)
233
        lwi     \dreg,CYGARC_REG_IMM_SIVEC      # if external, get SIU
234
        lbz     \dreg,0(\dreg)                  # vector.
235
        srwi    \dreg,\dreg,2
236
        addi    \dreg,\dreg,1                   # Skip decrementer vector
237
0:      stw     \dreg,CYGARC_PPCREG_VECTOR(\state) # update vector in state frame.
238
        slwi    \dreg,\dreg,2                   # convert to byte offset.
239
        .endm
240
 
241
 
242
#define CYGPKG_HAL_POWERPC_INTC_DEFINED
243
#endif // CYGPKG_HAL_POWERPC_INTC_DEFINED
244
 
245
#------------------------------------------------------------------------------
246
#endif // ifndef CYGONCE_HAL_VARIANT_INC
247
# end of variant.inc

powered by: WebSVN 2.1.0

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