smp.h revision 27559
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.8 1997/07/20 17:48:00 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 volatile u_int		stopped_cpus;
61extern volatile u_int		started_cpus;
62
63/* global data in mp_machdep.c */
64extern int			mp_ncpus;
65extern int			mp_naps;
66extern int			mp_nbusses;
67extern int			mp_napics;
68extern int			mp_picmode;
69extern int			boot_cpu_id;
70extern vm_offset_t		cpu_apic_address;
71extern vm_offset_t		io_apic_address[];
72extern u_int32_t		cpu_apic_versions[];
73extern u_int32_t		io_apic_versions[];
74extern int			cpu_num_to_apic_id[];
75extern int			io_num_to_apic_id[];
76extern int			apic_id_to_logical[];
77extern u_int			all_cpus;
78extern u_int			SMP_prvpt[];
79extern u_char			SMP_ioapic[];
80
81/* functions in mp_machdep.c */
82u_int	mp_bootaddress		__P((u_int));
83int	mp_probe		__P((void));
84void	mp_start		__P((void));
85void	mp_announce		__P((void));
86u_int	isa_apic_mask		__P((u_int));
87int	isa_apic_pin		__P((int));
88int	pci_apic_pin		__P((int, int, int));
89int	undirect_isa_irq	__P((int));
90int	undirect_pci_irq	__P((int));
91int	apic_bus_type		__P((int));
92int	apic_src_bus_id		__P((int, int));
93int	apic_src_bus_irq	__P((int, int));
94int	apic_int_type		__P((int, int));
95int	apic_trigger		__P((int, int));
96int	apic_polarity		__P((int, int));
97void	bsp_apic_configure	__P((void));
98void	init_secondary		__P((void));
99void	smp_invltlb		__P((void));
100int	stop_cpus		__P((u_int));
101int	restart_cpus		__P((u_int));
102
103/* global data in mpapic.c */
104extern volatile lapic_t		lapic;
105
106#if defined(MULTIPLE_IOAPICS)
107#error MULTIPLE_IOAPICSXXX
108#else
109extern volatile ioapic_t	*ioapic[];
110#endif /* MULTIPLE_IOAPICS */
111
112/* functions in mpapic.c */
113void	apic_dump		__P((char*));
114void	apic_initialize		__P((void));
115int	apic_ipi		__P((int, int, int));
116int	selected_apic_ipi	__P((u_int, int, int));
117int	io_apic_setup		__P((int));
118int	ext_int_setup		__P((int, int));
119void	write_io_apic_mask24	__P((int, u_int32_t));
120
121#if defined(READY)
122void	clr_io_apic_mask24	__P((int, u_int32_t));
123void	set_io_apic_mask24	__P((int, u_int32_t));
124#endif /* READY */
125
126void	set_apic_timer		__P((int));
127int	read_apic_timer		__P((void));
128void	u_sleep			__P((int));
129
130/* global data in init_smp.c */
131extern int			smp_active;
132extern int			invltlb_ok;
133
134/* 'private' global data in locore.s */
135extern volatile u_int		cpuid;
136extern volatile u_int		cpu_lockid;
137extern volatile u_int		other_cpus;
138
139#endif /* SMP || APIC_IO */
140#endif /* KERNEL */
141#endif /* _MACHINE_SMP_H_ */
142