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

Subversion Repositories openrisc

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

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
##      MPC8xxx 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, 2003 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, gthomas
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
#include    // For CYGARC_IMM_BASE
63
 
64
##-----------------------------------------------------------------------------
65
#ifndef SPRG0
66
#define SPRG0 272     # Counter Register
67
#endif
68
#ifndef SPRG1
69
#define SPRG1 273     # Counter Register
70
#endif
71
#ifndef SPRG2
72
#define SPRG2 274     # Counter Register
73
#endif
74
#ifndef SPRG3
75
#define SPRG3 275     # Counter Register
76
#endif
77
 
78
##-----------------------------------------------------------------------------
79
## MPC8260 defined vectors
80
        .macro mpc8260_vector name
81
        .p2align 8
82
        .globl  __exception_\name
83
__exception_\name:
84
        #-------------------------------------------#
85
        # save off registers used in vector routine #
86
        #-------------------------------------------#
87
 
88
        mtspr SPRG3,r3    # save r3
89
        mfspr r3,8
90
        mtspr SPRG2,r3    # save LR
91
 
92
        #-----------------------------------------------------------------------
93
        # Load the vector offset value in SPRG0 for handler shifted down 8 bits.
94
        #-----------------------------------------------------------------------
95
 
96
        #addi  r3,r0,0x0010
97
        addi  r3,r0,__exception_\name@l #load low 16 bits of exception vector
98
        srawi r3,r3,8                   #shift right by 8
99
        mtspr SPRG0,r3
100
 
101
        #---------------------------------------------------------
102
        # load link register in order to jump to physical address
103
        #---------------------------------------------------------
104
 
105
        addis    r3,0,handler@h
106
        ori      r3,r3,handler@l
107
        mtspr    8,r3
108
        bclr     20,0                 # jump unconditionally to address in Link
109
                                      # Register (LR)
110
        .endm
111
 
112
//
113
// This is for debugging purposes only
114
//
115
        .macro  infinite_loop_vector name
116
        .p2align 8
117
        .globl  __exception_\name
118
__exception_\name:
119
        mflr    r0
120
        lwi     r1,CYGARC_IMM_BASE
121
        lwi     r2,0x12345678
122
        stw     r0,0(r1)
123
        lwi     r3,__exception_\name
124
        stw     r3,4(r1)
125
        stw     r2,8(r1)
126
1:
127
        nop
128
        nop
129
        nop
130
        b 1b
131
        .endm
132
 
133
        .macro hal_reserved_vector_00000
134
        infinite_loop_vector    reserved
135
        .endm
136
#define CYG_HAL_RESERVED_VECTOR_00000
137
 
138
        .macro hal_extra_vectors
139
        infinite_loop_vector        itbl_miss
140
        infinite_loop_vector        dltlb_miss
141
        infinite_loop_vector        dstlb_miss
142
        infinite_loop_vector        iaddr_brkpt
143
        infinite_loop_vector        sys_mngmnt_intrpt
144
        .endm
145
 
146
##-----------------------------------------------------------------------------
147
## MPC8xxx CPU initialization
148
##
149
## Initialize CPU to a post-reset state, ensuring the ground doesn''t
150
## shift under us while we try to set things up.
151
 
152
        .macro hal_cpu_init
153
        # Set up MSR (disable MMU for now)
154
        lwi     r3,(CYG_MSR & ~(MSR_IR | MSR_DR))
155
        sync
156
        mtmsr   r3
157
        sync
158
        .endm
159
 
160
##-----------------------------------------------------------------------------
161
## MPC8xxx monitor initialization
162
 
163
#ifndef CYGPKG_HAL_PPC_MON_DEFINED
164
 
165
#if     defined(CYG_HAL_STARTUP_ROM) ||                 \
166
        defined(CYG_HAL_STARTUP_ROMRAM) ||                 \
167
        (       defined(CYG_HAL_STARTUP_RAM) &&         \
168
                !defined(CYGSEM_HAL_USE_ROM_MONITOR))
169
 
170
        .macro  hal_mon_init
171
#ifdef CYGSEM_HAL_POWERPC_COPY_VECTORS
172
        # If we are starting up from ROM and want vectors in RAM
173
        # or we are starting in RAM and NOT using a ROM monitor,
