xref: /dragonfly/sys/platform/pc64/apic/apicvar.h (revision fcf53d9b)
1 /*-
2  * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
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. Neither the name of the author nor the names of any co-contributors
15  *    may be used to endorse or promote products derived from this software
16  *    without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD: src/sys/i386/include/apicvar.h,v 1.5 2003/11/14 22:21:30 peter Exp $
31  * $DragonFly: src/sys/platform/pc64/apic/apicvar.h,v 1.1 2008/08/29 17:07:12 dillon Exp $
32  */
33 
34 #ifndef _MACHINE_APICVAR_H_
35 #define _MACHINE_APICVAR_H_
36 
37 /*
38  * Local && I/O APIC variable definitions.
39  */
40 
41 #define	LVT_LINT0	0
42 #define	LVT_LINT1	1
43 #define	LVT_TIMER	2
44 #define	LVT_ERROR	3
45 #define	LVT_PMC		4
46 #define	LVT_THERMAL	5
47 #define	LVT_MAX		LVT_THERMAL
48 
49 #ifndef LOCORE
50 
51 #define	APIC_IPI_DEST_SELF	-1
52 #define	APIC_IPI_DEST_ALL	-2
53 #define	APIC_IPI_DEST_OTHERS	-3
54 
55 /*
56  * An APIC enumerator is a psuedo bus driver that enumerates APIC's including
57  * CPU's and I/O APIC's.
58  */
59 struct apic_enumerator {
60 	const char *apic_name;
61 	int (*apic_probe)(void);
62 	int (*apic_probe_cpus)(void);
63 	int (*apic_setup_local)(void);
64 	int (*apic_setup_io)(void);
65 	SLIST_ENTRY(apic_enumerator) apic_next;
66 };
67 
68 u_int	apic_irq_to_idt(u_int irq);
69 u_int	apic_idt_to_irq(u_int vector);
70 void	apic_register_enumerator(struct apic_enumerator *enumerator);
71 void	*ioapic_create(uintptr_t addr, int32_t id, int intbase);
72 int	ioapic_disable_pin(void *cookie, u_int pin);
73 void	ioapic_enable_mixed_mode(void);
74 int	ioapic_get_vector(void *cookie, u_int pin);
75 int	ioapic_next_logical_cluster(void);
76 void	ioapic_register(void *cookie);
77 int	ioapic_remap_vector(void *cookie, u_int pin, int vector);
78 int	ioapic_set_extint(void *cookie, u_int pin);
79 int	ioapic_set_nmi(void *cookie, u_int pin);
80 int	ioapic_set_polarity(void *cookie, u_int pin, char activehi);
81 int	ioapic_set_triggermode(void *cookie, u_int pin, char edgetrigger);
82 int	ioapic_set_smi(void *cookie, u_int pin);
83 void	lapic_create(u_int apic_id, int boot_cpu);
84 void	lapic_disable(void);
85 void	lapic_dump(const char *str);
86 void	lapic_enable_intr(u_int vector);
87 void	lapic_eoi(void);
88 int	lapic_id(void);
89 int	lapic_intr_pending(u_int vector);
90 void	lapic_ipi_raw(register_t icrlo, u_int dest);
91 void	lapic_ipi_vectored(u_int vector, int dest);
92 int	lapic_ipi_wait(int delay);
93 void	lapic_handle_intr(struct intrframe *frame);
94 void	lapic_set_logical_id(u_int apic_id, u_int cluster, u_int cluster_id);
95 int	lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked);
96 int	lapic_set_lvt_mode(u_int apic_id, u_int lvt, u_int32_t mode);
97 int	lapic_set_lvt_polarity(u_int apic_id, u_int lvt, u_char activehi);
98 int	lapic_set_lvt_triggermode(u_int apic_id, u_int lvt, u_char edgetrigger);
99 void	lapic_setup(void);
100 
101 #endif /* !LOCORE */
102 #endif /* _MACHINE_APICVAR_H_ */
103