Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / platform / pc32 / isa / intr_machdep.h
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * $FreeBSD: src/sys/i386/isa/intr_machdep.h,v 1.19.2.2 2001/10/14 20:05:50 luigi Exp $
34  * $DragonFly: src/sys/platform/pc32/isa/intr_machdep.h,v 1.2 2003/06/17 04:28:37 dillon Exp $
35  */
36
37 #ifndef _I386_ISA_INTR_MACHDEP_H_
38 #define _I386_ISA_INTR_MACHDEP_H_
39
40 /*
41  * Low level interrupt code.
42  */ 
43
44 #ifdef _KERNEL
45
46 #if defined(SMP) || defined(APIC_IO)
47 /*
48  * XXX FIXME: rethink location for all IPI vectors.
49  */
50
51 /*
52     APIC TPR priority vector levels:
53
54         0xff (255) +-------------+
55                    |             | 15 (IPIs: Xspuriousint)
56         0xf0 (240) +-------------+
57                    |             | 14
58         0xe0 (224) +-------------+
59                    |             | 13
60         0xd0 (208) +-------------+
61                    |             | 12
62         0xc0 (192) +-------------+
63                    |             | 11
64         0xb0 (176) +-------------+
65                    |             | 10 (IPIs: Xcpustop)
66         0xa0 (160) +-------------+
67                    |             |  9 (IPIs: Xinvltlb)
68         0x90 (144) +-------------+
69                    |             |  8 (linux/BSD syscall, IGNORE FAST HW INTS)
70         0x80 (128) +-------------+
71                    |             |  7 (FAST_INTR 16-23)
72         0x70 (112) +-------------+
73                    |             |  6 (FAST_INTR 0-15)
74         0x60 (96)  +-------------+
75                    |             |  5 (IGNORE HW INTS)
76         0x50 (80)  +-------------+
77                    |             |  4 (2nd IO APIC)
78         0x40 (64)  +------+------+
79                    |      |      |  3 (upper APIC hardware INTs: PCI)
80         0x30 (48)  +------+------+
81                    |             |  2 (start of hardware INTs: ISA)
82         0x20 (32)  +-------------+
83                    |             |  1 (exceptions, traps, etc.)
84         0x10 (16)  +-------------+
85                    |             |  0 (exceptions, traps, etc.)
86         0x00 (0)   +-------------+
87  */
88
89 /* IDT vector base for regular (aka. slow) and fast interrupts */
90 #define TPR_SLOW_INTS           0x20
91 #define TPR_FAST_INTS           0x60
92
93 /* blocking values for local APIC Task Priority Register */
94 #define TPR_BLOCK_HWI           0x4f            /* hardware INTs */
95 #define TPR_IGNORE_HWI          0x5f            /* ignore INTs */
96 #define TPR_BLOCK_FHWI          0x7f            /* hardware FAST INTs */
97 #define TPR_IGNORE_FHWI         0x8f            /* ignore FAST INTs */
98 #define TPR_BLOCK_XINVLTLB      0x9f            /*  */
99 #define TPR_BLOCK_XCPUSTOP      0xaf            /*  */
100 #define TPR_BLOCK_ALL           0xff            /* all INTs */
101
102
103 #ifdef TEST_TEST1
104 /* put a 'fake' HWI in top of APIC prio 0x3x, 32 + 31 = 63 = 0x3f */
105 #define XTEST1_OFFSET           (ICU_OFFSET + 31)
106 #endif /** TEST_TEST1 */
107
108 /* TLB shootdowns */
109 #define XINVLTLB_OFFSET         (ICU_OFFSET + 112)
110
111 #ifdef BETTER_CLOCK
112 /* inter-cpu clock handling */
113 #define XCPUCHECKSTATE_OFFSET   (ICU_OFFSET + 113)
114 #endif
115
116 /* inter-CPU rendezvous */
117 #define XRENDEZVOUS_OFFSET      (ICU_OFFSET + 114)
118
119 /* IPI to generate an additional software trap at the target CPU */
120 #define XCPUAST_OFFSET          (ICU_OFFSET +  48)
121
122 /* IPI to signal the CPU holding the ISR lock that another IRQ has appeared */
123 #define XFORWARD_IRQ_OFFSET     (ICU_OFFSET +  49)
124
125 /* IPI to signal CPUs to stop and wait for another CPU to restart them */
126 #define XCPUSTOP_OFFSET         (ICU_OFFSET + 128)
127
128 /*
129  * Note: this vector MUST be xxxx1111, 32 + 223 = 255 = 0xff:
130  */
131 #define XSPURIOUSINT_OFFSET     (ICU_OFFSET + 223)
132
133 #endif /* SMP || APIC_IO */
134
135 #ifndef LOCORE
136
137 /*
138  * Type of the first (asm) part of an interrupt handler.
139  */
140 typedef void inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss));
141
142 #define IDTVEC(name)    __CONCAT(X,name)
143
144 extern u_long *intr_countp[];   /* pointers into intrcnt[] */
145 extern inthand2_t *intr_handler[];      /* C entry points of intr handlers */
146 extern u_int intr_mask[];       /* sets of intrs masked during handling of 1 */
147 extern void *intr_unit[];       /* cookies to pass to intr handlers */
148
149 inthand_t
150         IDTVEC(fastintr0), IDTVEC(fastintr1),
151         IDTVEC(fastintr2), IDTVEC(fastintr3),
152         IDTVEC(fastintr4), IDTVEC(fastintr5),
153         IDTVEC(fastintr6), IDTVEC(fastintr7),
154         IDTVEC(fastintr8), IDTVEC(fastintr9),
155         IDTVEC(fastintr10), IDTVEC(fastintr11),
156         IDTVEC(fastintr12), IDTVEC(fastintr13),
157         IDTVEC(fastintr14), IDTVEC(fastintr15);
158 inthand_t
159         IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3),
160         IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7),
161         IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11),
162         IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15);
163
164 #if defined(SMP) || defined(APIC_IO)
165 inthand_t
166         IDTVEC(fastintr16), IDTVEC(fastintr17),
167         IDTVEC(fastintr18), IDTVEC(fastintr19),
168         IDTVEC(fastintr20), IDTVEC(fastintr21),
169         IDTVEC(fastintr22), IDTVEC(fastintr23);
170 inthand_t
171         IDTVEC(intr16), IDTVEC(intr17), IDTVEC(intr18), IDTVEC(intr19),
172         IDTVEC(intr20), IDTVEC(intr21), IDTVEC(intr22), IDTVEC(intr23);
173
174 inthand_t
175         Xinvltlb,       /* TLB shootdowns */
176 #ifdef BETTER_CLOCK
177         Xcpucheckstate, /* Check cpu state */
178 #endif
179         Xcpuast,        /* Additional software trap on other cpu */ 
180         Xforward_irq,   /* Forward irq to cpu holding ISR lock */
181         Xcpustop,       /* CPU stops & waits for another CPU to restart it */
182         Xspuriousint,   /* handle APIC "spurious INTs" */
183         Xrendezvous;    /* handle CPU rendezvous */
184
185 #ifdef TEST_TEST1
186 inthand_t
187         Xtest1;         /* 'fake' HWI at top of APIC prio 0x3x, 32+31 = 0x3f */
188 #endif /** TEST_TEST1 */
189 #endif /* SMP || APIC_IO */
190
191 void    isa_defaultirq __P((void));
192 int     isa_nmi __P((int cd));
193 int     icu_setup __P((int intr, inthand2_t *func, void *arg, 
194                        u_int *maskptr, int flags));
195 int     icu_unset __P((int intr, inthand2_t *handler));
196 int     update_intr_masks __P((void));
197
198 intrmask_t splq __P((intrmask_t mask));
199
200 #define INTR_FAST               0x00000001 /* fast interrupt handler */
201 #define INTR_EXCL               0x00010000 /* excl. intr, default is shared */
202
203 /*
204  * WARNING: These are internal functions and not to be used by device drivers!
205  * They are subject to change without notice. 
206  */
207 struct intrec *inthand_add(const char *name, int irq, inthand2_t handler,
208                            void *arg, intrmask_t *maskptr, int flags);
209
210 int inthand_remove(struct intrec *idesc);
211
212 #endif /* LOCORE */
213
214 #endif /* _KERNEL */
215
216 #endif /* !_I386_ISA_INTR_MACHDEP_H_ */