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

Subversion Repositories openrisc

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

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
##      MPC8260 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
## Copyright (C) 2002 Gary Thomas
15
##
16
## eCos is free software; you can redistribute it and/or modify it under
17
## the terms of the GNU General Public License as published by the Free
18
## Software Foundation; either version 2 or (at your option) any later version.
19
##
20
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
## for more details.
24
##
25
## You should have received a copy of the GNU General Public License along
26
## with eCos; if not, write to the Free Software Foundation, Inc.,
27
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
##
29
## As a special exception, if other files instantiate templates or use macros
30
## or inline functions from this file, or you compile this file and link it
31
## with other works to produce a work based on this file, this file does not
32
## by itself cause the resulting work to be covered by the GNU General Public
33
## License. However the source code for this file must still be made available
34
## in accordance with section (3) of the GNU General Public License.
35
##
36
## This exception does not invalidate any other reasons why a work based on
37
## this file might be covered by the GNU General Public License.
38
##
39
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
## at http://sources.redhat.com/ecos/ecos-license/
41
## -------------------------------------------
42
#####ECOSGPLCOPYRIGHTEND####
43
##=============================================================================
44
#######DESCRIPTIONBEGIN####
45
##
46
## Author(s):   pfine
47
## Contributors:jskov
48
## Date:        2001-12-12
49
## Purpose:     MPC8260 family definitions.
50
## Description: This file contains various definitions and macros that are
51
##              useful for writing assembly code for the MPC8260 CPU family.
52
## Usage:
53
##              #include 
54
##              ...
55
##
56
##
57
######DESCRIPTIONEND####
58
##
59
##=============================================================================
60
 
61
#include 
62
 
63
#include 
64
 
65
##-----------------------------------------------------------------------------
66
#ifndef SPRG0
67
#define SPRG0 272     # Counter Register
68
#endif
69
#ifndef SPRG1
70
#define SPRG1 273     # Counter Register
71
#endif
72
#ifndef SPRG2
73
#define SPRG2 274     # Counter Register
74
#endif
75
#ifndef SPRG3
76
#define SPRG3 275     # Counter Register
77
#endif
78
 
79
##-----------------------------------------------------------------------------
80
## MPC8260 defined vectors
81
        .macro mpc8260_vector name
82
        .p2align 8
83
        .globl  __exception_\name
84
__exception_\name:
85
        #-------------------------------------------#
86
        # save off registers used in vector routine #
87
        #-------------------------------------------#
88
 
89
        mtspr SPRG3,r3    # save r3
90
        mfspr r3,8
91
        mtspr SPRG2,r3    # save LR
92
 
93
        #-----------------------------------------------------------------------
94
        # Load the vector offset value in SPRG0 for handler shifted down 8 bits.
95
        #-----------------------------------------------------------------------
96
 
97
        #addi  r3,r0,0x0010
98
        addi  r3,r0,__exception_\name@l #load low 16 bits of exception vector
99
        srawi r3,r3,8                   #shift right by 8
100
        mtspr SPRG0,r3
101
 
102
        #---------------------------------------------------------
103
        # load link register in order to jump to physical address
104
        #---------------------------------------------------------
105
 
106
        addis    r3,0,handler@h
107
        ori      r3,r3,handler@l
108
        mtspr    8,r3
109
        bclr     20,0                 # jump unconditionally to address in Link
110
                                      # Register (LR)
111
        .endm
112
 
113
        .macro  infinite_loop_vector name
114
        .p2align 8
115
        .globl  __exception_\name
116
__exception_\name:
117
        mflr    r0
118
        lwi     r1,0x04700010
119
        lwi     r2,0x12345678
120
        stw     r0,0(r1)
121
        lwi     r3,__exception_\name
122
        stw     r3,4(r1)
123
        stw     r2,8(r1)
124
1:
125
        nop
126
        nop
127
        nop
128
        b 1b
129
        .endm
130
 
131
        .macro hal_reserved_vector_00000
132
        infinite_loop_vector    reserved
133
        .endm
