]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/arm/sa11x0/sa11x0_irqhandler.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / arm / sa11x0 / sa11x0_irqhandler.c
1 /*      $NetBSD: sa11x0_irqhandler.c,v 1.5 2003/08/07 16:26:54 agc Exp $        */
2
3 /*-
4  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to the NetBSD Foundation
8  * by IWAMOTO Toshihiro.
9  *
10  * This code is derived from software contributed to The NetBSD Foundation
11  * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
12  * Simulation Facility, NASA Ames Research Center.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions
16  * are met:
17  * 1. Redistributions of source code must retain the above copyright
18  *    notice, this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright
20  *    notice, this list of conditions and the following disclaimer in the
21  *    documentation and/or other materials provided with the distribution.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 /*-
37  * Copyright (c) 1991 The Regents of the University of California.
38  * All rights reserved.
39  *
40  * This code is derived from software contributed to Berkeley by
41  * William Jolitz.
42  *
43  * Redistribution and use in source and binary forms, with or without
44  * modification, are permitted provided that the following conditions
45  * are met:
46  * 1. Redistributions of source code must retain the above copyright
47  *    notice, this list of conditions and the following disclaimer.
48  * 2. Redistributions in binary form must reproduce the above copyright
49  *    notice, this list of conditions and the following disclaimer in the
50  *    documentation and/or other materials provided with the distribution.
51  * 3. Neither the name of the University nor the names of its contributors
52  *    may be used to endorse or promote products derived from this software
53  *    without specific prior written permission.
54  *
55  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65  * SUCH DAMAGE.
66  *
67  *      @(#)isa.c       7.2 (Berkeley) 5/13/91
68  */
69
70
71 #include <sys/cdefs.h>
72 __FBSDID("$FreeBSD$");
73
74 #include <sys/param.h>
75 #include <sys/kernel.h>
76 #include <sys/systm.h>
77 #include <sys/syslog.h>
78 #include <sys/malloc.h>
79 #include <sys/bus.h>
80 #include <sys/interrupt.h>
81 #include <sys/rman.h>
82
83 #include <vm/vm.h>
84 #include <vm/vm_extern.h>
85
86 #include <arm/sa11x0/sa11x0_reg.h>
87 #include <arm/sa11x0/sa11x0_var.h>
88
89 #include <machine/cpu.h>
90 #include <machine/intr.h>
91
92 #define NIRQS 0x20
93 struct intrhand *irqhandlers[NIRQS];
94
95 int current_intr_depth;
96 extern struct sa11x0_softc *sa11x0_softc;
97
98
99 static uint32_t sa11x0_irq_mask = 0xfffffff;
100
101 extern vm_offset_t saipic_base;
102
103 int
104 arm_get_next_irq(int last __unused)
105 {
106         int irq;
107
108         if ((irq = (bus_space_read_4(sa11x0_softc->sc_iot, sa11x0_softc->sc_ioh,
109             SAIPIC_IP) &
110             sa11x0_irq_mask)) != 0)
111                 return (ffs(irq) - 1);
112         return (-1);
113 }
114
115 void
116 arm_mask_irq(uintptr_t irq)
117 {
118
119         sa11x0_irq_mask &= ~(1 << irq);
120         __asm __volatile("str   %0, [%1, #0x04]" /* SAIPIC_MR */
121             : : "r" (sa11x0_irq_mask), "r" (saipic_base));
122 }
123
124 void
125 arm_unmask_irq(uintptr_t irq)
126 {
127
128         sa11x0_irq_mask |= (1 << irq);
129         __asm __volatile("str   %0, [%1, #0x04]" /* SAIPIC_MR */
130             : : "r" (sa11x0_irq_mask), "r" (saipic_base));
131 }
132
133 void stray_irqhandler(void *);
134
135
136
137 void
138 stray_irqhandler(void *p)
139 {
140
141         printf("stray interrupt %p\n", p);
142 }
143 /* End of irqhandler.c */