xref: /netbsd-src/sys/arch/x86/include/cpuvar.h (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /* 	$NetBSD: cpuvar.h,v 1.38 2010/08/20 06:34:32 jruoho Exp $ */
2 
3 /*-
4  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by RedBack Networks Inc.
9  *
10  * Author: Bill Sommerfeld
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Copyright (c) 1999 Stefan Grefen
36  *
37  * Redistribution and use in source and binary forms, with or without
38  * modification, are permitted provided that the following conditions
39  * are met:
40  * 1. Redistributions of source code must retain the above copyright
41  *    notice, this list of conditions and the following disclaimer.
42  * 2. Redistributions in binary form must reproduce the above copyright
43  *    notice, this list of conditions and the following disclaimer in the
44  *    documentation and/or other materials provided with the distribution.
45  * 3. All advertising materials mentioning features or use of this software
46  *    must display the following acknowledgement:
47  *      This product includes software developed by the NetBSD
48  *      Foundation, Inc. and its contributors.
49  * 4. Neither the name of The NetBSD Foundation nor the names of its
50  *    contributors may be used to endorse or promote products derived
51  *    from this software without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
54  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE
57  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63  * SUCH DAMAGE.
64  */
65 
66 #ifndef _X86_CPUVAR_H_
67 #define	_X86_CPUVAR_H_
68 
69 struct cpu_functions {
70 	int (*start)(struct cpu_info *, paddr_t);
71 	int (*stop)(struct cpu_info *);
72 	void (*cleanup)(struct cpu_info *);
73 };
74 
75 extern const struct cpu_functions mp_cpu_funcs;
76 
77 #define CPU_ROLE_SP	0
78 #define CPU_ROLE_BP	1
79 #define CPU_ROLE_AP	2
80 
81 struct cpu_attach_args {
82 	int cpu_id;
83 	int cpu_number;
84 	int cpu_role;
85 	const struct cpu_functions *cpu_func;
86 };
87 
88 #ifdef _KERNEL
89 
90 #if defined(_KERNEL_OPT)
91 #include "opt_multiprocessor.h"
92 #include "opt_enhanced_speedstep.h"
93 #ifndef XEN
94 #include "opt_intel_coretemp.h"
95 #include "opt_intel_odcm.h"
96 #include "opt_via_c7temp.h"
97 #endif
98 #endif /* defined(_KERNEL_OPT) */
99 
100 #ifdef MULTIPROCESSOR
101 extern uint32_t cpus_running;
102 #endif
103 
104 int x86_ipi(int, int, int);
105 void x86_self_ipi(int);
106 int x86_ipi_init(int);
107 int x86_ipi_startup(int, int);
108 void x86_errata(void);
109 
110 void identifycpu(struct cpu_info *);
111 void identifycpu_cpuids(struct cpu_info *);
112 void cpu_init(struct cpu_info *);
113 void cpu_init_tss(struct cpu_info *);
114 void cpu_init_first(void);
115 
116 void x86_cpu_idle_init(void);
117 void x86_cpu_idle_halt(void);
118 void x86_cpu_idle_mwait(void);
119 #ifdef XEN
120 void x86_cpu_idle_xen(void);
121 #endif
122 
123 #ifdef VIA_C7TEMP
124 void viac7temp_register(struct cpu_info *);
125 #endif
126 
127 #ifdef INTEL_CORETEMP
128 void coretemp_register(struct cpu_info *);
129 #endif
130 
131 #ifdef INTEL_ONDEMAND_CLOCKMOD
132 void clockmod_init(void);
133 #endif
134 
135 #ifdef ENHANCED_SPEEDSTEP
136 void	est_init(int);
137 int	via_get_bus_clock(struct cpu_info *);
138 int	viac7_get_bus_clock(struct cpu_info *);
139 int	p3_get_bus_clock(struct cpu_info *);
140 int	p4_get_bus_clock(struct cpu_info *);
141 #endif
142 
143 void	cpu_get_tsc_freq(struct cpu_info *);
144 void	pat_init(struct cpu_info *);
145 
146 extern int cpu_vendor;
147 extern bool x86_mp_online;
148 
149 extern uint32_t cpu_feature[5];
150 
151 #endif /* _KERNEL */
152 
153 #endif /* !_X86_CPUVAR_H_ */
154