aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPasha <pasha@member.fsf.org>2024-02-20 18:49:50 +0000
committerPasha <pasha@member.fsf.org>2024-02-20 18:49:50 +0000
commit5e0b8d508ed51004bd836384293be00950ee62c9 (patch)
treee3f16b1aa8b7177032ce3ec429fbad2b1d92a876 /include
downloadgnumach-riscv-5e0b8d508ed51004bd836384293be00950ee62c9.tar.gz
gnumach-riscv-5e0b8d508ed51004bd836384293be00950ee62c9.tar.bz2
init gnumach copy
Diffstat (limited to 'include')
-rw-r--r--include/alloca.h25
-rw-r--r--include/cache.h25
-rw-r--r--include/device/audio_status.h164
-rw-r--r--include/device/bpf.h244
-rw-r--r--include/device/device.defs183
-rw-r--r--include/device/device_reply.defs110
-rw-r--r--include/device/device_request.defs95
-rw-r--r--include/device/device_types.defs92
-rw-r--r--include/device/device_types.h148
-rw-r--r--include/device/disk_status.h318
-rw-r--r--include/device/input.h106
-rw-r--r--include/device/net_status.h201
-rw-r--r--include/device/notify.defs36
-rw-r--r--include/device/notify.h34
-rw-r--r--include/device/tape_status.h140
-rw-r--r--include/device/tty_status.h134
-rw-r--r--include/inttypes.h64
-rw-r--r--include/mach/alert.h37
-rw-r--r--include/mach/boolean.h63
-rw-r--r--include/mach/boot.h93
-rw-r--r--include/mach/default_pager.defs65
-rw-r--r--include/mach/default_pager_types.defs53
-rw-r--r--include/mach/default_pager_types.h59
-rw-r--r--include/mach/error.h93
-rw-r--r--include/mach/exc.defs47
-rw-r--r--include/mach/exception.h58
-rw-r--r--include/mach/exec/a.out.h68
-rw-r--r--include/mach/exec/elf.h364
-rw-r--r--include/mach/exec/exec.h130
-rw-r--r--include/mach/experimental.defs15
-rw-r--r--include/mach/gnumach.defs217
-rw-r--r--include/mach/host_info.h90
-rw-r--r--include/mach/inline.h27
-rw-r--r--include/mach/kern_return.h166
-rw-r--r--include/mach/mach.defs724
-rw-r--r--include/mach/mach4.defs131
-rw-r--r--include/mach/mach_host.defs388
-rw-r--r--include/mach/mach_param.h39
-rw-r--r--include/mach/mach_port.defs360
-rw-r--r--include/mach/mach_traps.h43
-rw-r--r--include/mach/mach_types.defs299
-rw-r--r--include/mach/mach_types.h90
-rw-r--r--include/mach/machine.h268
-rw-r--r--include/mach/macro_help.h18
-rw-r--r--include/mach/memory_object.defs333
-rw-r--r--include/mach/memory_object.h90
-rw-r--r--include/mach/memory_object_default.defs118
-rw-r--r--include/mach/message.h540
-rw-r--r--include/mach/mig_errors.h89
-rw-r--r--include/mach/mig_support.h57
-rw-r--r--include/mach/notify.defs112
-rw-r--r--include/mach/notify.h92
-rw-r--r--include/mach/pc_sample.h66
-rw-r--r--include/mach/policy.h45
-rw-r--r--include/mach/port.h159
-rw-r--r--include/mach/processor_info.h104
-rw-r--r--include/mach/profil.h212
-rw-r--r--include/mach/profilparam.h62
-rw-r--r--include/mach/std_types.defs101
-rw-r--r--include/mach/std_types.h44
-rw-r--r--include/mach/syscall_sw.h121
-rw-r--r--include/mach/task_info.h126
-rw-r--r--include/mach/task_notify.defs59
-rw-r--r--include/mach/task_special_ports.h66
-rw-r--r--include/mach/thread_info.h124
-rw-r--r--include/mach/thread_special_ports.h59
-rw-r--r--include/mach/thread_status.h55
-rw-r--r--include/mach/thread_switch.h40
-rw-r--r--include/mach/time_value.h201
-rw-r--r--include/mach/version.h73
-rw-r--r--include/mach/vm_attributes.h63
-rw-r--r--include/mach/vm_cache_statistics.h41
-rw-r--r--include/mach/vm_inherit.h55
-rw-r--r--include/mach/vm_param.h102
-rw-r--r--include/mach/vm_prot.h79
-rw-r--r--include/mach/vm_statistics.h75
-rw-r--r--include/mach/vm_sync.h45
-rw-r--r--include/mach/vm_wire.h30
-rw-r--r--include/mach/xen.h95
-rw-r--r--include/mach_debug/hash_info.h41
-rw-r--r--include/mach_debug/mach_debug.defs228
-rw-r--r--include/mach_debug/mach_debug_types.defs121
-rw-r--r--include/mach_debug/mach_debug_types.h52
-rw-r--r--include/mach_debug/slab_info.h56
-rw-r--r--include/mach_debug/vm_info.h143
-rw-r--r--include/string.h55
-rw-r--r--include/sys/reboot.h135
-rw-r--r--include/sys/types.h88
88 files changed, 10776 insertions, 0 deletions
diff --git a/include/alloca.h b/include/alloca.h
new file mode 100644
index 0000000..29081ca
--- /dev/null
+++ b/include/alloca.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL). All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
+ * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
+ * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * CSL requests users of this software to return to csl-dist@cs.utah.edu any
+ * improvements that they make and grant CSL redistribution rights.
+ *
+ * Author: Bryan Ford, University of Utah CSL
+ */
+#ifndef _MACH_ALLOCA_H_
+#define _MACH_ALLOCA_H_
+
+#define alloca(size) __builtin_alloca(size)
+
+#endif /* _MACH_ALLOCA_H_ */
diff --git a/include/cache.h b/include/cache.h
new file mode 100644
index 0000000..6260366
--- /dev/null
+++ b/include/cache.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2013 Free Software Foundation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _MACH_CACHE_H_
+#define _MACH_CACHE_H_
+
+/* This macro can be used to align statically allocated objects so
+ that they start at a cache line. */
+#define __cacheline_aligned __attribute__((aligned(1 << CPU_L1_SHIFT)))
+
+#endif /* _MACH_CACHE_H_ */
diff --git a/include/device/audio_status.h b/include/device/audio_status.h
new file mode 100644
index 0000000..7effe99
--- /dev/null
+++ b/include/device/audio_status.h
@@ -0,0 +1,164 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Copyright (c) 1991, 1992 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. The name of the Laboratory may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEVICE_AUDIO_STATUS_H_
+#define _DEVICE_AUDIO_STATUS_H_
+
+/*
+ * Access to ADC devices, such as the AMD 79C30A/32A.
+ */
+
+/*
+ * Programmable gains, see tables in device drivers
+ * for detailed mapping to device specifics.
+ */
+#define AUDIO_MIN_GAIN (0)
+#define AUDIO_MAX_GAIN (255)
+
+/*
+ * Encoding of audio samples
+ */
+#define AUDIO_ENCODING_ULAW (1)
+#define AUDIO_ENCODING_ALAW (2)
+
+/*
+ * Selection of input/output jack
+ */
+#define AUDIO_MIKE 1
+
+#define AUDIO_SPEAKER 1
+#define AUDIO_HEADPHONE 2
+
+/*
+ * Programming information from/to user application.
+ * Only portions of this might be available on any given chip.
+ */
+struct audio_prinfo {
+ unsigned int sample_rate;
+ unsigned int channels;
+ unsigned int precision;
+ unsigned int encoding;
+ unsigned int gain;
+ unsigned int port; /* input/output jack */
+ unsigned int seek; /* BSD extension */
+ unsigned int ispare[3];
+ unsigned int samples;
+ unsigned int eof;
+
+ unsigned char pause;
+ unsigned char error;
+ unsigned char waiting;
+ unsigned char cspare[3];
+ unsigned char open;
+ unsigned char active;
+
+};
+
+struct audio_info {
+ struct audio_prinfo play;
+ struct audio_prinfo record;
+ unsigned int monitor_gain;
+ /* BSD extensions */
+ unsigned int blocksize; /* input blocking threshold */
+ unsigned int hiwat; /* output high water mark */
+ unsigned int lowat; /* output low water mark */
+ unsigned int backlog; /* samples of output backlog to gen. */
+};
+
+typedef struct audio_info audio_info_t;
+
+#define AUDIO_INITINFO(p)\
+ (void)memset((void *)(p), 0xff, sizeof(struct audio_info))
+
+#define AUDIO_GETINFO _IOR('A', 21, audio_info_t)
+#define AUDIO_SETINFO _IOWR('A', 22, audio_info_t)
+#define AUDIO_DRAIN _IO('A', 23)
+#define AUDIO_FLUSH _IO('A', 24)
+#define AUDIO_WSEEK _IOR('A', 25, unsigned int)
+#define AUDIO_RERROR _IOR('A', 26, int)
+#define AUDIO_WERROR _IOR('A', 27, int)
+
+/*
+ * Low level interface to the amd79c30.
+ * Internal registers of the MAP block,
+ * the Main Audio Processor.
+ */
+struct mapreg {
+ unsigned short mr_x[8];
+ unsigned short mr_r[8];
+ unsigned short mr_gx;
+ unsigned short mr_gr;
+ unsigned short mr_ger;
+ unsigned short mr_stgr;
+ unsigned short mr_ftgr;
+ unsigned short mr_atgr;
+ unsigned char mr_mmr1;
+ unsigned char mr_mmr2;
+};
+
+#define AUDIO_GETMAP _IOR('A', 27, struct mapreg)
+#define AUDIO_SETMAP _IOW('A', 28, struct mapreg)
+
+/*
+ * Compatibility with Sun interface
+ */
+struct audio_ioctl {
+ short control;
+ unsigned char data[46];
+};
+
+#define AUDIOGETREG _IOWR('i',1,struct audio_ioctl)
+#define AUDIOSETREG _IOW('i',2,struct audio_ioctl)
+
+#endif /* _DEVICE_AUDIO_STATUS_H_ */
diff --git a/include/device/bpf.h b/include/device/bpf.h
new file mode 100644
index 0000000..abc2d77
--- /dev/null
+++ b/include/device/bpf.h
@@ -0,0 +1,244 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+/*
+ * Berkeley Packet Filter Definitions from Berkeley
+ */
+
+/*-
+ * Copyright (c) 1990-1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)bpf.h 7.1 (Berkeley) 5/7/91
+ *
+ */
+
+#ifndef _DEVICE_BPF_H_
+#define _DEVICE_BPF_H_
+
+/*
+ * Alignment macros. BPF_WORDALIGN rounds up to the next
+ * even multiple of BPF_ALIGNMENT.
+ */
+#define BPF_ALIGNMENT sizeof(int)
+#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
+
+/*
+ * Struct return by BIOCVERSION. This represents the version number of
+ * the filter language described by the instruction encodings below.
+ * bpf understands a program iff kernel_major == filter_major &&
+ * kernel_minor >= filter_minor, that is, if the value returned by the
+ * running kernel has the same major number and a minor number equal
+ * equal to or less than the filter being downloaded. Otherwise, the
+ * results are undefined, meaning an error may be returned or packets
+ * may be accepted haphazardly.
+ * It has nothing to do with the source code version.
+ */
+struct bpf_version {
+ unsigned short bv_major;
+ unsigned short bv_minor;
+};
+/* Current version number. */
+#define BPF_MAJOR_VERSION 1
+#define BPF_MINOR_VERSION 1
+
+/*
+ * Data-link level type codes.
+ * Currently, only DLT_EN10MB and DLT_SLIP are supported.
+ */
+#define DLT_NULL 0 /* no link-layer encapsulation */
+#define DLT_EN10MB 1 /* Ethernet (10Mb) */
+#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
+#define DLT_AX25 3 /* Amateur Radio AX.25 */
+#define DLT_PRONET 4 /* Proteon ProNET Token Ring */
+#define DLT_CHAOS 5 /* Chaos */
+#define DLT_IEEE802 6 /* IEEE 802 Networks */
+#define DLT_ARCNET 7 /* ARCNET */
+#define DLT_SLIP 8 /* Serial Line IP */
+#define DLT_PPP 9 /* Point-to-point Protocol */
+#define DLT_FDDI 10 /* FDDI */
+
+/*
+ * The instruction encondings.
+ */
+
+/* Magic number and flags for the first instruction */
+#define BPF_BEGIN NETF_BPF
+#define BPF_IN NETF_IN
+#define BPF_OUT NETF_OUT
+
+/* instruction classes */
+#define BPF_CLASS(code) ((code) & 0x07)
+#define BPF_LD 0x00
+#define BPF_LDX 0x01
+#define BPF_ST 0x02
+#define BPF_STX 0x03
+#define BPF_ALU 0x04
+#define BPF_JMP 0x05
+#define BPF_RET 0x06
+#define BPF_MISC 0x07
+
+/* ld/ldx fields */
+#define BPF_SIZE(code) ((code) & 0x18)
+#define BPF_W 0x00
+#define BPF_H 0x08
+#define BPF_B 0x10
+#define BPF_MODE(code) ((code) & 0xe0)
+#define BPF_IMM 0x00
+#define BPF_ABS 0x20
+#define BPF_IND 0x40
+#define BPF_MEM 0x60
+#define BPF_LEN 0x80
+#define BPF_MSH 0xa0
+
+/* alu/jmp fields */
+#define BPF_OP(code) ((code) & 0xf0)
+#define BPF_ADD 0x00
+#define BPF_SUB 0x10
+#define BPF_MUL 0x20
+#define BPF_DIV 0x30
+#define BPF_OR 0x40
+#define BPF_AND 0x50
+#define BPF_LSH 0x60
+#define BPF_RSH 0x70
+#define BPF_NEG 0x80
+#define BPF_JA 0x00
+#define BPF_JEQ 0x10
+#define BPF_JGT 0x20
+#define BPF_JGE 0x30
+#define BPF_JSET 0x40
+#define BPF_CKMATCH_IMM 0x50
+#define BPF_SRC(code) ((code) & 0x08)
+#define BPF_K 0x00
+#define BPF_X 0x08
+
+/* ret - BPF_K and BPF_X also apply */
+#define BPF_RVAL(code) ((code) & 0x38)
+#define BPF_A 0x10
+#define BPF_MATCH_IMM 0x18
+#define BPF_MATCH_DATA 0x20
+
+/* misc */
+#define BPF_MISCOP(code) ((code) & 0xf8)
+#define BPF_TAX 0x00
+#define BPF_TXA 0x80
+#define BPF_KEY 0x10
+#define BPF_REG_DATA 0x18
+#define BPF_POSTPONE 0x20
+
+/*
+ * The instruction data structure.
+ */
+struct bpf_insn {
+ unsigned short code;
+ unsigned char jt;
+ unsigned char jf;
+ int k;
+};
+typedef struct bpf_insn *bpf_insn_t;
+
+/*
+ * largest bpf program size
+ */
+#define NET_MAX_BPF ((NET_MAX_FILTER*sizeof(filter_t))/sizeof(struct bpf_insn))
+
+/*
+ * Macros for insn array initializers.
+ */
+#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
+#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
+#define BPF_RETMATCH(code, k, nkey) { (unsigned short)(code), nkey, 0, k }
+
+#define BPF_INSN_STMT(pc, c, n) {\
+ (pc)->code = (c); \
+ (pc)->jt = (pc)->jf = 0; \
+ (pc)->k = (n); \
+ (pc)++; \
+}
+
+#define BPF_INSN_JUMP(pc, c, n, jtrue, jfalse) {\
+ (pc)->code = (c); \
+ (pc)->jt = (jtrue); \
+ (pc)->jf = (jfalse); \
+ (pc)->k = (n); \
+ (pc)++; \
+}
+
+#define BPF_INSN_RETMATCH(pc, c, n, nkey) {\
+ (pc)->code = (c); \
+ (pc)->jt = (nkey); \
+ (pc)->jf = 0; \
+ (pc)->k = (n); \
+ (pc)++; \
+}
+
+/*
+ * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
+ */
+#define BPF_MEMWORDS 16
+
+/*
+ * Link level header can be accessed by adding BPF_DLBASE to an offset.
+ */
+#define BPF_DLBASE (1<<30)
+
+#define BPF_BYTES(n) ((n) * sizeof (struct bpf_insn))
+#define BPF_BYTES2LEN(n) ((n) / sizeof (struct bpf_insn))
+#define BPF_INSN_EQ(p,q) ((p)->code == (q)->code && \
+ (p)->jt == (q)->jt && \
+ (p)->jf == (q)->jf && \
+ (p)->k == (q)->k)
+
+#endif /* _DEVICE_BPF_H_ */
diff --git a/include/device/device.defs b/include/device/device.defs
new file mode 100644
index 0000000..7f31612
--- /dev/null
+++ b/include/device/device.defs
@@ -0,0 +1,183 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: device/device.defs
+ * Author: Douglas Orr
+ * Feb 10, 1988
+ * Abstract:
+ * Mach device support. Mach devices are accessed through
+ * block and character device interfaces to the kernel.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif
+ device 2800;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+#include <device/device_types.defs>
+
+serverprefix ds_;
+
+type reply_port_t = MACH_MSG_TYPE_MAKE_SEND_ONCE | polymorphic
+ ctype: mach_port_t
+#ifndef KERNEL_SERVER
+#ifdef MACH_PAYLOAD_TO_PORT
+ intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT
+#endif /* MACH_PAYLOAD_TO_PORT */
+#endif /* KERNEL_SERVER */
+;
+
+/* Deprecated in favor of device_open_new. */
+routine device_open(
+ master_port : mach_port_t;
+ sreplyport reply_port : reply_port_t;
+ mode : dev_mode_t;
+ name : dev_name_t;
+ out device : device_t =
+ MACH_MSG_TYPE_PORT_SEND
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ outtran: mach_port_t convert_device_to_port(device_t)
+#else
+#ifdef DEVICE_OUTTRAN
+ outtran: DEVICE_OUTTRAN
+#endif
+#endif /* KERNEL_SERVER */
+ );
+
+routine device_close(
+ device : device_t
+ );
+
+routine device_write(
+ device : device_t;
+ sreplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in data : io_buf_ptr_t;
+ out bytes_written : int
+ );
+
+routine device_write_inband(
+ device : device_t;
+ sreplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in data : io_buf_ptr_inband_t;
+ out bytes_written : int
+ );
+
+routine device_read(
+ device : device_t;
+ sreplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in bytes_wanted : int;
+ out data : io_buf_ptr_t, dealloc
+ );
+
+routine device_read_inband(
+ device : device_t;
+ sreplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in bytes_wanted : int;
+ out data : io_buf_ptr_inband_t
+ );
+
+#if defined(KERNEL_SERVER) || defined(DEVICE_ENABLE_DEVICE_OPEN_NEW)
+routine device_open_new(
+ master_port : mach_port_t;
+ sreplyport reply_port : reply_port_t;
+ mode : dev_mode_t;
+ name : new_dev_name_t;
+ out device : device_t =
+ MACH_MSG_TYPE_PORT_SEND
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ outtran: mach_port_t convert_device_to_port(device_t)
+#else
+#ifdef DEVICE_OUTTRAN
+ outtran: DEVICE_OUTTRAN
+#endif
+#endif /* KERNEL_SERVER */
+ );
+#else
+skip; /* old xxx_device_set_status */
+#endif
+
+skip; /* old xxx_device_get_status */
+skip; /* old xxx_device_set_filter*/
+
+routine device_map(
+ device : device_t;
+ in prot : vm_prot_t;
+ in offset : vm_offset_t;
+ in size : vm_size_t;
+ out pager : memory_object_t;
+ in unmap : int
+ );
+
+routine device_set_status(
+ device : device_t;
+ in flavor : dev_flavor_t;
+ in status : dev_status_t
+ );
+
+routine device_get_status(
+ device : device_t;
+ in flavor : dev_flavor_t;
+ out status : dev_status_t, CountInOut
+ );
+
+routine device_set_filter(
+ device : device_t;
+ in receive_port : mach_port_send_t;
+ in priority : int;
+ in filter : filter_array_t
+ );
+
+routine device_intr_register(
+ device : device_t;
+ in id : int;
+ in flags : int;
+ in receive_port : mach_port_send_t
+ );
+
+/*
+ * Acknowledge the specified interrupt notification.
+ */
+/*
+ * When an IRQ happens and an intr notification is thus sent, the IRQ line
+ * is kept disabled until the notification is acknowledged with this RPC
+ */
+routine device_intr_ack(
+ device : device_t;
+ in receive_port : mach_port_send_t);
+
diff --git a/include/device/device_reply.defs b/include/device/device_reply.defs
new file mode 100644
index 0000000..5a32507
--- /dev/null
+++ b/include/device/device_reply.defs
@@ -0,0 +1,110 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: 8/89
+ *
+ * Reply-only side of device interface.
+ */
+
+subsystem
+#if KERNEL_USER
+ KernelUser
+#endif
+ device_reply 2900;
+ /* to match reply numbers for device.defs */
+
+/*
+ * Device_write_reply (only user of this data type) deallocates
+ * the data.
+ */
+
+
+#include <mach/std_types.defs>
+#include <device/device_types.defs>
+
+userprefix ds_;
+
+#if SEQNOS
+serverprefix seqnos_;
+serverdemux seqnos_device_reply_server;
+#endif /* SEQNOS */
+
+type reply_port_t = polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE
+ ctype: mach_port_t
+#ifndef KERNEL_SERVER
+#ifdef MACH_PAYLOAD_TO_PORT
+ intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT
+#endif /* MACH_PAYLOAD_TO_PORT */
+#endif /* KERNEL_SERVER */
+;
+
+simpleroutine device_open_reply(
+ reply_port : reply_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ in return_code : kern_return_t;
+ in device_port : mach_port_make_send_t
+ );
+
+skip; /* device_close */
+
+simpleroutine device_write_reply(
+ reply_port : reply_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ in return_code : kern_return_t;
+ in bytes_written : int
+ );
+
+simpleroutine device_write_reply_inband(
+ reply_port : reply_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ in return_code : kern_return_t;
+ in bytes_written : int
+ );
+
+simpleroutine device_read_reply(
+ reply_port : reply_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ in return_code : kern_return_t;
+ in data : io_buf_ptr_t, dealloc
+ );
+
+simpleroutine device_read_reply_inband(
+ reply_port : reply_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ in return_code : kern_return_t;
+ in data : io_buf_ptr_inband_t
+ );
diff --git a/include/device/device_request.defs b/include/device/device_request.defs
new file mode 100644
index 0000000..a8af3a8
--- /dev/null
+++ b/include/device/device_request.defs
@@ -0,0 +1,95 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: 8/89
+ *
+ * Request-only side of device interface.
+ */
+
+subsystem device_request 2800; /* to match device.defs */
+
+#include <device/device_types.defs>
+
+serverprefix ds_;
+
+type reply_port_t = MACH_MSG_TYPE_MAKE_SEND_ONCE
+ ctype: mach_port_t
+#ifndef KERNEL_SERVER
+#ifdef MACH_PAYLOAD_TO_PORT
+ intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT
+#endif /* MACH_PAYLOAD_TO_PORT */
+#endif /* KERNEL_SERVER */
+;
+
+/* Deprecated in favor of device_open_new_request. */
+simpleroutine device_open_request(
+ device_server_port : mach_port_t;
+ ureplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in name : dev_name_t
+ );
+
+skip; /* device_close */
+
+simpleroutine device_write_request(
+ device : device_t;
+ ureplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in data : io_buf_ptr_t
+ );
+
+simpleroutine device_write_request_inband(
+ device : device_t;
+ ureplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in data : io_buf_ptr_inband_t
+ );
+
+simpleroutine device_read_request(
+ device : device_t;
+ ureplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in bytes_wanted : int
+ );
+
+simpleroutine device_read_request_inband(
+ device : device_t;
+ ureplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in recnum : recnum_t;
+ in bytes_wanted : int
+ );
+
+simpleroutine device_open_new_request(
+ device_server_port : mach_port_t;
+ ureplyport reply_port : reply_port_t;
+ in mode : dev_mode_t;
+ in name : new_dev_name_t
+ );
diff --git a/include/device/device_types.defs b/include/device/device_types.defs
new file mode 100644
index 0000000..c74bff5
--- /dev/null
+++ b/include/device/device_types.defs
@@ -0,0 +1,92 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: 3/89
+ *
+ * Common definitions for device interface types.
+ */
+
+#ifndef _DEVICE_DEVICE_TYPES_DEFS_
+#define _DEVICE_DEVICE_TYPES_DEFS_
+
+/*
+ * Basic types
+ */
+
+#include <mach/std_types.defs>
+
+#ifdef DEVICE_IMPORTS
+DEVICE_IMPORTS
+#endif
+
+type rpc_recnum_t = rpc_long_natural_t;
+type recnum_t = rpc_recnum_t
+#if defined(KERNEL_SERVER)
+ intran: recnum_t convert_long_natural_from_user(rpc_recnum_t)
+ outtran: rpc_recnum_t convert_long_natural_to_user(recnum_t)
+#elif defined(KERNEL_USER)
+ ctype: rpc_recnum_t
+#endif
+ ;
+
+type dev_mode_t = uint32_t;
+type dev_flavor_t = uint32_t;
+type dev_name_t = (MACH_MSG_TYPE_STRING_C, 8*128);
+type new_dev_name_t = c_string[128]
+ ctype: dev_name_t;
+type dev_status_t = array[*:1024] of int;
+type io_buf_ptr_t = ^array[] of MACH_MSG_TYPE_INTEGER_8;
+type io_buf_ptr_inband_t= array[*:128] of char;
+type filter_t = short;
+type filter_array_t = array[*:128] of filter_t;
+
+type device_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: device_t dev_port_lookup(mach_port_t)
+ outtran: mach_port_t convert_device_to_port(device_t)
+ destructor: device_deallocate(device_t)
+#else /* KERNEL_SERVER */
+#ifdef DEVICE_INTRAN
+ intran: DEVICE_INTRAN
+#endif
+#ifdef DEVICE_INTRAN_PAYLOAD
+ intranpayload: DEVICE_INTRAN_PAYLOAD
+#endif
+#ifdef DEVICE_OUTTRAN
+ outtran: DEVICE_OUTTRAN
+#endif
+#ifdef DEVICE_DESTRUCTOR
+ destructor: DEVICE_DESTRUCTOR
+#endif
+#endif /* KERNEL_SERVER */
+ ;
+
+import <device/device_types.h>;
+import <device/net_status.h>;
+
+#endif /* _DEVICE_DEVICE_TYPES_DEFS_ */
diff --git a/include/device/device_types.h b/include/device/device_types.h
new file mode 100644
index 0000000..583d9e0
--- /dev/null
+++ b/include/device/device_types.h
@@ -0,0 +1,148 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: 3/89
+ */
+
+#ifndef DEVICE_TYPES_H
+#define DEVICE_TYPES_H
+
+/*
+ * Types for device interface.
+ */
+#include <mach/std_types.h>
+
+#ifdef MACH_KERNEL
+/*
+ * Get kernel-only type definitions.
+ */
+#include <device/device_types_kernel.h>
+
+#else /* MACH_KERNEL */
+/*
+ * Device handle.
+ */
+typedef mach_port_t device_t;
+
+#endif /* MACH_KERNEL */
+
+/*
+ * Device name string
+ */
+typedef char dev_name_t[128]; /* must match device_types.defs */
+typedef const char *const_dev_name_t;
+
+/*
+ * Mode for open/read/write
+ */
+typedef unsigned int dev_mode_t;
+#define D_READ 0x1 /* read */
+#define D_WRITE 0x2 /* write */
+#define D_NODELAY 0x4 /* no delay on open */
+#define D_NOWAIT 0x8 /* do not wait if data not available */
+
+/*
+ * IO buffer - out-of-line array of characters.
+ */
+typedef char * io_buf_ptr_t;
+typedef const char * const_io_buf_ptr_t;
+
+/*
+ * IO buffer - in-line array of characters.
+ */
+#define IO_INBAND_MAX (128) /* must match device_types.defs */
+typedef char io_buf_ptr_inband_t[IO_INBAND_MAX];
+typedef const char *const_io_buf_ptr_inband_t;
+
+/*
+ * IO buffer vector - for scatter/gather IO.
+ */
+typedef struct {
+ vm_offset_t data;
+ vm_size_t count;
+} io_buf_vec_t;
+typedef struct {
+ rpc_vm_offset_t data;
+ rpc_vm_size_t count;
+} rpc_io_buf_vec_t;
+
+/*
+ * Record number for random-access devices
+ */
+typedef long_natural_t recnum_t;
+typedef rpc_long_natural_t rpc_recnum_t;
+
+/*
+ * Flavors of set/get statuses
+ */
+typedef unsigned int dev_flavor_t;
+
+/*
+ * Generic array for get/set status
+ */
+typedef int *dev_status_t; /* Variable-length array of integers */
+#define DEV_STATUS_MAX (1024) /* Maximum array size */
+
+typedef int dev_status_data_t[DEV_STATUS_MAX];
+
+/*
+ * Mandatory get/set status operations
+ */
+
+/* size a device: op code and indexes for returned values */
+#define DEV_GET_SIZE 0
+# define DEV_GET_SIZE_DEVICE_SIZE 0 /* 0 if unknown */
+# define DEV_GET_SIZE_RECORD_SIZE 1 /* 1 if sequential */
+#define DEV_GET_SIZE_COUNT 2
+/* size a device in record numbers, not bytes */
+#define DEV_GET_RECORDS 1
+# define DEV_GET_RECORDS_DEVICE_RECORDS 0 /* 0 if unknown */
+# define DEV_GET_RECORDS_RECORD_SIZE 1 /* 1 if sequential */
+#define DEV_GET_RECORDS_COUNT 2
+
+/*
+ * Device error codes
+ */
+typedef int io_return_t;
+
+#define D_IO_QUEUED (-1) /* IO queued - do not return result */
+#define D_SUCCESS 0
+
+#define D_IO_ERROR 2500 /* hardware IO error */
+#define D_WOULD_BLOCK 2501 /* would block, but D_NOWAIT set */
+#define D_NO_SUCH_DEVICE 2502 /* no such device */
+#define D_ALREADY_OPEN 2503 /* exclusive-use device already open */
+#define D_DEVICE_DOWN 2504 /* device has been shut down */
+#define D_INVALID_OPERATION 2505 /* bad operation for device */
+#define D_INVALID_RECNUM 2506 /* invalid record (block) number */
+#define D_INVALID_SIZE 2507 /* invalid IO size */
+#define D_NO_MEMORY 2508 /* memory allocation failure */
+#define D_READ_ONLY 2509 /* device cannot be written to */
+
+void device_deallocate(device_t);
+
+#endif /* DEVICE_TYPES_H */
diff --git a/include/device/disk_status.h b/include/device/disk_status.h
new file mode 100644
index 0000000..a6ed106
--- /dev/null
+++ b/include/device/disk_status.h
@@ -0,0 +1,318 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Copyright (c) 1987, 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. The name of the Laboratory may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)disklabel.h 7.10 (Berkeley) 6/27/88
+ */
+
+#ifndef _DISK_STATUS_H_
+#define _DISK_STATUS_H_
+
+/*
+ * Each disk has a label which includes information about the hardware
+ * disk geometry, filesystem partitions, and drive specific information.
+ * The label is in block 0 or 1, possibly offset from the beginning
+ * to leave room for a bootstrap, etc.
+ */
+
+#define LABELSECTOR 0 /* sector containing label */
+#define LABELOFFSET 64 /* offset of label in sector */
+#define DISKMAGIC ((unsigned int) 0x82564557U) /* The disk magic number */
+#ifndef MAXPARTITIONS
+#define MAXPARTITIONS 8
+#endif
+
+
+#ifndef LOCORE
+struct disklabel {
+ unsigned int d_magic; /* the magic number */
+ short d_type; /* drive type */
+ short d_subtype; /* controller/d_type specific */
+ char d_typename[16]; /* type name, e.g. "eagle" */
+ /*
+ * d_packname contains the pack identifier and is returned when
+ * the disklabel is read off the disk or in-core copy.
+ * d_boot0 and d_boot1 are the (optional) names of the
+ * primary (block 0) and secondary (block 1-15) bootstraps
+ * as found in /usr/mdec. These are returned when using
+ * getdiskbyname(3) to retrieve the values from /etc/disktab.
+ */
+#if defined(MACH_KERNEL) || defined(STANDALONE)
+ char d_packname[16]; /* pack identifier */
+#else
+ union {
+ char un_d_packname[16]; /* pack identifier */
+ struct {
+ char *un_d_boot0; /* primary bootstrap name */
+ char *un_d_boot1; /* secondary bootstrap name */
+ } un_b;
+ } d_un;
+#define d_packname d_un.un_d_packname
+#define d_boot0 d_un.un_b.un_d_boot0
+#define d_boot1 d_un.un_b.un_d_boot1
+#endif /* ! MACH_KERNEL or STANDALONE */
+ /* disk geometry: */
+ unsigned int d_secsize; /* # of bytes per sector */
+ unsigned int d_nsectors; /* # of data sectors per track */
+ unsigned int d_ntracks; /* # of tracks per cylinder */
+ unsigned int d_ncylinders; /* # of data cylinders per unit */
+ unsigned int d_secpercyl; /* # of data sectors per cylinder */
+ unsigned int d_secperunit; /* # of data sectors per unit */
+ /*
+ * Spares (bad sector replacements) below
+ * are not counted in d_nsectors or d_secpercyl.
+ * Spare sectors are assumed to be physical sectors
+ * which occupy space at the end of each track and/or cylinder.
+ */
+ unsigned short d_sparespertrack; /* # of spare sectors per track */
+ unsigned short d_sparespercyl; /* # of spare sectors per cylinder */
+ /*
+ * Alternate cylinders include maintenance, replacement,
+ * configuration description areas, etc.
+ */
+ unsigned int d_acylinders; /* # of alt. cylinders per unit */
+
+ /* hardware characteristics: */
+ /*
+ * d_interleave, d_trackskew and d_cylskew describe perturbations
+ * in the media format used to compensate for a slow controller.
+ * Interleave is physical sector interleave, set up by the formatter
+ * or controller when formatting. When interleaving is in use,
+ * logically adjacent sectors are not physically contiguous,
+ * but instead are separated by some number of sectors.
+ * It is specified as the ratio of physical sectors traversed
+ * per logical sector. Thus an interleave of 1:1 implies contiguous
+ * layout, while 2:1 implies that logical sector 0 is separated
+ * by one sector from logical sector 1.
+ * d_trackskew is the offset of sector 0 on track N
+ * relative to sector 0 on track N-1 on the same cylinder.
+ * Finally, d_cylskew is the offset of sector 0 on cylinder N
+ * relative to sector 0 on cylinder N-1.
+ */
+ unsigned short d_rpm; /* rotational speed */
+ unsigned short d_interleave; /* hardware sector interleave */
+ unsigned short d_trackskew; /* sector 0 skew, per track */
+ unsigned short d_cylskew; /* sector 0 skew, per cylinder */
+ unsigned int d_headswitch; /* head switch time, usec */
+ unsigned int d_trkseek; /* track-to-track seek, usec */
+ unsigned int d_flags; /* generic flags */
+#define NDDATA 5
+ unsigned int d_drivedata[NDDATA]; /* drive-type specific information */
+#define NSPARE 5
+ unsigned int d_spare[NSPARE]; /* reserved for future use */
+ unsigned int d_magic2; /* the magic number (again) */
+ unsigned short d_checksum; /* xor of data incl. partitions */
+
+ /* filesystem and partition information: */
+ unsigned short d_npartitions; /* number of partitions in following */
+ unsigned int d_bbsize; /* size of boot area at sn0, bytes */
+ unsigned int d_sbsize; /* max size of fs superblock, bytes */
+ struct partition { /* the partition table */
+ unsigned int p_size; /* number of sectors in partition */
+ unsigned int p_offset; /* starting sector */
+ unsigned int p_fsize; /* filesystem basic fragment size */
+ unsigned char p_fstype; /* filesystem type, see below */
+ unsigned char p_frag; /* filesystem fragments per block */
+ unsigned short p_cpg; /* filesystem cylinders per group */
+ } d_partitions[MAXPARTITIONS+1]; /* actually may be more */
+
+#if defined(alpha) && defined(MACH_KERNEL)
+ /*
+ * Disgusting hack. If this structure contains a pointer,
+ * as it does for non-kernel, then the compiler rounds
+ * the size to make it pointer-sized properly (arrays of..).
+ * But if I define the pointer for the kernel then instances
+ * of this structure better be aligned otherwise picking
+ * up a short might be done by too-smart compilers (GCC) with
+ * a load-long instruction expecting the short to be aligned.
+ * I bet the OSF folks stomped into this too, since they use
+ * the same disgusting hack below.. [whatelse can I do ??]
+ */
+ int bugfix;
+#endif
+};
+#else /* LOCORE */
+ /*
+ * offsets for asm boot files.
+ */
+ .set d_secsize,40
+ .set d_nsectors,44
+ .set d_ntracks,48
+ .set d_ncylinders,52
+ .set d_secpercyl,56
+ .set d_secperunit,60
+ .set d_end_,276 /* size of disk label */
+#endif /* LOCORE */
+
+/* d_type values: */
+#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
+#define DTYPE_MSCP 2 /* MSCP */
+#define DTYPE_DEC 3 /* other DEC (rk, rl) */
+#define DTYPE_SCSI 4 /* SCSI */
+#define DTYPE_ESDI 5 /* ESDI interface */
+#define DTYPE_ST506 6 /* ST506 etc. */
+#define DTYPE_FLOPPY 10 /* floppy */
+
+#ifdef DKTYPENAMES
+static char *dktypenames[] = {
+ "unknown",
+ "SMD",
+ "MSCP",
+ "old DEC",
+ "SCSI",
+ "ESDI",
+ "type 6",
+ "type 7",
+ "type 8",
+ "type 9",
+ "floppy",
+ 0
+};
+#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
+#endif
+
+/*
+ * Filesystem type and version.
+ * Used to interpret other filesystem-specific
+ * per-partition information.
+ */
+#define FS_UNUSED 0 /* unused */
+#define FS_SWAP 1 /* swap */
+#define FS_V6 2 /* Sixth Edition */
+#define FS_V7 3 /* Seventh Edition */
+#define FS_SYSV 4 /* System V */
+#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
+#define FS_V8 6 /* Eighth Edition, 4K blocks */
+#define FS_BSDFFS 7 /* 4.2BSD fast file system */
+#define FS_LINUXFS 8 /* Linux file system */
+
+#ifdef DKTYPENAMES
+static char *fstypenames[] = {
+ "unused",
+ "swap",
+ "Version 6",
+ "Version 7",
+ "System V",
+ "4.1BSD",
+ "Eighth Edition",
+ "4.2BSD",
+ "Linux",
+ 0
+};
+#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
+#endif
+
+/*
+ * flags shared by various drives:
+ */
+#define D_REMOVABLE 0x01 /* removable media */
+#define D_ECC 0x02 /* supports ECC */
+#define D_BADSECT 0x04 /* supports bad sector forw. */
+#define D_RAMDISK 0x08 /* disk emulator */
+#define D_CHAIN 0x10 /* can do back-back transfers */
+
+/*
+ * Drive data for SMD.
+ */
+#define d_smdflags d_drivedata[0]
+#define D_SSE 0x1 /* supports skip sectoring */
+#define d_mindist d_drivedata[1]
+#define d_maxdist d_drivedata[2]
+#define d_sdist d_drivedata[3]
+
+/*
+ * Drive data for ST506.
+ */
+#define d_precompcyl d_drivedata[0]
+#define d_gap3 d_drivedata[1] /* used only when formatting */
+
+/*
+ * IBM controller info (d_precompcyl used, too)
+ */
+#define d_step d_drivedata[2]
+
+#ifndef LOCORE
+/*
+ * Structure used to perform a format
+ * or other raw operation, returning data
+ * and/or register values.
+ * Register identification and format
+ * are device- and driver-dependent.
+ */
+struct format_op {
+ char *df_buf;
+ int df_count; /* value-result */
+ recnum_t df_startblk;
+ int df_reg[8]; /* result */
+};
+
+/*
+ * Disk-specific ioctls.
+ */
+ /* get and set disklabel; DIOCGPART used internally */
+#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
+#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
+#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
+
+/* do format operation, read or write */
+#define DIOCRFORMAT _IOWR('d', 105, struct format_op)
+#define DIOCWFORMAT _IOWR('d', 106, struct format_op)
+
+#define DIOCSSTEP _IOW('d', 107, int) /* set step rate */
+#define DIOCSRETRIES _IOW('d', 108, int) /* set # of retries */
+#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
+
+#define DIOCSBAD _IOW('d', 110, struct dkbad) /* set kernel dkbad */
+
+#endif /* LOCORE */
+
+#endif /* _DISK_STATUS_H_ */
diff --git a/include/device/input.h b/include/device/input.h
new file mode 100644
index 0000000..9de73a3
--- /dev/null
+++ b/include/device/input.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2023 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Mach.
+ *
+ * GNU Mach is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _DEVICE_INPUT_H
+#define _DEVICE_INPUT_H
+
+#include <mach/boolean.h>
+#include <mach/time_value.h>
+
+/*
+ * Ioctl's have the command encoded in the lower word, and the size of
+ * any in or out parameters in the upper word. The high 3 bits of the
+ * upper word are used to encode the in/out status of the parameter.
+ */
+#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN 0x80000000U /* copy in parameters */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+
+#define _IOC(inout,group,num,len) \
+ (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
+#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
+#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
+#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
+#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
+
+typedef uint8_t Scancode;
+typedef uint16_t kev_type; /* kd event type */
+
+/* (used for event records) */
+struct mouse_motion {
+ short mm_deltaX; /* units? */
+ short mm_deltaY;
+};
+
+typedef struct {
+ kev_type type; /* see below */
+ /*
+ * This is not used anymore but is kept for backwards compatibility.
+ * Note the use of rpc_time_value to ensure compatibility for a 64 bit kernel and
+ * 32 bit user land.
+ */
+ struct rpc_time_value unused_time; /* timestamp*/
+ union { /* value associated with event */
+ boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
+ Scancode sc; /* KEYBD_EVENT */
+ struct mouse_motion mmotion; /* MOUSE_MOTION */
+ } value;
+} kd_event;
+#define m_deltaX mmotion.mm_deltaX
+#define m_deltaY mmotion.mm_deltaY
+
+/*
+ * kd_event ID's.
+ */
+#define MOUSE_LEFT 1 /* mouse left button up/down */
+#define MOUSE_MIDDLE 2
+#define MOUSE_RIGHT 3
+#define MOUSE_MOTION 4 /* mouse motion */
+#define KEYBD_EVENT 5 /* key up/down */
+
+/* Keyboard ioctls */
+
+/*
+ * KDSKBDMODE - When the console is in "ascii" mode, keyboard events are
+ * converted to Ascii characters that are readable from /dev/console.
+ * When the console is in "event" mode, keyboard events are
+ * timestamped and queued up on /dev/kbd as kd_events. When the last
+ * close is done on /dev/kbd, the console automatically reverts to ascii
+ * mode.
+ * When /dev/mouse is opened, mouse events are timestamped and queued
+ * on /dev/mouse, again as kd_events.
+ *
+ * KDGKBDTYPE - Returns the type of keyboard installed. Currently
+ * there is only one type, KB_VANILLAKB, which is your standard PC-AT
+ * keyboard.
+ */
+
+#define KDSKBDMODE _IOW('K', 1, int) /* set keyboard mode */
+#define KB_EVENT 1
+#define KB_ASCII 2
+
+#define KDGKBDTYPE _IOR('K', 2, int) /* get keyboard type */
+#define KB_VANILLAKB 0
+
+#define KDSETLEDS _IOW('K', 5, int) /* set the keyboard ledstate */
+
+#endif /* _DEVICE_INPUT_H */
diff --git a/include/device/net_status.h b/include/device/net_status.h
new file mode 100644
index 0000000..9ab95b9
--- /dev/null
+++ b/include/device/net_status.h
@@ -0,0 +1,201 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: 3/89
+ *
+ * Status information for network interfaces.
+ */
+
+#ifndef _DEVICE_NET_STATUS_H_
+#define _DEVICE_NET_STATUS_H_
+
+#include <device/device_types.h>
+#include <mach/message.h>
+
+/*
+ * General interface status
+ */
+struct net_status {
+ int min_packet_size; /* minimum size, including header */
+ int max_packet_size; /* maximum size, including header */
+ int header_format; /* format of network header */
+ int header_size; /* size of network header */
+ int address_size; /* size of network address */
+ int flags; /* interface status */
+ int mapped_size; /* if mappable, virtual mem needed */
+};
+#define NET_STATUS_COUNT (sizeof(struct net_status)/sizeof(int))
+#define NET_STATUS (('n'<<16) + 1)
+
+/*
+ * Header formats, as given by RFC 826/1010 for ARP:
+ */
+#define HDR_ETHERNET 1 /* Ethernet hardware address */
+#define HDR_EXP_ETHERNET 2 /* 3Mhz experimental Ethernet
+ hardware address */
+#define HDR_PRO_NET 4 /* Proteon ProNET Token Ring */
+#define HDR_CHAOS 5 /* Chaosnet */
+#define HDR_802 6 /* IEEE 802 networks */
+
+
+/*
+ * A network address is an array of bytes. In order to return
+ * this in an array of (long) integers, it is returned in net order.
+ * Use 'ntohl' on each element of the array to retrieve the original
+ * ordering.
+ */
+#define NET_ADDRESS (('n'<<16) + 2)
+
+#define NET_DSTADDR (('n'<<16) + 3)
+
+#define NET_FLAGS (('n'<<16) + 4)
+
+/*
+ * Input packet filter definition
+ */
+#define NET_MAX_FILTER 128 /* was 64, bpf programs are big */
+#define NET_FILTER_STACK_DEPTH 32
+
+/*
+ * We allow specification of up to NET_MAX_FILTER (short) words of a filter
+ * command list to be applied to incoming packets to determine if
+ * those packets should be given to a particular network input filter.
+ *
+ * Each network filter specifies the filter command list via net_add_filter.
+ * Each filter command list specifies a sequences of actions which leave a
+ * boolean value on the top of an internal stack. Each word of the
+ * command list specifies an action from the set {PUSHLIT, PUSHZERO,
+ * PUSHWORD+N} which respectively push the next word of the filter, zero,
+ * or word N of the incoming packet on the stack, and a binary operator
+ * from the set {EQ, LT, LE, GT, GE, AND, OR, XOR} which operates on the
+ * top two elements of the stack and replaces them with its result. The
+ * special action NOPUSH and the special operator NOP can be used to only
+ * perform the binary operation or to only push a value on the stack.
+ *
+ * If the final value of the filter operation is true, then the packet is
+ * accepted for the filter.
+ *
+ * The first filter_t object is a header which allows to set flags for the
+ * filter code. Main flags concern the direction of packets. This header is
+ * split in the same way NETF words are : the 6 MSB bits indicate the type
+ * of filter while the 10 LSB bits are the flags. For native NETF filters,
+ * clear the 6 MSB bits (which is why there is no dedicated macro).
+ */
+
+typedef unsigned short filter_t;
+typedef filter_t *filter_array_t;
+
+#define CSPF_BYTES(n) ((n) * sizeof (filter_t))
+
+/* these must sum to 16! */
+#define NETF_NBPA 10 /* # bits / argument */
+#define NETF_NBPO 6 /* # bits / operator */
+
+#define NETF_ARG(word) ((word) & 0x3ff)
+#define NETF_OP(word) (((word)>>NETF_NBPA)&0x3f)
+
+/* filter types */
+#define NETF_TYPE_MASK (((1 << NETF_NBPO) - 1) << NETF_NBPA)
+#define NETF_BPF (1 << NETF_NBPA)
+
+/* flags */
+#define NETF_IN 0x1
+#define NETF_OUT 0x2
+
+/* binary operators */
+#define NETF_NOP (0<<NETF_NBPA)
+#define NETF_EQ (1<<NETF_NBPA)
+#define NETF_LT (2<<NETF_NBPA)
+#define NETF_LE (3<<NETF_NBPA)
+#define NETF_GT (4<<NETF_NBPA)
+#define NETF_GE (5<<NETF_NBPA)
+#define NETF_AND (6<<NETF_NBPA)
+#define NETF_OR (7<<NETF_NBPA)
+#define NETF_XOR (8<<NETF_NBPA)
+#define NETF_COR (9<<NETF_NBPA)
+#define NETF_CAND (10<<NETF_NBPA)
+#define NETF_CNOR (11<<NETF_NBPA)
+#define NETF_CNAND (12<<NETF_NBPA)
+#define NETF_NEQ (13<<NETF_NBPA)
+#define NETF_LSH (14<<NETF_NBPA)
+#define NETF_RSH (15<<NETF_NBPA)
+#define NETF_ADD (16<<NETF_NBPA)
+#define NETF_SUB (17<<NETF_NBPA)
+
+
+/* stack arguments */
+#define NETF_NOPUSH 0 /* don`t push */
+#define NETF_PUSHLIT 1 /* next word in filter */
+#define NETF_PUSHZERO 2 /* 0 */
+#define NETF_PUSHIND 14 /* word indexed by stack top */
+#define NETF_PUSHHDRIND 15 /* header word indexed by stack top */
+#define NETF_PUSHWORD 16 /* word 0 .. 944 in packet */
+#define NETF_PUSHHDR 960 /* word 0 .. 31 in header */
+#define NETF_PUSHSTK 992 /* word 0 .. 31 in stack */
+
+/* priorities */
+#define NET_HI_PRI 100
+#define NET_PRI_MAX 255
+
+/*
+ * BPF support.
+ */
+#include <device/bpf.h>
+
+/*
+ * Net receive message format.
+ *
+ * The header and data are packaged separately, since some hardware
+ * supports variable-length headers. We prefix the packet with
+ * a packet_hdr structure so that the real data portion begins
+ * on a long-word boundary, and so that packet filters can address
+ * the type field and packet size uniformly.
+ */
+#define NET_RCV_MAX 4095
+#define NET_HDW_HDR_MAX 64
+
+#define NET_RCV_MSG_ID 2999 /* in device.defs reply range */
+
+struct packet_header {
+ unsigned short length;
+ unsigned short type; /* network order */
+};
+
+struct net_rcv_msg {
+ mach_msg_header_t msg_hdr;
+ mach_msg_type_t header_type;
+ char header[NET_HDW_HDR_MAX];
+ mach_msg_type_t packet_type;
+ char packet[NET_RCV_MAX];
+ boolean_t sent;
+};
+typedef struct net_rcv_msg *net_rcv_msg_t;
+#define net_rcv_msg_packet_count packet_type.msgt_number
+
+
+
+#endif /* _DEVICE_NET_STATUS_H_ */
diff --git a/include/device/notify.defs b/include/device/notify.defs
new file mode 100644
index 0000000..7919b33
--- /dev/null
+++ b/include/device/notify.defs
@@ -0,0 +1,36 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+subsystem notify 100;
+
+#include <mach/std_types.defs>
+
+serverprefix do_;
+serverdemux device_intr_notify_server;
+
+simpleroutine device_intr_notify(
+ notify : notify_port_t;
+ id : int);
diff --git a/include/device/notify.h b/include/device/notify.h
new file mode 100644
index 0000000..addf911
--- /dev/null
+++ b/include/device/notify.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010 Free Software Foundation, Inc.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * THE FREE SOFTWARE FOUNDATIONALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ */
+
+/*
+ * Device notification definitions.
+ */
+
+#ifndef _MACH_DEVICE_NOTIFY_H_
+#define _MACH_DEVICE_NOTIFY_H_
+
+#include <mach/port.h>
+#include <mach/message.h>
+
+typedef struct
+{
+ mach_msg_header_t intr_header;
+ mach_msg_type_t intr_type;
+ int id;
+} device_intr_notification_t;
+
+#define DEVICE_INTR_NOTIFY 100
+
+#endif /* _MACH_DEVICE_NOTIFY_H_ */
diff --git a/include/device/tape_status.h b/include/device/tape_status.h
new file mode 100644
index 0000000..603d76c
--- /dev/null
+++ b/include/device/tape_status.h
@@ -0,0 +1,140 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Copyright (c) 1982, 1986 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. The name of the Laboratory may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)mtio.h 7.4 (Berkeley) 8/31/88
+ */
+
+#ifndef _TAPE_STATUS_H_
+#define _TAPE_STATUS_H_
+
+/*
+ * Tape status
+ */
+
+struct tape_status {
+ unsigned int mt_type;
+ unsigned int speed;
+ unsigned int density;
+ unsigned int flags;
+# define TAPE_FLG_REWIND 0x1
+# define TAPE_FLG_WP 0x2
+};
+#define TAPE_STATUS_COUNT (sizeof(struct tape_status)/sizeof(int))
+#define TAPE_STATUS (('m'<<16) + 1)
+
+/*
+ * Constants for mt_type. These are the same
+ * for controllers compatible with the types listed.
+ */
+#define MT_ISTS 0x01 /* TS-11 */
+#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */
+#define MT_ISTM 0x03 /* TM11/TE10 Unibus */
+#define MT_ISMT 0x04 /* TM78/TU78 Massbus */
+#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */
+#define MT_ISCPC 0x06 /* SUN */
+#define MT_ISAR 0x07 /* SUN */
+#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */
+#define MT_ISCY 0x09 /* CCI Cipher */
+#define MT_ISSCSI 0x0a /* SCSI tape (all brands) */
+
+
+/*
+ * Set status parameters
+ */
+
+struct tape_params {
+ unsigned int mt_operation;
+ unsigned int mt_repeat_count;
+};
+
+/* operations */
+#define MTWEOF 0 /* write an end-of-file record */
+#define MTFSF 1 /* forward space file */
+#define MTBSF 2 /* backward space file */
+#define MTFSR 3 /* forward space record */
+#define MTBSR 4 /* backward space record */
+#define MTREW 5 /* rewind */
+#define MTOFFL 6 /* rewind and put the drive offline */
+#define MTNOP 7 /* no operation, sets status only */
+#define MTCACHE 8 /* enable controller cache */
+#define MTNOCACHE 9 /* disable controller cache */
+
+
+/*
+ * U*x compatibility
+ */
+
+/* structure for MTIOCGET - mag tape get status command */
+
+struct mtget {
+ short mt_type; /* type of magtape device */
+/* the following two registers are grossly device dependent */
+ short mt_dsreg; /* ``drive status'' register */
+ short mt_erreg; /* ``error'' register */
+/* end device-dependent registers */
+ short mt_resid; /* residual count */
+/* the following two are not yet implemented */
+ unsigned long mt_fileno; /* file number of current position */
+ unsigned long mt_blkno; /* block number of current position */
+/* end not yet implemented */
+};
+
+
+/* mag tape io control commands */
+#define MTIOCTOP _IOW('m', 1, struct tape_params)/* do a mag tape op */
+#define MTIOCGET _IOR('m', 2, struct mtget) /* get tape status */
+#define MTIOCIEOT _IO('m', 3) /* ignore EOT error */
+#define MTIOCEEOT _IO('m', 4) /* enable EOT error */
+
+
+#endif /* _TAPE_STATUS_H_ */
diff --git a/include/device/tty_status.h b/include/device/tty_status.h
new file mode 100644
index 0000000..2eed5d0
--- /dev/null
+++ b/include/device/tty_status.h
@@ -0,0 +1,134 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Author: David B. Golub, Carnegie Mellon University
+ * Date: ll/90
+ *
+ * Status information for tty.
+ */
+
+#ifndef _DEVICE_TTY_STATUS_H_
+#define _DEVICE_TTY_STATUS_H_
+
+struct tty_status {
+ int tt_ispeed; /* input speed */
+ int tt_ospeed; /* output speed */
+ int tt_breakc; /* character to deliver when break
+ detected on line */
+ int tt_flags; /* mode flags */
+};
+#define TTY_STATUS_COUNT (sizeof(struct tty_status)/sizeof(int))
+#define TTY_STATUS (dev_flavor_t)(('t'<<16) + 1)
+
+/*
+ * Speeds
+ */
+#define B0 0
+#define B50 1
+#define B75 2
+#define B110 3
+#define B134 4
+#define B150 5
+#define B200 6
+#define B300 7
+#define B600 8
+#define B1200 9
+#define B1800 10
+#define B2400 11
+#define B4800 12
+#define B9600 13
+#define EXTA 14 /* XX can we just get rid of EXTA and EXTB? */
+#define EXTB 15
+#define B19200 EXTA
+#define B38400 EXTB
+#define B57600 16
+#define B115200 17
+
+#define NSPEEDS 18
+
+/*
+ * Flags
+ */
+#define TF_TANDEM 0x00000001 /* send stop character when input
+ queue full */
+#define TF_ODDP 0x00000002 /* get/send odd parity */
+#define TF_EVENP 0x00000004 /* get/send even parity */
+#define TF_ANYP (TF_ODDP|TF_EVENP)
+ /* get any parity/send none */
+#define TF_LITOUT 0x00000008 /* output all 8 bits
+ otherwise, characters >= 0x80
+ are time delays XXX */
+#define TF_MDMBUF 0x00000010 /* start/stop output on carrier
+ interrupt
+ otherwise, dropping carrier
+ hangs up line */
+#define TF_NOHANG 0x00000020 /* no hangup signal on carrier drop */
+#define TF_HUPCLS 0x00000040 /* hang up (outgoing) on last close */
+
+/*
+ * Read-only flags - information about device
+ */
+#define TF_ECHO 0x00000080 /* device wants user to echo input */
+#define TF_CRMOD 0x00000100 /* device wants \r\n, not \n */
+#define TF_XTABS 0x00000200 /* device does not understand tabs */
+
+/*
+ * Modem control
+ */
+#define TTY_MODEM_COUNT (1) /* one integer */
+#define TTY_MODEM (dev_flavor_t)(('t'<<16) + 2)
+
+#define TM_LE 0x0001 /* line enable */
+#define TM_DTR 0x0002 /* data terminal ready */
+#define TM_RTS 0x0004 /* request to send */
+#define TM_ST 0x0008 /* secondary transmit */
+#define TM_SR 0x0010 /* secondary receive */
+#define TM_CTS 0x0020 /* clear to send */
+#define TM_CAR 0x0040 /* carrier detect */
+#define TM_RNG 0x0080 /* ring */
+#define TM_DSR 0x0100 /* data set ready */
+
+#define TM_BRK 0x0200 /* set line break (internal) */
+#define TM_HUP 0x0000 /* close line (internal) */
+
+/*
+ * Other controls
+ */
+#define TTY_FLUSH_COUNT (1) /* one integer - D_READ|D_WRITE */
+#define TTY_FLUSH (dev_flavor_t)(('t'<<16) + 3)
+ /* flush input or output */
+#define TTY_STOP (dev_flavor_t)(('t'<<16) + 4)
+ /* stop output */
+#define TTY_START (dev_flavor_t)(('t'<<16) + 5)
+ /* start output */
+#define TTY_SET_BREAK (dev_flavor_t)(('t'<<16) + 6)
+ /* set break condition */
+#define TTY_CLEAR_BREAK (dev_flavor_t)(('t'<<16) + 7)
+ /* clear break condition */
+#define TTY_SET_TRANSLATION (dev_flavor_t)(('t'<<16) + 8)
+ /* set translation table */
+
+#endif /* _DEVICE_TTY_STATUS_H_ */
diff --git a/include/inttypes.h b/include/inttypes.h
new file mode 100644
index 0000000..353984a
--- /dev/null
+++ b/include/inttypes.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Mach.
+ *
+ * GNU Mach is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _INTTYPES_H_
+#define _INTTYPES_H_
+
+#include <stdint.h>
+
+#ifdef __x86_64__
+#define __64PREFIX "l"
+#define __PTRPREFIX "l"
+#else
+#define __64PREFIX "ll"
+#define __PTRPREFIX
+#endif
+
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "d"
+#define PRId64 __64PREFIX"d"
+#define PRIdPTR __PTRPREFIX"d"
+
+#define PRIi8 "i"
+#define PRIi16 "i"
+#define PRIi32 "i"
+#define PRIi64 __64PREFIX"i"
+#define PRIiPTR __PTRPREFIX"i"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "u"
+#define PRIu64 __64PREFIX"u"
+#define PRIuPTR __PTRPREFIX"u"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "x"
+#define PRIx64 __64PREFIX"x"
+#define PRIxPTR __PTRPREFIX"x"
+
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "o"
+#define PRIo64 __64PREFIX"o"
+#define PRIoPTR __PTRPREFIX"o"
+
+#endif /* _INTTYPES_H_ */
diff --git a/include/mach/alert.h b/include/mach/alert.h
new file mode 100644
index 0000000..e8eb371
--- /dev/null
+++ b/include/mach/alert.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1993,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL). All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
+ * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
+ * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * CSL requests users of this software to return to csl-dist@cs.utah.edu any
+ * improvements that they make and grant CSL redistribution rights.
+ *
+ * Author: Bryan Ford, University of Utah CSL
+ */
+/*
+ * File: mach/alert.h
+ *
+ * Standard alert definitions
+ *
+ */
+
+#ifndef _MACH_ALERT_H_
+#define _MACH_ALERT_H_
+
+#define ALERT_BITS 32 /* Minimum; more may actually be available */
+
+#define ALERT_ABORT_STRONG 0x00000001 /* Request to abort _all_ operations */
+#define ALERT_ABORT_SAFE 0x00000002 /* Request to abort restartable operations */
+
+#define ALERT_USER 0xffff0000 /* User-defined alert bits */
+
+#endif /* _MACH_ALERT_H_ */
diff --git a/include/mach/boolean.h b/include/mach/boolean.h
new file mode 100644
index 0000000..f0f36a2
--- /dev/null
+++ b/include/mach/boolean.h
@@ -0,0 +1,63 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/boolean.h
+ *
+ * Boolean data type.
+ *
+ */
+
+#ifndef _MACH_BOOLEAN_H_
+#define _MACH_BOOLEAN_H_
+
+/*
+ * Pick up "boolean_t" type definition
+ */
+
+#ifndef __ASSEMBLER__
+#include <mach/machine/boolean.h>
+#endif /* __ASSEMBLER__ */
+
+#endif /* _MACH_BOOLEAN_H_ */
+
+/*
+ * Define TRUE and FALSE, only if they haven't been before,
+ * and not if they're explicitly refused. Note that we're
+ * outside the BOOLEAN_H_ conditional, to avoid ordering
+ * problems.
+ */
+
+#if !defined(NOBOOL)
+
+#ifndef TRUE
+#define TRUE ((boolean_t) 1)
+#endif /* TRUE */
+
+#ifndef FALSE
+#define FALSE ((boolean_t) 0)
+#endif /* FALSE */
+
+#endif /* !defined(NOBOOL) */
diff --git a/include/mach/boot.h b/include/mach/boot.h
new file mode 100644
index 0000000..7f14cc4
--- /dev/null
+++ b/include/mach/boot.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 1994 The University of Utah and
+ * the Computer Systems Laboratory at the University of Utah (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software is hereby
+ * granted provided that (1) source code retains these copyright, permission,
+ * and disclaimer notices, and (2) redistributions including binaries
+ * reproduce the notices in supporting documentation, and (3) all advertising
+ * materials mentioning features or use of this software display the following
+ * acknowledgement: ``This product includes software developed by the
+ * Computer Systems Laboratory at the University of Utah.''
+ *
+ * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
+ * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
+ * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * CSL requests users of this software to return to csl-dist@cs.utah.edu any
+ * improvements that they make and grant CSL redistribution rights.
+ *
+ * Author: Bryan Ford, University of Utah CSL
+ */
+#ifndef _MACH_BOOT_
+#define _MACH_BOOT_
+
+#include <mach/machine/boot.h>
+
+#ifndef __ASSEMBLER__
+
+#include <mach/machine/vm_types.h>
+
+struct boot_image_info
+{
+ /* First of the chain of boot modules in the boot image. */
+ struct boot_module *first_bmod;
+
+ /* List of rendezvous points:
+ starts out 0; and bmods can add nodes as needed. */
+ struct boot_rendezvous *first_rzv;
+
+ /* These register the total virtual address extent of the boot image. */
+ vm_offset_t start, end;
+
+ /* Machine-dependent boot information. */
+ struct machine_boot_image_info mboot;
+};
+
+struct boot_module
+{
+ int magic;
+ int (*init)(struct boot_image_info *bii);
+ vm_offset_t text;
+ vm_offset_t etext;
+ vm_offset_t data;
+ vm_offset_t edata;
+ vm_offset_t bss;
+ vm_offset_t ebss;
+};
+#define BMOD_VALID(bmod) ((bmod)->magic == BMOD_MAGIC)
+#define BMOD_NEXT(bmod) ((struct boot_module*)((bmod)->edata))
+
+struct boot_rendezvous
+{
+ struct boot_rendezvous *next;
+ int code;
+};
+
+#endif /* !__ASSEMBLER__ */
+
+
+/* This is the magic value that must appear in boot_module.magic. */
+#define BMOD_MAGIC 0x424d4f44 /* 'BMOD' */
+
+
+/* Following are the codes for boot_rendezvous.code. */
+
+/* This rendezvous is used for choosing a microkernel to start.
+ XX not used yet */
+#define BRZV_KERNEL 'K'
+
+/* Once the microkernel is fully initialized,
+ it starts one or more bootstrap services... */
+#define BRZV_BOOTSTRAP 'B'
+
+/* The bootstrap services might need other OS-dependent data,
+ such as initial programs to run, filesystem snapshots, etc.
+ These generic chunks of data are packaged up by the microkernel
+ and provided to the bootstrap services upon request.
+ XX When can they be deallocated? */
+#define BRZV_DATA 'D'
+
+
+#endif /* _MACH_BOOT_ */
diff --git a/include/mach/default_pager.defs b/include/mach/default_pager.defs
new file mode 100644
index 0000000..e2154e2
--- /dev/null
+++ b/include/mach/default_pager.defs
@@ -0,0 +1,65 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+subsystem default_pager 2275;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+#include <mach/default_pager_types.defs>
+
+routine default_pager_object_create(
+ default_pager : mach_port_t;
+ out memory_object : memory_object_t =
+ MACH_MSG_TYPE_MAKE_SEND;
+ object_size : vm_size_t);
+
+routine default_pager_info(
+ default_pager : mach_port_t;
+ out info : default_pager_info_t);
+
+routine default_pager_objects(
+ default_pager : mach_port_t;
+ out objects : default_pager_object_array_t,
+ CountInOut, Dealloc;
+ out ports : mach_port_array_t =
+ array[] of mach_port_move_send_t,
+ CountInOut, Dealloc);
+
+routine default_pager_object_pages(
+ default_pager : mach_port_t;
+ memory_object : memory_object_name_t;
+ out pages : default_pager_page_array_t,
+ CountInOut, Dealloc);
+
+routine default_pager_paging_file(
+ default_pager : mach_port_t;
+ master_device_port : mach_port_t;
+ filename : default_pager_filename_t;
+ add : boolean_t);
+
+routine default_pager_register_fileserver(
+ default_pager : mach_port_t;
+ fileserver_port : mach_port_t);
diff --git a/include/mach/default_pager_types.defs b/include/mach/default_pager_types.defs
new file mode 100644
index 0000000..398c62c
--- /dev/null
+++ b/include/mach/default_pager_types.defs
@@ -0,0 +1,53 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_DEFAULT_PAGER_TYPES_DEFS_
+#define _MACH_DEFAULT_PAGER_TYPES_DEFS_
+
+#include <mach/std_types.defs>
+
+type default_pager_info_t = struct {
+ vm_size_t dpi_total_space;
+ vm_size_t dpi_free_space;
+ vm_size_t dpi_page_size;
+};
+
+type default_pager_object_t = struct {
+ vm_offset_t dpo_object;
+ vm_size_t dpo_size;
+};
+type default_pager_object_array_t = array[] of default_pager_object_t;
+
+type default_pager_page_t = struct {
+ vm_offset_t dpp_offset;
+};
+type default_pager_page_array_t = array[] of default_pager_page_t;
+
+type default_pager_filename_t = (MACH_MSG_TYPE_STRING_C, 8*256);
+
+import <mach/default_pager_types.h>;
+
+#endif /* _MACH_DEFAULT_PAGER_TYPES_DEFS_ */
diff --git a/include/mach/default_pager_types.h b/include/mach/default_pager_types.h
new file mode 100644
index 0000000..2cf7da2
--- /dev/null
+++ b/include/mach/default_pager_types.h
@@ -0,0 +1,59 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_DEFAULT_PAGER_TYPES_H_
+#define _MACH_DEFAULT_PAGER_TYPES_H_
+
+/*
+ * Remember to update the mig type definitions
+ * in default_pager_types.defs when adding/removing fields.
+ */
+
+typedef struct default_pager_info {
+ vm_size_t dpi_total_space; /* size of backing store */
+ vm_size_t dpi_free_space; /* how much of it is unused */
+ vm_size_t dpi_page_size; /* the pager's vm page size */
+} default_pager_info_t;
+
+
+typedef struct default_pager_object {
+ vm_offset_t dpo_object; /* object managed by the pager */
+ vm_size_t dpo_size; /* backing store used for the object */
+} default_pager_object_t;
+
+typedef default_pager_object_t *default_pager_object_array_t;
+
+
+typedef struct default_pager_page {
+ vm_offset_t dpp_offset; /* offset of the page in its object */
+} default_pager_page_t;
+
+typedef default_pager_page_t *default_pager_page_array_t;
+
+typedef char default_pager_filename_t[256];
+typedef const char *const_default_pager_filename_t;
+
+#endif /* _MACH_DEFAULT_PAGER_TYPES_H_ */
diff --git a/include/mach/error.h b/include/mach/error.h
new file mode 100644
index 0000000..035dcf8
--- /dev/null
+++ b/include/mach/error.h
@@ -0,0 +1,93 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/error.h
+ * Purpose:
+ * error module definitions
+ *
+ */
+
+#ifndef _MACH_ERROR_H_
+#define _MACH_ERROR_H_
+#include <mach/kern_return.h>
+
+/*
+ * error number layout as follows:
+ *
+ * hi lo
+ * | system(6) | subsystem(12) | code(14) |
+ */
+
+
+#define err_none (mach_error_t)0
+#define ERR_SUCCESS (mach_error_t)0
+
+
+#define err_system(x) (((x)&0x3f)<<26)
+#define err_sub(x) (((x)&0xfff)<<14)
+
+#define err_get_system(err) (((err)>>26)&0x3f)
+#define err_get_sub(err) (((err)>>14)&0xfff)
+#define err_get_code(err) ((err)&0x3fff)
+
+#define system_emask (err_system(0x3f))
+#define sub_emask (err_sub(0xfff))
+#define code_emask (0x3fff)
+
+
+/* Mach error systems */
+#define err_kern err_system(0x0) /* kernel */
+#define err_us err_system(0x1) /* user space library */
+#define err_server err_system(0x2) /* user space servers */
+#define err_ipc err_system(0x3) /* old ipc errors */
+#define err_mach_ipc err_system(0x4) /* mach-ipc errors */
+#define err_bootstrap err_system(0x5) /* bootstrap errors */
+#define err_hurd err_system(0x10) /* GNU Hurd server errors */
+#define err_local err_system(0x3e) /* user defined errors */
+#define err_ipc_compat err_system(0x3f) /* (compatibility) mach-ipc errors */
+
+#define err_max_system 0x3f
+
+
+/* special old "subsystems" that don't really follow the above rules */
+#define err_mig -300
+#define err_exec 6000
+
+/* unix errors get lumped into one subsystem */
+#define err_unix (err_kern|err_sub(3))
+#define unix_err(errno) (err_kern|err_sub(3)|errno)
+
+/* MS-DOS extended error codes */
+#define err_dos (err_kern|err_sub(0xd05))
+
+/* Flux OS error systems */
+#define err_fluke err_system(0x20) /* Fluke API */
+
+#ifndef __ASSEMBLER__
+typedef kern_return_t mach_error_t;
+#endif /* __ASSEMBLER__ */
+
+#endif /* _MACH_ERROR_H_ */
diff --git a/include/mach/exc.defs b/include/mach/exc.defs
new file mode 100644
index 0000000..28638e2
--- /dev/null
+++ b/include/mach/exc.defs
@@ -0,0 +1,47 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993,1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Abstract:
+ * MiG definitions file for Mach exception interface.
+ */
+
+subsystem
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+ exc 2400;
+
+#include <mach/std_types.defs>
+
+ServerPrefix catch_;
+
+routine exception_raise(
+ exception_port : mach_port_t;
+ thread : mach_port_t;
+ task : mach_port_t;
+ exception : integer_t;
+ code : integer_t;
+ subcode : rpc_long_integer_t);
diff --git a/include/mach/exception.h b/include/mach/exception.h
new file mode 100644
index 0000000..c44fd53
--- /dev/null
+++ b/include/mach/exception.h
@@ -0,0 +1,58 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_EXCEPTION_H_
+#define _MACH_EXCEPTION_H_
+
+#include <mach/machine/exception.h>
+
+/*
+ * Machine-independent exception definitions.
+ */
+
+#define EXC_BAD_ACCESS 1 /* Could not access memory */
+ /* Code contains kern_return_t describing error. */
+ /* Subcode contains bad memory address. */
+
+#define EXC_BAD_INSTRUCTION 2 /* Instruction failed */
+ /* Illegal or undefined instruction or operand */
+
+#define EXC_ARITHMETIC 3 /* Arithmetic exception */
+ /* Exact nature of exception is in code field */
+
+#define EXC_EMULATION 4 /* Emulation instruction */
+ /* Emulation support instruction encountered */
+ /* Details in code and subcode fields */
+
+#define EXC_SOFTWARE 5 /* Software generated exception */
+ /* Exact exception is in code field. */
+ /* Codes 0 - 0xFFFF reserved to hardware */
+ /* Codes 0x10000 - 0x1FFFF reserved for OS emulation (Unix) */
+
+#define EXC_BREAKPOINT 6 /* Trace, breakpoint, etc. */
+ /* Details in code field. */
+
+#endif /* _MACH_EXCEPTION_H_ */
diff --git a/include/mach/exec/a.out.h b/include/mach/exec/a.out.h
new file mode 100644
index 0000000..c6dcaff
--- /dev/null
+++ b/include/mach/exec/a.out.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1994 The University of Utah and
+ * the Computer Systems Laboratory at the University of Utah (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software is hereby
+ * granted provided that (1) source code retains these copyright, permission,
+ * and disclaimer notices, and (2) redistributions including binaries
+ * reproduce the notices in supporting documentation, and (3) all advertising
+ * materials mentioning features or use of this software display the following
+ * acknowledgement: ``This product includes software developed by the
+ * Computer Systems Laboratory at the University of Utah.''
+ *
+ * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
+ * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
+ * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * CSL requests users of this software to return to csl-dist@cs.utah.edu any
+ * improvements that they make and grant CSL redistribution rights.
+ *
+ * Author: Bryan Ford, University of Utah CSL
+ */
+#ifndef _MACH_A_OUT_
+#define _MACH_A_OUT_
+
+struct exec
+{
+ unsigned long a_magic; /* magic number */
+ unsigned long a_text; /* size of text segment */
+ unsigned long a_data; /* size of initialized data */
+ unsigned long a_bss; /* size of uninitialized data */
+ unsigned long a_syms; /* size of symbol table */
+ unsigned long a_entry; /* entry point */
+ unsigned long a_trsize; /* size of text relocation */
+ unsigned long a_drsize; /* size of data relocation */
+};
+
+struct nlist {
+ long n_strx;
+ unsigned char n_type;
+ char n_other;
+ short n_desc;
+ unsigned long n_value;
+};
+
+#define OMAGIC 0407
+#define NMAGIC 0410
+#define ZMAGIC 0413
+#define QMAGIC 0314
+
+#define N_GETMAGIC(ex) \
+ ( (ex).a_magic & 0xffff )
+#define N_GETMAGIC_NET(ex) \
+ (ntohl((ex).a_magic) & 0xffff)
+
+/* Valid magic number check. */
+#define N_BADMAG(ex) \
+ (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
+ N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
+ N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
+ N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
+
+/* We don't provide any N_???OFF macros here
+ because they vary too much between the different a.out variants;
+ it's practically impossible to create one set of macros
+ that works for UX, FreeBSD, NetBSD, Linux, etc. */
+
+#endif /* _MACH_A_OUT_ */
diff --git a/include/mach/exec/elf.h b/include/mach/exec/elf.h
new file mode 100644
index 0000000..409947c
--- /dev/null
+++ b/include/mach/exec/elf.h
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 1995, 1994, 1993, 1992, 1991, 1990
+ * Open Software Foundation, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies and
+ * that both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of ("OSF") or Open Software
+ * Foundation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL OSF BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE
+ *
+ */
+/*
+ * OSF Research Institute MK6.1 (unencumbered) 1/31/1995
+ */
+#ifndef _MACH_EXEC_ELF_H_
+#define _MACH_EXEC_ELF_H_
+
+#include <mach/machine/exec/elf.h>
+
+/* ELF Header - figure 4-3, page 4-4 */
+
+#define EI_NIDENT 16
+
+typedef struct {
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+typedef struct {
+ unsigned char e_ident[EI_NIDENT]; /* Id bytes */
+ Elf64_Half e_type; /* file type */
+ Elf64_Half e_machine; /* machine type */
+ Elf64_Word e_version; /* version number */
+ Elf64_Addr e_entry; /* entry point */
+ Elf64_Off e_phoff; /* Program hdr offset */
+ Elf64_Off e_shoff; /* Section hdr offset */
+ Elf64_Word e_flags; /* Processor flags */
+ Elf64_Half e_ehsize; /* sizeof ehdr */
+ Elf64_Half e_phentsize; /* Program header entry size */
+ Elf64_Half e_phnum; /* Number of program headers */
+ Elf64_Half e_shentsize; /* Section header entry size */
+ Elf64_Half e_shnum; /* Number of section headers */
+ Elf64_Half e_shstrndx; /* String table index */
+} Elf64_Ehdr;
+
+/* e_ident[] identification indexes - figure 4-4, page 4-7 */
+
+#define EI_MAG0 0
+#define EI_MAG1 1
+#define EI_MAG2 2
+#define EI_MAG3 3
+#define EI_CLASS 4
+#define EI_DATA 5
+#define EI_VERSION 6
+#define EI_PAD 7
+
+/* magic number - pg 4-8 */
+
+#define ELFMAG0 0x7f
+#define ELFMAG1 'E'
+#define ELFMAG2 'L'
+#define ELFMAG3 'F'
+
+/* file class or capacity - page 4-8 */
+
+#define ELFCLASSNONE 0
+#define ELFCLASS32 1
+#define ELFCLASS64 2
+
+/* date encoding - page 4-9 */
+
+#define ELFDATANONE 0
+#define ELFDATA2LSB 1
+#define ELFDATA2MSB 2
+
+/* object file types - page 4-5 */
+
+#define ET_NONE 0
+#define ET_REL 1
+#define ET_EXEC 2
+#define ET_DYN 3
+#define ET_CORE 4
+
+#define ET_LOPROC 0xff00
+#define ET_HIPROC 0xffff
+
+/* architecture - page 4-5 */
+
+#define EM_NONE 0
+#define EM_M32 1
+#define EM_SPARC 2
+#define EM_386 3
+#define EM_68K 4
+#define EM_88K 5
+#define EM_860 7
+#define EM_MIPS 8
+#define EM_MIPS_RS4_BE 10
+#define EM_SPARC64 11
+#define EM_PARISC 15
+#define EM_PPC 20
+#define EM_X86_64 62
+
+/* version - page 4-6 */
+
+#define EV_NONE 0
+#define EV_CURRENT 1
+
+/* special section indexes - page 4-11, figure 4-7 */
+
+#define SHN_UNDEF 0
+#define SHN_LORESERVE 0xff00
+#define SHN_LOPROC 0xff00
+#define SHN_HIPROC 0xff1f
+#define SHN_ABS 0xfff1
+#define SHN_COMMON 0xfff2
+#define SHN_HIRESERVE 0xffff
+
+/* section header - page 4-13, figure 4-8 */
+
+typedef struct {
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+typedef struct elf64_shdr {
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Xword sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Xword sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Xword sh_addralign;
+ Elf64_Xword sh_entsize;
+} Elf64_Shdr;
+
+/* section types - page 4-15, figure 4-9 */
+
+#define SHT_NULL 0
+#define SHT_PROGBITS 1
+#define SHT_SYMTAB 2
+#define SHT_STRTAB 3
+#define SHT_RELA 4
+#define SHT_HASH 5
+#define SHT_DYNAMIC 6
+#define SHT_NOTE 7
+#define SHT_NOBITS 8
+#define SHT_REL 9
+#define SHT_SHLIB 10
+#define SHT_DYNSYM 11
+
+#define SHT_LOPROC 0x70000000
+#define SHT_HIPROC 0x7fffffff
+#define SHT_LOUSER 0x80000000
+#define SHT_HIUSER 0xffffffff
+
+/* section attribute flags - page 4-18, figure 4-11 */
+
+#define SHF_WRITE 0x1
+#define SHF_ALLOC 0x2
+#define SHF_EXECINSTR 0x4
+#define SHF_MASKPROC 0xf0000000
+
+/* symbol table - page 4-25, figure 4-15 */
+typedef struct
+{
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+} Elf32_Sym;
+
+typedef struct elf64_sym {
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Half st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
+} Elf64_Sym;
+
+#ifdef __x86_64__
+#define Elf_Sym Elf64_Sym
+#define Elf_Shdr Elf64_Shdr
+#else
+#define Elf_Sym Elf32_Sym
+#define Elf_Shdr Elf32_Shdr
+#endif
+
+/* symbol type and binding attributes - page 4-26 */
+
+#define ELF_ST_BIND(i) ((i) >> 4)
+#define ELF_ST_TYPE(i) ((i) & 0xf)
+#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
+
+/* symbol binding - page 4-26, figure 4-16 */
+
+#define STB_LOCAL 0
+#define STB_GLOBAL 1
+#define STB_WEAK 2
+#define STB_LOPROC 13
+#define STB_HIPROC 15
+
+/* symbol types - page 4-28, figure 4-17 */
+
+#define STT_NOTYPE 0
+#define STT_OBJECT 1
+#define STT_FUNC 2
+#define STT_SECTION 3
+#define STT_FILE 4
+#define STT_LOPROC 13
+#define STT_HIPROC 15
+
+
+/* relocation entries - page 4-31, figure 4-19 */
+
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+} Elf32_Rel;
+
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+} Elf32_Rela;
+
+/* Macros to split/combine relocation type and symbol page 4-32 */
+
+#define ELF32_R_SYM(__i) ((__i)>>8)
+#define ELF32_R_TYPE(__i) ((unsigned char) (__i))
+#define ELF32_R_INFO(__s, __t) (((__s)<<8) + (unsigned char) (__t))
+
+
+/* program header - page 5-2, figure 5-1 */
+
+typedef struct {
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
+} Elf32_Phdr;
+
+typedef struct {
+ Elf64_Word p_type; /* entry type */
+ Elf64_Word p_flags; /* flags */
+ Elf64_Off p_offset; /* offset */
+ Elf64_Addr p_vaddr; /* virtual address */
+ Elf64_Addr p_paddr; /* physical address */
+ Elf64_Xword p_filesz; /* file size */
+ Elf64_Xword p_memsz; /* memory size */
+ Elf64_Xword p_align; /* memory & file alignment */
+} Elf64_Phdr;
+
+/* segment types - page 5-3, figure 5-2 */
+
+#define PT_NULL 0
+#define PT_LOAD 1
+#define PT_DYNAMIC 2
+#define PT_INTERP 3
+#define PT_NOTE 4
+#define PT_SHLIB 5
+#define PT_PHDR 6
+
+#define PT_LOPROC 0x70000000
+#define PT_HIPROC 0x7fffffff
+
+/* segment permissions - page 5-6 */
+
+#define PF_X 0x1
+#define PF_W 0x2
+#define PF_R 0x4
+#define PF_MASKPROC 0xf0000000
+
+
+/* dynamic structure - page 5-15, figure 5-9 */
+
+typedef struct {
+ Elf32_Sword d_tag;
+ union {
+ Elf32_Word d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
+} Elf32_Dyn;
+
+/* Dynamic array tags - page 5-16, figure 5-10. */
+
+#define DT_NULL 0
+#define DT_NEEDED 1
+#define DT_PLTRELSZ 2
+#define DT_PLTGOT 3
+#define DT_HASH 4
+#define DT_STRTAB 5
+#define DT_SYMTAB 6
+#define DT_RELA 7
+#define DT_RELASZ 8
+#define DT_RELAENT 9
+#define DT_STRSZ 10
+#define DT_SYMENT 11
+#define DT_INIT 12
+#define DT_FINI 13
+#define DT_SONAME 14
+#define DT_RPATH 15
+#define DT_SYMBOLIC 16
+#define DT_REL 17
+#define DT_RELSZ 18
+#define DT_RELENT 19
+#define DT_PLTREL 20
+#define DT_DEBUG 21
+#define DT_TEXTREL 22
+#define DT_JMPREL 23
+
+#if defined(__x86_64__) && ! defined(USER32)
+typedef Elf64_Ehdr Elf_Ehdr;
+typedef Elf64_Phdr Elf_Phdr;
+#else
+typedef Elf32_Ehdr Elf_Ehdr;
+typedef Elf32_Phdr Elf_Phdr;
+#endif
+
+/*
+ * Bootstrap doesn't need machine dependent extensions.
+ */
+
+#endif /* _MACH_EXEC_ELF_H_ */
diff --git a/include/mach/exec/exec.h b/include/mach/exec/exec.h
new file mode 100644
index 0000000..94b234b
--- /dev/null
+++ b/include/mach/exec/exec.h
@@ -0,0 +1,130 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#ifndef _MACH_EXEC_H_
+#define _MACH_EXEC_H_
+
+#include <mach/machine/vm_types.h>
+#include <mach/vm_prot.h>
+
+/* XXX */
+typedef enum
+{
+ EXEC_ELF = 1,
+ EXEC_AOUT = 2,
+} exec_format_t;
+
+typedef struct exec_info
+{
+ /* Format of executable loaded - see above. */
+ exec_format_t format;
+
+ /* Program entrypoint. */
+ vm_offset_t entry;
+
+ /* Initial data pointer - only some architectures use this. */
+ vm_offset_t init_dp;
+
+ /* (ELF) Address of interpreter string for loading shared libraries, null if none. */
+ vm_offset_t interp;
+
+} exec_info_t;
+
+typedef int exec_sectype_t;
+#define EXEC_SECTYPE_READ VM_PROT_READ
+#define EXEC_SECTYPE_WRITE VM_PROT_WRITE
+#define EXEC_SECTYPE_EXECUTE VM_PROT_EXECUTE
+#define EXEC_SECTYPE_PROT_MASK VM_PROT_ALL
+#define EXEC_SECTYPE_ALLOC ((exec_sectype_t)0x000100)
+#define EXEC_SECTYPE_LOAD ((exec_sectype_t)0x000200)
+#define EXEC_SECTYPE_DEBUG ((exec_sectype_t)0x010000)
+#define EXEC_SECTYPE_AOUT_SYMTAB ((exec_sectype_t)0x020000)
+#define EXEC_SECTYPE_AOUT_STRTAB ((exec_sectype_t)0x040000)
+
+typedef int exec_read_func_t(void *handle, vm_offset_t file_ofs,
+ void *buf, vm_size_t size,
+ vm_size_t *out_actual);
+
+typedef int exec_read_exec_func_t(void *handle,
+ vm_offset_t file_ofs, vm_size_t file_size,
+ vm_offset_t mem_addr, vm_size_t mem_size,
+ exec_sectype_t section_type);
+
+/*
+ * Routines exported from libmach_exec.a
+ */
+
+/* Generic function to interpret an executable "file"
+ and "load" it into "memory".
+ Doesn't really know about files, loading, or memory;
+ all file I/O and destination memory accesses
+ go through provided functions.
+ Thus, this is a very generic loading mechanism.
+
+ The read() function is used to read metadata from the file
+ into the local address space.
+
+ The read_exec() function is used to load the actual sections.
+ It is used for all kinds of sections - code, data, bss, debugging data.
+ The 'section_type' parameter specifies what type of section is being loaded.
+
+ For code, data, and bss, the EXEC_SECTYPE_ALLOC flag will be set.
+ For code and data (i.e. stuff that's actually loaded from the file),
+ EXEC_SECTYPE_LOAD will also be set.
+ The EXEC_SECTYPE_PROT_MASK contains the intended access permissions
+ for the section.
+ 'file_size' may be less than 'mem_size';
+ the remaining data must be zero-filled.
+ 'mem_size' is always greater than zero, but 'file_size' may be zero
+ (e.g. in the case of a bss section).
+ No two read_exec() calls for one executable
+ will load data into the same virtual memory page,
+ although they may load from arbitrary (possibly overlapping) file positions.
+
+ For sections that aren't normally loaded into the process image
+ (e.g. debug sections), EXEC_SECTYPE_ALLOC isn't set,
+ but some other appropriate flag is set to indicate the type of section.
+
+ The 'handle' is an opaque pointer which is simply passed on
+ to the read() and read_exec() functions.
+
+ On return, the specified info structure is filled in
+ with information about the loaded executable.
+*/
+int exec_load(exec_read_func_t *read, exec_read_exec_func_t *read_exec,
+ void *handle, exec_info_t *out_info);
+
+/*
+ * Error codes
+ */
+
+#define EX_NOT_EXECUTABLE 6000 /* not a recognized executable format */
+#define EX_WRONG_ARCH 6001 /* valid executable, but wrong arch. */
+#define EX_CORRUPT 6002 /* recognized executable, but mangled */
+#define EX_BAD_LAYOUT 6003 /* something wrong with the memory or file image layout */
+
+
+#endif /* _MACH_EXEC_H_ */
diff --git a/include/mach/experimental.defs b/include/mach/experimental.defs
new file mode 100644
index 0000000..ddcbea5
--- /dev/null
+++ b/include/mach/experimental.defs
@@ -0,0 +1,15 @@
+subsystem
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+ experimental 424242;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+serverprefix experimental_;
+
+/* This is free for experimenting RPCs, with no backward compatibility guarantees. */
diff --git a/include/mach/gnumach.defs b/include/mach/gnumach.defs
new file mode 100644
index 0000000..7ecf74d
--- /dev/null
+++ b/include/mach/gnumach.defs
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2012 Free Software Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+ gnumach 4200;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+#include <mach_debug/mach_debug_types.defs>
+
+#ifdef GNUMACH_IMPORTS
+GNUMACH_IMPORTS
+#endif
+
+type vm_cache_statistics_data_t = struct[11] of integer_t;
+
+type vm_wire_t = int;
+
+/*
+ * Return page cache statistics for the host on which the target task
+ * resides.
+ */
+routine vm_cache_statistics(
+ target_task : vm_task_t;
+ out vm_cache_stats : vm_cache_statistics_data_t);
+
+/*
+ * Terminate a thread and release rights and memory.
+ *
+ * Intended to be used by threading libraries to provide a clean way for
+ * threads to terminate themselves. The resources a thread wouldn't be able
+ * to release without this call when terminating itself are its
+ * last reference to its kernel port, its reply port, and its stack.
+ *
+ * This call is semantically equivalent to :
+ * - mach_port_deallocate(task, thread_name);
+ * - if (reply_port != MACH_PORT_NULL)
+ * mach_port_destroy(task, reply_port);
+ * - if ((address != 0) || (size != 0))
+ * vm_deallocate(task, address, size)
+ * - thread_terminate(thread)
+ *
+ * Implemented as a simple routine so a reply port isn't required.
+ */
+simpleroutine thread_terminate_release(
+ thread : thread_t;
+ task : task_t;
+ thread_name : mach_port_name_t;
+ reply_port : mach_port_name_t;
+ address : vm_address_t;
+ size : vm_size_t);
+
+/*
+ * Set the name of task TASK to NAME. This is a debugging aid.
+ * NAME will be used in error messages printed by the kernel.
+ */
+simpleroutine task_set_name(
+ task : task_t;
+ name : kernel_debug_name_t);
+
+/*
+ * Register a port to which a notification about newly created tasks
+ * are sent.
+ */
+routine register_new_task_notification(
+ host_priv : host_priv_t;
+ notification : mach_port_send_t);
+
+/* Test that the contents of ADDR are equal to the 32-bit integer VAL1.
+ * If they are not, return immediately, otherwise, block until a
+ * matching 'gsync_wake' is done on the same address. FLAGS is used
+ * to control how the thread waits, and may be composed of:
+ * - GSYNC_SHARED: The address may be shared among tasks. If this
+ bit is not set, the address is assumed to be task-local.
+ * - GSYNC_QUAD: Additionally check that the adjacent 32-bit word
+ following ADDR matches the value VAL2.
+ * - GSYNC_TIMED: The call only blocks for MSEC milliseconds. */
+routine gsync_wait(
+ task : task_t;
+ addr : vm_address_t;
+ val1 : unsigned;
+ val2 : unsigned;
+ msec : natural_t;
+ flags : int);
+
+/* Wake up threads waiting on the address ADDR. Much like with
+ * 'gsync_wait', the parameter FLAGS controls how it is done. In this
+ * case, it may be composed of the following:
+ * - GSYNC_SHARED: Same as with 'gsync_wait'.
+ * - GSYNC_BROADCAST: Wake up every thread waiting on the address. If
+ * this flag is not set, the call wakes (at most) 1 thread.
+ * - GSYNC_MUTATE: Before waking any potential waiting threads, set the
+ * contents of ADDR to VAL.
+ *
+ * This RPC is implemented as a simple routine for efficiency reasons,
+ * and because the return value rarely matters. */
+simpleroutine gsync_wake(
+ task : task_t;
+ addr : vm_address_t;
+ val : unsigned;
+ flags : int);
+
+/* Arrange for threads waiting on address SRC_ADDR to instead
+ * wait on address DST_ADDR. If WAKE_ONE is true, additionally
+ * wake one of the threads waiting on SRC_ADDR. For this function,
+ * the parameter flags may be a combination of:
+ * - GSYNC_SHARED: Just like with 'gsync_wait' and 'gsync_wake'.
+ * - GSYNC_BROADCAST: Move all the threads waiting on SRC_ADDR. If
+ this flag is not set, the call moves (at most) 1 thread.
+ *
+ * This RPC is also a simple routine, and for the same reasons as
+ * with 'gsync_wake'. */
+simpleroutine gsync_requeue(
+ task : task_t;
+ src_addr : vm_address_t;
+ dst_addr : vm_address_t;
+ wake_one : boolean_t;
+ flags : int);
+
+/*
+ * If the VM_WIRE_CURRENT flag is passed, specify that the entire
+ * virtual address space of the target task must not cause page faults.
+ *
+ * If the VM_WIRE_FUTURE flag is passed, automatically wire new
+ * mappings in the address space of the target task.
+ *
+ * If the flags are empty (VM_WIRE_NONE), unwire all mappings.
+ */
+routine vm_wire_all(
+ host : mach_port_t;
+ task : vm_task_t;
+ flags : vm_wire_t);
+
+routine vm_object_sync(
+ object : memory_object_name_t;
+ offset : vm_offset_t;
+ size : vm_size_t;
+ should_flush : boolean_t;
+ should_return : boolean_t;
+ should_iosync : boolean_t);
+
+routine vm_msync(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t;
+ sync_flags : vm_sync_t);
+
+/*
+ * This routine is created for allocating DMA buffers.
+ * We are going to get a contiguous physical memory
+ * and its physical address in addition to the virtual address.
+ * We can specify physical memory range limits and alignment.
+ * NB:
+ * pmax is defined as the byte after the maximum address,
+ * eg 0x100000000 for 4GiB limit.
+ */
+/* XXX
+ * Future work: the RPC should return a special
+ * memory object (similar to device_map() ), which can then be mapped into
+ * the process address space with vm_map() like any other memory object.
+ */
+routine vm_allocate_contiguous(
+ host_priv : host_priv_t;
+ target_task : vm_task_t;
+ out vaddr : vm_address_t;
+ out paddr : rpc_phys_addr_t;
+ size : vm_size_t;
+ pmin : rpc_phys_addr_t;
+ pmax : rpc_phys_addr_t;
+ palign : rpc_phys_addr_t);
+
+/*
+ * Set whether TASK is an essential task, i.e. the whole system will crash
+ * if this task crashes.
+ */
+simpleroutine task_set_essential(
+ task : task_t;
+ essential : boolean_t);
+
+/*
+ * Returns physical addresses of a region of memory
+ */
+routine vm_pages_phys(
+ host_priv : host_priv_t;
+ target_task : vm_task_t;
+ vaddr : vm_address_t;
+ size : vm_size_t;
+ out pages : rpc_phys_addr_array_t);
+
+/*
+ * Set the name of thread THREAD to NAME. This is a debugging aid.
+ * NAME will be used in error messages printed by the kernel.
+ */
+simpleroutine thread_set_name(
+ thread : thread_t;
+ name : kernel_debug_name_t);
diff --git a/include/mach/host_info.h b/include/mach/host_info.h
new file mode 100644
index 0000000..b84376b
--- /dev/null
+++ b/include/mach/host_info.h
@@ -0,0 +1,90 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993,1992,1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/host_info.h
+ *
+ * Definitions for host_info call.
+ */
+
+#ifndef _MACH_HOST_INFO_H_
+#define _MACH_HOST_INFO_H_
+
+#include <mach/machine.h>
+#include <mach/machine/vm_types.h>
+
+/*
+ * Generic information structure to allow for expansion.
+ */
+typedef integer_t *host_info_t; /* varying array of integers */
+
+#define HOST_INFO_MAX (1024) /* max array size */
+typedef integer_t host_info_data_t[HOST_INFO_MAX];
+
+#define KERNEL_VERSION_MAX (512)
+typedef char kernel_version_t[KERNEL_VERSION_MAX];
+
+/*
+ * Currently defined information.
+ */
+#define HOST_BASIC_INFO 1 /* basic info */
+#define HOST_PROCESSOR_SLOTS 2 /* processor slot numbers */
+#define HOST_SCHED_INFO 3 /* scheduling info */
+#define HOST_LOAD_INFO 4 /* avenrun/mach_factor info */
+
+struct host_basic_info {
+ integer_t max_cpus; /* max number of cpus possible */
+ integer_t avail_cpus; /* number of cpus now available */
+ rpc_vm_size_t memory_size; /* size of memory in bytes */
+ cpu_type_t cpu_type; /* cpu type */
+ cpu_subtype_t cpu_subtype; /* cpu subtype */
+};
+
+typedef struct host_basic_info host_basic_info_data_t;
+typedef struct host_basic_info *host_basic_info_t;
+#define HOST_BASIC_INFO_COUNT \
+ (sizeof(host_basic_info_data_t)/sizeof(integer_t))
+
+struct host_sched_info {
+ integer_t min_timeout; /* minimum timeout in milliseconds */
+ integer_t min_quantum; /* minimum quantum in milliseconds */
+};
+
+typedef struct host_sched_info host_sched_info_data_t;
+typedef struct host_sched_info *host_sched_info_t;
+#define HOST_SCHED_INFO_COUNT \
+ (sizeof(host_sched_info_data_t)/sizeof(integer_t))
+
+struct host_load_info {
+ integer_t avenrun[3]; /* scaled by LOAD_SCALE */
+ integer_t mach_factor[3]; /* scaled by LOAD_SCALE */
+};
+
+typedef struct host_load_info host_load_info_data_t;
+typedef struct host_load_info *host_load_info_t;
+#define HOST_LOAD_INFO_COUNT \
+ (sizeof(host_load_info_data_t)/sizeof(integer_t))
+
+#endif /* _MACH_HOST_INFO_H_ */
diff --git a/include/mach/inline.h b/include/mach/inline.h
new file mode 100644
index 0000000..35f5c5d
--- /dev/null
+++ b/include/mach/inline.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 1994 The University of Utah and
+ * the Center for Software Science (CSS). All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * THE UNIVERSITY OF UTAH AND CSS ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
+ * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSS DISCLAIM ANY LIABILITY OF
+ * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * CSS requests users of this software to return to css-dist@cs.utah.edu any
+ * improvements that they make and grant CSS redistribution rights.
+ *
+ * Author: Bryan Ford, University of Utah CSS
+ */
+#ifndef _MACH_INLINE_H_
+#define _MACH_INLINE_H_
+
+#ifndef MACH_INLINE
+#define MACH_INLINE extern __inline
+#endif
+
+#endif /* _MACH_INLINE_H_ */
diff --git a/include/mach/kern_return.h b/include/mach/kern_return.h
new file mode 100644
index 0000000..15b836f
--- /dev/null
+++ b/include/mach/kern_return.h
@@ -0,0 +1,166 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University.
+ * Copyright (c) 1993,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
+ * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
+ * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
+ * THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: h/kern_return.h
+ * Author: Avadis Tevanian, Jr.
+ * Date: 1985
+ *
+ * Kernel return codes.
+ *
+ */
+
+#ifndef _MACH_KERN_RETURN_H_
+#define _MACH_KERN_RETURN_H_
+
+#include <mach/machine/kern_return.h>
+
+#define KERN_SUCCESS 0
+
+#define KERN_INVALID_ADDRESS 1
+ /* Specified address is not currently valid.
+ */
+
+#define KERN_PROTECTION_FAILURE 2
+ /* Specified memory is valid, but does not permit the
+ * required forms of access.
+ */
+
+#define KERN_NO_SPACE 3
+ /* The address range specified is already in use, or
+ * no address range of the size specified could be
+ * found.
+ */
+
+#define KERN_INVALID_ARGUMENT 4
+ /* The function requested was not applicable to this
+ * type of argument, or an argument
+ */
+
+#define KERN_FAILURE 5
+ /* The function could not be performed. A catch-all.
+ */
+
+#define KERN_RESOURCE_SHORTAGE 6
+ /* A system resource could not be allocated to fulfill
+ * this request. This failure may not be permanent.
+ */
+
+#define KERN_NOT_RECEIVER 7
+ /* The task in question does not hold receive rights
+ * for the port argument.
+ */
+
+#define KERN_NO_ACCESS 8
+ /* Bogus access restriction.
+ */
+
+#define KERN_MEMORY_FAILURE 9
+ /* During a page fault, the target address refers to a
+ * memory object that has been destroyed. This
+ * failure is permanent.
+ */
+
+#define KERN_MEMORY_ERROR 10
+ /* During a page fault, the memory object indicated
+ * that the data could not be returned. This failure
+ * may be temporary; future attempts to access this
+ * same data may succeed, as defined by the memory
+ * object.
+ */
+
+/* KERN_ALREADY_IN_SET 11 obsolete */
+
+#define KERN_NOT_IN_SET 12
+ /* The receive right is not a member of a port set.
+ */
+
+#define KERN_NAME_EXISTS 13
+ /* The name already denotes a right in the task.
+ */
+
+#define KERN_ABORTED 14
+ /* The operation was aborted. Ipc code will
+ * catch this and reflect it as a message error.
+ */
+
+#define KERN_INVALID_NAME 15
+ /* The name doesn't denote a right in the task.
+ */
+
+#define KERN_INVALID_TASK 16
+ /* Target task isn't an active task.
+ */
+
+#define KERN_INVALID_RIGHT 17
+ /* The name denotes a right, but not an appropriate right.
+ */
+
+#define KERN_INVALID_VALUE 18
+ /* A blatant range error.
+ */
+
+#define KERN_UREFS_OVERFLOW 19
+ /* Operation would overflow limit on user-references.
+ */
+
+#define KERN_INVALID_CAPABILITY 20
+ /* The supplied (port) capability is improper.
+ */
+
+#define KERN_RIGHT_EXISTS 21
+ /* The task already has send or receive rights
+ * for the port under another name.
+ */
+
+#define KERN_INVALID_HOST 22
+ /* Target host isn't actually a host.
+ */
+
+#define KERN_MEMORY_PRESENT 23
+ /* An attempt was made to supply "precious" data
+ * for memory that is already present in a
+ * memory object.
+ */
+
+#define KERN_WRITE_PROTECTION_FAILURE 24
+ /*
+ * A page was marked as VM_PROT_NOTIFY and an attempt was
+ * made to write it
+ */
+#define KERN_TERMINATED 26
+ /* Object has been terminated and is no longer available.
+ */
+
+#define KERN_TIMEDOUT 27
+ /* Kernel operation timed out. */
+
+#define KERN_INTERRUPTED 28
+ /* Kernel operation was interrupted. */
+
+#endif /* _MACH_KERN_RETURN_H_ */
diff --git a/include/mach/mach.defs b/include/mach/mach.defs
new file mode 100644
index 0000000..c6ad077
--- /dev/null
+++ b/include/mach/mach.defs
@@ -0,0 +1,724 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University.
+ * Copyright (c) 1993,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
+ * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
+ * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
+ * THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Matchmaker definitions file for Mach kernel interface.
+ */
+
+subsystem
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+ mach 2000;
+
+#ifdef KERNEL_USER
+userprefix r_;
+#endif /* KERNEL_USER */
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#ifdef MACH_IMPORTS
+MACH_IMPORTS
+#endif
+
+skip; /* old port_allocate */
+skip; /* old port_deallocate */
+skip; /* old port_enable */
+skip; /* old port_disable */
+skip; /* old port_select */
+skip; /* old port_set_backlog */
+skip; /* old port_status */
+
+/* We use only a handful of RPCs as client. Skip the rest. */
+#if ! KERNEL_USER
+
+/*
+ * Create a new task with an empty set of IPC rights,
+ * and having an address space constructed from the
+ * target task (or empty, if inherit_memory is FALSE).
+ */
+routine task_create(
+ target_task : task_t;
+ inherit_memory : boolean_t;
+ out child_task : task_t);
+
+/*
+ * Destroy the target task, causing all of its threads
+ * to be destroyed, all of its IPC rights to be deallocated,
+ * and all of its address space to be deallocated.
+ */
+routine task_terminate(
+ target_task : task_t);
+
+/*
+ * Get user-level handler entry points for all
+ * emulated system calls.
+ */
+routine task_get_emulation_vector(
+ task : task_t;
+ out vector_start : int;
+ out emulation_vector: emulation_vector_t);
+
+/*
+ * Establish user-level handlers for the specified
+ * system calls. Non-emulated system calls are specified
+ * with emulation_vector[i] == EML_ROUTINE_NULL.
+ */
+routine task_set_emulation_vector(
+ task : task_t;
+ vector_start : int;
+ emulation_vector: emulation_vector_t);
+
+
+/*
+ * Returns the set of threads belonging to the target task.
+ */
+routine task_threads(
+ target_task : task_t;
+ out thread_list : thread_array_t);
+
+/*
+ * Returns information about the target task.
+ */
+routine task_info(
+ target_task : task_t;
+ flavor : int;
+ out task_info_out : task_info_t, CountInOut);
+
+
+skip; /* old task_status */
+skip; /* old task_set_notify */
+skip; /* old thread_create */
+
+/*
+ * Destroy the target thread.
+ */
+routine thread_terminate(
+ target_thread : thread_t);
+
+/*
+ * Return the selected state information for the target
+ * thread. If the thread is currently executing, the results
+ * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a
+ * list of valid flavors for the target thread.]
+ */
+routine thread_get_state(
+ target_thread : thread_t;
+ flavor : int;
+ out old_state : thread_state_t, CountInOut);
+
+/*
+ * Set the selected state information for the target thread.
+ * If the thread is currently executing, the state change
+ * may be ill-defined.
+ */
+routine thread_set_state(
+ target_thread : thread_t;
+ flavor : int;
+ new_state : thread_state_t);
+
+/*
+ * Returns information about the target thread.
+ */
+routine thread_info(
+ target_thread : thread_t;
+ flavor : int;
+ out thread_info_out : thread_info_t, CountInOut);
+
+skip; /* old thread_mutate */
+
+/*
+ * Allocate zero-filled memory in the address space
+ * of the target task, either at the specified address,
+ * or wherever space can be found (if anywhere is TRUE),
+ * of the specified size. The address at which the
+ * allocation actually took place is returned.
+ */
+#ifdef EMULATOR
+skip; /* the emulator redefines vm_allocate using vm_map */
+#else /* EMULATOR */
+routine vm_allocate(
+ target_task : vm_task_t;
+ inout address : vm_address_t;
+ size : vm_size_t;
+ anywhere : boolean_t);
+#endif /* EMULATOR */
+
+skip; /* old vm_allocate_with_pager */
+
+/*
+ * Deallocate the specified range from the virtual
+ * address space of the target task.
+ */
+routine vm_deallocate(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t);
+
+/*
+ * Set the current or maximum protection attribute
+ * for the specified range of the virtual address
+ * space of the target task. The current protection
+ * limits the memory access rights of threads within
+ * the task; the maximum protection limits the accesses
+ * that may be given in the current protection.
+ * Protections are specified as a set of {read, write, execute}
+ * *permissions*.
+ */
+routine vm_protect(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t;
+ set_maximum : boolean_t;
+ new_protection : vm_prot_t);
+
+/*
+ * Set the inheritance attribute for the specified range
+ * of the virtual address space of the target task.
+ * The inheritance value is one of {none, copy, share}, and
+ * specifies how the child address space should acquire
+ * this memory at the time of a task_create call.
+ */
+routine vm_inherit(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t;
+ new_inheritance : vm_inherit_t);
+
+/*
+ * Returns the contents of the specified range of the
+ * virtual address space of the target task. [The
+ * range must be aligned on a virtual page boundary,
+ * and must be a multiple of pages in extent. The
+ * protection on the specified range must permit reading.]
+ */
+routine vm_read(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t;
+ out data : pointer_t);
+
+/*
+ * Writes the contents of the specified range of the
+ * virtual address space of the target task. [The
+ * range must be aligned on a virtual page boundary,
+ * and must be a multiple of pages in extent. The
+ * protection on the specified range must permit writing.]
+ */
+routine vm_write(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ data : pointer_t);
+
+/*
+ * Copy the contents of the source range of the virtual
+ * address space of the target task to the destination
+ * range in that same address space. [Both of the
+ * ranges must be aligned on a virtual page boundary,
+ * and must be multiples of pages in extent. The
+ * protection on the source range must permit reading,
+ * and the protection on the destination range must
+ * permit writing.]
+ */
+routine vm_copy(
+ target_task : vm_task_t;
+ source_address : vm_address_t;
+ size : vm_size_t;
+ dest_address : vm_address_t);
+
+/*
+ * Returns information about the contents of the virtual
+ * address space of the target task at the specified
+ * address. The returned protection, inheritance, sharing
+ * and memory object values apply to the entire range described
+ * by the address range returned; the memory object offset
+ * corresponds to the beginning of the address range.
+ * [If the specified address is not allocated, the next
+ * highest address range is described. If no addresses beyond
+ * the one specified are allocated, the call returns KERN_NO_SPACE.]
+ */
+routine vm_region(
+ target_task : vm_task_t;
+ inout address : vm_address_t;
+ out size : vm_size_t;
+ out protection : vm_prot_t;
+ out max_protection : vm_prot_t;
+ out inheritance : vm_inherit_t;
+ out is_shared : boolean_t;
+ /* avoid out-translation of the argument */
+ out object_name : memory_object_name_t =
+ MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t;
+ out offset : vm_offset_t);
+
+/*
+ * Return virtual memory statistics for the host
+ * on which the target task resides. [Note that the
+ * statistics are not specific to the target task.]
+ */
+routine vm_statistics(
+ target_task : vm_task_t;
+ out vm_stats : vm_statistics_data_t);
+
+skip; /* old task_by_u*x_pid */
+skip; /* old vm_pageable */
+
+/*
+ * Stash a handful of ports for the target task; child
+ * tasks inherit this stash at task_create time.
+ */
+routine mach_ports_register(
+ target_task : task_t;
+ init_port_set : mach_port_array_t =
+ ^array[] of mach_port_t);
+
+/*
+ * Retrieve the stashed ports for the target task.
+ */
+routine mach_ports_lookup(
+ target_task : task_t;
+ out init_port_set : mach_port_array_t =
+ ^array[] of mach_port_t);
+
+skip; /* old u*x_pid */
+skip; /* old netipc_listen */
+skip; /* old netipc_ignore */
+
+#else /* ! KERNEL_USER */
+
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip;
+
+#endif /* ! KERNEL_USER */
+
+skip; /* was: memory_object_data_provided */
+
+/*
+ * Indicate that a range of the given temporary memory object does
+ * not exist, and that the backing memory object should be used
+ * instead (or zero-fill memory be used, if no backing object exists).
+ * [This call is intended for use only by the default memory manager.
+ * It should not be used to indicate a real error --
+ * memory_object_data_error should be used for that purpose.]
+ */
+simpleroutine memory_object_data_unavailable(
+ memory_control : memory_object_control_t;
+ offset : vm_offset_t;
+ size : vm_size_t);
+
+/*
+ * Retrieves the attributes currently associated with
+ * a memory object.
+ */
+routine memory_object_get_attributes(
+ memory_control : memory_object_control_t;
+ out object_ready : boolean_t;
+ out may_cache : boolean_t;
+ out copy_strategy : memory_object_copy_strategy_t);
+
+#if ! KERNEL_USER
+
+/*
+ * Sets the default memory manager, the port to which
+ * newly-created temporary memory objects are delivered.
+ * [See (memory_object_default)memory_object_create.]
+ * The old memory manager port is returned.
+ */
+routine vm_set_default_memory_manager(
+ host_priv : host_priv_t;
+ inout default_manager : mach_port_make_send_t);
+
+#else /* ! KERNEL_USER */
+
+skip;
+
+#endif /* ! KERNEL_USER */
+
+skip; /* old pager_flush_request */
+
+/*
+ * Control use of the data associated with the given
+ * memory object. For each page in the given range,
+ * perform the following operations, in order:
+ * 1) restrict access to the page (disallow
+ * forms specified by "prot");
+ * 2) write back modifications (if "should_return"
+ * is RETURN_DIRTY and the page is dirty, or
+ * "should_return" is RETURN_ALL and the page
+ * is either dirty or precious); and,
+ * 3) flush the cached copy (if "should_flush"
+ * is asserted).
+ * The set of pages is defined by a starting offset
+ * ("offset") and size ("size"). Only pages with the
+ * same page alignment as the starting offset are
+ * considered.
+ *
+ * A single acknowledgement is sent (to the "reply_to"
+ * port) when these actions are complete.
+ *
+ * There are two versions of this routine because IPC distinguishes
+ * between booleans and integers (a 2-valued integer is NOT a
+ * boolean). The new routine is backwards compatible at the C
+ * language interface.
+ */
+
+skip; /* old xxx_memory_object_lock_request */
+
+simpleroutine memory_object_lock_request(
+ memory_control : memory_object_control_t;
+ offset : vm_offset_t;
+ size : vm_size_t;
+ should_return : memory_object_return_t;
+ should_flush : boolean_t;
+ lock_value : vm_prot_t;
+ reply_to : mach_port_t =
+ MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
+
+skip; /* old xxx_task_get_emulation_vector */
+skip; /* old xxx_task_set_emulation_vector */
+skip; /* old xxx_host_info */
+skip; /* old xxx_slot_info */
+skip; /* old xxx_cpu_control */
+skip; /* old thread_statistics */
+skip; /* old task_statistics */
+skip; /* old netport_init */
+skip; /* old netport_enter */
+skip; /* old netport_remove */
+skip; /* old thread_set_priority */
+
+#if ! KERNEL_USER
+
+/*
+ * Increment the suspend count for the target task.
+ * No threads within a task may run when the suspend
+ * count for that task is non-zero.
+ */
+routine task_suspend(
+ target_task : task_t);
+
+/*
+ * Decrement the suspend count for the target task,
+ * if the count is currently non-zero. If the resulting
+ * suspend count is zero, then threads within the task
+ * that also have non-zero suspend counts may execute.
+ */
+routine task_resume(
+ target_task : task_t);
+
+/*
+ * Returns the current value of the selected special port
+ * associated with the target task.
+ */
+routine task_get_special_port(
+ task : task_t;
+ which_port : int;
+ out special_port : mach_port_t);
+
+/*
+ * Set one of the special ports associated with the
+ * target task.
+ */
+routine task_set_special_port(
+ task : task_t;
+ which_port : int;
+ special_port : mach_port_t);
+
+skip; /* old xxx_task_info */
+
+
+/*
+ * Create a new thread within the target task, returning
+ * the port representing that new thread. The
+ * initial execution state of the thread is undefined.
+ */
+routine thread_create(
+ parent_task : task_t;
+ out child_thread : thread_t);
+
+/*
+ * Increment the suspend count for the target thread.
+ * Once this call has completed, the thread will not
+ * execute any further user or meta- instructions.
+ * Once suspended, a thread may not execute again until
+ * its suspend count is zero, and the suspend count
+ * for its task is also zero.
+ */
+routine thread_suspend(
+ target_thread : thread_t);
+
+/*
+ * Decrement the suspend count for the target thread,
+ * if that count is not already zero.
+ */
+routine thread_resume(
+ target_thread : thread_t);
+
+/*
+ * Cause any user or meta- instructions currently being
+ * executed by the target thread to be aborted. [Meta-
+ * instructions consist of the basic traps for IPC
+ * (e.g., msg_send, msg_receive) and self-identification
+ * (e.g., task_self, thread_self, thread_reply). Calls
+ * described by MiG interfaces are not meta-instructions
+ * themselves.]
+ */
+routine thread_abort(
+ target_thread : thread_t);
+
+skip; /* old xxx_thread_get_state */
+skip; /* old xxx_thread_set_state */
+
+/*
+ * Returns the current value of the selected special port
+ * associated with the target thread.
+ */
+routine thread_get_special_port(
+ thread : thread_t;
+ which_port : int;
+ out special_port : mach_port_t);
+
+/*
+ * Set one of the special ports associated with the
+ * target thread.
+ */
+routine thread_set_special_port(
+ thread : thread_t;
+ which_port : int;
+ special_port : mach_port_t);
+
+skip; /* old xxx_thread_info */
+
+/*
+ * Establish a user-level handler for the specified
+ * system call.
+ */
+routine task_set_emulation(
+ target_port : task_t;
+ routine_entry_pt: vm_address_t;
+ routine_number : int);
+
+/*
+ * Establish restart pc for interrupted atomic sequences.
+ * This reuses the message number for the old task_get_io_port.
+ * See task_info.h for description of flavors.
+ *
+ */
+routine task_ras_control(
+ target_task : task_t;
+ basepc : vm_address_t;
+ boundspc : vm_address_t;
+ flavor : int);
+
+
+
+skip; /* old host_ipc_statistics */
+skip; /* old port_names */
+skip; /* old port_type */
+skip; /* old port_rename */
+skip; /* old port_allocate */
+skip; /* old port_deallocate */
+skip; /* old port_set_backlog */
+skip; /* old port_status */
+skip; /* old port_set_allocate */
+skip; /* old port_set_deallocate */
+skip; /* old port_set_add */
+skip; /* old port_set_remove */
+skip; /* old port_set_status */
+skip; /* old port_insert_send */
+skip; /* old port_extract_send */
+skip; /* old port_insert_receive */
+skip; /* old port_extract_receive */
+
+/*
+ * Map a user-defined memory object into the virtual address
+ * space of the target task. If desired (anywhere is TRUE),
+ * the kernel will find a suitable address range of the
+ * specified size; else, the specific address will be allocated.
+ *
+ * The beginning address of the range will be aligned on a virtual
+ * page boundary, be at or beyond the address specified, and
+ * meet the mask requirements (bits turned on in the mask must not
+ * be turned on in the result); the size of the range, in bytes,
+ * will be rounded up to an integral number of virtual pages.
+ *
+ * The memory in the resulting range will be associated with the
+ * specified memory object, with the beginning of the memory range
+ * referring to the specified offset into the memory object.
+ *
+ * The mapping will take the current and maximum protections and
+ * the inheritance attributes specified; see the vm_protect and
+ * vm_inherit calls for a description of these attributes.
+ *
+ * If desired (copy is TRUE), the memory range will be filled
+ * with a copy of the data from the memory object; this copy will
+ * be private to this mapping in this target task. Otherwise,
+ * the memory in this mapping will be shared with other mappings
+ * of the same memory object at the same offset (in this task or
+ * in other tasks). [The Mach kernel only enforces shared memory
+ * consistency among mappings on one host with similar page alignments.
+ * The user-defined memory manager for this object is responsible
+ * for further consistency.]
+ */
+#ifdef EMULATOR
+routine htg_vm_map(
+ target_task : vm_task_t;
+ ureplyport reply_port : mach_port_make_send_once_t;
+ inout address : vm_address_t;
+ size : vm_size_t;
+ mask : vm_address_t;
+ anywhere : boolean_t;
+ memory_object : memory_object_t;
+ offset : vm_offset_t;
+ copy : boolean_t;
+ cur_protection : vm_prot_t;
+ max_protection : vm_prot_t;
+ inheritance : vm_inherit_t);
+#else /* EMULATOR */
+routine vm_map(
+ target_task : vm_task_t;
+ inout address : vm_address_t;
+ size : vm_size_t;
+ mask : vm_address_t;
+ anywhere : boolean_t;
+ memory_object : memory_object_t;
+ offset : vm_offset_t;
+ copy : boolean_t;
+ cur_protection : vm_prot_t;
+ max_protection : vm_prot_t;
+ inheritance : vm_inherit_t);
+#endif /* EMULATOR */
+
+#else /* ! KERNEL_USER */
+
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip; skip;
+skip; skip; skip; skip;
+
+#endif /* ! KERNEL_USER */
+
+/*
+ * Indicate that a range of the specified memory object cannot
+ * be provided at this time. [Threads waiting for memory pages
+ * specified by this call will experience a memory exception.
+ * Only threads waiting at the time of the call are affected.]
+ */
+simpleroutine memory_object_data_error(
+ memory_control : memory_object_control_t;
+ offset : vm_offset_t;
+ size : vm_size_t;
+ error_value : kern_return_t);
+
+skip; /* was: memory_object_set_attributes */
+
+/*
+ */
+simpleroutine memory_object_destroy(
+ memory_control : memory_object_control_t;
+ reason : kern_return_t);
+
+/*
+ * Provide the data contents of a range of the given memory
+ * object, with the access restriction specified, optional
+ * precious attribute, and reply message. [Only
+ * whole virtual pages of data can be accepted; partial pages
+ * will be discarded. Data should be provided on request, but
+ * may be provided in advance as desired. When data already
+ * held by this kernel is provided again, the new data is ignored.
+ * The access restriction is the subset of {read, write, execute}
+ * which are prohibited. The kernel may not provide any data (or
+ * protection) consistency among pages with different virtual page
+ * alignments within the same object. The precious value controls
+ * how the kernel treats the data. If it is FALSE, the kernel treats
+ * its copy as a temporary and may throw it away if it hasn't been
+ * changed. If the precious value is TRUE, the kernel treats its
+ * copy as a data repository and promises to return it to the manager;
+ * the manager may tell the kernel to throw it away instead by flushing
+ * and not cleaning the data -- see memory_object_lock_request. The
+ * reply_to port is for a compeletion message; it will be
+ * memory_object_supply_completed.]
+ */
+
+simpleroutine memory_object_data_supply(
+ memory_control : memory_object_control_t;
+ offset : vm_offset_t;
+ data : pointer_t, Dealloc[];
+ lock_value : vm_prot_t;
+ precious : boolean_t;
+ reply_to : mach_port_t =
+ MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
+
+simpleroutine memory_object_ready(
+ memory_control : memory_object_control_t;
+ may_cache : boolean_t;
+ copy_strategy : memory_object_copy_strategy_t);
+
+simpleroutine memory_object_change_attributes(
+ memory_control : memory_object_control_t;
+ may_cache : boolean_t;
+ copy_strategy : memory_object_copy_strategy_t;
+ reply_to : mach_port_t =
+ MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
+
+#if ! KERNEL_USER
+
+skip; /* old host_callout_statistics_reset */
+skip; /* old port_set_select */
+skip; /* old port_set_backup */
+
+/*
+ * Set/Get special properties of memory associated
+ * to some virtual address range, such as cachability,
+ * migrability, replicability. Machine-dependent.
+ */
+routine vm_machine_attribute(
+ target_task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t;
+ attribute : vm_machine_attribute_t;
+ inout value : vm_machine_attribute_val_t);
+
+skip; /* old host_fpa_counters_reset */
+
+#endif /* ! KERNEL_USER */
+
+/*
+ * There is no more room in this interface for additional calls.
+ */
diff --git a/include/mach/mach4.defs b/include/mach/mach4.defs
new file mode 100644
index 0000000..d63d6f7
--- /dev/null
+++ b/include/mach/mach4.defs
@@ -0,0 +1,131 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1994,1993,1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Matchmaker definitions file for Mach4 kernel interface.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+ mach4 4000;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+
+#ifdef MACH_PCSAMPLE
+type sampled_pc_flavor_t = unsigned;
+
+type sampled_pc_t = struct {
+ rpc_vm_offset_t id;
+ rpc_vm_offset_t pc;
+ sampled_pc_flavor_t sampletype;
+};
+
+type sampled_pc_array_t = array[*:512] of sampled_pc_t;
+type sampled_pc_seqno_t = unsigned;
+
+routine task_enable_pc_sampling(
+ host : task_t;
+ out tick : int; /* sample frequency in usecs */
+ flavor : sampled_pc_flavor_t );
+
+routine task_disable_pc_sampling(
+ host : task_t;
+ out samplecnt : int);
+
+routine task_get_sampled_pcs(
+ host : task_t;
+ inout seqno : sampled_pc_seqno_t;
+ out sampled_pcs : sampled_pc_array_t);
+
+routine thread_enable_pc_sampling(
+ host : thread_t;
+ out tick : int; /* sample frequency in usecs*/
+ flavor : sampled_pc_flavor_t );
+
+routine thread_disable_pc_sampling(
+ host : thread_t;
+ out samplecnt : int);
+
+routine thread_get_sampled_pcs(
+ host : thread_t;
+ inout seqno : sampled_pc_seqno_t;
+ out sampled_pcs : sampled_pc_array_t);
+
+
+skip /* pc_sampling reserved 1*/;
+skip /* pc_sampling reserved 2*/;
+skip /* pc_sampling reserved 3*/;
+skip /* pc_sampling reserved 4*/;
+
+#else
+
+skip; /* task_enable_pc_sampling */
+skip; /* task_disable_pc_sampling */
+skip; /* task_get_sampled_pcs */
+skip; /* thread_enable_pc_sampling */
+skip; /* thread_disable_pc_sampling */
+skip; /* thread_get_sampled_pcs */
+
+skip /* pc_sampling reserved 1*/;
+skip /* pc_sampling reserved 2*/;
+skip /* pc_sampling reserved 3*/;
+skip /* pc_sampling reserved 4*/;
+
+#endif
+
+
+/* Create a new proxy memory object from [START;START+LEN) in the
+ given memory object OBJECT at OFFSET in the new object with the maximum
+ protection MAX_PROTECTION and return it in *PORT. */
+type vm_offset_array_t = array[*:1024] of vm_offset_t;
+type vm_size_array_t = array[*:1024] of vm_size_t;
+type rpc_vm_size_array_t = array[*:1024] of rpc_vm_size_t;
+type rpc_vm_offset_array_t = array[*:1024] of rpc_vm_offset_t;
+routine memory_object_create_proxy(
+ task : ipc_space_t;
+ max_protection : vm_prot_t;
+ object : memory_object_array_t =
+ array[*:1024] of mach_port_send_t;
+ offset : rpc_vm_offset_array_t;
+ start : rpc_vm_offset_array_t;
+ len : rpc_vm_size_array_t;
+ out proxy : mach_port_t);
+
+/* Gets a proxy to the region that ADDRESS belongs to, starting at the region
+ start, with MAX_PROTECTION and LEN limited by the region ones, and returns
+ it in *PORT. */
+routine vm_region_create_proxy(
+ task : task_t;
+ address : vm_address_t;
+ max_protection : vm_prot_t;
+ len : vm_size_t;
+ out proxy : mach_port_t);
diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs
new file mode 100644
index 0000000..a8c40af
--- /dev/null
+++ b/include/mach/mach_host.defs
@@ -0,0 +1,388 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University.
+ * Copyright (c) 1993,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
+ * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
+ * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
+ * THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/mach_host.defs
+ *
+ * Abstract:
+ * Mach host operations support. Includes processor allocation and
+ * control.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif
+ mach_host 2600;
+
+/*
+ * Basic types
+ */
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#ifdef MACH_HOST_IMPORTS
+MACH_HOST_IMPORTS
+#endif
+
+/*
+ * Get list of processors on this host.
+ */
+
+routine host_processors(
+ host_priv : host_priv_t;
+ out processor_list : processor_array_t);
+
+skip; /* old yyy_host_info */
+skip; /* old yyy_processor_info */
+
+/*
+ * Start processor.
+ */
+
+routine processor_start(
+ processor : processor_t);
+
+/*
+ * Exit processor -- may not be restartable.
+ */
+
+routine processor_exit(
+ processor : processor_t);
+
+skip; /* old yyy_processor_control */
+
+/*
+ * Get default processor set for host.
+ */
+routine processor_set_default(
+ host : host_t;
+ out default_set : processor_set_name_t);
+
+skip; /* old xxx_processor_set_default_priv */
+
+/*
+ * Create new processor set. Returns real port for manipulations,
+ * and name port for obtaining information.
+ */
+routine processor_set_create(
+ host : host_t;
+ out new_set : processor_set_t;
+ out new_name : processor_set_name_t);
+
+/*
+ * Destroy processor set.
+ */
+routine processor_set_destroy(
+ set : processor_set_t);
+
+skip; /* old yyy_processor_set_info */
+
+/*
+ * Assign processor to processor set.
+ */
+routine processor_assign(
+ processor : processor_t;
+ new_set : processor_set_t;
+ wait : boolean_t);
+
+/*
+ * Get current assignment for processor.
+ */
+
+routine processor_get_assignment(
+ processor : processor_t;
+ out assigned_set : processor_set_name_t);
+
+/*
+ * Assign thread to processor set.
+ */
+routine thread_assign(
+ thread : thread_t;
+ new_set : processor_set_t);
+
+/*
+ * Assign thread to default set.
+ */
+routine thread_assign_default(
+ thread : thread_t);
+
+/*
+ * Get current assignment for thread.
+ */
+routine thread_get_assignment(
+ thread : thread_t;
+ out assigned_set : processor_set_name_t);
+
+/*
+ * Assign task to processor set.
+ */
+routine task_assign(
+ task : task_t;
+ new_set : processor_set_t;
+ assign_threads : boolean_t);
+/*
+ * Assign task to default set.
+ */
+routine task_assign_default(
+ task : task_t;
+ assign_threads : boolean_t);
+
+/*
+ * Get current assignment for task.
+ */
+routine task_get_assignment(
+ task : task_t;
+ out assigned_set : processor_set_name_t);
+
+#if defined(__x86_64__) && !defined(USER32)
+skip;
+#else
+/*
+ * Get string describing current kernel version.
+ * Deprecated, use host_get_kernel_version.
+ */
+routine host_kernel_version(
+ host : host_t;
+ out kernel_version : kernel_version_t);
+#endif
+
+/*
+ * Set priority for thread.
+ */
+routine thread_priority(
+ thread : thread_t;
+ priority : int;
+ set_max : boolean_t);
+
+/*
+ * Set max priority for thread.
+ */
+routine thread_max_priority(
+ thread : thread_t;
+ processor_set : processor_set_t;
+ max_priority : int);
+
+/*
+ * Set task priority.
+ */
+routine task_priority(
+ task : task_t;
+ priority : int;
+ change_threads : boolean_t);
+
+/*
+ * Set max priority for processor_set.
+ */
+routine processor_set_max_priority(
+ processor_set : processor_set_t;
+ max_priority : int;
+ change_threads : boolean_t);
+
+/*
+ * Set policy for thread
+ */
+routine thread_policy(
+ thread : thread_t;
+ policy : int;
+ data : int);
+
+/*
+ * Enable policy for processor set
+ */
+routine processor_set_policy_enable(
+ processor_set : processor_set_t;
+ policy : int);
+
+/*
+ * Disable policy for processor set
+ */
+routine processor_set_policy_disable(
+ processor_set : processor_set_t;
+ policy : int;
+ change_threads : boolean_t);
+/*
+ * List all tasks in processor set.
+ */
+routine processor_set_tasks(
+ processor_set : processor_set_t;
+ out task_list : task_array_t);
+
+/*
+ * List all threads in processor set.
+ */
+routine processor_set_threads(
+ processor_set : processor_set_t;
+ out thread_list : thread_array_t);
+
+/*
+ * List all processor sets on host.
+ */
+routine host_processor_sets(
+ host : host_t;
+ out processor_sets : processor_set_name_array_t);
+
+/*
+ * Get control port for a processor set.
+ */
+routine host_processor_set_priv(
+ host_priv : host_priv_t;
+ set_name : processor_set_name_t;
+ out set : processor_set_t);
+
+routine thread_depress_abort(
+ thread : thread_t);
+
+/*
+ * Set the time on this host.
+ * Only available to privileged users.
+ */
+routine host_set_time(
+ host_priv : host_priv_t;
+ new_time : time_value_t);
+
+/*
+ * Arrange for the time on this host to be gradually changed
+ * by an adjustment value, and return the old value.
+ * Only available to privileged users.
+ */
+routine host_adjust_time(
+ host_priv : host_priv_t;
+ in new_adjustment : time_value_t;
+ out old_adjustment : time_value_t);
+
+/*
+ * Get the time on this host.
+ * Available to all.
+ */
+routine host_get_time(
+ host : host_t;
+ out current_time : time_value_t);
+
+/*
+ * Reboot this host.
+ * Only available to privileged users.
+ */
+routine host_reboot(
+ host_priv : host_priv_t;
+ options : int);
+
+/*
+ * Specify that the range of the virtual address space
+ * of the target task must not cause page faults for
+ * the indicated accesses.
+ *
+ * [ To unwire the pages, specify VM_PROT_NONE. ]
+ */
+routine vm_wire(
+ host : mach_port_t;
+ task : vm_task_t;
+ address : vm_address_t;
+ size : vm_size_t;
+ access : vm_prot_t);
+
+/*
+ * Specify that the target thread must always be able
+ * to run and to allocate memory.
+ */
+routine thread_wire(
+ host_priv : host_priv_t;
+ thread : thread_t;
+ wired : boolean_t);
+
+/*
+ * Return information about this host.
+ */
+
+routine host_info(
+ host : host_t;
+ flavor : int;
+ out host_info_out : host_info_t, CountInOut);
+
+
+/*
+ * Return information about this processor.
+ */
+routine processor_info(
+ processor : processor_t;
+ flavor : int;
+ out host : host_t;
+ out processor_info_out: processor_info_t, CountInOut);
+
+/*
+ * Get information about processor set.
+ */
+routine processor_set_info(
+ set_name : processor_set_name_t;
+ flavor : int;
+ out host : host_t;
+ out info_out : processor_set_info_t, CountInOut);
+
+/*
+ * Do something machine-dependent to processor.
+ */
+routine processor_control(
+ processor : processor_t;
+ processor_cmd : processor_info_t);
+
+/* host_get_boot_info */
+skip;
+
+/*
+ * Get the time on this host.
+ * Available to all.
+ */
+routine host_get_time64(
+ host : host_t;
+ out current_time : time_value64_t);
+
+/*
+ * Set the time on this host.
+ * Only available to privileged users.
+ */
+routine host_set_time64(
+ host : host_t;
+ new_time : time_value64_t);
+
+/*
+ * Arrange for the time on this host to be gradually changed
+ * by an adjustment value, and return the old value.
+ * Only available to privileged users.
+ */
+routine host_adjust_time64(
+ host_priv : host_priv_t;
+ in new_adjustment : time_value64_t;
+ out old_adjustment : time_value64_t);
+
+/*
+ * Get string describing current kernel version.
+ */
+routine host_get_kernel_version(
+ host : host_t;
+ out kernel_version : new_kernel_version_t);
diff --git a/include/mach/mach_param.h b/include/mach/mach_param.h
new file mode 100644
index 0000000..b2aca08
--- /dev/null
+++ b/include/mach/mach_param.h
@@ -0,0 +1,39 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/mach_param.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
+ * Date: 1986
+ *
+ * Mach system sizing parameters
+ */
+
+#ifndef _MACH_MACH_PARAM_H_
+#define _MACH_MACH_PARAM_H_
+
+#define TASK_PORT_REGISTER_MAX 4 /* Number of "registered" ports */
+
+#endif /* _MACH_MACH_PARAM_H_ */
diff --git a/include/mach/mach_port.defs b/include/mach/mach_port.defs
new file mode 100644
index 0000000..3823bb1
--- /dev/null
+++ b/include/mach/mach_port.defs
@@ -0,0 +1,360 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University.
+ * Copyright (c) 1993,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
+ * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
+ * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
+ * THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/mach_port.defs
+ * Author: Rich Draves
+ *
+ * Copyright (c) 1989 Richard P. Draves, Jr.
+ *
+ * Exported kernel calls.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif
+ mach_port 3200;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+/*
+ * Returns the set of port and port set names
+ * to which the target task has access, along with
+ * the type (set or port) for each name.
+ */
+
+routine mach_port_names(
+ task : ipc_space_t;
+ out names : mach_port_name_array_t =
+ ^array[] of mach_port_name_t;
+ out types : mach_port_type_array_t =
+ ^array[] of mach_port_type_t);
+
+/*
+ * Returns the type (set or port) for the port name
+ * within the target task. Also indicates whether
+ * there is a dead-name request for the name.
+ */
+
+routine mach_port_type(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out ptype : mach_port_type_t);
+
+/*
+ * Changes the name by which a port (or port set) is known to
+ * the target task. The new name can't be in use. The
+ * old name becomes available for recycling.
+ */
+
+routine mach_port_rename(
+ task : ipc_space_t;
+ old_name : mach_port_name_t;
+ new_name : mach_port_name_t);
+
+/*
+ * Allocates the specified kind of object, with the given name.
+ * The right must be one of
+ * MACH_PORT_RIGHT_RECEIVE
+ * MACH_PORT_RIGHT_PORT_SET
+ * MACH_PORT_RIGHT_DEAD_NAME
+ * New port sets are empty. New ports don't have any
+ * send/send-once rights or queued messages. The make-send
+ * count is zero and their queue limit is MACH_PORT_QLIMIT_DEFAULT.
+ * New sets, ports, and dead names have one user reference.
+ */
+
+routine mach_port_allocate_name(
+ task : ipc_space_t;
+ right : mach_port_right_t;
+ name : mach_port_name_t);
+
+/*
+ * Allocates the specified kind of object.
+ * The right must be one of
+ * MACH_PORT_RIGHT_RECEIVE
+ * MACH_PORT_RIGHT_PORT_SET
+ * MACH_PORT_RIGHT_DEAD_NAME
+ * Like port_allocate_name, but the kernel picks a name.
+ * It can use any name not associated with a right.
+ */
+
+routine mach_port_allocate(
+ task : ipc_space_t;
+ right : mach_port_right_t;
+ out name : mach_port_name_t);
+
+/*
+ * Destroys all rights associated with the name and makes it
+ * available for recycling immediately. The name can be a
+ * port (possibly with multiple user refs), a port set, or
+ * a dead name (again, with multiple user refs).
+ */
+
+routine mach_port_destroy(
+ task : ipc_space_t;
+ name : mach_port_name_t);
+
+/*
+ * Releases one send/send-once/dead-name user ref.
+ * Just like mach_port_mod_refs -1, but deduces the
+ * correct type of right. This allows a user task
+ * to release a ref for a port without worrying
+ * about whether the port has died or not.
+ */
+
+routine mach_port_deallocate(
+ task : ipc_space_t;
+ name : mach_port_name_t);
+
+/*
+ * A port set always has one user ref.
+ * A send-once right always has one user ref.
+ * A dead name always has one or more user refs.
+ * A send right always has one or more user refs.
+ * A receive right always has one user ref.
+ * The right must be one of
+ * MACH_PORT_RIGHT_RECEIVE
+ * MACH_PORT_RIGHT_PORT_SET
+ * MACH_PORT_RIGHT_DEAD_NAME
+ * MACH_PORT_RIGHT_SEND
+ * MACH_PORT_RIGHT_SEND_ONCE
+ */
+
+routine mach_port_get_refs(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ right : mach_port_right_t;
+ out refs : mach_port_urefs_t);
+
+/*
+ * The delta is a signed change to the task's
+ * user ref count for the right. Only dead names
+ * and send rights can have a positive delta.
+ * The resulting user ref count can't be negative.
+ * If it is zero, the right is deallocated.
+ * If the name isn't a composite right, it becomes
+ * available for recycling. The right must be one of
+ * MACH_PORT_RIGHT_RECEIVE
+ * MACH_PORT_RIGHT_PORT_SET
+ * MACH_PORT_RIGHT_DEAD_NAME
+ * MACH_PORT_RIGHT_SEND
+ * MACH_PORT_RIGHT_SEND_ONCE
+ */
+
+routine mach_port_mod_refs(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ right : mach_port_right_t;
+ delta : mach_port_delta_t);
+
+skip; /* old old_mach_port_get_receive_status */
+
+/*
+ * Only valid for receive rights.
+ * Sets the queue-limit for the port.
+ * The limit must be
+ * 1 <= qlimit <= MACH_PORT_QLIMIT_MAX
+ */
+
+routine mach_port_set_qlimit(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ qlimit : mach_port_msgcount_t);
+
+/*
+ * Only valid for receive rights.
+ * Sets the make-send count for the port.
+ */
+
+routine mach_port_set_mscount(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ mscount : mach_port_mscount_t);
+
+/*
+ * Only valid for port sets. Returns a list of
+ * the members.
+ */
+
+routine mach_port_get_set_status(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out members : mach_port_name_array_t =
+ ^array[] of mach_port_name_t);
+
+/*
+ * Puts the member port (the task must have receive rights)
+ * into the after port set. (Or removes it from any port set
+ * if after is MACH_PORT_NULL.) If the port is already in
+ * a set, does an atomic move.
+ */
+
+routine mach_port_move_member(
+ task : ipc_space_t;
+ member : mach_port_name_t;
+ after : mach_port_name_t);
+
+/*
+ * Requests a notification from the kernel. The request
+ * must supply the send-once right which is used for
+ * the notification. If a send-once right was previously
+ * registered, it is returned. The msg_id must be one of
+ * MACH_NOTIFY_PORT_DESTROYED (receive rights)
+ * MACH_NOTIFY_DEAD_NAME (send/receive/send-once rights)
+ * MACH_NOTIFY_NO_SENDERS (receive rights)
+ *
+ * The sync value specifies whether a notification should
+ * get sent immediately, if appropriate. The exact meaning
+ * depends on the notification:
+ * MACH_NOTIFY_PORT_DESTROYED: must be zero.
+ * MACH_NOTIFY_DEAD_NAME: if non-zero, then name can be dead,
+ * and the notification gets sent immediately.
+ * If zero, then name can't be dead.
+ * MACH_NOTIFY_NO_SENDERS: the notification gets sent
+ * immediately if the current mscount is greater
+ * than or equal to the sync value and there are no
+ * extant send rights.
+ */
+
+routine mach_port_request_notification(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ id : mach_msg_id_t;
+ sync : mach_port_mscount_t;
+ notify : mach_port_send_once_t;
+ out previous : mach_port_send_once_t);
+
+/*
+ * Inserts the specified rights into the target task,
+ * using the specified name. If inserting send/receive
+ * rights and the task already has send/receive rights
+ * for the port, then the names must agree. In any case,
+ * the task gains a user ref for the port.
+ */
+
+routine mach_port_insert_right(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ poly : mach_port_poly_t);
+
+/*
+ * Returns the specified right for the named port
+ * in the target task, extracting that right from
+ * the target task. The target task loses a user
+ * ref and the name may be available for recycling.
+ * msgt_name must be one of
+ * MACH_MSG_TYPE_MOVE_RECEIVE
+ * MACH_MSG_TYPE_COPY_SEND
+ * MACH_MSG_TYPE_MAKE_SEND
+ * MACH_MSG_TYPE_MOVE_SEND
+ * MACH_MSG_TYPE_MAKE_SEND_ONCE
+ * MACH_MSG_TYPE_MOVE_SEND_ONCE
+ */
+
+routine mach_port_extract_right(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ msgt_name : mach_msg_type_name_t;
+ out poly : mach_port_poly_t);
+
+/*
+ * The task must have receive rights for the named port.
+ * Returns a status structure (see mach/port.h).
+ */
+
+routine mach_port_get_receive_status(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out status : mach_port_status_t);
+
+/*
+ * Only valid for receive rights.
+ * Sets the sequence number for the port.
+ */
+
+routine mach_port_set_seqno(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ seqno : mach_port_seqno_t);
+
+#ifdef MIGRATING_THREADS
+/*
+ * Only valid for receive rights.
+ * Set the user-mode entry info for RPCs coming through this port.
+ * Do this BEFORE attaching an ActPool to this port,
+ * unless you can be sure no RPCs will be coming through it yet.
+ */
+
+routine mach_port_set_rpcinfo(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ rpc_info : thread_info_t); /* XXX */
+
+/*
+ * Only valid for receive rights.
+ * Create a new activation for migrating RPC, and attach it to the port's ActPool.
+ * Create an ActPool for the port if it doesn't already have one.
+ * Supply a stack and receive memory buffer.
+ */
+
+routine mach_port_create_act(
+ task : task_t;
+ name : mach_port_name_t;
+ user_stack : vm_offset_t;
+ user_rbuf : vm_offset_t;
+ user_rbuf_size : vm_size_t;
+ out new_act : thread_t);
+
+#else /* MIGRATING_THREADS */
+
+skip; /* mach_port_set_rpcinfo */
+skip; /* mach_port_create_act */
+
+#endif /* MIGRATING_THREADS */
+
+/*
+ * Only valid for receive rights.
+ * Set the protected payload for this right to the given value.
+ */
+
+routine mach_port_set_protected_payload(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ payload : rpc_uintptr_t);
+
+/*
+ * Only valid for receive rights.
+ * Clear the protected payload for this right.
+ */
+
+routine mach_port_clear_protected_payload(
+ task : ipc_space_t;
+ name : mach_port_name_t);
diff --git a/include/mach/mach_traps.h b/include/mach/mach_traps.h
new file mode 100644
index 0000000..2a87f62
--- /dev/null
+++ b/include/mach/mach_traps.h
@@ -0,0 +1,43 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Definitions of general Mach system traps.
+ *
+ * IPC traps are defined in <mach/message.h>.
+ * Kernel RPC functions are defined in <mach/mach_interface.h>.
+ */
+
+#ifndef _MACH_MACH_TRAPS_H_
+#define _MACH_MACH_TRAPS_H_
+
+#include <mach/port.h>
+
+mach_port_name_t mach_reply_port (void);
+mach_port_name_t mach_thread_self (void);
+mach_port_name_t mach_task_self (void);
+mach_port_name_t mach_host_self (void);
+
+#endif /* _MACH_MACH_TRAPS_H_ */
diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs
new file mode 100644
index 0000000..7419601
--- /dev/null
+++ b/include/mach/mach_types.defs
@@ -0,0 +1,299 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1994-1988 Carnegie Mellon University.
+ * Copyright (c) 1993,1994 The University of Utah and
+ * the Computer Systems Laboratory (CSL).
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
+ * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
+ * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
+ * THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Mach kernel interface type declarations
+ */
+
+#ifndef _MACH_MACH_TYPES_DEFS_
+#define _MACH_MACH_TYPES_DEFS_
+
+/*
+ * For KernelServer and KernelUser interfaces, Mig will
+ * automagically use ipc_port_t instead of mach_port_t
+ * on the kernel side of the interface. For example,
+ * convert_task_to_port really returns ipc_port_t.
+ * Doing this in Mig saves many explicit conditional
+ * cusertype/cservertype declarations.
+ *
+ * Mig doesn't translate the components of an array.
+ * For example, Mig won't use the thread_t translations
+ * to translate a thread_array_t argument.
+ */
+
+#include <mach/std_types.defs>
+#if KERNEL_SERVER
+#endif /* KERNEL_SERVER */
+
+#ifdef USERPREFIX
+userprefix USERPREFIX;
+#endif
+
+#ifdef SERVERPREFIX
+serverprefix SERVERPREFIX;
+#endif
+
+type mach_port_status_t = struct {
+ mach_port_name_t mps_pset; /* containing port set */
+ mach_port_seqno_t mps_seqno; /* sequence number */
+ mach_port_mscount_t mps_mscount; /* make-send count */
+ mach_port_msgcount_t mps_qlimit; /* queue limit */
+ mach_port_msgcount_t mps_msgcount; /* number in the queue */
+ mach_port_rights_t mps_sorights; /* how many send-once rights */
+ boolean_t mps_srights; /* do send rights exist? */
+ boolean_t mps_pdrequest; /* port-deleted requested? */
+ boolean_t mps_nsrequest; /* no-senders requested? */
+};
+
+type task_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: task_t convert_port_to_task(mach_port_t)
+ outtran: mach_port_t convert_task_to_port(task_t)
+ destructor: task_deallocate(task_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+#ifdef MIGRATING_THREADS
+#if KERNEL
+/* What the conventional external Mach interfaces see as a thread_t
+ is really an act_t within the kernel. */
+#define thread_t act_t
+#define convert_port_to_thread convert_port_to_act
+#define convert_thread_to_port convert_act_to_port
+#define thread_deallocate act_deallocate
+#endif /* KERNEL */
+#endif /* MIGRATING_THREADS */
+
+type thread_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: thread_t convert_port_to_thread(mach_port_t)
+ outtran: mach_port_t convert_thread_to_port(thread_t)
+ destructor: thread_deallocate(thread_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type thread_state_t = array[*:1024] of natural_t;
+
+type task_array_t = ^array[] of task_t;
+type thread_array_t = ^array[] of thread_t;
+
+type vm_task_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: vm_map_t convert_port_to_map(mach_port_t)
+ destructor: vm_map_deallocate(vm_map_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type ipc_space_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: ipc_space_t convert_port_to_space(mach_port_t)
+ destructor: space_deallocate(ipc_space_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+#if defined(KERNEL) && defined(USER32)
+type rpc_uintptr_t = uint32_t;
+type rpc_vm_size_t = uint32_t;
+#else /* KERNEL and USER32 */
+type rpc_uintptr_t = uintptr_t;
+type rpc_vm_size_t = uintptr_t;
+#endif /* KERNEL_SERVER and USER32 */
+
+type rpc_vm_offset_t = rpc_vm_size_t;
+
+type vm_address_t = rpc_vm_size_t
+#if defined(KERNEL_SERVER)
+ intran: vm_address_t convert_vm_from_user(rpc_vm_address_t)
+ outtran: rpc_vm_address_t convert_vm_to_user(vm_address_t)
+#elif defined(KERNEL_USER)
+ ctype: rpc_vm_address_t
+#endif
+ ;
+type vm_offset_t = rpc_vm_offset_t
+#if defined(KERNEL_SERVER)
+ intran: vm_offset_t convert_vm_from_user(rpc_vm_offset_t)
+ outtran: rpc_vm_offset_t convert_vm_to_user(vm_offset_t)
+#elif defined(KERNEL_USER)
+ ctype: rpc_vm_offset_t
+#endif
+ ;
+type vm_size_t = rpc_vm_size_t
+#if defined(KERNEL_SERVER)
+ intran: vm_size_t convert_vm_from_user(rpc_vm_size_t)
+ outtran: rpc_vm_size_t convert_vm_to_user(vm_size_t)
+#elif defined(KERNEL_USER)
+ ctype: rpc_vm_size_t
+#endif
+;
+type vm_prot_t = int;
+type vm_inherit_t = int;
+type vm_statistics_data_t = struct[13] of integer_t;
+type vm_machine_attribute_t = int;
+type vm_machine_attribute_val_t = int;
+type vm_sync_t = int;
+
+type thread_info_t = array[*:1024] of integer_t;
+
+type task_info_t = array[*:1024] of integer_t;
+
+type memory_object_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: ipc_port_t null_conversion(mach_port_t)
+#else /* KERNEL_SERVER */
+#ifdef MEMORY_OBJECT_INTRAN
+ intran: MEMORY_OBJECT_INTRAN
+#endif
+#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD
+ intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD
+#endif
+#ifdef MEMORY_OBJECT_OUTTRAN
+ outtran: MEMORY_OBJECT_OUTTRAN
+#endif
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+#endif /* KERNEL_SERVER */
+ ;
+
+type memory_object_control_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: vm_object_t vm_object_lookup(mach_port_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type memory_object_name_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: vm_object_t vm_object_lookup_name(mach_port_t)
+ destructor: vm_object_deallocate(vm_object_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type memory_object_copy_strategy_t = int;
+type memory_object_return_t = int;
+
+type host_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: host_t convert_port_to_host(mach_port_t)
+ outtran: mach_port_t convert_host_to_port(host_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type host_priv_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: host_t convert_port_to_host_priv(mach_port_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type host_info_t = array[*:1024] of integer_t;
+
+type processor_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: processor_t convert_port_to_processor(mach_port_t)
+ outtran: mach_port_t convert_processor_to_port(processor_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type processor_array_t = ^array[] of processor_t;
+type processor_info_t = array[*:1024] of integer_t;
+
+type processor_set_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: processor_set_t convert_port_to_pset(mach_port_t)
+ outtran: mach_port_t convert_pset_to_port(processor_set_t)
+ destructor: pset_deallocate(processor_set_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type processor_set_array_t = ^array[] of processor_set_t;
+
+type processor_set_name_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+ intran: processor_set_t convert_port_to_pset_name(mach_port_t)
+ outtran: mach_port_t convert_pset_name_to_port(processor_set_t)
+ destructor: pset_deallocate(processor_set_t)
+#endif /* KERNEL_SERVER */
+ ;
+
+type processor_set_name_array_t = ^array[] of processor_set_name_t;
+
+type processor_set_info_t = array[*:1024] of integer_t;
+
+type kernel_version_t = (MACH_MSG_TYPE_STRING, 512*8);
+type new_kernel_version_t = c_string[512]
+ ctype: kernel_version_t;
+
+type rpc_time_value_t = struct {
+ rpc_long_integer_t seconds;
+ integer_t microseconds;
+};
+type time_value_t = rpc_time_value_t
+#if defined(KERNEL_SERVER)
+ intran: time_value_t convert_time_value_from_user(rpc_time_value_t)
+ outtran: rpc_time_value_t convert_time_value_to_user(time_value_t)
+#elif defined(KERNEL_USER)
+ ctype: rpc_time_value_t
+#endif
+ ;
+
+type time_value64_t = struct {
+ int64_t seconds;
+ int64_t nanoseconds;
+};
+
+type emulation_vector_t = ^array[] of vm_offset_t;
+
+type rpc_signature_info_t = array[*:1024] of int;
+
+#if KERNEL_SERVER
+simport <kern/ipc_kobject.h>; /* for null conversion */
+simport <kern/ipc_tt.h>; /* for task/thread conversion */
+simport <kern/ipc_host.h>; /* for host/processor/pset conversions */
+simport <kern/task.h>; /* for task_t */
+simport <kern/thread.h>; /* for thread_t */
+simport <kern/host.h>; /* for host_t */
+simport <kern/processor.h>; /* for processor_t, processor_set_t */
+simport <vm/vm_object.h>; /* for vm_object_t */
+simport <vm/vm_map.h>; /* for vm_map_t */
+simport <ipc/ipc_space.h>; /* for ipc_space_t */
+#endif /* KERNEL_SERVER */
+
+import <mach/mach_types.h>;
+
+#endif /* _MACH_MACH_TYPES_DEFS_ */
diff --git a/include/mach/mach_types.h b/include/mach/mach_types.h
new file mode 100644
index 0000000..5ecd686
--- /dev/null
+++ b/include/mach/mach_types.h
@@ -0,0 +1,90 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992,1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/mach_types.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
+ * Date: 1986
+ *
+ * Mach external interface definitions.
+ *
+ */
+
+#ifndef _MACH_MACH_TYPES_H_
+#define _MACH_MACH_TYPES_H_
+
+#include <mach/host_info.h>
+#include <mach/machine.h>
+#include <mach/machine/vm_types.h>
+#include <mach/memory_object.h>
+#include <mach/pc_sample.h>
+#include <mach/port.h>
+#include <mach/processor_info.h>
+#include <mach/task_info.h>
+#include <mach/task_special_ports.h>
+#include <mach/thread_info.h>
+#include <mach/thread_special_ports.h>
+#include <mach/thread_status.h>
+#include <mach/time_value.h>
+#include <mach/vm_attributes.h>
+#include <mach/vm_inherit.h>
+#include <mach/vm_prot.h>
+#include <mach/vm_statistics.h>
+#include <mach/vm_cache_statistics.h>
+#include <mach/vm_wire.h>
+#include <mach/vm_sync.h>
+
+#ifdef MACH_KERNEL
+
+typedef struct task *task_t;
+typedef struct thread *thread_t;
+typedef struct processor *processor_t;
+typedef struct processor_set *processor_set_t;
+
+#else /* MACH_KERNEL */
+typedef mach_port_t task_t;
+typedef task_t *task_array_t;
+typedef task_t vm_task_t;
+typedef task_t ipc_space_t;
+typedef mach_port_t thread_t;
+typedef thread_t *thread_array_t;
+typedef mach_port_t host_t;
+typedef mach_port_t host_priv_t;
+typedef mach_port_t processor_t;
+typedef mach_port_t *processor_array_t;
+typedef mach_port_t processor_set_t;
+typedef mach_port_t processor_set_name_t;
+typedef mach_port_t *processor_set_array_t;
+typedef mach_port_t *processor_set_name_array_t;
+typedef vm_offset_t *emulation_vector_t;
+#endif /* MACH_KERNEL */
+
+/*
+ * Backwards compatibility, for those programs written
+ * before mach/{std,mach}_types.{defs,h} were set up.
+ */
+#include <mach/std_types.h>
+
+#endif /* _MACH_MACH_TYPES_H_ */
diff --git a/include/mach/machine.h b/include/mach/machine.h
new file mode 100644
index 0000000..9a176e8
--- /dev/null
+++ b/include/mach/machine.h
@@ -0,0 +1,268 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/* File: machine.h
+ * Author: Avadis Tevanian, Jr.
+ * Date: 1986
+ *
+ * Machine independent machine abstraction.
+ */
+
+#ifndef _MACH_MACHINE_H_
+#define _MACH_MACHINE_H_
+
+#include <mach/machine/vm_types.h>
+#include <mach/boolean.h>
+
+/*
+ * For each host, there is a maximum possible number of
+ * cpus that may be available in the system. This is the
+ * compile-time constant NCPUS, which is defined in cpus.h.
+ *
+ * In addition, there is a machine_slot specifier for each
+ * possible cpu in the system.
+ */
+
+struct machine_info {
+ integer_t major_version; /* kernel major version id */
+ integer_t minor_version; /* kernel minor version id */
+ integer_t max_cpus; /* max number of cpus compiled */
+ integer_t avail_cpus; /* number actually available */
+ vm_size_t memory_size; /* size of memory in bytes */
+};
+
+typedef struct machine_info *machine_info_t;
+typedef struct machine_info machine_info_data_t; /* bogus */
+
+typedef integer_t cpu_type_t;
+typedef integer_t cpu_subtype_t;
+
+#define CPU_STATE_MAX 3
+
+#define CPU_STATE_USER 0
+#define CPU_STATE_SYSTEM 1
+#define CPU_STATE_IDLE 2
+
+struct machine_slot {
+/*boolean_t*/integer_t is_cpu; /* is there a cpu in this slot? */
+ cpu_type_t cpu_type; /* type of cpu */
+ cpu_subtype_t cpu_subtype; /* subtype of cpu */
+/*boolean_t*/integer_t running; /* is cpu running */
+ integer_t cpu_ticks[CPU_STATE_MAX];
+ integer_t clock_freq; /* clock interrupt frequency */
+};
+
+typedef struct machine_slot *machine_slot_t;
+typedef struct machine_slot machine_slot_data_t; /* bogus */
+
+#ifdef MACH_KERNEL
+extern struct machine_info machine_info;
+extern struct machine_slot machine_slot[NCPUS];
+#endif /* MACH_KERNEL */
+
+/*
+ * Machine types known by all.
+ *
+ * When adding new types & subtypes, please also update slot_name.c
+ * in the libmach sources.
+ */
+
+#define CPU_TYPE_VAX ((cpu_type_t) 1)
+#define CPU_TYPE_ROMP ((cpu_type_t) 2)
+#define CPU_TYPE_MC68020 ((cpu_type_t) 3)
+#define CPU_TYPE_NS32032 ((cpu_type_t) 4)
+#define CPU_TYPE_NS32332 ((cpu_type_t) 5)
+#define CPU_TYPE_NS32532 ((cpu_type_t) 6)
+#define CPU_TYPE_I386 ((cpu_type_t) 7)
+#define CPU_TYPE_MIPS ((cpu_type_t) 8)
+#define CPU_TYPE_MC68030 ((cpu_type_t) 9)
+#define CPU_TYPE_MC68040 ((cpu_type_t) 10)
+#define CPU_TYPE_HPPA ((cpu_type_t) 11)
+#define CPU_TYPE_ARM ((cpu_type_t) 12)
+#define CPU_TYPE_MC88000 ((cpu_type_t) 13)
+#define CPU_TYPE_SPARC ((cpu_type_t) 14)
+#define CPU_TYPE_I860 ((cpu_type_t) 15)
+#define CPU_TYPE_ALPHA ((cpu_type_t) 16)
+#define CPU_TYPE_I486 ((cpu_type_t) 17)
+#define CPU_TYPE_PENTIUM ((cpu_type_t) 18)
+#define CPU_TYPE_PENTIUMPRO ((cpu_type_t) 19)
+#define CPU_TYPE_POWERPC ((cpu_type_t) 20)
+#define CPU_TYPE_X86_64 ((cpu_type_t) 21)
+
+/*
+ * Machine subtypes (these are defined here, instead of in a machine
+ * dependent directory, so that any program can get all definitions
+ * regardless of where is it compiled).
+ */
+
+/*
+ * VAX subtypes (these do *not* necessarily conform to the actual cpu
+ * ID assigned by DEC available via the SID register).
+ */
+
+#define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4)
+#define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5)
+#define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6)
+#define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7)
+#define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8)
+#define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9)
+#define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10)
+#define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11)
+#define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12)
+
+/*
+ * ROMP subtypes.
+ */
+
+#define CPU_SUBTYPE_RT_PC ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_RT_APC ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_RT_135 ((cpu_subtype_t) 3)
+
+/*
+ * 68020 subtypes.
+ */
+
+#define CPU_SUBTYPE_SUN3_50 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_SUN3_160 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_SUN3_260 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_SUN3_110 ((cpu_subtype_t) 4)
+#define CPU_SUBTYPE_SUN3_60 ((cpu_subtype_t) 5)
+
+#define CPU_SUBTYPE_HP_320 ((cpu_subtype_t) 6)
+ /* 16.67 Mhz HP 300 series, custom MMU [HP 320] */
+#define CPU_SUBTYPE_HP_330 ((cpu_subtype_t) 7)
+ /* 16.67 Mhz HP 300 series, MC68851 MMU [HP 318,319,330,349] */
+#define CPU_SUBTYPE_HP_350 ((cpu_subtype_t) 8)
+ /* 25.00 Mhz HP 300 series, custom MMU [HP 350] */
+
+/*
+ * 32032/32332/32532 subtypes.
+ */
+
+#define CPU_SUBTYPE_MMAX_DPC ((cpu_subtype_t) 1) /* 032 CPU */
+#define CPU_SUBTYPE_SQT ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_MMAX_APC_FPU ((cpu_subtype_t) 3) /* 32081 FPU */
+#define CPU_SUBTYPE_MMAX_APC_FPA ((cpu_subtype_t) 4) /* Weitek FPA */
+#define CPU_SUBTYPE_MMAX_XPC ((cpu_subtype_t) 5) /* 532 CPU */
+#define CPU_SUBTYPE_PC532 ((cpu_subtype_t) 6) /* pc532 board */
+
+/*
+ * 80386/80486 subtypes.
+ */
+
+#define CPU_SUBTYPE_AT386 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_EXL ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_iPSC386 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_SYMMETRY ((cpu_subtype_t) 4)
+#define CPU_SUBTYPE_PS2 ((cpu_subtype_t) 5) /* PS/2 w/ MCA */
+
+/*
+ * Mips subtypes.
+ */
+
+#define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */
+#define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5)
+#define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */
+#define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7)
+
+/*
+ * MC68030 subtypes.
+ */
+
+#define CPU_SUBTYPE_NeXT ((cpu_subtype_t) 1)
+ /* NeXt thinks MC68030 is 6 rather than 9 */
+#define CPU_SUBTYPE_HP_340 ((cpu_subtype_t) 2)
+ /* 16.67 Mhz HP 300 series [HP 332,340] */
+#define CPU_SUBTYPE_HP_360 ((cpu_subtype_t) 3)
+ /* 25.00 Mhz HP 300 series [HP 360] */
+#define CPU_SUBTYPE_HP_370 ((cpu_subtype_t) 4)
+ /* 33.33 Mhz HP 300 series [HP 370] */
+
+/*
+ * HPPA subtypes.
+ */
+
+#define CPU_SUBTYPE_HPPA_825 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_HPPA_835 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_HPPA_840 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_HPPA_850 ((cpu_subtype_t) 4)
+#define CPU_SUBTYPE_HPPA_855 ((cpu_subtype_t) 5)
+
+/*
+ * ARM subtypes.
+ */
+
+#define CPU_SUBTYPE_ARM_A500_ARCH ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_ARM_A500 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_ARM_A440 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_ARM_M4 ((cpu_subtype_t) 4)
+#define CPU_SUBTYPE_ARM_A680 ((cpu_subtype_t) 5)
+
+/*
+ * MC88000 subtypes.
+ */
+
+#define CPU_SUBTYPE_MMAX_JPC ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_LUNA88K ((cpu_subtype_t) 2)
+
+/*
+ * Sparc subtypes.
+ */
+
+#define CPU_SUBTYPE_SUN4_260 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_SUN4_110 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_SUN4_330 ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_SUN4C_60 ((cpu_subtype_t) 4)
+#define CPU_SUBTYPE_SUN4C_65 ((cpu_subtype_t) 5)
+#define CPU_SUBTYPE_SUN4C_20 ((cpu_subtype_t) 6)
+#define CPU_SUBTYPE_SUN4C_30 ((cpu_subtype_t) 7)
+#define CPU_SUBTYPE_SUN4C_40 ((cpu_subtype_t) 8)
+#define CPU_SUBTYPE_SUN4C_50 ((cpu_subtype_t) 9)
+#define CPU_SUBTYPE_SUN4C_75 ((cpu_subtype_t) 10)
+
+/*
+ * i860 subtypes.
+ */
+
+#define CPU_SUBTYPE_iPSC860 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_OKI860 ((cpu_subtype_t) 2)
+
+/*
+ * Alpha subtypes.
+ */
+
+#define CPU_SUBTYPE_ALPHA_EV3 ((cpu_subtype_t) 1)
+#define CPU_SUBTYPE_ALPHA_EV4 ((cpu_subtype_t) 2)
+#define CPU_SUBTYPE_ALPHA_ISP ((cpu_subtype_t) 3)
+#define CPU_SUBTYPE_ALPHA_21064 ((cpu_subtype_t) 4)
+
+
+#endif /* _MACH_MACHINE_H_ */
diff --git a/include/mach/macro_help.h b/include/mach/macro_help.h
new file mode 100644
index 0000000..f041e40
--- /dev/null
+++ b/include/mach/macro_help.h
@@ -0,0 +1,18 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1988 Carnegie-Mellon University
+ * All rights reserved. The CMU software License Agreement specifies
+ * the terms and conditions for use and redistribution.
+ */
+
+#ifndef _MACRO_HELP_H_
+#define _MACRO_HELP_H_ 1
+
+#define MACRO_BEGIN do {
+#define MACRO_END } while (0)
+
+#define MACRO_RETURN if (1) return
+
+#endif /* _MACRO_HELP_H_ */
+
+
diff --git a/include/mach/memory_object.defs b/include/mach/memory_object.defs
new file mode 100644
index 0000000..4afd67b
--- /dev/null
+++ b/include/mach/memory_object.defs
@@ -0,0 +1,333 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/memory_object.defs
+ *
+ * Abstract:
+ * Basic Mach external memory management interface declaration.
+ */
+
+subsystem
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+ memory_object 2200;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#ifdef MEMORY_OBJECT_IMPORTS
+MEMORY_OBJECT_IMPORTS
+#endif
+
+#if SEQNOS
+serverprefix seqnos_;
+serverdemux seqnos_memory_object_server;
+#endif /* SEQNOS */
+
+/*
+ * Initialize the specified memory object, providing
+ * a reqeust port on which control calls can be made, and
+ * a name port that identifies this object to callers of
+ * vm_regions.
+ * [To allow the mapping of this object to be used, the
+ * memory manager must call memory_object_ready or
+ * memory_object_change_attributes. To reject all mappings of
+ * this object, the memory manager may use
+ * memory_object_destroy.]
+ */
+simpleroutine memory_object_init(
+ memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ memory_object_name : memory_object_name_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ memory_object_page_size : vm_size_t);
+
+/*
+ * Indicates that the specified memory object is no longer mapped
+ * (or cached -- see memory_object_ready or
+ * memory_object_change_attributes), and that further mappings
+ * will cause another memory_object_init call to be made. No
+ * further calls will be made on the memory object by this
+ * kernel.
+ *
+ * [All rights to the control and name ports are included
+ * in this call. The memory manager should use port_deallocate
+ * to release them once they are no longer needed.]
+ */
+simpleroutine memory_object_terminate(
+ memory_object : memory_object_t =
+ MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t
+#ifdef MEMORY_OBJECT_INTRAN
+ intran: MEMORY_OBJECT_INTRAN
+#endif
+#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD
+ intranpayload:
+ MEMORY_OBJECT_INTRAN_PAYLOAD
+#endif
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t
+#if KERNEL_USER
+ /* for compatibility with Mach 2.5 kernels */
+ , dealloc
+#endif /* KERNEL_USER */
+ ;
+ memory_object_name : memory_object_name_t =
+ MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t
+#if KERNEL_USER
+ /* for compatibility with Mach 2.5 kernels */
+ , dealloc
+#endif /* KERNEL_USER */
+ );
+
+/*
+ * Indicates that a copy has been made of the specified range of
+ * the given original memory object. The kernel will use the new
+ * memory object, control and name ports to refer to the new copy
+ * (once the memory manager has asserted its "ready" attribute).
+ *
+ * Cached pages from the original memory object at the time of
+ * the copy operation are handled as follows:
+ * Readable pages may be silently copied to the new
+ * memory object (with all access permissions).
+ * Pages not copied are locked to prevent write access.
+ *
+ * This call includes only the new memory object itself; a
+ * memory_object_init call will be made on the new memory
+ * object after the actions above are completed.
+ *
+ * The new memory object is *temporary*, meaning that the
+ * memory manager should not change its contents or allow
+ * the memory object to be mapped in another client. The
+ * memory manager may use the memory_object_data_unavailable
+ * call to indicate that the appropriate page of the original
+ * memory object may be used to fulfill a data request.
+ *
+ * [Reply should be memory_object_ready or
+ * memory_object_change_attributes on the new memory object control
+ * port to indicate readiness.]
+ */
+simpleroutine memory_object_copy(
+ old_memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ old_memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ length : vm_size_t;
+ new_memory_object : memory_object_t =
+ MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t
+#if KERNEL_USER
+ /* for compatibility with Mach 2.5 kernels */
+ , dealloc
+#endif /* KERNEL_USER */
+ );
+
+/*
+ * Request data from this memory object. At least
+ * the specified data should be returned with at
+ * least the specified access permitted.
+ *
+ * [Reply should be memory_object_data_supply.]
+ */
+simpleroutine memory_object_data_request(
+ memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ length : vm_size_t;
+ desired_access : vm_prot_t);
+
+/*
+ * Request that the specified portion of this
+ * memory object be unlocked to allow the specified
+ * forms of access; the kernel already has the data.
+ *
+ * [Reply should be memory_object_lock_request.]
+ */
+simpleroutine memory_object_data_unlock(
+ memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ length : vm_size_t;
+ desired_access : vm_prot_t);
+
+skip; /* was: memory_object_data_write */
+
+/*
+ * Indicate that a previous memory_object_lock_request has been
+ * completed. Note that this call is made on whatever
+ * port is specified in the memory_object_lock_request; that port
+ * need not be the memory object port itself.
+ *
+ * [No reply expected.]
+ */
+simpleroutine memory_object_lock_completed(
+ memory_object : memory_object_t =
+ polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE
+ ctype: mach_port_t
+#ifdef MEMORY_OBJECT_INTRAN
+ intran: MEMORY_OBJECT_INTRAN
+#endif
+#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD
+ intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD
+#endif
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ length : vm_size_t);
+
+/*
+ * Indicate that a previous memory_object_data_supply has been
+ * completed. Note that this call is made on whatever
+ * port is specified in the memory_object_data_supply; that port
+ * need not be the memory object port itself.
+ *
+ * The result parameter indicates what happened during the supply.
+ * If it is not KERN_SUCCESS, then error_offset identifies the
+ * first offset at which a problem occurred. The pagein operation
+ * stopped at this point. Note that the only failures reported
+ * by this mechanism are KERN_MEMORY_PRESENT. All other failures
+ * (invalid argument, error on pagein of supplied data in manager's
+ * address space) cause the entire operation to fail.
+ *
+ * XXX Check what actually happens in latter case!
+ *
+ * [No reply expected.]
+ */
+simpleroutine memory_object_supply_completed(
+ memory_object : memory_object_t =
+ polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE
+ ctype: mach_port_t
+#ifdef MEMORY_OBJECT_INTRAN
+ intran: MEMORY_OBJECT_INTRAN
+#endif
+#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD
+ intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD
+#endif
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ length : vm_size_t;
+ result : kern_return_t;
+ error_offset : vm_offset_t);
+
+/*
+ * Return data to manager. This call indicates whether the
+ * returned data is dirty and whether the kernel kept a copy.
+ * Precious data remains precious if the kernel keeps a copy.
+ * The indication that the kernel kept a copy is only a hint if
+ * the data is not precious; the cleaned copy may be discarded
+ * without further notifying the manager.
+ *
+ * [Reply should be vm_deallocate to release the data.]
+ */
+simpleroutine memory_object_data_return(
+ memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ data : pointer_t;
+ dirty : boolean_t;
+ kernel_copy : boolean_t);
+
+/*
+ * XXX Warning: This routine does NOT contain a memory_object_control_t
+ * XXX because the memory_object_change_attributes call may cause
+ * XXX memory object termination (by uncaching the object). This would
+ * XXX yield an invalid port.
+ */
+
+simpleroutine memory_object_change_completed(
+ memory_object : memory_object_t =
+ polymorphic|MACH_MSG_TYPE_PORT_SEND_ONCE
+ ctype: mach_port_t
+#ifdef MEMORY_OBJECT_INTRAN
+ intran: MEMORY_OBJECT_INTRAN
+#endif
+#ifdef MEMORY_OBJECT_INTRAN_PAYLOAD
+ intranpayload: MEMORY_OBJECT_INTRAN_PAYLOAD
+#endif
+#ifdef MEMORY_OBJECT_DESTRUCTOR
+ destructor: MEMORY_OBJECT_DESTRUCTOR
+#endif
+ ;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ may_cache : boolean_t;
+ copy_strategy : memory_object_copy_strategy_t);
diff --git a/include/mach/memory_object.h b/include/mach/memory_object.h
new file mode 100644
index 0000000..7e0c374
--- /dev/null
+++ b/include/mach/memory_object.h
@@ -0,0 +1,90 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: memory_object.h
+ * Author: Michael Wayne Young
+ *
+ * External memory management interface definition.
+ */
+
+#ifndef _MACH_MEMORY_OBJECT_H_
+#define _MACH_MEMORY_OBJECT_H_
+
+/*
+ * User-visible types used in the external memory
+ * management interface:
+ */
+
+#include <mach/port.h>
+
+#ifdef MACH_KERNEL
+#include <ipc/ipc_types.h>
+typedef ipc_port_t memory_object_t;
+#else
+typedef mach_port_t memory_object_t;
+#endif
+ /* Represents a memory object ... */
+ /* Used by user programs to specify */
+ /* the object to map; used by the */
+ /* kernel to retrieve or store data */
+
+typedef memory_object_t *memory_object_array_t;
+
+typedef mach_port_t memory_object_control_t;
+ /* Provided to a memory manager; ... */
+ /* used to control a memory object */
+
+typedef mach_port_t memory_object_name_t;
+ /* Used to describe the memory ... */
+ /* object in vm_regions() calls */
+
+typedef int memory_object_copy_strategy_t;
+ /* How memory manager handles copy: */
+#define MEMORY_OBJECT_COPY_NONE 0
+ /* ... No special support */
+#define MEMORY_OBJECT_COPY_CALL 1
+ /* ... Make call on memory manager */
+#define MEMORY_OBJECT_COPY_DELAY 2
+ /* ... Memory manager doesn't ... */
+ /* change data externally. */
+#define MEMORY_OBJECT_COPY_TEMPORARY 3
+ /* ... Memory manager doesn't ... */
+ /* change data externally, and */
+ /* doesn't need to see changes. */
+
+typedef int memory_object_return_t;
+ /* Which pages to return to manager
+ this time (lock_request) */
+#define MEMORY_OBJECT_RETURN_NONE 0
+ /* ... don't return any. */
+#define MEMORY_OBJECT_RETURN_DIRTY 1
+ /* ... only dirty pages. */
+#define MEMORY_OBJECT_RETURN_ALL 2
+ /* ... dirty and precious pages. */
+
+#define MEMORY_OBJECT_NULL MACH_PORT_NULL
+
+#endif /* _MACH_MEMORY_OBJECT_H_ */
diff --git a/include/mach/memory_object_default.defs b/include/mach/memory_object_default.defs
new file mode 100644
index 0000000..e62f14d
--- /dev/null
+++ b/include/mach/memory_object_default.defs
@@ -0,0 +1,118 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/memory_object_default.defs
+ *
+ * Abstract:
+ * Mach external memory management interface declaration; subset
+ * that is applicable to managers of kernel-created memory objects.
+ */
+
+subsystem
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+ memory_object_default 2250;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#ifdef MEMORY_OBJECT_IMPORTS
+MEMORY_OBJECT_IMPORTS
+#endif
+
+#if SEQNOS
+serverprefix seqnos_;
+serverdemux seqnos_memory_object_default_server;
+#endif /* SEQNOS */
+
+/*
+ * Pass on responsibility for the new kernel-created memory
+ * object. The port on which this request is that port
+ * (possibly a memory object itself) registered as the "default
+ * pager". Other arguments are as described for memory_object_init.
+ * [No reply required.]
+ */
+simpleroutine memory_object_create(
+ old_memory_object : memory_object_t =
+ MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ new_memory_object : memory_object_t =
+ MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t
+#if KERNEL_USER
+ /* for compatibility with Mach 2.5 kernels */
+ , dealloc
+#endif /* KERNEL_USER */
+ ;
+ new_object_size : vm_size_t;
+ new_control_port : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ new_name : memory_object_name_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ new_page_size : vm_size_t);
+
+/*
+ * Provide initial data contents for this region of
+ * the memory object. If data has already been written
+ * to the object, this value must be discarded; otherwise,
+ * this call acts identically to memory_object_data_return.
+ */
+simpleroutine memory_object_data_initialize(
+ memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control_port : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ data : pointer_t);
+
+#if 0
+/*
+ * Indicate that the specified range of data in this memory object
+ * will not be requested again until it is reinitialized with
+ * memory_object_data_return or memory_object_data_initialize.
+ */
+simpleroutine memory_object_data_terminate(
+ memory_object : memory_object_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif /* SEQNOS */
+ memory_control_port : memory_object_control_t =
+ MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ offset : vm_offset_t;
+ size : vm_size_t);
+#else /* 0 */
+skip; /* memory_object_data_terminate */
+#endif /* 0 */
diff --git a/include/mach/message.h b/include/mach/message.h
new file mode 100644
index 0000000..9790ef9
--- /dev/null
+++ b/include/mach/message.h
@@ -0,0 +1,540 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992-1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/message.h
+ *
+ * Mach IPC message and primitive function definitions.
+ */
+
+#ifndef _MACH_MESSAGE_H_
+#define _MACH_MESSAGE_H_
+
+#include <mach/kern_return.h>
+#include <mach/port.h>
+
+
+/*
+ * The timeout mechanism uses mach_msg_timeout_t values,
+ * passed by value. The timeout units are milliseconds.
+ * It is controlled with the MACH_SEND_TIMEOUT
+ * and MACH_RCV_TIMEOUT options.
+ */
+
+typedef natural_t mach_msg_timeout_t;
+
+/*
+ * The value to be used when there is no timeout.
+ * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
+ */
+
+#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
+
+/*
+ * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. It it isn't on, it
+ * assumes the body of the message doesn't contain port rights or OOL
+ * data. The field is set in received messages. A user task must
+ * use caution in interpreting the body of a message if the bit isn't
+ * on, because the mach_msg_type's in the body might "lie" about the
+ * contents. If the bit isn't on, but the mach_msg_types
+ * in the body specify rights or OOL data, the behaviour is undefined.
+ * (Ie, an error may or may not be produced.)
+ *
+ * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
+ * of the msgh_remote_port field. It is handled like a msgt_name.
+ *
+ * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
+ * of the msgh_local_port field. It is handled like a msgt_name.
+ *
+ * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
+ * and local fields, into a single value suitable for msgh_bits.
+ *
+ * MACH_MSGH_BITS_COMPLEX_PORTS, MACH_MSGH_BITS_COMPLEX_DATA, and
+ * MACH_MSGH_BITS_CIRCULAR should be zero; they are used internally.
+ *
+ * The unused bits should be zero.
+ */
+
+#define MACH_MSGH_BITS_ZERO 0x00000000
+#define MACH_MSGH_BITS_REMOTE_MASK 0x000000ff
+#define MACH_MSGH_BITS_LOCAL_MASK 0x0000ff00
+#define MACH_MSGH_BITS_COMPLEX 0x80000000U
+#define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */
+#define MACH_MSGH_BITS_COMPLEX_PORTS 0x20000000 /* internal use only */
+#define MACH_MSGH_BITS_COMPLEX_DATA 0x10000000 /* internal use only */
+#define MACH_MSGH_BITS_MIGRATED 0x08000000 /* internal use only */
+#define MACH_MSGH_BITS_UNUSED 0x07ff0000
+
+#define MACH_MSGH_BITS_PORTS_MASK \
+ (MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK)
+
+#define MACH_MSGH_BITS(remote, local) \
+ ((remote) | ((local) << 8))
+#define MACH_MSGH_BITS_REMOTE(bits) \
+ ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
+#define MACH_MSGH_BITS_LOCAL(bits) \
+ (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
+#define MACH_MSGH_BITS_PORTS(bits) \
+ ((bits) & MACH_MSGH_BITS_PORTS_MASK)
+#define MACH_MSGH_BITS_OTHER(bits) \
+ ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
+
+/*
+ * Every message starts with a message header.
+ * Following the message header are zero or more pairs of
+ * type descriptors (mach_msg_type_t/mach_msg_type_long_t) and
+ * data values. The size of the message must be specified in bytes,
+ * and includes the message header, type descriptors, inline
+ * data, and inline pointer for out-of-line data.
+ *
+ * The msgh_remote_port field specifies the destination of the message.
+ * It must specify a valid send or send-once right for a port.
+ *
+ * The msgh_local_port field specifies a "reply port". Normally,
+ * This field carries a send-once right that the receiver will use
+ * to reply to the message. It may carry the values MACH_PORT_NULL,
+ * MACH_PORT_DEAD, a send-once right, or a send right.
+ *
+ * The msgh_seqno field carries a sequence number associated with the
+ * received-from port. A port's sequence number is incremented every
+ * time a message is received from it. In sent messages, the field's
+ * value is ignored.
+ *
+ * The msgh_id field is uninterpreted by the message primitives.
+ * It normally carries information specifying the format
+ * or meaning of the message.
+ */
+
+typedef unsigned int mach_msg_bits_t;
+typedef unsigned int mach_msg_size_t;
+typedef natural_t mach_msg_seqno_t;
+typedef integer_t mach_msg_id_t;
+
+/* full header structure, may have different size in user/kernel spaces */
+typedef struct mach_msg_header {
+ mach_msg_bits_t msgh_bits;
+ mach_msg_size_t msgh_size;
+ union {
+ mach_port_t msgh_remote_port;
+ /*
+ * Ensure msgh_remote_port is wide enough to hold a kernel pointer
+ * to avoid message resizing for the 64 bits case. This field should
+ * not be used since it is here just for padding purposes.
+ */
+ rpc_uintptr_t msgh_remote_port_do_not_use;
+ };
+ union {
+ mach_port_t msgh_local_port;
+ rpc_uintptr_t msgh_protected_payload;
+ };
+ mach_port_seqno_t msgh_seqno;
+ mach_msg_id_t msgh_id;
+} mach_msg_header_t;
+
+#ifdef KERNEL
+/* user-side header format, needed in the kernel */
+typedef struct {
+ mach_msg_bits_t msgh_bits;
+ mach_msg_size_t msgh_size;
+ union {
+ mach_port_name_t msgh_remote_port;
+ rpc_uintptr_t msgh_remote_port_do_not_use;
+ };
+ union {
+ mach_port_name_t msgh_local_port;
+ rpc_uintptr_t msgh_protected_payload;
+ };
+ mach_port_seqno_t msgh_seqno;
+ mach_msg_id_t msgh_id;
+} mach_msg_user_header_t;
+#else
+typedef mach_msg_header_t mach_msg_user_header_t;
+#endif
+
+/*
+ * There is no fixed upper bound to the size of Mach messages.
+ */
+
+#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
+
+/*
+ * Compatibility definitions, for code written
+ * when there was a msgh_kind instead of msgh_seqno.
+ */
+
+#define MACH_MSGH_KIND_NORMAL 0x00000000
+#if 0
+/* code using this is likely to break, so better not to have it defined */
+#define MACH_MSGH_KIND_NOTIFICATION 0x00000001
+#endif
+#define msgh_kind msgh_seqno
+#define mach_msg_kind_t mach_port_seqno_t
+
+/*
+ * The msgt_number field specifies the number of data elements.
+ * The msgt_size field specifies the size of each data element, in bits.
+ * The msgt_name field specifies the type of each data element.
+ * If msgt_inline is TRUE, the data follows the type descriptor
+ * in the body of the message. If msgt_inline is FALSE, then a pointer
+ * to the data should follow the type descriptor, and the data is
+ * sent out-of-line. In this case, if msgt_deallocate is TRUE,
+ * then the out-of-line data is moved (instead of copied) into the message.
+ * If msgt_longform is TRUE, then the type descriptor is actually
+ * a mach_msg_type_long_t.
+ *
+ * The actual amount of inline data following the descriptor must
+ * a multiple of the word size. For out-of-line data, this is a
+ * pointer. For inline data, the supplied data size (calculated
+ * from msgt_number/msgt_size) is rounded up. This guarantees
+ * that type descriptors always fall on word boundaries.
+ *
+ * For port rights, msgt_size must be 8*sizeof(mach_port_t).
+ * If the data is inline, msgt_deallocate should be FALSE.
+ * The msgt_unused bit should be zero.
+ * The msgt_name, msgt_size, msgt_number fields in
+ * a mach_msg_type_long_t should be zero.
+ */
+
+typedef unsigned int mach_msg_type_name_t;
+typedef unsigned int mach_msg_type_size_t;
+typedef natural_t mach_msg_type_number_t;
+
+/**
+ * Structure used for inlined port rights in messages.
+ *
+ * We use this to avoid having to perform message resizing in the kernel
+ * since userspace port rights might be smaller than kernel ports in 64 bit
+ * architectures.
+ */
+typedef struct {
+ union {
+ mach_port_name_t name;
+#ifdef KERNEL
+ mach_port_t kernel_port;
+#else
+ uintptr_t kernel_port_do_not_use;
+#endif /* KERNEL */
+ };
+} mach_port_name_inlined_t;
+
+typedef struct {
+#ifdef __x86_64__
+ /*
+ * For 64 bits, this struct is 8 bytes long so we
+ * can pack the same amount of information as mach_msg_type_long_t.
+ * Note that for 64 bit userland, msgt_size only needs to be 8 bits long
+ * but for kernel compatibility with 32 bit userland we allow it to be
+ * 16 bits long.
+ *
+ * Effectively, we don't need mach_msg_type_long_t but we are keeping it
+ * for a while to make the code similar between 32 and 64 bits.
+ *
+ * We also keep the msgt_longform bit around simply because it makes it
+ * very easy to convert messages from a 32 bit userland into a 64 bit
+ * kernel. Otherwise, we would have to replicate some of the MiG logic
+ * internally in the kernel.
+ */
+ unsigned int msgt_name : 8,
+ msgt_size : 16,
+ msgt_unused : 5,
+ msgt_inline : 1,
+ msgt_longform : 1,
+ msgt_deallocate : 1;
+ mach_msg_type_number_t msgt_number;
+#else
+ unsigned int msgt_name : 8,
+ msgt_size : 8,
+ msgt_number : 12,
+ msgt_inline : 1,
+ msgt_longform : 1,
+ msgt_deallocate : 1,
+ msgt_unused : 1;
+#endif
+} __attribute__ ((aligned (__alignof__ (uintptr_t)))) mach_msg_type_t;
+
+typedef struct {
+#ifdef __x86_64__
+ union {
+ /* On x86_64 this is equivalent to mach_msg_type_t so use
+ * union to overlay with the old field names. */
+ mach_msg_type_t msgtl_header;
+ struct {
+ unsigned int msgtl_name : 8,
+ msgtl_size : 16,
+ msgtl_unused : 5,
+ msgtl_inline : 1,
+ msgtl_longform : 1,
+ msgtl_deallocate : 1;
+ mach_msg_type_number_t msgtl_number;
+ };
+ };
+#else
+ mach_msg_type_t msgtl_header;
+ unsigned short msgtl_name;
+ unsigned short msgtl_size;
+ natural_t msgtl_number;
+#endif
+} __attribute__ ((aligned (__alignof__ (uintptr_t)))) mach_msg_type_long_t;
+
+#ifdef __x86_64__
+#ifdef __cplusplus
+#if __cplusplus >= 201103L
+static_assert (sizeof (mach_msg_type_t) == sizeof (mach_msg_type_long_t),
+ "mach_msg_type_t and mach_msg_type_long_t need to have the same size.");
+#endif
+#else
+_Static_assert (sizeof (mach_msg_type_t) == sizeof (mach_msg_type_long_t),
+ "mach_msg_type_t and mach_msg_type_long_t need to have the same size.");
+#endif
+#endif
+
+/*
+ * Known values for the msgt_name field.
+ *
+ * The only types known to the Mach kernel are
+ * the port types, and those types used in the
+ * kernel RPC interface.
+ */
+
+#define MACH_MSG_TYPE_UNSTRUCTURED 0
+#define MACH_MSG_TYPE_BIT 0
+#define MACH_MSG_TYPE_BOOLEAN 0
+#define MACH_MSG_TYPE_INTEGER_16 1
+#define MACH_MSG_TYPE_INTEGER_32 2
+#define MACH_MSG_TYPE_CHAR 8
+#define MACH_MSG_TYPE_BYTE 9
+#define MACH_MSG_TYPE_INTEGER_8 9
+#define MACH_MSG_TYPE_REAL 10
+#define MACH_MSG_TYPE_INTEGER_64 11
+#define MACH_MSG_TYPE_STRING 12
+#define MACH_MSG_TYPE_STRING_C 12
+
+/*
+ * Values used when sending a port right.
+ */
+
+#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive rights */
+#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send rights */
+#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce rights */
+#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send rights */
+#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive rights */
+#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive rights */
+
+/*
+ * Values received/carried in messages. Tells the receiver what
+ * sort of port right he now has.
+ *
+ * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
+ * which should remain uninterpreted by the kernel. (Port rights
+ * are not transferred, just the port name.)
+ */
+
+#define MACH_MSG_TYPE_PORT_NAME 15
+#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
+#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
+#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
+
+#define MACH_MSG_TYPE_PROTECTED_PAYLOAD 23
+
+#define MACH_MSG_TYPE_LAST 23 /* Last assigned */
+
+/*
+ * A dummy value. Mostly used to indicate that the actual value
+ * will be filled in later, dynamically.
+ */
+
+#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
+
+/*
+ * Is a given item a port type?
+ */
+
+#define MACH_MSG_TYPE_PORT_ANY(x) \
+ (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
+ ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
+
+#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
+ (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
+ ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
+
+#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
+ (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
+ ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
+
+typedef integer_t mach_msg_option_t;
+
+#define MACH_MSG_OPTION_NONE 0x00000000
+
+#define MACH_SEND_MSG 0x00000001
+#define MACH_RCV_MSG 0x00000002
+
+#define MACH_SEND_TIMEOUT 0x00000010
+#define MACH_SEND_NOTIFY 0x00000020
+#define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */
+#define MACH_SEND_CANCEL 0x00000080
+#define MACH_RCV_TIMEOUT 0x00000100
+#define MACH_RCV_NOTIFY 0x00000200
+#define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */
+#define MACH_RCV_LARGE 0x00000800
+
+#define MACH_SEND_ALWAYS 0x00010000 /* internal use only */
+
+#ifdef __x86_64__
+#if defined(KERNEL) && defined(USER32)
+#define MACH_MSG_USER_ALIGNMENT 4
+#else
+#define MACH_MSG_USER_ALIGNMENT 8
+#endif
+#else
+#define MACH_MSG_USER_ALIGNMENT 4
+#endif
+
+#ifdef KERNEL
+/* This is the alignment of msg descriptors and the actual data
+ * for both in kernel messages and user land messages.
+ *
+ * We have two types of alignment because for specific configurations
+ * (in particular a 64 bit kernel with 32 bit userland) we transform
+ * 4-byte aligned user messages into 8-byte aligned messages (and vice-versa)
+ * so that kernel messages are correctly aligned.
+ */
+#define MACH_MSG_KERNEL_ALIGNMENT sizeof(uintptr_t)
+
+#define mach_msg_align(x, alignment) \
+ ( ( ((vm_offset_t)(x)) + ((alignment)-1) ) & ~((alignment)-1) )
+#define mach_msg_user_align(x) mach_msg_align(x, MACH_MSG_USER_ALIGNMENT)
+#define mach_msg_kernel_align(x) mach_msg_align(x, MACH_MSG_KERNEL_ALIGNMENT)
+#define mach_msg_user_is_misaligned(x) ((x) & ((MACH_MSG_USER_ALIGNMENT)-1))
+#define mach_msg_kernel_is_misaligned(x) ((x) & ((MACH_MSG_KERNEL_ALIGNMENT)-1))
+#endif /* KERNEL */
+
+/*
+ * Much code assumes that mach_msg_return_t == kern_return_t.
+ * This definition is useful for descriptive purposes.
+ *
+ * See <mach/error.h> for the format of error codes.
+ * IPC errors are system 4. Send errors are subsystem 0;
+ * receive errors are subsystem 1. The code field is always non-zero.
+ * The high bits of the code field communicate extra information
+ * for some error codes. MACH_MSG_MASK masks off these special bits.
+ */
+
+typedef kern_return_t mach_msg_return_t;
+
+#define MACH_MSG_SUCCESS 0x00000000
+
+#define MACH_MSG_MASK 0x00003c00
+ /* All special error code bits defined below. */
+#define MACH_MSG_IPC_SPACE 0x00002000
+ /* No room in IPC name space for another capability name. */
+#define MACH_MSG_VM_SPACE 0x00001000
+ /* No room in VM address space for out-of-line memory. */
+#define MACH_MSG_IPC_KERNEL 0x00000800
+ /* Kernel resource shortage handling an IPC capability. */
+#define MACH_MSG_VM_KERNEL 0x00000400
+ /* Kernel resource shortage handling out-of-line memory. */
+
+#define MACH_SEND_IN_PROGRESS 0x10000001
+ /* Thread is waiting to send. (Internal use only.) */
+#define MACH_SEND_INVALID_DATA 0x10000002
+ /* Bogus in-line data. */
+#define MACH_SEND_INVALID_DEST 0x10000003
+ /* Bogus destination port. */
+#define MACH_SEND_TIMED_OUT 0x10000004
+ /* Message not sent before timeout expired. */
+#define MACH_SEND_WILL_NOTIFY 0x10000005
+ /* Msg-accepted notification will be generated. */
+#define MACH_SEND_NOTIFY_IN_PROGRESS 0x10000006
+ /* Msg-accepted notification already pending. */
+#define MACH_SEND_INTERRUPTED 0x10000007
+ /* Software interrupt. */
+#define MACH_SEND_MSG_TOO_SMALL 0x10000008
+ /* Data doesn't contain a complete message. */
+#define MACH_SEND_INVALID_REPLY 0x10000009
+ /* Bogus reply port. */
+#define MACH_SEND_INVALID_RIGHT 0x1000000a
+ /* Bogus port rights in the message body. */
+#define MACH_SEND_INVALID_NOTIFY 0x1000000b
+ /* Bogus notify port argument. */
+#define MACH_SEND_INVALID_MEMORY 0x1000000c
+ /* Invalid out-of-line memory pointer. */
+#define MACH_SEND_NO_BUFFER 0x1000000d
+ /* No message buffer is available. */
+#define MACH_SEND_NO_NOTIFY 0x1000000e
+ /* Resource shortage; can't request msg-accepted notif. */
+#define MACH_SEND_INVALID_TYPE 0x1000000f
+ /* Invalid msg-type specification. */
+#define MACH_SEND_INVALID_HEADER 0x10000010
+ /* A field in the header had a bad value. */
+
+#define MACH_RCV_IN_PROGRESS 0x10004001
+ /* Thread is waiting for receive. (Internal use only.) */
+#define MACH_RCV_INVALID_NAME 0x10004002
+ /* Bogus name for receive port/port-set. */
+#define MACH_RCV_TIMED_OUT 0x10004003
+ /* Didn't get a message within the timeout value. */
+#define MACH_RCV_TOO_LARGE 0x10004004
+ /* Message buffer is not large enough for inline data. */
+#define MACH_RCV_INTERRUPTED 0x10004005
+ /* Software interrupt. */
+#define MACH_RCV_PORT_CHANGED 0x10004006
+ /* Port moved into a set during the receive. */
+#define MACH_RCV_INVALID_NOTIFY 0x10004007
+ /* Bogus notify port argument. */
+#define MACH_RCV_INVALID_DATA 0x10004008
+ /* Bogus message buffer for inline data. */
+#define MACH_RCV_PORT_DIED 0x10004009
+ /* Port/set was sent away/died during receive. */
+#define MACH_RCV_IN_SET 0x1000400a
+ /* Port is a member of a port set. */
+#define MACH_RCV_HEADER_ERROR 0x1000400b
+ /* Error receiving message header. See special bits. */
+#define MACH_RCV_BODY_ERROR 0x1000400c
+ /* Error receiving message body. See special bits. */
+
+extern mach_msg_return_t
+mach_msg_trap
+ (mach_msg_user_header_t *msg,
+ mach_msg_option_t option,
+ mach_msg_size_t send_size,
+ mach_msg_size_t rcv_size,
+ mach_port_name_t rcv_name,
+ mach_msg_timeout_t timeout,
+ mach_port_name_t notify);
+
+extern mach_msg_return_t
+mach_msg
+ (mach_msg_header_t *msg,
+ mach_msg_option_t option,
+ mach_msg_size_t send_size,
+ mach_msg_size_t rcv_size,
+ mach_port_name_t rcv_name,
+ mach_msg_timeout_t timeout,
+ mach_port_name_t notify);
+
+extern __typeof (mach_msg) __mach_msg;
+extern __typeof (mach_msg_trap) __mach_msg_trap;
+
+#endif /* _MACH_MESSAGE_H_ */
diff --git a/include/mach/mig_errors.h b/include/mach/mig_errors.h
new file mode 100644
index 0000000..389ce77
--- /dev/null
+++ b/include/mach/mig_errors.h
@@ -0,0 +1,89 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Mach Interface Generator errors
+ *
+ */
+
+#ifndef _MACH_MIG_ERRORS_H_
+#define _MACH_MIG_ERRORS_H_
+
+#include <mach/kern_return.h>
+#include <mach/message.h>
+
+/*
+ * These error codes should be specified as system 4, subsytem 2.
+ * But alas backwards compatibility makes that impossible.
+ * The problem is old clients of new servers (eg, the kernel)
+ * which get strange large error codes when there is a Mig problem
+ * in the server. Unfortunately, the IPC system doesn't have
+ * the knowledge to convert the codes in this situation.
+ */
+
+#define MIG_TYPE_ERROR -300 /* client type check failure */
+#define MIG_REPLY_MISMATCH -301 /* wrong reply message ID */
+#define MIG_REMOTE_ERROR -302 /* server detected error */
+#define MIG_BAD_ID -303 /* bad request message ID */
+#define MIG_BAD_ARGUMENTS -304 /* server type check failure */
+#define MIG_NO_REPLY -305 /* no reply should be sent */
+#define MIG_EXCEPTION -306 /* server raised exception */
+#define MIG_ARRAY_TOO_LARGE -307 /* array not large enough */
+#define MIG_SERVER_DIED -308 /* server died */
+#define MIG_DESTROY_REQUEST -309 /* destroy request with no reply */
+
+typedef struct {
+ mach_msg_header_t Head;
+ mach_msg_type_t RetCodeType;
+ kern_return_t RetCode;
+} mig_reply_header_t;
+
+typedef struct mig_symtab {
+ char *ms_routine_name;
+ int ms_routine_number;
+#if defined(__STDC__) || defined(c_plus_plus) || defined(hc)
+ void
+#else
+ int
+#endif
+ (*ms_routine)(void);
+} mig_symtab_t;
+
+/*
+ * Definition for server stub routines. These routines
+ * unpack the request message, call the server procedure,
+ * and pack the reply message.
+ */
+#if defined(__STDC__) || defined(c_plus_plus)
+typedef void (*mig_routine_t)(mach_msg_header_t *, mach_msg_header_t *);
+#else
+#if defined(hc)
+typedef void (*mig_routine_t)();
+#else
+typedef int (*mig_routine_t)(); /* PCC cannot handle void (*)() */
+#endif
+#endif
+
+#endif /* _MACH_MIG_ERRORS_H_ */
diff --git a/include/mach/mig_support.h b/include/mach/mig_support.h
new file mode 100644
index 0000000..ed871c0
--- /dev/null
+++ b/include/mach/mig_support.h
@@ -0,0 +1,57 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Abstract:
+ * Header file for support routines called by MiG generated interfaces.
+ *
+ */
+
+#ifndef _MACH_MIG_SUPPORT_H_
+#define _MACH_MIG_SUPPORT_H_
+
+#include <string.h>
+
+#include <mach/message.h>
+#include <mach/mach_types.h>
+
+extern void mig_init(void *_first);
+
+extern void mig_allocate(vm_address_t *_addr_p, vm_size_t _size);
+
+extern void mig_deallocate(vm_address_t _addr, vm_size_t _size);
+
+extern void mig_dealloc_reply_port(mach_port_t);
+
+extern void mig_put_reply_port(mach_port_t);
+
+extern mach_port_name_t mig_get_reply_port(void);
+
+extern void mig_reply_setup(const mach_msg_header_t *_request,
+ mach_msg_header_t *reply);
+
+extern vm_size_t mig_strncpy(char *_dest, const char *_src, vm_size_t _len);
+
+#endif /* not defined(_MACH_MIG_SUPPORT_H_) */
diff --git a/include/mach/notify.defs b/include/mach/notify.defs
new file mode 100644
index 0000000..6ba4cde
--- /dev/null
+++ b/include/mach/notify.defs
@@ -0,0 +1,112 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+subsystem notify 64;
+
+#include <mach/std_types.defs>
+
+#ifdef NOTIFY_IMPORTS
+NOTIFY_IMPORTS
+#endif
+
+#if SEQNOS
+serverprefix do_seqnos_;
+serverdemux seqnos_notify_server;
+#else
+serverprefix do_;
+serverdemux notify_server;
+#endif
+
+type notify_port_t = MACH_MSG_TYPE_MOVE_SEND_ONCE
+ ctype: mach_port_t
+#ifdef NOTIFY_INTRAN
+ intran: NOTIFY_INTRAN
+#endif
+#ifdef NOTIFY_INTRAN_PAYLOAD
+ intranpayload: NOTIFY_INTRAN_PAYLOAD
+#endif
+#ifdef NOTIFY_OUTTRAN
+ outtran: NOTIFY_OUTTRAN
+#endif
+#ifdef NOTIFY_DESTRUCTOR
+ destructor: NOTIFY_DESTRUCTOR
+#endif
+;
+
+/* MACH_NOTIFY_FIRST: 0100 */
+skip;
+
+/* MACH_NOTIFY_PORT_DELETED: 0101 */
+simpleroutine mach_notify_port_deleted(
+ notify : notify_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif
+ name : mach_port_name_t);
+
+/* MACH_NOTIFY_MSG_ACCEPTED: 0102 */
+simpleroutine mach_notify_msg_accepted(
+ notify : notify_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif
+ name : mach_port_name_t);
+
+skip; /* was NOTIFY_OWNERSHIP_RIGHTS: 0103 */
+
+skip; /* was NOTIFY_RECEIVE_RIGHTS: 0104 */
+
+/* MACH_NOTIFY_PORT_DESTROYED: 0105 */
+simpleroutine mach_notify_port_destroyed(
+ notify : notify_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif
+ rights : mach_port_receive_t);
+
+/* MACH_NOTIFY_NO_SENDERS: 0106 */
+simpleroutine mach_notify_no_senders(
+ notify : notify_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif
+ mscount : mach_port_mscount_t);
+
+/* MACH_NOTIFY_SEND_ONCE: 0107 */
+simpleroutine mach_notify_send_once(
+ notify : notify_port_t
+#if SEQNOS
+; msgseqno seqno : mach_port_seqno_t
+#endif
+ );
+
+/* MACH_NOTIFY_DEAD_NAME: 0110 */
+simpleroutine mach_notify_dead_name(
+ notify : notify_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif
+ name : mach_port_name_t);
diff --git a/include/mach/notify.h b/include/mach/notify.h
new file mode 100644
index 0000000..14bcd6f
--- /dev/null
+++ b/include/mach/notify.h
@@ -0,0 +1,92 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/notify.h
+ *
+ * Kernel notification message definitions.
+ */
+
+#ifndef _MACH_NOTIFY_H_
+#define _MACH_NOTIFY_H_
+
+#include <mach/port.h>
+#include <mach/message.h>
+
+/*
+ * An alternative specification of the notification interface
+ * may be found in mach/notify.defs.
+ */
+
+#define MACH_NOTIFY_FIRST 0100
+#define MACH_NOTIFY_PORT_DELETED (MACH_NOTIFY_FIRST + 001 )
+ /* A send or send-once right was deleted. */
+#define MACH_NOTIFY_MSG_ACCEPTED (MACH_NOTIFY_FIRST + 002)
+ /* A MACH_SEND_NOTIFY msg was accepted */
+#define MACH_NOTIFY_PORT_DESTROYED (MACH_NOTIFY_FIRST + 005)
+ /* A receive right was (would have been) deallocated */
+#define MACH_NOTIFY_NO_SENDERS (MACH_NOTIFY_FIRST + 006)
+ /* Receive right has no extant send rights */
+#define MACH_NOTIFY_SEND_ONCE (MACH_NOTIFY_FIRST + 007)
+ /* An extant send-once right died */
+#define MACH_NOTIFY_DEAD_NAME (MACH_NOTIFY_FIRST + 010)
+ /* Send or send-once right died, leaving a dead-name */
+#define MACH_NOTIFY_LAST (MACH_NOTIFY_FIRST + 015)
+
+typedef struct {
+ mach_msg_header_t not_header;
+ mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_NAME */
+ mach_port_name_t not_port;
+} mach_port_deleted_notification_t;
+
+typedef struct {
+ mach_msg_header_t not_header;
+ mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_NAME */
+ mach_port_name_t not_port;
+} mach_msg_accepted_notification_t;
+
+typedef struct {
+ mach_msg_header_t not_header;
+ mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_RECEIVE */
+ mach_port_t not_port;
+} mach_port_destroyed_notification_t;
+
+typedef struct {
+ mach_msg_header_t not_header;
+ mach_msg_type_t not_type; /* MACH_MSG_TYPE_INTEGER_32 */
+ unsigned int not_count;
+} mach_no_senders_notification_t;
+
+typedef struct {
+ mach_msg_header_t not_header;
+} mach_send_once_notification_t;
+
+typedef struct {
+ mach_msg_header_t not_header;
+ mach_msg_type_t not_type; /* MACH_MSG_TYPE_PORT_NAME */
+ mach_port_name_t not_port;
+} mach_dead_name_notification_t;
+
+#endif /* _MACH_NOTIFY_H_ */
diff --git a/include/mach/pc_sample.h b/include/mach/pc_sample.h
new file mode 100644
index 0000000..2d56b34
--- /dev/null
+++ b/include/mach/pc_sample.h
@@ -0,0 +1,66 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993,1992 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_PC_SAMPLE_H_
+#define _MACH_PC_SAMPLE_H_
+
+#include <mach/machine/vm_types.h>
+
+typedef unsigned int sampled_pc_flavor_t;
+
+
+#define SAMPLED_PC_PERIODIC 0x1 /* default */
+
+
+#define SAMPLED_PC_VM_ZFILL_FAULTS 0x10
+#define SAMPLED_PC_VM_REACTIVATION_FAULTS 0x20
+#define SAMPLED_PC_VM_PAGEIN_FAULTS 0x40
+#define SAMPLED_PC_VM_COW_FAULTS 0x80
+#define SAMPLED_PC_VM_FAULTS_ANY 0x100
+#define SAMPLED_PC_VM_FAULTS \
+ (SAMPLED_PC_VM_ZFILL_FAULTS | \
+ SAMPLED_PC_VM_REACTIVATION_FAULTS |\
+ SAMPLED_PC_VM_PAGEIN_FAULTS |\
+ SAMPLED_PC_VM_COW_FAULTS )
+
+
+
+
+/*
+ * Definitions for the PC sampling interface.
+ */
+
+typedef struct sampled_pc {
+ rpc_vm_offset_t id; /* task_t address */
+ rpc_vm_offset_t pc; /* program counter */
+ sampled_pc_flavor_t sampletype;
+} sampled_pc_t;
+
+typedef sampled_pc_t *sampled_pc_array_t;
+typedef unsigned int sampled_pc_seqno_t;
+
+
+#endif /* _MACH_PC_SAMPLE_H_ */
diff --git a/include/mach/policy.h b/include/mach/policy.h
new file mode 100644
index 0000000..da776c9
--- /dev/null
+++ b/include/mach/policy.h
@@ -0,0 +1,45 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_POLICY_H_
+#define _MACH_POLICY_H_
+
+/*
+ * mach/policy.h
+ *
+ * Definitions for scheduing policy.
+ */
+
+/*
+ * Policy definitions. Policies must be powers of 2.
+ */
+#define POLICY_TIMESHARE 1
+#define POLICY_FIXEDPRI 2
+#define POLICY_LAST 2
+
+#define invalid_policy(policy) (((policy) <= 0) || ((policy) > POLICY_LAST))
+
+#endif /* _MACH_POLICY_H_ */
diff --git a/include/mach/port.h b/include/mach/port.h
new file mode 100644
index 0000000..c9bbcf1
--- /dev/null
+++ b/include/mach/port.h
@@ -0,0 +1,159 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/port.h
+ *
+ * Definition of a port
+ *
+ * [The basic mach_port_t type should probably be machine-dependent,
+ * as it must be represented by a 32-bit integer.]
+ */
+
+#ifndef _MACH_PORT_H_
+#define _MACH_PORT_H_
+
+#include <mach/boolean.h>
+#include <mach/machine/vm_types.h>
+
+/*
+ * Port names are the type used by userspace, they are always 32-bit wide.
+ */
+typedef unsigned int mach_port_name_t;
+typedef mach_port_name_t *mach_port_name_array_t;
+typedef const mach_port_name_t *const_mach_port_name_array_t;
+
+/*
+ * A port is represented
+ * - by a port name in userspace
+ * - by a pointer in kernel space
+ * While in userspace mach_port_name_t and mach_port_name are interchangable,
+ * in kernelspace they need to be different and appropriately converted.
+ */
+#ifdef KERNEL
+typedef vm_offset_t mach_port_t;
+#else /* KERNEL */
+typedef mach_port_name_t mach_port_t;
+#endif
+typedef mach_port_t *mach_port_array_t;
+typedef const mach_port_t *const_mach_port_array_t;
+typedef int *rpc_signature_info_t;
+
+/*
+ * MACH_PORT_NULL is a legal value that can be carried in messages.
+ * It indicates the absence of any port or port rights. (A port
+ * argument keeps the message from being "simple", even if the
+ * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also
+ * a legal value that can be carried in messages. It indicates
+ * that a port right was present, but it died.
+ */
+
+#define MACH_PORT_NULL 0 /* works with both user and kernel ports */
+#define MACH_PORT_DEAD ((mach_port_t) ~0)
+#define MACH_PORT_NAME_NULL ((mach_port_name_t) 0)
+#define MACH_PORT_NAME_DEAD ((mach_port_name_t) ~0)
+
+#define MACH_PORT_VALID(port) \
+ (((port) != MACH_PORT_NULL) && ((port) != MACH_PORT_DEAD))
+#define MACH_PORT_NAME_VALID(name) \
+ (((name) != MACH_PORT_NAME_NULL) && ((name) != MACH_PORT_NAME_DEAD))
+
+/*
+ * These are the different rights a task may have.
+ * The MACH_PORT_RIGHT_* definitions are used as arguments
+ * to mach_port_allocate, mach_port_get_refs, etc, to specify
+ * a particular right to act upon. The mach_port_names and
+ * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_*
+ * definitions. This is because a single name may denote
+ * multiple rights.
+ */
+
+typedef natural_t mach_port_right_t;
+
+#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0)
+#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1)
+#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2)
+#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3)
+#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4)
+#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 5)
+
+typedef natural_t mach_port_type_t;
+typedef mach_port_type_t *mach_port_type_array_t;
+
+#define MACH_PORT_TYPE(right) ((mach_port_type_t)(1 << ((right)+16)))
+#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0)
+#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
+#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
+#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE)
+#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET)
+#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
+
+/* Convenient combinations. */
+
+#define MACH_PORT_TYPE_SEND_RECEIVE \
+ (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
+#define MACH_PORT_TYPE_SEND_RIGHTS \
+ (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
+#define MACH_PORT_TYPE_PORT_RIGHTS \
+ (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
+#define MACH_PORT_TYPE_PORT_OR_DEAD \
+ (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
+#define MACH_PORT_TYPE_ALL_RIGHTS \
+ (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
+
+/* Dummy type bits that mach_port_type/mach_port_names can return. */
+
+#define MACH_PORT_TYPE_DNREQUEST 0x80000000U
+#define MACH_PORT_TYPE_MAREQUEST 0x40000000
+#define MACH_PORT_TYPE_COMPAT 0x20000000
+
+/* User-references for capabilities. */
+
+typedef natural_t mach_port_urefs_t;
+typedef integer_t mach_port_delta_t; /* change in urefs */
+
+/* Attributes of ports. (See mach_port_get_receive_status.) */
+
+typedef natural_t mach_port_seqno_t; /* sequence number */
+typedef unsigned int mach_port_mscount_t; /* make-send count */
+typedef unsigned int mach_port_msgcount_t; /* number of msgs */
+typedef unsigned int mach_port_rights_t; /* number of rights */
+
+typedef struct mach_port_status {
+ mach_port_name_t mps_pset; /* containing port set */
+ mach_port_seqno_t mps_seqno; /* sequence number */
+ mach_port_mscount_t mps_mscount; /* make-send count */
+ mach_port_msgcount_t mps_qlimit; /* queue limit */
+ mach_port_msgcount_t mps_msgcount; /* number in the queue */
+ mach_port_rights_t mps_sorights; /* how many send-once rights */
+ boolean_t mps_srights; /* do send rights exist? */
+ boolean_t mps_pdrequest; /* port-deleted requested? */
+ boolean_t mps_nsrequest; /* no-senders requested? */
+} mach_port_status_t;
+
+#define MACH_PORT_QLIMIT_DEFAULT ((mach_port_msgcount_t) 5)
+#define MACH_PORT_QLIMIT_MAX ((mach_port_msgcount_t) 16)
+
+#endif /* _MACH_PORT_H_ */
diff --git a/include/mach/processor_info.h b/include/mach/processor_info.h
new file mode 100644
index 0000000..5f761ea
--- /dev/null
+++ b/include/mach/processor_info.h
@@ -0,0 +1,104 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993,1992,1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/processor_info.h
+ * Author: David L. Black
+ * Date: 1988
+ *
+ * Data structure definitions for processor_info, processor_set_info
+ */
+
+#ifndef _MACH_PROCESSOR_INFO_H_
+#define _MACH_PROCESSOR_INFO_H_
+
+#include <mach/machine.h>
+
+/*
+ * Generic information structure to allow for expansion.
+ */
+typedef integer_t *processor_info_t; /* varying array of int. */
+
+#define PROCESSOR_INFO_MAX (1024) /* max array size */
+typedef integer_t processor_info_data_t[PROCESSOR_INFO_MAX];
+
+
+typedef integer_t *processor_set_info_t; /* varying array of int. */
+
+#define PROCESSOR_SET_INFO_MAX (1024) /* max array size */
+typedef integer_t processor_set_info_data_t[PROCESSOR_SET_INFO_MAX];
+
+/*
+ * Currently defined information.
+ */
+#define PROCESSOR_BASIC_INFO 1 /* basic information */
+
+struct processor_basic_info {
+ cpu_type_t cpu_type; /* type of cpu */
+ cpu_subtype_t cpu_subtype; /* subtype of cpu */
+/*boolean_t*/integer_t running; /* is processor running */
+ integer_t slot_num; /* slot number */
+/*boolean_t*/integer_t is_master; /* is this the master processor */
+};
+
+typedef struct processor_basic_info processor_basic_info_data_t;
+typedef struct processor_basic_info *processor_basic_info_t;
+#define PROCESSOR_BASIC_INFO_COUNT \
+ (sizeof(processor_basic_info_data_t)/sizeof(integer_t))
+
+
+#define PROCESSOR_SET_BASIC_INFO 1 /* basic information */
+
+struct processor_set_basic_info {
+ integer_t processor_count; /* How many processors */
+ integer_t task_count; /* How many tasks */
+ integer_t thread_count; /* How many threads */
+ integer_t load_average; /* Scaled */
+ integer_t mach_factor; /* Scaled */
+};
+
+/*
+ * Scaling factor for load_average, mach_factor.
+ */
+#define LOAD_SCALE 1000
+
+typedef struct processor_set_basic_info processor_set_basic_info_data_t;
+typedef struct processor_set_basic_info *processor_set_basic_info_t;
+#define PROCESSOR_SET_BASIC_INFO_COUNT \
+ (sizeof(processor_set_basic_info_data_t)/sizeof(integer_t))
+
+#define PROCESSOR_SET_SCHED_INFO 2 /* scheduling info */
+
+struct processor_set_sched_info {
+ integer_t policies; /* allowed policies */
+ integer_t max_priority; /* max priority for new threads */
+};
+
+typedef struct processor_set_sched_info processor_set_sched_info_data_t;
+typedef struct processor_set_sched_info *processor_set_sched_info_t;
+#define PROCESSOR_SET_SCHED_INFO_COUNT \
+ (sizeof(processor_set_sched_info_data_t)/sizeof(integer_t))
+
+#endif /* _MACH_PROCESSOR_INFO_H_ */
diff --git a/include/mach/profil.h b/include/mach/profil.h
new file mode 100644
index 0000000..866f267
--- /dev/null
+++ b/include/mach/profil.h
@@ -0,0 +1,212 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+/*
+ * Copyright 1991 by Open Software Foundation,
+ * Grenoble, FRANCE
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies and
+ * that both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of OSF or Open Software
+ * Foundation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission.
+ *
+ * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
+ * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#ifndef _MACH_PROFIL_H_
+#define _MACH_PROFIL_H_
+
+#include <mach/boolean.h>
+#include <ipc/ipc_object.h>
+#include <vm/vm_kern.h>
+
+
+#define NB_PROF_BUFFER 2 /* number of buffers servicing a
+ * profiled thread */
+#define SIZE_PROF_BUFFER 100 /* size of a profil buffer (in int)
+ * This values is also defined in
+ * the server (ugly), be careful ! */
+
+
+struct prof_data {
+ ipc_object_t prof_port; /* where to send a full buffer */
+
+ struct buffer {
+ int *p_zone; /* points to the actual storage area */
+ int p_index;/* next slot to be filled */
+ boolean_t p_full; /* is the current buffer full ? */
+ } prof_area[NB_PROF_BUFFER];
+
+ int prof_index; /* index of the buffer structure
+ * currently in use */
+
+};
+typedef struct prof_data *prof_data_t;
+#define NULLPBUF ((prof_data_t) 0)
+typedef struct buffer *buffer_t;
+
+/* Macros */
+
+#define set_pbuf_nb(pbuf, nb) \
+ (((nb) >= 0 && (nb) < NB_PROF_BUFFER) \
+ ? (pbuf)->prof_index = (nb), 1 \
+ : 0)
+
+
+#define get_pbuf_nb(pbuf) \
+ (pbuf)->prof_index
+
+
+extern vm_map_t kernel_map;
+
+#define dealloc_pbuf_area(pbuf) \
+ { \
+ register int i; \
+ \
+ for(i=0; i < NB_PROF_BUFFER ; i++) \
+ kmem_free(kernel_map, \
+ (vm_offset_t) (pbuf)->prof_area[i].p_zone, \
+ SIZE_PROF_BUFFER*sizeof(int)); \
+ kmem_free(kernel_map, \
+ (vm_offset_t)(pbuf), \
+ sizeof(struct prof_data)); \
+ }
+
+
+#define alloc_pbuf_area(pbuf, vmpbuf) \
+ (vmpbuf) = (vm_offset_t) 0; \
+ if (kmem_alloc(kernel_map, &(vmpbuf) , sizeof(struct prof_data)) == \
+ KERN_SUCCESS) { \
+ register int i; \
+ register boolean_t end; \
+ \
+ (pbuf) = (prof_data_t) (vmpbuf); \
+ for(i=0, end=FALSE; i < NB_PROF_BUFFER && end == FALSE; i++) { \
+ (vmpbuf) = (vm_offset_t) 0; \
+ if (kmem_alloc(kernel_map,&(vmpbuf),SIZE_PROF_BUFFER*sizeof(int)) == KERN_SUCCESS) { \
+ (pbuf)->prof_area[i].p_zone = (int *) (vmpbuf); \
+ (pbuf)->prof_area[i].p_full = FALSE; \
+ } \
+ else { \
+ (pbuf) = NULLPBUF; \
+ end = TRUE; \
+ } \
+ } \
+ } \
+ else \
+ (pbuf) = NULLPBUF;
+
+
+
+/* MACRO set_pbuf_value
+**
+** enters the value 'val' in the buffer 'pbuf' and returns the following
+** indications: 0: means that a fatal error occurred: the buffer was full
+** (it hasn't been sent yet)
+** 1: means that a value has been inserted successfully
+** 2: means that we'v just entered the last value causing
+** the current buffer to be full.(must switch to
+** another buffer and signal the sender to send it)
+*/
+
+#define set_pbuf_value(pbuf, val) \
+ { \
+ register buffer_t a = &((pbuf)->prof_area[(pbuf)->prof_index]); \
+ register int i = a->p_index++; \
+ register boolean_t f = a->p_full; \
+ \
+ if (f == TRUE ) \
+ *(val) = 0; \
+ else { \
+ a->p_zone[i] = *(val); \
+ if (i == SIZE_PROF_BUFFER-1) { \
+ a->p_full = TRUE; \
+ *(val) = 2; \
+ } \
+ else \
+ *(val) = 1; \
+ } \
+ }
+
+
+#define reset_pbuf_area(pbuf) \
+ { \
+ register int *i = &((pbuf)->prof_index); \
+ \
+ *i = (*i == NB_PROF_BUFFER-1) ? 0 : ++(*i); \
+ (pbuf)->prof_area[*i].p_index = 0; \
+ }
+
+
+/**************************************************************/
+/* Structure, elements used for queuing operations on buffers */
+/**************************************************************/
+
+#define thread_t int *
+/*
+** This must be done in order to avoid a circular inclusion
+** with file kern/thread.h .
+** When using this data structure, one must cast the actual
+** type, this is (int *) or (thread_t)
+*/
+
+struct buf_to_send {
+ queue_chain_t list;
+ thread_t thread;
+ int number; /* the number of the buffer to be sent */
+ char wakeme; /* do wakeup when buffer has been sent */
+ } ;
+
+#undef thread_t
+
+
+
+typedef struct buf_to_send *buf_to_send_t;
+
+#define NULLBTS ((buf_to_send_t) 0)
+
+/*
+** Global variable: the head of the queue of buffers to send
+** It is a queue with locks (uses macros from queue.h) and it
+** is shared by hardclock() and the sender_thread()
+*/
+
+mpqueue_head_t prof_queue;
+
+#endif /* _MACH_PROF_H_ */
diff --git a/include/mach/profilparam.h b/include/mach/profilparam.h
new file mode 100644
index 0000000..20a8aaf
--- /dev/null
+++ b/include/mach/profilparam.h
@@ -0,0 +1,62 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+/*
+ * Copyright 1991 by Open Software Foundation,
+ * Grenoble, FRANCE
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appears in all copies and
+ * that both the copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of OSF or Open Software
+ * Foundation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission.
+ *
+ * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
+ * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _MACH_PROFILPARAM_H_
+#define _MACH_PROFILPARAM_H_
+
+/*
+ * These values are also used when compiling the server, be careful !
+ */
+
+#define NB_PROF_BUFFER 2 /* number of buffers servicing a
+ * profiled thread */
+#define SIZE_PROF_BUFFER 100 /* size of a profil buffer (in int) */
+
+#endif /* _MACH_PROFILPARAM_H_ */
diff --git a/include/mach/std_types.defs b/include/mach/std_types.defs
new file mode 100644
index 0000000..b461f06
--- /dev/null
+++ b/include/mach/std_types.defs
@@ -0,0 +1,101 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Mach kernel standard interface type declarations
+ */
+
+#ifndef _MACH_STD_TYPES_DEFS_
+#define _MACH_STD_TYPES_DEFS_
+
+type int32_t = MACH_MSG_TYPE_INTEGER_32;
+type int64_t = MACH_MSG_TYPE_INTEGER_64;
+type boolean_t = MACH_MSG_TYPE_BOOLEAN;
+type unsigned = MACH_MSG_TYPE_INTEGER_32;
+type uint32_t = MACH_MSG_TYPE_INTEGER_32;
+type uint64_t = MACH_MSG_TYPE_INTEGER_64;
+
+/* Get the definitions for natural_t and integer_t */
+#include <mach/machine/machine_types.defs>
+
+type kern_return_t = int;
+
+type pointer_t = ^array[] of MACH_MSG_TYPE_BYTE
+ ctype: vm_offset_t;
+
+
+type mach_port_t = MACH_MSG_TYPE_COPY_SEND
+#ifndef KERNEL_SERVER
+#ifdef MACH_PAYLOAD_TO_PORT
+ intranpayload: mach_port_t MACH_PAYLOAD_TO_PORT
+#endif /* MACH_PAYLOAD_TO_PORT */
+#endif /* KERNEL_SERVER */
+;
+type mach_port_array_t = array[] of mach_port_t;
+
+type mach_port_name_t = MACH_MSG_TYPE_PORT_NAME;
+type mach_port_name_array_t = array[] of mach_port_name_t;
+
+type mach_port_right_t = natural_t;
+
+type mach_port_type_t = natural_t;
+type mach_port_type_array_t = array[] of mach_port_type_t;
+
+type mach_port_urefs_t = natural_t;
+type mach_port_delta_t = integer_t;
+type mach_port_seqno_t = natural_t;
+type mach_port_mscount_t = unsigned;
+type mach_port_msgcount_t = unsigned;
+type mach_port_rights_t = unsigned;
+type mach_msg_id_t = integer_t;
+type mach_msg_type_name_t = unsigned;
+type mach_msg_type_number_t = natural_t;
+
+type mach_port_move_receive_t = MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t;
+type mach_port_copy_send_t = MACH_MSG_TYPE_COPY_SEND
+ ctype: mach_port_t;
+type mach_port_make_send_t = MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+type mach_port_move_send_t = MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t;
+type mach_port_make_send_once_t = MACH_MSG_TYPE_MAKE_SEND_ONCE
+ ctype: mach_port_t;
+type mach_port_move_send_once_t = MACH_MSG_TYPE_MOVE_SEND_ONCE
+ ctype: mach_port_t;
+
+type mach_port_receive_t = MACH_MSG_TYPE_PORT_RECEIVE
+ ctype: mach_port_t;
+type mach_port_send_t = MACH_MSG_TYPE_PORT_SEND
+ ctype: mach_port_t;
+type mach_port_send_once_t = MACH_MSG_TYPE_PORT_SEND_ONCE
+ ctype: mach_port_t;
+
+type mach_port_poly_t = polymorphic
+ ctype: mach_port_t;
+
+import <mach/std_types.h>;
+
+#endif /* _MACH_STD_TYPES_DEFS_ */
diff --git a/include/mach/std_types.h b/include/mach/std_types.h
new file mode 100644
index 0000000..0d5db0a
--- /dev/null
+++ b/include/mach/std_types.h
@@ -0,0 +1,44 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992,1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Mach standard external interface type definitions.
+ *
+ */
+
+#ifndef _MACH_STD_TYPES_H_
+#define _MACH_STD_TYPES_H_
+
+#define EXPORT_BOOLEAN
+
+#include <mach/boolean.h>
+#include <mach/kern_return.h>
+#include <mach/port.h>
+#include <mach/machine/vm_types.h>
+
+typedef vm_offset_t pointer_t;
+typedef vm_offset_t vm_address_t;
+
+#endif /* _MACH_STD_TYPES_H_ */
diff --git a/include/mach/syscall_sw.h b/include/mach/syscall_sw.h
new file mode 100644
index 0000000..89597e9
--- /dev/null
+++ b/include/mach/syscall_sw.h
@@ -0,0 +1,121 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_SYSCALL_SW_H_
+#define _MACH_SYSCALL_SW_H_
+
+/*
+ * The machine-dependent "syscall_sw.h" file should
+ * define a macro for
+ * kernel_trap(trap_name, trap_number, arg_count)
+ * which will expand into assembly code for the
+ * trap.
+ *
+ * N.B.: When adding calls, do not put spaces in the macros.
+ */
+
+#include <mach/machine/syscall_sw.h>
+
+/*
+ * These trap numbers should be taken from the
+ * table in <kern/syscall_sw.c>.
+ */
+
+kernel_trap(evc_wait,-17,1)
+kernel_trap(evc_wait_clear,-18,1)
+
+kernel_trap(mach_msg_trap,-25,7)
+kernel_trap(mach_reply_port,-26,0)
+kernel_trap(mach_thread_self,-27,0)
+kernel_trap(mach_task_self,-28,0)
+kernel_trap(mach_host_self,-29,0)
+kernel_trap(mach_print,-30,1)
+
+kernel_trap(swtch_pri,-59,1)
+kernel_trap(swtch,-60,0)
+kernel_trap(thread_switch,-61,3)
+kernel_trap(nw_update,-80,3)
+kernel_trap(nw_lookup,-81,2)
+kernel_trap(nw_endpoint_allocate,-82,4)
+kernel_trap(nw_endpoint_deallocate,-83,1)
+kernel_trap(nw_buffer_allocate,-84,2)
+kernel_trap(nw_buffer_deallocate,-85,2)
+kernel_trap(nw_connection_open,-86,4)
+kernel_trap(nw_connection_accept,-87,3)
+kernel_trap(nw_connection_close,-88,1)
+kernel_trap(nw_multicast_add,-89,4)
+kernel_trap(nw_multicast_drop,-90,4)
+kernel_trap(nw_endpoint_status,-91,3)
+kernel_trap(nw_send,-92,3)
+kernel_trap(nw_receive,-93,2)
+kernel_trap(nw_rpc,-94,4)
+kernel_trap(nw_select,-95,3)
+
+
+/*
+ * These are syscall versions of Mach kernel calls.
+ * They only work on local tasks.
+ */
+
+kernel_trap(syscall_vm_map,-64,11)
+kernel_trap(syscall_vm_allocate,-65,4)
+kernel_trap(syscall_vm_deallocate,-66,3)
+
+kernel_trap(syscall_task_create,-68,3)
+kernel_trap(syscall_task_terminate,-69,1)
+kernel_trap(syscall_task_suspend,-70,1)
+kernel_trap(syscall_task_set_special_port,-71,3)
+
+kernel_trap(syscall_mach_port_allocate,-72,3)
+kernel_trap(syscall_mach_port_deallocate,-73,2)
+kernel_trap(syscall_mach_port_insert_right,-74,4)
+kernel_trap(syscall_mach_port_allocate_name,-75,3)
+kernel_trap(syscall_thread_depress_abort,-76,1)
+
+/* These are screwing up glibc somehow. */
+/*kernel_trap(syscall_device_writev_request,-39,6)*/
+/*kernel_trap(syscall_device_write_request,-40,6)*/
+
+/*
+ * These "Mach" traps are not implemented by the kernel;
+ * the emulation library and Unix server implement them.
+ * But they are traditionally part of libmach, and use
+ * the Mach trap calling conventions and numbering.
+ */
+
+#if UNIXOID_TRAPS
+
+kernel_trap(task_by_pid,-33,1)
+kernel_trap(pid_by_task,-34,4)
+kernel_trap(init_process,-41,0)
+kernel_trap(map_fd,-43,5)
+kernel_trap(rfs_make_symlink,-44,3)
+kernel_trap(htg_syscall,-52,3)
+kernel_trap(set_ras_address,-53,2)
+
+#endif /* UNIXOID_TRAPS */
+
+#endif /* _MACH_SYSCALL_SW_H_ */
diff --git a/include/mach/task_info.h b/include/mach/task_info.h
new file mode 100644
index 0000000..0e048c5
--- /dev/null
+++ b/include/mach/task_info.h
@@ -0,0 +1,126 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Machine-independent task information structures and definitions.
+ *
+ * The definitions in this file are exported to the user. The kernel
+ * will translate its internal data structures to these structures
+ * as appropriate.
+ *
+ */
+
+#ifndef _MACH_TASK_INFO_H_
+#define _MACH_TASK_INFO_H_
+
+#include <mach/machine/vm_types.h>
+#include <mach/time_value.h>
+
+/*
+ * Generic information structure to allow for expansion.
+ */
+typedef integer_t *task_info_t; /* varying array of int */
+
+#define TASK_INFO_MAX (1024) /* maximum array size */
+typedef integer_t task_info_data_t[TASK_INFO_MAX];
+
+/*
+ * Currently defined information structures.
+ */
+#define TASK_BASIC_INFO 1 /* basic information */
+
+struct task_basic_info {
+ integer_t suspend_count; /* suspend count for task */
+ integer_t base_priority; /* base scheduling priority */
+ rpc_vm_size_t virtual_size; /* number of virtual pages */
+ rpc_vm_size_t resident_size; /* number of resident pages */
+ /* Deprecated, please use user_time64 */
+ rpc_time_value_t user_time; /* total user run time for
+ terminated threads */
+ /* Deprecated, please use system_time64 */
+ rpc_time_value_t system_time; /* total system run time for
+ terminated threads */
+ /* Deprecated, please use creation_time64 */
+ rpc_time_value_t creation_time; /* creation time stamp */
+ time_value64_t user_time64; /* total user run time for
+ terminated threads */
+ time_value64_t system_time64; /* total system run time for
+ terminated threads */
+ time_value64_t creation_time64; /* creation time stamp */
+};
+
+typedef struct task_basic_info task_basic_info_data_t;
+typedef struct task_basic_info *task_basic_info_t;
+#define TASK_BASIC_INFO_COUNT \
+ (sizeof(task_basic_info_data_t) / sizeof(integer_t))
+
+
+#define TASK_EVENTS_INFO 2 /* various event counts */
+
+struct task_events_info {
+ rpc_long_natural_t faults; /* number of page faults */
+ rpc_long_natural_t zero_fills; /* number of zero fill pages */
+ rpc_long_natural_t reactivations; /* number of reactivated pages */
+ rpc_long_natural_t pageins; /* number of actual pageins */
+ rpc_long_natural_t cow_faults; /* number of copy-on-write faults */
+ rpc_long_natural_t messages_sent; /* number of messages sent */
+ rpc_long_natural_t messages_received; /* number of messages received */
+};
+typedef struct task_events_info task_events_info_data_t;
+typedef struct task_events_info *task_events_info_t;
+#define TASK_EVENTS_INFO_COUNT \
+ (sizeof(task_events_info_data_t) / sizeof(integer_t))
+
+#define TASK_THREAD_TIMES_INFO 3 /* total times for live threads -
+ only accurate if suspended */
+
+struct task_thread_times_info {
+ /* Deprecated, please use user_time64 */
+ rpc_time_value_t user_time; /* total user run time for
+ live threads */
+ /* Deprecated, please use system_time64 */
+ rpc_time_value_t system_time; /* total system run time for
+ live threads */
+ time_value64_t user_time64; /* total user run time for
+ live threads */
+ time_value64_t system_time64; /* total system run time for
+ live threads */
+};
+
+typedef struct task_thread_times_info task_thread_times_info_data_t;
+typedef struct task_thread_times_info *task_thread_times_info_t;
+#define TASK_THREAD_TIMES_INFO_COUNT \
+ (sizeof(task_thread_times_info_data_t) / sizeof(integer_t))
+
+/*
+ * Flavor definitions for task_ras_control
+ */
+#define TASK_RAS_CONTROL_PURGE_ALL 0
+#define TASK_RAS_CONTROL_PURGE_ONE 1
+#define TASK_RAS_CONTROL_PURGE_ALL_AND_INSTALL_ONE 2
+#define TASK_RAS_CONTROL_INSTALL_ONE 3
+
+#endif /* _MACH_TASK_INFO_H_ */
+
diff --git a/include/mach/task_notify.defs b/include/mach/task_notify.defs
new file mode 100644
index 0000000..a4aff67
--- /dev/null
+++ b/include/mach/task_notify.defs
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Free Software Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+#if KERNEL_USER
+ KernelUser
+#endif /* KERNEL_USER */
+ task_notify 4400;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+type task_notify_port_t = mach_port_t
+ ctype: mach_port_t
+#ifdef TASK_NOTIFY_INTRAN
+ intran: TASK_NOTIFY_INTRAN
+#endif
+#ifdef TASK_NOTIFY_INTRAN_PAYLOAD
+ intranpayload: TASK_NOTIFY_INTRAN_PAYLOAD
+#endif
+#ifdef TASK_NOTIFY_OUTTRAN
+ outtran: TASK_NOTIFY_OUTTRAN
+#endif
+#ifdef TASK_NOTIFY_DESTRUCTOR
+ destructor: TASK_NOTIFY_DESTRUCTOR
+#endif
+;
+
+#ifdef TASK_NOTIFY_IMPORTS
+TASK_NOTIFY_IMPORTS
+#endif
+
+type task_move_t = MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t;
+
+/* These notifications are sent to the port registered via
+ `register_new_task_notification' and provide a robust parental
+ relation between tasks. */
+simpleroutine mach_notify_new_task(
+ notify : task_notify_port_t;
+ task : task_move_t;
+ parent : task_move_t);
diff --git a/include/mach/task_special_ports.h b/include/mach/task_special_ports.h
new file mode 100644
index 0000000..42ecc15
--- /dev/null
+++ b/include/mach/task_special_ports.h
@@ -0,0 +1,66 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/task_special_ports.h
+ *
+ * Defines codes for special_purpose task ports. These are NOT
+ * port identifiers - they are only used for the task_get_special_port
+ * and task_set_special_port routines.
+ *
+ */
+
+#ifndef _MACH_TASK_SPECIAL_PORTS_H_
+#define _MACH_TASK_SPECIAL_PORTS_H_
+
+#define TASK_KERNEL_PORT 1 /* Represents task to the outside
+ world.*/
+#define TASK_EXCEPTION_PORT 3 /* Exception messages for task are
+ sent to this port. */
+#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */
+
+/*
+ * Definitions for ease of use
+ */
+
+#define task_get_kernel_port(task, port) \
+ (task_get_special_port((task), TASK_KERNEL_PORT, (port)))
+
+#define task_set_kernel_port(task, port) \
+ (task_set_special_port((task), TASK_KERNEL_PORT, (port)))
+
+#define task_get_exception_port(task, port) \
+ (task_get_special_port((task), TASK_EXCEPTION_PORT, (port)))
+
+#define task_set_exception_port(task, port) \
+ (task_set_special_port((task), TASK_EXCEPTION_PORT, (port)))
+
+#define task_get_bootstrap_port(task, port) \
+ (task_get_special_port((task), TASK_BOOTSTRAP_PORT, (port)))
+
+#define task_set_bootstrap_port(task, port) \
+ (task_set_special_port((task), TASK_BOOTSTRAP_PORT, (port)))
+
+#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */
diff --git a/include/mach/thread_info.h b/include/mach/thread_info.h
new file mode 100644
index 0000000..4f322e0
--- /dev/null
+++ b/include/mach/thread_info.h
@@ -0,0 +1,124 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/thread_info
+ *
+ * Thread information structure and definitions.
+ *
+ * The defintions in this file are exported to the user. The kernel
+ * will translate its internal data structures to these structures
+ * as appropriate.
+ *
+ */
+
+#ifndef _MACH_THREAD_INFO_H_
+#define _MACH_THREAD_INFO_H_
+
+#include <mach/boolean.h>
+#include <mach/policy.h>
+#include <mach/time_value.h>
+
+/*
+ * Generic information structure to allow for expansion.
+ */
+typedef integer_t *thread_info_t; /* varying array of ints */
+
+#define THREAD_INFO_MAX (1024) /* maximum array size */
+typedef integer_t thread_info_data_t[THREAD_INFO_MAX];
+
+/*
+ * Currently defined information.
+ */
+#define THREAD_BASIC_INFO 1 /* basic information */
+
+struct thread_basic_info {
+ /* Deprecated, please use user_time64 */
+ rpc_time_value_t user_time; /* user run time */
+ /* Deprecated, please use system_time64 */
+ rpc_time_value_t system_time; /* system run time */
+ integer_t cpu_usage; /* scaled cpu usage percentage */
+ integer_t base_priority; /* base scheduling priority */
+ integer_t cur_priority; /* current scheduling priority */
+ integer_t run_state; /* run state (see below) */
+ integer_t flags; /* various flags (see below) */
+ integer_t suspend_count; /* suspend count for thread */
+ integer_t sleep_time; /* number of seconds that thread
+ has been sleeping */
+ /* Deprecated, please use creation_time64 */
+ rpc_time_value_t creation_time; /* time stamp of creation */
+ time_value64_t user_time64; /* user run time */
+ time_value64_t system_time64; /* system run time */
+ time_value64_t creation_time64; /* time stamp of creation */
+};
+
+typedef struct thread_basic_info thread_basic_info_data_t;
+typedef struct thread_basic_info *thread_basic_info_t;
+#define THREAD_BASIC_INFO_COUNT \
+ (sizeof(thread_basic_info_data_t) / sizeof(natural_t))
+
+/*
+ * Scale factor for usage field.
+ */
+
+#define TH_USAGE_SCALE 1000
+
+/*
+ * Thread run states (state field).
+ */
+
+#define TH_STATE_RUNNING 1 /* thread is running normally */
+#define TH_STATE_STOPPED 2 /* thread is stopped */
+#define TH_STATE_WAITING 3 /* thread is waiting normally */
+#define TH_STATE_UNINTERRUPTIBLE 4 /* thread is in an uninterruptible
+ wait */
+#define TH_STATE_HALTED 5 /* thread is halted at a
+ clean point */
+
+/*
+ * Thread flags (flags field).
+ */
+#define TH_FLAGS_SWAPPED 0x1 /* thread is swapped out */
+#define TH_FLAGS_IDLE 0x2 /* thread is an idle thread */
+
+#define THREAD_SCHED_INFO 2
+
+struct thread_sched_info {
+ integer_t policy; /* scheduling policy */
+ integer_t data; /* associated data */
+ integer_t base_priority; /* base priority */
+ integer_t max_priority; /* max priority */
+ integer_t cur_priority; /* current priority */
+/*boolean_t*/integer_t depressed; /* depressed ? */
+ integer_t depress_priority; /* priority depressed from */
+ integer_t last_processor; /* last processor used by the thread */
+};
+
+typedef struct thread_sched_info thread_sched_info_data_t;
+typedef struct thread_sched_info *thread_sched_info_t;
+#define THREAD_SCHED_INFO_COUNT \
+ (sizeof(thread_sched_info_data_t) / sizeof(natural_t))
+
+#endif /* _MACH_THREAD_INFO_H_ */
diff --git a/include/mach/thread_special_ports.h b/include/mach/thread_special_ports.h
new file mode 100644
index 0000000..33e3a1f
--- /dev/null
+++ b/include/mach/thread_special_ports.h
@@ -0,0 +1,59 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/thread_special_ports.h
+ *
+ * Defines codes for special_purpose thread ports. These are NOT
+ * port identifiers - they are only used for the thread_get_special_port
+ * and thread_set_special_port routines.
+ *
+ */
+
+#ifndef _MACH_THREAD_SPECIAL_PORTS_H_
+#define _MACH_THREAD_SPECIAL_PORTS_H_
+
+#define THREAD_KERNEL_PORT 1 /* Represents the thread to the outside
+ world.*/
+#define THREAD_EXCEPTION_PORT 3 /* Exception messages for the thread
+ are sent to this port. */
+
+/*
+ * Definitions for ease of use
+ */
+
+#define thread_get_kernel_port(thread, port) \
+ (thread_get_special_port((thread), THREAD_KERNEL_PORT, (port)))
+
+#define thread_set_kernel_port(thread, port) \
+ (thread_set_special_port((thread), THREAD_KERNEL_PORT, (port)))
+
+#define thread_get_exception_port(thread, port) \
+ (thread_get_special_port((thread), THREAD_EXCEPTION_PORT, (port)))
+
+#define thread_set_exception_port(thread, port) \
+ (thread_set_special_port((thread), THREAD_EXCEPTION_PORT, (port)))
+
+#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */
diff --git a/include/mach/thread_status.h b/include/mach/thread_status.h
new file mode 100644
index 0000000..b02f5b4
--- /dev/null
+++ b/include/mach/thread_status.h
@@ -0,0 +1,55 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ *
+ * This file contains the structure definitions for the user-visible
+ * thread state. This thread state is examined with the thread_get_state
+ * kernel call and may be changed with the thread_set_state kernel call.
+ *
+ */
+
+#ifndef _MACH_THREAD_STATUS_H_
+#define _MACH_THREAD_STATUS_H_
+
+/*
+ * The actual structure that comprises the thread state is defined
+ * in the machine dependent module.
+ */
+#include <mach/machine/vm_types.h>
+#include <mach/machine/thread_status.h>
+
+/*
+ * Generic definition for machine-dependent thread status.
+ */
+
+typedef natural_t *thread_state_t; /* Variable-length array */
+
+#define THREAD_STATE_MAX (1024) /* Maximum array size */
+typedef natural_t thread_state_data_t[THREAD_STATE_MAX];
+
+#define THREAD_STATE_FLAVOR_LIST 0 /* List of valid flavors */
+
+#endif /* _MACH_THREAD_STATUS_H_ */
diff --git a/include/mach/thread_switch.h b/include/mach/thread_switch.h
new file mode 100644
index 0000000..5235b87
--- /dev/null
+++ b/include/mach/thread_switch.h
@@ -0,0 +1,40 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_THREAD_SWITCH_H_
+#define _MACH_THREAD_SWITCH_H_
+
+/*
+ * Constant definitions for thread_switch trap.
+ */
+
+#define SWITCH_OPTION_NONE 0
+#define SWITCH_OPTION_DEPRESS 1
+#define SWITCH_OPTION_WAIT 2
+
+#define valid_switch_option(opt) ((0 <= (opt)) && ((opt) <= 2))
+
+#endif /* _MACH_THREAD_SWITCH_H_ */
diff --git a/include/mach/time_value.h b/include/mach/time_value.h
new file mode 100644
index 0000000..e08707b
--- /dev/null
+++ b/include/mach/time_value.h
@@ -0,0 +1,201 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_TIME_VALUE_H_
+#define _MACH_TIME_VALUE_H_
+
+#include <mach/machine/vm_types.h>
+
+/*
+ * Time value returned by kernel.
+ */
+
+struct rpc_time_value {
+ /* TODO: this should be 64 bits regardless of the arch to be Y2038 proof. */
+ rpc_long_integer_t seconds;
+ integer_t microseconds;
+};
+
+/*
+ * Time value used by kernel interfaces. Ideally they should be migrated
+ * to use time_value64 below.
+ */
+struct time_value {
+ long_integer_t seconds;
+ integer_t microseconds;
+};
+typedef struct time_value time_value_t;
+
+#ifdef KERNEL
+typedef struct rpc_time_value rpc_time_value_t;
+#else
+typedef struct time_value rpc_time_value_t;
+#endif
+
+/*
+ * Time value used internally by the kernel that uses 64 bits to track seconds
+ * and nanoseconds. Note that the current resolution is only microseconds.
+ */
+struct time_value64 {
+ int64_t seconds;
+ int64_t nanoseconds;
+};
+typedef struct time_value64 time_value64_t;
+
+/**
+ * Functions used by Mig to perform user to kernel conversion and vice-versa.
+ * We only do this because we may run a 64 bit kernel with a 32 bit user space.
+ */
+static __inline__ rpc_time_value_t convert_time_value_to_user(time_value_t tv)
+{
+ rpc_time_value_t user = {.seconds = tv.seconds, .microseconds = tv.microseconds};
+ return user;
+}
+static __inline__ time_value_t convert_time_value_from_user(rpc_time_value_t tv)
+{
+ time_value_t kernel = {.seconds = tv.seconds, .microseconds = tv.microseconds};
+ return kernel;
+}
+
+/*
+ * Macros to manipulate time values. Assume that time values
+ * are normalized (microseconds <= 999999).
+ */
+#define TIME_MICROS_MAX (1000000)
+#define TIME_NANOS_MAX (1000000000)
+
+#define time_value_assert(val) \
+ assert(0 <= (val)->microseconds && (val)->microseconds < TIME_MICROS_MAX);
+
+#define time_value64_assert(val) \
+ assert(0 <= (val)->nanoseconds && (val)->nanoseconds < TIME_NANOS_MAX);
+
+#define time_value_add_usec(val, micros) { \
+ time_value_assert(val); \
+ if (((val)->microseconds += (micros)) \
+ >= TIME_MICROS_MAX) { \
+ (val)->microseconds -= TIME_MICROS_MAX; \
+ (val)->seconds++; \
+ } \
+ time_value_assert(val); \
+}
+
+#define time_value64_add_nanos(val, nanos) { \
+ time_value64_assert(val); \
+ if (((val)->nanoseconds += (nanos)) \
+ >= TIME_NANOS_MAX) { \
+ (val)->nanoseconds -= TIME_NANOS_MAX; \
+ (val)->seconds++; \
+ } \
+ time_value64_assert(val); \
+}
+
+#define time_value64_sub_nanos(val, nanos) { \
+ time_value64_assert(val); \
+ if (((val)->nanoseconds -= (nanos)) < 0) { \
+ (val)->nanoseconds += TIME_NANOS_MAX; \
+ (val)->seconds--; \
+ } \
+ time_value64_assert(val); \
+}
+
+#define time_value_add(result, addend) { \
+ time_value_assert(addend); \
+ (result)->seconds += (addend)->seconds; \
+ time_value_add_usec(result, (addend)->microseconds); \
+ }
+
+#define time_value64_add(result, addend) { \
+ time_value64_assert(addend); \
+ (result)->seconds += (addend)->seconds; \
+ time_value64_add_nanos(result, (addend)->nanoseconds); \
+ }
+
+#define time_value64_sub(result, subtrahend) { \
+ time_value64_assert(subtrahend); \
+ (result)->seconds -= (subtrahend)->seconds; \
+ time_value64_sub_nanos(result, (subtrahend)->nanoseconds); \
+ }
+
+#define time_value64_init(tv) { \
+ (tv)->seconds = 0; \
+ (tv)->nanoseconds = 0; \
+ }
+
+#define TIME_VALUE64_TO_TIME_VALUE(tv64, tv) do { \
+ (tv)->seconds = (tv64)->seconds; \
+ (tv)->microseconds = (tv64)->nanoseconds / 1000; \
+} while(0)
+
+#define TIME_VALUE_TO_TIME_VALUE64(tv, tv64) do { \
+ (tv64)->seconds = (tv)->seconds; \
+ (tv64)->nanoseconds = (tv)->microseconds * 1000; \
+} while(0)
+
+/*
+ * Time value available through the mapped-time interface.
+ * Read this mapped value with
+ * do {
+ * secs = mtime->seconds;
+ * __sync_synchronize();
+ * usecs = mtime->microseconds;
+ * __sync_synchronize();
+ * } while (secs != mtime->check_seconds);
+ */
+
+typedef struct mapped_time_value {
+ integer_t seconds;
+ integer_t microseconds;
+ integer_t check_seconds;
+ struct time_value64 time_value;
+ int64_t check_seconds64;
+} mapped_time_value_t;
+
+/* Macros for converting between struct timespec and time_value_t. */
+
+#define TIME_VALUE_TO_TIMESPEC(tv, ts) do { \
+ (ts)->tv_sec = (tv)->seconds; \
+ (ts)->tv_nsec = (tv)->microseconds * 1000; \
+} while(0)
+
+#define TIMESPEC_TO_TIME_VALUE(tv, ts) do { \
+ (tv)->seconds = (ts)->tv_sec; \
+ (tv)->microseconds = (ts)->tv_nsec / 1000; \
+} while(0)
+
+/* Macros for converting between struct timespec and time_value64_t. */
+
+#define TIME_VALUE64_TO_TIMESPEC(tv, ts) do { \
+ (ts)->tv_sec = (tv)->seconds; \
+ (ts)->tv_nsec = (tv)->nanoseconds; \
+} while(0)
+
+#define TIMESPEC_TO_TIME_VALUE64(tv, ts) do { \
+ (tv)->seconds = (ts)->tv_sec; \
+ (tv)->nanoseconds = (ts)->tv_nsec; \
+} while(0)
+
+#endif /* _MACH_TIME_VALUE_H_ */
diff --git a/include/mach/version.h b/include/mach/version.h
new file mode 100644
index 0000000..3ef7859
--- /dev/null
+++ b/include/mach/version.h
@@ -0,0 +1,73 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon rights
+ * to redistribute these changes.
+ */
+/*
+ * Each kernel has a major and minor version number. Changes in
+ * the major number in general indicate a change in exported features.
+ * Changes in minor number usually correspond to internal-only
+ * changes that the user need not be aware of (in general). These
+ * values are stored at boot time in the machine_info strucuture and
+ * can be obtained by user programs with the host_info kernel call.
+ * This mechanism is intended to be the formal way for Mach programs
+ * to provide for backward compatibility in future releases.
+ *
+ * [ This needs to be reconciled somehow with the major/minor version
+ * number stuffed into the version string - mja, 5/8/87 ]
+ *
+ * Following is an informal history of the numbers:
+ *
+ * 25-March-87 Avadis Tevanian, Jr.
+ * Created version numbering scheme. Started with major 1,
+ * minor 0.
+ */
+
+#ifndef _MACH_VERSION_H_
+#define _MACH_VERSION_H_
+
+#define KERNEL_MAJOR_VERSION 4
+#define KERNEL_MINOR_VERSION 0
+
+/*
+ * Version number of the kernel include files.
+ *
+ * This number must be changed whenever an incompatible change is made to one
+ * or more of our include files which are used by application programs that
+ * delve into kernel memory. The number should normally be simply incremented
+ * but may actually be changed in any manner so long as it differs from the
+ * numbers previously assigned to any other versions with which the current
+ * version is incompatible. It is used at boot time to determine which
+ * versions of the system programs to install.
+ *
+ * Note that the symbol _INCLUDE_VERSION must be set to this in the symbol
+ * table. On the VAX for example, this is done in locore.s.
+ */
+
+/*
+ * Current allocation strategy: bump either branch by 2, until non-MACH is
+ * excised from the CSD environment.
+ */
+#define INCLUDE_VERSION 0
+
+#endif /* _MACH_VERSION_H_ */
diff --git a/include/mach/vm_attributes.h b/include/mach/vm_attributes.h
new file mode 100644
index 0000000..9ca3ef5
--- /dev/null
+++ b/include/mach/vm_attributes.h
@@ -0,0 +1,63 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/vm_attributes.h
+ * Author: Alessandro Forin
+ *
+ * Virtual memory attributes definitions.
+ *
+ * These definitions are in addition to the machine-independent
+ * ones (e.g. protection), and are only selectively supported
+ * on specific machine architectures.
+ *
+ */
+
+#ifndef _MACH_VM_ATTRIBUTES_H_
+#define _MACH_VM_ATTRIBUTES_H_
+
+/*
+ * Types of machine-dependent attributes
+ */
+typedef unsigned int vm_machine_attribute_t;
+
+#define MATTR_CACHE 1 /* cachability */
+#define MATTR_MIGRATE 2 /* migrability */
+#define MATTR_REPLICATE 4 /* replicability */
+
+/*
+ * Values for the above, e.g. operations on attribute
+ */
+typedef int vm_machine_attribute_val_t;
+
+#define MATTR_VAL_OFF 0 /* (generic) turn attribute off */
+#define MATTR_VAL_ON 1 /* (generic) turn attribute on */
+#define MATTR_VAL_GET 2 /* (generic) return current value */
+
+#define MATTR_VAL_CACHE_FLUSH 6 /* flush from all caches */
+#define MATTR_VAL_DCACHE_FLUSH 7 /* flush from data caches */
+#define MATTR_VAL_ICACHE_FLUSH 8 /* flush from instruction caches */
+
+#endif /* _MACH_VM_ATTRIBUTES_H_ */
diff --git a/include/mach/vm_cache_statistics.h b/include/mach/vm_cache_statistics.h
new file mode 100644
index 0000000..072976a
--- /dev/null
+++ b/include/mach/vm_cache_statistics.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Free Software Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_VM_CACHE_STATISTICS_H_
+#define _MACH_VM_CACHE_STATISTICS_H_
+
+#include <mach/machine/vm_types.h>
+
+struct vm_cache_statistics {
+ integer_t cache_object_count; /* # of cached objects */
+ integer_t cache_count; /* # of cached pages */
+ integer_t active_tmp_count; /* # of active temporary pages */
+ integer_t inactive_tmp_count; /* # of inactive temporary pages */
+ integer_t active_perm_count; /* # of active permanent pages */
+ integer_t inactive_perm_count; /* # of inactive permanent pages */
+ integer_t dirty_count; /* # of dirty pages */
+ integer_t laundry_count; /* # of pages being laundered */
+ integer_t writeback_count; /* # of pages being written back */
+ integer_t slab_count; /* # of slab allocator pages */
+ integer_t slab_reclaim_count; /* # of reclaimable slab pages */
+};
+
+typedef struct vm_cache_statistics *vm_cache_statistics_t;
+typedef struct vm_cache_statistics vm_cache_statistics_data_t;
+
+#endif /* _MACH_VM_CACHE_STATISTICS_H_ */
diff --git a/include/mach/vm_inherit.h b/include/mach/vm_inherit.h
new file mode 100644
index 0000000..2899290
--- /dev/null
+++ b/include/mach/vm_inherit.h
@@ -0,0 +1,55 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/vm_inherit.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Virtual memory map inheritance definitions.
+ *
+ */
+
+#ifndef _MACH_VM_INHERIT_H_
+#define _MACH_VM_INHERIT_H_
+
+/*
+ * Types defined:
+ *
+ * vm_inherit_t inheritance codes.
+ */
+
+typedef int vm_inherit_t; /* might want to change this */
+
+/*
+ * Enumeration of valid values for vm_inherit_t.
+ */
+
+#define VM_INHERIT_SHARE ((vm_inherit_t) 0) /* share with child */
+#define VM_INHERIT_COPY ((vm_inherit_t) 1) /* copy into child */
+#define VM_INHERIT_NONE ((vm_inherit_t) 2) /* absent from child */
+
+#define VM_INHERIT_DEFAULT VM_INHERIT_COPY
+
+#endif /* _MACH_VM_INHERIT_H_ */
diff --git a/include/mach/vm_param.h b/include/mach/vm_param.h
new file mode 100644
index 0000000..4cbd0ec
--- /dev/null
+++ b/include/mach/vm_param.h
@@ -0,0 +1,102 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/vm_param.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
+ * Date: 1985
+ *
+ * Machine independent virtual memory parameters.
+ *
+ */
+
+#ifndef _MACH_VM_PARAM_H_
+#define _MACH_VM_PARAM_H_
+
+#include <mach/machine/vm_param.h>
+#include <mach/machine/vm_types.h>
+
+/*
+ * The machine independent pages are referred to as PAGES. A page
+ * is some number of hardware pages, depending on the target machine.
+ *
+ * All references to the size of a page should be done
+ * with PAGE_SIZE, PAGE_SHIFT, or PAGE_MASK.
+ * They may be implemented as either constants or variables,
+ * depending on more-specific code.
+ * If they're variables, they had better be initialized
+ * by the time system-independent code starts getting called.
+ *
+ * Regardless whether it is implemented with a constant or a variable,
+ * the PAGE_SIZE is assumed to be a power of two throughout the
+ * virtual memory system implementation.
+ *
+ * More-specific code must at least provide PAGE_SHIFT;
+ * we can calculate the others if necessary.
+ * (However, if PAGE_SHIFT really refers to a variable,
+ * PAGE_SIZE and PAGE_MASK should also be variables
+ * so their values don't have to be constantly recomputed.)
+ */
+#ifndef PAGE_SHIFT
+#error mach/machine/vm_param.h needs to define PAGE_SHIFT.
+#endif
+
+#ifndef PAGE_SIZE
+#define PAGE_SIZE (1 << PAGE_SHIFT)
+#endif
+
+#ifndef PAGE_MASK
+#define PAGE_MASK (PAGE_SIZE-1)
+#endif
+
+/*
+ * Convert addresses to pages and vice versa.
+ * No rounding is used.
+ */
+
+#define atop(x) (((vm_size_t)(x)) >> PAGE_SHIFT)
+#define ptoa(x) ((vm_offset_t)((x) << PAGE_SHIFT))
+
+/*
+ * Round off or truncate to the nearest page. These will work
+ * for either addresses or counts. (i.e. 1 byte rounds to 1 page
+ * bytes.
+ */
+
+#define round_page(x) ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
+#define trunc_page(x) ((vm_offset_t)(((vm_offset_t)(x)) & ~PAGE_MASK))
+
+#define round_phys(x) ((phys_addr_t)((((phys_addr_t)(x)) + PAGE_MASK) & ~PAGE_MASK))
+#define trunc_phys(x) ((phys_addr_t)(((phys_addr_t)(x)) & ~PAGE_MASK))
+
+/*
+ * Determine whether an address is page-aligned, or a count is
+ * an exact page multiple.
+ */
+
+#define page_aligned(x) ((((vm_offset_t) (x)) & PAGE_MASK) == 0)
+#define phys_aligned(x) ((((phys_addr_t) (x)) & PAGE_MASK) == 0)
+
+#endif /* _MACH_VM_PARAM_H_ */
diff --git a/include/mach/vm_prot.h b/include/mach/vm_prot.h
new file mode 100644
index 0000000..22a76a8
--- /dev/null
+++ b/include/mach/vm_prot.h
@@ -0,0 +1,79 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/vm_prot.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
+ *
+ * Virtual memory protection definitions.
+ *
+ */
+
+#ifndef _MACH_VM_PROT_H_
+#define _MACH_VM_PROT_H_
+
+/*
+ * Types defined:
+ *
+ * vm_prot_t VM protection values.
+ */
+
+typedef int vm_prot_t;
+
+/*
+ * Protection values, defined as bits within the vm_prot_t type
+ */
+
+#define VM_PROT_NONE ((vm_prot_t) 0x00)
+
+#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */
+#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */
+#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */
+
+/*
+ * The default protection for newly-created virtual memory
+ */
+
+#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE)
+
+/*
+ * The maximum privileges possible, for parameter checking.
+ */
+
+#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
+
+/*
+ * An invalid protection value.
+ * Used only by memory_object_lock_request to indicate no change
+ * to page locks. Using -1 here is a bad idea because it
+ * looks like VM_PROT_ALL and then some.
+ */
+#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08)
+
+/*
+ * This protection value says whether special notification is to be used.
+ */
+#define VM_PROT_NOTIFY ((vm_prot_t) 0x10)
+#endif /* _MACH_VM_PROT_H_ */
diff --git a/include/mach/vm_statistics.h b/include/mach/vm_statistics.h
new file mode 100644
index 0000000..2039a82
--- /dev/null
+++ b/include/mach/vm_statistics.h
@@ -0,0 +1,75 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993-1987 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach/vm_statistics.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub
+ *
+ * Virtual memory statistics structure.
+ *
+ */
+
+#ifndef _MACH_VM_STATISTICS_H_
+#define _MACH_VM_STATISTICS_H_
+
+#include <mach/machine/vm_types.h>
+
+struct vm_statistics {
+ integer_t pagesize; /* page size in bytes */
+ integer_t free_count; /* # of pages free */
+ integer_t active_count; /* # of pages active */
+ integer_t inactive_count; /* # of pages inactive */
+ integer_t wire_count; /* # of pages wired down */
+ integer_t zero_fill_count; /* # of zero fill pages */
+ integer_t reactivations; /* # of pages reactivated */
+ integer_t pageins; /* # of pageins */
+ integer_t pageouts; /* # of pageouts */
+ integer_t faults; /* # of faults */
+ integer_t cow_faults; /* # of copy-on-writes */
+ integer_t lookups; /* object cache lookups */
+ integer_t hits; /* object cache hits */
+};
+
+typedef struct vm_statistics *vm_statistics_t;
+typedef struct vm_statistics vm_statistics_data_t;
+
+#ifdef MACH_KERNEL
+extern vm_statistics_data_t vm_stat;
+#endif /* MACH_KERNEL */
+
+/*
+ * Each machine dependent implementation is expected to
+ * keep certain statistics. They may do this anyway they
+ * so choose, but are expected to return the statistics
+ * in the following structure.
+ */
+
+struct pmap_statistics {
+ integer_t resident_count; /* # of pages mapped (total)*/
+ integer_t wired_count; /* # of pages wired */
+};
+
+typedef struct pmap_statistics *pmap_statistics_t;
+#endif /* _MACH_VM_STATISTICS_H_ */
diff --git a/include/mach/vm_sync.h b/include/mach/vm_sync.h
new file mode 100644
index 0000000..0c7451c
--- /dev/null
+++ b/include/mach/vm_sync.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * All Rights Reserved.
+ */
+
+#ifndef _MACH_VM_SYNC_H_
+#define _MACH_VM_SYNC_H_
+
+/*
+ * Types defined:
+ *
+ * vm_sync_t VM synchronization flags
+ */
+
+typedef int vm_sync_t;
+
+/*
+ * Synchronization values
+ */
+
+#define VM_SYNC_ASYNCHRONOUS ((vm_sync_t) 0x01)
+#define VM_SYNC_SYNCHRONOUS ((vm_sync_t) 0x02)
+#define VM_SYNC_INVALIDATE ((vm_sync_t) 0x04)
+#if 0
+/* Not supported yet. */
+#define VM_SYNC_KILLPAGES ((vm_sync_t) 0x08)
+#define VM_SYNC_DEACTIVATE ((vm_sync_t) 0x10)
+#define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20)
+#define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40)
+#endif
+
+#endif /* _MACH_VM_SYNC_H_ */
diff --git a/include/mach/vm_wire.h b/include/mach/vm_wire.h
new file mode 100644
index 0000000..1552dfa
--- /dev/null
+++ b/include/mach/vm_wire.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 Free Software Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _MACH_VM_WIRE_H_
+#define _MACH_VM_WIRE_H_
+
+typedef int vm_wire_t;
+
+#define VM_WIRE_NONE 0
+#define VM_WIRE_CURRENT 1
+#define VM_WIRE_FUTURE 2
+
+#define VM_WIRE_ALL (VM_WIRE_CURRENT | VM_WIRE_FUTURE)
+
+#endif /* _MACH_VM_WIRE_H_ */
diff --git a/include/mach/xen.h b/include/mach/xen.h
new file mode 100644
index 0000000..4462082
--- /dev/null
+++ b/include/mach/xen.h
@@ -0,0 +1,95 @@
+
+/*
+ * Copyright (C) 2006-2009, 2011 Free Software Foundation
+ *
+ * This program is free software ; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation ; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY ; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with the program ; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _MACH_XEN_H
+#define _MACH_XEN_H
+#ifdef MACH_XEN
+#include <sys/types.h>
+#include <xen/public/xen.h>
+#include <i386/vm_param.h>
+
+extern struct start_info boot_info;
+
+extern volatile struct shared_info hyp_shared_info;
+
+#ifdef MACH_PV_PAGETABLES
+/* Memory translations */
+
+/* pa are physical addresses, from 0 to size of memory */
+/* ma are machine addresses, i.e. _real_ hardware adresses */
+/* la are linear addresses, i.e. without segmentation */
+
+/* This might also be useful out of Xen */
+#if VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS
+extern unsigned long la_shift;
+#else
+#define la_shift LINEAR_MIN_KERNEL_ADDRESS
+#endif
+#define la_to_pa(a) ((vm_offset_t)(((vm_offset_t)(a)) - la_shift))
+#define pa_to_la(a) ((vm_offset_t)(((vm_offset_t)(a)) + la_shift))
+
+#define kv_to_la(a) pa_to_la(_kvtophys(a))
+#define la_to_kv(a) phystokv(la_to_pa(a))
+
+#ifdef MACH_PSEUDO_PHYS
+#ifdef __i386__
+#if PAE
+#define PFN_LIST MACH2PHYS_VIRT_START_PAE
+#else
+#define PFN_LIST MACH2PHYS_VIRT_START_NONPAE
+#endif
+#else
+#define PFN_LIST MACH2PHYS_VIRT_START
+#endif
+#if VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS
+extern unsigned long *pfn_list;
+#else
+#define pfn_list ((unsigned long *) PFN_LIST)
+#endif
+#define mfn_to_pfn(n) (pfn_list[n])
+
+extern unsigned long *mfn_list;
+#define pfn_to_mfn(n) (mfn_list[n])
+#else
+#define mfn_to_pfn(n) (n)
+#define pfn_to_mfn(n) (n)
+#endif /* MACH_PSEUDO_PHYS */
+
+#define pa_to_mfn(a) (pfn_to_mfn(atop(a)))
+#ifdef PAE
+#define pa_to_ma(a) ({ vm_offset_t __a = (vm_offset_t) (a); (((pt_entry_t) pa_to_mfn(__a)) << PAGE_SHIFT) | (__a & PAGE_MASK); })
+#define ma_to_pa(a) ({ pt_entry_t __a = (pt_entry_t) (a); (mfn_to_pfn(__a >> PAGE_SHIFT) << PAGE_SHIFT) | (__a & PAGE_MASK); })
+#else
+#define pa_to_ma(a) ({ vm_offset_t __a = (vm_offset_t) (a); ptoa(pa_to_mfn(__a)) | (__a & PAGE_MASK); })
+#define ma_to_pa(a) ({ vm_offset_t __a = (vm_offset_t) (a); (mfn_to_pfn(atop((__a))) << PAGE_SHIFT) | (__a & PAGE_MASK); })
+#endif
+
+#define kv_to_mfn(a) pa_to_mfn(_kvtophys(a))
+#define kv_to_ma(a) pa_to_ma(_kvtophys(a))
+#else /* MACH_PV_PAGETABLES */
+#define mfn_to_pfn(n) (n)
+#define pfn_to_mfn(n) (n)
+#endif /* MACH_PV_PAGETABLES */
+
+#define mfn_to_kv(mfn) phystokv(ptoa(mfn_to_pfn(mfn)))
+
+#include <machine/xen.h>
+
+#endif /* MACH_XEN */
+#endif /* _MACH_XEN_H */
diff --git a/include/mach_debug/hash_info.h b/include/mach_debug/hash_info.h
new file mode 100644
index 0000000..8e6f19c
--- /dev/null
+++ b/include/mach_debug/hash_info.h
@@ -0,0 +1,41 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_DEBUG_HASH_INFO_H_
+#define _MACH_DEBUG_HASH_INFO_H_
+
+/*
+ * Remember to update the mig type definitions
+ * in mach_debug_types.defs when adding/removing fields.
+ */
+
+typedef struct hash_info_bucket {
+ unsigned int hib_count; /* number of records in bucket */
+} hash_info_bucket_t;
+
+typedef hash_info_bucket_t *hash_info_bucket_array_t;
+
+#endif /* _MACH_DEBUG_HASH_INFO_H_ */
diff --git a/include/mach_debug/mach_debug.defs b/include/mach_debug/mach_debug.defs
new file mode 100644
index 0000000..2de7df5
--- /dev/null
+++ b/include/mach_debug/mach_debug.defs
@@ -0,0 +1,228 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Matchmaker definitions file for Mach kernel debugging interface.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif /* KERNEL_SERVER */
+ mach_debug 3000;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+#include <mach_debug/mach_debug_types.defs>
+
+skip; /* host_ipc_statistics */
+skip; /* host_ipc_statistics_reset */
+skip; /* host_callout_info */
+skip; /* host_callout_statistics */
+skip; /* host_callout_statistics_reset */
+skip; /* host_zone_info */
+skip; /* host_ipc_bucket_info */
+
+#if !defined(MACH_IPC_DEBUG) || MACH_IPC_DEBUG
+
+/*
+ * Returns the exact number of extant send rights
+ * for the given receive right.
+ */
+
+routine mach_port_get_srights(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out srights : mach_port_rights_t);
+
+skip; /* host_ipc_hash_info */
+
+/*
+ * Returns information about the marequest hash table.
+ */
+
+routine host_ipc_marequest_info(
+ host : host_t;
+ out max_requests : unsigned;
+ out info : hash_info_bucket_array_t,
+ CountInOut, Dealloc);
+
+skip; /* mach_port_space_info */
+
+/*
+ * Returns information about the dead-name requests
+ * registered with the named receive right.
+ */
+
+routine mach_port_dnrequest_info(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out total : unsigned; /* total size of table */
+ out used : unsigned); /* amount used */
+
+#else /* !defined(MACH_IPC_DEBUG) || MACH_IPC_DEBUG */
+skip; /* mach_port_get_srights */
+skip; /* host_ipc_hash_info */
+skip; /* host_ipc_marequest_info */
+skip; /* mach_port_space_info */
+skip; /* mach_port_dnrequest_info */
+#endif /* !defined(MACH_IPC_DEBUG) || MACH_IPC_DEBUG */
+
+skip; /* mach_vm_region_info */
+skip; /* vm_mapped_pages_info */
+
+/*
+ * Returns stack usage information:
+ * reserved Amount of stack space reserved for pcb.
+ * total Number of stacks.
+ * space Total VM space for stacks.
+ * resident Resident VM space for stacks.
+ * maxusage Maximum amount of stack used.
+ * maxstack Address in the kernel of the largest stack.
+ */
+
+routine host_stack_usage(
+ host : host_t;
+ out reserved : vm_size_t;
+ out total : unsigned;
+ out space : vm_size_t;
+ out resident : vm_size_t;
+ out maxusage : vm_size_t;
+ out maxstack : vm_offset_t);
+
+routine processor_set_stack_usage(
+ pset : processor_set_name_t;
+ out total : unsigned;
+ out space : vm_size_t;
+ out resident : vm_size_t;
+ out maxusage : vm_size_t;
+ out maxstack : vm_offset_t);
+
+#if !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG
+
+/*
+ * Returns information about the global VP table.
+ */
+
+routine host_virtual_physical_table_info(
+ host : host_t;
+ out info : hash_info_bucket_array_t,
+ CountInOut, Dealloc);
+
+#else /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */
+skip; /* host_virtual_physical_table_info */
+#endif /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */
+
+/* The old host_load_symbol_table with a different ABI for symtab_name_t */
+skip;
+
+#if !defined(MACH_IPC_DEBUG) || MACH_IPC_DEBUG
+
+/*
+ * Return the type and address of the kernel object
+ * that the given send/receive right represents.
+ */
+
+routine mach_port_kernel_object(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out object_type : unsigned;
+ out object_addr : vm_offset_t);
+
+#else /* !defined(MACH_IPC_DEBUG) || MACH_IPC_DEBUG */
+skip; /* mach_port_kernel_object */
+#endif /* !defined(MACH_IPC_DEBUG) || MACH_IPC_DEBUG */
+
+#if !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG
+
+/*
+ * Returns information about a region of memory.
+ */
+
+routine mach_vm_region_info(
+ task : vm_task_t;
+ address : vm_address_t;
+ out region : vm_region_info_t;
+ /* avoid out-translation of the argument */
+ out object : memory_object_name_t =
+ MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t);
+
+routine mach_vm_object_info(
+ object : memory_object_name_t;
+ out info : vm_object_info_t;
+ /* avoid out-translation of the argument */
+ out shadow : memory_object_name_t =
+ MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t;
+ /* avoid out-translation of the argument */
+ out copy : memory_object_name_t =
+ MACH_MSG_TYPE_MOVE_SEND
+ ctype: mach_port_t);
+
+routine mach_vm_object_pages(
+ object : memory_object_name_t;
+ out pages : vm_page_info_array_t,
+ CountInOut, Dealloc);
+
+#else /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */
+skip; /* mach_vm_region_info */
+skip; /* mach_vm_object_info */
+skip; /* mach_vm_object_pages */
+#endif /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */
+
+/*
+ * Returns information about the memory allocation caches.
+ */
+routine host_slab_info(
+ host : host_t;
+ out info : cache_info_array_t,
+ CountInOut, Dealloc);
+
+#if !defined(MACH_KDB) || MACH_KDB
+/*
+ * Loads a symbol table for an external file into the kernel debugger.
+ * The symbol table data is an array of characters. It is assumed that
+ * the caller and the kernel debugger agree on its format.
+ */
+
+routine host_load_symbol_table(
+ host : host_priv_t;
+ task : task_t;
+ name : symtab_name_t;
+ symtab : pointer_t);
+
+#else /* !defined(MACH_KDB) || MACH_KDB */
+skip; /* host_load_symbol_table */
+#endif /* !defined(MACH_KDB) || MACH_KDB */
+
+#if !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG
+routine mach_vm_object_pages_phys(
+ object : memory_object_name_t;
+ out pages : vm_page_phys_info_array_t,
+ CountInOut, Dealloc);
+#else /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */
+skip; /* mach_vm_object_pages_phys */
+#endif /* !defined(MACH_VM_DEBUG) || MACH_VM_DEBUG */
diff --git a/include/mach_debug/mach_debug_types.defs b/include/mach_debug/mach_debug_types.defs
new file mode 100644
index 0000000..d897380
--- /dev/null
+++ b/include/mach_debug/mach_debug_types.defs
@@ -0,0 +1,121 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Mach kernel debugging interface type declarations
+ */
+
+#ifndef _MACH_DEBUG_MACH_DEBUG_TYPES_DEFS_
+#define _MACH_DEBUG_MACH_DEBUG_TYPES_DEFS_
+
+#include <mach/std_types.defs>
+
+#define CACHE_NAME_MAX_LEN 32
+type cache_name_t = struct[CACHE_NAME_MAX_LEN] of char;
+#undef CACHE_NAME_MAX_LEN
+type cache_info_t = struct {
+ integer_t flags;
+ rpc_vm_size_t cpu_pool_size;
+ rpc_vm_size_t obj_size;
+ rpc_vm_size_t align;
+ rpc_vm_size_t buf_size;
+ rpc_vm_size_t slab_size;
+ rpc_long_natural_t bufs_per_slab;
+ rpc_long_natural_t nr_objs;
+ rpc_long_natural_t nr_bufs;
+ rpc_long_natural_t nr_slabs;
+ rpc_long_natural_t nr_free_slabs;
+ cache_name_t name;
+};
+type cache_info_array_t = array[] of cache_info_t;
+
+type hash_info_bucket_t = struct {
+ unsigned hib_count;
+};
+type hash_info_bucket_array_t = array[] of hash_info_bucket_t;
+
+type vm_region_info_t = struct {
+ rpc_vm_offset_t vri_start;
+ rpc_vm_offset_t vri_end;
+ vm_prot_t vri_protection;
+ vm_prot_t vri_max_protection;
+ vm_inherit_t vri_inheritance;
+ unsigned vri_wired_count;
+ unsigned vri_user_wired_count;
+ rpc_vm_offset_t vri_object;
+ rpc_vm_offset_t vri_offset;
+ integer_t vri_needs_copy;
+ unsigned vri_sharing;
+};
+type vm_region_info_array_t = array[] of vm_region_info_t;
+
+type vm_object_info_state_t = uint32_t;
+type vm_object_info_t = struct {
+ rpc_vm_offset_t voi_object;
+ rpc_vm_size_t voi_pagesize;
+ rpc_vm_size_t voi_size;
+ unsigned voi_ref_count;
+ unsigned voi_resident_page_count;
+ unsigned voi_absent_count;
+ rpc_vm_offset_t voi_copy;
+ rpc_vm_offset_t voi_shadow;
+ rpc_vm_offset_t voi_shadow_offset;
+ rpc_vm_offset_t voi_paging_offset;
+ memory_object_copy_strategy_t voi_copy_strategy;
+ rpc_vm_offset_t voi_last_alloc;
+ unsigned voi_paging_in_progress;
+ vm_object_info_state_t voi_state;
+};
+type vm_object_info_array_t = array[] of vm_object_info_t;
+
+type vm_page_info_state_t = uint32_t;
+
+type vm_page_info_t = struct {
+ rpc_vm_offset_t vpi_offset;
+ rpc_vm_offset_t vpi_phys_addr;
+ unsigned vpi_wire_count;
+ vm_prot_t vpi_page_lock;
+ vm_prot_t vpi_unlock_request;
+ vm_page_info_state_t vpi_state;
+};
+type vm_page_info_array_t = array[] of vm_page_info_t;
+
+type vm_page_phys_info_t = struct {
+ rpc_vm_offset_t vpi_offset;
+ rpc_phys_addr_t vpi_phys_addr;
+ unsigned vpi_wire_count;
+ vm_prot_t vpi_page_lock;
+ vm_prot_t vpi_unlock_request;
+ vm_page_info_state_t vpi_state;
+};
+type vm_page_phys_info_array_t = array[] of vm_page_phys_info_t;
+
+type symtab_name_t = c_string[32];
+
+type kernel_debug_name_t = c_string[*: 64];
+
+import <mach_debug/mach_debug_types.h>;
+
+#endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_DEFS_ */
diff --git a/include/mach_debug/mach_debug_types.h b/include/mach_debug/mach_debug_types.h
new file mode 100644
index 0000000..98124ad
--- /dev/null
+++ b/include/mach_debug/mach_debug_types.h
@@ -0,0 +1,52 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Mach kernel debugging interface type declarations
+ */
+
+#ifndef _MACH_DEBUG_MACH_DEBUG_TYPES_H_
+#define _MACH_DEBUG_MACH_DEBUG_TYPES_H_
+
+#include <mach_debug/vm_info.h>
+#include <mach_debug/slab_info.h>
+#include <mach_debug/hash_info.h>
+
+typedef char symtab_name_t[32];
+typedef const char *const_symtab_name_t;
+
+/*
+ * A fixed-length string data type intended for names given to
+ * kernel objects.
+ *
+ * Note that it is not guaranteed that the in-kernel data
+ * structure will hold KERNEL_DEBUG_NAME_MAX bytes. The given
+ * name will be truncated to fit into the target data structure.
+ */
+#define KERNEL_DEBUG_NAME_MAX (64)
+typedef char kernel_debug_name_t[KERNEL_DEBUG_NAME_MAX];
+typedef const char *const_kernel_debug_name_t;
+
+#endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */
diff --git a/include/mach_debug/slab_info.h b/include/mach_debug/slab_info.h
new file mode 100644
index 0000000..0f6b5a2
--- /dev/null
+++ b/include/mach_debug/slab_info.h
@@ -0,0 +1,56 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_DEBUG_SLAB_INFO_H_
+#define _MACH_DEBUG_SLAB_INFO_H_
+
+#include <sys/types.h>
+
+/*
+ * Remember to update the mig type definitions
+ * in mach_debug_types.defs when adding/removing fields.
+ */
+
+#define CACHE_NAME_MAX_LEN 32
+
+typedef struct cache_info {
+ int flags;
+ rpc_vm_size_t cpu_pool_size;
+ rpc_vm_size_t obj_size;
+ rpc_vm_size_t align;
+ rpc_vm_size_t buf_size;
+ rpc_vm_size_t slab_size;
+ rpc_long_natural_t bufs_per_slab;
+ rpc_long_natural_t nr_objs;
+ rpc_long_natural_t nr_bufs;
+ rpc_long_natural_t nr_slabs;
+ rpc_long_natural_t nr_free_slabs;
+ char name[CACHE_NAME_MAX_LEN];
+} cache_info_t;
+
+typedef cache_info_t *cache_info_array_t;
+
+#endif /* _MACH_DEBUG_SLAB_INFO_H_ */
diff --git a/include/mach_debug/vm_info.h b/include/mach_debug/vm_info.h
new file mode 100644
index 0000000..cf45a2c
--- /dev/null
+++ b/include/mach_debug/vm_info.h
@@ -0,0 +1,143 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: mach_debug/vm_info.h
+ * Author: Rich Draves
+ * Date: March, 1990
+ *
+ * Definitions for the VM debugging interface.
+ */
+
+#ifndef _MACH_DEBUG_VM_INFO_H_
+#define _MACH_DEBUG_VM_INFO_H_
+
+#include <mach/boolean.h>
+#include <mach/machine/vm_types.h>
+#include <mach/vm_inherit.h>
+#include <mach/vm_prot.h>
+#include <mach/memory_object.h>
+#include <stdint.h>
+
+/*
+ * Remember to update the mig type definitions
+ * in mach_debug_types.defs when adding/removing fields.
+ */
+
+typedef struct vm_region_info {
+ rpc_vm_offset_t vri_start; /* start of region */
+ rpc_vm_offset_t vri_end; /* end of region */
+
+ vm_prot_t vri_protection; /* protection code */
+ vm_prot_t vri_max_protection; /* maximum protection */
+ vm_inherit_t vri_inheritance; /* inheritance */
+ unsigned int vri_wired_count; /* number of times wired */
+ unsigned int vri_user_wired_count; /* number of times user has wired */
+
+ rpc_vm_offset_t vri_object; /* the mapped object */
+ rpc_vm_offset_t vri_offset; /* offset into object */
+/*boolean_t*/integer_t vri_needs_copy; /* does object need to be copied? */
+ unsigned int vri_sharing; /* share map references */
+} vm_region_info_t;
+
+typedef vm_region_info_t *vm_region_info_array_t;
+
+
+typedef uint32_t vm_object_info_state_t;
+
+#define VOI_STATE_PAGER_CREATED 0x00000001
+#define VOI_STATE_PAGER_INITIALIZED 0x00000002
+#define VOI_STATE_PAGER_READY 0x00000004
+#define VOI_STATE_CAN_PERSIST 0x00000008
+#define VOI_STATE_INTERNAL 0x00000010
+#define VOI_STATE_TEMPORARY 0x00000020
+#define VOI_STATE_ALIVE 0x00000040
+#define VOI_STATE_LOCK_IN_PROGRESS 0x00000080
+#define VOI_STATE_LOCK_RESTART 0x00000100
+
+typedef struct vm_object_info {
+ rpc_vm_offset_t voi_object; /* this object */
+ rpc_vm_size_t voi_pagesize; /* object's page size */
+ rpc_vm_size_t voi_size; /* object size (valid if internal) */
+ unsigned int voi_ref_count; /* number of references */
+ unsigned int voi_resident_page_count; /* number of resident pages */
+ unsigned int voi_absent_count; /* number requested but not filled */
+ rpc_vm_offset_t voi_copy; /* copy object */
+ rpc_vm_offset_t voi_shadow; /* shadow object */
+ rpc_vm_offset_t voi_shadow_offset; /* offset into shadow object */
+ rpc_vm_offset_t voi_paging_offset; /* offset into memory object */
+ memory_object_copy_strategy_t voi_copy_strategy;
+ /* how to handle data copy */
+ rpc_vm_offset_t voi_last_alloc; /* offset of last allocation */
+ unsigned int voi_paging_in_progress; /* paging references */
+ vm_object_info_state_t voi_state; /* random state bits */
+} vm_object_info_t;
+
+typedef vm_object_info_t *vm_object_info_array_t;
+
+typedef uint32_t vm_page_info_state_t;
+
+#define VPI_STATE_BUSY 0x00000001
+#define VPI_STATE_WANTED 0x00000002
+#define VPI_STATE_TABLED 0x00000004
+#define VPI_STATE_FICTITIOUS 0x00000008
+#define VPI_STATE_PRIVATE 0x00000010
+#define VPI_STATE_ABSENT 0x00000020
+#define VPI_STATE_ERROR 0x00000040
+#define VPI_STATE_DIRTY 0x00000080
+#define VPI_STATE_PRECIOUS 0x00000100
+#define VPI_STATE_OVERWRITING 0x00000200
+#define VPI_STATE_INACTIVE 0x00000400
+#define VPI_STATE_ACTIVE 0x00000800
+#define VPI_STATE_LAUNDRY 0x00001000
+#define VPI_STATE_FREE 0x00002000
+#define VPI_STATE_REFERENCE 0x00004000
+
+#define VPI_STATE_PAGER 0x80000000 /* pager has the page */
+
+/* XXX: This structure holds a 32bit vpi_phys_addr. */
+typedef struct vm_page_info {
+ rpc_vm_offset_t vpi_offset; /* offset in object */
+ rpc_vm_offset_t vpi_phys_addr; /* physical address */
+ unsigned int vpi_wire_count; /* number of times wired */
+ vm_prot_t vpi_page_lock; /* XP access restrictions */
+ vm_prot_t vpi_unlock_request; /* outstanding unlock requests */
+ vm_page_info_state_t vpi_state; /* random state bits */
+} vm_page_info_t;
+
+typedef vm_page_info_t *vm_page_info_array_t;
+
+typedef struct vm_page_phys_info {
+ rpc_vm_offset_t vpi_offset; /* offset in object */
+ rpc_phys_addr_t vpi_phys_addr; /* physical address */
+ unsigned int vpi_wire_count; /* number of times wired */
+ vm_prot_t vpi_page_lock; /* XP access restrictions */
+ vm_prot_t vpi_unlock_request; /* outstanding unlock requests */
+ vm_page_info_state_t vpi_state; /* random state bits */
+} vm_page_phys_info_t;
+
+typedef vm_page_phys_info_t *vm_page_phys_info_array_t;
+
+#endif /* _MACH_DEBUG_VM_INFO_H_ */
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..91c5fe4
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,55 @@
+/*
+ * String Handling Functions.
+ * Copyright (C) 2006 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Barry deFreese.
+ */
+/*
+ * String handling functions.
+ *
+ */
+
+#ifndef _MACH_SA_SYS_STRING_H_
+#define _MACH_SA_SYS_STRING_H_
+
+#include <sys/types.h>
+
+extern void *memcpy (void *dest, const void *src, size_t n);
+
+extern void *memmove (void *dest, const void *src, size_t n);
+
+extern int memcmp (const void *s1, const void *s2, size_t n) __attribute__ ((pure));
+
+extern void *memset (void *s, int c, size_t n);
+
+extern char *strchr (const char *s, int c);
+
+extern char *strcpy (char *dest, const char *src);
+
+extern char *strncpy (char *dest, const char *src, size_t n);
+
+extern char *strsep (char **strp, const char *delim);
+
+extern int strcmp (const char *s1, const char *s2) __attribute__ ((pure));
+
+extern int strncmp (const char *s1, const char *s2, size_t n) __attribute__ ((pure));
+
+extern size_t strlen (const char *s) __attribute__ ((pure));
+
+extern char *strstr(const char *haystack, const char *needle);
+
+#endif /* _MACH_SA_SYS_STRING_H_ */
diff --git a/include/sys/reboot.h b/include/sys/reboot.h
new file mode 100644
index 0000000..21d421a
--- /dev/null
+++ b/include/sys/reboot.h
@@ -0,0 +1,135 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993,1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 4. The name of the Laboratory may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)reboot.h 7.5 (Berkeley) 6/27/88
+ */
+/*
+ * Warning: The contents of this file are deprecated;
+ * it should only ever be used for BSD and Mach 3 compatibility.
+ * As the above copyright notice suggests, this file originated in BSD;
+ * it is mostly the same, except the flags after RB_DFLTROOT
+ * have diverged from BSD.
+ */
+#ifndef _MACH_SYS_REBOOT_H_
+#define _MACH_SYS_REBOOT_H_
+
+/*
+ * Arguments to reboot system call.
+ * These are converted to switches, and passed to startup program,
+ * and on to init.
+ */
+#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
+
+#define RB_ASKNAME 0x01 /* -a: ask for file name to reboot from */
+#define RB_SINGLE 0x02 /* -s: reboot to single user only */
+#define RB_KDB 0x04 /* -d: kernel debugger symbols loaded */
+#define RB_HALT 0x08 /* -h: enter KDB at bootup */
+ /* for host_reboot(): don't reboot,
+ just halt */
+#define RB_INITNAME 0x10 /* -i: name given for /etc/init (unused) */
+#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */
+#define RB_NOBOOTRC 0x20 /* -b: don't run /etc/rc.boot */
+#define RB_ALTBOOT 0x40 /* use /boot.old vs /boot */
+#define RB_UNIPROC 0x80 /* -u: start only one processor */
+
+#define RB_SHIFT 8 /* second byte is for ux */
+
+#define RB_DEBUGGER 0x1000 /* for host_reboot(): enter kernel
+ debugger from user level */
+
+/* Corresponding BSD definitions, where they disagree with the Mach flags. */
+#define BSD_RB_NOSYNC 0x04 /* dont sync before reboot */
+#define BSD_RB_KDB 0x40 /* give control to kernel debugger */
+#define BSD_RB_RDONLY 0x80 /* mount root fs read-only */
+#define BSD_RB_DUMP 0x100 /* dump kernel memory before reboot */
+#define BSD_RB_MINIROOT 0x200 /* mini-root present in memory at boot time */
+#define BSD_RB_CONFIG 0x400 /* invoke user configuration routing */
+
+
+/*
+ * Constants for converting boot-style device number to type,
+ * adaptor (uba, mba, etc), unit number and partition number.
+ * Type (== major device number) is in the low byte
+ * for backward compatibility. Except for that of the "magic
+ * number", each mask applies to the shifted value.
+ * Format:
+ * (4) (4) (4) (4) (8) (8)
+ * --------------------------------
+ * |MA | AD| CT| UN| PART | TYPE |
+ * --------------------------------
+ */
+#define B_ADAPTORSHIFT 24
+#define B_ADAPTORMASK 0x0f
+#define B_ADAPTOR(val) (((val) >> B_ADAPTORSHIFT) & B_ADAPTORMASK)
+#define B_CONTROLLERSHIFT 20
+#define B_CONTROLLERMASK 0xf
+#define B_CONTROLLER(val) (((val)>>B_CONTROLLERSHIFT) & B_CONTROLLERMASK)
+#define B_UNITSHIFT 16
+#define B_UNITMASK 0xf
+#define B_UNIT(val) (((val) >> B_UNITSHIFT) & B_UNITMASK)
+#define B_PARTITIONSHIFT 8
+#define B_PARTITIONMASK 0xff
+#define B_PARTITION(val) (((val) >> B_PARTITIONSHIFT) & B_PARTITIONMASK)
+#define B_TYPESHIFT 0
+#define B_TYPEMASK 0xff
+#define B_TYPE(val) (((val) >> B_TYPESHIFT) & B_TYPEMASK)
+
+#define B_MAGICMASK ((u_int)0xf0000000U)
+#define B_DEVMAGIC ((u_int)0xa0000000U)
+
+#define MAKEBOOTDEV(type, adaptor, controller, unit, partition) \
+ (((type) << B_TYPESHIFT) | ((adaptor) << B_ADAPTORSHIFT) | \
+ ((controller) << B_CONTROLLERSHIFT) | ((unit) << B_UNITSHIFT) | \
+ ((partition) << B_PARTITIONSHIFT) | B_DEVMAGIC)
+
+#endif /* _MACH_SYS_REBOOT_H_ */
diff --git a/include/sys/types.h b/include/sys/types.h
new file mode 100644
index 0000000..8d5af37
--- /dev/null
+++ b/include/sys/types.h
@@ -0,0 +1,88 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+#ifndef _MACH_SA_SYS_TYPES_H_
+#define _MACH_SA_SYS_TYPES_H_
+
+#include <mach/machine/vm_types.h>
+#include <stdint.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef unsigned long size_t;
+#endif
+
+#ifndef _SSIZE_T
+#define _SSIZE_T
+typedef integer_t ssize_t;
+#endif
+
+typedef unsigned short dev_t; /* device id */
+typedef unsigned long gid_t; /* group id */
+typedef unsigned long ino_t; /* inode number */
+typedef unsigned short mode_t; /* permissions */
+typedef unsigned short nlink_t; /* link count */
+typedef natural_t off_t; /* file offset */
+typedef unsigned long uid_t; /* user id */
+
+
+/* Symbols allowed but not required by POSIX */
+
+typedef char * caddr_t; /* address of a (signed) char */
+
+#ifndef _TIME_T
+#define _TIME_T
+typedef unsigned long long time_t;
+#endif
+
+#define RAND_MAX 0x7fffffff
+
+/* Symbols not allowed by POSIX */
+#ifndef _POSIX_SOURCE
+
+/*
+ * Common type definitions that lots of old files seem to want.
+ */
+
+typedef unsigned char u_char; /* unsigned char */
+typedef unsigned short u_short; /* unsigned short */
+typedef unsigned int u_int; /* unsigned int */
+typedef unsigned long u_long; /* unsigned long */
+
+typedef unsigned int daddr_t; /* disk address */
+
+#define major(i) (((i) >> 8) & 0xFF)
+#define minor(i) ((i) & 0xFF)
+#define makedev(i,j) ((((i) & 0xFF) << 8) | ((j) & 0xFF))
+
+#define NBBY 8
+
+#ifndef NULL
+#define NULL ((void *) 0) /* the null pointer */
+#endif
+
+#endif /* _POSIX_SOURCE */
+
+#endif /* _MACH_SA_SYS_TYPES_H_ */