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

Subversion Repositories openrisc_me

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

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
##      PPC40x 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, gthomas
47
## Date:        2000-08-27
48
## Purpose:     MPCxxx family definitions.
49
## Description: This file contains various definitions and macros that are
50
##              useful for writing assembly code for the PPC40x CPU family.
51
## Usage:
52
##              #include 
53
##              ...
54
##
55
##
56
######DESCRIPTIONEND####
57
##
58
##=============================================================================
59
 
60
#include 
61
 
62
#undef CYG_MSR_COMMON
63
#define CYG_MSR_COMMON (MSR_ME | MSR_RI)
64
 
65
#include 
66
#include 
67
 
68
##-----------------------------------------------------------------------------
69
## PPC40x defined vectors
70
 
71
## Special code to handle the various timers which generate non-standard
72
## interrupts.  There are really three VSRs here, each 0x10 apart.
73
        .macro  timer_vector name
74
        .p2align 8
75
        .globl  __exception_\name
76
__exception_\name:
77
        # Variable timer interrupt
78
        mtspr   SPRG1,r3                     # stash some work registers away
79
        mtspr   SPRG2,r4
80
        li      r4,0x1000                    # vector offset
81
        b       0f
82
        # Fixed timer interrupt
83
        mtspr   SPRG1,r3                     # stash some work registers away
84
        mtspr   SPRG2,r4
85
        li      r4,0x1010                    # vector offset
86
        b       0f
87
        # Watchdog timer interrupt
88
        mtspr   SPRG1,r3                     # stash some work registers away
89
        mtspr   SPRG2,r4
90
        li      r4,0x1020                    # vector offset
91
0:      mtspr   SPRG3,r5
92
        lwi     r3,hal_vsr_table+(0x1000>>6) # table base
93
        lwz     r3,0(r3)                     # address of vsr
94
        mflr    r5                           # save link register
95
        mtlr    r3                           # put vsr address into it
96
        mr      r3,r4                        # original vector
97
        mfcr    r4                           # stash CR
98
        blr                                  # go to common code
99
        .endm
100
 
101
        .macro hal_extra_vectors
102
        timer_vector            ppc40x_timers
103
        exception_vector        data_TLB_miss
104
        exception_vector        instr_TLB_miss
105
        exception_vector        reserved_01300
106
        exception_vector        reserved_01400
107
        exception_vector        reserved_01500
108
        exception_vector        reserved_01600
109
        exception_vector        reserved_01700
110
        exception_vector        reserved_01800
111
        exception_vector        reserved_01900
112
        exception_vector        reserved_01A00
113
        exception_vector        reserved_01B00
114
        exception_vector        reserved_01C00
115
        exception_vector        reserved_01D00
116
        exception_vector        reserved_01E00
117
        exception_vector        reserved_01F00
118
        exception_vector        ppc40x_debug
119
        .endm
120
 
121
##-----------------------------------------------------------------------------
122
## PPC40x CPU initialization
123
##
124
## Initialize CPU to a post-reset state, ensuring the ground doesn''t
125
## shift under us while we try to set things up.
126
 
127
        .macro hal_cpu_init
128
        # Set up MSR (disable MMU for now)
129
        lwi     r3,(CYG_MSR & ~(MSR_IR | MSR_DR))
130
        sync
131
        mfmsr   r4
132
        mtmsr   r3
133
        sync
134
        .endm
135
 
136
##-----------------------------------------------------------------------------
137
## PPC40x monitor initialization
138
 
139
#ifndef CYGPKG_HAL_PPC_MON_DEFINED
140
 
141
#if     defined(CYG_HAL_STARTUP_ROM) ||                 \
142
        (       defined(CYG_HAL_STARTUP_RAM) &&         \
143
                !defined(CYGSEM_HAL_USE_ROM_MONITOR))
144
 
145
        .macro  hal_mon_init
146
#ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS
147
        # If we are starting up from ROM and want vectors in RAM
148
        # or we are starting in RAM and NOT using a ROM monitor,
149
        # copy exception handler code to 0.
150
        lwi     r3,rom_vectors          # r3 = rom start
151
        lwi     r4,0                    # r4 = ram start
152
        lwi     r5,rom_vectors_end      # r5 = rom end
153
        cmplw   r3,r5                   # skip if no vectors
154
        beq     2f
155
 
156
        subi    r3,r3,4
157
        subi    r4,r4,4
