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.4 2003/07/08 06:27:27 dillon Exp $
14 #ifndef _MACHINE_SMP_H_
15 #define _MACHINE_SMP_H_
19 #if defined(SMP) && !defined(APIC_IO)
20 # error APIC_IO required for SMP, add "options APIC_IO" to your config file.
21 #endif /* SMP && !APIC_IO */
23 #if defined(SMP) || defined(APIC_IO)
28 * For sending values to POST displays.
29 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
31 extern int current_postcode; /** XXX currently in mp_machdep.c */
32 #define POSTCODE(X) current_postcode = (X), \
33 outb(0x80, current_postcode)
34 #define POSTCODE_LO(X) current_postcode &= 0xf0, \
35 current_postcode |= ((X) & 0x0f), \
36 outb(0x80, current_postcode)
37 #define POSTCODE_HI(X) current_postcode &= 0x0f, \
38 current_postcode |= (((X) << 4) & 0xf0), \
39 outb(0x80, current_postcode)
42 #include <machine/apic.h>
44 /* global data in mpboot.s */
45 extern int bootMP_size;
47 /* functions in mpboot.s */
48 void bootMP __P((void));
50 /* global data in apic_vector.s */
51 extern volatile u_int stopped_cpus;
52 extern volatile u_int started_cpus;
54 extern volatile u_int checkstate_probed_cpus;
55 extern volatile u_int checkstate_need_ast;
56 extern volatile u_int resched_cpus;
57 extern void (*cpustop_restartfunc) __P((void));
59 /* functions in apic_ipl.s */
60 void apic_eoi __P((void));
61 u_int io_apic_read __P((int, int));
62 void io_apic_write __P((int, int, u_int));
64 /* global data in mp_machdep.c */
65 extern int bsp_apic_ready;
67 extern int mp_nbusses;
69 extern int mp_picmode;
70 extern int boot_cpu_id;
71 extern vm_offset_t cpu_apic_address;
72 extern vm_offset_t io_apic_address[];
73 extern u_int32_t cpu_apic_versions[];
74 extern u_int32_t *io_apic_versions;
75 extern int cpu_num_to_apic_id[];
76 extern int io_num_to_apic_id[];
77 extern int apic_id_to_logical[];
78 #define APIC_INTMAPSIZE 24
79 struct apic_intmapinfo {
82 volatile void *apic_address;
85 extern struct apic_intmapinfo int_to_apicintpin[];
86 extern u_int all_cpus;
87 extern struct pcb stoppcbs[];
89 /* functions in mp_machdep.c */
90 u_int mp_bootaddress __P((u_int));
91 int mp_probe __P((void));
92 void mp_start __P((void));
93 void mp_announce __P((void));
94 u_int isa_apic_mask __P((u_int));
95 int isa_apic_irq __P((int));
96 int pci_apic_irq __P((int, int, int));
97 int apic_irq __P((int, int));
98 int next_apic_irq __P((int));
99 int undirect_isa_irq __P((int));
100 int undirect_pci_irq __P((int));
101 int apic_bus_type __P((int));
102 int apic_src_bus_id __P((int, int));
103 int apic_src_bus_irq __P((int, int));
104 int apic_int_type __P((int, int));
105 int apic_trigger __P((int, int));
106 int apic_polarity __P((int, int));
107 void assign_apic_irq __P((int apic, int intpin, int irq));
108 void revoke_apic_irq __P((int irq));
109 void bsp_apic_configure __P((void));
110 void init_secondary __P((void));
111 int stop_cpus __P((u_int));
112 void ap_init __P((void));
113 int restart_cpus __P((u_int));
115 void forward_statclock __P((int pscnt));
116 void forward_hardclock __P((int pscnt));
117 #endif /* BETTER_CLOCK */
118 void forward_signal __P((struct proc *));
119 void forward_roundrobin __P((void));
120 #ifdef APIC_INTR_REORDER
121 void set_lapic_isrloc __P((int, int));
122 #endif /* APIC_INTR_REORDER */
123 void smp_rendezvous_action __P((void));
124 void smp_rendezvous __P((void (*)(void *),
129 /* global data in mpapic.c */
130 extern volatile lapic_t lapic;
131 extern volatile ioapic_t **ioapic;
133 /* functions in mpapic.c */
134 void apic_dump __P((char*));
135 void apic_initialize __P((void));
136 void imen_dump __P((void));
137 int apic_ipi __P((int, int, int));
138 int selected_apic_ipi __P((u_int, int, int));
139 int io_apic_setup __P((int));
140 void io_apic_setup_intpin __P((int, int));
141 void io_apic_set_id __P((int, int));
142 int io_apic_get_id __P((int));
143 int ext_int_setup __P((int, int));
146 void clr_io_apic_mask24 __P((int, u_int32_t));
147 void set_io_apic_mask24 __P((int, u_int32_t));
150 void set_apic_timer __P((int));
151 int read_apic_timer __P((void));
152 void u_sleep __P((int));
153 void cpu_send_ipiq __P((int));
155 /* global data in init_smp.c */
156 extern int invltlb_ok;
157 extern int smp_active;
158 extern int smp_started;
159 extern volatile int smp_idle_loops;
162 #else /* !SMP && !APIC_IO */
167 #endif /* _MACHINE_SMP_H_ */