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