158
        subi    r5,r5,4
159
1:
160
        lwzu    r0,4(r3)                # get word from ROM
161
        stwu    r0,4(r4)                # store in RAM
162
        cmplw   r3,r5                   # compare
163
        blt     1b                      # loop if not yet done
164
2:
165
 
166
        # Ensure that the vectors will come from 0x0000
167
        lwi     r4,0
168
        mtspr   SPR_EVPR,r4
169
#endif
170
 
171
        # Next initialize the VSR table. This happens whether the
172
        # vectors were copied to RAM or not.
173
 
174
        # First fill with exception handlers
175
        lwi     r3,cyg_hal_default_exception_vsr
176
        lwi     r4,hal_vsr_table
177
        subi    r4,r4,4
178
        li      r5,CYGNUM_HAL_VSR_COUNT
179
1:      stwu    r3,4(r4)
180
        subi    r5,r5,1
181
        cmpwi   r5,0
182
        bne     1b
183
 
184
        # Then fill in the special vectors
185
        lwi     r3,cyg_hal_default_interrupt_vsr
186
        lwi     r4,hal_vsr_table
187
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
188
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
189
        stw     r3,CYGNUM_HAL_VECTOR_TIMERS*4(r4)
190
        .endm
191
 
192
#elif defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR)
193
 
194
        # Initialize the VSR table entries
195
        # We only take control of the interrupt vectors,
196
        # the rest are left to the ROM for now...
197
 
198
        .macro  hal_mon_init
199
        lwi     r3,cyg_hal_default_interrupt_vsr
200
        lwi     r4,hal_vsr_table
201
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
202
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
203
        stw     r3,CYGNUM_HAL_VECTOR_TIMERS*4(r4)
204
        .endm
205
 
206
 
207
#else
208
 
209
        .macro  hal_mon_init
210
 
211
        .endm
212
 
213
#endif
214
 
215
 
216
#define CYGPKG_HAL_PPC_MON_DEFINED
217
 
218
#endif // CYGPKG_HAL_PPC_MON_DEFINED
219
 
220
##-----------------------------------------------------------------------------
221
## PPC40x exception state handling
222
        .macro  hal_variant_save regs
223
        .endm
224
 
225
        .macro  hal_variant_load regs
226
        .endm
227
 
228
##-----------------------------------------------------------------------------
229
## Indicate that the ISR tables are defined in variant.S
230
 
231
#define CYG_HAL_PPC_ISR_TABLES_DEFINED
232
 
233
##-----------------------------------------------------------------------------
234
## MPC4xx interrupt handling.
235
 
236
## Decode the EXISR appropriately
237
 
238
#define CYGPKG_HAL_POWERPC_INTC_DEFINED
239
        # decode the interrupt
240
        # the interrupt vector will be 0x500 or 0x10x0
241
        # 0x0500 = external, must be decoded via EXISR
242
        # 0x10X0 = timer, X is the timer type
243
        # r3 used as scratch
244
        .macro  hal_intc_decode dreg,state
245
        lwz     \dreg,CYGARC_PPCREG_VECTOR(\state) # retrieve vector number,
246
        extrwi. \dreg,\dreg,1,19                # isolate bit 19
247
        beq     0f                              # timer interrupt = 1
248
        lwz     \dreg,CYGARC_PPCREG_VECTOR(\state) # retrieve vector number,
249
        extrwi  \dreg,\dreg,2,26                # isolate bits 26-27
250
        addi    \dreg,\dreg,CYGNUM_HAL_INTERRUPT_VAR_TIMER # FIXME
251
        b       1f
252
0:      mfdcr   r3,DCR_EXISR                    # Interrupt status register
253
        lwi     \dreg,0x8FF0001F                # significant bits
254
        and     \dreg,\dreg,r3
255
        cntlzw  r3,\dreg                        # find highest "1" bit
256
        slwi    r3,r3,2
257
        lwi     \dreg,EXISR_TAB                 # convert bit # to signal #
258
        lwzx    \dreg,\dreg,r3
259
1:      stw     \dreg,CYGARC_PPCREG_VECTOR(\state) # update vector in state frame.
260
        slwi    \dreg,\dreg,2                   # convert to byte offset.
261
        .endm
262
 
263
 
264
#------------------------------------------------------------------------------
265
#endif // ifndef CYGONCE_HAL_VARIANT_INC
266
# end of variant.inc

powered by: WebSVN 2.1.0

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