[ba71076] | 1 | /* |
---|
| 2 | * SH7750 interrupt support. |
---|
| 3 | * |
---|
| 4 | * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia |
---|
| 5 | * Author: Victor V. Vengerov <vvv@oktet.ru> |
---|
| 6 | * |
---|
| 7 | * Based on work: |
---|
| 8 | * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and |
---|
| 9 | * Bernd Becker (becker@faw.uni-ulm.de) |
---|
| 10 | * |
---|
| 11 | * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE |
---|
| 16 | * |
---|
| 17 | * |
---|
| 18 | * COPYRIGHT (c) 1998. |
---|
| 19 | * On-Line Applications Research Corporation (OAR). |
---|
| 20 | * Copyright assigned to U.S. Government, 1994. |
---|
| 21 | * |
---|
| 22 | * The license and distribution terms for this file may be |
---|
| 23 | * found in the file LICENSE in this distribution or at |
---|
| 24 | * http://www.OARcorp.com/rtems/license.html. |
---|
| 25 | * |
---|
| 26 | * Modified to reflect isp entries for sh7045 processor: |
---|
| 27 | * John M. Mills (jmills@tga.com) |
---|
| 28 | * TGA Technologies, Inc. |
---|
| 29 | * 100 Pinnacle Way, Suite 140 |
---|
| 30 | * Norcross, GA 30071 U.S.A. |
---|
| 31 | * August, 1999 |
---|
| 32 | * |
---|
| 33 | * This modified file may be copied and distributed in accordance |
---|
| 34 | * the above-referenced license. It is provided for critique and |
---|
| 35 | * developmental purposes without any warranty nor representation |
---|
| 36 | * by the authors or by TGA Technologies. |
---|
| 37 | * |
---|
| 38 | * $Id$ |
---|
| 39 | */ |
---|
| 40 | |
---|
| 41 | #include <rtems/system.h> |
---|
| 42 | #include <rtems/score/shtypes.h> |
---|
| 43 | #include <rtems/score/isr.h> |
---|
| 44 | |
---|
| 45 | #if !defined (sh7750) |
---|
| 46 | #error Wrong CPU MODEL |
---|
| 47 | #endif |
---|
| 48 | |
---|
| 49 | /* |
---|
| 50 | * This is a exception vector table |
---|
| 51 | * |
---|
| 52 | * It has the same structure as the actual vector table (vectab) |
---|
| 53 | */ |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | #include <rtems/score/ispsh7750.h> |
---|
| 57 | #include <rtems/score/sh7750_regs.h> |
---|
| 58 | |
---|
| 59 | /* VBR register contents saved on startup -- used to hook exception by debug |
---|
| 60 | * agent */ |
---|
| 61 | void *_VBR_Saved; |
---|
| 62 | |
---|
| 63 | /*PAGE |
---|
| 64 | * |
---|
| 65 | * _CPU_ISR_install_vector |
---|
| 66 | * |
---|
| 67 | * This kernel routine installs the RTEMS handler for the |
---|
| 68 | * specified vector. |
---|
| 69 | * |
---|
| 70 | * Input parameters: |
---|
| 71 | * vector - interrupt vector number |
---|
| 72 | * old_handler - former ISR for this vector number |
---|
| 73 | * new_handler - replacement ISR for this vector number |
---|
| 74 | * |
---|
| 75 | * Output parameters: NONE |
---|
| 76 | * |
---|
| 77 | */ |
---|
| 78 | void _CPU_ISR_install_vector( |
---|
| 79 | unsigned32 vector, |
---|
| 80 | proc_ptr new_handler, |
---|
| 81 | proc_ptr *old_handler |
---|
| 82 | ) |
---|
| 83 | { |
---|
| 84 | *old_handler = _ISR_Vector_table[vector]; |
---|
| 85 | _ISR_Vector_table[vector] = new_handler; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | #define __STRINGIFY1__(x) #x |
---|
| 90 | #define __STRINGIFY__(x) __STRINGIFY1__(x) |
---|
| 91 | |
---|
| 92 | #define STOP_TIMER \ |
---|
| 93 | " mov.l TSTR_k,r0 \n" \ |
---|
| 94 | " mov.b @r0,r1 \n" \ |
---|
| 95 | " and #" __STRINGIFY__(~SH7750_TSTR_STR0) ",r1\n" \ |
---|
| 96 | " mov.b r1,@r0 \n" |
---|
| 97 | |
---|
| 98 | #define START_TIMER \ |
---|
| 99 | " mov.l TSTR_k,r0 \n" \ |
---|
| 100 | " mov.b @r0,r1 \n" \ |
---|
| 101 | " or #" __STRINGIFY__(SH7750_TSTR_STR0) ",r1\n" \ |
---|
| 102 | " mov.b r1,@r0 \n" |
---|
| 103 | |
---|
| 104 | asm (" .text\n" |
---|
| 105 | " .balign 256\n" |
---|
| 106 | " .global __vbr_base\n" |
---|
| 107 | "__vbr_base:\n" |
---|
| 108 | " .org __vbr_base + 0x100\n" |
---|
| 109 | "vbr_100:\n" |
---|
| 110 | " mov.l r0,@-r15\n" |
---|
| 111 | " mov.l r1,@-r15\n" |
---|
| 112 | " mov.l __VBR_Saved100_k, r0\n" |
---|
| 113 | " mov.l offset100_k,r1\n" |
---|
| 114 | " mov.l @r0,r0\n" |
---|
| 115 | " add r1,r0\n" |
---|
| 116 | " mov.l @r15+,r1\n" |
---|
| 117 | " jmp @r0\n" |
---|
| 118 | " mov.l @r15+,r0\n" |
---|
| 119 | " .align 2\n" |
---|
| 120 | "__VBR_Saved100_k:\n" |
---|
| 121 | " .long __VBR_Saved\n" |
---|
| 122 | "offset100_k:\n" |
---|
| 123 | " .long 0x100\n" |
---|
| 124 | |
---|
| 125 | " .org __vbr_base + 0x400\n" |
---|
| 126 | "vbr_400:\n" |
---|
| 127 | " mov.l r0,@-r15\n" |
---|
| 128 | " mov.l r1,@-r15\n" |
---|
| 129 | " mov.l __VBR_Saved400_k, r0\n" |
---|
| 130 | " mov.l offset400_k,r1\n" |
---|
| 131 | " mov.l @r0,r0\n" |
---|
| 132 | " add r1,r0\n" |
---|
| 133 | " mov.l @r15+,r1\n" |
---|
| 134 | " jmp @r0\n" |
---|
| 135 | " mov.l @r15+,r0\n" |
---|
| 136 | " .align 2\n" |
---|
| 137 | "__VBR_Saved400_k:\n" |
---|
| 138 | " .long __VBR_Saved\n" |
---|
| 139 | "offset400_k:\n" |
---|
| 140 | " .long 0x400\n" |
---|
| 141 | |
---|
| 142 | " .org __vbr_base + 0x600\n" |
---|
| 143 | "vbr_600:\n" |
---|
| 144 | " mov.l r0,@-r15 \n" |
---|
| 145 | " mov.l r1,@-r15 \n" |
---|
| 146 | " stc sr,r0 \n" |
---|
| 147 | " mov.l __vbr_600_sr_and_k,r1\n" |
---|
| 148 | " and r1,r0 \n" |
---|
| 149 | " mov.l __vbr_600_sr_or_k,r1\n" |
---|
| 150 | " or r1,r0 \n" |
---|
| 151 | " ldc r0,sr \n" |
---|
| 152 | " ldc.l @r15+,r1_bank\n" |
---|
| 153 | " ldc.l @r15+,r0_bank\n" |
---|
| 154 | " mov.l r0,@-r15 \n" |
---|
| 155 | " mov.l r1,@-r15 \n" |
---|
| 156 | " mov.l r2,@-r15 \n" |
---|
| 157 | " mov.l r3,@-r15 \n" |
---|
| 158 | " mov.l r4,@-r15 \n" |
---|
| 159 | " mov.l r5,@-r15 \n" |
---|
| 160 | " mov.l r6,@-r15 \n" |
---|
| 161 | " mov.l r7,@-r15 \n" |
---|
| 162 | #if 0 |
---|
| 163 | " mov.l r8,@-r15 \n" |
---|
| 164 | " mov.l r9,@-r15 \n" |
---|
| 165 | " mov.l r10,@-r15 \n" |
---|
| 166 | " mov.l r11,@-r15 \n" |
---|
| 167 | " mov.l r12,@-r15 \n" |
---|
| 168 | " mov.l r13,@-r15 \n" |
---|
| 169 | #endif |
---|
| 170 | " mov.l r14,@-r15 \n" |
---|
| 171 | " sts.l fpscr,@-r15\n" |
---|
| 172 | " sts.l fpul,@-r15 \n" |
---|
| 173 | " mov.l __ISR_temp_fpscr_k,r0 \n" |
---|
| 174 | " lds r0,fpscr \n" |
---|
| 175 | " fmov fr0,@-r15 \n" |
---|
| 176 | " fmov fr1,@-r15 \n" |
---|
| 177 | " fmov fr2,@-r15 \n" |
---|
| 178 | " fmov fr3,@-r15 \n" |
---|
| 179 | " fmov fr4,@-r15 \n" |
---|
| 180 | " fmov fr5,@-r15 \n" |
---|
| 181 | " fmov fr6,@-r15 \n" |
---|
| 182 | " fmov fr7,@-r15 \n" |
---|
| 183 | " fmov fr8,@-r15 \n" |
---|
| 184 | " fmov fr9,@-r15 \n" |
---|
| 185 | " fmov fr10,@-r15 \n" |
---|
| 186 | " fmov fr11,@-r15 \n" |
---|
| 187 | " fmov fr12,@-r15 \n" |
---|
| 188 | " fmov fr13,@-r15 \n" |
---|
| 189 | " fmov fr14,@-r15 \n" |
---|
| 190 | " fmov fr15,@-r15 \n" |
---|
| 191 | |
---|
| 192 | " sts.l pr,@-r15 \n" |
---|
| 193 | " sts.l mach,@-r15 \n" |
---|
| 194 | " sts.l macl,@-r15 \n" |
---|
| 195 | " stc.l spc,@-r15 \n" |
---|
| 196 | " stc.l ssr,@-r15 \n" |
---|
| 197 | " mov r15,r14 \n" |
---|
| 198 | #if 0 |
---|
| 199 | " stc ssr,r0 \n" |
---|
| 200 | " ldc r0,sr \n" |
---|
| 201 | #endif |
---|
| 202 | " mov.l __ISR_Handler_k, r1\n" |
---|
| 203 | " mov.l _INTEVT_k,r4\n" |
---|
| 204 | " mov.l @r4,r4 \n" |
---|
| 205 | " shlr2 r4 \n" |
---|
| 206 | " shlr r4 \n" |
---|
| 207 | |
---|
| 208 | " mov.l _ISR_Table_k,r0\n" |
---|
| 209 | " mov.l @r0,r0 \n" |
---|
| 210 | " add r4,r0 \n" |
---|
| 211 | " mov.l @r0,r0 \n" |
---|
| 212 | " cmp/eq #0,r0 \n" |
---|
| 213 | " bt _ipl_hook \n" |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | " jsr @r1 \n" |
---|
| 217 | " shlr2 r4 \n" |
---|
| 218 | " mov r14,r15 \n" |
---|
| 219 | " ldc.l @r15+,ssr \n" |
---|
| 220 | " ldc.l @r15+,spc \n" |
---|
| 221 | " lds.l @r15+,macl \n" |
---|
| 222 | " lds.l @r15+,mach \n" |
---|
| 223 | " lds.l @r15+,pr \n" |
---|
| 224 | " mov.l __ISR_temp_fpscr_k,r0 \n" |
---|
| 225 | " lds r0,fpscr \n" |
---|
| 226 | |
---|
| 227 | " fmov @r15+,fr15 \n" |
---|
| 228 | " fmov @r15+,fr14 \n" |
---|
| 229 | " fmov @r15+,fr13 \n" |
---|
| 230 | " fmov @r15+,fr12 \n" |
---|
| 231 | " fmov @r15+,fr11 \n" |
---|
| 232 | " fmov @r15+,fr10 \n" |
---|
| 233 | " fmov @r15+,fr9 \n" |
---|
| 234 | " fmov @r15+,fr8 \n" |
---|
| 235 | " fmov @r15+,fr7 \n" |
---|
| 236 | " fmov @r15+,fr6 \n" |
---|
| 237 | " fmov @r15+,fr5 \n" |
---|
| 238 | " fmov @r15+,fr4 \n" |
---|
| 239 | " fmov @r15+,fr3 \n" |
---|
| 240 | " fmov @r15+,fr2 \n" |
---|
| 241 | " fmov @r15+,fr1 \n" |
---|
| 242 | " fmov @r15+,fr0 \n" |
---|
| 243 | " lds.l @r15+,fpul \n" |
---|
| 244 | " lds.l @r15+,fpscr\n" |
---|
| 245 | " mov.l @r15+,r14 \n" |
---|
| 246 | #if 0 |
---|
| 247 | " mov.l @r15+,r13 \n" |
---|
| 248 | " mov.l @r15+,r12 \n" |
---|
| 249 | " mov.l @r15+,r11 \n" |
---|
| 250 | " mov.l @r15+,r10 \n" |
---|
| 251 | " mov.l @r15+,r9 \n" |
---|
| 252 | " mov.l @r15+,r8 \n" |
---|
| 253 | #endif |
---|
| 254 | |
---|
| 255 | " mov.l @r15+,r7 \n" |
---|
| 256 | " mov.l @r15+,r6 \n" |
---|
| 257 | " mov.l @r15+,r5 \n" |
---|
| 258 | " mov.l @r15+,r4 \n" |
---|
| 259 | " mov.l @r15+,r3 \n" |
---|
| 260 | " mov.l @r15+,r2 \n" |
---|
| 261 | " mov.l @r15+,r1 \n" |
---|
| 262 | " mov.l @r15+,r0 \n" |
---|
| 263 | " rte \n" |
---|
| 264 | " nop \n" |
---|
| 265 | " .align 2 \n" |
---|
| 266 | "__vbr_600_sr_and_k: \n" |
---|
| 267 | " .long " __STRINGIFY__(~(SH4_SR_RB | SH4_SR_BL)) "\n" |
---|
| 268 | "__vbr_600_sr_or_k: \n" |
---|
| 269 | " .long " __STRINGIFY__(SH4_SR_IMASK) "\n" |
---|
| 270 | "__ISR_Handler_k: \n" |
---|
| 271 | " .long ___ISR_Handler\n" |
---|
| 272 | "_INTEVT_k: \n" |
---|
| 273 | " .long " __STRINGIFY__(SH7750_INTEVT) "\n" |
---|
| 274 | "_ISR_Table_k: \n" |
---|
| 275 | " .long __ISR_Vector_table\n" |
---|
| 276 | |
---|
| 277 | "_ipl_hook: \n" |
---|
| 278 | " mov r14,r15 \n" |
---|
| 279 | " ldc.l @r15+,ssr \n" |
---|
| 280 | " ldc.l @r15+,spc \n" |
---|
| 281 | " lds.l @r15+,macl \n" |
---|
| 282 | " lds.l @r15+,mach \n" |
---|
| 283 | " lds.l @r15+,pr \n" |
---|
| 284 | " mov.l __ISR_temp_fpscr_k,r0 \n" |
---|
| 285 | " lds r0,fpscr \n" |
---|
| 286 | " fmov @r15+,fr15 \n" |
---|
| 287 | " fmov @r15+,fr14 \n" |
---|
| 288 | " fmov @r15+,fr13 \n" |
---|
| 289 | " fmov @r15+,fr12 \n" |
---|
| 290 | " fmov @r15+,fr11 \n" |
---|
| 291 | " fmov @r15+,fr10 \n" |
---|
| 292 | " fmov @r15+,fr9 \n" |
---|
| 293 | " fmov @r15+,fr8 \n" |
---|
| 294 | " fmov @r15+,fr7 \n" |
---|
| 295 | " fmov @r15+,fr6 \n" |
---|
| 296 | " fmov @r15+,fr5 \n" |
---|
| 297 | " fmov @r15+,fr4 \n" |
---|
| 298 | " fmov @r15+,fr3 \n" |
---|
| 299 | " fmov @r15+,fr2 \n" |
---|
| 300 | " fmov @r15+,fr1 \n" |
---|
| 301 | " fmov @r15+,fr0 \n" |
---|
| 302 | " lds.l @r15+,fpul \n" |
---|
| 303 | " lds.l @r15+,fpscr\n" |
---|
| 304 | " mov.l @r15+,r14 \n" |
---|
| 305 | |
---|
| 306 | " mov.l @r15+,r13 \n" |
---|
| 307 | " mov.l @r15+,r12 \n" |
---|
| 308 | " mov.l @r15+,r11 \n" |
---|
| 309 | " mov.l @r15+,r10 \n" |
---|
| 310 | " mov.l @r15+,r9 \n" |
---|
| 311 | " mov.l @r15+,r8 \n" |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | " mov.l @r15+,r7 \n" |
---|
| 315 | " mov.l @r15+,r6 \n" |
---|
| 316 | " mov.l @r15+,r5 \n" |
---|
| 317 | " mov.l @r15+,r4 \n" |
---|
| 318 | " mov.l @r15+,r3 \n" |
---|
| 319 | " mov.l @r15+,r2 \n" |
---|
| 320 | " mov.l __VBR_Saved600_k, r0\n" |
---|
| 321 | " mov.l offset600_k,r1\n" |
---|
| 322 | " mov.l @r0,r0\n" |
---|
| 323 | " add r1,r0\n" |
---|
| 324 | " mov.l @r15+,r1\n" |
---|
| 325 | " jmp @r0\n" |
---|
| 326 | " mov.l @r15+,r0\n" |
---|
| 327 | " .align 2\n" |
---|
| 328 | "__ISR_temp_fpscr_k: \n" |
---|
| 329 | " .long " __STRINGIFY__(SH4_FPSCR_PR) " \n" |
---|
| 330 | "__VBR_Saved600_k:\n" |
---|
| 331 | " .long __VBR_Saved\n" |
---|
| 332 | "offset600_k:\n" |
---|
| 333 | " .long 0x600\n" |
---|
| 334 | |
---|
| 335 | ); |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | /************************************************ |
---|
| 339 | * Dummy interrupt service procedure for |
---|
| 340 | * interrupts being not allowed --> Trap 2 |
---|
| 341 | ************************************************/ |
---|
| 342 | asm(" .section .text |
---|
| 343 | .global __dummy_isp |
---|
| 344 | __dummy_isp: |
---|
| 345 | mov.l r14,@-r15 |
---|
| 346 | mov r15, r14 |
---|
| 347 | trapa #2 |
---|
| 348 | mov.l @r15+,r14 |
---|
| 349 | rte |
---|
| 350 | nop"); |
---|
| 351 | |
---|