xref: /freebsd/sys/amd64/include/smp.h (revision 9a3b3e8bce8e8c8bbec663229e16bebb3cfc5d53)
1 /*
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  * ----------------------------------------------------------------------------
8  *
9  * $Id: smp.h,v 1.29 1997/08/24 20:33:24 fsmp Exp $
10  *
11  */
12 
13 #ifndef _MACHINE_SMP_H_
14 #define _MACHINE_SMP_H_
15 
16 #ifdef KERNEL
17 
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 */
21 
22 /* Number of CPUs. */
23 #if defined(SMP) && !defined(NCPU)
24 # define NCPU			2
25 #endif /* SMP && NCPU */
26 
27 /* Number of IO APICs. */
28 #if defined(APIC_IO) && !defined(NAPIC)
29 # define NAPIC			1
30 #endif /* SMP && NAPIC */
31 
32 
33 #if defined(SMP) || defined(APIC_IO)
34 
35 #ifndef LOCORE
36 
37 /*
38  * For sending values to POST displays.
39  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
40  */
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)
50 
51 
52 #include <machine/apic.h>
53 
54 /* global data in mpboot.s */
55 extern int			bootMP_size;
56 
57 /* functions in mpboot.s */
58 void	bootMP			__P((void));
59 
60 /* global data in mplock.s */
61 extern u_int			mp_lock;
62 extern u_int			isr_lock;
63 
64 /* functions in mplock.s */
65 void	get_mplock		__P((void));
66 void	rel_mplock		__P((void));
67 void	try_mplock		__P((void));
68 
69 /* global data in apic_vector.s */
70 extern u_int			ivectors[];
71 extern volatile u_int		stopped_cpus;
72 extern volatile u_int		started_cpus;
73 
74 /* global data in apic_ipl.s */
75 extern u_int			vec[];
76 extern u_int			Xintr8254;
77 extern u_int			mask8254;
78 
79 /* functions in apic_ipl.s */
80 void	vec8254			__P((void));
81 void	INTREN			__P((u_int));
82 void	INTRDIS			__P((u_int));
83 void	apic_eoi		__P((void));
84 u_int	io_apic_read		__P((int, int));
85 void	io_apic_write		__P((int, int, u_int));
86 
87 /* global data in mp_machdep.c */
88 extern int			bsp_apic_ready;
89 extern int			mp_ncpus;
90 extern int			mp_naps;
91 extern int			mp_nbusses;
92 extern int			mp_napics;
93 extern int			mp_picmode;
94 extern int			boot_cpu_id;
95 extern vm_offset_t		cpu_apic_address;
96 extern vm_offset_t		io_apic_address[];
97 extern u_int32_t		cpu_apic_versions[];
98 extern u_int32_t		io_apic_versions[];
99 extern int			cpu_num_to_apic_id[];
100 extern int			io_num_to_apic_id[];
101 extern int			apic_id_to_logical[];
102 extern u_int			all_cpus;
103 extern u_char			SMP_ioapic[];
104 
105 /* functions in mp_machdep.c */
106 u_int	mp_bootaddress		__P((u_int));
107 int	mp_probe		__P((void));
108 void	mp_start		__P((void));
109 void	mp_announce		__P((void));
110 u_int	isa_apic_mask		__P((u_int));
111 int	isa_apic_pin		__P((int));
112 int	pci_apic_pin		__P((int, int, int));
113 int	undirect_isa_irq	__P((int));
114 int	undirect_pci_irq	__P((int));
115 int	apic_bus_type		__P((int));
116 int	apic_src_bus_id		__P((int, int));
117 int	apic_src_bus_irq	__P((int, int));
118 int	apic_int_type		__P((int, int));
119 int	apic_trigger		__P((int, int));
120 int	apic_polarity		__P((int, int));
121 void	bsp_apic_configure	__P((void));
122 void	init_secondary		__P((void));
123 void	smp_invltlb		__P((void));
124 int	stop_cpus		__P((u_int));
125 int	restart_cpus		__P((u_int));
126 
127 /* global data in mpapic.c */
128 extern volatile lapic_t		lapic;
129 
130 #if defined(MULTIPLE_IOAPICS)
131 #error MULTIPLE_IOAPICSXXX
132 #else
133 extern volatile ioapic_t	*ioapic[];
134 #endif /* MULTIPLE_IOAPICS */
135 
136 /* functions in mpapic.c */
137 void	apic_dump		__P((char*));
138 void	apic_initialize		__P((void));
139 void	imen_dump		__P((void));
140 int	apic_ipi		__P((int, int, int));
141 int	selected_apic_ipi	__P((u_int, int, int));
142 int	io_apic_setup		__P((int));
143 int	ext_int_setup		__P((int, int));
144 
145 #if defined(READY)
146 void	clr_io_apic_mask24	__P((int, u_int32_t));
147 void	set_io_apic_mask24	__P((int, u_int32_t));
148 #endif /* READY */
149 
150 void	set_apic_timer		__P((int));
151 int	read_apic_timer		__P((void));
152 void	u_sleep			__P((int));
153 
154 /* global data in init_smp.c */
155 extern int			invltlb_ok;
156 extern int			smp_active;
157 extern volatile int		smp_idle_loops;
158 
159 /* 'private' global data in locore.s */
160 extern volatile u_int		cpuid;
161 extern volatile u_int		cpu_lockid;
162 extern volatile u_int		other_cpus;
163 
164 #endif /* !LOCORE */
165 #endif /* SMP || APIC_IO */
166 #endif /* KERNEL */
167 #endif /* _MACHINE_SMP_H_ */
168