]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/systm.h
xnu-1228.15.4.tar.gz
[apple/xnu.git] / bsd / sys / systm.h
1 /*
2 * Copyright (c) 2000-2007 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) 1982, 1988, 1991, 1993
31 * The Regents of the University of California. All rights reserved.
32 * (c) UNIX System Laboratories, Inc.
33 * All or some portions of this file are derived from material licensed
34 * to the University of California by American Telephone and Telegraph
35 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36 * the permission of UNIX System Laboratories, Inc.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 * must display the following acknowledgement:
48 * This product includes software developed by the University of
49 * California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 * may be used to endorse or promote products derived from this software
52 * without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 * @(#)systm.h 8.7 (Berkeley) 3/29/95
67 */
68
69 /*
70 * The `securelevel' variable controls the security level of the system.
71 * It can only be decreased by process 1 (/sbin/init).
72 *
73 * Security levels are as follows:
74 * -1 permannently insecure mode - always run system in level 0 mode.
75 * 0 insecure mode - immutable and append-only flags make be turned off.
76 * All devices may be read or written subject to permission modes.
77 * 1 secure mode - immutable and append-only flags may not be changed;
78 * raw disks of mounted filesystems, /dev/mem, and /dev/kmem are
79 * read-only.
80 * 2 highly secure mode - same as (1) plus raw disks are always
81 * read-only whether mounted or not. This level precludes tampering
82 * with filesystems by unmounting them, but also inhibits running
83 * newfs while the system is secured.
84 *
85 * In normal operation, the system runs in level 0 mode while single user
86 * and in level 1 mode while multiuser. If level 2 mode is desired while
87 * running multiuser, it can be set in the multiuser startup script
88 * (/etc/rc.local) using sysctl(1). If it is desired to run the system
89 * in level 0 mode while multiuser, initialize the variable securelevel
90 * in /sys/kern/kern_sysctl.c to -1. Note that it is NOT initialized to
91 * zero as that would allow the vmunix binary to be patched to -1.
92 * Without initialization, securelevel loads in the BSS area which only
93 * comes into existence when the kernel is loaded and hence cannot be
94 * patched by a stalking hacker.
95 */
96
97 #ifndef _SYS_SYSTM_H_
98 #define _SYS_SYSTM_H_
99
100 #include <sys/appleapiopts.h>
101 #include <sys/cdefs.h>
102 #include <sys/types.h>
103 #include <sys/time.h>
104 #include <sys/ioctl.h>
105 #include <sys/malloc.h>
106 #ifdef BSD_KERNEL_PRIVATE
107 #include <sys/tty.h>
108 #include <sys/vm.h>
109 #endif
110 #include <sys/proc.h>
111 __BEGIN_DECLS
112 #ifdef KERNEL
113 #include <libkern/libkern.h>
114 #endif
115 #include <kern/thread.h>
116 #include <kern/debug.h>
117 __END_DECLS
118
119 #ifdef BSD_KERNEL_PRIVATE
120 extern char version[]; /* system version */
121 extern char copyright[]; /* system copyright */
122
123
124 extern int boothowto; /* reboot flags, from console subsystem */
125 extern int show_space;
126
127 extern int nblkdev; /* number of entries in bdevsw */
128 extern int nchrdev; /* number of entries in cdevsw */
129 #endif /* BSD_KERNEL_PRIVATE */
130
131 #ifdef KERNEL_PRIVATE
132 #define NO_FUNNEL 0
133 #define KERNEL_FUNNEL 1
134
135 extern int securelevel; /* system security level */
136 extern dev_t rootdev; /* root device */
137 extern struct vnode *rootvp; /* vnode equivalent to above */
138 extern funnel_t * kernel_flock;
139
140 #endif /* KERNEL_PRIVATE */
141
142 #define SYSINIT(a,b,c,d,e)
143 #define MALLOC_DEFINE(a,b,c)
144
145 #define getenv_int(a,b) (*b = 0)
146 #define KASSERT(exp,msg)
147
148 /*
149 * General function declarations.
150 */
151 __BEGIN_DECLS
152 int nullop(void);
153 int nulldev(void);
154 int enoioctl(void);
155 int enosys(void);
156 int errsys(void);
157 void nullsys(void);
158 int enxio(void);
159 int eopnotsupp(void);
160 int einval(void);
161
162 #ifdef BSD_KERNEL_PRIVATE
163 int seltrue(dev_t dev, int which, struct proc *p);
164 void ttyprintf(struct tty *, const char *, ...);
165 void realitexpire(struct proc *);
166 int hzto(struct timeval *tv);
167 #endif /* __APPLE_API_UNSTABLE */
168
169 void *hashinit(int count, int type, u_long *hashmask);
170
171 void tablefull(const char *);
172
173 int kvprintf(char const *, void (*)(int, void*), void *, int,
174 __darwin_va_list);
175
176 void uprintf(const char *, ...) __printflike(1,2);
177
178
179 void ovbcopy(const void *from, void *to, size_t len);
180 int copywithin(void *saddr, void *daddr, size_t len);
181
182 int fubyte(user_addr_t addr);
183 int fuibyte(user_addr_t addr);
184 int subyte(user_addr_t addr, int byte);
185 int suibyte(user_addr_t addr, int byte);
186 long fuword(user_addr_t addr);
187 long fuiword(user_addr_t addr);
188 int suword(user_addr_t addr, long word);
189 int suiword(user_addr_t addr, long word);
190 int64_t fulong(user_addr_t addr);
191 int sulong(user_addr_t addr, int64_t longword);
192 uint64_t fuulong(user_addr_t addr);
193 int suulong(user_addr_t addr, uint64_t ulongword);
194 #define fusize(_a) ((user_size_t)fulong(_a))
195 #define susize(_a, _s) sulong((_a), (_s))
196 #define fuptr(a) ((user_addr_t)fulong(_a)
197 #define suptr(_a, _p) sulong((_a), (_p))
198 int useracc(user_addr_t addr, user_size_t len,int prot);
199
200 typedef void (*timeout_fcn_t)(void *);
201 #ifdef KERNEL_PRIVATE
202 void timeout(void (*)(void *), void *arg, int ticks);
203 void untimeout(void (*)(void *), void *arg);
204 #endif /* KERNEL_PRIVATE */
205 void bsd_timeout(void (*)(void *), void *arg, struct timespec * ts);
206 void bsd_untimeout(void (*)(void *), void *arg);
207
208 void set_fsblocksize(struct vnode *);
209
210 #ifdef BSD_KERNEL_PRIVATE
211 int vslock(user_addr_t addr, user_size_t len);
212 int vsunlock(user_addr_t addr, user_size_t len, int dirtied);
213 int clone_system_shared_regions(int shared_regions_active,
214 int chain_regions,
215 int base_vnode);
216
217 extern kern_return_t bsd_exception(int, mach_exception_data_t codes, int);
218 extern void bsdinit_task(void);
219 extern void unix_syscall_return(int) __dead2;
220
221 void initclocks(void);
222
223 void startprofclock(struct proc *);
224 void stopprofclock(struct proc *);
225 void setstatclockrate(int hzrate);
226
227 struct time_value;
228 void get_procrustime(struct time_value *tv);
229
230 void load_init_program(struct proc *p);
231 void __pthread_testcancel(int presyscall);
232 void syscall_exit_funnelcheck(void);
233 void throttle_info_get_last_io_time(mount_t mp, struct timeval *tv);
234 void update_last_io_time(mount_t mp);
235 #endif /* BSD_KERNEL_PRIVATE */
236
237
238 __END_DECLS
239
240 #endif /* !_SYS_SYSTM_H_ */