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