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

