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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [mpc8260/] [current/] [include/] [variant.inc] - Blame information for rev 856

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

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

powered by: WebSVN 2.1.0

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