source: rtems/cpukit/score/cpu/i960/cpu_asm.S @ 3239698

4.104.114.84.95
Last change on this file since 3239698 was 3239698, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/15/04 at 13:26:21

Remove stray white spaces.

  • Property mode set to 100644
File size: 7.9 KB
Line 
1/*
2 *  This file contains all assembly code for the i960 port of RTEMS.
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13        .data
14_ISR_reg_save:
15        .word  0
16        .word  0
17        .word  0
18        .word  0
19        .word  0
20        .word  0
21
22          .text
23/*
24 * Format of i960ca Register structure
25 */
26
27.set REG_R0_PFP    , 0                # (r0)  Previous Frame Pointer
28.set REG_R1_SP     , REG_R0_PFP+4     # (r1)  Stack Pointer
29.set REG_PC        , REG_R1_SP+4      # (pc)  Processor Controls
30.set REG_G8        , REG_PC+4         # (g8)  Global Register 8
31.set REG_G9        , REG_G8+4         # (g9)  Global Register 9
32.set REG_G10       , REG_G9+4         # (g10) Global Register 10
33.set REG_G11       , REG_G10+4        # (g11) Global Register 11
34.set REG_G12       , REG_G11+4        # (g12) Global Register 12
35.set REG_G13       , REG_G12+4        # (g13) Global Register 13
36.set REG_G14       , REG_G13+4        # (g14) Global Register 14
37.set REG_G15_FP    , REG_G14+4        # (g15) Global Register 15
38.set SIZE_REGS     , REG_G15_FP+4     # size of cpu_context_registers
39                                      #    structure
40
41/*
42 *  void _CPU_Context_switch( run_context, heir_context )
43 *
44 *  This routine performs a normal non-FP context.
45 */
46          .align    4
47          .globl    __CPU_Context_switch
48
49__CPU_Context_switch:
50          modpc     0,0,g2                   # get old intr level (PC)
51          st        g2,REG_PC(g0)            # save pc
52          stq       g8,REG_G8(g0)            # save g8-g11
53          stq       g12,REG_G12(g0)          # save g12-g15
54          stl       pfp,REG_R0_PFP(g0)       # save pfp, sp
55
56restore:  flushreg                           # flush register cache
57          ldconst   0x001f0000,g2            # g2 = PC mask
58          ld        REG_PC(g1),g3            # thread->Regs.pc = pc;
59          ldq       REG_G12(g1),g12          # restore g12-g15
60          ldl       REG_R0_PFP(g1),pfp       # restore pfp, sp
61          ldq       REG_G8(g1),g8            # restore g8-g11
62          modpc     0,g2,g3                  # restore PC register
63          ret
64
65/*
66 *  void _CPU_Context_restore( new_context )
67 *
68 *  This routine performs a normal non-FP context.
69 */
70
71        .globl __CPU_Context_restore
72__CPU_Context_restore:
73          mov       g0,g1                    # g0 = _Thread_executing
74          b         restore
75
76/*PAGE
77 *  void _CPU_Context_save_fp_context( &fp_context_ptr )
78 *  void _CPU_Context_restore_fp_context( &fp_context_ptr )
79 *
80 *  There is currently no hardware floating point for the i960.
81 */
82
83          .globl    __CPU_Context_save_fp
84          .globl    __CPU_Context_restore_fp
85__CPU_Context_save_fp:
86__CPU_Context_restore_fp:
87#if ( I960_HAS_FPU == 1 )
88#error "Floating point support for i960 family has been implemented!!!"
89#endif
90          ret
91
92/*PAGE
93 *  void __ISR_Handler()
94 *
95 *  This routine provides the RTEMS interrupt management.
96 *
97 *  Input parameters:  NONE
98 *
99 *  Output parameters:  NONE
100 *
101 *  NOTE:
102 *    Upon entry, the supervisor stack will contain a stack frame
103 *    back to the interrupted thread and the interrupt stack will contain
104 *    an interrupt stack frame.  If dispatching is enabled, this
105 *    is the outer most interrupt, and (a context switch is necessary or
106 *    the current thread has signals), then set up the supervisor stack to
107 *    transfer control to the interrupt dispatcher.
108 */
109
110          .globl    __ISR_Handler
111__ISR_Handler:
112          #ldconst 1,r8
113          #modpc   0,r8,r8     # enable tracing
114
115                               # r4 = &_Thread_Dispatch_disable_level
116          ld         __Thread_Dispatch_disable_level,r4
117          movl      g0,r8                    # save g0-g1
118
119          ld        -16+8(fp),g0             # g0 = vector number
120          movl      g2,r10                   # save g2-g3
121
122          ld         __ISR_Nest_level,r5     # r5 = &_Isr_nest_level
123          mov       g14,r7                   # save g14
124
125          lda       0,g14                    # NOT Branch and Link
126          movl      g4,r12                   # save g4-g5
127
128          lda       1(r4),r4                 # increment dispatch disable level
129          movl      g6,r14                   # save g6-g7
130
131          ld        __ISR_Vector_table,g1    # g1 = base of vector table
132
133          stq       g8, _ISR_reg_save        # save g8-g11
134          stl       g12, _ISR_reg_save+16    # save g12-g13
135
136          ld        (g1)[g0*4],g1            # g1 = Users handler
137          addo      1,r5,r5                  # increment ISR level
138
139          st        r4,__Thread_Dispatch_disable_level
140                                             # one ISR nest level deeper
141          subo      1,r4,r4                  # decrement dispatch disable level
142
143          st        r5,__ISR_Nest_level      # disable multitasking
144          subo      1,r5,r5                  # decrement ISR nest level
145
146          callx     (g1)                     # invoke user ISR
147
148                                             # unnest multitasking
149          st        r5,__ISR_Nest_level      # one less ISR nest level
150          cmpobne.f 0,r4,exit                # If dispatch disabled, exit
151          ldl       -16(fp),g0               # g0 = threads PC reg
152                                             # g1 = threads AC reg
153          ld        __Context_Switch_necessary,r6
154                                             # r6 = Is thread switch necessary?
155          bbs.f     13,g0,exit               # not outer level, then exit
156          cmpobne.f 0,r6,bframe              # Switch necessary?
157
158          ld        __ISR_Signals_to_thread_executing,g2
159                                             # signals sent to Run_thread
160                                             #   while in interrupt handler?
161          cmpobe.f  0,g2,exit                # No, then exit
162
163bframe:   mov       0,g2
164          st        g2,__ISR_Signals_to_thread_executing
165
166          ldconst   0x1f0000,g2              # g2 = intr disable mask
167          mov       g2,g3                    # g3 = new intr level
168          modpc     0,g2,g3                  # set new level
169
170          andnot    7,pfp,r4                 # r4 = pfp without ret type
171          flushreg                           # flush registers
172                                             # push _Isr_dispatch ret frame
173                                             #   build ISF in r4-r6
174          ldconst   64,g2                    # g2 = size of stack frame
175          ld        4(r4),g3                 # g3 = previous sp
176          addo      g2,g3,r5                 # r5 = _Isr_dispatch SP
177          lda       __ISR_Dispatch,r6        # r6 = _Isr_dispatch entry
178          stt       r4,(g3)                  # set _Isr_dispatch ret info
179          st        g1,16(g3)                # set r4 = AC for ISR disp
180          or        7,g3,pfp                 # pfp to _Isr_dispatch
181          flushreg
182          b         exit1
183exit:     st        r4,__Thread_Dispatch_disable_level
184exit1:    mov       r7,g14                   # restore g14
185          movq      r8,g0                    # restore g0-g3
186          movq      r12,g4                   # restore g4-g7
187                  ldq           _ISR_reg_save, g8                # restore g8-g11
188                  ldl           _ISR_reg_save+16, g12    # restore g12-g13
189          ret
190
191
192/*PAGE
193 *
194 *  void __ISR_Dispatch()
195 *
196 *  Entry point from the outermost interrupt service routine exit.
197 *  The current stack is the supervisor mode stack.
198 */
199
200          .globl    __ISR_Dispatch
201__ISR_Dispatch:
202        mov       g14,r7
203        mov       0,g14
204        movq      g0,r8
205        movq      g4,r12
206        call      __Thread_Dispatch
207
208        ldconst   -1,r5                    # r5 = reload mask
209        modac     r5,r4,r4                 # restore threads AC register
210        mov       r7,g14
211        movq      r8,g0
212        movq      r12,g4
213        ret
Note: See TracBrowser for help on using the repository browser.