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