2 * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
29 * $FreeBSD: src/sys/i386/include/apicvar.h,v 1.5 2003/11/14 22:21:30 peter Exp $
30 * $DragonFly: src/sys/platform/pc32/apic/apicvar.h,v 1.4 2007/04/30 16:45:55 dillon Exp $
33 #ifndef _MACHINE_APICVAR_H_
34 #define _MACHINE_APICVAR_H_
37 * Local && I/O APIC variable definitions.
41 * Layout of local APIC interrupt vectors:
43 * 0xff (255) +-------------+
44 * | | 15 (Spurious / IPIs / Local Interrupts)
45 * 0xf0 (240) +-------------+
46 * | | 14 (I/O Interrupts)
47 * 0xe0 (224) +-------------+
48 * | | 13 (I/O Interrupts)
49 * 0xd0 (208) +-------------+
50 * | | 12 (I/O Interrupts)
51 * 0xc0 (192) +-------------+
52 * | | 11 (I/O Interrupts)
53 * 0xb0 (176) +-------------+
54 * | | 10 (I/O Interrupts)
55 * 0xa0 (160) +-------------+
56 * | | 9 (I/O Interrupts)
57 * 0x90 (144) +-------------+
58 * | | 8 (I/O Interrupts / System Calls)
59 * 0x80 (128) +-------------+
60 * | | 7 (I/O Interrupts)
61 * 0x70 (112) +-------------+
62 * | | 6 (I/O Interrupts)
63 * 0x60 (96) +-------------+
64 * | | 5 (I/O Interrupts)
65 * 0x50 (80) +-------------+
66 * | | 4 (I/O Interrupts)
67 * 0x40 (64) +-------------+
68 * | | 3 (I/O Interrupts)
69 * 0x30 (48) +-------------+
70 * | | 2 (ATPIC Interrupts)
71 * 0x20 (32) +-------------+
72 * | | 1 (Exceptions, traps, faults, etc.)
73 * 0x10 (16) +-------------+
74 * | | 0 (Exceptions, traps, faults, etc.)
75 * 0x00 (0) +-------------+
77 * Note: 0x80 needs to be handled specially and not allocated to an
81 #define APIC_ID_ALL 0xff
82 #define APIC_IO_INTS (IDT_IO_INTS + 16)
83 #define APIC_NUM_IOINTS 192
85 #define APIC_LOCAL_INTS 240
87 /* XXX put APIC interrupt and IPI assignments here */
89 #define APIC_SPURIOUS_INT 255
97 #define LVT_MAX LVT_THERMAL
101 #define APIC_IPI_DEST_SELF -1
102 #define APIC_IPI_DEST_ALL -2
103 #define APIC_IPI_DEST_OTHERS -3
106 * An APIC enumerator is a psuedo bus driver that enumerates APIC's including
107 * CPU's and I/O APIC's.
109 struct apic_enumerator
{
110 const char *apic_name
;
111 int (*apic_probe
)(void);
112 int (*apic_probe_cpus
)(void);
113 int (*apic_setup_local
)(void);
114 int (*apic_setup_io
)(void);
115 SLIST_ENTRY(apic_enumerator
) apic_next
;
118 u_int
apic_irq_to_idt(u_int irq
);
119 u_int
apic_idt_to_irq(u_int vector
);
120 void apic_register_enumerator(struct apic_enumerator
*enumerator
);
121 void *ioapic_create(uintptr_t addr
, int32_t id
, int intbase
);
122 int ioapic_disable_pin(void *cookie
, u_int pin
);
123 void ioapic_enable_mixed_mode(void);
124 int ioapic_get_vector(void *cookie
, u_int pin
);
125 int ioapic_next_logical_cluster(void);
126 void ioapic_register(void *cookie
);
127 int ioapic_remap_vector(void *cookie
, u_int pin
, int vector
);
128 int ioapic_set_extint(void *cookie
, u_int pin
);
129 int ioapic_set_nmi(void *cookie
, u_int pin
);
130 int ioapic_set_polarity(void *cookie
, u_int pin
, char activehi
);
131 int ioapic_set_triggermode(void *cookie
, u_int pin
, char edgetrigger
);
132 int ioapic_set_smi(void *cookie
, u_int pin
);
133 void lapic_create(u_int apic_id
, int boot_cpu
);
134 void lapic_disable(void);
135 void lapic_dump(const char *str
);
136 void lapic_enable_intr(u_int vector
);
137 void lapic_eoi(void);
139 void lapic_init(uintptr_t addr
);
140 int lapic_intr_pending(u_int vector
);
141 void lapic_ipi_raw(register_t icrlo
, u_int dest
);
142 void lapic_ipi_vectored(u_int vector
, int dest
);
143 int lapic_ipi_wait(int delay
);
144 void lapic_handle_intr(struct intrframe
*frame
);
145 void lapic_set_logical_id(u_int apic_id
, u_int cluster
, u_int cluster_id
);
146 int lapic_set_lvt_mask(u_int apic_id
, u_int lvt
, u_char masked
);
147 int lapic_set_lvt_mode(u_int apic_id
, u_int lvt
, u_int32_t mode
);
148 int lapic_set_lvt_polarity(u_int apic_id
, u_int lvt
, u_char activehi
);
149 int lapic_set_lvt_triggermode(u_int apic_id
, u_int lvt
, u_char edgetrigger
);
150 void lapic_setup(void);
153 #endif /* _MACHINE_APICVAR_H_ */