]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
8ad349bb | 2 | * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /*- | |
31 | * Copyright (c) 1982, 1986, 1989, 1993 | |
32 | * The Regents of the University of California. All rights reserved. | |
33 | * | |
34 | * This code is derived from software contributed to Berkeley by | |
35 | * Mike Karels at Berkeley Software Design, Inc. | |
36 | * | |
37 | * Quite extensively rewritten by Poul-Henning Kamp of the FreeBSD | |
38 | * project, to make these variables more userfriendly. | |
39 | * | |
40 | * Redistribution and use in source and binary forms, with or without | |
41 | * modification, are permitted provided that the following conditions | |
42 | * are met: | |
43 | * 1. Redistributions of source code must retain the above copyright | |
44 | * notice, this list of conditions and the following disclaimer. | |
45 | * 2. Redistributions in binary form must reproduce the above copyright | |
46 | * notice, this list of conditions and the following disclaimer in the | |
47 | * documentation and/or other materials provided with the distribution. | |
48 | * 3. All advertising materials mentioning features or use of this software | |
49 | * must display the following acknowledgement: | |
50 | * This product includes software developed by the University of | |
51 | * California, Berkeley and its contributors. | |
52 | * 4. Neither the name of the University nor the names of its contributors | |
53 | * may be used to endorse or promote products derived from this software | |
54 | * without specific prior written permission. | |
55 | * | |
56 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
57 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
58 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
59 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
60 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
61 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
62 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
63 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
64 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
65 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
66 | * SUCH DAMAGE. | |
67 | * | |
68 | * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 | |
69 | */ | |
70 | ||
71 | #include <sys/param.h> | |
72 | #include <sys/kernel.h> | |
73 | #include <sys/systm.h> | |
74 | #include <sys/sysctl.h> | |
91447636 | 75 | #include <sys/proc_internal.h> |
1c79356b A |
76 | #include <sys/unistd.h> |
77 | ||
78 | #if defined(SMP) | |
79 | #include <machine/smp.h> | |
80 | #endif | |
81 | ||
43866e37 A |
82 | #include <sys/param.h> /* XXX prune includes */ |
83 | #include <sys/systm.h> | |
84 | #include <sys/kernel.h> | |
85 | #include <sys/malloc.h> | |
86 | #include <sys/proc.h> | |
91447636 | 87 | #include <sys/file_internal.h> |
43866e37 A |
88 | #include <sys/vnode.h> |
89 | #include <sys/unistd.h> | |
43866e37 A |
90 | #include <sys/ioctl.h> |
91 | #include <sys/namei.h> | |
92 | #include <sys/tty.h> | |
93 | #include <sys/disklabel.h> | |
94 | #include <sys/vm.h> | |
95 | #include <sys/sysctl.h> | |
96 | #include <sys/user.h> | |
97 | #include <mach/machine.h> | |
98 | #include <mach/mach_types.h> | |
99 | #include <mach/vm_param.h> | |
100 | #include <kern/task.h> | |
101 | #include <vm/vm_kern.h> | |
102 | #include <mach/host_info.h> | |
103 | ||
104 | extern vm_map_t bsd_pageable_map; | |
105 | ||
91447636 | 106 | #include <sys/mount_internal.h> |
43866e37 A |
107 | #include <sys/kdebug.h> |
108 | ||
109 | #include <IOKit/IOPlatformExpert.h> | |
110 | #include <pexpert/pexpert.h> | |
111 | ||
112 | #include <machine/machine_routines.h> | |
113 | #include <machine/cpu_capabilities.h> | |
114 | ||
8ad349bb | 115 | static int cputype, cpusubtype, cputhreadtype; |
43866e37 | 116 | |
1c79356b A |
117 | SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0, |
118 | "Sysctl internal magic"); | |
119 | SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, | |
120 | "High kernel, proc, limits &c"); | |
121 | SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, | |
122 | "Virtual memory"); | |
123 | SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, | |
124 | "File system"); | |
125 | SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, | |
126 | "Network, (see socket.h)"); | |
127 | SYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW, 0, | |
128 | "Debugging"); | |
129 | SYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW, 0, | |
130 | "hardware"); | |
131 | SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0, | |
132 | "machine dependent"); | |
133 | SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0, | |
134 | "user-level"); | |
135 | ||
43866e37 A |
136 | #define SYSCTL_RETURN(r, x) SYSCTL_OUT(r, &x, sizeof(x)) |
137 | ||
138 | /****************************************************************************** | |
139 | * hw.* MIB | |
140 | */ | |
141 | ||
142 | #define CTLHW_RETQUAD (1 << 31) | |
91447636 A |
143 | #define CTLHW_LOCAL (1 << 30) |
144 | ||
145 | #define HW_LOCAL_CPUTHREADTYPE (1 | CTLHW_LOCAL) | |
146 | #define HW_LOCAL_PHYSICALCPU (2 | CTLHW_LOCAL) | |
147 | #define HW_LOCAL_PHYSICALCPUMAX (3 | CTLHW_LOCAL) | |
148 | #define HW_LOCAL_LOGICALCPU (4 | CTLHW_LOCAL) | |
149 | #define HW_LOCAL_LOGICALCPUMAX (5 | CTLHW_LOCAL) | |
150 | ||
43866e37 A |
151 | |
152 | /* | |
153 | * Supporting some variables requires us to do "real" work. We | |
154 | * gather some of that here. | |
155 | */ | |
156 | static int | |
157 | sysctl_hw_generic SYSCTL_HANDLER_ARGS | |
158 | { | |
159 | char dummy[65]; | |
160 | int epochTemp; | |
161 | extern int vm_page_wire_count; | |
162 | ml_cpu_info_t cpu_info; | |
163 | int val, doquad; | |
164 | long long qval; | |
91447636 A |
165 | host_basic_info_data_t hinfo; |
166 | kern_return_t kret; | |
167 | int count = HOST_BASIC_INFO_COUNT; | |
43866e37 A |
168 | |
169 | /* | |
170 | * Test and mask off the 'return quad' flag. | |
171 | * Note that only some things here support it. | |
172 | */ | |
173 | doquad = arg2 & CTLHW_RETQUAD; | |
174 | arg2 &= ~CTLHW_RETQUAD; | |
175 | ||
176 | ml_cpu_get_info(&cpu_info); | |
177 | ||
91447636 A |
178 | #define BSD_HOST 1 |
179 | kret = host_info(BSD_HOST, HOST_BASIC_INFO, &hinfo, &count); | |
180 | ||
43866e37 A |
181 | /* |
182 | * Handle various OIDs. | |
183 | * | |
184 | * OIDs that can return int or quad set val and qval and then break. | |
185 | * Errors and int-only values return inline. | |
186 | */ | |
187 | switch (arg2) { | |
188 | case HW_NCPU: | |
91447636 A |
189 | if (kret == KERN_SUCCESS) { |
190 | return(SYSCTL_RETURN(req, hinfo.max_cpus)); | |
191 | } else { | |
192 | return(EINVAL); | |
43866e37 A |
193 | } |
194 | case HW_AVAILCPU: | |
91447636 A |
195 | if (kret == KERN_SUCCESS) { |
196 | return(SYSCTL_RETURN(req, hinfo.avail_cpus)); | |
197 | } else { | |
198 | return(EINVAL); | |
199 | } | |
200 | case HW_LOCAL_PHYSICALCPU: | |
201 | if (kret == KERN_SUCCESS) { | |
202 | return(SYSCTL_RETURN(req, hinfo.physical_cpu)); | |
203 | } else { | |
204 | return(EINVAL); | |
205 | } | |
206 | case HW_LOCAL_PHYSICALCPUMAX: | |
207 | if (kret == KERN_SUCCESS) { | |
208 | return(SYSCTL_RETURN(req, hinfo.physical_cpu_max)); | |
209 | } else { | |
210 | return(EINVAL); | |
211 | } | |
212 | case HW_LOCAL_LOGICALCPU: | |
213 | if (kret == KERN_SUCCESS) { | |
214 | return(SYSCTL_RETURN(req, hinfo.logical_cpu)); | |
215 | } else { | |
216 | return(EINVAL); | |
217 | } | |
218 | case HW_LOCAL_LOGICALCPUMAX: | |
219 | if (kret == KERN_SUCCESS) { | |
220 | return(SYSCTL_RETURN(req, hinfo.logical_cpu_max)); | |
221 | } else { | |
222 | return(EINVAL); | |
43866e37 A |
223 | } |
224 | case HW_CACHELINE: | |
225 | val = cpu_info.cache_line_size; | |
226 | qval = (long long)val; | |
227 | break; | |
228 | case HW_L1ICACHESIZE: | |
229 | val = cpu_info.l1_icache_size; | |
230 | qval = (long long)val; | |
231 | break; | |
232 | case HW_L1DCACHESIZE: | |
233 | val = cpu_info.l1_dcache_size; | |
234 | qval = (long long)val; | |
235 | break; | |
236 | case HW_L2CACHESIZE: | |
237 | if (cpu_info.l2_cache_size == 0xFFFFFFFF) | |
238 | return(EINVAL); | |
239 | val = cpu_info.l2_cache_size; | |
240 | qval = (long long)val; | |
241 | break; | |
242 | case HW_L3CACHESIZE: | |
243 | if (cpu_info.l3_cache_size == 0xFFFFFFFF) | |
244 | return(EINVAL); | |
245 | val = cpu_info.l3_cache_size; | |
246 | qval = (long long)val; | |
247 | break; | |
248 | ||
249 | /* | |
250 | * Deprecated variables. We still support these for | |
251 | * backwards compatibility purposes only. | |
252 | */ | |
253 | case HW_MACHINE: | |
254 | bzero(dummy, sizeof(dummy)); | |
255 | if(!PEGetMachineName(dummy,64)) | |
256 | return(EINVAL); | |
257 | dummy[64] = 0; | |
258 | return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1)); | |
259 | case HW_MODEL: | |
260 | bzero(dummy, sizeof(dummy)); | |
261 | if(!PEGetModelName(dummy,64)) | |
262 | return(EINVAL); | |
263 | dummy[64] = 0; | |
264 | return(SYSCTL_OUT(req, dummy, strlen(dummy) + 1)); | |
265 | case HW_USERMEM: | |
266 | { | |
267 | int usermem = mem_size - vm_page_wire_count * page_size; | |
268 | ||
269 | return(SYSCTL_RETURN(req, usermem)); | |
270 | } | |
271 | case HW_EPOCH: | |
272 | epochTemp = PEGetPlatformEpoch(); | |
273 | if (epochTemp == -1) | |
274 | return(EINVAL); | |
275 | return(SYSCTL_RETURN(req, epochTemp)); | |
8ad349bb A |
276 | case HW_VECTORUNIT: |
277 | return(SYSCTL_RETURN(req, cpu_info.vector_unit)); | |
43866e37 A |
278 | case HW_L2SETTINGS: |
279 | if (cpu_info.l2_cache_size == 0xFFFFFFFF) | |
280 | return(EINVAL); | |
281 | return(SYSCTL_RETURN(req, cpu_info.l2_settings)); | |
282 | case HW_L3SETTINGS: | |
283 | if (cpu_info.l3_cache_size == 0xFFFFFFFF) | |
284 | return(EINVAL); | |
285 | return(SYSCTL_RETURN(req, cpu_info.l3_settings)); | |
286 | default: | |
287 | return(ENOTSUP); | |
288 | } | |
289 | /* | |
290 | * Callers may come to us with either int or quad buffers. | |
291 | */ | |
292 | if (doquad) { | |
293 | return(SYSCTL_RETURN(req, qval)); | |
294 | } | |
295 | return(SYSCTL_RETURN(req, val)); | |
296 | } | |
297 | ||
298 | /* | |
299 | * hw.* MIB variables. | |
300 | */ | |
91447636 | 301 | SYSCTL_PROC (_hw, HW_NCPU, ncpu, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_NCPU, sysctl_hw_generic, "I", ""); |
43866e37 | 302 | SYSCTL_PROC (_hw, HW_AVAILCPU, activecpu, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_AVAILCPU, sysctl_hw_generic, "I", ""); |
91447636 A |
303 | SYSCTL_PROC (_hw, OID_AUTO, physicalcpu, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_LOCAL_PHYSICALCPU, sysctl_hw_generic, "I", ""); |
304 | SYSCTL_PROC (_hw, OID_AUTO, physicalcpu_max, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_LOCAL_PHYSICALCPUMAX, sysctl_hw_generic, "I", ""); | |
305 | SYSCTL_PROC (_hw, OID_AUTO, logicalcpu, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_LOCAL_LOGICALCPU, sysctl_hw_generic, "I", ""); | |
306 | SYSCTL_PROC (_hw, OID_AUTO, logicalcpu_max, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_LOCAL_LOGICALCPUMAX, sysctl_hw_generic, "I", ""); | |
43866e37 | 307 | SYSCTL_INT (_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD | CTLFLAG_KERN, NULL, BYTE_ORDER, ""); |
91447636 A |
308 | SYSCTL_INT (_hw, OID_AUTO, cputype, CTLFLAG_RD | CTLFLAG_KERN, &cputype, 0, ""); |
309 | SYSCTL_INT (_hw, OID_AUTO, cpusubtype, CTLFLAG_RD | CTLFLAG_KERN, &cpusubtype, 0, ""); | |
43866e37 A |
310 | SYSCTL_INT2QUAD(_hw, OID_AUTO, pagesize, CTLFLAG_RD | CTLFLAG_KERN, &page_size, ""); |
311 | SYSCTL_QUAD (_hw, OID_AUTO, busfrequency, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.bus_frequency_hz, ""); | |
312 | SYSCTL_QUAD (_hw, OID_AUTO, busfrequency_min, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.bus_frequency_min_hz, ""); | |
313 | SYSCTL_QUAD (_hw, OID_AUTO, busfrequency_max, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.bus_frequency_max_hz, ""); | |
314 | SYSCTL_QUAD (_hw, OID_AUTO, cpufrequency, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.cpu_frequency_hz, ""); | |
315 | SYSCTL_QUAD (_hw, OID_AUTO, cpufrequency_min, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.cpu_frequency_min_hz, ""); | |
316 | SYSCTL_QUAD (_hw, OID_AUTO, cpufrequency_max, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.cpu_frequency_max_hz, ""); | |
317 | SYSCTL_PROC (_hw, OID_AUTO, cachelinesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_CACHELINE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", ""); | |
318 | SYSCTL_PROC (_hw, OID_AUTO, l1icachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L1ICACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", ""); | |
319 | SYSCTL_PROC (_hw, OID_AUTO, l1dcachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L1DCACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", ""); | |
320 | SYSCTL_PROC (_hw, OID_AUTO, l2cachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L2CACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", ""); | |
321 | SYSCTL_PROC (_hw, OID_AUTO, l3cachesize, CTLTYPE_QUAD | CTLFLAG_RD | CTLFLAG_KERN, 0, HW_L3CACHESIZE | CTLHW_RETQUAD, sysctl_hw_generic, "Q", ""); | |
322 | SYSCTL_INT2QUAD(_hw, OID_AUTO, tbfrequency, CTLFLAG_RD | CTLFLAG_KERN, &gPEClockFrequencyInfo.timebase_frequency_hz, ""); | |
323 | SYSCTL_QUAD (_hw, HW_MEMSIZE, memsize, CTLFLAG_RD | CTLFLAG_KERN, &max_mem, ""); | |
324 | ||
325 | /* | |
326 | * Optional features can register nodes below hw.optional. | |
327 | * | |
328 | * If the feature is not present, the node should either not be registered, | |
329 | * or it should return -1. If the feature is present, the node should return | |
330 | * 0. If the feature is present and its use is advised, the node should | |
331 | * return 1. | |
332 | */ | |
333 | SYSCTL_NODE(_hw, OID_AUTO, optional, CTLFLAG_RW, NULL, "optional features"); | |
334 | ||
335 | SYSCTL_INT(_hw_optional, OID_AUTO, floatingpoint, CTLFLAG_RD | CTLFLAG_KERN, 0, 1, ""); /* always set */ | |
336 | ||
43866e37 A |
337 | /* |
338 | * Deprecated variables. These are supported for backwards compatibility | |
339 | * purposes only. The MASKED flag requests that the variables not be | |
340 | * printed by sysctl(8) and similar utilities. | |
341 | * | |
342 | * The variables named *_compat here are int-sized versions of variables | |
343 | * that are now exported as quads. The int-sized versions are normally | |
344 | * looked up only by number, wheras the quad-sized versions should be | |
345 | * looked up by name. | |
346 | * | |
347 | * The *_compat nodes are *NOT* visible within the kernel. | |
348 | */ | |
349 | SYSCTL_INT (_hw, HW_PAGESIZE, pagesize_compat, CTLFLAG_RD | CTLFLAG_MASKED, &page_size, 0, ""); | |
350 | SYSCTL_INT (_hw, HW_BUS_FREQ, busfrequency_compat, CTLFLAG_RD | CTLFLAG_MASKED, &gPEClockFrequencyInfo.bus_clock_rate_hz, 0, ""); | |
351 | SYSCTL_INT (_hw, HW_CPU_FREQ, cpufrequency_compat, CTLFLAG_RD | CTLFLAG_MASKED, &gPEClockFrequencyInfo.cpu_clock_rate_hz, 0, ""); | |
352 | SYSCTL_PROC(_hw, HW_CACHELINE, cachelinesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_CACHELINE, sysctl_hw_generic, "I", ""); | |
353 | SYSCTL_PROC(_hw, HW_L1ICACHESIZE, l1icachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L1ICACHESIZE, sysctl_hw_generic, "I", ""); | |
354 | SYSCTL_PROC(_hw, HW_L1DCACHESIZE, l1dcachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L1DCACHESIZE, sysctl_hw_generic, "I", ""); | |
355 | SYSCTL_PROC(_hw, HW_L2CACHESIZE, l2cachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L2CACHESIZE, sysctl_hw_generic, "I", ""); | |
356 | SYSCTL_PROC(_hw, HW_L3CACHESIZE, l3cachesize_compat, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L3CACHESIZE, sysctl_hw_generic, "I", ""); | |
357 | SYSCTL_INT (_hw, HW_TB_FREQ, tbfrequency_compat, CTLFLAG_RD | CTLFLAG_MASKED, &gPEClockFrequencyInfo.timebase_frequency_hz, 0, ""); | |
358 | SYSCTL_PROC(_hw, HW_MACHINE, machine, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_MACHINE, sysctl_hw_generic, "A", ""); | |
359 | SYSCTL_PROC(_hw, HW_MODEL, model, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_MODEL, sysctl_hw_generic, "A", ""); | |
55e303ae | 360 | SYSCTL_UINT(_hw, HW_PHYSMEM, physmem, CTLFLAG_RD | CTLFLAG_MASKED, &mem_size, 0, ""); |
43866e37 A |
361 | SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_USERMEM, sysctl_hw_generic, "I", ""); |
362 | SYSCTL_PROC(_hw, HW_EPOCH, epoch, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_EPOCH, sysctl_hw_generic, "I", ""); | |
363 | SYSCTL_PROC(_hw, HW_VECTORUNIT, vectorunit, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_VECTORUNIT, sysctl_hw_generic, "I", ""); | |
364 | SYSCTL_PROC(_hw, HW_L2SETTINGS, l2settings, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L2SETTINGS, sysctl_hw_generic, "I", ""); | |
365 | SYSCTL_PROC(_hw, HW_L3SETTINGS, l3settings, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MASKED, 0, HW_L3SETTINGS, sysctl_hw_generic, "I", ""); | |
366 | ||
367 | /****************************************************************************** | |
368 | * Generic MIB initialisation. | |
369 | * | |
370 | * This is a hack, and should be replaced with SYSINITs | |
371 | * at some point. | |
372 | */ | |
373 | void | |
374 | sysctl_mib_init(void) | |
375 | { | |
91447636 A |
376 | cputype = cpu_type(); |
377 | cpusubtype = cpu_subtype(); | |
378 | cputhreadtype = cpu_threadtype(); | |
379 | ||
43866e37 A |
380 | /* |
381 | * Populate the optional portion of the hw.* MIB. | |
382 | * | |
383 | * XXX This could be broken out into parts of the code | |
384 | * that actually directly relate to the functions in | |
385 | * question. | |
386 | */ | |
91447636 A |
387 | |
388 | if (cputhreadtype != CPU_THREADTYPE_NONE) { | |
389 | static SYSCTL_INT(_hw, OID_AUTO, cputhreadtype, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &cputhreadtype, 0, ""); | |
390 | sysctl_register_oid(&sysctl__hw_cputhreadtype); | |
391 | } | |
392 | ||
43866e37 A |
393 | #ifdef __ppc__ |
394 | { | |
395 | static int altivec_flag = -1; | |
396 | static SYSCTL_INT(_hw_optional, OID_AUTO, altivec, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &altivec_flag, 0, ""); | |
397 | ||
398 | if (_cpu_capabilities & kHasAltivec) { | |
399 | altivec_flag = 1; | |
400 | sysctl_register_oid(&sysctl__hw_optional_altivec); | |
401 | } | |
402 | } | |
403 | { | |
404 | static int graphicsops_flag = -1; | |
405 | static SYSCTL_INT(_hw_optional, OID_AUTO, graphicsops, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &graphicsops_flag, 0, ""); | |
406 | ||
407 | if (_cpu_capabilities & kHasGraphicsOps) { | |
408 | graphicsops_flag = 1; | |
409 | sysctl_register_oid(&sysctl__hw_optional_graphicsops); | |
410 | } | |
411 | } | |
412 | { | |
413 | static int x64bitops_flag = -1; | |
414 | static SYSCTL_INT(_hw_optional, OID_AUTO, 64bitops, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &x64bitops_flag, 0, ""); | |
415 | ||
416 | if (_cpu_capabilities & k64Bit) { | |
417 | x64bitops_flag = 1; | |
418 | sysctl_register_oid(&sysctl__hw_optional_64bitops); | |
419 | } | |
420 | } | |
421 | { | |
422 | static int fsqrt_flag = -1; | |
423 | static SYSCTL_INT(_hw_optional, OID_AUTO, fsqrt, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &fsqrt_flag, 0, ""); | |
424 | ||
425 | if (_cpu_capabilities & kHasFsqrt) { | |
426 | fsqrt_flag = 1; | |
427 | sysctl_register_oid(&sysctl__hw_optional_fsqrt); | |
428 | } | |
429 | } | |
430 | { | |
431 | static int stfiwx_flag = -1; | |
432 | static SYSCTL_INT(_hw_optional, OID_AUTO, stfiwx, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &stfiwx_flag, 0, ""); | |
433 | ||
434 | if (_cpu_capabilities & kHasStfiwx) { | |
435 | stfiwx_flag = 1; | |
436 | sysctl_register_oid(&sysctl__hw_optional_stfiwx); | |
437 | } | |
438 | } | |
439 | { | |
440 | static int dcba_flag = -1; | |
441 | static SYSCTL_INT(_hw_optional, OID_AUTO, dcba, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &dcba_flag, 0, ""); | |
442 | ||
443 | if (_cpu_capabilities & kDcbaAvailable) | |
444 | dcba_flag = 0; | |
445 | if (_cpu_capabilities & kDcbaRecommended) | |
446 | dcba_flag = 1; | |
447 | if (dcba_flag >= 0) | |
448 | sysctl_register_oid(&sysctl__hw_optional_dcba); | |
449 | } | |
450 | { | |
451 | static int datastreams_flag = -1; | |
452 | static SYSCTL_INT(_hw_optional, OID_AUTO, datastreams, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &datastreams_flag, 0, ""); | |
453 | ||
454 | if (_cpu_capabilities & kDataStreamsAvailable) | |
455 | datastreams_flag = 0; | |
456 | if (_cpu_capabilities & kDataStreamsRecommended) | |
457 | datastreams_flag = 1; | |
458 | if (datastreams_flag >= 0) | |
459 | sysctl_register_oid(&sysctl__hw_optional_datastreams); | |
460 | } | |
461 | { | |
462 | static int dcbtstreams_flag = -1; | |
463 | static SYSCTL_INT(_hw_optional, OID_AUTO, dcbtstreams, CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN, &dcbtstreams_flag, 0, ""); | |
464 | ||
465 | if (_cpu_capabilities & kDcbtStreamsAvailable) | |
466 | dcbtstreams_flag = 0; | |
467 | if (_cpu_capabilities & kDcbtStreamsRecommended) | |
468 | dcbtstreams_flag = 1; | |
469 | if (dcbtstreams_flag >= 0) | |
470 | sysctl_register_oid(&sysctl__hw_optional_dcbtstreams); | |
471 | } | |
8ad349bb | 472 | #else |
43866e37 A |
473 | # warning we do not support this platform yet |
474 | #endif /* __ppc__ */ | |
475 | ||
476 | ||
477 | } |