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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sh/] [arch/] [v2_0/] [include/] [hal_var_bank.inc] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
##==========================================================================
2
##
3
##      hal_var_bank.inc
4
##
5
##      SH support code for variants using register banks
6
##
7
##==========================================================================
8
#####ECOSGPLCOPYRIGHTBEGIN####
9
## -------------------------------------------
10
## This file is part of eCos, the Embedded Configurable Operating System.
11
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
##
13
## eCos is free software; you can redistribute it and/or modify it under
14
## the terms of the GNU General Public License as published by the Free
15
## Software Foundation; either version 2 or (at your option) any later version.
16
##
17
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
## for more details.
21
##
22
## You should have received a copy of the GNU General Public License along
23
## with eCos; if not, write to the Free Software Foundation, Inc.,
24
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
##
26
## As a special exception, if other files instantiate templates or use macros
27
## or inline functions from this file, or you compile this file and link it
28
## with other works to produce a work based on this file, this file does not
29
## by itself cause the resulting work to be covered by the GNU General Public
30
## License. However the source code for this file must still be made available
31
## in accordance with section (3) of the GNU General Public License.
32
##
33
## This exception does not invalidate any other reasons why a work based on
34
## this file might be covered by the GNU General Public License.
35
##
36
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
## at http://sources.redhat.com/ecos/ecos-license/
38
## -------------------------------------------
39
#####ECOSGPLCOPYRIGHTEND####
40
##==========================================================================
41
#######DESCRIPTIONBEGIN####
42
##
43
## Author(s):    jskov
44
## Contributors: jskov
45
## Date:         2002-01-11
46
## Purpose:      SH support code for variants using register banks
47
##
48
######DESCRIPTIONEND####
49
##
50
##==========================================================================
51
 
52
#---------------------------------------------------------------------------
53
# The models with banked registers jump directly to code without storing
54
# anything on the stack. Instead, the CPU switches to use banked registers
55
# leaving initial saving of state to the VSRs.
56
 
57
# reset            0xa0000000
58
# other exceptions VBR+0x100
59
# tlb miss         VBR+0x400
60
# interrupts       VBR+0x600
61
 
62
 
63
#===========================================================================
64
# Reset code must be PC relative so it can be executed out of the shadow
65
# area during startup. Not until after hal_hardware_init can the system
66
# be expected to provide the proper address space (at that time we
67
# jump to the VMA base of the code).
68
 
69
        .org    0x000
70
FUNC_START(_reset)
71
        mov.l   $_reset_platform,r0
72
        jmp     @r0
73
         nop
74
 
75
# Note: this is the unmapped, shadow address of the start of code
76
# Sadly, it is too far to just branch to.
77
        .align   2
78
$_reset_platform:
79
#ifdef CYG_HAL_STARTUP_RAM
80
        .long   CYG_LABEL_DEFN(_reset_platform)
81
#elif defined(CYG_HAL_STARTUP_ROMRAM)
82
        // Uncached "shadow" address but adjusted for VMA/LMA differences
83
        .long   __reset_platform+0x20000000-CYGMEM_REGION_ram+CYGMEM_REGION_rom
84
#else
85
        // Uncached "shadow" address
86
        .long   CYG_LABEL_DEFN(_reset_platform)+0x20000000
87
#endif
88
 
89
#---------------------------------------------------------------------------
90
# Exception entry
91
 
92
        .org    0x100
93
__exception:
94
 
95
#if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR)
96
        mov     #1,r7
97
#endif
98
 
99
        mov.l   $nCYGARC_REG_EXCEVT2,r1
100
        mov.l   @r1,r1
101
        shlr2   r1
102
        shlr    r1                      ! divide cause by 0x08
103
        mov.l   $hal_vsr_table2,r0
104
        mov.l   @(r0,r1),r1
105
        jmp     @r1
106
         nop
107
 
108
        .align   2
109
        SYM_PTR_REFn(hal_vsr_table,2)
110
 
111
#---------------------------------------------------------------------------
112
# TLB miss entry
113
 
114
        .org    0x400
115
__tlb_miss:
116
#if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR)
117
        mov      #2,r7
118
#endif
119
 
120
        mov.l   $nCYGARC_REG_EXCEVT2,r1
121
        mov.l   @r1,r1
122
        shlr2   r1
123
        shlr    r1                      ! divide cause by 0x08
124
        mov.l   $hal_vsr_table3,r0
125
        mov.l   @(r0,r1),r1
126
        jmp     @r1
127
         nop
128
 
129
        .align   2
130
        SYM_PTR_REFn(hal_vsr_table,3)
131
$nCYGARC_REG_EXCEVT2:
132
        .long   CYGARC_REG_EXCEVT
133
 
134
#---------------------------------------------------------------------------
135
# Interrupt entry
136
 
137
        .org    0x600
138
__interrupt:
139
 
140
#ifdef CYGHWR_HAL_SH_IRQ_HANDLE_SPURIOUS_INTERRUPTS
141
        # A spurious interrupt with INTEVT=0 may be caused by
142
        # clearing of BL. Those interrupts need to be ignored.
143
        mov.l   1f,r0
144
        mov.l   @r0,r0
145
        cmp/eq  #0,r0
146
        bf      2f
147
        rte
148
         nop
149
        .align  2
150
1:      .long   CYGARC_REG_INTEVT
151
2:
152
#endif
153
 
154
 
155
#if defined(CYGPKG_KERNEL_INSTRUMENT) && defined(CYGDBG_KERNEL_INSTRUMENT_INTR)
156
        mov      #3,r7
157
#endif
158
 
159
        mov.l    $hal_vsr_table_int,r1
160
        mov.l    @r1,r1
161
        jmp      @r1
162
         nop
163
 
164
        .align   2
