master
1/*
2 * Copyright (c) 2000-2021 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/* 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 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
68 * support for mandatory and extensible security protections. This notice
69 * is included in support of clause 2.2 (b) of the Apple Public License,
70 * Version 2.0.
71 */
72
73#ifndef _SYS_SYSCTL_H_
74#define _SYS_SYSCTL_H_
75
76/*
77 * These are for the eproc structure defined below.
78 */
79#include <sys/cdefs.h>
80
81#include <sys/appleapiopts.h>
82#include <sys/time.h>
83#include <sys/ucred.h>
84
85#include <sys/proc.h>
86#include <sys/vm.h>
87
88/*
89 * Definitions for sysctl call. The sysctl call uses a hierarchical name
90 * for objects that can be examined or modified. The name is expressed as
91 * a sequence of integers. Like a file path name, the meaning of each
92 * component depends on its place in the hierarchy. The top-level and kern
93 * identifiers are defined here, and other identifiers are defined in the
94 * respective subsystem header files.
95 */
96
97#define CTL_MAXNAME 12 /* largest number of components supported */
98
99/*
100 * Each subsystem defined by sysctl defines a list of variables
101 * for that subsystem. Each name is either a node with further
102 * levels defined below it, or it is a leaf of some particular
103 * type given below. Each sysctl level defines a set of name/type
104 * pairs to be used by sysctl(1) in manipulating the subsystem.
105 *
106 * When declaring new sysctl names, use the CTLFLAG_LOCKED flag in the
107 * type to indicate that all necessary locking will be handled
108 * within the sysctl.
109 *
110 * Any sysctl defined without CTLFLAG_LOCKED is considered legacy
111 * and will be protected by a global mutex.
112 *
113 * Note: This is not optimal, so it is best to handle locking
114 * yourself, if you are able to do so. A simple design
115 * pattern for use to avoid in a single function known
116 * to potentially be in the paging path ot doing a DMA
117 * to physical memory in a user space process is:
118 *
119 * lock
120 * perform operation vs. local buffer
121 * unlock
122 * SYSCTL_OUT(rey, local buffer, length)
123 *
124 * ...this assumes you are not using a deep call graph
125 * or are unable to pass a local buffer address as a
126 * parameter into your deep call graph.
127 *
128 * Note that very large user buffers can fail the wire
129 * if to do so would require more physical pages than
130 * are available (the caller will get an ENOMEM error,
131 * see sysctl_mem_hold() for details).
132 */
133struct ctlname {
134 char *ctl_name; /* subsystem name */
135 int ctl_type; /* type of name */
136};
137
138#define CTLTYPE 0xf /* Mask for the type */
139#define CTLTYPE_NODE 1 /* name is a node */
140#define CTLTYPE_INT 2 /* name describes an integer */
141#define CTLTYPE_STRING 3 /* name describes a string */
142#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
143#define CTLTYPE_OPAQUE 5 /* name describes a structure */
144#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */
145
146#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */
147#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */
148#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR)
149#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */
150#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */
151#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */
152#define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */
153#define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */
154#define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */
155#define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */
156#define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */
157#define CTLFLAG_EXPERIMENT 0x00100000 /* Allows read/write w/ the trial experiment entitlement. */
158#define CTLFLAG_LEGACY_EXPERIMENT 0x00080000 /* Allows writing w/ the legacy trial experiment entitlement. */
159
160/*
161 * USE THIS instead of a hardwired number from the categories below
162 * to get dynamically assigned sysctl entries using the linker-set
163 * technology. This is the way nearly all new sysctl variables should
164 * be implemented.
165 *
166 * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, "");
167 *
168 * Note that linker set technology will automatically register all nodes
169 * declared like this on kernel initialization, UNLESS they are defined
170 * in I/O-Kit. In this case, you have to call sysctl_register_oid()
171 * manually - just like in a KEXT.
172 */
173#define OID_AUTO (-1)
174#define OID_AUTO_START 100 /* conventional */
175
176
177#define SYSCTL_DEF_ENABLED
178
179#ifdef SYSCTL_DEF_ENABLED
180/*
181 * Top-level identifiers
182 */
183#define CTL_UNSPEC 0 /* unused */
184#define CTL_KERN 1 /* "high kernel": proc, limits */
185#define CTL_VM 2 /* virtual memory */
186#define CTL_VFS 3 /* file system, mount type is next */
187#define CTL_NET 4 /* network, see socket.h */
188#define CTL_DEBUG 5 /* debugging parameters */
189#define CTL_HW 6 /* generic cpu/io */
190#define CTL_MACHDEP 7 /* machine dependent */
191#define CTL_USER 8 /* user-level */
192#define CTL_MAXID 9 /* number of valid top-level ids */
193
194#define CTL_NAMES { \
195 { 0, 0 }, \
196 { "kern", CTLTYPE_NODE }, \
197 { "vm", CTLTYPE_NODE }, \
198 { "vfs", CTLTYPE_NODE }, \
199 { "net", CTLTYPE_NODE }, \
200 { "debug", CTLTYPE_NODE }, \
201 { "hw", CTLTYPE_NODE }, \
202 { "machdep", CTLTYPE_NODE }, \
203 { "user", CTLTYPE_NODE }, \
204}
205
206/*
207 * CTL_KERN identifiers
208 */
209#define KERN_OSTYPE 1 /* string: system version */
210#define KERN_OSRELEASE 2 /* string: system release */
211#define KERN_OSREV 3 /* int: system revision */
212#define KERN_VERSION 4 /* string: compile time info */
213#define KERN_MAXVNODES 5 /* int: max vnodes */
214#define KERN_MAXPROC 6 /* int: max processes */
215#define KERN_MAXFILES 7 /* int: max open files */
216#define KERN_ARGMAX 8 /* int: max arguments to exec */
217#define KERN_SECURELVL 9 /* int: system security level */
218#define KERN_HOSTNAME 10 /* string: hostname */
219#define KERN_HOSTID 11 /* int: host identifier */
220#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
221#define KERN_VNODE 13 /* struct: vnode structures */
222#define KERN_PROC 14 /* struct: process entries */
223#define KERN_FILE 15 /* struct: file entries */
224#define KERN_PROF 16 /* node: kernel profiling info */
225#define KERN_POSIX1 17 /* int: POSIX.1 version */
226#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
227#define KERN_JOB_CONTROL 19 /* int: is job control available */
228#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
229#define KERN_BOOTTIME 21 /* struct: time kernel was booted */
230#define KERN_NISDOMAINNAME 22 /* string: YP domain name */
231#define KERN_DOMAINNAME KERN_NISDOMAINNAME
232#define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
233#define KERN_KDEBUG 24 /* int: kernel trace points */
234#define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */
235#define KERN_OSRELDATE 26 /* int: OS release date */
236#define KERN_NTP_PLL 27 /* node: NTP PLL control */
237#define KERN_BOOTFILE 28 /* string: name of booted kernel */
238#define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */
239#define KERN_MAXPROCPERUID 30 /* int: max processes per uid */
240#define KERN_DUMPDEV 31 /* dev_t: device to dump on */
241#define KERN_IPC 32 /* node: anything related to IPC */
242#define KERN_DUMMY 33 /* unused */
243#define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */
244#define KERN_USRSTACK32 35 /* int: address of USRSTACK */
245#define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */
246#define KERN_SYMFILE 37 /* string: kernel symbol filename */
247#define KERN_PROCARGS 38
248/* 39 was KERN_PCSAMPLES... now obsolete */
249#define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */
250/* 41 was KERN_PANICINFO : panic UI information (deprecated) */
251#define KERN_SYSV 42 /* node: System V IPC information */
252#define KERN_AFFINITY 43 /* xxx */
253#define KERN_TRANSLATE 44 /* xxx */
254#define KERN_CLASSIC KERN_TRANSLATE /* XXX backwards compat */
255#define KERN_EXEC 45 /* xxx */
256#define KERN_CLASSICHANDLER KERN_EXEC /* XXX backwards compatibility */
257#define KERN_AIOMAX 46 /* int: max aio requests */
258#define KERN_AIOPROCMAX 47 /* int: max aio requests per process */
259#define KERN_AIOTHREADS 48 /* int: max aio worker threads */
260#ifdef __APPLE_API_UNSTABLE
261#define KERN_PROCARGS2 49
262#endif /* __APPLE_API_UNSTABLE */
263#define KERN_COREFILE 50 /* string: corefile format string */
264#define KERN_COREDUMP 51 /* int: whether to coredump at all */
265#define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */
266#define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */
267#define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */
268/* 55 was KERN_PROC_LOW_PRI_IO... now deprecated */
269#define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */
270#define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */
271#define KERN_POSIX 58 /* node: posix tunables */
272#define KERN_USRSTACK64 59 /* LP64 user stack query */
273#define KERN_NX_PROTECTION 60 /* int: whether no-execute protection is enabled */
274#define KERN_TFP 61 /* Task for pid settings */
275#define KERN_PROCNAME 62 /* setup process program name(2*MAXCOMLEN) */
276#define KERN_THALTSTACK 63 /* for compat with older x86 and does nothing */
277#define KERN_SPECULATIVE_READS 64 /* int: whether speculative reads are disabled */
278#define KERN_OSVERSION 65 /* for build number i.e. 9A127 */
279#define KERN_SAFEBOOT 66 /* are we booted safe? */
280/* 67 was KERN_LCTX (login context) */
281#define KERN_RAGEVNODE 68
282#define KERN_TTY 69 /* node: tty settings */
283#define KERN_CHECKOPENEVT 70 /* spi: check the VOPENEVT flag on vnodes at open time */
284#define KERN_THREADNAME 71 /* set/get thread name */
285#define KERN_MAXID 72 /* number of valid kern ids */
286/*
287 * Don't add any more sysctls like this. Instead, use the SYSCTL_*() macros
288 * and OID_AUTO. This will have the added benefit of not having to recompile
289 * sysctl(8) to pick up your changes.
290 */
291
292
293#if defined(__LP64__)
294#define KERN_USRSTACK KERN_USRSTACK64
295#else
296#define KERN_USRSTACK KERN_USRSTACK32
297#endif
298
299
300/* KERN_RAGEVNODE types */
301#define KERN_RAGE_PROC 1
302#define KERN_RAGE_THREAD 2
303#define KERN_UNRAGE_PROC 3
304#define KERN_UNRAGE_THREAD 4
305
306/* KERN_OPENEVT types */
307#define KERN_OPENEVT_PROC 1
308#define KERN_UNOPENEVT_PROC 2
309
310/* KERN_TFP types */
311#define KERN_TFP_POLICY 1
312
313/* KERN_TFP_POLICY values . All policies allow task port for self */
314#define KERN_TFP_POLICY_DENY 0 /* Deny Mode: None allowed except privileged */
315#define KERN_TFP_POLICY_DEFAULT 2 /* Default Mode: related ones allowed and upcall authentication */
316
317/* KERN_KDEBUG types */
318#define KERN_KDEFLAGS 1
319#define KERN_KDDFLAGS 2
320#define KERN_KDENABLE 3
321#define KERN_KDSETBUF 4
322#define KERN_KDGETBUF 5
323#define KERN_KDSETUP 6
324#define KERN_KDREMOVE 7
325#define KERN_KDSETREG 8
326#define KERN_KDGETREG 9
327#define KERN_KDREADTR 10
328#define KERN_KDPIDTR 11
329#define KERN_KDTHRMAP 12
330/* Don't use 13 as it is overloaded with KERN_VNODE */
331#define KERN_KDPIDEX 14
332#define KERN_KDSETRTCDEC 15 /* obsolete */
333#define KERN_KDGETENTROPY 16 /* obsolete */
334#define KERN_KDWRITETR 17
335#define KERN_KDWRITEMAP 18
336#define KERN_KDTEST 19
337/* 20 unused */
338#define KERN_KDREADCURTHRMAP 21
339#define KERN_KDSET_TYPEFILTER 22
340#define KERN_KDBUFWAIT 23
341#define KERN_KDCPUMAP 24
342#define KERN_KDCPUMAP_EXT 25
343#define KERN_KDSET_EDM 26
344#define KERN_KDGET_EDM 27
345#define KERN_KDWRITETR_V3 28
346
347#define CTL_KERN_NAMES { \
348 { 0, 0 }, \
349 { "ostype", CTLTYPE_STRING }, \
350 { "osrelease", CTLTYPE_STRING }, \
351 { "osrevision", CTLTYPE_INT }, \
352 { "version", CTLTYPE_STRING }, \
353 { "maxvnodes", CTLTYPE_INT }, \
354 { "maxproc", CTLTYPE_INT }, \
355 { "maxfiles", CTLTYPE_INT }, \
356 { "argmax", CTLTYPE_INT }, \
357 { "securelevel", CTLTYPE_INT }, \
358 { "hostname", CTLTYPE_STRING }, \
359 { "hostid", CTLTYPE_INT }, \
360 { "clockrate", CTLTYPE_STRUCT }, \
361 { "vnode", CTLTYPE_STRUCT }, \
362 { "proc", CTLTYPE_STRUCT }, \
363 { "file", CTLTYPE_STRUCT }, \
364 { "profiling", CTLTYPE_NODE }, \
365 { "posix1version", CTLTYPE_INT }, \
366 { "ngroups", CTLTYPE_INT }, \
367 { "job_control", CTLTYPE_INT }, \
368 { "saved_ids", CTLTYPE_INT }, \
369 { "boottime", CTLTYPE_STRUCT }, \
370 { "nisdomainname", CTLTYPE_STRING }, \
371 { "maxpartitions", CTLTYPE_INT }, \
372 { "kdebug", CTLTYPE_INT }, \
373 { "update", CTLTYPE_INT }, \
374 { "osreldate", CTLTYPE_INT }, \
375 { "ntp_pll", CTLTYPE_NODE }, \
376 { "bootfile", CTLTYPE_STRING }, \
377 { "maxfilesperproc", CTLTYPE_INT }, \
378 { "maxprocperuid", CTLTYPE_INT }, \
379 { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \
380 { "ipc", CTLTYPE_NODE }, \
381 { "dummy", CTLTYPE_INT }, \
382 { "dummy", CTLTYPE_INT }, \
383 { "usrstack", CTLTYPE_INT }, \
384 { "logsigexit", CTLTYPE_INT }, \
385 { "symfile",CTLTYPE_STRING },\
386 { "procargs",CTLTYPE_STRUCT },\
387 { "dummy", CTLTYPE_INT }, /* deprecated pcsamples */ \
388 { "netboot", CTLTYPE_INT }, \
389 { "dummy", CTLTYPE_INT }, /* deprecated: panicinfo */ \
390 { "sysv", CTLTYPE_NODE }, \
391 { "dummy", CTLTYPE_INT }, \
392 { "dummy", CTLTYPE_INT }, \
393 { "exec", CTLTYPE_NODE }, \
394 { "aiomax", CTLTYPE_INT }, \
395 { "aioprocmax", CTLTYPE_INT }, \
396 { "aiothreads", CTLTYPE_INT }, \
397 { "procargs2",CTLTYPE_STRUCT }, \
398 { "corefile",CTLTYPE_STRING }, \
399 { "coredump", CTLTYPE_INT }, \
400 { "sugid_coredump", CTLTYPE_INT }, \
401 { "delayterm", CTLTYPE_INT }, \
402 { "shreg_private", CTLTYPE_INT }, \
403 { "proc_low_pri_io", CTLTYPE_INT }, \
404 { "low_pri_window", CTLTYPE_INT }, \
405 { "low_pri_delay", CTLTYPE_INT }, \
406 { "posix", CTLTYPE_NODE }, \
407 { "usrstack64", CTLTYPE_QUAD }, \
408 { "nx", CTLTYPE_INT }, \
409 { "tfp", CTLTYPE_NODE }, \
410 { "procname", CTLTYPE_STRING }, \
411 { "threadsigaltstack", CTLTYPE_INT }, \
412 { "speculative_reads_disabled", CTLTYPE_INT }, \
413 { "osversion", CTLTYPE_STRING }, \
414 { "safeboot", CTLTYPE_INT }, \
415 { "dummy", CTLTYPE_INT }, /* deprecated: lctx */ \
416 { "rage_vnode", CTLTYPE_INT }, \
417 { "tty", CTLTYPE_NODE }, \
418 { "check_openevt", CTLTYPE_INT }, \
419 { "thread_name", CTLTYPE_STRING } \
420}
421
422/*
423 * CTL_VFS identifiers
424 */
425#define CTL_VFS_NAMES { \
426 { "vfsconf", CTLTYPE_STRUCT } \
427}
428
429/*
430 * KERN_PROC subtypes
431 */
432#define KERN_PROC_ALL 0 /* everything */
433#define KERN_PROC_PID 1 /* by process id */
434#define KERN_PROC_PGRP 2 /* by process group id */
435#define KERN_PROC_SESSION 3 /* by session of pid */
436#define KERN_PROC_TTY 4 /* by controlling tty */
437#define KERN_PROC_UID 5 /* by effective uid */
438#define KERN_PROC_RUID 6 /* by real uid */
439#define KERN_PROC_LCID 7 /* by login context id */
440
441/*
442 * KERN_VFSNSPACE subtypes
443 */
444#define KERN_VFSNSPACE_HANDLE_PROC 1
445#define KERN_VFSNSPACE_UNHANDLE_PROC 2
446
447/*
448 * KERN_PROC subtype ops return arrays of augmented proc structures:
449 */
450
451struct _pcred {
452 char pc_lock[72]; /* opaque content */
453 struct ucred *pc_ucred; /* Current credentials. */
454 uid_t p_ruid; /* Real user id. */
455 uid_t p_svuid; /* Saved effective user id. */
456 gid_t p_rgid; /* Real group id. */
457 gid_t p_svgid; /* Saved effective group id. */
458 int p_refcnt; /* Number of references. */
459};
460
461struct _ucred {
462 int32_t cr_ref; /* reference count */
463 uid_t cr_uid; /* effective user id */
464 short cr_ngroups; /* number of groups */
465 gid_t cr_groups[NGROUPS]; /* groups */
466};
467
468struct kinfo_proc {
469 struct extern_proc kp_proc; /* proc structure */
470 struct eproc {
471 struct proc *e_paddr; /* address of proc */
472 struct session *e_sess; /* session pointer */
473 struct _pcred e_pcred; /* process credentials */
474 struct _ucred e_ucred; /* current credentials */
475 struct vmspace e_vm; /* address space */
476 pid_t e_ppid; /* parent process id */
477 pid_t e_pgid; /* process group id */
478 short e_jobc; /* job control counter */
479 dev_t e_tdev; /* controlling tty dev */
480 pid_t e_tpgid; /* tty process group id */
481 struct session *e_tsess; /* tty session pointer */
482#define WMESGLEN 7
483 char e_wmesg[WMESGLEN + 1]; /* wchan message */
484 segsz_t e_xsize; /* text size */
485 short e_xrssize; /* text rss */
486 short e_xccount; /* text references */
487 short e_xswrss;
488 int32_t e_flag;
489#define EPROC_CTTY 0x01 /* controlling tty vnode active */
490#define EPROC_SLEADER 0x02 /* session leader */
491#define COMAPT_MAXLOGNAME 12
492 char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */
493 int32_t e_spare[4];
494 } kp_eproc;
495};
496
497
498
499/*
500 * KERN_IPC identifiers
501 */
502#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */
503#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */
504#define KIPC_SOMAXCONN 3 /* int: max length of connection q */
505#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */
506#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */
507#define KIPC_MAX_HDR 6 /* int: max total length of headers */
508#define KIPC_MAX_DATALEN 7 /* int: max length of data? */
509#define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */
510#define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */
511#define KIPC_SOQLIMITCOMPAT 10 /* int: socket queue limit */
512
513/*
514 * CTL_VM identifiers
515 */
516#define VM_METER 1 /* struct vmmeter */
517#define VM_LOADAVG 2 /* struct loadavg */
518/*
519 * Note: "3" was skipped sometime ago and should probably remain unused
520 * to avoid any new entry from being accepted by older kernels...
521 */
522#define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/
523#define VM_SWAPUSAGE 5 /* total swap usage */
524#define VM_MAXID 6 /* number of valid vm ids */
525
526#define CTL_VM_NAMES { \
527 { 0, 0 }, \
528 { "vmmeter", CTLTYPE_STRUCT }, \
529 { "loadavg", CTLTYPE_STRUCT }, \
530 { 0, 0 }, /* placeholder for "3" (see comment above) */ \
531 { "dummy", CTLTYPE_INT }, \
532 { "swapusage", CTLTYPE_STRUCT } \
533}
534
535struct xsw_usage {
536 u_int64_t xsu_total;
537 u_int64_t xsu_avail;
538 u_int64_t xsu_used;
539 u_int32_t xsu_pagesize;
540 boolean_t xsu_encrypted;
541};
542
543#ifdef __APPLE_API_PRIVATE
544/* Load average structure. Use of fixpt_t assume <sys/types.h> in scope. */
545/* XXX perhaps we should protect fixpt_t, and define it here (or discard it) */
546struct loadavg {
547 fixpt_t ldavg[3];
548 long fscale;
549};
550extern struct loadavg averunnable;
551#define LSCALE 1000 /* scaling for "fixed point" arithmetic */
552
553#endif /* __APPLE_API_PRIVATE */
554
555
556/*
557 * CTL_HW identifiers
558 */
559#define HW_MACHINE 1 /* string: machine class (deprecated: use HW_PRODUCT) */
560#define HW_MODEL 2 /* string: specific machine model (deprecated: use HW_TARGET) */
561#define HW_NCPU 3 /* int: number of cpus */
562#define HW_BYTEORDER 4 /* int: machine byte order */
563#define HW_PHYSMEM 5 /* int: total memory */
564#define HW_USERMEM 6 /* int: non-kernel memory */
565#define HW_PAGESIZE 7 /* int: software page size */
566#define HW_DISKNAMES 8 /* strings: disk drive names */
567#define HW_DISKSTATS 9 /* struct: diskstats[] */
568#define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */
569#define HW_FLOATINGPT 11 /* int: has HW floating point? */
570#define HW_MACHINE_ARCH 12 /* string: machine architecture */
571#define HW_VECTORUNIT 13 /* int: has HW vector unit? */
572#define HW_BUS_FREQ 14 /* int: Bus Frequency */
573#define HW_CPU_FREQ 15 /* int: CPU Frequency */
574#define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */
575#define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */
576#define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */
577#define HW_L2SETTINGS 19 /* int: L2 Cache Settings */
578#define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */
579#define HW_L3SETTINGS 21 /* int: L3 Cache Settings */
580#define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */
581#define HW_TB_FREQ 23 /* int: Bus Frequency */
582#define HW_MEMSIZE 24 /* uint64_t: physical ram size */
583#define HW_AVAILCPU 25 /* int: number of available CPUs */
584#define HW_TARGET 26 /* string: model identifier */
585#define HW_PRODUCT 27 /* string: product identifier */
586#define HW_MAXID 28 /* number of valid hw ids */
587
588#define CTL_HW_NAMES { \
589 { 0, 0 }, \
590 { "machine", CTLTYPE_STRING }, /* Deprecated: use hw.product */ \
591 { "model", CTLTYPE_STRING }, /* Deprecated: use hw.target */ \
592 { "ncpu", CTLTYPE_INT }, \
593 { "byteorder", CTLTYPE_INT }, \
594 { "physmem", CTLTYPE_INT }, \
595 { "usermem", CTLTYPE_INT }, \
596 { "pagesize", CTLTYPE_INT }, \
597 { "disknames", CTLTYPE_STRUCT }, \
598 { "diskstats", CTLTYPE_STRUCT }, \
599 { "epoch", CTLTYPE_INT }, \
600 { "floatingpoint", CTLTYPE_INT }, \
601 { "machinearch", CTLTYPE_STRING }, \
602 { "vectorunit", CTLTYPE_INT }, \
603 { "busfrequency", CTLTYPE_INT }, \
604 { "cpufrequency", CTLTYPE_INT }, \
605 { "cachelinesize", CTLTYPE_INT }, \
606 { "l1icachesize", CTLTYPE_INT }, \
607 { "l1dcachesize", CTLTYPE_INT }, \
608 { "l2settings", CTLTYPE_INT }, \
609 { "l2cachesize", CTLTYPE_INT }, \
610 { "l3settings", CTLTYPE_INT }, \
611 { "l3cachesize", CTLTYPE_INT }, \
612 { "tbfrequency", CTLTYPE_INT }, \
613 { "memsize", CTLTYPE_QUAD }, \
614 { "availcpu", CTLTYPE_INT }, \
615 { "target", CTLTYPE_STRING }, \
616 { "product", CTLTYPE_STRING }, \
617}
618
619/*
620 * XXX This information should be moved to the man page.
621 *
622 * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers.
623 * All other parameters are 32 bit numbers.
624 *
625 * hw.memsize - The number of bytes of physical memory in the system.
626 *
627 * hw.ncpu - The maximum number of processors that could be available this boot.
628 * Use this value for sizing of static per processor arrays; i.e. processor load statistics.
629 *
630 * hw.activecpu - The number of processors currently available for executing threads.
631 * Use this number to determine the number threads to create in SMP aware applications.
632 * This number can change when power management modes are changed.
633 *
634 * hw.physicalcpu - The number of physical processors available in the current power management mode.
635 * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot
636 *
637 * hw.logicalcpu - The number of logical processors available in the current power management mode.
638 * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot
639 *
640 * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services.
641 * In general is is better to use mach's or higher level timing services, but this value
642 * is needed to convert the PPC Time Base registers to real time.
643 *
644 * hw.cpufrequency, hw.busfrequency and their min/max versions are deprecated because frequency isn't consistent.
645 *
646 * hw.cpufrequency - (deprecated) These values provide the current, min and max cpu frequency. The min and max are for
647 * hw.cpufrequency_max - (deprecated) all power management modes. The current frequency is the max frequency in the current mode.
648 * hw.cpufrequency_min - (deprecated) All frequencies are in Hz.
649 *
650 * hw.busfrequency - (deprecated) These values provide the current, min and max bus frequency. The min and max are for
651 * hw.busfrequency_max - (deprecated) all power management modes. The current frequency is the max frequency in the current mode.
652 * hw.busfrequency_min - (deprecated) All frequencies are in Hz.
653 *
654 * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in <mach/machine.h>
655 * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that
656 * the best binary can be chosen, or the best dynamic code generated. They should not be used
657 * to determine if a given processor feature is available.
658 * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector
659 * should not be used to infer features, and only used to name the processors thread architecture.
660 * The values are defined in <mach/machine.h>
661 *
662 * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little.
663 *
664 * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system.
665 *
666 * hw.cachelinesize - Gives the size in bytes of the processor's cache lines.
667 * This value should be use to control the strides of loops that use cache control instructions
668 * like dcbz, dcbt or dcbst.
669 *
670 * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present
671 * hw.l1icachesize - then the selector will return and error.
672 * hw.l2cachesize -
673 * hw.l3cachesize -
674 *
675 * hw.nperflevels - Number of core types in the system. See the parameters below, which can be used to get
676 * - information associated with a specific perf level.
677 *
678 * The following parameters apply to perflevel N, where N is a number between 0 and the number of core types in the system minus one.
679 * perflevel 0 always refers to the highest performance core type in the system.
680 *
681 * hw.perflevelN.physicalcpu - The number of physical processors available in the current power management mode.
682 * hw.perflevelN.physicalcpumax - The maximum number of physical processors that could be available this boot.
683 * hw.perflevelN.logicalcpu - The number of logical processors available in the current power management mode.
684 * hw.perflevelN.logicalcpumax - The maximum number of logical processors that could be available this boot.
685 *
686 * hw.perflevelN.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present
687 * hw.perflevelN.l1icachesize - then the selector will return and error.
688 * hw.perflevelN.l2cachesize -
689 * hw.perflevelN.l3cachesize -
690 *
691 * hw.perflevelN.cpusperl2 - These values provide the number of CPUs of the same type that share L2 and L3 caches.
692 * hw.perflevelN.cpusperl3 - If a cache is not present then the selector will return and error.
693 *
694 * hw.perflevelN.l2perflevels - These values provide a bitmap, where bit number of CPUs of the same type that share L2 and L3 caches.
695 * hw.perflevelN.l3perflevels - If a cache is not present then the selector will return and error.
696 *
697 * hw.packages - Gives the number of processor packages.
698 *
699 * These are the selectors for optional processor features for specific processors. Selectors that return errors are not support
700 * on the system. Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help .
701 * performance. Future versions of these selectors may return larger values as necessary so it is best to test for non zero.
702 *
703 * For PowerPC:
704 *
705 * hw.optional.floatingpoint - Floating Point Instructions
706 * hw.optional.altivec - AltiVec Instructions
707 * hw.optional.graphicsops - Graphics Operations
708 * hw.optional.64bitops - 64-bit Instructions
709 * hw.optional.fsqrt - HW Floating Point Square Root Instruction
710 * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions
711 * hw.optional.dcba - Data Cache Block Allocate Instruction
712 * hw.optional.datastreams - Data Streams Instructions
713 * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form
714 *
715 * For x86 Architecture:
716 *
717 * hw.optional.floatingpoint - Floating Point Instructions
718 * hw.optional.mmx - Original MMX vector instructions
719 * hw.optional.sse - Streaming SIMD Extensions
720 * hw.optional.sse2 - Streaming SIMD Extensions 2
721 * hw.optional.sse3 - Streaming SIMD Extensions 3
722 * hw.optional.supplementalsse3 - Supplemental Streaming SIMD Extensions 3
723 * hw.optional.x86_64 - 64-bit support
724 */
725
726
727/*
728 * CTL_USER definitions
729 */
730#define USER_CS_PATH 1 /* string: _CS_PATH */
731#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */
732#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */
733#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */
734#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */
735#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */
736#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */
737#define USER_LINE_MAX 8 /* int: LINE_MAX */
738#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */
739#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */
740#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */
741#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */
742#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */
743#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */
744#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */
745#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */
746#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */
747#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
748#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
749#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
750#define USER_MAXID 21 /* number of valid user ids */
751
752#define CTL_USER_NAMES { \
753 { 0, 0 }, \
754 { "cs_path", CTLTYPE_STRING }, \
755 { "bc_base_max", CTLTYPE_INT }, \
756 { "bc_dim_max", CTLTYPE_INT }, \
757 { "bc_scale_max", CTLTYPE_INT }, \
758 { "bc_string_max", CTLTYPE_INT }, \
759 { "coll_weights_max", CTLTYPE_INT }, \
760 { "expr_nest_max", CTLTYPE_INT }, \
761 { "line_max", CTLTYPE_INT }, \
762 { "re_dup_max", CTLTYPE_INT }, \
763 { "posix2_version", CTLTYPE_INT }, \
764 { "posix2_c_bind", CTLTYPE_INT }, \
765 { "posix2_c_dev", CTLTYPE_INT }, \
766 { "posix2_char_term", CTLTYPE_INT }, \
767 { "posix2_fort_dev", CTLTYPE_INT }, \
768 { "posix2_fort_run", CTLTYPE_INT }, \
769 { "posix2_localedef", CTLTYPE_INT }, \
770 { "posix2_sw_dev", CTLTYPE_INT }, \
771 { "posix2_upe", CTLTYPE_INT }, \
772 { "stream_max", CTLTYPE_INT }, \
773 { "tzname_max", CTLTYPE_INT } \
774}
775
776
777
778/*
779 * CTL_DEBUG definitions
780 *
781 * Second level identifier specifies which debug variable.
782 * Third level identifier specifies which stucture component.
783 */
784#define CTL_DEBUG_NAME 0 /* string: variable name */
785#define CTL_DEBUG_VALUE 1 /* int: variable value */
786#define CTL_DEBUG_MAXID 20
787
788
789#if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 28) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20)
790#error Use the SYSCTL_*() macros and OID_AUTO instead!
791#endif
792
793
794
795__BEGIN_DECLS
796int sysctl(int *, u_int, void *__sized_by(*oldlenp), size_t *oldlenp,
797 void *__sized_by(newlen), size_t newlen);
798int sysctlbyname(const char *, void *__sized_by(*oldlenp), size_t *oldlenp,
799 void *__sized_by(newlen), size_t newlen);
800int sysctlnametomib(const char *, int *__counted_by(*sizep), size_t *sizep);
801__END_DECLS
802
803
804
805#endif /* SYSCTL_DEF_ENABLED */
806
807
808#endif /* !_SYS_SYSCTL_H_ */