134
#define CYG_HAL_RESERVED_VECTOR_00000
135
 
136
        .macro hal_extra_vectors
137
        infinite_loop_vector        itbl_miss
138
        infinite_loop_vector        dltlb_miss
139
        infinite_loop_vector        dstlb_miss
140
        infinite_loop_vector        iaddr_brkpt
141
        infinite_loop_vector        sys_mngmnt_intrpt
142
#if 0
143
        exception_vector        reserved_01500
144
        exception_vector        reserved_01600
145
        exception_vector        reserved_01700
146
        exception_vector        reserved_01800
147
        exception_vector        reserved_01900
148
        exception_vector        reserved_01a00
149
        exception_vector        reserved_01b00
150
        exception_vector        reserved_01c00
151
        exception_vector        reserved_01d00
152
        exception_vector        reserved_01e00
153
        exception_vector        reserved_01f00
154
        exception_vector        reserved_02000
155
        exception_vector        reserved_02100
156
        exception_vector        reserved_02200
157
        exception_vector        reserved_02300
158
        exception_vector        reserved_02400
159
        exception_vector        reserved_02500
160
        exception_vector        reserved_02600
161
        exception_vector        reserved_02700
162
        exception_vector        reserved_02800
163
        exception_vector        reserved_02900
164
        exception_vector        reserved_02a00
165
        exception_vector        reserved_02b00
166
        exception_vector        reserved_02c00
167
        exception_vector        reserved_02d00
168
        exception_vector        reserved_02e00
169
        exception_vector        reserved_02f00
170
#endif
171
        .endm
172
 
173
#if 0
174
## MPC8260 defined vectors
175
# infinite_loop_vector macro
176
 
177
        .macro  infinite_loop_vector name
178
        .p2align 8
179
        .globl  __exception_\name
180
__exception_\name:
181
        nop
182
        nop
183
        nop
184
        b __exception_\name
185
        .endm
186
 
187
        .macro hal_extra_vectors
188
        # MPC8260 vectors
189
        mpc8260_vector        instruction_tlb_miss
190
        mpc8260_vector        data_load_tlb_miss
191
        mpc8260_vector        data_store_tlb_miss
192
        mpc8260_vector        instruction_addr_brkpt
193
        mpc8260_vector        system_mngmnt_intrpt
194
        .endm
195
#endif
196
 
197
##-----------------------------------------------------------------------------
198
## MPC8260 CPU initialization
199
##
200
## Initialize CPU to a post-reset state, ensuring the ground doesn''t
201
## shift under us while we try to set things up.
202
 
203
        .macro hal_cpu_init
204
        # Set up MSR (disable MMU for now)
205
        lwi     r3,(CYG_MSR & ~(MSR_IR | MSR_DR))
206
        sync
207
        mtmsr   r3
208
        sync
209
        .endm
210
 
211
##-----------------------------------------------------------------------------
212
## MPC8260 monitor initialization
213
 
214
#ifndef CYGPKG_HAL_PPC_MON_DEFINED
215
 
216
#if     defined(CYG_HAL_STARTUP_ROM) ||                 \
217
        (       defined(CYG_HAL_STARTUP_RAM) &&         \
218
                !defined(CYGSEM_HAL_USE_ROM_MONITOR))
219
 
220
        .macro  hal_mon_init
221
#ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS
222
        # If we are starting up from ROM and want vectors in RAM
223
        # or we are starting in RAM and NOT using a ROM monitor,
224
        # copy exception handler code to 0.
225
        lwi     r3,rom_vectors          # r3 = rom start
226
        lwi     r4,0                    # r4 = ram start
227
        lwi     r5,rom_vectors_end      # r5 = rom end
228
        cmplw   r3,r5                   # skip if no vectors
229
        beq     2f
230
 
231
        subi    r3,r3,4
232
        subi    r4,r4,4
233
        subi    r5,r5,4
234
1:
235
        lwzu    r0,4(r3)                # get word from ROM
236
        stwu    r0,4(r4)                # store in RAM
