smp.h revision 65932
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 * $FreeBSD: head/sys/amd64/include/smp.h 65932 2000-09-16 18:55:05Z phk $
10 *
11 */
12
13#ifndef _MACHINE_SMP_H_
14#define _MACHINE_SMP_H_
15
16#ifdef _KERNEL
17
18#if defined(SMP) && defined(I386_CPU) && !defined(COMPILING_LINT)
19#error SMP not supported with I386_CPU
20#endif
21#if defined(SMP) && !defined(APIC_IO)
22# error APIC_IO required for SMP, add "options APIC_IO" to your config file.
23#endif /* SMP && !APIC_IO */
24
25/* Number of CPUs. */
26#if defined(SMP) && !defined(NCPU)
27# define NCPU			2
28#endif /* SMP && NCPU */
29
30/* Number of IO APICs. */
31#if defined(APIC_IO) && !defined(NAPIC)
32# define NAPIC			2
33#endif /* SMP && NAPIC */
34
35
36#if defined(SMP) || defined(APIC_IO)
37
38#ifndef LOCORE
39
40/*
41 * For sending values to POST displays.
42 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
43 */
44extern int current_postcode;  /** XXX currently in mp_machdep.c */
45#define POSTCODE(X)	current_postcode = (X), \
46			outb(0x80, current_postcode)
47#define POSTCODE_LO(X)	current_postcode &= 0xf0, \
48			current_postcode |= ((X) & 0x0f), \
49			outb(0x80, current_postcode)
50#define POSTCODE_HI(X)	current_postcode &= 0x0f, \
51			current_postcode |= (((X) << 4) & 0xf0), \
52			outb(0x80, current_postcode)
53
54
55#include <machine/apic.h>
56
57/* global data in mpboot.s */
58extern int			bootMP_size;
59
60/* functions in mpboot.s */
61void	bootMP			__P((void));
62
63/* global data in apic_vector.s */
64extern volatile u_int		stopped_cpus;
65extern volatile u_int		started_cpus;
66
67extern volatile u_int		checkstate_probed_cpus;
68extern volatile u_int		checkstate_need_ast;
69extern volatile u_int		resched_cpus;
70extern void (*cpustop_restartfunc) __P((void));
71
72/* functions in apic_ipl.s */
73void	apic_eoi		__P((void));
74u_int	io_apic_read		__P((int, int));
75void	io_apic_write		__P((int, int, u_int));
76
77/* global data in mp_machdep.c */
78extern int			bsp_apic_ready;
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[];
92#define APIC_INTMAPSIZE 24
93struct apic_intmapinfo {
94  	int ioapic;
95	int int_pin;
96	volatile void *apic_address;
97	int redirindex;
98};
99extern struct apic_intmapinfo	int_to_apicintpin[];
100extern u_int			all_cpus;
101extern struct pcb		stoppcbs[];
102
103/* functions in mp_machdep.c */
104u_int	mp_bootaddress		__P((u_int));
105int	mp_probe		__P((void));
106void	mp_start		__P((void));
107void	mp_announce		__P((void));
108u_int	isa_apic_mask		__P((u_int));
109int	isa_apic_irq		__P((int));
110int	pci_apic_irq		__P((int, int, int));
111int	apic_irq		__P((int, int));
112int	next_apic_irq		__P((int));
113int	undirect_isa_irq	__P((int));
114int	undirect_pci_irq	__P((int));
115int	apic_bus_type		__P((int));
116int	apic_src_bus_id		__P((int, int));
117int	apic_src_bus_irq	__P((int, int));
118int	apic_int_type		__P((int, int));
119int	apic_trigger		__P((int, int));
120int	apic_polarity		__P((int, int));
121void	assign_apic_irq		__P((int apic, int intpin, int irq));
122void	revoke_apic_irq		__P((int irq));
123void	bsp_apic_configure	__P((void));
124void	init_secondary		__P((void));
125void	smp_invltlb		__P((void));
126int	stop_cpus		__P((u_int));
127int	restart_cpus		__P((u_int));
128#ifdef BETTER_CLOCK
129void	forward_statclock	__P((int pscnt));
130void	forward_hardclock	__P((int pscnt));
131#endif /* BETTER_CLOCK */
132void	forward_signal		__P((struct proc *));
133void	forward_roundrobin	__P((void));
134#ifdef	APIC_INTR_REORDER
135void	set_lapic_isrloc	__P((int, int));
136#endif /* APIC_INTR_REORDER */
137void	smp_rendezvous_action	__P((void));
138void	smp_rendezvous		__P((void (*)(void *),
139				     void (*)(void *),
140				     void (*)(void *),
141				     void *arg));
142
143/* global data in mpapic.c */
144extern volatile lapic_t		lapic;
145extern volatile ioapic_t	*ioapic[];
146
147/* functions in mpapic.c */
148void	apic_dump		__P((char*));
149void	apic_initialize		__P((void));
150void	imen_dump		__P((void));
151int	apic_ipi		__P((int, int, int));
152int	selected_apic_ipi	__P((u_int, int, int));
153int	io_apic_setup		__P((int));
154void	io_apic_set_id		__P((int, int));
155int	io_apic_get_id		__P((int));
156int	ext_int_setup		__P((int, int));
157
158#if defined(READY)
159void	clr_io_apic_mask24	__P((int, u_int32_t));
160void	set_io_apic_mask24	__P((int, u_int32_t));
161#endif /* READY */
162
163void	set_apic_timer		__P((int));
164int	read_apic_timer		__P((void));
165void	u_sleep			__P((int));
166
167/* global data in init_smp.c */
168extern int			invltlb_ok;
169extern int			smp_active;
170extern int			smp_started;
171extern volatile int		smp_idle_loops;
172
173#endif /* !LOCORE */
174#endif /* SMP && !APIC_IO */
175
176#endif /* _KERNEL */
177#endif /* _MACHINE_SMP_H_ */
178