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

4.104.114.84.95
Last change on this file since acc25ee was acc25ee, checked in by Joel Sherrill <joel.sherrill@…>, on 12/02/99 at 14:31:19

Merged of mcp750 and mvme2307 BSP by Eric Valette <valette@…>.
As part of this effort, the mpc750 libcpu code is now shared with the
ppc6xx.

  • Property mode set to 100644
File size: 5.5 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/*  void __ISR_Handler()
24 *
25 *  This routine provides the RTEMS interrupt management.
26 *  The vector number is in r0. R0 has already been stacked.
27 *
28 */
29        PUBLIC_VAR (_CPU_IRQ_info )
30
31        /* Finish off the interrupt frame */
32        stw     r2, IP_2(r1)
33        stw     r3, IP_3(r1)
34        stw     r4, IP_4(r1)
35        stw     r5, IP_5(r1)
36        stw     r6, IP_6(r1)
37        stw     r7, IP_7(r1)
38        stw     r8, IP_8(r1)
39        stw     r9, IP_9(r1)
40        stw     r10, IP_10(r1)
41        stw     r11, IP_11(r1)
42        stw     r12, IP_12(r1)
43        stw     r13, IP_13(r1)
44        stmw    r28, IP_28(r1)
45        mfcr    r5
46        mfctr   r6
47        mfxer   r7
48        mflr    r8
49        MFPC    (r9)
50        MFMSR   (r10)
51        /* Establish addressing */
52#if (PPC_USE_SPRG)
53        mfspr   r11, sprg3
54#else
55        lis     r11,_CPU_IRQ_info@ha
56        addi    r11,r11,_CPU_IRQ_info@l
57#endif
58        dcbt    r0, r11
59        stw     r5, IP_CR(r1)
60        stw     r6, IP_CTR(r1)
61        stw     r7, IP_XER(r1)
62        stw     r8, IP_LR(r1)
63        stw     r9, IP_PC(r1)
64        stw     r10, IP_MSR(r1)
65
66        lwz     r30, Vector_table(r11)
67        slwi    r4,r0,2
68        lwz     r28, Nest_level(r11)
69        add     r4, r4, r30
70       
71        lwz     r30, 0(r28)
72        mr      r3, r0
73        lwz     r31, Stack(r11)
74  /*
75   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
76   *    if ( _ISR_Nest_level == 0 )
77   *      switch to software interrupt stack
78   *  #endif
79   */
80        /* Switch stacks, here we must prevent ALL interrupts */
81#if (PPC_USE_SPRG)
82        mfmsr   r5         
83        mfspr   r6, sprg2   
84#else   
85        lwz     r6,msr_initial(r11)
86        lis     r5,~PPC_MSR_DISABLE_MASK@ha
87        ori     r5,r5,~PPC_MSR_DISABLE_MASK@l
88        and     r6,r6,r5
89        mfmsr   r5         
90#endif
91        mtmsr   r6
92        cmpwi   r30, 0
93        lwz     r29, Disable_level(r11)
94        subf    r31,r1,r31
95        bne     LABEL (nested)
96        stwux   r1,r1,r31
97LABEL (nested):
98  /*
99   *  _ISR_Nest_level++;
100   */
101        lwz     r31, 0(r29)
102        addi    r30,r30,1
103        stw     r30,0(r28)
104        /* From here on out, interrupts can be re-enabled. RTEMS
105         * convention says not.
106         */
107        lwz     r4,0(r4)
108  /*
109   *  _Thread_Dispatch_disable_level++;
110   */
111        addi    r31,r31,1
112        stw     r31, 0(r29)
113/* SCE 980217
114 *
115 * We need address translation ON when we call our ISR routine
116
117        mtmsr   r5
118
119 */
120
121  /*
122   *  (*_ISR_Vector_table[ vector ])( vector );
123   */
124#if (PPC_ABI == PPC_ABI_POWEROPEN)
125        lwz     r6,0(r4)
126        lwz     r2,4(r4)
127        mtlr    r6
128        lwz     r11,8(r4)
129#endif
130#if (PPC_ABI == PPC_ABI_GCC27)
131        lwz     r2, Default_r2(r11)
132        mtlr    r4
133        #lwz    r2, 0(r2)
134#endif
135#if (PPC_ABI == PPC_ABI_SVR4 || PPC_ABI == PPC_ABI_EABI)
136        mtlr    r4
137        lwz     r2, Default_r2(r11)
138        lwz     r13, Default_r13(r11)
139        #lwz    r2, 0(r2)
140        #lwz    r13, 0(r13)
141#endif
142        mr      r4,r1
143        blrl
144        /* NOP marker for debuggers */
145        or      r6,r6,r6
146
147        /*      We must re-disable the interrupts */
148#if (PPC_USE_SPRG)
149        mfspr   r11, sprg3
150        mfspr   r0, sprg2 
151#else
152        lis     r11,_CPU_IRQ_info@ha
153        addi    r11,r11,_CPU_IRQ_info@l
154        lwz     r0,msr_initial(r11)
155        lis     r30,~PPC_MSR_DISABLE_MASK@ha
156        ori     r30,r30,~PPC_MSR_DISABLE_MASK@l
157        and     r0,r0,r30
158#endif
159        mtmsr   r0
160        lwz     r30, 0(r28)
161        lwz     r31, 0(r29)
162
163  /*
164   *  if (--Thread_Dispatch_disable,--_ISR_Nest_level)
165   *    goto easy_exit;
166   */
167        addi    r30, r30, -1
168        cmpwi   r30, 0
169        addi    r31, r31, -1
170        stw     r30, 0(r28)
171        stw     r31, 0(r29)
172        bne     LABEL (easy_exit)
173        cmpwi   r31, 0
174
175        lwz     r30, Switch_necessary(r11)
176
177  /*
178   *  #if ( CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE )
179   *    restore stack
180   *  #endif
181   */
182        lwz     r1,0(r1)
183        bne     LABEL (easy_exit)
184        lwz     r30, 0(r30)
185        lwz     r31, Signal(r11)
186       
187  /* 
188   *  if ( _Context_Switch_necessary )
189   *    goto switch
190   */
191        cmpwi   r30, 0
192        lwz     r28, 0(r31)
193        li      r6,0
194        bne     LABEL (switch)
195  /* 
196   *  if ( !_ISR_Signals_to_thread_executing )
197   *    goto easy_exit
198   *  _ISR_Signals_to_thread_executing = 0;
199   */
200        cmpwi   r28, 0
201        beq     LABEL (easy_exit)
202
203  /*
204   * switch:
205   *  call _Thread_Dispatch() or prepare to return to _ISR_Dispatch
206   */
207LABEL (switch):
208        stw     r6, 0(r31)
209        /* Re-enable interrupts */
210        lwz     r0, IP_MSR(r1)
211#if (PPC_ABI == PPC_ABI_POWEROPEN)
212        lwz     r2, Dispatch_r2(r11)
213#else
214        /* R2 and R13 still hold their values from the last call */
215#endif
216        mtmsr   r0
217        bl      SYM (_Thread_Dispatch)
218        /* NOP marker for debuggers */
219        or      r6,r6,r6
220  /*
221   *  prepare to get out of interrupt
222   */
223        /* Re-disable IRQs */
224#if (PPC_USE_SPRG)
225        mfspr   r0, sprg2
226#else
227        lis     r11,_CPU_IRQ_info@ha
228        addi    r11,r11,_CPU_IRQ_info@l
229        lwz     r0,msr_initial(r11)
230        lis     r5,~PPC_MSR_DISABLE_MASK@ha
231        ori     r5,r5,~PPC_MSR_DISABLE_MASK@l
232        and     r0,r0,r5
233#endif
234        mtmsr   r0
235       
236  /*
237   *  easy_exit:
238   *  prepare to get out of interrupt
239   *  return from interrupt
240   */
241LABEL (easy_exit):
242        lwz     r5, IP_CR(r1)
243        lwz     r6, IP_CTR(r1)
244        lwz     r7, IP_XER(r1)
245        lwz     r8, IP_LR(r1)
246        lwz     r9, IP_PC(r1)
247        lwz     r10, IP_MSR(r1)
248        mtcrf   255,r5
249        mtctr   r6
250        mtxer   r7
251        mtlr    r8
252        MTPC    (r9)
253        MTMSR   (r10)
254        lwz     r0, IP_0(r1)
255        lwz     r2, IP_2(r1)
256        lwz     r3, IP_3(r1)
257        lwz     r4, IP_4(r1)
258        lwz     r5, IP_5(r1)
259        lwz     r6, IP_6(r1)
260        lwz     r7, IP_7(r1)
261        lwz     r8, IP_8(r1)
262        lwz     r9, IP_9(r1)
263        lwz     r10, IP_10(r1)
264        lwz     r11, IP_11(r1)
265        lwz     r12, IP_12(r1)
266        lwz     r13, IP_13(r1)
267        lmw     r28, IP_28(r1)
268        lwz     r1, 0(r1)
Note: See TracBrowser for help on using the repository browser.