Merge branch 'vendor/FILE'
[dragonfly.git] / sys / platform / pc64 / isa / intr_machdep.h
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * Copyright (c) 2008 The DragonFly Project.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed by the University of
17  *      California, Berkeley and its contributors.
18  * 4. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * $FreeBSD: src/sys/i386/isa/intr_machdep.h,v 1.19.2.2 2001/10/14 20:05:50 luigi Exp $
35  * $DragonFly: src/sys/platform/pc64/isa/intr_machdep.h,v 1.1 2008/08/29 17:07:19 dillon Exp $
36  */
37
38 #ifndef _ARCH_ISA_INTR_MACHDEP_H_
39 #define _ARCH_ISA_INTR_MACHDEP_H_
40
41 #ifndef LOCORE
42 #ifndef _SYS_INTERRUPT_H_
43 #include <sys/interrupt.h>
44 #endif
45 #ifndef _SYS_SERIALIZE_H_
46 #include <sys/serialize.h>
47 #endif
48 #endif
49
50 /*
51  * Low level interrupt code.
52  */ 
53
54 #ifdef _KERNEL
55
56 #define IDT_OFFSET              0x20
57 #define IDT_OFFSET_SYSCALL      0x80
58 #define IDT_OFFSET_IPI          0xe0
59
60 #if defined(SMP)
61
62 /*
63  * Local APIC TPR priority vector levels:
64  *
65  *      0xff (255) +-------------+
66  *                 |             | 15 (IPIs: Xcpustop, Xspuriousint)
67  *      0xf0 (240) +-------------+
68  *                 |             | 14 (IPIs: Xinvltlb, Xipiq, Xtimer)
69  *      0xe0 (224) +-------------+
70  *                 |             | 13
71  *      0xd0 (208) +-------------+
72  *                 |             | 12
73  *      0xc0 (192) +-------------+
74  *                 |             | 11
75  *      0xb0 (176) +-------------+
76  *                 |             | 10
77  *      0xa0 (160) +-------------+
78  *                 |             |  9
79  *      0x90 (144) +-------------+
80  *                 |             |  8 (syscall at 0x80)
81  *      0x80 (128) +-------------+
82  *                 |             |  7
83  *      0x70 (112) +-------------+
84  *                 |             |  6
85  *      0x60 (96)  +-------------+
86  *                 |             |  5
87  *      0x50 (80)  +-------------+
88  *                 |             |  4
89  *      0x40 (64)  +-------------+
90  *                 |             |  3
91  *      0x30 (48)  +-------------+
92  *                 |             |  2 (hardware INTs)
93  *      0x20 (32)  +-------------+
94  *                 |             |  1 (exceptions, traps, etc.)
95  *      0x10 (16)  +-------------+
96  *                 |             |  0 (exceptions, traps, etc.)
97  *      0x00 (0)   +-------------+
98  */
99 #define TPR_STEP                0x10
100
101 /* Local APIC Task Priority Register */
102 #define TPR_IPI                 (IDT_OFFSET_IPI - 1)
103
104
105 /*
106  * IPI group1
107  */
108 #define IDT_OFFSET_IPIG1        IDT_OFFSET_IPI
109
110 /* TLB shootdowns */
111 #define XINVLTLB_OFFSET         (IDT_OFFSET_IPIG1 + 0)
112
113 /* IPI group1 1: unused (was inter-cpu clock handling) */
114 /* IPI group1 2: unused (was inter-cpu rendezvous) */
115
116 /* IPIQ rendezvous */
117 #define XIPIQ_OFFSET            (IDT_OFFSET_IPIG1 + 3)
118
119 /* TIMER rendezvous */
120 #define XTIMER_OFFSET           (IDT_OFFSET_IPIG1 + 4)
121
122 /* IPI group1 5 ~ 15: unused */
123
124
125 /*
126  * IPI group2
127  */
128 #define IDT_OFFSET_IPIG2        (IDT_OFFSET_IPIG1 + TPR_STEP)
129
130 /* IPI to signal CPUs to stop and wait for another CPU to restart them */
131 #define XCPUSTOP_OFFSET         (IDT_OFFSET_IPIG2 + 0)
132
133 /* IPI group2 1 ~ 14: unused */
134
135 /* NOTE: this vector MUST be xxxx1111 */
136 #define XSPURIOUSINT_OFFSET     (IDT_OFFSET_IPIG2 + 15)
137
138 #endif /* SMP */
139
140 #ifndef LOCORE
141
142 /*
143  * Type of the first (asm) part of an interrupt handler.
144  */
145 #ifndef JG_defined_inthand_t
146 #define JG_defined_inthand_t
147 typedef void inthand_t(u_int cs, u_int ef, u_int esp, u_int ss);
148 #endif
149
150 #define IDTVEC(name)    __CONCAT(X,name)
151
152 #if defined(SMP)
153 inthand_t
154         Xinvltlb,       /* TLB shootdowns */
155         Xcpuast,        /* Additional software trap on other cpu */ 
156         Xforward_irq,   /* Forward irq to cpu holding ISR lock */
157         Xcpustop,       /* CPU stops & waits for another CPU to restart it */
158         Xspuriousint,   /* handle APIC "spurious INTs" */
159         Xtimer,         /* handle LAPIC timer INT */
160         Xipiq;          /* handle lwkt_send_ipiq() requests */
161 #endif /* SMP */
162
163 void    isa_defaultirq (void);
164 int     isa_nmi (int cd);
165 void    icu_reinit (void);
166
167 #endif /* LOCORE */
168
169 #endif /* _KERNEL */
170
171 #endif /* !_ARCH_ISA_INTR_MACHDEP_H_ */