smp.h revision 91260
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 91260 2002-02-25 23:49:51Z 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 <sys/bus.h>	/* XXX */
45#include <machine/apic.h>
46#include <machine/frame.h>
47#include <i386/isa/icu.h>
48#include <i386/isa/intr_machdep.h>
49
50/*
51 * Interprocessor interrupts for SMP.
52 */
53#define	IPI_INVLTLB		XINVLTLB_OFFSET
54#define	IPI_INVLPG		XINVLPG_OFFSET
55#define	IPI_INVLRNG		XINVLRNG_OFFSET
56#define	IPI_RENDEZVOUS		XRENDEZVOUS_OFFSET
57#define	IPI_AST			XCPUAST_OFFSET
58#define	IPI_STOP		XCPUSTOP_OFFSET
59#define	IPI_HARDCLOCK		XHARDCLOCK_OFFSET
60#define	IPI_STATCLOCK		XSTATCLOCK_OFFSET
61
62/* global data in mpboot.s */
63extern int			bootMP_size;
64
65/* functions in mpboot.s */
66void	bootMP			__P((void));
67
68/* global data in mp_machdep.c */
69extern int			bsp_apic_ready;
70extern int			mp_naps;
71extern int			mp_nbusses;
72extern int			mp_napics;
73extern int			mp_picmode;
74extern int			boot_cpu_id;
75extern vm_offset_t		cpu_apic_address;
76extern vm_offset_t		io_apic_address[];
77extern u_int32_t		cpu_apic_versions[];
78extern u_int32_t		*io_apic_versions;
79extern int			cpu_num_to_apic_id[];
80extern int			io_num_to_apic_id[];
81extern int			apic_id_to_logical[];
82#define APIC_INTMAPSIZE 32
83struct apic_intmapinfo {
84  	int ioapic;
85	int int_pin;
86	volatile void *apic_address;
87	int redirindex;
88};
89extern struct apic_intmapinfo	int_to_apicintpin[];
90extern struct pcb		stoppcbs[];
91
92/* functions in mp_machdep.c */
93void	i386_mp_probe		__P((void));
94u_int	mp_bootaddress		__P((u_int));
95u_int	isa_apic_mask		__P((u_int));
96int	isa_apic_irq		__P((int));
97int	pci_apic_irq		__P((int, int, int));
98int	apic_irq		__P((int, int));
99int	next_apic_irq		__P((int));
100int	undirect_isa_irq	__P((int));
101int	undirect_pci_irq	__P((int));
102int	apic_bus_type		__P((int));
103int	apic_src_bus_id		__P((int, int));
104int	apic_src_bus_irq	__P((int, int));
105int	apic_int_type		__P((int, int));
106int	apic_trigger		__P((int, int));
107int	apic_polarity		__P((int, int));
108void	assign_apic_irq		__P((int apic, int intpin, int irq));
109void	revoke_apic_irq		__P((int irq));
110void	bsp_apic_configure	__P((void));
111void	init_secondary		__P((void));
112void	forward_statclock	__P((void));
113void	forwarded_statclock	__P((struct trapframe frame));
114void	forward_hardclock	__P((void));
115void	forwarded_hardclock	__P((struct trapframe frame));
116void	ipi_selected		__P((u_int cpus, u_int ipi));
117void	ipi_all			__P((u_int ipi));
118void	ipi_all_but_self	__P((u_int ipi));
119void	ipi_self		__P((u_int ipi));
120#ifdef	APIC_INTR_REORDER
121void	set_lapic_isrloc	__P((int, int));
122#endif /* APIC_INTR_REORDER */
123
124/* global data in mpapic.c */
125extern volatile lapic_t		lapic;
126extern volatile ioapic_t	**ioapic;
127
128/* functions in mpapic.c */
129void	apic_dump		__P((char*));
130void	apic_initialize		__P((void));
131void	imen_dump		__P((void));
132int	apic_ipi		__P((int, int, int));
133int	selected_apic_ipi	__P((u_int, int, int));
134int	io_apic_setup		__P((int));
135void	io_apic_setup_intpin	__P((int, int));
136void	io_apic_set_id		__P((int, int));
137int	io_apic_get_id		__P((int));
138int	ext_int_setup		__P((int, int));
139
140void	set_apic_timer		__P((int));
141int	read_apic_timer		__P((void));
142void	u_sleep			__P((int));
143u_int	io_apic_read		__P((int, int));
144void	io_apic_write		__P((int, int, u_int));
145
146#endif /* !LOCORE */
147#endif /* SMP && !APIC_IO */
148
149#endif /* _KERNEL */
150#endif /* _MACHINE_SMP_H_ */
151