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_
24 * For sending values to POST displays.
25 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
27 extern int current_postcode; /** XXX currently in mp_machdep.c */
28 #define POSTCODE(X) current_postcode = (X), \
29 outb(0x80, current_postcode)
30 #define POSTCODE_LO(X) current_postcode &= 0xf0, \
31 current_postcode |= ((X) & 0x0f), \
32 outb(0x80, current_postcode)
33 #define POSTCODE_HI(X) current_postcode &= 0x0f, \
34 current_postcode |= (((X) << 4) & 0xf0), \
35 outb(0x80, current_postcode)
38 #include <machine_base/apic/apicreg.h>
39 #include <machine/pcb.h>
41 /* global data in mpboot.s */
42 extern int bootMP_size;
44 /* functions in mpboot.s */
47 /* global data in apic_vector.s */
48 extern volatile cpumask_t stopped_cpus;
49 extern volatile cpumask_t started_cpus;
51 extern volatile u_int checkstate_probed_cpus;
52 extern void (*cpustop_restartfunc) (void);
54 /* functions in apic_ipl.s */
55 u_int ioapic_read (volatile void *, int);
56 void ioapic_write (volatile void *, int, u_int);
58 /* global data in mp_machdep.c */
59 extern int imcr_present;
61 extern u_int32_t cpu_apic_versions[];
62 extern int cpu_num_to_apic_id[];
63 extern int apic_id_to_logical[];
65 #define APIC_INTMAPSIZE 192
68 * - Keep size of apic_intmapinfo power of 2
69 * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
71 struct apic_intmapinfo {
74 volatile void *apic_address;
76 uint32_t flags; /* IOAPIC_IM_FLAG_ */
79 #define IOAPIC_IM_SZSHIFT 5
81 #define IOAPIC_IM_FLAG_LEVEL 0x1 /* default to edge trigger */
82 #define IOAPIC_IM_FLAG_MASKED 0x2
84 extern struct apic_intmapinfo int_to_apicintpin[];
85 extern struct pcb stoppcbs[];
87 /* functions in mp_machdep.c */
88 void *ioapic_map(vm_paddr_t);
89 u_int mp_bootaddress (u_int);
91 void mp_announce (void);
92 void mp_set_cpuids (int, int);
93 void init_secondary (void);
94 int stop_cpus (cpumask_t);
96 int restart_cpus (cpumask_t);
97 void forward_signal (struct proc *);
98 int mptable_pci_int_route(int, int, int, int);
99 void mptable_pci_int_dump(void);
101 #ifndef _SYS_QUEUE_H_
102 #include <sys/queue.h>
105 struct lapic_enumerator {
107 TAILQ_ENTRY(lapic_enumerator) lapic_link;
108 int (*lapic_probe)(struct lapic_enumerator *);
109 void (*lapic_enumerate)(struct lapic_enumerator *);
112 #define LAPIC_ENUM_PRIO_MPTABLE 20
113 #define LAPIC_ENUM_PRIO_MADT 40
115 struct ioapic_enumerator {
117 TAILQ_ENTRY(ioapic_enumerator) ioapic_link;
118 int (*ioapic_probe)(struct ioapic_enumerator *);
119 void (*ioapic_enumerate)(struct ioapic_enumerator *);
122 #define IOAPIC_ENUM_PRIO_MPTABLE 20
123 #define IOAPIC_ENUM_PRIO_MADT 40
125 /* global data in mpapic.c */
126 extern volatile lapic_t lapic;
132 /* functions in mpapic.c */
133 void apic_dump (char*);
134 void lapic_init (boolean_t);
135 int apic_ipi (int, int, int);
136 void selected_apic_ipi (cpumask_t, int, int);
137 void single_apic_ipi(int cpu, int vector, int delivery_mode);
138 int single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
139 void lapic_config(void);
140 void lapic_enumerator_register(struct lapic_enumerator *);
141 void ioapic_config(void);
142 void ioapic_enumerator_register(struct ioapic_enumerator *);
143 void ioapic_add(void *, int, int);
144 void ioapic_intsrc(int, int, enum intr_trigger, enum intr_polarity);
145 void *ioapic_gsi_ioaddr(int);
146 int ioapic_gsi_pin(int);
147 void ioapic_pin_setup(void *, int, int,
148 enum intr_trigger, enum intr_polarity);
149 void ioapic_extpin_setup(void *, int, int);
150 int ioapic_extpin_gsi(void);
151 int ioapic_gsi(int, int);
153 extern int apic_io_enable;
156 void clr_io_apic_mask24 (int, u_int32_t);
157 void set_io_apic_mask24 (int, u_int32_t);
160 void set_apic_timer (int);
161 int get_apic_timer_frequency(void);
162 int read_apic_timer (void);
164 void cpu_send_ipiq (int);
165 int cpu_send_ipiq_passive (int);
167 /* global data in init_smp.c */
168 extern cpumask_t smp_active_mask;
173 #define smp_active_mask 1 /* smp_active_mask always 1 on UP machines */
178 #endif /* _MACHINE_SMP_H_ */