165
$hal_vsr_table_int:
166
        .long    CYG_LABEL_DEFN(hal_vsr_table)+CYGNUM_HAL_VECTOR_INTERRUPT*4
167
 
168
 
169
##============================================================================
170
## Macros for saving/restoring register state on an exception.
171
 
172
#---------------------------------------------------------------------------
173
## Save registers on exception:
174
## At entry:
175
## r15 is location to be stored to
176
## r0  is the available scratch register
177
 
178
## At exit:
179
## r7  is the vector #
180
## all other registers (except sp) are available
181
 
182
        .macro hal_cpu_save_regs
183
 
184
        # We come here with all register containing their
185
        # pre-exception values except:
186
        # r0_b-r7_b  = saved r0-r7
187
        # r7    = vector #
188
        # spc   = saved pc
189
        # ssr   = saved sr
190
 
191
        # Save away some registers
192
        mov     r15,r1                  ! entry sp
193
#ifdef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
194
        add     #-12,r15                ! Space for cause, gbr, and vbr
195
#else
196
        add     #-4,r15                 ! Space for cause
197
 
198
        stc     gbr,r0                  ! GBR
199
        mov.l   r0,@-r15
200
        stc     vbr,r0                  ! VBR
201
        mov.l   r0,@-r15
202
#endif
203
 
204
        stc     spc,r0
205
        mov.l   r0,@-r15                ! PC
206
        stc     ssr,r0
207
        mov.l   r0,@-r15                ! SR
208
 
209
        sts.l   pr,@-r15                ! PR
210
        sts.l   mach,@-r15              ! mach
211
        sts.l   macl,@-r15              ! macl
212
 
213
        mov.l   r1,@-r15                ! entry sp
214
        mov.l   r14,@-r15               ! r14-r0
215
        mov.l   r13,@-r15
216
        mov.l   r12,@-r15
217
        mov.l   r11,@-r15
218
        mov.l   r10,@-r15
219
        mov.l   r9,@-r15
220
        mov.l   r8,@-r15
221
        stc.l   r7_bank,@-r15
222
        stc.l   r6_bank,@-r15
223
        stc.l   r5_bank,@-r15
224
        stc.l   r4_bank,@-r15
225
        stc.l   r3_bank,@-r15
226
        stc.l   r2_bank,@-r15
227
        stc.l   r1_bank,@-r15
228
        stc.l   r0_bank,@-r15
229
 
230
        # After setting the SR it will be possible to use breakpoints.
231
        mov.l   1f,r1
232
        ldc     r1,sr
233
        bra     2f
234
         nop
235
        .align  2
236
1:      .long   CYG_SR
237
        # ------------------------------------------------------------
238
        # Register bank has changed now.
239
2:
240
        .endm
241
 
242
        # No additional magic needed. hal_cpu_save_regs does it all.
243
        .macro hal_exception_entry_extras
244
        .endm
245
        .macro hal_interrupt_entry_extras
246
        .endm
247
 
248
#---------------------------------------------------------------------------
249
## Restore registers after exception:
250
## At entry:
251
## r15 is location to be loaded from
252
## all other registers (except sp) are available
253
 
254
## At exit:
255
##  Returns to interrupted code
256
 
257
        .macro hal_cpu_restore_regs_return
258
        # Disable interrupts and switch register bank during the restore
259
        # operation
260
        mov.l   1f,r1
261
        ldc     r1,sr
262
        # ------------------------------------------------------------
263
        # Register bank has changed now.
264
 
265
        #
266
        # Single step debugging becomes impossible after this point!
267
        #
268
        mov     r15,r0
269
        ldc.l   @r0+,r0_bank
270
        ldc.l   @r0+,r1_bank
271
        ldc.l   @r0+,r2_bank
272
        ldc.l   @r0+,r3_bank
273
        ldc.l   @r0+,r4_bank
274
        ldc.l   @r0+,r5_bank
275
        ldc.l   @r0+,r6_bank
276
        ldc.l   @r0+,r7_bank
277
        mov.l   @r0+,r8
278
        mov.l   @r0+,r9
279
        mov.l   @r0+,r10
280
        mov.l   @r0+,r11
281
        mov.l   @r0+,r12
282
        mov.l   @r0+,r13
283
        mov.l   @r0+,r14
284
        mov.l   @r0+,r15                ! return SP
285
 
286
        lds.l   @r0+,macl               ! macl
287
        lds.l   @r0+,mach               ! mach
288
        lds.l   @r0+,pr                 ! PR
289
 
290
        mov.l   @r0+,r2
291
        ldc     r2,ssr                  ! return SR
292
        mov.l   @r0+,r2
293
        ldc     r2,spc                  ! return PC
294
 
295
#ifndef CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT
296
        mov.l   @r0+,r2
297
        ldc     r2,vbr                  ! return VBR
298
        mov.l   @r0+,r2
299
        ldc     r2,gbr                  ! return GBR
300
#endif
301
 
302
        rte
303
         nop
304
        .align  2
305
1:      .long   CYG_SR_BANK1
306
 
307
        .endm
308
 
309
#---------------------------------------------------------------------------
310
# Translate cause of exception to a vector number
311
        .macro hal_exception_translate
312
        mov.l   1f,r0
313
        mov.l   @r0,r4
314
        mov     #-5,r0                  ! divide cause by 0x20
315
        shld    r0,r4
316
        mov     #CYGARC_SHREG_EVENT,r0
317
        bra     2f
318
         mov.l   r4,@(r0,r15)            ! store decoded vector number back
319
        .align  2
320
1:      .long   CYGARC_REG_EXCEVT
321
2:
322
        .endm
323
 
324
#---------------------------------------------------------------------------
325
# end of hal_var_bank.inc

powered by: WebSVN 2.1.0

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