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