]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. |
3 | * | |
8f6c56a5 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
8f6c56a5 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 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 | |
8ad349bb | 24 | * limitations under the License. |
8f6c56a5 A |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * Copyright (c) 1989, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * | |
33 | * This code is derived from software contributed to Berkeley by | |
34 | * Mike Karels at Berkeley Software Design, Inc. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 | |
65 | */ | |
66 | ||
67 | #ifndef _SYS_SYSCTL_H_ | |
68 | #define _SYS_SYSCTL_H_ | |
69 | ||
70 | /* | |
71 | * These are for the eproc structure defined below. | |
72 | */ | |
91447636 A |
73 | #include <sys/cdefs.h> |
74 | ||
9bccf70c | 75 | #include <sys/appleapiopts.h> |
1c79356b A |
76 | #ifndef KERNEL |
77 | #include <sys/time.h> | |
78 | #include <sys/ucred.h> | |
91447636 A |
79 | #else |
80 | #include <libkern/sysctl.h> | |
1c79356b | 81 | #endif |
1c79356b | 82 | #include <sys/proc.h> |
91447636 A |
83 | #include <sys/vm.h> |
84 | ||
85 | #ifdef BSD_KERNEL_PRIVATE | |
1c79356b | 86 | #include <sys/linker_set.h> |
91447636 | 87 | #endif |
1c79356b A |
88 | |
89 | /* | |
90 | * Definitions for sysctl call. The sysctl call uses a hierarchical name | |
91 | * for objects that can be examined or modified. The name is expressed as | |
92 | * a sequence of integers. Like a file path name, the meaning of each | |
93 | * component depends on its place in the hierarchy. The top-level and kern | |
94 | * identifiers are defined here, and other identifiers are defined in the | |
95 | * respective subsystem header files. | |
96 | */ | |
97 | ||
98 | #define CTL_MAXNAME 12 /* largest number of components supported */ | |
99 | ||
100 | /* | |
101 | * Each subsystem defined by sysctl defines a list of variables | |
102 | * for that subsystem. Each name is either a node with further | |
103 | * levels defined below it, or it is a leaf of some particular | |
104 | * type given below. Each sysctl level defines a set of name/type | |
105 | * pairs to be used by sysctl(1) in manipulating the subsystem. | |
106 | */ | |
107 | struct ctlname { | |
108 | char *ctl_name; /* subsystem name */ | |
109 | int ctl_type; /* type of name */ | |
110 | }; | |
111 | ||
112 | #define CTLTYPE 0xf /* Mask for the type */ | |
113 | #define CTLTYPE_NODE 1 /* name is a node */ | |
114 | #define CTLTYPE_INT 2 /* name describes an integer */ | |
115 | #define CTLTYPE_STRING 3 /* name describes a string */ | |
116 | #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ | |
117 | #define CTLTYPE_OPAQUE 5 /* name describes a structure */ | |
118 | #define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ | |
119 | ||
120 | #define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ | |
121 | #define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ | |
122 | #define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) | |
123 | #define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */ | |
124 | #define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ | |
125 | #define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ | |
43866e37 A |
126 | #define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */ |
127 | #define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */ | |
128 | #define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */ | |
1c79356b A |
129 | |
130 | /* | |
131 | * USE THIS instead of a hardwired number from the categories below | |
132 | * to get dynamically assigned sysctl entries using the linker-set | |
133 | * technology. This is the way nearly all new sysctl variables should | |
134 | * be implemented. | |
135 | * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); | |
136 | */ | |
137 | #define OID_AUTO (-1) | |
138 | ||
139 | #ifdef KERNEL | |
140 | #define SYSCTL_HANDLER_ARGS (struct sysctl_oid *oidp, void *arg1, int arg2, \ | |
141 | struct sysctl_req *req) | |
142 | ||
143 | /* | |
144 | * This describes the access space for a sysctl request. This is needed | |
145 | * so that we can use the interface from the kernel or from user-space. | |
146 | */ | |
147 | struct sysctl_req { | |
148 | struct proc *p; | |
91447636 A |
149 | int lock; |
150 | user_addr_t oldptr; | |
1c79356b A |
151 | size_t oldlen; |
152 | size_t oldidx; | |
91447636 A |
153 | int (*oldfunc)(struct sysctl_req *, const void *, size_t); |
154 | user_addr_t newptr; | |
1c79356b A |
155 | size_t newlen; |
156 | size_t newidx; | |
91447636 | 157 | int (*newfunc)(struct sysctl_req *, void *, size_t); |
1c79356b A |
158 | }; |
159 | ||
160 | SLIST_HEAD(sysctl_oid_list, sysctl_oid); | |
161 | ||
162 | /* | |
163 | * This describes one "oid" in the MIB tree. Potentially more nodes can | |
164 | * be hidden behind it, expanded by the handler. | |
165 | */ | |
166 | struct sysctl_oid { | |
167 | struct sysctl_oid_list *oid_parent; | |
168 | SLIST_ENTRY(sysctl_oid) oid_link; | |
169 | int oid_number; | |
170 | int oid_kind; | |
171 | void *oid_arg1; | |
172 | int oid_arg2; | |
173 | const char *oid_name; | |
174 | int (*oid_handler) SYSCTL_HANDLER_ARGS; | |
175 | const char *oid_fmt; | |
176 | }; | |
177 | ||
178 | #define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) | |
179 | #define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) | |
180 | ||
91447636 A |
181 | __BEGIN_DECLS |
182 | ||
1c79356b A |
183 | int sysctl_handle_int SYSCTL_HANDLER_ARGS; |
184 | int sysctl_handle_long SYSCTL_HANDLER_ARGS; | |
43866e37 A |
185 | int sysctl_handle_quad SYSCTL_HANDLER_ARGS; |
186 | int sysctl_handle_int2quad SYSCTL_HANDLER_ARGS; | |
187 | /*int sysctl_handle_intptr SYSCTL_HANDLER_ARGS; XXX not implemented */ | |
1c79356b A |
188 | int sysctl_handle_string SYSCTL_HANDLER_ARGS; |
189 | int sysctl_handle_opaque SYSCTL_HANDLER_ARGS; | |
190 | ||
191 | /* | |
192 | * These functions are used to add/remove an oid from the mib. | |
193 | */ | |
194 | void sysctl_register_oid(struct sysctl_oid *oidp); | |
195 | void sysctl_unregister_oid(struct sysctl_oid *oidp); | |
196 | ||
91447636 A |
197 | __END_DECLS |
198 | ||
1c79356b A |
199 | /* Declare an oid to allow child oids to be added to it. */ |
200 | #define SYSCTL_DECL(name) \ | |
201 | extern struct sysctl_oid_list sysctl_##name##_children | |
202 | ||
203 | /* This constructs a "raw" MIB oid. */ | |
204 | #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ | |
9bccf70c | 205 | struct sysctl_oid sysctl_##parent##_##name = { \ |
1c79356b A |
206 | &sysctl_##parent##_children, { 0 }, \ |
207 | nbr, kind, a1, a2, #name, handler, fmt }; | |
208 | ||
209 | ||
210 | /* This constructs a node from which other oids can hang. */ | |
211 | #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ | |
212 | struct sysctl_oid_list sysctl_##parent##_##name##_children; \ | |
213 | SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|access, \ | |
214 | (void*)&sysctl_##parent##_##name##_children, 0, handler, \ | |
215 | "N", descr); | |
216 | ||
217 | /* Oid for a string. len can be 0 to indicate '\0' termination. */ | |
218 | #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ | |
219 | SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|access, \ | |
220 | arg, len, sysctl_handle_string, "A", descr) | |
221 | ||
222 | /* Oid for an int. If ptr is NULL, val is returned. */ | |
223 | #define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ | |
224 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
225 | ptr, val, sysctl_handle_int, "I", descr) | |
226 | ||
55e303ae A |
227 | /* Oid for an unsigned int. If ptr is NULL, val is returned. */ |
228 | #define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ | |
229 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
230 | ptr, val, sysctl_handle_int, "IU", descr) | |
231 | ||
1c79356b A |
232 | /* Oid for a long. The pointer must be non NULL. */ |
233 | #define SYSCTL_LONG(parent, nbr, name, access, ptr, descr) \ | |
234 | SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ | |
235 | ptr, 0, sysctl_handle_long, "L", descr) | |
236 | ||
43866e37 A |
237 | /* Oid for a quad. The pointer must be non NULL. */ |
238 | #define SYSCTL_QUAD(parent, nbr, name, access, ptr, descr) \ | |
239 | SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \ | |
240 | ptr, 0, sysctl_handle_quad, "Q", descr) | |
241 | ||
242 | /* Oid for a int returned as quad. The pointer must be non NULL. */ | |
243 | #define SYSCTL_INT2QUAD(parent, nbr, name, access, ptr, descr) \ | |
244 | SYSCTL_OID(parent, nbr, name, CTLTYPE_QUAD|access, \ | |
245 | ptr, 0, sysctl_handle_int2quad, "Q", descr) | |
246 | ||
1c79356b A |
247 | /* Oid for an opaque object. Specified by a pointer and a length. */ |
248 | #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ | |
249 | SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \ | |
250 | ptr, len, sysctl_handle_opaque, fmt, descr) | |
251 | ||
252 | /* Oid for a struct. Specified by a pointer and a type. */ | |
253 | #define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ | |
254 | SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|access, \ | |
255 | ptr, sizeof(struct type), sysctl_handle_opaque, \ | |
256 | "S," #type, descr) | |
257 | ||
258 | /* Oid for a procedure. Specified by a pointer and an arg. */ | |
259 | #define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ | |
260 | SYSCTL_OID(parent, nbr, name, access, \ | |
261 | ptr, arg, handler, fmt, descr) | |
91447636 A |
262 | |
263 | ||
264 | extern struct sysctl_oid_list sysctl__children; | |
265 | SYSCTL_DECL(_kern); | |
266 | SYSCTL_DECL(_sysctl); | |
267 | SYSCTL_DECL(_vm); | |
268 | SYSCTL_DECL(_vfs); | |
269 | SYSCTL_DECL(_net); | |
270 | SYSCTL_DECL(_debug); | |
271 | SYSCTL_DECL(_hw); | |
272 | SYSCTL_DECL(_machdep); | |
273 | SYSCTL_DECL(_user); | |
274 | ||
1c79356b A |
275 | #endif /* KERNEL */ |
276 | ||
91447636 A |
277 | #ifdef XNU_KERNEL_PRIVATE |
278 | #define SYSCTL_DEF_ENABLED | |
279 | #else | |
280 | #ifndef KERNEL | |
281 | #define SYSCTL_DEF_ENABLED | |
282 | #endif | |
283 | #endif | |
284 | ||
285 | #ifdef SYSCTL_DEF_ENABLED | |
1c79356b A |
286 | /* |
287 | * Top-level identifiers | |
288 | */ | |
289 | #define CTL_UNSPEC 0 /* unused */ | |
290 | #define CTL_KERN 1 /* "high kernel": proc, limits */ | |
291 | #define CTL_VM 2 /* virtual memory */ | |
292 | #define CTL_VFS 3 /* file system, mount type is next */ | |
293 | #define CTL_NET 4 /* network, see socket.h */ | |
294 | #define CTL_DEBUG 5 /* debugging parameters */ | |
295 | #define CTL_HW 6 /* generic cpu/io */ | |
296 | #define CTL_MACHDEP 7 /* machine dependent */ | |
297 | #define CTL_USER 8 /* user-level */ | |
298 | #define CTL_MAXID 9 /* number of valid top-level ids */ | |
299 | ||
300 | #define CTL_NAMES { \ | |
301 | { 0, 0 }, \ | |
302 | { "kern", CTLTYPE_NODE }, \ | |
303 | { "vm", CTLTYPE_NODE }, \ | |
304 | { "vfs", CTLTYPE_NODE }, \ | |
305 | { "net", CTLTYPE_NODE }, \ | |
306 | { "debug", CTLTYPE_NODE }, \ | |
307 | { "hw", CTLTYPE_NODE }, \ | |
308 | { "machdep", CTLTYPE_NODE }, \ | |
309 | { "user", CTLTYPE_NODE }, \ | |
310 | } | |
311 | ||
312 | /* | |
313 | * CTL_KERN identifiers | |
314 | */ | |
315 | #define KERN_OSTYPE 1 /* string: system version */ | |
316 | #define KERN_OSRELEASE 2 /* string: system release */ | |
317 | #define KERN_OSREV 3 /* int: system revision */ | |
318 | #define KERN_VERSION 4 /* string: compile time info */ | |
319 | #define KERN_MAXVNODES 5 /* int: max vnodes */ | |
320 | #define KERN_MAXPROC 6 /* int: max processes */ | |
321 | #define KERN_MAXFILES 7 /* int: max open files */ | |
322 | #define KERN_ARGMAX 8 /* int: max arguments to exec */ | |
323 | #define KERN_SECURELVL 9 /* int: system security level */ | |
324 | #define KERN_HOSTNAME 10 /* string: hostname */ | |
325 | #define KERN_HOSTID 11 /* int: host identifier */ | |
326 | #define KERN_CLOCKRATE 12 /* struct: struct clockrate */ | |
327 | #define KERN_VNODE 13 /* struct: vnode structures */ | |
328 | #define KERN_PROC 14 /* struct: process entries */ | |
329 | #define KERN_FILE 15 /* struct: file entries */ | |
330 | #define KERN_PROF 16 /* node: kernel profiling info */ | |
331 | #define KERN_POSIX1 17 /* int: POSIX.1 version */ | |
332 | #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ | |
333 | #define KERN_JOB_CONTROL 19 /* int: is job control available */ | |
334 | #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ | |
335 | #define KERN_BOOTTIME 21 /* struct: time kernel was booted */ | |
336 | #define KERN_NISDOMAINNAME 22 /* string: YP domain name */ | |
337 | #define KERN_DOMAINNAME KERN_NISDOMAINNAME | |
338 | #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ | |
55e303ae | 339 | #define KERN_KDEBUG 24 /* int: kernel trace points */ |
1c79356b A |
340 | #define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */ |
341 | #define KERN_OSRELDATE 26 /* int: OS release date */ | |
342 | #define KERN_NTP_PLL 27 /* node: NTP PLL control */ | |
343 | #define KERN_BOOTFILE 28 /* string: name of booted kernel */ | |
344 | #define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */ | |
345 | #define KERN_MAXPROCPERUID 30 /* int: max processes per uid */ | |
346 | #define KERN_DUMPDEV 31 /* dev_t: device to dump on */ | |
91447636 A |
347 | #define KERN_IPC 32 /* node: anything related to IPC */ |
348 | #define KERN_DUMMY 33 /* unused */ | |
349 | #define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */ | |
350 | #define KERN_USRSTACK32 35 /* int: address of USRSTACK */ | |
351 | #define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */ | |
1c79356b A |
352 | #define KERN_SYMFILE 37 /* string: kernel symbol filename */ |
353 | #define KERN_PROCARGS 38 | |
9bccf70c A |
354 | #define KERN_PCSAMPLES 39 /* node: pc sampling */ |
355 | #define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */ | |
356 | #define KERN_PANICINFO 41 /* node: panic UI information */ | |
91447636 | 357 | #define KERN_SYSV 42 /* node: System V IPC information */ |
55e303ae | 358 | #define KERN_AFFINITY 43 /* xxx */ |
21362eb3 A |
359 | #define KERN_CLASSIC 44 /* xxx */ |
360 | #define KERN_CLASSICHANDLER 45 /* xxx */ | |
91447636 | 361 | #define KERN_AIOMAX 46 /* int: max aio requests */ |
55e303ae A |
362 | #define KERN_AIOPROCMAX 47 /* int: max aio requests per process */ |
363 | #define KERN_AIOTHREADS 48 /* int: max aio worker threads */ | |
364 | #ifdef __APPLE_API_UNSTABLE | |
e5568f75 | 365 | #define KERN_PROCARGS2 49 |
55e303ae | 366 | #endif /* __APPLE_API_UNSTABLE */ |
e5568f75 A |
367 | #define KERN_COREFILE 50 /* string: corefile format string */ |
368 | #define KERN_COREDUMP 51 /* int: whether to coredump at all */ | |
369 | #define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */ | |
91447636 A |
370 | #define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */ |
371 | #define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */ | |
372 | #define KERN_PROC_LOW_PRI_IO 55 /* int: set/reset current proc for low priority I/O */ | |
373 | #define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */ | |
374 | #define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */ | |
375 | #define KERN_POSIX 58 /* node: posix tunables */ | |
21362eb3 A |
376 | #define KERN_USRSTACK64 59 /* LP64 user stack query */ |
377 | #define KERN_MAXID 60 /* number of valid kern ids */ | |
91447636 A |
378 | |
379 | #if defined(__LP64__) | |
380 | #define KERN_USRSTACK KERN_USRSTACK64 | |
381 | #else | |
382 | #define KERN_USRSTACK KERN_USRSTACK32 | |
383 | #endif | |
1c79356b A |
384 | |
385 | /* KERN_KDEBUG types */ | |
386 | #define KERN_KDEFLAGS 1 | |
387 | #define KERN_KDDFLAGS 2 | |
388 | #define KERN_KDENABLE 3 | |
389 | #define KERN_KDSETBUF 4 | |
390 | #define KERN_KDGETBUF 5 | |
391 | #define KERN_KDSETUP 6 | |
392 | #define KERN_KDREMOVE 7 | |
393 | #define KERN_KDSETREG 8 | |
394 | #define KERN_KDGETREG 9 | |
395 | #define KERN_KDREADTR 10 | |
55e303ae | 396 | #define KERN_KDPIDTR 11 |
1c79356b A |
397 | #define KERN_KDTHRMAP 12 |
398 | /* Don't use 13 as it is overloaded with KERN_VNODE */ | |
399 | #define KERN_KDPIDEX 14 | |
400 | #define KERN_KDSETRTCDEC 15 | |
9bccf70c | 401 | #define KERN_KDGETENTROPY 16 |
1c79356b A |
402 | |
403 | /* KERN_PCSAMPLES types */ | |
404 | #define KERN_PCDISABLE 1 | |
405 | #define KERN_PCSETBUF 2 | |
406 | #define KERN_PCGETBUF 3 | |
407 | #define KERN_PCSETUP 4 | |
408 | #define KERN_PCREMOVE 5 | |
409 | #define KERN_PCREADBUF 6 | |
410 | #define KERN_PCSETREG 7 | |
411 | #define KERN_PCCOMM 8 | |
412 | ||
9bccf70c A |
413 | /* KERN_PANICINFO types */ |
414 | #define KERN_PANICINFO_MAXSIZE 1 /* quad: panic UI image size limit */ | |
91447636 | 415 | #define KERN_PANICINFO_IMAGE 2 /* panic UI in 8-bit kraw format */ |
9bccf70c A |
416 | |
417 | /* | |
418 | * KERN_SYSV identifiers | |
419 | */ | |
420 | #define KSYSV_SHMMAX 1 /* int: max shared memory segment size (bytes) */ | |
421 | #define KSYSV_SHMMIN 2 /* int: min shared memory segment size (bytes) */ | |
422 | #define KSYSV_SHMMNI 3 /* int: max number of shared memory identifiers */ | |
423 | #define KSYSV_SHMSEG 4 /* int: max shared memory segments per process */ | |
424 | #define KSYSV_SHMALL 5 /* int: max amount of shared memory (pages) */ | |
55e303ae A |
425 | #define KSYSV_SEMMNI 6 /* int: max num of semaphore identifiers */ |
426 | #define KSYSV_SEMMNS 7 /* int: max num of semaphores in system */ | |
427 | #define KSYSV_SEMMNU 8 /* int: max num of undo structures in system */ | |
428 | #define KSYSV_SEMMSL 9 /* int: max num of semaphores per id */ | |
429 | #define KSYSV_SEMUNE 10 /* int: max num of undo entries per process */ | |
9bccf70c A |
430 | |
431 | ||
1c79356b A |
432 | #define CTL_KERN_NAMES { \ |
433 | { 0, 0 }, \ | |
434 | { "ostype", CTLTYPE_STRING }, \ | |
435 | { "osrelease", CTLTYPE_STRING }, \ | |
436 | { "osrevision", CTLTYPE_INT }, \ | |
437 | { "version", CTLTYPE_STRING }, \ | |
438 | { "maxvnodes", CTLTYPE_INT }, \ | |
439 | { "maxproc", CTLTYPE_INT }, \ | |
440 | { "maxfiles", CTLTYPE_INT }, \ | |
441 | { "argmax", CTLTYPE_INT }, \ | |
442 | { "securelevel", CTLTYPE_INT }, \ | |
443 | { "hostname", CTLTYPE_STRING }, \ | |
444 | { "hostid", CTLTYPE_INT }, \ | |
445 | { "clockrate", CTLTYPE_STRUCT }, \ | |
446 | { "vnode", CTLTYPE_STRUCT }, \ | |
447 | { "proc", CTLTYPE_STRUCT }, \ | |
448 | { "file", CTLTYPE_STRUCT }, \ | |
449 | { "profiling", CTLTYPE_NODE }, \ | |
450 | { "posix1version", CTLTYPE_INT }, \ | |
451 | { "ngroups", CTLTYPE_INT }, \ | |
452 | { "job_control", CTLTYPE_INT }, \ | |
453 | { "saved_ids", CTLTYPE_INT }, \ | |
454 | { "boottime", CTLTYPE_STRUCT }, \ | |
455 | { "nisdomainname", CTLTYPE_STRING }, \ | |
456 | { "maxpartitions", CTLTYPE_INT }, \ | |
457 | { "kdebug", CTLTYPE_INT }, \ | |
458 | { "update", CTLTYPE_INT }, \ | |
459 | { "osreldate", CTLTYPE_INT }, \ | |
9bccf70c | 460 | { "ntp_pll", CTLTYPE_NODE }, \ |
1c79356b A |
461 | { "bootfile", CTLTYPE_STRING }, \ |
462 | { "maxfilesperproc", CTLTYPE_INT }, \ | |
463 | { "maxprocperuid", CTLTYPE_INT }, \ | |
464 | { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \ | |
465 | { "ipc", CTLTYPE_NODE }, \ | |
466 | { "dummy", CTLTYPE_INT }, \ | |
91447636 | 467 | { "dummy", CTLTYPE_INT }, \ |
1c79356b A |
468 | { "usrstack", CTLTYPE_INT }, \ |
469 | { "logsigexit", CTLTYPE_INT }, \ | |
9bccf70c A |
470 | { "symfile",CTLTYPE_STRING },\ |
471 | { "procargs",CTLTYPE_STRUCT },\ | |
472 | { "pcsamples",CTLTYPE_STRUCT },\ | |
473 | { "netboot", CTLTYPE_INT }, \ | |
474 | { "panicinfo", CTLTYPE_NODE }, \ | |
55e303ae A |
475 | { "sysv", CTLTYPE_NODE }, \ |
476 | { "dummy", CTLTYPE_INT }, \ | |
477 | { "dummy", CTLTYPE_INT }, \ | |
21362eb3 | 478 | { "dummy", CTLTYPE_INT }, \ |
55e303ae A |
479 | { "aiomax", CTLTYPE_INT }, \ |
480 | { "aioprocmax", CTLTYPE_INT }, \ | |
481 | { "aiothreads", CTLTYPE_INT }, \ | |
e5568f75 A |
482 | { "procargs2",CTLTYPE_STRUCT }, \ |
483 | { "corefile",CTLTYPE_STRING }, \ | |
484 | { "coredump", CTLTYPE_INT }, \ | |
91447636 A |
485 | { "sugid_coredump", CTLTYPE_INT }, \ |
486 | { "delayterm", CTLTYPE_INT }, \ | |
487 | { "shreg_private", CTLTYPE_INT }, \ | |
488 | { "proc_low_pri_io", CTLTYPE_INT }, \ | |
489 | { "low_pri_window", CTLTYPE_INT }, \ | |
490 | { "low_pri_delay", CTLTYPE_INT }, \ | |
21362eb3 | 491 | { "posix", CTLTYPE_NODE } \ |
1c79356b A |
492 | } |
493 | ||
494 | /* | |
495 | * CTL_VFS identifiers | |
496 | */ | |
497 | #define CTL_VFS_NAMES { \ | |
9bccf70c | 498 | { "vfsconf", CTLTYPE_STRUCT } \ |
1c79356b A |
499 | } |
500 | ||
501 | /* | |
502 | * KERN_PROC subtypes | |
503 | */ | |
504 | #define KERN_PROC_ALL 0 /* everything */ | |
505 | #define KERN_PROC_PID 1 /* by process id */ | |
506 | #define KERN_PROC_PGRP 2 /* by process group id */ | |
507 | #define KERN_PROC_SESSION 3 /* by session of pid */ | |
508 | #define KERN_PROC_TTY 4 /* by controlling tty */ | |
509 | #define KERN_PROC_UID 5 /* by effective uid */ | |
510 | #define KERN_PROC_RUID 6 /* by real uid */ | |
511 | ||
512 | /* | |
513 | * KERN_PROC subtype ops return arrays of augmented proc structures: | |
514 | */ | |
9bccf70c | 515 | #ifdef __APPLE_API_UNSTABLE |
91447636 A |
516 | |
517 | struct _pcred { | |
518 | char pc_lock[72]; /* opaque content */ | |
519 | struct ucred *pc_ucred; /* Current credentials. */ | |
520 | uid_t p_ruid; /* Real user id. */ | |
521 | uid_t p_svuid; /* Saved effective user id. */ | |
522 | gid_t p_rgid; /* Real group id. */ | |
523 | gid_t p_svgid; /* Saved effective group id. */ | |
524 | int p_refcnt; /* Number of references. */ | |
525 | }; | |
526 | ||
527 | struct _ucred { | |
528 | int32_t cr_ref; /* reference count */ | |
529 | uid_t cr_uid; /* effective user id */ | |
530 | short cr_ngroups; /* number of groups */ | |
531 | gid_t cr_groups[NGROUPS]; /* groups */ | |
532 | }; | |
533 | ||
1c79356b A |
534 | struct kinfo_proc { |
535 | struct extern_proc kp_proc; /* proc structure */ | |
536 | struct eproc { | |
537 | struct proc *e_paddr; /* address of proc */ | |
538 | struct session *e_sess; /* session pointer */ | |
91447636 A |
539 | struct _pcred e_pcred; /* process credentials */ |
540 | struct _ucred e_ucred; /* current credentials */ | |
9bccf70c | 541 | struct vmspace e_vm; /* address space */ |
1c79356b A |
542 | pid_t e_ppid; /* parent process id */ |
543 | pid_t e_pgid; /* process group id */ | |
544 | short e_jobc; /* job control counter */ | |
545 | dev_t e_tdev; /* controlling tty dev */ | |
546 | pid_t e_tpgid; /* tty process group id */ | |
547 | struct session *e_tsess; /* tty session pointer */ | |
548 | #define WMESGLEN 7 | |
549 | char e_wmesg[WMESGLEN+1]; /* wchan message */ | |
550 | segsz_t e_xsize; /* text size */ | |
551 | short e_xrssize; /* text rss */ | |
552 | short e_xccount; /* text references */ | |
553 | short e_xswrss; | |
91447636 | 554 | int32_t e_flag; |
1c79356b A |
555 | #define EPROC_CTTY 0x01 /* controlling tty vnode active */ |
556 | #define EPROC_SLEADER 0x02 /* session leader */ | |
9bccf70c A |
557 | #define COMAPT_MAXLOGNAME 12 |
558 | char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ | |
91447636 | 559 | int32_t e_spare[4]; |
1c79356b A |
560 | } kp_eproc; |
561 | }; | |
91447636 A |
562 | |
563 | #ifdef BSD_KERNEL_PRIVATE | |
564 | #include <sys/proc_internal.h> | |
565 | ||
566 | // LP64todo - should this move? | |
567 | ||
568 | /* LP64 version of _pcred. all pointers | |
569 | * grow when we're dealing with a 64-bit process. | |
570 | * WARNING - keep in sync with _pcred | |
571 | */ | |
572 | ||
21362eb3 A |
573 | #if __DARWIN_ALIGN_NATURAL |
574 | #pragma options align=natural | |
575 | #endif | |
576 | ||
91447636 A |
577 | struct user_pcred { |
578 | char pc_lock[72]; /* opaque content */ | |
579 | user_addr_t pc_ucred; /* Current credentials. */ | |
580 | uid_t p_ruid; /* Real user id. */ | |
581 | uid_t p_svuid; /* Saved effective user id. */ | |
582 | gid_t p_rgid; /* Real group id. */ | |
583 | gid_t p_svgid; /* Saved effective group id. */ | |
21362eb3 | 584 | int p_refcnt; /* Number of references. */ |
91447636 A |
585 | }; |
586 | ||
587 | /* LP64 version of kinfo_proc. all pointers | |
588 | * grow when we're dealing with a 64-bit process. | |
589 | * WARNING - keep in sync with kinfo_proc | |
590 | */ | |
591 | struct user_kinfo_proc { | |
592 | struct user_extern_proc kp_proc; /* proc structure */ | |
593 | struct user_eproc { | |
594 | user_addr_t e_paddr; /* address of proc */ | |
595 | user_addr_t e_sess; /* session pointer */ | |
596 | struct user_pcred e_pcred; /* process credentials */ | |
597 | struct _ucred e_ucred; /* current credentials */ | |
598 | struct user_vmspace e_vm; /* address space */ | |
599 | pid_t e_ppid; /* parent process id */ | |
600 | pid_t e_pgid; /* process group id */ | |
601 | short e_jobc; /* job control counter */ | |
602 | dev_t e_tdev; /* controlling tty dev */ | |
603 | pid_t e_tpgid; /* tty process group id */ | |
21362eb3 | 604 | user_addr_t e_tsess; /* tty session pointer */ |
91447636 A |
605 | char e_wmesg[WMESGLEN+1]; /* wchan message */ |
606 | segsz_t e_xsize; /* text size */ | |
607 | short e_xrssize; /* text rss */ | |
608 | short e_xccount; /* text references */ | |
609 | short e_xswrss; | |
610 | int32_t e_flag; | |
611 | char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ | |
612 | int32_t e_spare[4]; | |
613 | } kp_eproc; | |
614 | }; | |
615 | ||
21362eb3 A |
616 | #if __DARWIN_ALIGN_NATURAL |
617 | #pragma options align=reset | |
618 | #endif | |
619 | ||
91447636 A |
620 | #endif /* BSD_KERNEL_PRIVATE */ |
621 | ||
9bccf70c | 622 | #endif /* __APPLE_API_UNSTABLE */ |
1c79356b A |
623 | |
624 | /* | |
625 | * KERN_IPC identifiers | |
626 | */ | |
627 | #define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ | |
628 | #define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ | |
629 | #define KIPC_SOMAXCONN 3 /* int: max length of connection q */ | |
630 | #define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ | |
631 | #define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ | |
632 | #define KIPC_MAX_HDR 6 /* int: max total length of headers */ | |
633 | #define KIPC_MAX_DATALEN 7 /* int: max length of data? */ | |
634 | #define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */ | |
635 | #define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */ | |
636 | ||
637 | /* | |
638 | * CTL_VM identifiers | |
639 | */ | |
640 | #define VM_METER 1 /* struct vmmeter */ | |
641 | #define VM_LOADAVG 2 /* struct loadavg */ | |
91447636 A |
642 | /* |
643 | * Note: "3" was skipped sometime ago and should probably remain unused | |
644 | * to avoid any new entry from being accepted by older kernels... | |
645 | */ | |
1c79356b | 646 | #define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/ |
91447636 A |
647 | #define VM_SWAPUSAGE 5 /* total swap usage */ |
648 | #define VM_MAXID 6 /* number of valid vm ids */ | |
1c79356b A |
649 | |
650 | #define CTL_VM_NAMES { \ | |
651 | { 0, 0 }, \ | |
652 | { "vmmeter", CTLTYPE_STRUCT }, \ | |
91447636 A |
653 | { "loadavg", CTLTYPE_STRUCT }, \ |
654 | { 0, 0 }, /* placeholder for "3" (see comment above) */ \ | |
655 | { "machfactor", CTLTYPE_STRUCT }, \ | |
656 | { "swapusage", CTLTYPE_STRUCT } \ | |
1c79356b A |
657 | } |
658 | ||
91447636 A |
659 | struct xsw_usage { |
660 | u_int64_t xsu_total; | |
661 | u_int64_t xsu_avail; | |
662 | u_int64_t xsu_used; | |
663 | u_int32_t xsu_pagesize; | |
664 | boolean_t xsu_encrypted; | |
665 | }; | |
666 | ||
667 | #ifdef __APPLE_API_PRIVATE | |
668 | /* Load average structure. Use of fixpt_t assume <sys/types.h> in scope. */ | |
669 | /* XXX perhaps we should protect fixpt_t, and define it here (or discard it) */ | |
670 | struct loadavg { | |
671 | fixpt_t ldavg[3]; | |
672 | long fscale; | |
673 | }; | |
674 | extern struct loadavg averunnable; | |
675 | #define LSCALE 1000 /* scaling for "fixed point" arithmetic */ | |
676 | ||
677 | // LP64todo - should this move? | |
678 | #ifdef BSD_KERNEL_PRIVATE | |
679 | ||
21362eb3 A |
680 | #if __DARWIN_ALIGN_NATURAL |
681 | #pragma options align=natural | |
682 | #endif | |
91447636 A |
683 | struct user_loadavg { |
684 | fixpt_t ldavg[3]; | |
21362eb3 | 685 | user_long_t fscale; |
91447636 A |
686 | }; |
687 | ||
21362eb3 A |
688 | #if __DARWIN_ALIGN_NATURAL |
689 | #pragma options align=reset | |
690 | #endif | |
691 | ||
91447636 A |
692 | #endif /* BSD_KERNEL_PRIVATE */ |
693 | #endif /* __APPLE_API_PRIVATE */ | |
694 | ||
695 | ||
1c79356b A |
696 | /* |
697 | * CTL_HW identifiers | |
698 | */ | |
699 | #define HW_MACHINE 1 /* string: machine class */ | |
700 | #define HW_MODEL 2 /* string: specific machine model */ | |
701 | #define HW_NCPU 3 /* int: number of cpus */ | |
702 | #define HW_BYTEORDER 4 /* int: machine byte order */ | |
703 | #define HW_PHYSMEM 5 /* int: total memory */ | |
704 | #define HW_USERMEM 6 /* int: non-kernel memory */ | |
705 | #define HW_PAGESIZE 7 /* int: software page size */ | |
706 | #define HW_DISKNAMES 8 /* strings: disk drive names */ | |
707 | #define HW_DISKSTATS 9 /* struct: diskstats[] */ | |
708 | #define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */ | |
709 | #define HW_FLOATINGPT 11 /* int: has HW floating point? */ | |
710 | #define HW_MACHINE_ARCH 12 /* string: machine architecture */ | |
711 | #define HW_VECTORUNIT 13 /* int: has HW vector unit? */ | |
712 | #define HW_BUS_FREQ 14 /* int: Bus Frequency */ | |
713 | #define HW_CPU_FREQ 15 /* int: CPU Frequency */ | |
714 | #define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */ | |
715 | #define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */ | |
716 | #define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */ | |
717 | #define HW_L2SETTINGS 19 /* int: L2 Cache Settings */ | |
718 | #define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */ | |
719 | #define HW_L3SETTINGS 21 /* int: L3 Cache Settings */ | |
720 | #define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */ | |
90556fb8 | 721 | #define HW_TB_FREQ 23 /* int: Bus Frequency */ |
43866e37 A |
722 | #define HW_MEMSIZE 24 /* uint64_t: physical ram size */ |
723 | #define HW_AVAILCPU 25 /* int: number of available CPUs */ | |
724 | #define HW_MAXID 26 /* number of valid hw ids */ | |
1c79356b A |
725 | |
726 | #define CTL_HW_NAMES { \ | |
727 | { 0, 0 }, \ | |
728 | { "machine", CTLTYPE_STRING }, \ | |
729 | { "model", CTLTYPE_STRING }, \ | |
730 | { "ncpu", CTLTYPE_INT }, \ | |
731 | { "byteorder", CTLTYPE_INT }, \ | |
732 | { "physmem", CTLTYPE_INT }, \ | |
733 | { "usermem", CTLTYPE_INT }, \ | |
734 | { "pagesize", CTLTYPE_INT }, \ | |
735 | { "disknames", CTLTYPE_STRUCT }, \ | |
736 | { "diskstats", CTLTYPE_STRUCT }, \ | |
737 | { "epoch", CTLTYPE_INT }, \ | |
738 | { "floatingpoint", CTLTYPE_INT }, \ | |
739 | { "machinearch", CTLTYPE_STRING }, \ | |
740 | { "vectorunit", CTLTYPE_INT }, \ | |
741 | { "busfrequency", CTLTYPE_INT }, \ | |
742 | { "cpufrequency", CTLTYPE_INT }, \ | |
743 | { "cachelinesize", CTLTYPE_INT }, \ | |
744 | { "l1icachesize", CTLTYPE_INT }, \ | |
745 | { "l1dcachesize", CTLTYPE_INT }, \ | |
746 | { "l2settings", CTLTYPE_INT }, \ | |
747 | { "l2cachesize", CTLTYPE_INT }, \ | |
748 | { "l3settings", CTLTYPE_INT }, \ | |
90556fb8 | 749 | { "l3cachesize", CTLTYPE_INT }, \ |
43866e37 A |
750 | { "tbfrequency", CTLTYPE_INT }, \ |
751 | { "memsize", CTLTYPE_QUAD }, \ | |
752 | { "availcpu", CTLTYPE_INT } \ | |
1c79356b A |
753 | } |
754 | ||
43866e37 | 755 | /* |
91447636 | 756 | * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers. |
43866e37 A |
757 | * All other parameters are 32 bit numbers. |
758 | * | |
759 | * hw.memsize - The number of bytes of physical memory in the system. | |
760 | * | |
91447636 | 761 | * hw.ncpu - The maximum number of processors that could be available this boot. |
43866e37 A |
762 | * Use this value for sizing of static per processor arrays; i.e. processor load statistics. |
763 | * | |
91447636 | 764 | * hw.activecpu - The number of processors currently available for executing threads. |
43866e37 A |
765 | * Use this number to determine the number threads to create in SMP aware applications. |
766 | * This number can change when power management modes are changed. | |
91447636 A |
767 | * |
768 | * hw.physicalcpu - The number of physical processors available in the current power management mode. | |
769 | * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot | |
770 | * | |
771 | * hw.logicalcpu - The number of logical processors available in the current power management mode. | |
772 | * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot | |
773 | * | |
43866e37 A |
774 | * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services. |
775 | * In general is is better to use mach's or higher level timing services, but this value | |
776 | * is needed to convert the PPC Time Base registers to real time. | |
777 | * | |
778 | * hw.cpufrequency - These values provide the current, min and max cpu frequency. The min and max are for | |
779 | * hw.cpufrequency_max - all power management modes. The current frequency is the max frequency in the current mode. | |
780 | * hw.cpufrequency_min - All frequencies are in Hz. | |
781 | * | |
782 | * hw.busfrequency - These values provide the current, min and max bus frequency. The min and max are for | |
783 | * hw.busfrequency_max - all power management modes. The current frequency is the max frequency in the current mode. | |
784 | * hw.busfrequency_min - All frequencies are in Hz. | |
785 | * | |
786 | * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in <mach/machine.h> | |
787 | * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that | |
788 | * the best binary can be chosen, or the best dynamic code generated. They should not be used | |
789 | * to determine if a given processor feature is available. | |
91447636 A |
790 | * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector |
791 | * should not be used to infer features, and only used to name the processors thread architecture. | |
792 | * The values are defined in <mach/machine.h> | |
43866e37 A |
793 | * |
794 | * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little. | |
795 | * | |
796 | * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system. | |
797 | * | |
798 | * hw.cachelinesize - Gives the size in bytes of the processor's cache lines. | |
799 | * This value should be use to control the strides of loops that use cache control instructions | |
800 | * like dcbz, dcbt or dcbst. | |
801 | * | |
802 | * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present | |
803 | * hw.l1icachesize - then the selector will return and error. | |
804 | * hw.l2cachesize - | |
805 | * hw.l3cachesize - | |
806 | * | |
807 | * | |
21362eb3 A |
808 | * These are the selectors for optional processor features. Selectors that return errors are not support on the system. |
809 | * Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help performance. | |
810 | * Future versions of these selectors may return larger values as necessary so it is best to test for non zero. | |
43866e37 A |
811 | * |
812 | * hw.optional.floatingpoint - Floating Point Instructions | |
813 | * hw.optional.altivec - AltiVec Instructions | |
814 | * hw.optional.graphicsops - Graphics Operations | |
815 | * hw.optional.64bitops - 64-bit Instructions | |
816 | * hw.optional.fsqrt - HW Floating Point Square Root Instruction | |
817 | * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions | |
818 | * hw.optional.dcba - Data Cache Block Allocate Instruction | |
819 | * hw.optional.datastreams - Data Streams Instructions | |
820 | * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form | |
821 | * | |
822 | */ | |
823 | ||
824 | ||
1c79356b A |
825 | /* |
826 | * CTL_USER definitions | |
827 | */ | |
828 | #define USER_CS_PATH 1 /* string: _CS_PATH */ | |
829 | #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ | |
830 | #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ | |
831 | #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ | |
832 | #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ | |
833 | #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ | |
834 | #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ | |
835 | #define USER_LINE_MAX 8 /* int: LINE_MAX */ | |
836 | #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ | |
837 | #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ | |
838 | #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ | |
839 | #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ | |
840 | #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ | |
841 | #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ | |
842 | #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ | |
843 | #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ | |
844 | #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ | |
845 | #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ | |
846 | #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ | |
847 | #define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ | |
848 | #define USER_MAXID 21 /* number of valid user ids */ | |
849 | ||
850 | #define CTL_USER_NAMES { \ | |
851 | { 0, 0 }, \ | |
852 | { "cs_path", CTLTYPE_STRING }, \ | |
853 | { "bc_base_max", CTLTYPE_INT }, \ | |
854 | { "bc_dim_max", CTLTYPE_INT }, \ | |
855 | { "bc_scale_max", CTLTYPE_INT }, \ | |
856 | { "bc_string_max", CTLTYPE_INT }, \ | |
857 | { "coll_weights_max", CTLTYPE_INT }, \ | |
858 | { "expr_nest_max", CTLTYPE_INT }, \ | |
859 | { "line_max", CTLTYPE_INT }, \ | |
860 | { "re_dup_max", CTLTYPE_INT }, \ | |
861 | { "posix2_version", CTLTYPE_INT }, \ | |
862 | { "posix2_c_bind", CTLTYPE_INT }, \ | |
863 | { "posix2_c_dev", CTLTYPE_INT }, \ | |
864 | { "posix2_char_term", CTLTYPE_INT }, \ | |
865 | { "posix2_fort_dev", CTLTYPE_INT }, \ | |
866 | { "posix2_fort_run", CTLTYPE_INT }, \ | |
867 | { "posix2_localedef", CTLTYPE_INT }, \ | |
868 | { "posix2_sw_dev", CTLTYPE_INT }, \ | |
869 | { "posix2_upe", CTLTYPE_INT }, \ | |
870 | { "stream_max", CTLTYPE_INT }, \ | |
9bccf70c | 871 | { "tzname_max", CTLTYPE_INT } \ |
1c79356b A |
872 | } |
873 | ||
874 | ||
875 | ||
876 | /* | |
877 | * CTL_DEBUG definitions | |
878 | * | |
879 | * Second level identifier specifies which debug variable. | |
880 | * Third level identifier specifies which stucture component. | |
881 | */ | |
882 | #define CTL_DEBUG_NAME 0 /* string: variable name */ | |
883 | #define CTL_DEBUG_VALUE 1 /* int: variable value */ | |
884 | #define CTL_DEBUG_MAXID 20 | |
885 | ||
886 | #ifdef KERNEL | |
1c79356b A |
887 | #ifdef DEBUG |
888 | /* | |
889 | * CTL_DEBUG variables. | |
890 | * | |
891 | * These are declared as separate variables so that they can be | |
892 | * individually initialized at the location of their associated | |
893 | * variable. The loader prevents multiple use by issuing errors | |
894 | * if a variable is initialized in more than one place. They are | |
895 | * aggregated into an array in debug_sysctl(), so that it can | |
896 | * conveniently locate them when querried. If more debugging | |
897 | * variables are added, they must also be declared here and also | |
898 | * entered into the array. | |
899 | */ | |
900 | struct ctldebug { | |
901 | char *debugname; /* name of debugging variable */ | |
902 | int *debugvar; /* pointer to debugging variable */ | |
903 | }; | |
904 | extern struct ctldebug debug0, debug1, debug2, debug3, debug4; | |
905 | extern struct ctldebug debug5, debug6, debug7, debug8, debug9; | |
906 | extern struct ctldebug debug10, debug11, debug12, debug13, debug14; | |
907 | extern struct ctldebug debug15, debug16, debug17, debug18, debug19; | |
908 | #endif /* DEBUG */ | |
909 | ||
91447636 | 910 | #ifdef BSD_KERNEL_PRIVATE |
1c79356b A |
911 | extern char machine[]; |
912 | extern char osrelease[]; | |
913 | extern char ostype[]; | |
914 | ||
915 | struct linker_set; | |
916 | ||
917 | void sysctl_register_set(struct linker_set *lsp); | |
918 | void sysctl_unregister_set(struct linker_set *lsp); | |
43866e37 | 919 | void sysctl_mib_init(void); |
1c79356b | 920 | int kernel_sysctl(struct proc *p, int *name, u_int namelen, void *old, |
43866e37 | 921 | size_t *oldlenp, void *newp, size_t newlen); |
91447636 A |
922 | int userland_sysctl(struct proc *p, int *name, u_int namelen, user_addr_t old, |
923 | size_t *oldlenp, int inkernel, user_addr_t newp, size_t newlen, | |
1c79356b | 924 | size_t *retval); |
43866e37 | 925 | |
1c79356b A |
926 | /* |
927 | * Internal sysctl function calling convention: | |
928 | * | |
929 | * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen); | |
930 | * | |
931 | * The name parameter points at the next component of the name to be | |
932 | * interpreted. The namelen parameter is the number of integers in | |
933 | * the name. | |
934 | */ | |
935 | typedef int (sysctlfn) | |
91447636 A |
936 | (int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, struct proc *); |
937 | ||
938 | int sysctl_int(user_addr_t, size_t *, user_addr_t, size_t, int *); | |
939 | int sysctl_rdint(user_addr_t, size_t *, user_addr_t, int); | |
940 | int sysctl_quad(user_addr_t, size_t *, user_addr_t, size_t, quad_t *); | |
941 | int sysctl_rdquad(void *, size_t *, void *, quad_t); | |
942 | int sysctl_string(user_addr_t, size_t *, user_addr_t, size_t, char *, int); | |
943 | int sysctl_trstring(user_addr_t, size_t *, user_addr_t, size_t, char *, int); | |
944 | int sysctl_rdstring(user_addr_t, size_t *, user_addr_t, char *); | |
945 | int sysctl_rdstruct(user_addr_t, size_t *, user_addr_t, void *, int); | |
946 | ||
947 | #endif /* BSD_KERNEL_PRIVATE */ | |
1c79356b | 948 | #else /* !KERNEL */ |
1c79356b A |
949 | |
950 | __BEGIN_DECLS | |
91447636 A |
951 | int sysctl(int *, u_int, void *, size_t *, void *, size_t); |
952 | int sysctlbyname(const char *, void *, size_t *, void *, size_t); | |
953 | int sysctlnametomib(const char *, int *, size_t *); | |
1c79356b | 954 | __END_DECLS |
91447636 | 955 | |
1c79356b | 956 | #endif /* KERNEL */ |
91447636 A |
957 | |
958 | ||
959 | #endif /* SYSCTL_DEF_ENABLED */ | |
960 | ||
961 | ||
1c79356b | 962 | #endif /* !_SYS_SYSCTL_H_ */ |