xref: /dragonfly/sys/platform/pc64/include/smp.h (revision fb5b3747)
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: src/sys/i386/include/smp.h,v 1.50.2.5 2001/02/13 22:32:45 tegge Exp $
10  * $DragonFly: src/sys/platform/pc32/include/smp.h,v 1.20 2006/11/07 06:43:24 dillon Exp $
11  *
12  */
13 
14 #ifndef _MACHINE_SMP_H_
15 #define _MACHINE_SMP_H_
16 
17 #ifdef _KERNEL
18 
19 #ifndef LOCORE
20 
21 /* XXX wrong header */
22 void	initializecpu(void);
23 
24 #endif	/* LOCORE */
25 
26 /*
27  * Size of APIC ID list.
28  * Also used a MAX size of various other arrays.
29  */
30 #define NAPICID		256
31 
32 #if defined(SMP)
33 
34 #ifndef LOCORE
35 
36 /*
37  * For sending values to POST displays.
38  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
39  */
40 extern int current_postcode;  /** XXX currently in mp_machdep.c */
41 #define POSTCODE(X)	current_postcode = (X), \
42 			outb(0x80, current_postcode)
43 #define POSTCODE_LO(X)	current_postcode &= 0xf0, \
44 			current_postcode |= ((X) & 0x0f), \
45 			outb(0x80, current_postcode)
46 #define POSTCODE_HI(X)	current_postcode &= 0x0f, \
47 			current_postcode |= (((X) << 4) & 0xf0), \
48 			outb(0x80, current_postcode)
49 
50 
51 #include <machine_base/apic/apicreg.h>
52 #include <machine/pcb.h>
53 
54 /* global symbols in mpboot.S */
55 extern char			mptramp_start[];
56 extern char			mptramp_end[];
57 extern u_int32_t		mptramp_pagetables;
58 
59 /* functions in mpboot.s */
60 void	bootMP			(void);
61 
62 /* global data in apic_vector.s */
63 extern volatile cpumask_t	stopped_cpus;
64 extern volatile cpumask_t	started_cpus;
65 
66 extern volatile u_int		checkstate_probed_cpus;
67 extern void (*cpustop_restartfunc) (void);
68 
69 #define APIC_INTMAPSIZE 192
70 /*
71  * NOTE:
72  * - Keep size of apic_intmapinfo power of 2
73  * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
74  */
75 struct apic_intmapinfo {
76   	int ioapic;
77 	int int_pin;
78 	volatile void *apic_address;
79 	int redirindex;
80 	uint32_t flags;		/* IOAPIC_IM_FLAG_ */
81 	uint32_t pad[2];
82 };
83 #define IOAPIC_IM_SZSHIFT	5
84 
85 #define IOAPIC_IM_FLAG_LEVEL	0x1	/* default to edge trigger */
86 #define IOAPIC_IM_FLAG_MASKED	0x2
87 
88 extern struct apic_intmapinfo	int_to_apicintpin[];
89 extern struct pcb		stoppcbs[];
90 
91 /* functions in mp_machdep.c */
92 u_int	mp_bootaddress		(u_int);
93 void	mp_start		(void);
94 void	mp_announce		(void);
95 void	init_secondary		(void);
96 int	stop_cpus		(cpumask_t);
97 void	ap_init			(void);
98 int	restart_cpus		(cpumask_t);
99 void	forward_signal		(struct proc *);
100 
101 #if defined(READY)
102 void	clr_io_apic_mask24	(int, u_int32_t);
103 void	set_io_apic_mask24	(int, u_int32_t);
104 #endif /* READY */
105 
106 void	cpu_send_ipiq		(int);
107 int	cpu_send_ipiq_passive	(int);
108 
109 /* global data in init_smp.c */
110 extern cpumask_t		smp_active_mask;
111 
112 #endif /* !LOCORE */
113 #else	/* !SMP */
114 
115 #define	smp_active_mask	1	/* smp_active_mask always 1 on UP machines */
116 
117 #endif
118 
119 #endif /* _KERNEL */
120 #endif /* _MACHINE_SMP_H_ */
121