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