]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/i386/sysctl.c
xnu-1699.32.7.tar.gz
[apple/xnu.git] / bsd / dev / i386 / sysctl.c
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #include <string.h>
30 #include <sys/param.h>
31 #include <sys/kernel.h>
32 #include <sys/sysctl.h>
33 #include <i386/cpuid.h>
34 #include <i386/tsc.h>
35 #include <i386/machine_routines.h>
36 #include <i386/ucode.h>
37 #include <kern/clock.h>
38 #include <libkern/libkern.h>
39
40 static int
41 _i386_cpu_info SYSCTL_HANDLER_ARGS
42 {
43 __unused struct sysctl_oid *unused_oidp = oidp;
44 void *ptr = arg1;
45 int value;
46
47 if (arg2 == -1) {
48 ptr = *(void **)ptr;
49 arg2 = 0;
50 }
51
52 if (arg2 == 0 && ((char *)ptr)[0] == '\0') {
53 return ENOENT;
54 }
55
56 if (arg2 == sizeof(uint8_t)) {
57 value = (uint32_t) *(uint8_t *)ptr;
58 ptr = &value;
59 arg2 = sizeof(uint32_t);
60 }
61 return SYSCTL_OUT(req, ptr, arg2 ? (size_t) arg2 : strlen((char *)ptr)+1);
62 }
63
64 static int
65 i386_cpu_info SYSCTL_HANDLER_ARGS
66 {
67 void *ptr = (uint8_t *)cpuid_info() + (uintptr_t)arg1;
68 return _i386_cpu_info(oidp, ptr, arg2, req);
69 }
70
71 static int
72 i386_cpu_info_nonzero SYSCTL_HANDLER_ARGS
73 {
74 void *ptr = (uint8_t *)cpuid_info() + (uintptr_t)arg1;
75 int value = *(uint32_t *)ptr;
76
77 if (value == 0)
78 return ENOENT;
79
80 return _i386_cpu_info(oidp, ptr, arg2, req);
81 }
82 static int
83 cpu_mwait SYSCTL_HANDLER_ARGS
84 {
85 i386_cpu_info_t *cpu_info = cpuid_info();
86 void *ptr = (uint8_t *)cpu_info->cpuid_mwait_leafp + (uintptr_t)arg1;
87 if (cpu_info->cpuid_mwait_leafp == NULL)
88 return ENOENT;
89 return _i386_cpu_info(oidp, ptr, arg2, req);
90 }
91
92 static int
93 cpu_thermal SYSCTL_HANDLER_ARGS
94 {
95 i386_cpu_info_t *cpu_info = cpuid_info();
96 void *ptr = (uint8_t *)cpu_info->cpuid_thermal_leafp + (uintptr_t)arg1;
97 if (cpu_info->cpuid_thermal_leafp == NULL)
98 return ENOENT;
99 return _i386_cpu_info(oidp, ptr, arg2, req);
100 }
101
102 static int
103 cpu_arch_perf SYSCTL_HANDLER_ARGS
104 {
105 i386_cpu_info_t *cpu_info = cpuid_info();
106 void *ptr = (uint8_t *)cpu_info->cpuid_arch_perf_leafp + (uintptr_t)arg1;
107 if (cpu_info->cpuid_arch_perf_leafp == NULL)
108 return ENOENT;
109 return _i386_cpu_info(oidp, ptr, arg2, req);
110 }
111
112 static int
113 cpu_xsave SYSCTL_HANDLER_ARGS
114 {
115 i386_cpu_info_t *cpu_info = cpuid_info();
116 void *ptr = (uint8_t *)cpu_info->cpuid_xsave_leafp + (uintptr_t)arg1;
117 if (cpu_info->cpuid_xsave_leafp == NULL)
118 return ENOENT;
119 return _i386_cpu_info(oidp, ptr, arg2, req);
120 }
121
122 static int
123 cpu_features SYSCTL_HANDLER_ARGS
124 {
125 __unused struct sysctl_oid *unused_oidp = oidp;
126 __unused void *unused_arg1 = arg1;
127 __unused int unused_arg2 = arg2;
128 char buf[512];
129
130 buf[0] = '\0';
131 cpuid_get_feature_names(cpuid_features(), buf, sizeof(buf));
132
133 return SYSCTL_OUT(req, buf, strlen(buf) + 1);
134 }
135
136 static int
137 cpu_extfeatures SYSCTL_HANDLER_ARGS
138 {
139 __unused struct sysctl_oid *unused_oidp = oidp;
140 __unused void *unused_arg1 = arg1;
141 __unused int unused_arg2 = arg2;
142 char buf[512];
143
144 buf[0] = '\0';
145 cpuid_get_extfeature_names(cpuid_extfeatures(), buf, sizeof(buf));
146
147 return SYSCTL_OUT(req, buf, strlen(buf) + 1);
148 }
149
150 static int
151 cpu_leaf7_features SYSCTL_HANDLER_ARGS
152 {
153 __unused struct sysctl_oid *unused_oidp = oidp;
154 __unused void *unused_arg1 = arg1;
155 __unused int unused_arg2 = arg2;
156 char buf[512];
157
158 uint32_t leaf7_features = cpuid_info()->cpuid_leaf7_features;
159 if (leaf7_features == 0)
160 return ENOENT;
161
162 buf[0] = '\0';
163 cpuid_get_leaf7_feature_names(leaf7_features, buf, sizeof(buf));
164
165 return SYSCTL_OUT(req, buf, strlen(buf) + 1);
166 }
167
168 static int
169 cpu_logical_per_package SYSCTL_HANDLER_ARGS
170 {
171 __unused struct sysctl_oid *unused_oidp = oidp;
172 __unused void *unused_arg1 = arg1;
173 __unused int unused_arg2 = arg2;
174 i386_cpu_info_t *cpu_info = cpuid_info();
175
176 if (!(cpuid_features() & CPUID_FEATURE_HTT))
177 return ENOENT;
178
179 return SYSCTL_OUT(req, &cpu_info->cpuid_logical_per_package,
180 sizeof(cpu_info->cpuid_logical_per_package));
181 }
182
183 static int
184 cpu_flex_ratio_desired SYSCTL_HANDLER_ARGS
185 {
186 __unused struct sysctl_oid *unused_oidp = oidp;
187 __unused void *unused_arg1 = arg1;
188 __unused int unused_arg2 = arg2;
189 i386_cpu_info_t *cpu_info = cpuid_info();
190
191 if (cpu_info->cpuid_model != 26)
192 return ENOENT;
193
194 return SYSCTL_OUT(req, &flex_ratio, sizeof(flex_ratio));
195 }
196
197 static int
198 cpu_flex_ratio_min SYSCTL_HANDLER_ARGS
199 {
200 __unused struct sysctl_oid *unused_oidp = oidp;
201 __unused void *unused_arg1 = arg1;
202 __unused int unused_arg2 = arg2;
203 i386_cpu_info_t *cpu_info = cpuid_info();
204
205 if (cpu_info->cpuid_model != 26)
206 return ENOENT;
207
208 return SYSCTL_OUT(req, &flex_ratio_min, sizeof(flex_ratio_min));
209 }
210
211 static int
212 cpu_flex_ratio_max SYSCTL_HANDLER_ARGS
213 {
214 __unused struct sysctl_oid *unused_oidp = oidp;
215 __unused void *unused_arg1 = arg1;
216 __unused int unused_arg2 = arg2;
217 i386_cpu_info_t *cpu_info = cpuid_info();
218
219 if (cpu_info->cpuid_model != 26)
220 return ENOENT;
221
222 return SYSCTL_OUT(req, &flex_ratio_max, sizeof(flex_ratio_max));
223 }
224
225 static int
226 cpu_ucode_update SYSCTL_HANDLER_ARGS
227 {
228 __unused struct sysctl_oid *unused_oidp = oidp;
229 __unused void *unused_arg1 = arg1;
230 __unused int unused_arg2 = arg2;
231 uint64_t addr;
232 int error;
233
234 error = SYSCTL_IN(req, &addr, sizeof(addr));
235 if (error)
236 return error;
237
238 int ret = ucode_interface(addr);
239 return ret;
240 }
241
242 extern uint64_t panic_restart_timeout;
243 static int
244 panic_set_restart_timeout(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
245 {
246 int new_value = 0, old_value = 0, changed = 0, error;
247 uint64_t nstime;
248
249 if (panic_restart_timeout) {
250 absolutetime_to_nanoseconds(panic_restart_timeout, &nstime);
251 old_value = nstime / NSEC_PER_SEC;
252 }
253
254 error = sysctl_io_number(req, old_value, sizeof(int), &new_value, &changed);
255 if (error == 0 && changed) {
256 nanoseconds_to_absolutetime(((uint64_t)new_value) * NSEC_PER_SEC, &panic_restart_timeout);
257 }
258 return error;
259 }
260
261 /*
262 * Populates the {CPU, vector, latency} triple for the maximum observed primary
263 * interrupt latency
264 */
265 static int
266 misc_interrupt_latency_max(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
267 {
268 int changed = 0, error;
269 char buf[128];
270 buf[0] = '\0';
271
272 interrupt_populate_latency_stats(buf, sizeof(buf));
273
274 error = sysctl_io_string(req, buf, sizeof(buf), 0, &changed);
275
276 if (error == 0 && changed) {
277 interrupt_reset_latency_stats();
278 }
279
280 return error;
281 }
282
283 SYSCTL_NODE(_machdep, OID_AUTO, cpu, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
284 "CPU info");
285
286 SYSCTL_PROC(_machdep_cpu, OID_AUTO, max_basic, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
287 (void *)offsetof(i386_cpu_info_t, cpuid_max_basic),sizeof(uint32_t),
288 i386_cpu_info, "IU", "Max Basic Information value");
289
290 SYSCTL_PROC(_machdep_cpu, OID_AUTO, max_ext, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
291 (void *)offsetof(i386_cpu_info_t, cpuid_max_ext), sizeof(uint32_t),
292 i386_cpu_info, "IU", "Max Extended Function Information value");
293
294 SYSCTL_PROC(_machdep_cpu, OID_AUTO, vendor, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
295 (void *)offsetof(i386_cpu_info_t, cpuid_vendor), 0,
296 i386_cpu_info, "A", "CPU vendor");
297
298 SYSCTL_PROC(_machdep_cpu, OID_AUTO, brand_string, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
299 (void *)offsetof(i386_cpu_info_t, cpuid_brand_string), 0,
300 i386_cpu_info, "A", "CPU brand string");
301
302 SYSCTL_PROC(_machdep_cpu, OID_AUTO, family, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
303 (void *)offsetof(i386_cpu_info_t, cpuid_family), sizeof(uint8_t),
304 i386_cpu_info, "I", "CPU family");
305
306 SYSCTL_PROC(_machdep_cpu, OID_AUTO, model, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
307 (void *)offsetof(i386_cpu_info_t, cpuid_model), sizeof(uint8_t),
308 i386_cpu_info, "I", "CPU model");
309
310 SYSCTL_PROC(_machdep_cpu, OID_AUTO, extmodel, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
311 (void *)offsetof(i386_cpu_info_t, cpuid_extmodel), sizeof(uint8_t),
312 i386_cpu_info, "I", "CPU extended model");
313
314 SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfamily, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
315 (void *)offsetof(i386_cpu_info_t, cpuid_extfamily), sizeof(uint8_t),
316 i386_cpu_info, "I", "CPU extended family");
317
318 SYSCTL_PROC(_machdep_cpu, OID_AUTO, stepping, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
319 (void *)offsetof(i386_cpu_info_t, cpuid_stepping), sizeof(uint8_t),
320 i386_cpu_info, "I", "CPU stepping");
321
322 SYSCTL_PROC(_machdep_cpu, OID_AUTO, feature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_LOCKED,
323 (void *)offsetof(i386_cpu_info_t, cpuid_features), sizeof(uint64_t),
324 i386_cpu_info, "IU", "CPU features");
325
326 SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_feature_bits,
327 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
328 (void *)offsetof(i386_cpu_info_t, cpuid_leaf7_features),
329 sizeof(uint32_t),
330 i386_cpu_info_nonzero, "IU", "CPU Leaf7 features");
331
332 SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeature_bits, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_LOCKED,
333 (void *)offsetof(i386_cpu_info_t, cpuid_extfeatures), sizeof(uint64_t),
334 i386_cpu_info, "IU", "CPU extended features");
335
336 SYSCTL_PROC(_machdep_cpu, OID_AUTO, signature, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
337 (void *)offsetof(i386_cpu_info_t, cpuid_signature), sizeof(uint32_t),
338 i386_cpu_info, "I", "CPU signature");
339
340 SYSCTL_PROC(_machdep_cpu, OID_AUTO, brand, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
341 (void *)offsetof(i386_cpu_info_t, cpuid_brand), sizeof(uint8_t),
342 i386_cpu_info, "I", "CPU brand");
343
344 SYSCTL_PROC(_machdep_cpu, OID_AUTO, features, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
345 0, 0,
346 cpu_features, "A", "CPU feature names");
347
348 SYSCTL_PROC(_machdep_cpu, OID_AUTO, leaf7_features,
349 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
350 0, 0,
351 cpu_leaf7_features, "A", "CPU Leaf7 feature names");
352
353 SYSCTL_PROC(_machdep_cpu, OID_AUTO, extfeatures, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_LOCKED,
354 0, 0,
355 cpu_extfeatures, "A", "CPU extended feature names");
356
357 SYSCTL_PROC(_machdep_cpu, OID_AUTO, logical_per_package,
358 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
359 0, 0,
360 cpu_logical_per_package, "I", "CPU logical cpus per package");
361
362 SYSCTL_PROC(_machdep_cpu, OID_AUTO, cores_per_package,
363 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
364 (void *)offsetof(i386_cpu_info_t, cpuid_cores_per_package),
365 sizeof(uint32_t),
366 i386_cpu_info, "I", "CPU cores per package");
367
368 SYSCTL_PROC(_machdep_cpu, OID_AUTO, microcode_version,
369 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
370 (void *)offsetof(i386_cpu_info_t, cpuid_microcode_version),
371 sizeof(uint32_t),
372 i386_cpu_info, "I", "Microcode version number");
373
374 SYSCTL_PROC(_machdep_cpu, OID_AUTO, processor_flag,
375 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
376 (void *)offsetof(i386_cpu_info_t, cpuid_processor_flag),
377 sizeof(uint32_t),
378 i386_cpu_info, "I", "CPU processor flag");
379
380
381 SYSCTL_NODE(_machdep_cpu, OID_AUTO, mwait, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
382 "mwait");
383
384 SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, linesize_min,
385 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
386 (void *)offsetof(cpuid_mwait_leaf_t, linesize_min),
387 sizeof(uint32_t),
388 cpu_mwait, "I", "Monitor/mwait minimum line size");
389
390 SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, linesize_max,
391 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
392 (void *)offsetof(cpuid_mwait_leaf_t, linesize_max),
393 sizeof(uint32_t),
394 cpu_mwait, "I", "Monitor/mwait maximum line size");
395
396 SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, extensions,
397 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
398 (void *)offsetof(cpuid_mwait_leaf_t, extensions),
399 sizeof(uint32_t),
400 cpu_mwait, "I", "Monitor/mwait extensions");
401
402 SYSCTL_PROC(_machdep_cpu_mwait, OID_AUTO, sub_Cstates,
403 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
404 (void *)offsetof(cpuid_mwait_leaf_t, sub_Cstates),
405 sizeof(uint32_t),
406 cpu_mwait, "I", "Monitor/mwait sub C-states");
407
408
409 SYSCTL_NODE(_machdep_cpu, OID_AUTO, thermal, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
410 "thermal");
411
412 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, sensor,
413 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
414 (void *)offsetof(cpuid_thermal_leaf_t, sensor),
415 sizeof(boolean_t),
416 cpu_thermal, "I", "Thermal sensor present");
417
418 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, dynamic_acceleration,
419 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
420 (void *)offsetof(cpuid_thermal_leaf_t, dynamic_acceleration),
421 sizeof(boolean_t),
422 cpu_thermal, "I", "Dynamic Acceleration Technology (Turbo Mode)");
423
424 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, invariant_APIC_timer,
425 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
426 (void *)offsetof(cpuid_thermal_leaf_t, invariant_APIC_timer),
427 sizeof(boolean_t),
428 cpu_thermal, "I", "Invariant APIC Timer");
429
430 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, thresholds,
431 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
432 (void *)offsetof(cpuid_thermal_leaf_t, thresholds),
433 sizeof(uint32_t),
434 cpu_thermal, "I", "Number of interrupt thresholds");
435
436 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, ACNT_MCNT,
437 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
438 (void *)offsetof(cpuid_thermal_leaf_t, ACNT_MCNT),
439 sizeof(boolean_t),
440 cpu_thermal, "I", "ACNT_MCNT capability");
441
442 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, core_power_limits,
443 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
444 (void *)offsetof(cpuid_thermal_leaf_t, core_power_limits),
445 sizeof(boolean_t),
446 cpu_thermal, "I", "Power Limit Notifications at a Core Level");
447
448 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, fine_grain_clock_mod,
449 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
450 (void *)offsetof(cpuid_thermal_leaf_t, fine_grain_clock_mod),
451 sizeof(boolean_t),
452 cpu_thermal, "I", "Fine Grain Clock Modulation");
453
454 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, package_thermal_intr,
455 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
456 (void *)offsetof(cpuid_thermal_leaf_t, package_thermal_intr),
457 sizeof(boolean_t),
458 cpu_thermal, "I", "Packge Thermal interrupt and Status");
459
460 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, hardware_feedback,
461 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
462 (void *)offsetof(cpuid_thermal_leaf_t, hardware_feedback),
463 sizeof(boolean_t),
464 cpu_thermal, "I", "Hardware Coordination Feedback");
465
466 SYSCTL_PROC(_machdep_cpu_thermal, OID_AUTO, energy_policy,
467 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
468 (void *)offsetof(cpuid_thermal_leaf_t, energy_policy),
469 sizeof(boolean_t),
470 cpu_thermal, "I", "Energy Efficient Policy Support");
471
472 SYSCTL_NODE(_machdep_cpu, OID_AUTO, xsave, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
473 "xsave");
474
475 SYSCTL_PROC(_machdep_cpu_xsave, OID_AUTO, extended_state,
476 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
477 (void *)offsetof(cpuid_xsave_leaf_t, extended_state),
478 sizeof(cpuid_xsave_leaf_t),
479 cpu_xsave, "IU", "XSAVE Extended State");
480
481
482 SYSCTL_NODE(_machdep_cpu, OID_AUTO, arch_perf, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
483 "arch_perf");
484
485 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, version,
486 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
487 (void *)offsetof(cpuid_arch_perf_leaf_t, version),
488 sizeof(uint8_t),
489 cpu_arch_perf, "I", "Architectural Performance Version Number");
490
491 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, number,
492 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
493 (void *)offsetof(cpuid_arch_perf_leaf_t, number),
494 sizeof(uint8_t),
495 cpu_arch_perf, "I", "Number of counters per logical cpu");
496
497 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, width,
498 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
499 (void *)offsetof(cpuid_arch_perf_leaf_t, width),
500 sizeof(uint8_t),
501 cpu_arch_perf, "I", "Bit width of counters");
502
503 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, events_number,
504 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
505 (void *)offsetof(cpuid_arch_perf_leaf_t, events_number),
506 sizeof(uint8_t),
507 cpu_arch_perf, "I", "Number of monitoring events");
508
509 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, events,
510 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
511 (void *)offsetof(cpuid_arch_perf_leaf_t, events),
512 sizeof(uint32_t),
513 cpu_arch_perf, "I", "Bit vector of events");
514
515 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, fixed_number,
516 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
517 (void *)offsetof(cpuid_arch_perf_leaf_t, fixed_number),
518 sizeof(uint8_t),
519 cpu_arch_perf, "I", "Number of fixed-function counters");
520
521 SYSCTL_PROC(_machdep_cpu_arch_perf, OID_AUTO, fixed_width,
522 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
523 (void *)offsetof(cpuid_arch_perf_leaf_t, fixed_width),
524 sizeof(uint8_t),
525 cpu_arch_perf, "I", "Bit-width of fixed-function counters");
526
527
528 SYSCTL_NODE(_machdep_cpu, OID_AUTO, cache, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
529 "cache");
530
531 SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, linesize,
532 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
533 (void *)offsetof(i386_cpu_info_t, cpuid_cache_linesize),
534 sizeof(uint32_t),
535 i386_cpu_info, "I", "Cacheline size");
536
537 SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, L2_associativity,
538 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
539 (void *)offsetof(i386_cpu_info_t, cpuid_cache_L2_associativity),
540 sizeof(uint32_t),
541 i386_cpu_info, "I", "L2 cache associativity");
542
543 SYSCTL_PROC(_machdep_cpu_cache, OID_AUTO, size,
544 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
545 (void *)offsetof(i386_cpu_info_t, cpuid_cache_size),
546 sizeof(uint32_t),
547 i386_cpu_info, "I", "Cache size (in Kbytes)");
548
549
550 SYSCTL_NODE(_machdep_cpu, OID_AUTO, tlb, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
551 "tlb");
552 SYSCTL_NODE(_machdep_cpu_tlb, OID_AUTO, inst, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
553 "inst");
554 SYSCTL_NODE(_machdep_cpu_tlb, OID_AUTO, data, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
555 "data");
556
557 SYSCTL_PROC(_machdep_cpu_tlb_inst, OID_AUTO, small,
558 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
559 (void *)offsetof(i386_cpu_info_t,
560 cpuid_tlb[TLB_INST][TLB_SMALL][0]),
561 sizeof(uint32_t),
562 i386_cpu_info_nonzero, "I",
563 "Number of small page instruction TLBs");
564
565 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, small,
566 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
567 (void *)offsetof(i386_cpu_info_t,
568 cpuid_tlb[TLB_DATA][TLB_SMALL][0]),
569 sizeof(uint32_t),
570 i386_cpu_info_nonzero, "I",
571 "Number of small page data TLBs (1st level)");
572
573 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, small_level1,
574 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
575 (void *)offsetof(i386_cpu_info_t,
576 cpuid_tlb[TLB_DATA][TLB_SMALL][1]),
577 sizeof(uint32_t),
578 i386_cpu_info_nonzero, "I",
579 "Number of small page data TLBs (2nd level)");
580
581 SYSCTL_PROC(_machdep_cpu_tlb_inst, OID_AUTO, large,
582 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
583 (void *)offsetof(i386_cpu_info_t,
584 cpuid_tlb[TLB_INST][TLB_LARGE][0]),
585 sizeof(uint32_t),
586 i386_cpu_info_nonzero, "I",
587 "Number of large page instruction TLBs");
588
589 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, large,
590 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
591 (void *)offsetof(i386_cpu_info_t,
592 cpuid_tlb[TLB_DATA][TLB_LARGE][0]),
593 sizeof(uint32_t),
594 i386_cpu_info_nonzero, "I",
595 "Number of large page data TLBs (1st level)");
596
597 SYSCTL_PROC(_machdep_cpu_tlb_data, OID_AUTO, large_level1,
598 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
599 (void *)offsetof(i386_cpu_info_t,
600 cpuid_tlb[TLB_DATA][TLB_LARGE][1]),
601 sizeof(uint32_t),
602 i386_cpu_info_nonzero, "I",
603 "Number of large page data TLBs (2nd level)");
604
605 SYSCTL_PROC(_machdep_cpu_tlb, OID_AUTO, shared,
606 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
607 (void *)offsetof(i386_cpu_info_t, cpuid_stlb),
608 sizeof(uint32_t),
609 i386_cpu_info_nonzero, "I",
610 "Number of shared TLBs");
611
612
613 SYSCTL_NODE(_machdep_cpu, OID_AUTO, address_bits, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
614 "address_bits");
615
616 SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, physical,
617 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
618 (void *)offsetof(i386_cpu_info_t, cpuid_address_bits_physical),
619 sizeof(uint32_t),
620 i386_cpu_info, "I", "Number of physical address bits");
621
622 SYSCTL_PROC(_machdep_cpu_address_bits, OID_AUTO, virtual,
623 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
624 (void *)offsetof(i386_cpu_info_t, cpuid_address_bits_virtual),
625 sizeof(uint32_t),
626 i386_cpu_info, "I", "Number of virtual address bits");
627
628
629 SYSCTL_PROC(_machdep_cpu, OID_AUTO, core_count,
630 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
631 (void *)offsetof(i386_cpu_info_t, core_count),
632 sizeof(uint32_t),
633 i386_cpu_info, "I", "Number of enabled cores per package");
634
635 SYSCTL_PROC(_machdep_cpu, OID_AUTO, thread_count,
636 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
637 (void *)offsetof(i386_cpu_info_t, thread_count),
638 sizeof(uint32_t),
639 i386_cpu_info, "I", "Number of enabled threads per package");
640
641 SYSCTL_NODE(_machdep_cpu, OID_AUTO, flex_ratio, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
642 "Flex ratio");
643
644 SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, desired,
645 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
646 0, 0,
647 cpu_flex_ratio_desired, "I", "Flex ratio desired (0 disabled)");
648
649 SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, min,
650 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
651 0, 0,
652 cpu_flex_ratio_min, "I", "Flex ratio min (efficiency)");
653
654 SYSCTL_PROC(_machdep_cpu_flex_ratio, OID_AUTO, max,
655 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_LOCKED,
656 0, 0,
657 cpu_flex_ratio_max, "I", "Flex ratio max (non-turbo)");
658
659 SYSCTL_PROC(_machdep_cpu, OID_AUTO, ucupdate,
660 CTLTYPE_INT | CTLFLAG_WR | CTLFLAG_LOCKED, 0, 0,
661 cpu_ucode_update, "S", "Microcode update interface");
662
663 uint64_t pmap_pv_hashlist_walks;
664 uint64_t pmap_pv_hashlist_cnts;
665 uint32_t pmap_pv_hashlist_max;
666 uint32_t pmap_kernel_text_ps = PAGE_SIZE;
667 extern uint32_t pv_hashed_kern_low_water_mark;
668
669 /*extern struct sysctl_oid_list sysctl__machdep_pmap_children;*/
670
671 SYSCTL_NODE(_machdep, OID_AUTO, pmap, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
672 "PMAP info");
673
674 SYSCTL_QUAD (_machdep_pmap, OID_AUTO, hashwalks, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_walks, "");
675 SYSCTL_QUAD (_machdep_pmap, OID_AUTO, hashcnts, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_cnts, "");
676 SYSCTL_INT (_machdep_pmap, OID_AUTO, hashmax, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_pv_hashlist_max, 0, "");
677 SYSCTL_INT (_machdep_pmap, OID_AUTO, kernel_text_ps, CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED, &pmap_kernel_text_ps, 0, "");
678 SYSCTL_INT (_machdep_pmap, OID_AUTO, kern_pv_reserve, CTLFLAG_RW | CTLFLAG_KERN | CTLFLAG_LOCKED, &pv_hashed_kern_low_water_mark, 0, "");
679
680 SYSCTL_NODE(_machdep, OID_AUTO, memmap, CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "physical memory map");
681
682 uint64_t firmware_Conventional_bytes = 0;
683 uint64_t firmware_RuntimeServices_bytes = 0;
684 uint64_t firmware_ACPIReclaim_bytes = 0;
685 uint64_t firmware_ACPINVS_bytes = 0;
686 uint64_t firmware_PalCode_bytes = 0;
687 uint64_t firmware_Reserved_bytes = 0;
688 uint64_t firmware_Unusable_bytes = 0;
689 uint64_t firmware_other_bytes = 0;
690
691 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Conventional, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_Conventional_bytes, "");
692 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, RuntimeServices, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_RuntimeServices_bytes, "");
693 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, ACPIReclaim, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_ACPIReclaim_bytes, "");
694 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, ACPINVS, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_ACPINVS_bytes, "");
695 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, PalCode, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_PalCode_bytes, "");
696 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Reserved, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_Reserved_bytes, "");
697 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Unusable, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_Unusable_bytes, "");
698 SYSCTL_QUAD(_machdep_memmap, OID_AUTO, Other, CTLFLAG_RD|CTLFLAG_LOCKED, &firmware_other_bytes, "");
699
700 SYSCTL_NODE(_machdep, OID_AUTO, tsc, CTLFLAG_RD|CTLFLAG_LOCKED, NULL, "Timestamp counter parameters");
701
702 SYSCTL_QUAD(_machdep_tsc, OID_AUTO, frequency, CTLFLAG_RD|CTLFLAG_LOCKED, &tscFreq, "");
703
704 SYSCTL_NODE(_machdep, OID_AUTO, misc, CTLFLAG_RW|CTLFLAG_LOCKED, 0,
705 "Miscellaneous x86 kernel parameters");
706
707 SYSCTL_PROC(_machdep_misc, OID_AUTO, panic_restart_timeout,
708 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_LOCKED,
709 0, 0,
710 panic_set_restart_timeout, "I", "Panic restart timeout in seconds");
711
712 SYSCTL_PROC(_machdep_misc, OID_AUTO, interrupt_latency_max, CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_LOCKED,
713 0, 0,
714 misc_interrupt_latency_max, "A", "Maximum Interrupt latency");