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 * ----------------------------------------------------------------------------
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 $
14 #ifndef _MACHINE_SMP_H_
15 #define _MACHINE_SMP_H_
21 /* XXX wrong header */
22 void initializecpu(void);
31 * For sending values to POST displays.
32 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
34 extern 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)
45 #include <machine_base/apic/apicreg.h>
46 #include <machine/pcb.h>
48 /* global symbols in mpboot.S */
49 extern char mptramp_start[];
50 extern char mptramp_end[];
51 extern u_int32_t mptramp_pagetables;
53 /* functions in mpboot.s */
56 /* global data in apic_vector.s */
57 extern volatile cpumask_t stopped_cpus;
58 extern volatile cpumask_t started_cpus;
60 extern volatile u_int checkstate_probed_cpus;
61 extern void (*cpustop_restartfunc) (void);
63 /* functions in apic_ipl.s */
64 u_int ioapic_read (volatile void *, int);
65 void ioapic_write (volatile void *, int, u_int);
67 /* global data in mp_machdep.c */
68 extern int imcr_present;
69 extern int apic_io_enable;
71 extern u_int32_t cpu_apic_versions[];
72 extern int cpu_num_to_apic_id[];
73 extern int apic_id_to_logical[];
75 #define APIC_INTMAPSIZE 192
78 * - Keep size of apic_intmapinfo power of 2
79 * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
81 struct apic_intmapinfo {
84 volatile void *apic_address;
86 uint32_t flags; /* IOAPIC_IM_FLAG_ */
89 #define IOAPIC_IM_SZSHIFT 5
91 #define IOAPIC_IM_FLAG_LEVEL 0x1 /* default to edge trigger */
92 #define IOAPIC_IM_FLAG_MASKED 0x2
94 extern struct apic_intmapinfo int_to_apicintpin[];
95 extern struct pcb stoppcbs[];
97 /* functions in mp_machdep.c */
98 void *ioapic_map(vm_paddr_t);
99 u_int mp_bootaddress (u_int);
100 void mp_start (void);
101 void mp_announce (void);
102 void mp_set_cpuids (int, int);
103 void init_secondary (void);
104 int stop_cpus (cpumask_t);
106 int restart_cpus (cpumask_t);
107 void forward_signal (struct proc *);
108 int mptable_pci_int_route(int, int, int, int);
109 void mptable_pci_int_dump(void);
111 #ifndef _SYS_QUEUE_H_
112 #include <sys/queue.h>
115 struct lapic_enumerator {
117 TAILQ_ENTRY(lapic_enumerator) lapic_link;
118 int (*lapic_probe)(struct lapic_enumerator *);
119 void (*lapic_enumerate)(struct lapic_enumerator *);
122 #define LAPIC_ENUM_PRIO_MPTABLE 20
123 #define LAPIC_ENUM_PRIO_MADT 40
125 struct ioapic_enumerator {
127 TAILQ_ENTRY(ioapic_enumerator) ioapic_link;
128 int (*ioapic_probe)(struct ioapic_enumerator *);
129 void (*ioapic_enumerate)(struct ioapic_enumerator *);
132 #define IOAPIC_ENUM_PRIO_MPTABLE 20
133 #define IOAPIC_ENUM_PRIO_MADT 40
135 /* global data in mpapic.c */
136 extern volatile lapic_t *lapic;
142 /* functions in mpapic.c */
143 void apic_dump (char*);
144 void lapic_init (boolean_t);
145 int apic_ipi (int, int, int);
146 void selected_apic_ipi (cpumask_t, int, int);
147 void single_apic_ipi(int cpu, int vector, int delivery_mode);
148 int single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
149 void lapic_config(void);
150 void lapic_enumerator_register(struct lapic_enumerator *);
151 void ioapic_config(void);
152 void ioapic_enumerator_register(struct ioapic_enumerator *);
153 void ioapic_add(void *, int, int);
154 void ioapic_intsrc(int, int, enum intr_trigger, enum intr_polarity);
155 void *ioapic_gsi_ioaddr(int);
156 int ioapic_gsi_pin(int);
157 void ioapic_pin_setup(void *, int, int,
158 enum intr_trigger, enum intr_polarity);
159 void ioapic_extpin_setup(void *, int, int);
160 int ioapic_extpin_gsi(void);
161 int ioapic_gsi(int, int);
164 void clr_io_apic_mask24 (int, u_int32_t);
165 void set_io_apic_mask24 (int, u_int32_t);
168 void set_apic_timer (int);
169 int get_apic_timer_frequency(void);
170 int read_apic_timer (void);
172 void cpu_send_ipiq (int);
173 int cpu_send_ipiq_passive (int);
175 /* global data in init_smp.c */
176 extern cpumask_t smp_active_mask;
181 #define smp_active_mask 1 /* smp_active_mask always 1 on UP machines */
186 #endif /* _MACHINE_SMP_H_ */