]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/sh/sh4/v2_0/src/variant.S
Initial revision
[karo-tx-redboot.git] / packages / hal / sh / sh4 / v2_0 / src / variant.S
1 ##==========================================================================
2 ##
3 ##      variant.S
4 ##
5 ##      SH4 variant assembly code
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:         2000-10-31
46 ## Purpose:      SH4 misc assembly code
47 ######DESCRIPTIONEND####
48 ##
49 ##==========================================================================
50
51 #include <pkgconf/hal.h>
52 #include <pkgconf/hal_sh.h>
53
54 #include <cyg/hal/sh_regs.h>
55 #include <cyg/hal/sh4_offsets.inc>
56
57 #include <cyg/hal/arch.inc>
58 #include <cyg/hal/hal_intr.h>
59         
60 #---------------------------------------------------------------------------
61 # Cache operations
62 # These need to be written in assembly to ensure they do not rely on data
63 # in cachable space (i.e., code must use registers exclusively, not the stack).
64
65 # This macro must be used at the top of each cache function. It ensures
66 # that the code gets executed from a shadow region where caching is disabled
67 # (0xA0000000).
68         .macro GOTO_NONCACHED_SHADOW
69         mova    10f,r0
70         mov.l   $MASK,r1
71         and     r1,r0
72         mov.l   $BASE,r1
73         or      r1,r0
74         jmp     @r0
75          nop
76         .align  2
77 10:
78         .endm
79
80         .macro RETURN_FROM_NONCACHED_SHADOW
81         nop                             ! Wait for 8 instructions
82         nop                             ! before jumping to a non-P2
83         nop                             ! area
84         nop
85         nop
86         nop
87         nop
88         nop
89         rts
90          nop
91         .endm
92
93 FUNC_START(cyg_hal_dcache_enable)
94         GOTO_NONCACHED_SHADOW
95         mov.l   $nCYGARC_REG_CCR,r1
96         mov.l   @r1,r0
97         mov     #CYGARC_REG_CCR_OCE,r2
98         or      r2,r0
99         mov.l   r0,@r1
100         RETURN_FROM_NONCACHED_SHADOW
101
102 FUNC_START(cyg_hal_dcache_disable)
103         GOTO_NONCACHED_SHADOW
104         mov.l   $nCYGARC_REG_CCR,r1
105         mov.l   @r1,r0
106         mov     #CYGARC_REG_CCR_OCE,r2
107         not     r2,r2
108         and     r2,r0
109         mov.l   r0,@r1
110         RETURN_FROM_NONCACHED_SHADOW
111         
112 FUNC_START(cyg_hal_dcache_invalidate_all)
113         GOTO_NONCACHED_SHADOW
114         mov.l   $nCYGARC_REG_CCR,r1
115         mov.l   @r1,r0
116         mov     #CYGARC_REG_CCR_OCI,r2
117         or      r2,r0
118         mov.l   r0,@r1
119         RETURN_FROM_NONCACHED_SHADOW
120
121 FUNC_START(cyg_hal_dcache_sync)
122         GOTO_NONCACHED_SHADOW
123         mov.l   $CYGARC_REG_DCACHE_ADDRESS_FLUSH,r0
124         mov.l   $CYGARC_REG_DCACHE_ADDRESS_BASE,r1
125         mov.l   $CYGARC_REG_DCACHE_ADDRESS_TOP,r2
126         mov.l   $CYGARC_REG_DCACHE_ADDRESS_STEP,r3
127 1:      cmp/hi  r1,r2
128         bf      2f
129         mov.l   r0,@r1
130         bra     1b        
131          add     r3,r1                  ! delay slot!
132 2:
133         RETURN_FROM_NONCACHED_SHADOW
134
135         .align  2
136 $CYGARC_REG_DCACHE_ADDRESS_FLUSH:
137         .long   CYGARC_REG_DCACHE_ADDRESS_FLUSH
138 $CYGARC_REG_DCACHE_ADDRESS_BASE:
139         .long   CYGARC_REG_DCACHE_ADDRESS_BASE
140 $CYGARC_REG_DCACHE_ADDRESS_TOP:
141         .long   CYGARC_REG_DCACHE_ADDRESS_TOP
142 $CYGARC_REG_DCACHE_ADDRESS_STEP:
143         .long   CYGARC_REG_DCACHE_ADDRESS_STEP
144
145
146         ! r4 = base
147         ! r5 = size
148 FUNC_START(cyg_hal_dcache_sync_region)
149         GOTO_NONCACHED_SHADOW
150 1:      ocbp    @r4                     ! operand cache block purge
151         add     #CYGARC_SH_MOD_DCAC_ADDRESS_STEP,r4
152         add     #-CYGARC_SH_MOD_DCAC_ADDRESS_STEP,r5
153         cmp/pl  r5
154         bt      1b
155         RETURN_FROM_NONCACHED_SHADOW
156
157 FUNC_START(cyg_hal_dcache_write_mode)
158         GOTO_NONCACHED_SHADOW
159         # Mode argument in r4.
160         # Read current state and mask out the two caching mode bits
161         mov.l   $nCYGARC_REG_CCR,r1
162         mov.l   @r1,r3
163         mov     #CYGARC_REG_CCR_CB|CYGARC_REG_CCR_WT,r2
164         and     r2,r4
165         not     r2,r2
166         and     r2,r3
167         # Or in the new settings and restore to CCR
168         or      r4,r3
169         mov.l   r3,@r1
170         RETURN_FROM_NONCACHED_SHADOW
171
172 FUNC_START(cyg_hal_icache_enable)
173         GOTO_NONCACHED_SHADOW
174         mov.l   $nCYGARC_REG_CCR,r1
175         mov.l   @r1,r0
176         mov.l   $nCYGARC_REG_CCR_ICE,r2
177         or      r2,r0
178         mov.l   r0,@r1
179         RETURN_FROM_NONCACHED_SHADOW
180
181 FUNC_START(cyg_hal_icache_disable)
182         GOTO_NONCACHED_SHADOW
183         mov.l   $nCYGARC_REG_CCR,r1
184         mov.l   @r1,r0
185         mov.l   $nCYGARC_REG_CCR_ICE,r2
186         not     r2,r2
187         and     r2,r0
188         mov.l   r0,@r1
189         RETURN_FROM_NONCACHED_SHADOW
190         
191 FUNC_START(cyg_hal_icache_invalidate_all)
192         GOTO_NONCACHED_SHADOW
193         mov.l   $nCYGARC_REG_CCR,r1
194         mov.l   @r1,r0
195         mov.l   $nCYGARC_REG_CCR_ICI,r2
196         or      r2,r0
197         mov.l   r0,@r1
198         RETURN_FROM_NONCACHED_SHADOW
199
200         .align  2
201 $MASK:
202         .long   0x1fffffff              ! mask off top 3 bits
203 $BASE:
204         .long   0xa0000000              ! base of non-cachable memory
205 $nCYGARC_REG_CCR:
206         .long   CYGARC_REG_CCR        
207 $nCYGARC_REG_CCR_ICE:
208         .long   CYGARC_REG_CCR_ICE
209 $nCYGARC_REG_CCR_ICI:
210         .long   CYGARC_REG_CCR_ICI
211
212
213         .data
214
215 SYM_DEF(cyg_hal_ILVL_table)
216         # The first entries in the table have static priorities.
217
218         .byte   0xf                     // NMI
219         .byte   0xf                     // Reserved
220         .byte   0xf                     // LVL0
221         .byte   0xe                     // LVL1
222         .byte   0xd                     // LVL2
223         .byte   0xc                     // LVL3
224         .byte   0xb                     // LVL4
225         .byte   0xa                     // LVL5
226         .byte   0x9                     // LVL6
227         .byte   0x8                     // LVL7
228         .byte   0x7                     // LVL8
229         .byte   0x6                     // LVL9
230         .byte   0x5                     // LVL10
231         .byte   0x4                     // LVL11
232         .byte   0x3                     // LVL12
233         .byte   0x2                     // LVL13
234         .byte   0x1                     // LVL14
235         .byte   0xf                     // Reserved
236
237         # The rest of the table consists of programmable levels, maintained
238         # by the HAL_INTERRUPT_SET_LEVEL macro. 
239         # These default to the highest level so that a spurious
240         # interrupt cause the IPL to be suddenly lowered to allow all
241         # interrupts. This should give a better chance at tracking down
242         # the problem.
243         .rept   (CYGNUM_HAL_ISR_MAX-CYGNUM_HAL_INTERRUPT_RESERVED_3E0)
244         .byte   0xf
245         .endr
246
247         # All interrupts are masked initally. Set to 1 to enable.
248 SYM_DEF(cyg_hal_IMASK_table)
249         .rept   (CYGNUM_HAL_ISR_MAX)
250         .byte   0x0
251         .endr