smp.h revision 27616
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.13 1997/07/22 18:31:51 smp Exp smp $
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#if defined(SMP) && !defined(NCPU)
23# define NCPU			2
24#endif /* SMP && NCPU */
25
26#if defined(SMP) || defined(APIC_IO)
27
28/*
29 * For sending values to POST displays.
30 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
31 */
32extern int current_postcode;  /** XXX currently in mp_machdep.c */
33#define POSTCODE(X)	current_postcode = (X), \
34			outb(0x80, current_postcode)
35#define POSTCODE_LO(X)	current_postcode &= 0xf0, \
36			current_postcode |= ((X) & 0x0f), \
37			outb(0x80, current_postcode)
38#define POSTCODE_HI(X)	current_postcode &= 0x0f, \
39			current_postcode |= (((X) << 4) & 0xf0), \
40			outb(0x80, current_postcode)
41
42
43#include <machine/apic.h>
44
45/* global data in mpboot.s */
46extern int			bootMP_size;
47
48/* functions in mpboot.s */
49void	bootMP			__P((void));
50
51/* global data in mplock.s */
52extern u_int			mp_lock;
53
54/* functions in mplock.s */
55void	get_mplock		__P((void));
56void	rel_mplock		__P((void));
57void	try_mplock		__P((void));
58
59/* global data in apic_vector.s */
60extern u_int			ivectors[];
61extern volatile u_int		stopped_cpus;
62extern volatile u_int		started_cpus;
63
64/* global data in apic_ipl.s */
65extern u_int			vec[];
66extern u_int			Xintr8254;
67extern u_int			mask8254;
68
69/* functions in apic_ipl.s */
70void	vec8254			__P((void));
71void	INTREN			__P((u_int));
72void	INTRDIS			__P((u_int));
73void	apic_eoi		__P((void));
74u_int	io_apic_read		__P((int, int));
75void	io_apic_write		__P((int, int, u_int));
76void	write_io_apic_mask24	__P((int, u_int));
77
78/* global data in mp_machdep.c */
79extern int			mp_ncpus;
80extern int			mp_naps;
81extern int			mp_nbusses;
82extern int			mp_napics;
83extern int			mp_picmode;
84extern int			boot_cpu_id;
85extern vm_offset_t		cpu_apic_address;
86extern vm_offset_t		io_apic_address[];
87extern u_int32_t		cpu_apic_versions[];
88extern u_int32_t		io_apic_versions[];
89extern int			cpu_num_to_apic_id[];
90extern int			io_num_to_apic_id[];
91extern int			apic_id_to_logical[];
92extern u_int			all_cpus;
93extern u_int			SMP_prvpt[];
94extern u_char			SMP_ioapic[];
95
96/* functions in mp_machdep.c */
97u_int	mp_bootaddress		__P((u_int));
98int	mp_probe		__P((void));
99void	mp_start		__P((void));
100void	mp_announce		__P((void));
101u_int	isa_apic_mask		__P((u_int));
102int	isa_apic_pin		__P((int));
103int	pci_apic_pin		__P((int, int, int));
104int	undirect_isa_irq	__P((int));
105int	undirect_pci_irq	__P((int));
106int	apic_bus_type		__P((int));
107int	apic_src_bus_id		__P((int, int));
108int	apic_src_bus_irq	__P((int, int));
109int	apic_int_type		__P((int, int));
110int	apic_trigger		__P((int, int));
111int	apic_polarity		__P((int, int));
112void	bsp_apic_configure	__P((void));
113void	init_secondary		__P((void));
114void	smp_invltlb		__P((void));
115int	stop_cpus		__P((u_int));
116int	restart_cpus		__P((u_int));
117
118/* global data in mpapic.c */
119extern volatile lapic_t		lapic;
120
121#if defined(MULTIPLE_IOAPICS)
122#error MULTIPLE_IOAPICSXXX
123#else
124extern volatile ioapic_t	*ioapic[];
125#endif /* MULTIPLE_IOAPICS */
126
127/* functions in mpapic.c */
128void	apic_dump		__P((char*));
129void	apic_initialize		__P((void));
130void	imen_dump		__P((void));
131int	apic_ipi		__P((int, int, int));
132int	selected_apic_ipi	__P((u_int, int, int));
133int	io_apic_setup		__P((int));
134int	ext_int_setup		__P((int, int));
135
136#if defined(READY)
137void	clr_io_apic_mask24	__P((int, u_int32_t));
138void	set_io_apic_mask24	__P((int, u_int32_t));
139#endif /* READY */
140
141void	set_apic_timer		__P((int));
142int	read_apic_timer		__P((void));
143void	u_sleep			__P((int));
144
145/* global data in init_smp.c */
146extern int			smp_active;
147extern int			invltlb_ok;
148
149/* 'private' global data in locore.s */
150extern volatile u_int		cpuid;
151extern volatile u_int		cpu_lockid;
152extern volatile u_int		other_cpus;
153
154#endif /* SMP || APIC_IO */
155#endif /* KERNEL */
156#endif /* _MACHINE_SMP_H_ */
157