2 * Copyright (c) 2003-2011 Apple 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>
35 #include <i386/machine_routines.h>
36 #include <i386/pal_routines.h>
37 #include <i386/ucode.h>
38 #include <kern/clock.h>
39 #include <libkern/libkern.h>
40 #include <i386/lapic.h>
41 #include <i386/pmCPU.h>
45 _i386_cpu_info SYSCTL_HANDLER_ARGS
47 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
56 if (arg2
== 0 && ((char *)ptr
)[0] == '\0') {
60 if (arg2
== sizeof(uint8_t)) {
61 value
= (uint32_t) *(uint8_t *)ptr
;
63 arg2
= sizeof(uint32_t);
65 return SYSCTL_OUT(req
, ptr
, arg2
? (size_t) arg2
: strlen((char *)ptr
)+1);
69 i386_cpu_info SYSCTL_HANDLER_ARGS
71 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
72 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
76 i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
78 void *ptr
= (uint8_t *)cpuid_info() + (uintptr_t)arg1
;
79 int value
= *(uint32_t *)ptr
;
84 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
87 cpu_mwait SYSCTL_HANDLER_ARGS
89 i386_cpu_info_t
*cpu_info
= cpuid_info();
90 void *ptr
= (uint8_t *)cpu_info
->cpuid_mwait_leafp
+ (uintptr_t)arg1
;
91 if (cpu_info
->cpuid_mwait_leafp
== NULL
)
93 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
97 cpu_thermal SYSCTL_HANDLER_ARGS
99 i386_cpu_info_t
*cpu_info
= cpuid_info();
100 void *ptr
= (uint8_t *)cpu_info
->cpuid_thermal_leafp
+ (uintptr_t)arg1
;
101 if (cpu_info
->cpuid_thermal_leafp
== NULL
)
103 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
107 cpu_arch_perf SYSCTL_HANDLER_ARGS
109 i386_cpu_info_t
*cpu_info
= cpuid_info();
110 void *ptr
= (uint8_t *)cpu_info
->cpuid_arch_perf_leafp
+ (uintptr_t)arg1
;
111 if (cpu_info
->cpuid_arch_perf_leafp
== NULL
)
113 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
117 cpu_xsave SYSCTL_HANDLER_ARGS
119 i386_cpu_info_t
*cpu_info
= cpuid_info();
120 void *ptr
= (uint8_t *)cpu_info
->cpuid_xsave_leafp
+ (uintptr_t)arg1
;
121 if (cpu_info
->cpuid_xsave_leafp
== NULL
)
123 return _i386_cpu_info(oidp
, ptr
, arg2
, req
);
128 cpu_features SYSCTL_HANDLER_ARGS
130 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
131 __unused
void *unused_arg1
= arg1
;
132 __unused
int unused_arg2
= arg2
;
136 cpuid_get_feature_names(cpuid_features(), buf
, sizeof(buf
));
138 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
142 cpu_extfeatures SYSCTL_HANDLER_ARGS
144 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
145 __unused
void *unused_arg1
= arg1
;
146 __unused
int unused_arg2
= arg2
;
150 cpuid_get_extfeature_names(cpuid_extfeatures(), buf
, sizeof(buf
));
152 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
156 cpu_leaf7_features SYSCTL_HANDLER_ARGS
158 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
159 __unused
void *unused_arg1
= arg1
;
160 __unused
int unused_arg2
= arg2
;
163 uint32_t leaf7_features
= cpuid_info()->cpuid_leaf7_features
;
164 if (leaf7_features
== 0)
168 cpuid_get_leaf7_feature_names(leaf7_features
, buf
, sizeof(buf
));
170 return SYSCTL_OUT(req
, buf
, strlen(buf
) + 1);
174 cpu_logical_per_package SYSCTL_HANDLER_ARGS
176 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
177 __unused
void *unused_arg1
= arg1
;
178 __unused
int unused_arg2
= arg2
;
179 i386_cpu_info_t
*cpu_info
= cpuid_info();
181 if (!(cpuid_features() & CPUID_FEATURE_HTT
))
184 return SYSCTL_OUT(req
, &cpu_info
->cpuid_logical_per_package
,
185 sizeof(cpu_info
->cpuid_logical_per_package
));
189 cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
191 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
192 __unused
void *unused_arg1
= arg1
;
193 __unused
int unused_arg2
= arg2
;
194 i386_cpu_info_t
*cpu_info
= cpuid_info();
196 if (cpu_info
->cpuid_model
!= 26)
199 return SYSCTL_OUT(req
, &flex_ratio
, sizeof(flex_ratio
));
203 cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
205 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
206 __unused
void *unused_arg1
= arg1
;
207 __unused
int unused_arg2
= arg2
;
208 i386_cpu_info_t
*cpu_info
= cpuid_info();
210 if (cpu_info
->cpuid_model
!= 26)
213 return SYSCTL_OUT(req
, &flex_ratio_min
, sizeof(flex_ratio_min
));
217 cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
219 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
220 __unused
void *unused_arg1
= arg1
;
221 __unused
int unused_arg2
= arg2
;
222 i386_cpu_info_t
*cpu_info
= cpuid_info();
224 if (cpu_info
->cpuid_model
!= 26)
227 return SYSCTL_OUT(req
, &flex_ratio_max
, sizeof(flex_ratio_max
));
231 cpu_ucode_update SYSCTL_HANDLER_ARGS
233 __unused
struct sysctl_oid
*unused_oidp
= oidp
;
234 __unused
void *unused_arg1
= arg1
;
235 __unused
int unused_arg2
= arg2
;
239 error
= SYSCTL_IN(req
, &addr
, sizeof(addr
));
243 int ret
= ucode_interface(addr
);
247 extern uint64_t panic_restart_timeout
;
249 panic_set_restart_timeout(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
251 int new_value
= 0, old_value
= 0, changed
= 0, error
;
254 if (panic_restart_timeout
) {
255 absolutetime_to_nanoseconds(panic_restart_timeout
, &nstime
);
256 old_value
= nstime
/ NSEC_PER_SEC
;
259 error
= sysctl_io_number(req
, old_value
, sizeof(int), &new_value
, &changed
);
260 if (error
== 0 && changed
) {
261 nanoseconds_to_absolutetime(((uint64_t)new_value
) * NSEC_PER_SEC
, &panic_restart_timeout
);
267 * Populates the {CPU, vector, latency} triple for the maximum observed primary
271 misc_interrupt_latency_max(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
273 int changed
= 0, error
;
277 interrupt_populate_latency_stats(buf
, sizeof(buf
));
279 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
281 if (error
== 0 && changed
) {
282 interrupt_reset_latency_stats();
289 * Triggers a machine-check exception - for a suitably configured kernel only.
291 extern void mca_exception_panic(void);
293 misc_machine_check_panic(__unused
struct sysctl_oid
*oidp
, __unused
void *arg1
, __unused
int arg2
, struct sysctl_req
*req
)
295 int changed
= 0, error
;
299 error
= sysctl_io_string(req
, buf
, sizeof(buf
), 0, &changed
);
301 if (error
== 0 && changed
) {
302 mca_exception_panic();
308 SYSCTL_NODE(_machdep
, OID_AUTO
, cpu
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
311 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_basic
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
312 (void *)offsetof(i386_cpu_info_t
, cpuid_max_basic
),sizeof(uint32_t),
313 i386_cpu_info
, "IU", "Max Basic Information value");
315 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, max_ext
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
316 (void *)offsetof(i386_cpu_info_t
, cpuid_max_ext
), sizeof(uint32_t),
317 i386_cpu_info
, "IU", "Max Extended Function Information value");
319 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, vendor
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
320 (void *)offsetof(i386_cpu_info_t
, cpuid_vendor
), 0,
321 i386_cpu_info
, "A", "CPU vendor");
323 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand_string
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
324 (void *)offsetof(i386_cpu_info_t
, cpuid_brand_string
), 0,
325 i386_cpu_info
, "A", "CPU brand string");
327 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, family
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
328 (void *)offsetof(i386_cpu_info_t
, cpuid_family
), sizeof(uint8_t),
329 i386_cpu_info
, "I", "CPU family");
331 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, model
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
332 (void *)offsetof(i386_cpu_info_t
, cpuid_model
), sizeof(uint8_t),
333 i386_cpu_info
, "I", "CPU model");
335 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extmodel
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
336 (void *)offsetof(i386_cpu_info_t
, cpuid_extmodel
), sizeof(uint8_t),
337 i386_cpu_info
, "I", "CPU extended model");
339 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfamily
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
340 (void *)offsetof(i386_cpu_info_t
, cpuid_extfamily
), sizeof(uint8_t),
341 i386_cpu_info
, "I", "CPU extended family");
343 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, stepping
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
344 (void *)offsetof(i386_cpu_info_t
, cpuid_stepping
), sizeof(uint8_t),
345 i386_cpu_info
, "I", "CPU stepping");
347 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, feature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
348 (void *)offsetof(i386_cpu_info_t
, cpuid_features
), sizeof(uint64_t),
349 i386_cpu_info
, "IU", "CPU features");
351 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_feature_bits
,
352 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
353 (void *)offsetof(i386_cpu_info_t
, cpuid_leaf7_features
),
355 i386_cpu_info_nonzero
, "IU", "CPU Leaf7 features");
357 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeature_bits
, CTLTYPE_QUAD
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
358 (void *)offsetof(i386_cpu_info_t
, cpuid_extfeatures
), sizeof(uint64_t),
359 i386_cpu_info
, "IU", "CPU extended features");
361 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, signature
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
362 (void *)offsetof(i386_cpu_info_t
, cpuid_signature
), sizeof(uint32_t),
363 i386_cpu_info
, "I", "CPU signature");
365 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, brand
, CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
366 (void *)offsetof(i386_cpu_info_t
, cpuid_brand
), sizeof(uint8_t),
367 i386_cpu_info
, "I", "CPU brand");
369 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, features
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
371 cpu_features
, "A", "CPU feature names");
373 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, leaf7_features
,
374 CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
376 cpu_leaf7_features
, "A", "CPU Leaf7 feature names");
378 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, extfeatures
, CTLTYPE_STRING
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
380 cpu_extfeatures
, "A", "CPU extended feature names");
382 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, logical_per_package
,
383 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
385 cpu_logical_per_package
, "I", "CPU logical cpus per package");
387 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, cores_per_package
,
388 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
389 (void *)offsetof(i386_cpu_info_t
, cpuid_cores_per_package
),
391 i386_cpu_info
, "I", "CPU cores per package");
393 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, microcode_version
,
394 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
395 (void *)offsetof(i386_cpu_info_t
, cpuid_microcode_version
),
397 i386_cpu_info
, "I", "Microcode version number");
399 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, processor_flag
,
400 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
401 (void *)offsetof(i386_cpu_info_t
, cpuid_processor_flag
),
403 i386_cpu_info
, "I", "CPU processor flag");
406 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, mwait
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
409 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_min
,
410 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
411 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_min
),
413 cpu_mwait
, "I", "Monitor/mwait minimum line size");
415 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, linesize_max
,
416 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
417 (void *)offsetof(cpuid_mwait_leaf_t
, linesize_max
),
419 cpu_mwait
, "I", "Monitor/mwait maximum line size");
421 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, extensions
,
422 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
423 (void *)offsetof(cpuid_mwait_leaf_t
, extensions
),
425 cpu_mwait
, "I", "Monitor/mwait extensions");
427 SYSCTL_PROC(_machdep_cpu_mwait
, OID_AUTO
, sub_Cstates
,
428 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
429 (void *)offsetof(cpuid_mwait_leaf_t
, sub_Cstates
),
431 cpu_mwait
, "I", "Monitor/mwait sub C-states");
434 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, thermal
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
437 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, sensor
,
438 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
439 (void *)offsetof(cpuid_thermal_leaf_t
, sensor
),
441 cpu_thermal
, "I", "Thermal sensor present");
443 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, dynamic_acceleration
,
444 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
445 (void *)offsetof(cpuid_thermal_leaf_t
, dynamic_acceleration
),
447 cpu_thermal
, "I", "Dynamic Acceleration Technology (Turbo Mode)");
449 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, invariant_APIC_timer
,
450 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
451 (void *)offsetof(cpuid_thermal_leaf_t
, invariant_APIC_timer
),
453 cpu_thermal
, "I", "Invariant APIC Timer");
455 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, thresholds
,
456 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
457 (void *)offsetof(cpuid_thermal_leaf_t
, thresholds
),
459 cpu_thermal
, "I", "Number of interrupt thresholds");
461 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, ACNT_MCNT
,
462 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
463 (void *)offsetof(cpuid_thermal_leaf_t
, ACNT_MCNT
),
465 cpu_thermal
, "I", "ACNT_MCNT capability");
467 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, core_power_limits
,
468 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
469 (void *)offsetof(cpuid_thermal_leaf_t
, core_power_limits
),
471 cpu_thermal
, "I", "Power Limit Notifications at a Core Level");
473 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, fine_grain_clock_mod
,
474 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
475 (void *)offsetof(cpuid_thermal_leaf_t
, fine_grain_clock_mod
),
477 cpu_thermal
, "I", "Fine Grain Clock Modulation");
479 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, package_thermal_intr
,
480 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
481 (void *)offsetof(cpuid_thermal_leaf_t
, package_thermal_intr
),
483 cpu_thermal
, "I", "Package Thermal interrupt and Status");
485 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, hardware_feedback
,
486 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
487 (void *)offsetof(cpuid_thermal_leaf_t
, hardware_feedback
),
489 cpu_thermal
, "I", "Hardware Coordination Feedback");
491 SYSCTL_PROC(_machdep_cpu_thermal
, OID_AUTO
, energy_policy
,
492 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
493 (void *)offsetof(cpuid_thermal_leaf_t
, energy_policy
),
495 cpu_thermal
, "I", "Energy Efficient Policy Support");
497 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, xsave
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
500 SYSCTL_PROC(_machdep_cpu_xsave
, OID_AUTO
, extended_state
,
501 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
502 (void *)offsetof(cpuid_xsave_leaf_t
, extended_state
),
503 sizeof(cpuid_xsave_leaf_t
),
504 cpu_xsave
, "IU", "XSAVE Extended State");
507 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, arch_perf
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
510 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, version
,
511 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
512 (void *)offsetof(cpuid_arch_perf_leaf_t
, version
),
514 cpu_arch_perf
, "I", "Architectural Performance Version Number");
516 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, number
,
517 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
518 (void *)offsetof(cpuid_arch_perf_leaf_t
, number
),
520 cpu_arch_perf
, "I", "Number of counters per logical cpu");
522 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, width
,
523 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
524 (void *)offsetof(cpuid_arch_perf_leaf_t
, width
),
526 cpu_arch_perf
, "I", "Bit width of counters");
528 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events_number
,
529 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
530 (void *)offsetof(cpuid_arch_perf_leaf_t
, events_number
),
532 cpu_arch_perf
, "I", "Number of monitoring events");
534 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, events
,
535 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
536 (void *)offsetof(cpuid_arch_perf_leaf_t
, events
),
538 cpu_arch_perf
, "I", "Bit vector of events");
540 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_number
,
541 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
542 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_number
),
544 cpu_arch_perf
, "I", "Number of fixed-function counters");
546 SYSCTL_PROC(_machdep_cpu_arch_perf
, OID_AUTO
, fixed_width
,
547 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
548 (void *)offsetof(cpuid_arch_perf_leaf_t
, fixed_width
),
550 cpu_arch_perf
, "I", "Bit-width of fixed-function counters");
553 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, cache
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
556 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, linesize
,
557 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
558 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_linesize
),
560 i386_cpu_info
, "I", "Cacheline size");
562 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, L2_associativity
,
563 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
564 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_L2_associativity
),
566 i386_cpu_info
, "I", "L2 cache associativity");
568 SYSCTL_PROC(_machdep_cpu_cache
, OID_AUTO
, size
,
569 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
570 (void *)offsetof(i386_cpu_info_t
, cpuid_cache_size
),
572 i386_cpu_info
, "I", "Cache size (in Kbytes)");
575 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, tlb
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
577 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, inst
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
579 SYSCTL_NODE(_machdep_cpu_tlb
, OID_AUTO
, data
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
582 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, small
,
583 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
584 (void *)offsetof(i386_cpu_info_t
,
585 cpuid_tlb
[TLB_INST
][TLB_SMALL
][0]),
587 i386_cpu_info_nonzero
, "I",
588 "Number of small page instruction TLBs");
590 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small
,
591 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
592 (void *)offsetof(i386_cpu_info_t
,
593 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][0]),
595 i386_cpu_info_nonzero
, "I",
596 "Number of small page data TLBs (1st level)");
598 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, small_level1
,
599 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
600 (void *)offsetof(i386_cpu_info_t
,
601 cpuid_tlb
[TLB_DATA
][TLB_SMALL
][1]),
603 i386_cpu_info_nonzero
, "I",
604 "Number of small page data TLBs (2nd level)");
606 SYSCTL_PROC(_machdep_cpu_tlb_inst
, OID_AUTO
, large
,
607 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
608 (void *)offsetof(i386_cpu_info_t
,
609 cpuid_tlb
[TLB_INST
][TLB_LARGE
][0]),
611 i386_cpu_info_nonzero
, "I",
612 "Number of large page instruction TLBs");
614 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large
,
615 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
616 (void *)offsetof(i386_cpu_info_t
,
617 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][0]),
619 i386_cpu_info_nonzero
, "I",
620 "Number of large page data TLBs (1st level)");
622 SYSCTL_PROC(_machdep_cpu_tlb_data
, OID_AUTO
, large_level1
,
623 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
624 (void *)offsetof(i386_cpu_info_t
,
625 cpuid_tlb
[TLB_DATA
][TLB_LARGE
][1]),
627 i386_cpu_info_nonzero
, "I",
628 "Number of large page data TLBs (2nd level)");
630 SYSCTL_PROC(_machdep_cpu_tlb
, OID_AUTO
, shared
,
631 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
632 (void *)offsetof(i386_cpu_info_t
, cpuid_stlb
),
634 i386_cpu_info_nonzero
, "I",
635 "Number of shared TLBs");
638 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, address_bits
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
641 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, physical
,
642 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
643 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_physical
),
645 i386_cpu_info
, "I", "Number of physical address bits");
647 SYSCTL_PROC(_machdep_cpu_address_bits
, OID_AUTO
, virtual,
648 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
649 (void *)offsetof(i386_cpu_info_t
, cpuid_address_bits_virtual
),
651 i386_cpu_info
, "I", "Number of virtual address bits");
654 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, core_count
,
655 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
656 (void *)offsetof(i386_cpu_info_t
, core_count
),
658 i386_cpu_info
, "I", "Number of enabled cores per package");
660 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, thread_count
,
661 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
662 (void *)offsetof(i386_cpu_info_t
, thread_count
),
664 i386_cpu_info
, "I", "Number of enabled threads per package");
666 SYSCTL_NODE(_machdep_cpu
, OID_AUTO
, flex_ratio
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
669 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, desired
,
670 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
672 cpu_flex_ratio_desired
, "I", "Flex ratio desired (0 disabled)");
674 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, min
,
675 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
677 cpu_flex_ratio_min
, "I", "Flex ratio min (efficiency)");
679 SYSCTL_PROC(_machdep_cpu_flex_ratio
, OID_AUTO
, max
,
680 CTLTYPE_INT
| CTLFLAG_RD
| CTLFLAG_LOCKED
,
682 cpu_flex_ratio_max
, "I", "Flex ratio max (non-turbo)");
684 SYSCTL_PROC(_machdep_cpu
, OID_AUTO
, ucupdate
,
685 CTLTYPE_INT
| CTLFLAG_WR
| CTLFLAG_LOCKED
, 0, 0,
686 cpu_ucode_update
, "S", "Microcode update interface");
688 static const uint32_t apic_timer_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_TIMER_INTERRUPT
);
689 static const uint32_t apic_IPI_vector
= (LAPIC_DEFAULT_INTERRUPT_BASE
+ LAPIC_INTERPROCESSOR_INTERRUPT
);
691 SYSCTL_NODE(_machdep
, OID_AUTO
, vectors
, CTLFLAG_RD
| CTLFLAG_LOCKED
, 0,
692 "Interrupt vector assignments");
694 SYSCTL_UINT (_machdep_vectors
, OID_AUTO
, timer
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, (uint32_t *)&apic_timer_vector
, 0, "");
695 SYSCTL_UINT (_machdep_vectors
, OID_AUTO
, IPI
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, (uint32_t *)&apic_IPI_vector
, 0, "");
697 uint64_t pmap_pv_hashlist_walks
;
698 uint64_t pmap_pv_hashlist_cnts
;
699 uint32_t pmap_pv_hashlist_max
;
700 uint32_t pmap_kernel_text_ps
= PAGE_SIZE
;
701 extern uint32_t pv_hashed_kern_low_water_mark
;
703 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
705 SYSCTL_NODE(_machdep
, OID_AUTO
, pmap
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
708 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashwalks
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_walks
, "");
709 SYSCTL_QUAD (_machdep_pmap
, OID_AUTO
, hashcnts
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_cnts
, "");
710 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, hashmax
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_pv_hashlist_max
, 0, "");
711 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, kernel_text_ps
, CTLFLAG_RD
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pmap_kernel_text_ps
, 0, "");
712 SYSCTL_INT (_machdep_pmap
, OID_AUTO
, kern_pv_reserve
, CTLFLAG_RW
| CTLFLAG_KERN
| CTLFLAG_LOCKED
, &pv_hashed_kern_low_water_mark
, 0, "");
714 SYSCTL_NODE(_machdep
, OID_AUTO
, memmap
, CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "physical memory map");
716 uint64_t firmware_Conventional_bytes
= 0;
717 uint64_t firmware_RuntimeServices_bytes
= 0;
718 uint64_t firmware_ACPIReclaim_bytes
= 0;
719 uint64_t firmware_ACPINVS_bytes
= 0;
720 uint64_t firmware_PalCode_bytes
= 0;
721 uint64_t firmware_Reserved_bytes
= 0;
722 uint64_t firmware_Unusable_bytes
= 0;
723 uint64_t firmware_other_bytes
= 0;
725 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Conventional
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Conventional_bytes
, "");
726 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, RuntimeServices
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_RuntimeServices_bytes
, "");
727 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPIReclaim
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_ACPIReclaim_bytes
, "");
728 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, ACPINVS
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_ACPINVS_bytes
, "");
729 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, PalCode
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_PalCode_bytes
, "");
730 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Reserved
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Reserved_bytes
, "");
731 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Unusable
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_Unusable_bytes
, "");
732 SYSCTL_QUAD(_machdep_memmap
, OID_AUTO
, Other
, CTLFLAG_RD
|CTLFLAG_LOCKED
, &firmware_other_bytes
, "");
734 SYSCTL_NODE(_machdep
, OID_AUTO
, tsc
, CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "Timestamp counter parameters");
736 SYSCTL_QUAD(_machdep_tsc
, OID_AUTO
, frequency
,
737 CTLFLAG_RD
|CTLFLAG_LOCKED
, &tscFreq
, "");
739 extern uint32_t deep_idle_rebase
;
740 SYSCTL_UINT(_machdep_tsc
, OID_AUTO
, deep_idle_rebase
,
741 CTLFLAG_RW
|CTLFLAG_KERN
|CTLFLAG_LOCKED
, &deep_idle_rebase
, 0, "");
743 SYSCTL_NODE(_machdep_tsc
, OID_AUTO
, nanotime
,
744 CTLFLAG_RD
|CTLFLAG_LOCKED
, NULL
, "TSC to ns conversion");
745 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, tsc_base
,
746 CTLFLAG_RD
| CTLFLAG_LOCKED
,
747 (uint64_t *) &pal_rtc_nanotime_info
.tsc_base
, "");
748 SYSCTL_QUAD(_machdep_tsc_nanotime
, OID_AUTO
, ns_base
,
749 CTLFLAG_RD
| CTLFLAG_LOCKED
,
750 (uint64_t *)&pal_rtc_nanotime_info
.ns_base
, "");
751 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, scale
,
752 CTLFLAG_RD
| CTLFLAG_LOCKED
,
753 (uint32_t *)&pal_rtc_nanotime_info
.scale
, 0, "");
754 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, shift
,
755 CTLFLAG_RD
| CTLFLAG_LOCKED
,
756 (uint32_t *)&pal_rtc_nanotime_info
.shift
, 0, "");
757 SYSCTL_UINT(_machdep_tsc_nanotime
, OID_AUTO
, generation
,
758 CTLFLAG_RD
| CTLFLAG_LOCKED
,
759 (uint32_t *)&pal_rtc_nanotime_info
.generation
, 0, "");
761 SYSCTL_NODE(_machdep
, OID_AUTO
, misc
, CTLFLAG_RW
|CTLFLAG_LOCKED
, 0,
762 "Miscellaneous x86 kernel parameters");
764 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, panic_restart_timeout
,
765 CTLTYPE_INT
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
767 panic_set_restart_timeout
, "I", "Panic restart timeout in seconds");
769 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, interrupt_latency_max
,
770 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
772 misc_interrupt_latency_max
, "A", "Maximum Interrupt latency");
774 SYSCTL_PROC(_machdep_misc
, OID_AUTO
, machine_check_panic
,
775 CTLTYPE_STRING
| CTLFLAG_RW
| CTLFLAG_LOCKED
,
777 misc_machine_check_panic
, "A", "Machine-check exception test");