]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2007 Apple 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) 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 | ||
9bccf70c | 100 | #include <sys/appleapiopts.h> |
1c79356b | 101 | #include <sys/cdefs.h> |
1c79356b A |
102 | #include <sys/types.h> |
103 | #include <sys/time.h> | |
91447636 A |
104 | #include <sys/ioctl.h> |
105 | #include <sys/malloc.h> | |
106 | #ifdef BSD_KERNEL_PRIVATE | |
1c79356b A |
107 | #include <sys/tty.h> |
108 | #include <sys/vm.h> | |
91447636 A |
109 | #endif |
110 | #include <sys/proc.h> | |
1c79356b | 111 | __BEGIN_DECLS |
91447636 A |
112 | #ifdef KERNEL |
113 | #include <libkern/libkern.h> | |
114 | #endif | |
1c79356b | 115 | #include <kern/thread.h> |
91447636 | 116 | #include <kern/debug.h> |
1c79356b A |
117 | __END_DECLS |
118 | ||
91447636 | 119 | #ifdef BSD_KERNEL_PRIVATE |
b0d623f7 A |
120 | extern char version[]; /* system version */ |
121 | extern const char copyright[]; /* system copyright */ | |
1c79356b | 122 | |
1c79356b | 123 | |
1c79356b A |
124 | extern int boothowto; /* reboot flags, from console subsystem */ |
125 | extern int show_space; | |
3e170ce0 | 126 | extern int minimalboot; |
5ba3f43e A |
127 | #if CONFIG_EMBEDDED |
128 | extern int darkboot; | |
129 | #endif | |
1c79356b | 130 | |
39037602 A |
131 | extern const int nblkdev; /* number of entries in bdevsw */ |
132 | extern const int nchrdev; /* number of entries in cdevsw */ | |
91447636 | 133 | #endif /* BSD_KERNEL_PRIVATE */ |
9bccf70c | 134 | |
91447636 | 135 | #ifdef KERNEL_PRIVATE |
9bccf70c | 136 | |
91447636 A |
137 | extern int securelevel; /* system security level */ |
138 | extern dev_t rootdev; /* root device */ | |
139 | extern struct vnode *rootvp; /* vnode equivalent to above */ | |
b0d623f7 | 140 | |
91447636 | 141 | #endif /* KERNEL_PRIVATE */ |
1c79356b A |
142 | |
143 | #define SYSINIT(a,b,c,d,e) | |
144 | #define MALLOC_DEFINE(a,b,c) | |
145 | ||
1c79356b A |
146 | #define getenv_int(a,b) (*b = 0) |
147 | #define KASSERT(exp,msg) | |
1c79356b A |
148 | /* |
149 | * General function declarations. | |
150 | */ | |
151 | __BEGIN_DECLS | |
91447636 A |
152 | |
153 | #ifdef BSD_KERNEL_PRIVATE | |
b0d623f7 A |
154 | int einval(void); |
155 | void nullsys(void); | |
156 | int errsys(void); | |
91447636 | 157 | int seltrue(dev_t dev, int which, struct proc *p); |
b0d623f7 | 158 | void ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); |
2d21ac55 | 159 | void realitexpire(struct proc *); |
91447636 | 160 | int hzto(struct timeval *tv); |
91447636 | 161 | void tablefull(const char *); |
91447636 | 162 | int kvprintf(char const *, void (*)(int, void*), void *, int, |
5ba3f43e | 163 | __darwin_va_list) __printflike(1,0); |
2d21ac55 | 164 | void uprintf(const char *, ...) __printflike(1,2); |
91447636 | 165 | int copywithin(void *saddr, void *daddr, size_t len); |
91447636 A |
166 | int64_t fulong(user_addr_t addr); |
167 | int sulong(user_addr_t addr, int64_t longword); | |
168 | uint64_t fuulong(user_addr_t addr); | |
169 | int suulong(user_addr_t addr, uint64_t ulongword); | |
91447636 A |
170 | int clone_system_shared_regions(int shared_regions_active, |
171 | int chain_regions, | |
172 | int base_vnode); | |
2d21ac55 | 173 | extern kern_return_t bsd_exception(int, mach_exception_data_t codes, int); |
91447636 | 174 | extern void bsdinit_task(void); |
2d21ac55 | 175 | extern void unix_syscall_return(int) __dead2; |
91447636 | 176 | void initclocks(void); |
91447636 A |
177 | void startprofclock(struct proc *); |
178 | void stopprofclock(struct proc *); | |
179 | void setstatclockrate(int hzrate); | |
91447636 A |
180 | struct time_value; |
181 | void get_procrustime(struct time_value *tv); | |
91447636 | 182 | void load_init_program(struct proc *p); |
2d21ac55 | 183 | void __pthread_testcancel(int presyscall); |
e2fac8b1 A |
184 | void throttle_info_get_last_io_time(mount_t mp, struct timeval *tv); |
185 | void update_last_io_time(mount_t mp); | |
39037602 | 186 | void throttle_info_end_io(buf_t bp); |
91447636 | 187 | #endif /* BSD_KERNEL_PRIVATE */ |
1c79356b | 188 | |
b0d623f7 A |
189 | #ifdef KERNEL_PRIVATE |
190 | void timeout(void (*)(void *), void *arg, int ticks); | |
39236c6e | 191 | void timeout_with_leeway(void (*)(void *), void *arg, int ticks, int leeway_ticks); |
b0d623f7 A |
192 | void untimeout(void (*)(void *), void *arg); |
193 | int bsd_hostname(char *, int, int*); | |
39037602 A |
194 | int vslock(user_addr_t addr, user_size_t len); |
195 | int vsunlock(user_addr_t addr, user_size_t len, int dirtied); | |
b0d623f7 | 196 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 197 | |
b0d623f7 A |
198 | int nullop(void); |
199 | int nulldev(void); | |
200 | int enoioctl(void); | |
201 | int enosys(void); | |
202 | int enxio(void); | |
203 | int eopnotsupp(void); | |
204 | void *hashinit(int count, int type, u_long *hashmask); | |
205 | void ovbcopy(const void *from, void *to, size_t len); | |
206 | int fubyte(user_addr_t addr); | |
207 | int fuibyte(user_addr_t addr); | |
208 | int subyte(user_addr_t addr, int byte); | |
209 | int suibyte(user_addr_t addr, int byte); | |
210 | long fuword(user_addr_t addr); | |
211 | long fuiword(user_addr_t addr); | |
212 | int suword(user_addr_t addr, long word); | |
213 | int suiword(user_addr_t addr, long word); | |
214 | #define fusize(_a) ((user_size_t)fulong(_a)) | |
215 | #define susize(_a, _s) sulong((_a), (_s)) | |
216 | #define fuptr(a) ((user_addr_t)fulong(_a) | |
217 | #define suptr(_a, _p) sulong((_a), (_p)) | |
218 | int useracc(user_addr_t addr, user_size_t len,int prot); | |
219 | typedef void (*timeout_fcn_t)(void *); | |
220 | void bsd_timeout(void (*)(void *), void *arg, struct timespec * ts); | |
221 | void bsd_untimeout(void (*)(void *), void *arg); | |
222 | void set_fsblocksize(struct vnode *); | |
223 | uint64_t tvtoabstime(struct timeval *); | |
4bd07ac2 | 224 | uint64_t tstoabstime(struct timespec *); |
b0d623f7 | 225 | void *throttle_info_create(void); |
6d2010ae A |
226 | void throttle_info_mount_ref(mount_t mp, void * throttle_info); |
227 | void throttle_info_mount_rel(mount_t mp); | |
b0d623f7 A |
228 | void throttle_info_release(void *throttle_info); |
229 | void throttle_info_update(void *throttle_info, int flags); | |
6d2010ae A |
230 | uint32_t throttle_lowpri_io(int sleep_amount); |
231 | void throttle_set_thread_io_policy(int policy); | |
a39ff7e2 | 232 | int throttle_get_thread_effective_io_policy(void); |
316670eb | 233 | |
6d2010ae | 234 | typedef struct __throttle_info_handle *throttle_info_handle_t; |
316670eb | 235 | int throttle_info_ref_by_mask(uint64_t throttle_mask, throttle_info_handle_t *throttle_info_handle); |
6d2010ae A |
236 | void throttle_info_rel_by_mask(throttle_info_handle_t throttle_info_handle); |
237 | void throttle_info_update_by_mask(void *throttle_info_handle, int flags); | |
3e170ce0 | 238 | void throttle_info_disable_throttle(int devno, boolean_t isfusion); |
316670eb A |
239 | /* |
240 | * 'throttle_info_handle' acquired via 'throttle_info_ref_by_mask' | |
241 | * 'policy' should be specified as either IOPOL_UTILITY or IPOL_THROTTLE, | |
242 | * all other values will be treated as IOPOL_NORMAL (i.e. no throttling) | |
243 | */ | |
244 | int throttle_info_io_will_be_throttled(void *throttle_info_handle, int policy); | |
245 | ||
39037602 A |
246 | #ifdef KERNEL_PRIVATE |
247 | ||
248 | /* returned by throttle_io_will_be_throttled */ | |
249 | #define THROTTLE_DISENGAGED 0 | |
250 | #define THROTTLE_ENGAGED 1 | |
251 | #define THROTTLE_NOW 2 | |
252 | ||
253 | int throttle_io_will_be_throttled(int lowpri_window_msecs, mount_t mp); | |
254 | int throttle_lowpri_window(void) __attribute__((pure)); | |
255 | struct uthread; | |
256 | void throttle_info_reset_window(struct uthread *ut); | |
257 | ||
258 | #endif | |
259 | ||
39236c6e A |
260 | #ifdef XNU_KERNEL_PRIVATE |
261 | void *exec_spawnattr_getmacpolicyinfo(const void *macextensions, const char *policyname, size_t *lenp); | |
262 | #endif | |
263 | ||
264 | #ifdef BSD_KERNEL_PRIVATE | |
265 | ||
d9a64523 | 266 | void sys_override_io_throttle(boolean_t enable_override); |
39236c6e A |
267 | |
268 | #endif /* BSD_KERNEL_PRIVATE */ | |
269 | ||
1c79356b A |
270 | __END_DECLS |
271 | ||
272 | #endif /* !_SYS_SYSTM_H_ */ |