2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/sysctl.h>
33 #include <i386/cpuid.h>
36 hw_cpu_sysctl SYSCTL_HANDLER_ARGS
38 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
39 i386_cpu_info_t
*cpu_info
= cpuid_info();
40 void *ptr
= (uint8_t *)cpu_info
+ (uint32_t)arg1
;
48 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
52 if (arg2
== sizeof(uint8_t)) {
53 value
= (uint32_t) *(uint8_t *)ptr
;
55 arg2
= sizeof(uint32_t);
57 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
)+1);
61 hw_cpu_features SYSCTL_HANDLER_ARGS
63 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
64 __unused
void *unused_arg1
= arg1
;
65 __unused
int unused_arg2
= arg2
;
69 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
71 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
75 hw_cpu_extfeatures SYSCTL_HANDLER_ARGS
77 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
78 __unused
void *unused_arg1
= arg1
;
79 __unused
int unused_arg2
= arg2
;
83 cpuid_get_extfeature_names(cpuid_extfeatures(), buf
, sizeof(buf
));
85 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
89 hw_cpu_logical_per_package SYSCTL_HANDLER_ARGS
91 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
92 __unused
void *unused_arg1
= arg1
;
93 __unused
int unused_arg2
= arg2
;
94 i386_cpu_info_t
*cpu_info
= cpuid_info();
96 if (!(cpuid_features() & CPUID_FEATURE_HTT
))
99 return SYSCTL_OUT(req
, &cpu_info
->cpuid_logical_per_package
,
100 sizeof(cpu_info
->cpuid_logical_per_package
));
103 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
106 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
,
107 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
108 hw_cpu_sysctl
, "A", "CPU vendor");
110 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
,
111 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
112 hw_cpu_sysctl
, "A", "CPU brand string");
114 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
,
115 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
116 hw_cpu_sysctl
, "I", "CPU family");
118 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
,
119 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
120 hw_cpu_sysctl
, "I", "CPU model");
122 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
,
123 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
124 hw_cpu_sysctl
, "I", "CPU extended model");
126 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
,
127 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
128 hw_cpu_sysctl
, "I", "CPU extended family");
130 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
,
131 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
132 hw_cpu_sysctl
, "I", "CPU stepping");
134 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
,
135 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint64_t),
136 hw_cpu_sysctl
, "I", "CPU features");
138 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
,
139 (void *)offsetof(i386_cpu_info_t
, cpuid_extfeatures
), sizeof(uint64_t),
140 hw_cpu_sysctl
, "I", "CPU extended features");
142 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
,
143 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
144 hw_cpu_sysctl
, "I", "CPU signature");
146 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
,
147 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
148 hw_cpu_sysctl
, "I", "CPU brand");
150 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
,
152 hw_cpu_features
, "A", "CPU feature names");
154 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeatures
, CTLTYPE_STRING
| CTLFLAG_RD
,
156 hw_cpu_extfeatures
, "A", "CPU extended feature names");
158 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, logical_per_package
,
159 CTLTYPE_INT
| CTLFLAG_RD
,
161 hw_cpu_logical_per_package
, "I", "CPU logical cpus per package");
163 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, cores_per_package
,
164 CTLTYPE_INT
| CTLFLAG_RD
,
165 (void *)offsetof(i386_cpu_info_t
, cpuid_cores_per_package
),
167 hw_cpu_sysctl
, "I", "CPU cores per package");
170 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, mwait
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
173 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_min
,
174 CTLTYPE_INT
| CTLFLAG_RD
,
175 (void *)offsetof(i386_cpu_info_t
, cpuid_mwait_linesize_min
),
177 hw_cpu_sysctl
, "I", "Monitor/mwait minimum line size");
179 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_max
,
180 CTLTYPE_INT
| CTLFLAG_RD
,
181 (void *)offsetof(i386_cpu_info_t
, cpuid_mwait_linesize_max
),
183 hw_cpu_sysctl
, "I", "Monitor/mwait maximum line size");
185 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, extensions
,
186 CTLTYPE_INT
| CTLFLAG_RD
,
187 (void *)offsetof(i386_cpu_info_t
, cpuid_mwait_extensions
),
189 hw_cpu_sysctl
, "I", "Monitor/mwait extensions");
191 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, sub_Cstates
,
192 CTLTYPE_INT
| CTLFLAG_RD
,
193 (void *)offsetof(i386_cpu_info_t
, cpuid_mwait_sub_Cstates
),
195 hw_cpu_sysctl
, "I", "Monitor/mwait sub C-states");
198 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, thermal
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
201 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, sensor
,
202 CTLTYPE_INT
| CTLFLAG_RD
,
203 (void *)offsetof(i386_cpu_info_t
, cpuid_thermal_sensor
),
205 hw_cpu_sysctl
, "I", "Thermal sensor present");
207 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, dynamic_acceleration
,
208 CTLTYPE_INT
| CTLFLAG_RD
,
209 (void *)offsetof(i386_cpu_info_t
, cpuid_thermal_dynamic_acceleration
),
211 hw_cpu_sysctl
, "I", "Dynamic Acceleration Technology");
213 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, thresholds
,
214 CTLTYPE_INT
| CTLFLAG_RD
,
215 (void *)offsetof(i386_cpu_info_t
, cpuid_thermal_thresholds
),
217 hw_cpu_sysctl
, "I", "Number of interrupt thresholds");
219 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, ACNT_MCNT
,
220 CTLTYPE_INT
| CTLFLAG_RD
,
221 (void *)offsetof(i386_cpu_info_t
, cpuid_thermal_ACNT_MCNT
),
223 hw_cpu_sysctl
, "I", "ACNT_MCNT capability");
226 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, arch_perf
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
229 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, version
,
230 CTLTYPE_INT
| CTLFLAG_RD
,
231 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_version
),
233 hw_cpu_sysctl
, "I", "Architectural Performance Version Number");
235 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, number
,
236 CTLTYPE_INT
| CTLFLAG_RD
,
237 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_number
),
239 hw_cpu_sysctl
, "I", "Number of counters per logical cpu");
241 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, width
,
242 CTLTYPE_INT
| CTLFLAG_RD
,
243 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_width
),
245 hw_cpu_sysctl
, "I", "Bit width of counters");
247 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events_number
,
248 CTLTYPE_INT
| CTLFLAG_RD
,
249 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_events_number
),
251 hw_cpu_sysctl
, "I", "Number of monitoring events");
253 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events
,
254 CTLTYPE_INT
| CTLFLAG_RD
,
255 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_events
),
257 hw_cpu_sysctl
, "I", "Bit vector of events");
259 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_number
,
260 CTLTYPE_INT
| CTLFLAG_RD
,
261 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_fixed_number
),
263 hw_cpu_sysctl
, "I", "Number of fixed-function counters");
265 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_width
,
266 CTLTYPE_INT
| CTLFLAG_RD
,
267 (void *)offsetof(i386_cpu_info_t
, cpuid_arch_perf_fixed_width
),
269 hw_cpu_sysctl
, "I", "Bit-width of fixed-function counters");
272 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, cache
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
275 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, linesize
,
276 CTLTYPE_INT
| CTLFLAG_RD
,
277 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_linesize
),
279 hw_cpu_sysctl
, "I", "Cacheline size");
281 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, L2_associativity
,
282 CTLTYPE_INT
| CTLFLAG_RD
,
283 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_L2_associativity
),
285 hw_cpu_sysctl
, "I", "L2 cache associativity");
287 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, size
,
288 CTLTYPE_INT
| CTLFLAG_RD
,
289 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_size
),
291 hw_cpu_sysctl
, "I", "Cache size (in Kbytes)");
294 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, address_bits
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
297 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, physical
,
298 CTLTYPE_INT
| CTLFLAG_RD
,
299 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_physical
),
301 hw_cpu_sysctl
, "I", "Number of physical address bits");
303 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, virtual,
304 CTLTYPE_INT
| CTLFLAG_RD
,
305 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_virtual
),
307 hw_cpu_sysctl
, "I", "Number of virtual address bits");
309 uint64_t pmap_pv_hashlist_walks
;
310 uint64_t pmap_pv_hashlist_cnts
;
311 uint32_t pmap_pv_hashlist_max
;
313 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
315 SYSCTL_NODE(_machdep
, OID_AUTO
, pmap
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
318 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashwalks
, CTLFLAG_RD
| CTLFLAG_KERN
, &pmap_pv_hashlist_walks
, "");
319 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashcnts
, CTLFLAG_RD
| CTLFLAG_KERN
, &pmap_pv_hashlist_cnts
, "");
320 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, hashmax
, CTLFLAG_RD
| CTLFLAG_KERN
, &pmap_pv_hashlist_max
, 0, "");