smp.h revision 25517
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 * $Id: smp.h,v 1.6 1997/05/05 22:56:37 fsmp Exp $
10 *
11 */
12
13#ifndef _MACHINE_SMP_H_
14#define _MACHINE_SMP_H_
15
16#ifdef KERNEL
17
18#include "opt_smp.h"
19
20#if defined(SMP) && !defined(APIC_IO)
21# error APIC_IO required for SMP, add "options APIC_IO" to your config file.
22#endif /* SMP && NCPU */
23
24#if defined(SMP) && !defined(NCPU)
25# define NCPU			2
26#endif /* SMP && NCPU */
27
28#if defined(SMP) || defined(APIC_IO)
29
30/* global data in mpboot.s */
31extern int			bootMP_size;
32
33/* functions in mpboot.s */
34void	bootMP			__P((void));
35
36/* global data in mplock.s */
37extern u_int			mp_lock;
38
39/* functions in mplock.s */
40void	get_mplock		__P((void));
41void	rel_mplock		__P((void));
42void	try_mplock		__P((void));
43
44/* global data in mp_machdep.c */
45extern struct proc*		SMPcurproc[NCPU];
46extern struct pcb*		SMPcurpcb[NCPU];
47extern struct timeval		SMPruntime[NCPU];
48extern int			mp_ncpus;
49extern int			mp_naps;
50extern int			mp_nbusses;
51extern int			mp_napics;
52extern int			mp_picmode;
53extern int			mpenabled;
54extern int			boot_cpu_id;
55extern vm_offset_t		cpu_apic_address;
56extern vm_offset_t		io_apic_address[];
57extern u_int32_t		cpu_apic_versions[];
58extern u_int32_t		io_apic_versions[];
59extern int			cpu_num_to_apic_id[];
60extern int			io_num_to_apic_id[];
61extern int			apic_id_to_logical[];
62
63/* functions in mp_machdep.c */
64u_int	mp_bootaddress		__P((u_int));
65void	mp_start		__P((void));
66void	mp_announce		__P((void));
67int	get_isa_apic_irq	__P((int));
68u_int	get_isa_apic_mask	__P((u_int));
69int	undirect_isa_irq	__P((int));
70int	get_eisa_apic_irq	__P((int));
71int	get_pci_apic_irq	__P((int, int, int));
72int	undirect_pci_irq	__P((int));
73int	apic_bus_type		__P((int));
74int	apic_src_bus_id		__P((int, int));
75int	apic_src_bus_irq	__P((int, int));
76int	apic_int_type		__P((int, int));
77int	apic_trigger		__P((int, int));
78int	apic_polarity		__P((int, int));
79void	configure_local_apic	__P((void));
80void	init_secondary		__P((void));
81void	smp_invltlb		__P((void));
82
83/* global data in mpapic.c */
84extern volatile u_int*		apic_base;
85
86#if defined(MULTIPLE_IOAPICS)
87#error MULTIPLE_IOAPICSXXX
88#else
89extern volatile u_int*		io_apic_base;
90#endif /* MULTIPLE_IOAPICS */
91
92/* functions in mpapic.c */
93void	apic_initialize		__P((int));
94int	apic_ipi		__P((int, int, int));
95int	selected_apic_ipi	__P((u_int, int, int));
96int	io_apic_setup		__P((int));
97int	ext_int_setup		__P((int, int));
98void	write_io_apic_mask24	__P((int, u_int32_t));
99
100#if defined(READY)
101void	clr_io_apic_mask24	__P((int, u_int32_t));
102void	set_io_apic_mask24	__P((int, u_int32_t));
103#endif /* READY */
104
105void	set_apic_timer		__P((int));
106int	read_apic_timer		__P((void));
107void	u_sleep			__P((int));
108
109/* global data in init_smp.c */
110extern int			smp_active;
111extern int			invltlb_ok;
112
113/* in pmap.c FIXME: belongs in pmap.h??? */
114void	pmap_bootstrap_apics	__P((void));
115void	pmap_bootstrap2		__P((void));
116
117#if 0
118/* chicken and egg problem... */
119static __inline unsigned
120cpunumber(void)
121{
122	return (unsigned)ID_TO_CPU((apic_base[APIC_ID] & APIC_ID_MASK) >> 24);
123}
124#else
125/*
126 * we 'borrow' this info from apic.h
127 * this will go away soon...
128 */
129static __inline unsigned
130cpunumber(void)
131{
132	return (unsigned)(apic_id_to_logical[(apic_base[8] & 0x0f000000) >> 24]);
133}
134#endif /* 0 */
135
136#endif /* SMP || APIC_IO */
137#endif /* KERNEL */
138#endif /* _MACHINE_SMP_H_ */
139