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 u_int stopped_cpus
;
49 extern volatile u_int started_cpus
;
51 extern volatile u_int checkstate_probed_cpus
;
52 extern void (*cpustop_restartfunc
) (void);
54 /* functions in apic_ipl.s */
56 u_int
io_apic_read (int, int);
57 void io_apic_write (int, int, u_int
);
59 /* global data in mp_machdep.c */
62 extern vm_offset_t io_apic_address
[];
63 extern u_int32_t cpu_apic_versions
[];
64 extern u_int32_t
*io_apic_versions
;
65 extern int cpu_num_to_apic_id
[];
66 extern int io_num_to_apic_id
[];
67 extern int apic_id_to_logical
[];
68 #define APIC_INTMAPSIZE 24
71 * - Keep size of apic_intmapinfo power of 2
72 * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
74 struct apic_intmapinfo
{
77 volatile void *apic_address
;
79 uint32_t flags
; /* IOAPIC_IM_FLAG_ */
82 #define IOAPIC_IM_SZSHIFT 5
84 #define IOAPIC_IM_FLAG_LEVEL 0x1 /* default to edge trigger */
86 extern struct apic_intmapinfo int_to_apicintpin
[];
87 extern struct pcb stoppcbs
[];
89 /* functions in mp_machdep.c */
90 void *permanent_io_mapping(vm_paddr_t
);
91 u_int
mp_bootaddress (u_int
);
93 void mp_announce (void);
94 void mp_set_cpuids (int, int);
95 u_int
isa_apic_mask (u_int
);
96 int isa_apic_irq (int);
97 int pci_apic_irq (int, int, int);
98 int apic_irq (int, int);
99 int next_apic_irq (int);
100 int undirect_isa_irq (int);
101 int undirect_pci_irq (int);
102 int apic_bus_type (int);
103 int apic_src_bus_id (int, int);
104 int apic_src_bus_irq (int, int);
105 int apic_int_type (int, int);
106 int apic_trigger (int, int);
107 int apic_polarity (int, int);
108 void assign_apic_irq (int apic
, int intpin
, int irq
);
109 void revoke_apic_irq (int irq
);
110 void init_secondary (void);
111 int stop_cpus (u_int
);
113 int restart_cpus (u_int
);
114 void forward_signal (struct proc
*);
116 #ifndef _SYS_QUEUE_H_
117 #include <sys/queue.h>
120 struct lapic_enumerator
{
122 TAILQ_ENTRY(lapic_enumerator
) lapic_link
;
123 int (*lapic_probe
)(struct lapic_enumerator
*);
124 void (*lapic_enumerate
)(struct lapic_enumerator
*);
127 #define LAPIC_ENUM_PRIO_MPTABLE 20
128 #define LAPIC_ENUM_PRIO_MADT 40
130 /* global data in mpapic.c */
131 extern volatile lapic_t lapic
;
132 extern volatile ioapic_t
**ioapic
;
134 /* functions in mpapic.c */
135 void apic_dump (char*);
136 void apic_initialize (boolean_t
);
137 void imen_dump (void);
138 int apic_ipi (int, int, int);
139 void selected_apic_ipi (u_int
, int, int);
140 void single_apic_ipi(int cpu
, int vector
, int delivery_mode
);
141 int single_apic_ipi_passive(int cpu
, int vector
, int delivery_mode
);
142 int io_apic_setup (int);
143 void io_apic_setup_intpin (int, int);
144 void io_apic_set_id (int, int);
145 int io_apic_get_id (int);
146 int ext_int_setup (int, int);
147 void lapic_config(void);
148 void lapic_enumerator_register(struct lapic_enumerator
*);
151 void clr_io_apic_mask24 (int, u_int32_t
);
152 void set_io_apic_mask24 (int, u_int32_t
);
155 void set_apic_timer (int);
156 int read_apic_timer (void);
158 void cpu_send_ipiq (int);
159 int cpu_send_ipiq_passive (int);
161 /* global data in init_smp.c */
162 extern cpumask_t smp_active_mask
;
167 #define smp_active_mask 1 /* smp_active_mask always 1 on UP machines */
172 #endif /* _MACHINE_SMP_H_ */