xref: /dflybsd-src/sys/platform/pc64/include/smp.h (revision 308af577f531e89dce6dff0ecea68ab4474f4d24)
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 #if defined(SMP)
27 
28 #ifndef LOCORE
29 
30 /*
31  * For sending values to POST displays.
32  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
33  */
34 extern int current_postcode;  /** XXX currently in mp_machdep.c */
35 #define POSTCODE(X)	current_postcode = (X), \
36 			outb(0x80, current_postcode)
37 #define POSTCODE_LO(X)	current_postcode &= 0xf0, \
38 			current_postcode |= ((X) & 0x0f), \
39 			outb(0x80, current_postcode)
40 #define POSTCODE_HI(X)	current_postcode &= 0x0f, \
41 			current_postcode |= (((X) << 4) & 0xf0), \
42 			outb(0x80, current_postcode)
43 
44 
45 #include <machine_base/apic/apicreg.h>
46 #include <machine/pcb.h>
47 
48 /* global symbols in mpboot.S */
49 extern char			mptramp_start[];
50 extern char			mptramp_end[];
51 extern u_int32_t		mptramp_pagetables;
52 
53 /* functions in mpboot.s */
54 void	bootMP			(void);
55 
56 /* global data in apic_vector.s */
57 extern volatile u_int		stopped_cpus;
58 extern volatile u_int		started_cpus;
59 
60 extern volatile u_int		checkstate_probed_cpus;
61 extern void (*cpustop_restartfunc) (void);
62 
63 /* functions in apic_ipl.s */
64 u_int	io_apic_read		(int, int);
65 void	io_apic_write		(int, int, u_int);
66 
67 /* global data in mp_machdep.c */
68 extern int			mp_naps;
69 extern int			mp_napics;
70 extern vm_offset_t		cpu_apic_address;
71 extern vm_offset_t		io_apic_address[];
72 extern u_int32_t		cpu_apic_versions[];
73 extern u_int32_t		*io_apic_versions;
74 extern int			cpu_num_to_apic_id[];
75 extern int			io_num_to_apic_id[];
76 extern int			apic_id_to_logical[];
77 #define APIC_INTMAPSIZE 24
78 struct apic_intmapinfo {
79   	int ioapic;
80 	int int_pin;
81 	volatile void *apic_address;
82 	int redirindex;
83 };
84 extern struct apic_intmapinfo	int_to_apicintpin[];
85 extern struct pcb		stoppcbs[];
86 
87 /* functions in mp_machdep.c */
88 void	*permanent_io_mapping(vm_paddr_t);
89 u_int	mp_bootaddress		(u_int);
90 void	mp_start		(void);
91 void	mp_announce		(void);
92 void	mp_set_cpuids		(int, int);
93 u_int	isa_apic_mask		(u_int);
94 int	isa_apic_irq		(int);
95 int	pci_apic_irq		(int, int, int);
96 int	apic_irq		(int, int);
97 int	next_apic_irq		(int);
98 int	undirect_isa_irq	(int);
99 int	undirect_pci_irq	(int);
100 int	apic_bus_type		(int);
101 int	apic_src_bus_id		(int, int);
102 int	apic_src_bus_irq	(int, int);
103 int	apic_int_type		(int, int);
104 int	apic_trigger		(int, int);
105 int	apic_polarity		(int, int);
106 void	assign_apic_irq		(int apic, int intpin, int irq);
107 void	revoke_apic_irq		(int irq);
108 void	init_secondary		(void);
109 int	stop_cpus		(u_int);
110 void	ap_init			(void);
111 int	restart_cpus		(u_int);
112 void	forward_signal		(struct proc *);
113 
114 /* global data in mpapic.c */
115 extern volatile lapic_t		*lapic;
116 extern volatile ioapic_t	**ioapic;
117 
118 /* functions in mpapic.c */
119 void	apic_dump		(char*);
120 void	apic_initialize		(boolean_t);
121 void	imen_dump		(void);
122 int	apic_ipi		(int, int, int);
123 void	selected_apic_ipi	(u_int, int, int);
124 void	single_apic_ipi(int cpu, int vector, int delivery_mode);
125 int	single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
126 int	io_apic_setup		(int);
127 void	io_apic_setup_intpin	(int, int);
128 void	io_apic_set_id		(int, int);
129 int	io_apic_get_id		(int);
130 int	ext_int_setup		(int, int);
131 
132 /* functions in mp_madt.c */
133 vm_paddr_t	madt_probe(void);
134 vm_offset_t	madt_pass1(vm_paddr_t);
135 int		madt_pass2(vm_paddr_t, int);
136 
137 #if defined(READY)
138 void	clr_io_apic_mask24	(int, u_int32_t);
139 void	set_io_apic_mask24	(int, u_int32_t);
140 #endif /* READY */
141 
142 void	set_apic_timer		(int);
143 int	get_apic_timer_frequency(void);
144 int	read_apic_timer		(void);
145 void	u_sleep			(int);
146 void	cpu_send_ipiq		(int);
147 int	cpu_send_ipiq_passive	(int);
148 
149 /* global data in init_smp.c */
150 extern cpumask_t		smp_active_mask;
151 
152 #endif /* !LOCORE */
153 #else	/* !SMP */
154 
155 #define	smp_active_mask	1	/* smp_active_mask always 1 on UP machines */
156 
157 #endif
158 
159 #endif /* _KERNEL */
160 #endif /* _MACHINE_SMP_H_ */
161