| 1 |
786 |
skrzyp |
##==========================================================================
|
| 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 Free Software Foundation, 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
|
| 16 |
|
|
## version.
|
| 17 |
|
|
##
|
| 18 |
|
|
## eCos is distributed in the hope that it will be useful, but WITHOUT
|
| 19 |
|
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 20 |
|
|
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 21 |
|
|
## for more details.
|
| 22 |
|
|
##
|
| 23 |
|
|
## You should have received a copy of the GNU General Public License
|
| 24 |
|
|
## along with eCos; if not, write to the Free Software Foundation, Inc.,
|
| 25 |
|
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| 26 |
|
|
##
|
| 27 |
|
|
## As a special exception, if other files instantiate templates or use
|
| 28 |
|
|
## macros or inline functions from this file, or you compile this file
|
| 29 |
|
|
## and link it with other works to produce a work based on this file,
|
| 30 |
|
|
## this file does not by itself cause the resulting work to be covered by
|
| 31 |
|
|
## the GNU General Public License. However the source code for this file
|
| 32 |
|
|
## must still be made available in accordance with section (3) of the GNU
|
| 33 |
|
|
## General Public License v2.
|
| 34 |
|
|
##
|
| 35 |
|
|
## This exception does not invalidate any other reasons why a work based
|
| 36 |
|
|
## on this file might be covered by the GNU General Public License.
|
| 37 |
|
|
## -------------------------------------------
|
| 38 |
|
|
## ####ECOSGPLCOPYRIGHTEND####
|
| 39 |
|
|
##==========================================================================
|
| 40 |
|
|
#######DESCRIPTIONBEGIN####
|
| 41 |
|
|
##
|
| 42 |
|
|
## Author(s): jskov
|
| 43 |
|
|
## Contributors: jskov
|
| 44 |
|
|
## Date: 2000-10-31
|
| 45 |
|
|
## Purpose: SH4 misc assembly code
|
| 46 |
|
|
######DESCRIPTIONEND####
|
| 47 |
|
|
##
|
| 48 |
|
|
##==========================================================================
|
| 49 |
|
|
|
| 50 |
|
|
#include
|
| 51 |
|
|
#include
|
| 52 |
|
|
|
| 53 |
|
|
#include
|
| 54 |
|
|
#include
|
| 55 |
|
|
|
| 56 |
|
|
#include
|
| 57 |
|
|
#include
|
| 58 |
|
|
|
| 59 |
|
|
#---------------------------------------------------------------------------
|
| 60 |
|
|
# Cache operations
|
| 61 |
|
|
# These need to be written in assembly to ensure they do not rely on data
|
| 62 |
|
|
# in cachable space (i.e., code must use registers exclusively, not the stack).
|
| 63 |
|
|
|
| 64 |
|
|
# This macro must be used at the top of each cache function. It ensures
|
| 65 |
|
|
# that the code gets executed from a shadow region where caching is disabled
|
| 66 |
|
|
# (0xA0000000).
|
| 67 |
|
|
.macro GOTO_NONCACHED_SHADOW
|
| 68 |
|
|
mova 10f,r0
|
| 69 |
|
|
mov.l $MASK,r1
|
| 70 |
|
|
and r1,r0
|
| 71 |
|
|
mov.l $BASE,r1
|
| 72 |
|
|
or r1,r0
|
| 73 |
|
|
jmp @r0
|
| 74 |
|
|
nop
|
| 75 |
|
|
.align 2
|
| 76 |
|
|
10:
|
| 77 |
|
|
.endm
|
| 78 |
|
|
|
| 79 |
|
|
.macro RETURN_FROM_NONCACHED_SHADOW
|
| 80 |
|
|
nop ! Wait for 8 instructions
|
| 81 |
|
|
nop ! before jumping to a non-P2
|
| 82 |
|
|
nop ! area
|
| 83 |
|
|
nop
|
| 84 |
|
|
nop
|
| 85 |
|
|
nop
|
| 86 |
|
|
nop
|
| 87 |
|
|
nop
|
| 88 |
|
|
rts
|
| 89 |
|
|
nop
|
| 90 |
|
|
.endm
|
| 91 |
|
|
|
| 92 |
|
|
FUNC_START(cyg_hal_dcache_enable)
|
| 93 |
|
|
GOTO_NONCACHED_SHADOW
|
| 94 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 95 |
|
|
mov.l @r1,r0
|
| 96 |
|
|
mov #CYGARC_REG_CCR_OCE,r2
|
| 97 |
|
|
or r2,r0
|
| 98 |
|
|
mov.l r0,@r1
|
| 99 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 100 |
|
|
|
| 101 |
|
|
FUNC_START(cyg_hal_dcache_disable)
|
| 102 |
|
|
GOTO_NONCACHED_SHADOW
|
| 103 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 104 |
|
|
mov.l @r1,r0
|
| 105 |
|
|
mov #CYGARC_REG_CCR_OCE,r2
|
| 106 |
|
|
not r2,r2
|
| 107 |
|
|
and r2,r0
|
| 108 |
|
|
mov.l r0,@r1
|
| 109 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 110 |
|
|
|
| 111 |
|
|
FUNC_START(cyg_hal_dcache_invalidate_all)
|
| 112 |
|
|
GOTO_NONCACHED_SHADOW
|
| 113 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 114 |
|
|
mov.l @r1,r0
|
| 115 |
|
|
mov #CYGARC_REG_CCR_OCI,r2
|
| 116 |
|
|
or r2,r0
|
| 117 |
|
|
mov.l r0,@r1
|
| 118 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 119 |
|
|
|
| 120 |
|
|
FUNC_START(cyg_hal_dcache_sync)
|
| 121 |
|
|
GOTO_NONCACHED_SHADOW
|
| 122 |
|
|
mov.l $CYGARC_REG_DCACHE_ADDRESS_FLUSH,r0
|
| 123 |
|
|
mov.l $CYGARC_REG_DCACHE_ADDRESS_BASE,r1
|
| 124 |
|
|
mov.l $CYGARC_REG_DCACHE_ADDRESS_TOP,r2
|
| 125 |
|
|
mov.l $CYGARC_REG_DCACHE_ADDRESS_STEP,r3
|
| 126 |
|
|
1: cmp/hi r1,r2
|
| 127 |
|
|
bf 2f
|
| 128 |
|
|
mov.l r0,@r1
|
| 129 |
|
|
bra 1b
|
| 130 |
|
|
add r3,r1 ! delay slot!
|
| 131 |
|
|
2:
|
| 132 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 133 |
|
|
|
| 134 |
|
|
.align 2
|
| 135 |
|
|
$CYGARC_REG_DCACHE_ADDRESS_FLUSH:
|
| 136 |
|
|
.long CYGARC_REG_DCACHE_ADDRESS_FLUSH
|
| 137 |
|
|
$CYGARC_REG_DCACHE_ADDRESS_BASE:
|
| 138 |
|
|
.long CYGARC_REG_DCACHE_ADDRESS_BASE
|
| 139 |
|
|
$CYGARC_REG_DCACHE_ADDRESS_TOP:
|
| 140 |
|
|
.long CYGARC_REG_DCACHE_ADDRESS_TOP
|
| 141 |
|
|
$CYGARC_REG_DCACHE_ADDRESS_STEP:
|
| 142 |
|
|
.long CYGARC_REG_DCACHE_ADDRESS_STEP
|
| 143 |
|
|
|
| 144 |
|
|
|
| 145 |
|
|
! r4 = base
|
| 146 |
|
|
! r5 = size
|
| 147 |
|
|
FUNC_START(cyg_hal_dcache_sync_region)
|
| 148 |
|
|
GOTO_NONCACHED_SHADOW
|
| 149 |
|
|
1: ocbp @r4 ! operand cache block purge
|
| 150 |
|
|
add #CYGARC_SH_MOD_DCAC_ADDRESS_STEP,r4
|
| 151 |
|
|
add #-CYGARC_SH_MOD_DCAC_ADDRESS_STEP,r5
|
| 152 |
|
|
cmp/pl r5
|
| 153 |
|
|
bt 1b
|
| 154 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 155 |
|
|
|
| 156 |
|
|
FUNC_START(cyg_hal_dcache_write_mode)
|
| 157 |
|
|
GOTO_NONCACHED_SHADOW
|
| 158 |
|
|
# Mode argument in r4.
|
| 159 |
|
|
# Read current state and mask out the two caching mode bits
|
| 160 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 161 |
|
|
mov.l @r1,r3
|
| 162 |
|
|
mov #CYGARC_REG_CCR_CB|CYGARC_REG_CCR_WT,r2
|
| 163 |
|
|
and r2,r4
|
| 164 |
|
|
not r2,r2
|
| 165 |
|
|
and r2,r3
|
| 166 |
|
|
# Or in the new settings and restore to CCR
|
| 167 |
|
|
or r4,r3
|
| 168 |
|
|
mov.l r3,@r1
|
| 169 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 170 |
|
|
|
| 171 |
|
|
FUNC_START(cyg_hal_icache_enable)
|
| 172 |
|
|
GOTO_NONCACHED_SHADOW
|
| 173 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 174 |
|
|
mov.l @r1,r0
|
| 175 |
|
|
mov.l $nCYGARC_REG_CCR_ICE,r2
|
| 176 |
|
|
or r2,r0
|
| 177 |
|
|
mov.l r0,@r1
|
| 178 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 179 |
|
|
|
| 180 |
|
|
FUNC_START(cyg_hal_icache_disable)
|
| 181 |
|
|
GOTO_NONCACHED_SHADOW
|
| 182 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 183 |
|
|
mov.l @r1,r0
|
| 184 |
|
|
mov.l $nCYGARC_REG_CCR_ICE,r2
|
| 185 |
|
|
not r2,r2
|
| 186 |
|
|
and r2,r0
|
| 187 |
|
|
mov.l r0,@r1
|
| 188 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 189 |
|
|
|
| 190 |
|
|
FUNC_START(cyg_hal_icache_invalidate_all)
|
| 191 |
|
|
GOTO_NONCACHED_SHADOW
|
| 192 |
|
|
mov.l $nCYGARC_REG_CCR,r1
|
| 193 |
|
|
mov.l @r1,r0
|
| 194 |
|
|
mov.l $nCYGARC_REG_CCR_ICI,r2
|
| 195 |
|
|
or r2,r0
|
| 196 |
|
|
mov.l r0,@r1
|
| 197 |
|
|
RETURN_FROM_NONCACHED_SHADOW
|
| 198 |
|
|
|
| 199 |
|
|
.align 2
|
| 200 |
|
|
$MASK:
|
| 201 |
|
|
.long 0x1fffffff ! mask off top 3 bits
|
| 202 |
|
|
$BASE:
|
| 203 |
|
|
.long 0xa0000000 ! base of non-cachable memory
|
| 204 |
|
|
$nCYGARC_REG_CCR:
|
| 205 |
|
|
.long CYGARC_REG_CCR
|
| 206 |
|
|
$nCYGARC_REG_CCR_ICE:
|
| 207 |
|
|
.long CYGARC_REG_CCR_ICE
|
| 208 |
|
|
$nCYGARC_REG_CCR_ICI:
|
| 209 |
|
|
.long CYGARC_REG_CCR_ICI
|
| 210 |
|
|
|
| 211 |
|
|
|
| 212 |
|
|
.data
|
| 213 |
|
|
|
| 214 |
|
|
SYM_DEF(cyg_hal_ILVL_table)
|
| 215 |
|
|
# The first entries in the table have static priorities.
|
| 216 |
|
|
|
| 217 |
|
|
.byte 0xf // NMI
|
| 218 |
|
|
.byte 0xf // Reserved
|
| 219 |
|
|
.byte 0xf // LVL0
|
| 220 |
|
|
.byte 0xe // LVL1
|
| 221 |
|
|
.byte 0xd // LVL2
|
| 222 |
|
|
.byte 0xc // LVL3
|
| 223 |
|
|
.byte 0xb // LVL4
|
| 224 |
|
|
.byte 0xa // LVL5
|
| 225 |
|
|
.byte 0x9 // LVL6
|
| 226 |
|
|
.byte 0x8 // LVL7
|
| 227 |
|
|
.byte 0x7 // LVL8
|
| 228 |
|
|
.byte 0x6 // LVL9
|
| 229 |
|
|
.byte 0x5 // LVL10
|
| 230 |
|
|
.byte 0x4 // LVL11
|
| 231 |
|
|
.byte 0x3 // LVL12
|
| 232 |
|
|
.byte 0x2 // LVL13
|
| 233 |
|
|
.byte 0x1 // LVL14
|
| 234 |
|
|
.byte 0xf // Reserved
|
| 235 |
|
|
|
| 236 |
|
|
# The rest of the table consists of programmable levels, maintained
|
| 237 |
|
|
# by the HAL_INTERRUPT_SET_LEVEL macro.
|
| 238 |
|
|
# These default to the highest level so that a spurious
|
| 239 |
|
|
# interrupt cause the IPL to be suddenly lowered to allow all
|
| 240 |
|
|
# interrupts. This should give a better chance at tracking down
|
| 241 |
|
|
# the problem.
|
| 242 |
|
|
.rept (CYGNUM_HAL_ISR_MAX-CYGNUM_HAL_INTERRUPT_RESERVED_3E0)
|
| 243 |
|
|
.byte 0xf
|
| 244 |
|
|
.endr
|
| 245 |
|
|
|
| 246 |
|
|
# All interrupts are masked initally. Set to 1 to enable.
|
| 247 |
|
|
SYM_DEF(cyg_hal_IMASK_table)
|
| 248 |
|
|
.rept (CYGNUM_HAL_ISR_MAX)
|
| 249 |
|
|
.byte 0x0
|
| 250 |
|
|
.endr
|