174
        # copy exception handler code to 0.
175
        lwi     r3,rom_vectors          # r3 = rom start
176
        lwi     r4,0                    # r4 = ram start
177
        lwi     r5,rom_vectors_end      # r5 = rom end
178
        cmplw   r3,r5                   # skip if no vectors
179
        beq     2f
180
 
181
        subi    r3,r3,4
182
        subi    r4,r4,4
183
        subi    r5,r5,4
184
1:
185
        lwzu    r0,4(r3)                # get word from ROM
186
        stwu    r0,4(r4)                # store in RAM
187
        cmplw   r3,r5                   # compare
188
        blt     1b                      # loop if not yet done
189
2:
190
 
191
        # Next initialize the VSR table. This happens whether the
192
        # vectors were copied to RAM or not.
193
 
194
        # First fill with exception handlers
195
        lwi     r3,cyg_hal_default_exception_vsr
196
        lwi     r4,hal_vsr_table
197
        subi    r4,r4,4
198
        li      r5,CYGNUM_HAL_VSR_COUNT
199
1:      stwu    r3,4(r4)
200
        subi    r5,r5,1
201
        cmpwi   r5,0
202
        bne     1b
203
#endif
204
 
205
        # Then fill in the special vectors
206
        lwi     r3,cyg_hal_default_interrupt_vsr
207
        lwi     r4,hal_vsr_table
208
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
209
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
210
        .endm
211
 
212
#elif defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR)
213
 
214
        # Initialize the VSR table entries
215
        # We only take control of the interrupt vectors,
216
        # the rest are left to the ROM for now...
217
 
218
        .macro  hal_mon_init
219
        lwi     r3,cyg_hal_default_interrupt_vsr
220
        lwi     r4,hal_vsr_table
221
        stw     r3,CYGNUM_HAL_VECTOR_INTERRUPT*4(r4)
222
        stw     r3,CYGNUM_HAL_VECTOR_DECREMENTER*4(r4)
223
        .endm
224
 
225
 
226
#else
227
 
228
        .macro  hal_mon_init
229
 
230
        .endm
231
 
232
#endif
233
 
234
 
235
#define CYGPKG_HAL_PPC_MON_DEFINED
236
 
237
#endif // CYGPKG_HAL_PPC_MON_DEFINED
238
 
239
##-----------------------------------------------------------------------------
240
## MPC8xxx exception state handling
241
        .macro  hal_variant_save regs
242
        .endm
243
 
244
        .macro  hal_variant_load regs
245
        .endm
246
 
247
##-----------------------------------------------------------------------------
248
## Indicate that the ISR tables are defined in variant.S
249
 
250
#define CYG_HAL_PPC_ISR_TABLES_DEFINED
251
 
252
##-----------------------------------------------------------------------------
253
## MPC8260 interrupt handling.
254
 
255
#ifndef CYGPKG_HAL_POWERPC_INTC_DEFINED
256
 
257
## First level decoding of MPC8xxx SIU interrupt controller.
258
 
259
        # decode the interrupt
260
        .macro  hal_intc_decode dreg,state
261
        lwz     \dreg,CYGARC_PPCREG_VECTOR(\state) # retrieve vector number,
262
        rlwinm. \dreg,\dreg,22,31,31            # isolate bit 21
263
        beq     0f                              # done if decrementer (vec 0)
264
        lis     \dreg,(CYGARC_IMM_BASE+0x10000)>>16 # load register base
265
        lbz     \dreg,CYGARC_REG_IMM_SIVEC(\dreg)      # if external, get SIU vector
266
        srwi    \dreg,\dreg,2                   # shift SIVEC value by 2
267
        //addi    \dreg,\dreg,1                   # Skip decrementer vector
268
0:      stw     \dreg,CYGARC_PPCREG_VECTOR(\state) # update vector in state frame.
269
        slwi    \dreg,\dreg,2                   # convert to byte offset.
270
        .endm
271
 
272
 
273
#define CYGPKG_HAL_POWERPC_INTC_DEFINED
274
#endif // CYGPKG_HAL_POWERPC_INTC_DEFINED
275
#------------------------------------------------------------------------------
276
#endif // ifndef CYGONCE_HAL_VARIANT_INC
277
# end of variant.inc

powered by: WebSVN 2.1.0

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