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