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