smp.h revision 69651
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 69651 2000-12-06 01:04:02Z peter $
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#if defined(SMP) || defined(APIC_IO)
26
27#ifndef LOCORE
28
29/*
30 * For sending values to POST displays.
31 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
32 */
33extern int current_postcode;  /** XXX currently in mp_machdep.c */
34#define POSTCODE(X)	current_postcode = (X), \
35			outb(0x80, current_postcode)
36#define POSTCODE_LO(X)	current_postcode &= 0xf0, \
37			current_postcode |= ((X) & 0x0f), \
38			outb(0x80, current_postcode)
39#define POSTCODE_HI(X)	current_postcode &= 0x0f, \
40			current_postcode |= (((X) << 4) & 0xf0), \
41			outb(0x80, current_postcode)
42
43
44#include <machine/apic.h>
45
46/* global data in mpboot.s */
47extern int			bootMP_size;
48
49/* functions in mpboot.s */
50void	bootMP			__P((void));
51
52/* global data in apic_vector.s */
53extern volatile u_int		stopped_cpus;
54extern volatile u_int		started_cpus;
55
56extern volatile u_int		checkstate_probed_cpus;
57extern volatile u_int		checkstate_need_ast;
58extern volatile u_int		resched_cpus;
59extern void (*cpustop_restartfunc) __P((void));
60
61/* global data in mp_machdep.c */
62extern int			bsp_apic_ready;
63extern int			mp_ncpus;
64extern int			mp_naps;
65extern int			mp_nbusses;
66extern int			mp_napics;
67extern int			mp_picmode;
68extern int			boot_cpu_id;
69extern vm_offset_t		cpu_apic_address;
70extern vm_offset_t		io_apic_address[];
71extern u_int32_t		cpu_apic_versions[];
72extern u_int32_t		*io_apic_versions;
73extern int			cpu_num_to_apic_id[];
74extern int			io_num_to_apic_id[];
75extern int			apic_id_to_logical[];
76#define APIC_INTMAPSIZE 32
77struct apic_intmapinfo {
78  	int ioapic;
79	int int_pin;
80	volatile void *apic_address;
81	int redirindex;
82};
83extern struct apic_intmapinfo	int_to_apicintpin[];
84extern u_int			all_cpus;
85extern struct pcb		stoppcbs[];
86
87/* functions in mp_machdep.c */
88u_int	mp_bootaddress		__P((u_int));
89int	mp_probe		__P((void));
90void	mp_start		__P((void));
91void	mp_announce		__P((void));
92u_int	isa_apic_mask		__P((u_int));
93int	isa_apic_irq		__P((int));
94int	pci_apic_irq		__P((int, int, int));
95int	apic_irq		__P((int, int));
96int	next_apic_irq		__P((int));
97int	undirect_isa_irq	__P((int));
98int	undirect_pci_irq	__P((int));
99int	apic_bus_type		__P((int));
100int	apic_src_bus_id		__P((int, int));
101int	apic_src_bus_irq	__P((int, int));
102int	apic_int_type		__P((int, int));
103int	apic_trigger		__P((int, int));
104int	apic_polarity		__P((int, int));
105void	assign_apic_irq		__P((int apic, int intpin, int irq));
106void	revoke_apic_irq		__P((int irq));
107void	bsp_apic_configure	__P((void));
108void	init_secondary		__P((void));
109void	smp_invltlb		__P((void));
110int	stop_cpus		__P((u_int));
111int	restart_cpus		__P((u_int));
112#ifdef BETTER_CLOCK
113void	forward_statclock	__P((int pscnt));
114void	forward_hardclock	__P((int pscnt));
115#endif /* BETTER_CLOCK */
116void	forward_signal		__P((struct proc *));
117void	forward_roundrobin	__P((void));
118#ifdef	APIC_INTR_REORDER
119void	set_lapic_isrloc	__P((int, int));
120#endif /* APIC_INTR_REORDER */
121void	smp_rendezvous_action	__P((void));
122void	smp_rendezvous		__P((void (*)(void *),
123				     void (*)(void *),
124				     void (*)(void *),
125				     void *arg));
126
127/* global data in mpapic.c */
128extern volatile lapic_t		lapic;
129extern volatile ioapic_t	**ioapic;
130
131/* functions in mpapic.c */
132void	apic_dump		__P((char*));
133void	apic_initialize		__P((void));
134void	imen_dump		__P((void));
135int	apic_ipi		__P((int, int, int));
136int	selected_apic_ipi	__P((u_int, int, int));
137int	io_apic_setup		__P((int));
138void	io_apic_set_id		__P((int, int));
139int	io_apic_get_id		__P((int));
140int	ext_int_setup		__P((int, int));
141
142void	set_apic_timer		__P((int));
143int	read_apic_timer		__P((void));
144void	u_sleep			__P((int));
145u_int	io_apic_read		__P((int, int));
146void	io_apic_write		__P((int, int, u_int));
147
148
149/* global data in init_smp.c */
150extern int			invltlb_ok;
151extern int			smp_active;
152extern int			smp_started;
153extern volatile int		smp_idle_loops;
154
155#endif /* !LOCORE */
156#endif /* SMP && !APIC_IO */
157
158#endif /* _KERNEL */
159#endif /* _MACHINE_SMP_H_ */
160