source: rtems/c/src/lib/libbsp/powerpc/support/old_exception_processing/irq_stub.S @ b5328149

4.104.114.84.95
Last change on this file since b5328149 was 0567cb2, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/10/05 at 15:13:34

2005-02-10 Ralf Corsepius <ralf.corsepius@…>

  • cpu.c, cpu_asm.S, irq_stub.S, rtems/score/ppc_offs.h: Remove PPC_ABI_POWEROPEN.
  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 *  This file contains the interrupt handler assembly code for the PowerPC
3 *  implementation of RTEMS.  It is #included from cpu_asm.s.
4 *
5 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
6 *
7 *  COPYRIGHT (c) 1995 by i-cubed ltd.
8 *
9 *  To anyone who acknowledges that this file is provided "AS IS"
10 *  without any express or implied warranty:
11 *      permission to use, copy, modify, and distribute this file
12 *      for any purpose is hereby granted without fee, provided that
13 *      the above copyright notice and this notice appears in all
14 *      copies, and that the name of i-cubed limited not be used in
15 *      advertising or publicity pertaining to distribution of the
16 *      software without specific, written prior permission.
17 *      i-cubed limited makes no representations about the suitability
18 *      of this software for any purpose.
19 *
20 *  $Id$
21 */
22
23/*
24 * FIXME: this file is bsp dependent.
25 */
26#include <bspopts.h>
27
28/*  void __ISR_Handler()
29 *
30 *  This routine provides the RTEMS interrupt management.
31 *  The vector number is in r0. R0 has already been stacked.
32 *
33 */
34        PUBLIC_VAR (_CPU_IRQ_info )
35
36        /* Finish off the interrupt frame */
37        stw     r2, IP_2(r1)
38        stw     r3, IP_3(r1)
39        stw     r4, IP_4(r1)
40        stw     r5, IP_5(r1)
41        stw     r6, IP_6(r1)
42        stw     r7, IP_7(r1)
43        stw     r8, IP_8(r1)
44        stw     r9, IP_9(r1)
45        stw     r10, IP_10(r1)
46        stw     r11, IP_11(r1)
47        stw     r12, IP_12(r1)
48        stw     r13, IP_13(r1)
49        stmw    r28, IP_28(r1)
50        mfcr    r5
51        mfctr   r6
52        mfxer   r7
53        mflr    r8
54        MFPC    (r9)
55        MFMSR   (r10)
56        /* Establish addressing */
57#if (PPC_USE_SPRG)
58        mfspr   r11, sprg3
59#else
60        lis     r11,_CPU_IRQ_info@ha
61        addi    r11,r11,_CPU_IRQ_info@l
62#endif
63#if ( PPC_USE_DATA_CACHE )
64        dcbt    r0, r11
65#endif
66        stw     r5, IP_CR(r1)
67        stw     r6, IP_CTR(r1)
68        stw     r7, IP_XER(r1)
69        stw     r8, IP_LR(r1)
70        stw     r9, IP_PC(r1)
71        stw     r10, IP_MSR(r1)
72
73        lwz     r30, Vector_table(r11)
74        slwi    r4,r0,2
75        lwz     r28, Nest_level(r11)
76        add     r4, r4, r30
77
78        lwz     r30, 0(r28)
79        mr      r3, r0
80        lwz     r31, Stack(r11)
81  /*
82   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
83   *    if ( _ISR_Nest_level == 0 )
84   *      switch to software interrupt stack
85   *  #endif
86   */
87        /* Switch stacks, here we must prevent ALL interrupts */
88#if (PPC_USE_SPRG)
89        mfmsr   r5
90        mfspr   r6, sprg2
91#else
92        lwz     r6,msr_initial(r11)
93        lis     r5,~PPC_MSR_DISABLE_MASK@ha
94        ori     r5,r5,~PPC_MSR_DISABLE_MASK@l
95        and     r6,r6,r5
96        mfmsr   r5
97#endif
98        mtmsr   r6
99        cmpwi   r30, 0
100        lwz     r29, Disable_level(r11)
101        subf    r31,r1,r31
102        bne     LABEL (nested)
103        stwux   r1,r1,r31
104LABEL (nested):
105  /*
106   *  _ISR_Nest_level++;
107   */
108        lwz     r31, 0(r29)
109        addi    r30,r30,1
110        stw     r30,0(r28)
111        /* From here on out, interrupts can be re-enabled. RTEMS
112         * convention says not.
113         */
114        lwz     r4,0(r4)
115  /*
116   *  _Thread_Dispatch_disable_level++;
117   */
118        addi    r31,r31,1
119        stw     r31, 0(r29)
120/* SCE 980217
121 *
122 * We need address translation ON when we call our ISR routine
123
124        mtmsr   r5
125
126 */
127
128  /*
129   *  (*_ISR_Vector_table[ vector ])( vector );
130   */
131#if (PPC_ABI == PPC_ABI_SVR4 || PPC_ABI == PPC_ABI_EABI)
132        mtlr    r4
133        lwz     r2, Default_r2(r11)
134        lwz     r13, Default_r13(r11)
135        #lwz    r2, 0(r2)
136        #lwz    r13, 0(r13)
137#endif
138        mr      r4,r1
139        blrl
140        /* NOP marker for debuggers */
141        or      r6,r6,r6
142
143        /*      We must re-disable the interrupts */
144#if (PPC_USE_SPRG)
145        mfspr   r11, sprg3
146        mfspr   r0, sprg2
147#else
148        lis     r11,_CPU_IRQ_info@ha
149        addi    r11,r11,_CPU_IRQ_info@l
150        lwz     r0,msr_initial(r11)
151        lis     r30,~PPC_MSR_DISABLE_MASK@ha
152        ori     r30,r30,~PPC_MSR_DISABLE_MASK@l
153        and     r0,r0,r30
154#endif
155        mtmsr   r0
156        lwz     r30, 0(r28)
157        lwz     r31, 0(r29)
158
159  /*
160   *  if (--Thread_Dispatch_disable,--_ISR_Nest_level)
161   *    goto easy_exit;
162   */
163        addi    r30, r30, -1
164        cmpwi   r30, 0
165        addi    r31, r31, -1
166        stw     r30, 0(r28)
167        stw     r31, 0(r29)
168        bne     LABEL (easy_exit)
169        cmpwi   r31, 0
170
171        lwz     r30, Switch_necessary(r11)
172
173  /*
174   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
175   *    restore stack
176   *  #endif
177   */
178        lwz     r1,0(r1)
179        bne     LABEL (easy_exit)
180        lwz     r30, 0(r30)
181        lwz     r31, Signal(r11)
182
183  /*
184   *  if ( _Context_Switch_necessary )
185   *    goto switch
186   */
187        cmpwi   r30, 0
188        lwz     r28, 0(r31)
189        li      r6,0
190        bne     LABEL (switch)
191  /*
192   *  if ( !_ISR_Signals_to_thread_executing )
193   *    goto easy_exit
194   *  _ISR_Signals_to_thread_executing = 0;
195   */
196        cmpwi   r28, 0
197        beq     LABEL (easy_exit)
198
199  /*
200   * switch:
201   *  call _Thread_Dispatch() or prepare to return to _ISR_Dispatch
202   */
203LABEL (switch):
204        stw     r6, 0(r31)
205        /* Re-enable interrupts */
206        lwz     r0, IP_MSR(r1)
207        /* R2 and R13 still hold their values from the last call */
208        mtmsr   r0
209        bl      SYM (_Thread_Dispatch)
210        /* NOP marker for debuggers */
211        or      r6,r6,r6
212  /*
213   *  prepare to get out of interrupt
214   */
215        /* Re-disable IRQs */
216#if (PPC_USE_SPRG)
217        mfspr   r0, sprg2
218#else
219        lis     r11,_CPU_IRQ_info@ha
220        addi    r11,r11,_CPU_IRQ_info@l
221        lwz     r0,msr_initial(r11)
222        lis     r5,~PPC_MSR_DISABLE_MASK@ha
223        ori     r5,r5,~PPC_MSR_DISABLE_MASK@l
224        and     r0,r0,r5
225#endif
226        mtmsr   r0
227
228  /*
229   *  easy_exit:
230   *  prepare to get out of interrupt
231   *  return from interrupt
232   */
233LABEL (easy_exit):
234        lwz     r5, IP_CR(r1)
235        lwz     r6, IP_CTR(r1)
236        lwz     r7, IP_XER(r1)
237        lwz     r8, IP_LR(r1)
238        lwz     r9, IP_PC(r1)
239        lwz     r10, IP_MSR(r1)
240        mtcrf   255,r5
241        mtctr   r6
242        mtxer   r7
243        mtlr    r8
244        MTPC    (r9)
245        MTMSR   (r10)
246        lwz     r0, IP_0(r1)
247        lwz     r2, IP_2(r1)
248        lwz     r3, IP_3(r1)
249        lwz     r4, IP_4(r1)
250        lwz     r5, IP_5(r1)
251        lwz     r6, IP_6(r1)
252        lwz     r7, IP_7(r1)
253        lwz     r8, IP_8(r1)
254        lwz     r9, IP_9(r1)
255        lwz     r10, IP_10(r1)
256        lwz     r11, IP_11(r1)
257        lwz     r12, IP_12(r1)
258        lwz     r13, IP_13(r1)
259        lmw     r28, IP_28(r1)
260        lwz     r1, 0(r1)
Note: See TracBrowser for help on using the repository browser.