237
        cmplw   r3,r5                   # compare
238
        blt     1b                      # loop if not yet done
239
2:
240
 
241
        # Next initialize the VSR table. This happens whether the
242
        # vectors were copied to RAM or not.
243
 
244
        # First fill with exception handlers
245
        lwi     r3,cyg_hal_default_exception_vsr
246
        lwi     r4,hal_vsr_table
247
        subi    r4,r4,4
248
        li      r5,CYGNUM_HAL_VSR_COUNT
249
1:      stwu    r3,4(r4)
250
        subi    r5,r5,1
251
        cmpwi   r5,0
252
        bne     1b
253
#endif
254
 
255
        # Then fill in the special vectors
256
        lwi     r3,cyg_hal_default_interrupt_vsr
257
        lwi     r4,hal_vsr_table
258
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
259
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
260
        .endm
261
 
262
#elif defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR)
263
 
264
        # Initialize the VSR table entries
265
        # We only take control of the interrupt vectors,
266
        # the rest are left to the ROM for now...
267
 
268
        .macro  hal_mon_init
269
        lwi     r3,cyg_hal_default_interrupt_vsr
270
        lwi     r4,hal_vsr_table
271
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
272
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
273
        .endm
274
 
275
 
276
#else
277
 
278
        .macro  hal_mon_init
279
 
280
        .endm
281
 
282
#endif
283
 
284
 
285
#define CYGPKG_HAL_PPC_MON_DEFINED
286
 
287
#endif // CYGPKG_HAL_PPC_MON_DEFINED
288
 
289
##-----------------------------------------------------------------------------
290
## MPC8260 exception state handling
291
        .macro  hal_variant_save regs
292
        .endm
293
 
294
        .macro  hal_variant_load regs
295
        .endm
296
 
297
##-----------------------------------------------------------------------------
298
## Indicate that the ISR tables are defined in variant.S
299
 
300
#define CYG_HAL_PPC_ISR_TABLES_DEFINED
301
 
302
##-----------------------------------------------------------------------------
303
## MPC8260 interrupt handling.
304
 
305
#ifndef CYGPKG_HAL_POWERPC_INTC_DEFINED
306
 
307
## First level decoding of MPC8xx SIU interrupt controller.
308
 
309
        # decode the interrupt
310
        .macro  hal_intc_decode dreg,state
311
#if 0
312
        lis     r24,0x0471                      # load register base
313
        lbz     r24,CYGARC_REG_IMM_SIVEC(r24)      # if
314
        //lwi     \dreg,0x00ffff1c
315
        //stw     r24,0(\dreg)
316
        stw     r24,0(0)
317
#endif
318
        lwz     \dreg,CYGARC_PPCREG_VECTOR(\state) # retrieve vector number,
319
        rlwinm. \dreg,\dreg,22,31,31            # isolate bit 21
320
        //stw     \dreg,CYGARC_PPCREG_VECTOR(\state) # update vector in state frame.
321
        //slwi    \dreg,\dreg,2                   # convert to byte offset.
322
#if 1
323
        beq     0f                              # done if decrementer (vec 0)
324
        lis     \dreg,0x0471                    # load register base
325
        lbz     \dreg,CYGARC_REG_IMM_SIVEC(\dreg)      # if external, get SIU vector
326
        srwi    \dreg,\dreg,2                   # shift SIVEC value by 2
327
        //addi    \dreg,\dreg,1                   # Skip decrementer vector
328
0:      stw     \dreg,CYGARC_PPCREG_VECTOR(\state) # update vector in state frame.
329
        slwi    \dreg,\dreg,2                   # convert to byte offset.
330
#endif
331
        .endm
332
 
333
 
334
#define CYGPKG_HAL_POWERPC_INTC_DEFINED
335
#endif // CYGPKG_HAL_POWERPC_INTC_DEFINED
336
#------------------------------------------------------------------------------
337
#endif // ifndef CYGONCE_HAL_VARIANT_INC
338
# end of variant.inc

powered by: WebSVN 2.1.0

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