1 /*-
2 * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
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. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: releng/5.2/sys/i386/include/apicvar.h 122710 2003-11-14 22:21:30Z peter $
30 */
31
32 #ifndef _MACHINE_APICVAR_H_
33 #define _MACHINE_APICVAR_H_
34
35 /*
36 * Local && I/O APIC variable definitions.
37 */
38
39 /*
40 * Layout of local APIC interrupt vectors:
41 *
42 * 0xff (255) +-------------+
43 * | | 15 (Spurious / IPIs / Local Interrupts)
44 * 0xf0 (240) +-------------+
45 * | | 14 (I/O Interrupts)
46 * 0xe0 (224) +-------------+
47 * | | 13 (I/O Interrupts)
48 * 0xd0 (208) +-------------+
49 * | | 12 (I/O Interrupts)
50 * 0xc0 (192) +-------------+
51 * | | 11 (I/O Interrupts)
52 * 0xb0 (176) +-------------+
53 * | | 10 (I/O Interrupts)
54 * 0xa0 (160) +-------------+
55 * | | 9 (I/O Interrupts)
56 * 0x90 (144) +-------------+
57 * | | 8 (I/O Interrupts / System Calls)
58 * 0x80 (128) +-------------+
59 * | | 7 (I/O Interrupts)
60 * 0x70 (112) +-------------+
61 * | | 6 (I/O Interrupts)
62 * 0x60 (96) +-------------+
63 * | | 5 (I/O Interrupts)
64 * 0x50 (80) +-------------+
65 * | | 4 (I/O Interrupts)
66 * 0x40 (64) +-------------+
67 * | | 3 (I/O Interrupts)
68 * 0x30 (48) +-------------+
69 * | | 2 (ATPIC Interrupts)
70 * 0x20 (32) +-------------+
71 * | | 1 (Exceptions, traps, faults, etc.)
72 * 0x10 (16) +-------------+
73 * | | 0 (Exceptions, traps, faults, etc.)
74 * 0x00 (0) +-------------+
75 *
76 * Note: 0x80 needs to be handled specially and not allocated to an
77 * I/O device!
78 */
79
80 #define APIC_ID_ALL 0xff
81 #define APIC_IO_INTS (IDT_IO_INTS + 16)
82 #define APIC_NUM_IOINTS 192
83
84 #define APIC_LOCAL_INTS 240
85 #define APIC_TIMER_INT APIC_LOCAL_INTS
86 #define APIC_ERROR_INT (APIC_LOCAL_INTS + 1)
87 #define APIC_THERMAL_INT (APIC_LOCAL_INTS + 2)
88
89 #define APIC_IPI_INTS (APIC_LOCAL_INTS + 3)
90 #define IPI_AST APIC_IPI_INTS /* Generate software trap. */
91 #define IPI_INVLTLB (APIC_IPI_INTS + 1) /* TLB Shootdown IPIs */
92 #define IPI_INVLPG (APIC_IPI_INTS + 2)
93 #define IPI_INVLRNG (APIC_IPI_INTS + 3)
94 #define IPI_LAZYPMAP (APIC_IPI_INTS + 4) /* Lazy pmap release. */
95 #define IPI_HARDCLOCK (APIC_IPI_INTS + 8) /* Inter-CPU clock handling. */
96 #define IPI_STATCLOCK (APIC_IPI_INTS + 9)
97 #define IPI_RENDEZVOUS (APIC_IPI_INTS + 10) /* Inter-CPU rendezvous. */
98 #define IPI_STOP (APIC_IPI_INTS + 11) /* Stop CPU until restarted. */
99
100 #define APIC_SPURIOUS_INT 255
101
102 #define LVT_LINT0 0
103 #define LVT_LINT1 1
104 #define LVT_TIMER 2
105 #define LVT_ERROR 3
106 #define LVT_PMC 4
107 #define LVT_THERMAL 5
108 #define LVT_MAX LVT_THERMAL
109
110 #ifndef LOCORE
111
112 #define APIC_IPI_DEST_SELF -1
113 #define APIC_IPI_DEST_ALL -2
114 #define APIC_IPI_DEST_OTHERS -3
115
116 /*
117 * An APIC enumerator is a psuedo bus driver that enumerates APIC's including
118 * CPU's and I/O APIC's.
119 */
120 struct apic_enumerator {
121 const char *apic_name;
122 int (*apic_probe)(void);
123 int (*apic_probe_cpus)(void);
124 int (*apic_setup_local)(void);
125 int (*apic_setup_io)(void);
126 SLIST_ENTRY(apic_enumerator) apic_next;
127 };
128
129 inthand_t
130 IDTVEC(apic_isr1), IDTVEC(apic_isr2), IDTVEC(apic_isr3),
131 IDTVEC(apic_isr4), IDTVEC(apic_isr5), IDTVEC(apic_isr6),
132 IDTVEC(apic_isr7), IDTVEC(spuriousint);
133
134 u_int apic_irq_to_idt(u_int irq);
135 u_int apic_idt_to_irq(u_int vector);
136 void apic_register_enumerator(struct apic_enumerator *enumerator);
137 void *ioapic_create(uintptr_t addr, int32_t id, int intbase);
138 int ioapic_disable_pin(void *cookie, u_int pin);
139 int ioapic_get_vector(void *cookie, u_int pin);
140 int ioapic_next_logical_cluster(void);
141 void ioapic_register(void *cookie);
142 int ioapic_remap_vector(void *cookie, u_int pin, int vector);
143 int ioapic_set_extint(void *cookie, u_int pin);
144 int ioapic_set_nmi(void *cookie, u_int pin);
145 int ioapic_set_polarity(void *cookie, u_int pin, char activehi);
146 int ioapic_set_triggermode(void *cookie, u_int pin, char edgetrigger);
147 int ioapic_set_smi(void *cookie, u_int pin);
148 void lapic_create(u_int apic_id, int boot_cpu);
149 void lapic_disable(void);
150 void lapic_dump(const char *str);
151 void lapic_enable_intr(u_int vector);
152 void lapic_eoi(void);
153 int lapic_id(void);
154 void lapic_init(uintptr_t addr);
155 int lapic_intr_pending(u_int vector);
156 void lapic_ipi_raw(register_t icrlo, u_int dest);
157 void lapic_ipi_vectored(u_int vector, int dest);
158 int lapic_ipi_wait(int delay);
159 void lapic_handle_intr(struct intrframe frame);
160 void lapic_set_logical_id(u_int apic_id, u_int cluster, u_int cluster_id);
161 int lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked);
162 int lapic_set_lvt_mode(u_int apic_id, u_int lvt, u_int32_t mode);
163 int lapic_set_lvt_polarity(u_int apic_id, u_int lvt, u_char activehi);
164 int lapic_set_lvt_triggermode(u_int apic_id, u_int lvt, u_char edgetrigger);
165 void lapic_setup(void);
166
167 #endif /* !LOCORE */
168 #endif /* _MACHINE_APICVAR_H_ */
Cache object: b23a380c3111e7eab6fd44425229544e
|