x86_64: Remove old IOAPIC code
[dragonfly.git] / sys / platform / pc64 / include / smp.h
CommitLineData
46d4e165 1/*
b6871f55
YY
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 *
46d4e165
JG
9 * $FreeBSD: src/sys/i386/include/smp.h,v 1.50.2.5 2001/02/13 22:32:45 tegge Exp $
10 * $DragonFly: src/sys/platform/pc32/include/smp.h,v 1.20 2006/11/07 06:43:24 dillon Exp $
b6871f55
YY
11 *
12 */
13
14#ifndef _MACHINE_SMP_H_
15#define _MACHINE_SMP_H_
16
17#ifdef _KERNEL
18
6e738e4e
SS
19#ifndef LOCORE
20
21/* XXX wrong header */
22void initializecpu(void);
23
24#endif /* LOCORE */
25
46d4e165 26#if defined(SMP)
b6871f55
YY
27
28#ifndef LOCORE
29
46d4e165
JG
30/*
31 * For sending values to POST displays.
32 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
33 */
34extern int current_postcode; /** XXX currently in mp_machdep.c */
35#define POSTCODE(X) current_postcode = (X), \
36 outb(0x80, current_postcode)
37#define POSTCODE_LO(X) current_postcode &= 0xf0, \
38 current_postcode |= ((X) & 0x0f), \
39 outb(0x80, current_postcode)
40#define POSTCODE_HI(X) current_postcode &= 0x0f, \
41 current_postcode |= (((X) << 4) & 0xf0), \
42 outb(0x80, current_postcode)
43
44
45#include <machine_base/apic/apicreg.h>
b6871f55
YY
46#include <machine/pcb.h>
47
48/* global symbols in mpboot.S */
49extern char mptramp_start[];
50extern char mptramp_end[];
51extern u_int32_t mptramp_pagetables;
52
46d4e165
JG
53/* functions in mpboot.s */
54void bootMP (void);
55
56/* global data in apic_vector.s */
da23a592
MD
57extern volatile cpumask_t stopped_cpus;
58extern volatile cpumask_t started_cpus;
46d4e165
JG
59
60extern volatile u_int checkstate_probed_cpus;
61extern void (*cpustop_restartfunc) (void);
62
63/* functions in apic_ipl.s */
e17120aa
SZ
64u_int ioapic_read (volatile void *, int);
65void ioapic_write (volatile void *, int, u_int);
46d4e165 66
b6871f55 67/* global data in mp_machdep.c */
9d758cc4 68extern int imcr_present;
faaf4131 69extern int apic_io_enable;
b6871f55 70extern int mp_naps;
46d4e165 71extern int mp_napics;
46d4e165
JG
72extern vm_offset_t io_apic_address[];
73extern u_int32_t cpu_apic_versions[];
74extern u_int32_t *io_apic_versions;
75extern int cpu_num_to_apic_id[];
76extern int io_num_to_apic_id[];
77extern int apic_id_to_logical[];
c571da4a 78#define APIC_INTMAPSIZE 192
4ceff811
SZ
79/*
80 * NOTE:
81 * - Keep size of apic_intmapinfo power of 2
82 * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
83 */
46d4e165
JG
84struct apic_intmapinfo {
85 int ioapic;
86 int int_pin;
87 volatile void *apic_address;
4ceff811
SZ
88 int redirindex;
89 uint32_t flags; /* IOAPIC_IM_FLAG_ */
90 uint32_t pad[2];
46d4e165 91};
4ceff811 92#define IOAPIC_IM_SZSHIFT 5
54d63b2f 93
dfeaac88
SZ
94#define IOAPIC_IM_FLAG_LEVEL 0x1 /* default to edge trigger */
95#define IOAPIC_IM_FLAG_MASKED 0x2
54d63b2f 96
46d4e165 97extern struct apic_intmapinfo int_to_apicintpin[];
b6871f55 98extern struct pcb stoppcbs[];
b6871f55
YY
99
100/* functions in mp_machdep.c */
01616f8b 101void *ioapic_map(vm_paddr_t);
46d4e165 102u_int mp_bootaddress (u_int);
46d4e165
JG
103void mp_start (void);
104void mp_announce (void);
40d323b6 105void mp_set_cpuids (int, int);
46d4e165
JG
106u_int isa_apic_mask (u_int);
107int isa_apic_irq (int);
108int pci_apic_irq (int, int, int);
109int apic_irq (int, int);
110int next_apic_irq (int);
111int undirect_isa_irq (int);
112int undirect_pci_irq (int);
113int apic_bus_type (int);
114int apic_src_bus_id (int, int);
115int apic_src_bus_irq (int, int);
116int apic_int_type (int, int);
117int apic_trigger (int, int);
118int apic_polarity (int, int);
119void assign_apic_irq (int apic, int intpin, int irq);
120void revoke_apic_irq (int irq);
121void init_secondary (void);
da23a592 122int stop_cpus (cpumask_t);
46d4e165 123void ap_init (void);
da23a592 124int restart_cpus (cpumask_t);
46d4e165 125void forward_signal (struct proc *);
e90e7ac4
SZ
126int mptable_pci_int_route(int, int, int, int);
127void mptable_pci_int_dump(void);
46d4e165 128
91903a05
MN
129#ifndef _SYS_QUEUE_H_
130#include <sys/queue.h>
131#endif
132
133struct lapic_enumerator {
134 int lapic_prio;
135 TAILQ_ENTRY(lapic_enumerator) lapic_link;
136 int (*lapic_probe)(struct lapic_enumerator *);
137 void (*lapic_enumerate)(struct lapic_enumerator *);
138};
139
65b2387f
SZ
140#define LAPIC_ENUM_PRIO_MPTABLE 20
141#define LAPIC_ENUM_PRIO_MADT 40
142
143struct ioapic_enumerator {
144 int ioapic_prio;
145 TAILQ_ENTRY(ioapic_enumerator) ioapic_link;
146 int (*ioapic_probe)(struct ioapic_enumerator *);
147 void (*ioapic_enumerate)(struct ioapic_enumerator *);
148};
149
150#define IOAPIC_ENUM_PRIO_MPTABLE 20
8589df2b 151#define IOAPIC_ENUM_PRIO_MADT 40
91903a05 152
46d4e165
JG
153/* global data in mpapic.c */
154extern volatile lapic_t *lapic;
155extern volatile ioapic_t **ioapic;
c5c405ff 156extern int lapic_id_max;
46d4e165 157
ecec8ddc
SZ
158#ifndef _SYS_BUS_H_
159#include <sys/bus.h>
160#endif
161
46d4e165
JG
162/* functions in mpapic.c */
163void apic_dump (char*);
5ddeabb9 164void lapic_init (boolean_t);
46d4e165
JG
165void imen_dump (void);
166int apic_ipi (int, int, int);
da23a592 167void selected_apic_ipi (cpumask_t, int, int);
46d4e165
JG
168void single_apic_ipi(int cpu, int vector, int delivery_mode);
169int single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
170int io_apic_setup (int);
171void io_apic_setup_intpin (int, int);
172void io_apic_set_id (int, int);
173int io_apic_get_id (int);
174int ext_int_setup (int, int);
91903a05
MN
175void lapic_config(void);
176void lapic_enumerator_register(struct lapic_enumerator *);
65b2387f
SZ
177void ioapic_config(void);
178void ioapic_enumerator_register(struct ioapic_enumerator *);
ebf4f417 179void ioapic_add(void *, int, int);
ae80be10 180void ioapic_intsrc(int, int, enum intr_trigger, enum intr_polarity);
23b08e03
SZ
181void *ioapic_gsi_ioaddr(int);
182int ioapic_gsi_pin(int);
ecec8ddc
SZ
183void ioapic_pin_setup(void *, int, int,
184 enum intr_trigger, enum intr_polarity);
185void ioapic_extpin_setup(void *, int, int);
6b809ec7 186int ioapic_extpin_gsi(void);
e90e7ac4 187int ioapic_gsi(int, int);
8e4c6923 188
46d4e165
JG
189#if defined(READY)
190void clr_io_apic_mask24 (int, u_int32_t);
191void set_io_apic_mask24 (int, u_int32_t);
192#endif /* READY */
193
194void set_apic_timer (int);
bb467734 195int get_apic_timer_frequency(void);
46d4e165
JG
196int read_apic_timer (void);
197void u_sleep (int);
198void cpu_send_ipiq (int);
199int cpu_send_ipiq_passive (int);
200
201/* global data in init_smp.c */
202extern cpumask_t smp_active_mask;
b6871f55
YY
203
204#endif /* !LOCORE */
46d4e165 205#else /* !SMP */
b6871f55 206
46d4e165 207#define smp_active_mask 1 /* smp_active_mask always 1 on UP machines */
b6871f55 208
46d4e165 209#endif
b6871f55
YY
210
211#endif /* _KERNEL */
212#endif /* _MACHINE_SMP_H_ */