source: rtems/c/src/exec/score/cpu/i960/cpu_asm.S @ 073e2411

4.104.114.84.95
Last change on this file since 073e2411 was bc85fd5a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/11/00 at 19:31:04

Reworked score/cpu/i960 so it can be safely compiled multilib. All
routines and structures that require CPU model specific information
are now in libcpu. This required significant rework of the
score/cpu header files and the creation of multiple header files
and subdirectories in libcpu/i960.

  • Property mode set to 100644
File size: 7.8 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.OARcorp.com/rtems/license.html.
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                  stq           g8, _ISR_reg_save                # save g8-g11
132                  stl           g12, _ISR_reg_save+16    # save g12-g13
133
134          ld        __ISR_Vector_table[g0*4],g1    # g1 = Users handler
135          addo      1,r5,r5                  # increment ISR level
136
137          st        r4,__Thread_Dispatch_disable_level
138                                             # one ISR nest level deeper
139          subo      1,r4,r4                  # decrement dispatch disable level
140
141          st        r5,__ISR_Nest_level      # disable multitasking
142          subo      1,r5,r5                  # decrement ISR nest level
143
144          callx     (g1)                     # invoke user ISR
145
146                                             # unnest multitasking
147          st        r5,__ISR_Nest_level      # one less ISR nest level
148          cmpobne.f 0,r4,exit                # If dispatch disabled, exit
149          ldl       -16(fp),g0               # g0 = threads PC reg
150                                             # g1 = threads AC reg
151          ld        __Context_Switch_necessary,r6
152                                             # r6 = Is thread switch necessary?
153          bbs.f     13,g0,exit               # not outer level, then exit
154          cmpobne.f 0,r6,bframe              # Switch necessary?
155
156          ld        __ISR_Signals_to_thread_executing,g2
157                                             # signals sent to Run_thread
158                                             #   while in interrupt handler?
159          cmpobe.f  0,g2,exit                # No, then exit
160
161bframe:   mov       0,g2
162          st        g2,__ISR_Signals_to_thread_executing
163
164          ldconst   0x1f0000,g2              # g2 = intr disable mask
165          mov       g2,g3                    # g3 = new intr level
166          modpc     0,g2,g3                  # set new level
167
168          andnot    7,pfp,r4                 # r4 = pfp without ret type
169          flushreg                           # flush registers
170                                             # push _Isr_dispatch ret frame
171                                             #   build ISF in r4-r6
172          ldconst   64,g2                    # g2 = size of stack frame
173          ld        4(r4),g3                 # g3 = previous sp
174          addo      g2,g3,r5                 # r5 = _Isr_dispatch SP
175          lda       __ISR_Dispatch,r6        # r6 = _Isr_dispatch entry
176          stt       r4,(g3)                  # set _Isr_dispatch ret info
177          st        g1,16(g3)                # set r4 = AC for ISR disp
178          or        7,g3,pfp                 # pfp to _Isr_dispatch
179          flushreg
180          b         exit1
181exit:     st        r4,__Thread_Dispatch_disable_level
182exit1:    mov       r7,g14                   # restore g14
183          movq      r8,g0                    # restore g0-g3
184          movq      r12,g4                   # restore g4-g7
185                  ldq           _ISR_reg_save, g8                # restore g8-g11
186                  ldl           _ISR_reg_save+16, g12    # restore g12-g13
187          ret
188
189
190/*PAGE
191 *
192 *  void __ISR_Dispatch()
193 *
194 *  Entry point from the outermost interrupt service routine exit.
195 *  The current stack is the supervisor mode stack.
196 */
197
198__ISR_Dispatch:
199        mov       g14,r7
200        mov       0,g14
201        movq      g0,r8
202        movq      g4,r12
203        call      __Thread_Dispatch
204
205        ldconst   -1,r5                    # r5 = reload mask
206        modac     r5,r4,r4                 # restore threads AC register
207        mov       r7,g14
208        movq      r8,g0
209        movq      r12,g4
210        ret
211
Note: See TracBrowser for help on using the repository browser.