]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/arm/sa11x0/sa11x0_irq.S
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / arm / sa11x0 / sa11x0_irq.S
1 /*      $NetBSD: sa11x0_irq.S,v 1.5 2003/03/31 19:52:35 chris Exp $     */
2
3 /*-
4  * Copyright (c) 1998 Mark Brinicombe.
5  * Copyright (c) 1998 Causality Limited
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to the NetBSD Foundation
9  * by IWAMOTO Toshihiro.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *      This product includes software developed by Mark Brinicombe
22  *      for the NetBSD Project.
23  * 4. The name of the company nor the name of the author may be used to
24  *    endorse or promote products derived from this software without specific
25  *    prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
28  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
31  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37  * SUCH DAMAGE.
38  *
39  */
40
41 #include "assym.s"
42 #include <machine/asm.h>
43 #include <machine/armreg.h>
44 #include <machine/asmacros.h>
45 #include <arm/sa11x0/sa11x0_reg.h>
46 __FBSDID("$FreeBSD$");
47 Lcurrent_intr_depth:
48         .word   _C_LABEL(current_intr_depth)
49
50         .globl  _C_LABEL(saipic_base)
51 _C_LABEL(saipic_base):
52         .word   0x00000000
53
54 #ifdef INTR_DEBUG
55 Ldbg_str:
56         .asciz  "irq_entry %x %x\n"
57 #endif
58
59 AST_LOCALS
60 /*
61  * Regsister usage
62  *
63  *  r6  - Address of current handler
64  *  r7  - Pointer to handler pointer list
65  *  r8  - Current IRQ requests.
66  *  r9  - Used to count through possible IRQ bits.
67  *  r10 - Base address of SAIP
68  */
69
70 ASENTRY_NP(irq_entry)
71         sub     lr, lr, #0x00000004     /* Adjust the lr */
72
73         PUSHFRAMEINSVC                  /* Push an interrupt frame */
74
75         /* Load r8 with the SAIPIC interrupt requests */
76
77         ldr     r10, _C_LABEL(saipic_base)
78         ldr     r8, [r10, #(SAIPIC_IP)] /* Load IRQ pending register */
79
80 #ifdef INTR_DEBUG
81         ldr     r2, [r10, #(SAIPIC_MR)]
82         adr     r0, Ldbg_str
83         mov     r1, r8
84         bl      _C_LABEL(printf)
85 #endif
86         /*
87          * Note that we have entered the IRQ handler.
88          * We are in SVC mode so we cannot use the processor mode
89          * to determine if we are in an IRQ. Instead we will count the
90          * each time the interrupt handler is nested.
91          */
92
93         ldr     r0, Lcurrent_intr_depth
94         ldr     r1, [r0]
95         add     r1, r1, #1
96         str     r1, [r0]
97
98         mov     r0, sp
99         mov     r1, r8
100         bl      _C_LABEL(arm_handler_execute)
101
102 #ifdef INTR_DEBUG
103         adr     r0, Ldbg_str
104         mov     r1, #3
105         ldr     r2, [r10, #(SAIPIC_MR)]
106         bl      _C_LABEL(printf)
107 #endif
108
109         /* Decrement the nest count */
110         ldr     r0, Lcurrent_intr_depth
111         ldr     r1, [r0]
112         sub     r1, r1, #1
113         str     r1, [r0]
114
115         DO_AST
116         PULLFRAMEFROMSVCANDEXIT
117
118         /* NOT REACHED */
119         b       . - 8
120 Lcnt:
121         .word   _C_LABEL(cnt)
122
123 ENTRY(sa11x0_activateirqs)
124         ldr     r0, _C_LABEL(saipic_base)
125         mov     r1, #0xffffffff
126         str     r1, [r0, #(SAIPIC_MR)]
127         mov     pc, lr
128 #ifdef IRQSTATS
129 Lintrcnt:
130         .word   _C_LABEL(intrcnt)
131 #endif
132
133         .global _C_LABEL(intrnames), _C_LABEL(eintrnames)
134         .global _C_LABEL(eintrcnt)
135 _C_LABEL(intrnames): 
136 _C_LABEL(eintrnames):
137 _C_LABEL(eintrcnt):
138
139         .globl  _C_LABEL(intrcnt), _C_LABEL(sintrcnt)
140
141 _C_LABEL(intrcnt):
142         .space  ICU_LEN*4  /* XXX Should be linked to number of interrupts */
143
144 _C_LABEL(sintrcnt):
145         .space 32*4