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 * ----------------------------------------------------------------------------
13 #ifndef _MACHINE_SMP_H_
14 #define _MACHINE_SMP_H_
18 #if defined(SMP) && !defined(APIC_IO)
19 # error APIC_IO required for SMP, add "options APIC_IO" to your config file.
20 #endif /* SMP && !APIC_IO */
23 #if defined(SMP) && !defined(NCPU)
25 #endif /* SMP && NCPU */
27 /* Number of IO APICs. */
28 #if defined(APIC_IO) && !defined(NAPIC)
30 #endif /* SMP && NAPIC */
33 #if defined(SMP) || defined(APIC_IO)
38 * For sending values to POST displays.
39 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
41 extern int current_postcode; /** XXX currently in mp_machdep.c */
42 #define POSTCODE(X) current_postcode = (X), \
43 outb(0x80, current_postcode)
44 #define POSTCODE_LO(X) current_postcode &= 0xf0, \
45 current_postcode |= ((X) & 0x0f), \
46 outb(0x80, current_postcode)
47 #define POSTCODE_HI(X) current_postcode &= 0x0f, \
48 current_postcode |= (((X) << 4) & 0xf0), \
49 outb(0x80, current_postcode)
52 #include <machine/apic.h>
54 /* global data in mpboot.s */
55 extern int bootMP_size;
57 /* functions in mpboot.s */
58 void bootMP __P((void));
60 /* global data in mplock.s */
62 extern u_int isr_lock;
63 #ifdef RECURSIVE_MPINTRLOCK
64 extern u_int mpintr_lock;
65 #endif /* RECURSIVE_MPINTRLOCK */
67 /* functions in mplock.s */
68 void get_mplock __P((void));
69 void rel_mplock __P((void));
70 int try_mplock __P((void));
71 #ifdef RECURSIVE_MPINTRLOCK
72 void get_mpintrlock __P((void));
73 void rel_mpintrlock __P((void));
74 int try_mpintrlock __P((void));
75 #endif /* RECURSIVE_MPINTRLOCK */
77 /* global data in apic_vector.s */
78 extern volatile u_int stopped_cpus;
79 extern volatile u_int started_cpus;
81 extern volatile u_int checkstate_probed_cpus;
82 extern volatile u_int checkstate_need_ast;
83 extern volatile u_int resched_cpus;
84 extern void (*cpustop_restartfunc) __P((void));
86 /* functions in apic_ipl.s */
87 void apic_eoi __P((void));
88 u_int io_apic_read __P((int, int));
89 void io_apic_write __P((int, int, u_int));
91 /* global data in mp_machdep.c */
92 extern int bsp_apic_ready;
95 extern int mp_nbusses;
97 extern int mp_picmode;
98 extern int boot_cpu_id;
99 extern vm_offset_t cpu_apic_address;
100 extern vm_offset_t io_apic_address[];
101 extern u_int32_t cpu_apic_versions[];
102 extern u_int32_t io_apic_versions[];
103 extern int cpu_num_to_apic_id[];
104 extern int io_num_to_apic_id[];
105 extern int apic_id_to_logical[];
106 #define APIC_INTMAPSIZE 24
107 struct apic_intmapinfo {
110 volatile void *apic_address;
113 extern struct apic_intmapinfo int_to_apicintpin[];
114 extern u_int all_cpus;
115 extern struct pcb stoppcbs[];
117 /* functions in mp_machdep.c */
118 u_int mp_bootaddress __P((u_int));
119 int mp_probe __P((void));
120 void mp_start __P((void));
121 void mp_announce __P((void));
122 u_int isa_apic_mask __P((u_int));
123 int isa_apic_irq __P((int));
124 int pci_apic_irq __P((int, int, int));
125 int apic_irq __P((int, int));
126 int next_apic_irq __P((int));
127 int undirect_isa_irq __P((int));
128 int undirect_pci_irq __P((int));
129 int apic_bus_type __P((int));
130 int apic_src_bus_id __P((int, int));
131 int apic_src_bus_irq __P((int, int));
132 int apic_int_type __P((int, int));
133 int apic_trigger __P((int, int));
134 int apic_polarity __P((int, int));
135 void assign_apic_irq __P((int apic, int intpin, int irq));
136 void revoke_apic_irq __P((int irq));
137 void bsp_apic_configure __P((void));
138 void init_secondary __P((void));
139 void smp_invltlb __P((void));
140 int stop_cpus __P((u_int));
141 int restart_cpus __P((u_int));
143 void forward_statclock __P((int pscnt));
144 void forward_hardclock __P((int pscnt));
145 #endif /* BETTER_CLOCK */
146 void forward_signal __P((struct proc *));
147 void forward_roundrobin __P((void));
148 #ifdef APIC_INTR_REORDER
149 void set_lapic_isrloc __P((int, int));
150 #endif /* APIC_INTR_REORDER */
151 void smp_rendezvous_action __P((void));
152 void smp_rendezvous __P((void (*)(void *),
157 /* global data in mpapic.c */
158 extern volatile lapic_t lapic;
159 extern volatile ioapic_t *ioapic[];
161 /* functions in mpapic.c */
162 void apic_dump __P((char*));
163 void apic_initialize __P((void));
164 void imen_dump __P((void));
165 int apic_ipi __P((int, int, int));
166 int selected_apic_ipi __P((u_int, int, int));
167 int io_apic_setup __P((int));
168 int ext_int_setup __P((int, int));
171 void clr_io_apic_mask24 __P((int, u_int32_t));
172 void set_io_apic_mask24 __P((int, u_int32_t));
175 void set_apic_timer __P((int));
176 int read_apic_timer __P((void));
177 void u_sleep __P((int));
179 /* global data in init_smp.c */
180 extern int invltlb_ok;
181 extern int smp_active;
182 extern int smp_started;
183 extern volatile int smp_idle_loops;
186 #endif /* SMP || APIC_IO */
188 #endif /* _MACHINE_SMP_H_ */