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