source: rtems/c/src/lib/libcpu/sh/sh7750/score/ispsh7750.c @ 3bcc0d8

4.104.114.84.95
Last change on this file since 3bcc0d8 was f08c3a86, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/01 at 21:00:22

2001-10-12 Joel Sherrill <joel@…>

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