summaryrefslogtreecommitdiff
path: root/include/mach
diff options
context:
space:
mode:
Diffstat (limited to 'include/mach')
-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/bootstrap.defs49
-rw-r--r--include/mach/cthreads.h424
-rw-r--r--include/mach/default_pager.defs65
-rw-r--r--include/mach/default_pager_helper.defs53
-rw-r--r--include/mach/default_pager_types.defs44
-rw-r--r--include/mach/default_pager_types.h58
-rw-r--r--include/mach/error.h95
-rw-r--r--include/mach/errorlib.h69
-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.h298
-rw-r--r--include/mach/exec/exec.h130
-rw-r--r--include/mach/flick_mach3.h75
-rw-r--r--include/mach/flick_mach3_glue.h218
-rw-r--r--include/mach/flick_mach3mig_glue.h449
-rw-r--r--include/mach/host_info.h93
-rw-r--r--include/mach/inline.h27
-rw-r--r--include/mach/kern_return.h160
-rw-r--r--include/mach/lmm.h60
-rw-r--r--include/mach/mach.defs958
-rw-r--r--include/mach/mach4.defs82
-rw-r--r--include/mach/mach_host.defs379
-rw-r--r--include/mach/mach_norma.defs120
-rw-r--r--include/mach/mach_param.h53
-rw-r--r--include/mach/mach_port.defs346
-rw-r--r--include/mach/mach_traps.h132
-rw-r--r--include/mach/mach_types.defs249
-rw-r--r--include/mach/mach_types.h93
-rw-r--r--include/mach/machine.h267
-rw-r--r--include/mach/macro_help.h18
-rw-r--r--include/mach/memory_object.defs313
-rw-r--r--include/mach/memory_object.h83
-rw-r--r--include/mach/memory_object_default.defs121
-rw-r--r--include/mach/message.h750
-rw-r--r--include/mach/mig_errors.h105
-rw-r--r--include/mach/mig_support.h67
-rw-r--r--include/mach/msg_type.h42
-rw-r--r--include/mach/multiboot.h164
-rw-r--r--include/mach/norma_special_ports.h84
-rw-r--r--include/mach/norma_task.defs43
-rw-r--r--include/mach/notify.defs95
-rw-r--r--include/mach/notify.h122
-rw-r--r--include/mach/pc_sample.h66
-rw-r--r--include/mach/policy.h45
-rw-r--r--include/mach/port.h189
-rw-r--r--include/mach/proc_ops.h51
-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/rpc.h35
-rw-r--r--include/mach/sa/a.out.h28
-rw-r--r--include/mach/sa/alloca.h25
-rw-r--r--include/mach/sa/assert.h44
-rw-r--r--include/mach/sa/ctype.h59
-rw-r--r--include/mach/sa/errno.h98
-rw-r--r--include/mach/sa/fcntl.h22
-rw-r--r--include/mach/sa/limits.h32
-rw-r--r--include/mach/sa/malloc.h51
-rw-r--r--include/mach/sa/memory.h25
-rw-r--r--include/mach/sa/stddef.h24
-rw-r--r--include/mach/sa/stdio.h72
-rw-r--r--include/mach/sa/stdlib.h56
-rw-r--r--include/mach/sa/string.h56
-rw-r--r--include/mach/sa/strings.h28
-rw-r--r--include/mach/sa/sys/cdefs.h48
-rw-r--r--include/mach/sa/sys/ioctl.h52
-rw-r--r--include/mach/sa/sys/mman.h41
-rw-r--r--include/mach/sa/sys/reboot.h123
-rw-r--r--include/mach/sa/sys/signal.h206
-rw-r--r--include/mach/sa/sys/stat.h126
-rw-r--r--include/mach/sa/sys/termios.h207
-rw-r--r--include/mach/sa/sys/time.h53
-rw-r--r--include/mach/sa/sys/types.h91
-rw-r--r--include/mach/sa/time.h26
-rw-r--r--include/mach/sa/unistd.h18
-rw-r--r--include/mach/std_types.defs131
-rw-r--r--include/mach/std_types.h48
-rw-r--r--include/mach/syscall_sw.h140
-rw-r--r--include/mach/task_info.h111
-rw-r--r--include/mach/task_special_ports.h86
-rw-r--r--include/mach/thread_info.h116
-rw-r--r--include/mach/thread_special_ports.h79
-rw-r--r--include/mach/thread_status.h55
-rw-r--r--include/mach/thread_switch.h40
-rw-r--r--include/mach/time_value.h80
-rw-r--r--include/mach/version.h68
-rw-r--r--include/mach/vm_attributes.h63
-rw-r--r--include/mach/vm_inherit.h55
-rw-r--r--include/mach/vm_param.h98
-rw-r--r--include/mach/vm_prot.h79
-rw-r--r--include/mach/vm_statistics.h75
95 files changed, 11118 insertions, 0 deletions
diff --git a/include/mach/alert.h b/include/mach/alert.h
new file mode 100644
index 0000000..8232f9e
--- /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..54028ad
--- /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..2f3e6c8
--- /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/bootstrap.defs b/include/mach/bootstrap.defs
new file mode 100644
index 0000000..0b233e4
--- /dev/null
+++ b/include/mach/bootstrap.defs
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+subsystem bootstrap 999999;
+
+#include <mach/std_types.defs>
+
+ServerPrefix do_;
+
+/*
+ * The old form of the bootstrap_privileged_ports RPC
+ * is not expressible in Mig syntax, because the reply
+ * message doesn't have a return code.
+ */
+
+skip; /* old bootstrap_privileged_ports */
+
+/*
+ * The startup task can make this call on its bootstrap port
+ * to get the privileged ports.
+ */
+
+routine bootstrap_privileged_ports(
+ bootstrap : mach_port_t;
+ out priv_host : mach_port_t;
+ out priv_device : mach_port_t);
diff --git a/include/mach/cthreads.h b/include/mach/cthreads.h
new file mode 100644
index 0000000..d44fa20
--- /dev/null
+++ b/include/mach/cthreads.h
@@ -0,0 +1,424 @@
+/*
+ * 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: cthreads.h
+ * Author: Eric Cooper, Carnegie Mellon University
+ * Date: Jul, 1987
+ *
+ * Definitions for the C Threads package.
+ *
+ */
+
+
+#ifndef _CTHREADS_
+#define _CTHREADS_ 1
+
+#include <mach/machine/cthreads.h>
+#include <mach.h>
+#include <mach/macro_help.h>
+#include <mach/machine/vm_param.h>
+
+#ifdef __STDC__
+extern void *malloc();
+#else
+extern char *malloc();
+#endif
+
+typedef void *any_t; /* XXX - obsolete, should be deleted. */
+
+#if defined(TRUE)
+#else /* not defined(TRUE) */
+#define TRUE 1
+#define FALSE 0
+#endif
+
+/*
+ * C Threads package initialization.
+ */
+
+extern vm_offset_t cthread_init(void);
+
+
+/*
+ * Queues.
+ */
+typedef struct cthread_queue {
+ struct cthread_queue_item *head;
+ struct cthread_queue_item *tail;
+} *cthread_queue_t;
+
+typedef struct cthread_queue_item {
+ struct cthread_queue_item *next;
+} *cthread_queue_item_t;
+
+#define NO_QUEUE_ITEM ((cthread_queue_item_t) 0)
+
+#define QUEUE_INITIALIZER { NO_QUEUE_ITEM, NO_QUEUE_ITEM }
+
+#define cthread_queue_alloc() ((cthread_queue_t) calloc(1, sizeof(struct cthread_queue)))
+#define cthread_queue_init(q) ((q)->head = (q)->tail = 0)
+#define cthread_queue_free(q) free((q))
+
+#define cthread_queue_enq(q, x) \
+ MACRO_BEGIN \
+ (x)->next = 0; \
+ if ((q)->tail == 0) \
+ (q)->head = (cthread_queue_item_t) (x); \
+ else \
+ (q)->tail->next = (cthread_queue_item_t) (x); \
+ (q)->tail = (cthread_queue_item_t) (x); \
+ MACRO_END
+
+#define cthread_queue_preq(q, x) \
+ MACRO_BEGIN \
+ if ((q)->tail == 0) \
+ (q)->tail = (cthread_queue_item_t) (x); \
+ ((cthread_queue_item_t) (x))->next = (q)->head; \
+ (q)->head = (cthread_queue_item_t) (x); \
+ MACRO_END
+
+#define cthread_queue_head(q, t) ((t) ((q)->head))
+
+#define cthread_queue_deq(q, t, x) \
+ MACRO_BEGIN \
+ if (((x) = (t) ((q)->head)) != 0 && \
+ ((q)->head = (cthread_queue_item_t) ((x)->next)) == 0) \
+ (q)->tail = 0; \
+ MACRO_END
+
+#define cthread_queue_map(q, t, f) \
+ MACRO_BEGIN \
+ register cthread_queue_item_t x, next; \
+ for (x = (cthread_queue_item_t) ((q)->head); x != 0; x = next){\
+ next = x->next; \
+ (*(f))((t) x); \
+ } \
+ MACRO_END
+
+/*
+ * Spin locks.
+ */
+extern void spin_lock_solid(spin_lock_t *_lock);
+
+#if defined(spin_unlock)
+#else /* not defined(spin_unlock) */
+extern void spin_unlock(spin_lock_t *_lock);
+#endif
+
+#if defined(spin_try_lock)
+#else /* not defined(spin_try_lock) */
+extern boolean_t spin_try_lock(spin_lock_t *_lock);
+#endif
+
+#define spin_lock(p) \
+ MACRO_BEGIN \
+ if (!spin_try_lock(p)) { \
+ spin_lock_solid(p); \
+ } \
+ MACRO_END
+
+/*
+ * Mutex objects.
+ */
+typedef struct mutex {
+ spin_lock_t lock;
+ const char *name;
+ struct cthread_queue queue;
+ spin_lock_t held;
+ /* holder is for WAIT_DEBUG. Not ifdeffed to keep size constant. */
+ struct cthread *holder;
+} *mutex_t;
+
+#define MUTEX_INITIALIZER { SPIN_LOCK_INITIALIZER, 0, QUEUE_INITIALIZER, SPIN_LOCK_INITIALIZER}
+#define MUTEX_NAMED_INITIALIZER(Name) { SPIN_LOCK_INITIALIZER, Name, QUEUE_INITIALIZER, SPIN_LOCK_INITIALIZER}
+
+#ifdef WAIT_DEBUG
+#define mutex_set_holder(m,h) ((m)->holder = (h))
+#else
+#define mutex_set_holder(m,h) (0)
+#endif
+
+#define mutex_alloc() ((mutex_t) calloc(1, sizeof(struct mutex)))
+#define mutex_init(m) \
+ MACRO_BEGIN \
+ spin_lock_init(&(m)->lock); \
+ cthread_queue_init(&(m)->queue); \
+ spin_lock_init(&(m)->held); \
+ mutex_set_holder(m, 0); \
+ MACRO_END
+#define mutex_set_name(m, x) ((m)->name = (x))
+#define mutex_name(m) ((m)->name != 0 ? (m)->name : "?")
+#define mutex_clear(m) /* nop */???
+#define mutex_free(m) free((m))
+
+extern void mutex_lock_solid(mutex_t _mutex); /* blocking */
+
+extern void mutex_unlock_solid(mutex_t _mutex);
+
+#define mutex_try_lock(m) \
+ (spin_try_lock(&(m)->held) ? mutex_set_holder((m), cthread_self()), TRUE : FALSE)
+#define mutex_lock(m) \
+ MACRO_BEGIN \
+ if (!spin_try_lock(&(m)->held)) { \
+ mutex_lock_solid(m); \
+ } \
+ mutex_set_holder(m, cthread_self()); \
+ MACRO_END
+#define mutex_unlock(m) \
+ MACRO_BEGIN \
+ mutex_set_holder(m, 0); \
+ if (spin_unlock(&(m)->held), \
+ cthread_queue_head(&(m)->queue, vm_offset_t) != 0) { \
+ mutex_unlock_solid(m); \
+ } \
+ MACRO_END
+
+/*
+ * Condition variables.
+ */
+typedef struct condition {
+ spin_lock_t lock;
+ struct cthread_queue queue;
+ const char *name;
+} *condition_t;
+
+#define CONDITION_INITIALIZER { SPIN_LOCK_INITIALIZER, QUEUE_INITIALIZER, 0 }
+#define CONDITION_NAMED_INITIALIZER(Name) { SPIN_LOCK_INITIALIZER, QUEUE_INITIALIZER, Name }
+
+#define condition_alloc() \
+ ((condition_t) calloc(1, sizeof(struct condition)))
+#define condition_init(c) \
+ MACRO_BEGIN \
+ spin_lock_init(&(c)->lock); \
+ cthread_queue_init(&(c)->queue); \
+ MACRO_END
+#define condition_set_name(c, x) ((c)->name = (x))
+#define condition_name(c) ((c)->name != 0 ? (c)->name : "?")
+#define condition_clear(c) \
+ MACRO_BEGIN \
+ condition_broadcast(c); \
+ spin_lock(&(c)->lock); \
+ MACRO_END
+#define condition_free(c) \
+ MACRO_BEGIN \
+ condition_clear(c); \
+ free((c)); \
+ MACRO_END
+
+#define condition_signal(c) \
+ MACRO_BEGIN \
+ if ((c)->queue.head) { \
+ cond_signal(c); \
+ } \
+ MACRO_END
+
+#define condition_broadcast(c) \
+ MACRO_BEGIN \
+ if ((c)->queue.head) { \
+ cond_broadcast(c); \
+ } \
+ MACRO_END
+
+extern void cond_signal(condition_t _cond);
+
+extern void cond_broadcast(condition_t _cond);
+
+extern void condition_wait(condition_t _cond, mutex_t _mutex);
+
+/*
+ * Threads.
+ */
+
+typedef void * (*cthread_fn_t)(void *arg);
+
+/* XXX We really should be using the setjmp.h that goes with the libc
+ * that we're planning on using, since that's where the setjmp()
+ * functions are going to be comming from.
+ */
+#include <mach/setjmp.h>
+
+typedef struct cthread {
+ struct cthread *next;
+ struct mutex lock;
+ struct condition done;
+ int state;
+ jmp_buf catch_exit;
+ cthread_fn_t func;
+ void *arg;
+ void *result;
+ const char *name;
+ void *data;
+ void *ldata;
+ void *private_data;
+ struct ur_cthread *ur;
+} *cthread_t;
+
+#define NO_CTHREAD ((cthread_t) 0)
+
+extern cthread_t cthread_fork(cthread_fn_t _func, void *_arg);
+
+extern void cthread_detach(cthread_t _thread);
+
+extern any_t cthread_join(cthread_t _thread);
+
+extern void cthread_yield(void);
+
+extern void cthread_exit(void *_result);
+
+/*
+ * This structure must agree with struct cproc in cthread_internals.h
+ */
+typedef struct ur_cthread {
+ struct ur_cthread *next;
+ cthread_t incarnation;
+} *ur_cthread_t;
+
+#ifndef cthread_sp
+extern vm_offset_t
+cthread_sp(void);
+#endif
+
+extern vm_offset_t cthread_stack_mask;
+
+#if defined(STACK_GROWTH_UP)
+#define ur_cthread_ptr(sp) \
+ (* (ur_cthread_t *) ((sp) & cthread_stack_mask))
+#else /* not defined(STACK_GROWTH_UP) */
+#define ur_cthread_ptr(sp) \
+ (* (ur_cthread_t *) ( ((sp) | cthread_stack_mask) + 1 \
+ - sizeof(ur_cthread_t *)) )
+#endif /* defined(STACK_GROWTH_UP) */
+
+#define ur_cthread_self() (ur_cthread_ptr(cthread_sp()))
+
+#define cthread_assoc(id, t) ((((ur_cthread_t) (id))->incarnation = (t)), \
+ ((t) ? ((t)->ur = (ur_cthread_t)(id)) : 0))
+#define cthread_self() (ur_cthread_self()->incarnation)
+
+extern void cthread_set_name(cthread_t _thread, const char *_name);
+
+extern const char * cthread_name(cthread_t _thread);
+
+extern int cthread_count(void);
+
+extern void cthread_set_limit(int _limit);
+
+extern int cthread_limit(void);
+
+extern void cthread_set_kernel_limit(int _n);
+
+extern int cthread_kernel_limit(void);
+
+extern void cthread_wire(void);
+
+extern void cthread_unwire(void);
+
+extern void cthread_msg_busy(mach_port_t _port, int _min, int _max);
+
+extern void cthread_msg_active(mach_port_t _prt, int _min, int _max);
+
+extern mach_msg_return_t cthread_mach_msg(mach_msg_header_t *_header,
+ mach_msg_option_t _option,
+ mach_msg_size_t _send_size,
+ mach_msg_size_t _rcv_size,
+ mach_port_t _rcv_name,
+ mach_msg_timeout_t _timeout,
+ mach_port_t _notify,
+ int _min, int _max);
+
+extern void cthread_fork_prepare(void);
+
+extern void cthread_fork_parent(void);
+
+extern void cthread_fork_child(void);
+
+#if defined(THREAD_CALLS)
+/*
+ * Routines to replace thread_*.
+ */
+extern kern_return_t cthread_get_state(cthread_t _thread);
+
+extern kern_return_t cthread_set_state(cthread_t _thread);
+
+extern kern_return_t cthread_abort(cthread_t _thread);
+
+extern kern_return_t cthread_resume(cthread_t _thread);
+
+extern kern_return_t cthread_suspend(cthread_t _thread);
+
+extern kern_return_t cthread_call_on(cthread_t _thread);
+#endif /* defined(THREAD_CALLS) */
+
+#if defined(CTHREAD_DATA_XX)
+/*
+ * Set or get thread specific "global" variable
+ *
+ * The thread given must be the calling thread (ie. thread_self).
+ * XXX This is for compatibility with the old cthread_data. XXX
+ */
+extern int cthread_set_data(cthread_t _thread, void *_val);
+
+extern void * cthread_data(cthread_t _thread);
+#else /* defined(CTHREAD_DATA_XX) */
+
+#define cthread_set_data(_thread, _val) ((_thread)->data) = (void *)(_val);
+#define cthread_data(_thread) ((_thread)->data)
+
+#define cthread_set_ldata(_thread, _val) ((_thread)->ldata) = (void *)(_val);
+#define cthread_ldata(_thread) ((_thread)->ldata)
+
+#endif /* defined(CTHREAD_DATA_XX) */
+
+
+/*
+ * Support for POSIX thread specific data
+ *
+ * Multiplexes a thread specific "global" variable
+ * into many thread specific "global" variables.
+ */
+#define CTHREAD_DATA_VALUE_NULL (void *)0
+#define CTHREAD_KEY_INVALID (cthread_key_t)-1
+
+typedef int cthread_key_t;
+
+/*
+ * Create key to private data visible to all threads in task.
+ * Different threads may use same key, but the values bound to the key are
+ * maintained on a thread specific basis.
+ */
+extern int cthread_keycreate(cthread_key_t *_key);
+
+/*
+ * Get value currently bound to key for calling thread
+ */
+extern int cthread_getspecific(cthread_key_t _key, void **_value);
+
+/*
+ * Bind value to given key for calling thread
+ */
+extern int cthread_setspecific(cthread_key_t _key, void *_value);
+
+#endif /* not defined(_CTHREADS_) */
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_helper.defs b/include/mach/default_pager_helper.defs
new file mode 100644
index 0000000..a8a9f78
--- /dev/null
+++ b/include/mach/default_pager_helper.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.
+ */
+
+subsystem dp_helper 888888;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+ServerPrefix do_;
+
+/*
+ * Message that the default pager sends to
+ * a fileserver who has registered itself
+ * with the default pager as a "paging helper"
+ * to notify that more paging spage is or
+ * is not needed. Same message to let the
+ * fileserver know it can (ask to) reclaim space.
+ *
+ * This message is only sent to a port that
+ * has been previously registered via
+ * default_pager_register_fileserver.
+ * The (optional) reply from the fileserver
+ * is a call to default_pager_paging_file.
+ */
+
+simpleroutine dp_helper_paging_space(
+ dp_helper : mach_port_t;
+ space_shortage : boolean_t;
+ approx_amount : vm_size_t);
+
diff --git a/include/mach/default_pager_types.defs b/include/mach/default_pager_types.defs
new file mode 100644
index 0000000..3164f04
--- /dev/null
+++ b/include/mach/default_pager_types.defs
@@ -0,0 +1,44 @@
+/*
+ * 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[3] of natural_t;
+
+type default_pager_object_t = struct[2] of natural_t;
+type default_pager_object_array_t = array[] of default_pager_object_t;
+
+type default_pager_page_t = struct[1] of natural_t;
+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..99e43ce
--- /dev/null
+++ b/include/mach/default_pager_types.h
@@ -0,0 +1,58 @@
+/*
+ * 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];
+
+#endif _MACH_DEFAULT_PAGER_TYPES_H_
diff --git a/include/mach/error.h b/include/mach/error.h
new file mode 100644
index 0000000..1aa6a84
--- /dev/null
+++ b/include/mach/error.h
@@ -0,0 +1,95 @@
+/*
+ * 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_ROUTINE_NIL (mach_error_fn_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;
+typedef mach_error_t (* mach_error_fn_t)();
+#endif /* ASSEMBLER */
+
+#endif /* _MACH_ERROR_H_ */
diff --git a/include/mach/errorlib.h b/include/mach/errorlib.h
new file mode 100644
index 0000000..6c4d2bf
--- /dev/null
+++ b/include/mach/errorlib.h
@@ -0,0 +1,69 @@
+/*
+ * 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
+ * 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.
+ */
+/*
+ * File: errorlib.h
+ * Author: Douglas Orr, Carnegie Mellon University
+ * Date: Mar. 1988
+ *
+ * Error bases for subsytems errors.
+ */
+
+#include <mach/error.h>
+
+#define KERN_DEVICE_MOD (err_kern|err_sub(1))
+
+#define BOOTSTRAP_FS_MOD (err_bootstrap|err_sub(0))
+
+#define MACH_IPC_SEND_MOD (err_mach_ipc|err_sub(0))
+#define MACH_IPC_RCV_MOD (err_mach_ipc|err_sub(1))
+#define MACH_IPC_MIG_MOD (err_mach_ipc|err_sub(2))
+
+#define IPC_SEND_MOD (err_ipc|err_sub(0))
+#define IPC_RCV_MOD (err_ipc|err_sub(1))
+#define IPC_MIG_MOD (err_ipc|err_sub(2))
+
+#define SERV_NETNAME_MOD (err_server|err_sub(0))
+#define SERV_ENV_MOD (err_server|err_sub(1))
+#define SERV_EXECD_MOD (err_server|err_sub(2))
+
+
+#define NO_SUCH_ERROR "unknown error code"
+
+struct error_subsystem {
+ char * subsys_name;
+ int max_code;
+ char * * codes;
+};
+
+struct error_system {
+ int max_sub;
+ char * bad_sub;
+ struct error_subsystem * subsystem;
+};
+
+extern struct error_system errors[err_max_system+1];
+
+#define errlib_count(s) (sizeof(s)/sizeof(s[0]))
diff --git a/include/mach/exc.defs b/include/mach/exc.defs
new file mode 100644
index 0000000..94af828
--- /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 : 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..8198930
--- /dev/null
+++ b/include/mach/exec/elf.h
@@ -0,0 +1,298 @@
+/*
+ * 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;
+
+
+/* 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
+
+/* 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;
+
+/* 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;
+
+/* symbol type and binding attributes - page 4-26 */
+
+#define ELF32_ST_BIND(i) ((i) >> 4)
+#define ELF32_ST_TYPE(i) ((i) & 0xf)
+#define ELF32_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;
+
+/* 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
+
+/*
+ * 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/flick_mach3.h b/include/mach/flick_mach3.h
new file mode 100644
index 0000000..7d7675d
--- /dev/null
+++ b/include/mach/flick_mach3.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1995 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
+ */
+/*
+ * Glue for the Flick's Mach 3 backend. (Flick := Flexible IDL Compiler Kit.)
+ * This file is included from every header file generated by that backend.
+ * It provides standard MOM types and routines.
+ */
+#ifndef _MACH_FLICK_MACH3MIG_H_
+#define _MACH_FLICK_MACH3MIG_H_
+
+#include <mach/boolean.h>
+#include <mach/port.h>
+#include <mach/message.h>
+
+typedef char mom_char8_t;
+typedef unsigned8_t mom_unsigned8_t;
+typedef unsigned16_t mom_unsigned16_t;
+typedef unsigned32_t mom_unsigned32_t;
+typedef signed8_t mom_signed8_t;
+typedef signed16_t mom_signed16_t;
+typedef signed32_t mom_signed32_t;
+
+typedef int mom_key_t;
+
+struct mom_ref
+{
+ mom_refcount_t count;
+ mach_port_t port;
+
+ /* Chain on hash mom_ref hash table,
+ for canonicalization. */
+ struct mom_ref *hash_next;
+
+ /* Array of associations for this reference. */
+ int assoc_count;
+ void *assoc[0];
+};
+typedef struct mom_ref *mom_ref_t;
+
+struct mom_obj
+{
+ void *handle;
+
+ int port_count;
+ mach_port_t port[0];
+};
+typedef struct mom_obj *mom_obj_t;
+
+#define MOM__LABEL_BITS 8
+#define MOM__MAX_LABELS (1 << MOM__LABEL_BITS)
+
+#define mom_get_label_bits() MOM__LABEL_BITS
+
+
+#endif /* _MACH_FLICK_MACH3MIG_H_ */
diff --git a/include/mach/flick_mach3_glue.h b/include/mach/flick_mach3_glue.h
new file mode 100644
index 0000000..7deb620
--- /dev/null
+++ b/include/mach/flick_mach3_glue.h
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 1995 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
+ */
+/*
+ * Glue for the Flick's Mach 3 backend. (Flick := Flexible IDL Compiler Kit.)
+ * This file is included from every stub source code (.c) file generated by that backend.
+ * Stubs are built primarily out of invocations of these macros.
+ */
+#ifndef _MACH_FLICK_MACH3_GLUE_H_
+#define _MACH_FLICK_MACH3_GLUE_H_
+
+#include <stdlib.h>
+#include <string.h>
+#include <mach/flick_mach3.h>
+
+
+/*** Internal Flick data types ***/
+
+/* Each client stub allocates one of these on its stack first thing,
+ and holds all the important generic state throughout RPC processing. */
+struct flick_mach3_rpc_desc
+{
+ /* This is initially set to point to init_buf,
+ but is dynamically re-allocated if more space is needed. */
+ char *msg_buf;
+ vm_size_t msg_buf_size;
+
+ /* Before calling flick_mach3_rpc(),
+ the client stub sets this to the offset of the end of the data it marshaled.
+ It always starts marshaling at offset 4*4, to leave room for a mach_msg_header
+ (which is actually 6*4 bytes, but overwrites the 2*4-byte marshaled IDL ID). */
+ vm_size_t send_end_ofs;
+
+ /* flick_mach3_rpc() sets these to the offset of the data to unmarshal,
+ and the offset of the end of the data to unmarshal, respectively. */
+ vm_size_t rcv_ofs, rcv_end_ofs;
+
+ /* The size of this buffer varies from stub to stub. */
+ char init_buf[0];
+};
+
+/* Each server stub allocates one of these on its stack first thing,
+ and holds all the important generic state throughout RPC processing. */
+struct flick_mach3_rpc_serv_desc
+{
+ /* This is initially set to point to init_buf,
+ but is dynamically re-allocated if more space is needed. */
+ char *msg_buf;
+ vm_size_t msg_buf_size;
+
+ /* Before calling flick_mach3_rpc(),
+ the client stub sets this to the offset of the end of the data it marshaled.
+ It always starts marshaling at offset 4*4, to leave room for a mach_msg_header
+ (which is actually 6*4 bytes, but overwrites the 2*4-byte marshaled IDL ID). */
+ vm_size_t send_end_ofs;
+
+ /* flick_mach3_rpc() sets these to the offset of the data to unmarshal,
+ and the offset of the end of the data to unmarshal, respectively. */
+ vm_size_t rcv_ofs, rcv_end_ofs;
+
+ /* The size of this buffer varies from stub to stub. */
+ char init_buf[0];
+};
+
+
+/*** Encoding ***/
+
+#define flick_mach3_encode_new_glob(max_size) \
+{ \
+ while (_desc.d.send_end_ofs + (max_size) > _desc.d.msg_buf_size) \
+ { \
+ mach_msg_return_t result = flick_mach3_rpc_grow_buf(&_desc); \
+ /*XXX result */ \
+ } \
+ _e_chunk = _desc.d.msg_buf + _desc.d.send_end_ofs; \
+}
+#define flick_mach3_encode_end_glob(max_size) \
+ _desc.d.send_end_ofs += (max_size);
+
+#define flick_mach3_encode_new_chunk(size) /* do nothing */
+#define flick_mach3_encode_end_chunk(size) (_e_chunk += (size))
+
+#define flick_mach3_encode_prim(_ofs, _data, _name, _bits, _ctype) \
+{ \
+ struct { mach_msg_type_t _t; _ctype _v; } *_p = (void*)(_e_chunk + _ofs); \
+ mach_msg_type_t _tmpl = { _name, _bits, 1, 1, 0, 0 }; \
+ _p->_t = _tmpl; _p->_v = (_data); \
+}
+
+#define flick_mach3_encode_boolean(_ofs, _data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t);
+
+#define flick_mach3_encode_char8(_ofs, _data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_CHAR, 8, signed8_t);
+#define flick_mach3_encode_char16(_ofs, _data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t);
+
+#define flick_mach3_encode_signed8(_ofs, _data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t);
+#define flick_mach3_encode_unsigned8(ofs, data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t);
+#define flick_mach3_encode_signed16(_ofs, _data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t);
+#define flick_mach3_encode_unsigned16(ofs, data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t);
+#define flick_mach3_encode_signed32(_ofs, _data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t);
+#define flick_mach3_encode_unsigned32(ofs, data) \
+ flick_mach3_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t);
+
+#define flick_mach3_encode_port(_ofs, _data, _adjust) \
+{ \
+ if (_adjust > 1) { \
+ kern_return_t res = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, -(_adjust-1)); \
+ } \
+ flick_mach3_encode_prim(_ofs, _data, \
+ _adjust ? MACH_MSG_TYPE_MOVE_SEND : MACH_MSG_TYPE_COPY_SEND, \
+ 32, mach_port_t); \
+}
+
+
+/*** Decoding ***/
+
+#if TypeCheck
+#define flick_iftypecheck(code) code
+#else
+#define flick_iftypecheck(code)
+#endif
+
+#define flick_mach3_decode_new_glob(max_size)
+#define flick_mach3_decode_end_glob(max_size)
+
+#define flick_mach3_decode_new_chunk(size) \
+{ \
+ flick_iftypecheck( \
+ if (_desc.d.rcv_ofs + (size) > _d_msgsize) \
+ XXX throw MIG_TYPE_ERROR; \
+ ); \
+ _d_chunk = _desc.d.msg_buf + _desc.d.rcv_ofs; \
+}
+#define flick_mach3_decode_end_chunk(size) \
+ _desc.d.rcv_ofs += (size);
+
+#define flick_mach3_decode_prim(_ofs, _data, _name, _bits, _ctype) \
+{ \
+ struct { mach_msg_type_t _t; _ctype _v; } *_p = (void*)(_d_chunk + _ofs); \
+ flick_iftypecheck( ({ \
+ mach_msg_type_t _tmpl = { _name, _bits, 1, 1, 0, 0 }; \
+ if (*((signed32_t*)&_tmpl) != *((signed32_t)&_p->_t)) \
+ XXX throw MIG_TYPE_ERROR; \
+ )} ) \
+ (_data) = _p->_v; \
+}
+
+#define flick_mach3_decode_boolean(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t);
+
+#define flick_mach3_decode_char8(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_CHAR, 8, signed8_t);
+#define flick_mach3_decode_char16(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t);
+
+#define flick_mach3_decode_signed8(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t);
+#define flick_mach3_decode_unsigned8(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t);
+#define flick_mach3_decode_signed16(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t);
+#define flick_mach3_decode_unsigned16(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t);
+#define flick_mach3_decode_signed32(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t);
+#define flick_mach3_decode_unsigned32(_ofs, _data) \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t);
+
+#define flick_mach3_decode_port(_ofs, _data, _adjust) \
+{ \
+ flick_mach3_decode_prim(_ofs, _data, MACH_MSG_TYPE_PORT_SEND, 32, mach_port_t); \
+ if (_adjust != 1) { \
+ kern_return_t res = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, _adjust-1); \
+ } \
+}
+
+
+/*** Client-side support ***/
+
+mach_msg_return_t flick_mach3_rpc(struct flick_mach3_rpc_desc *rpc,
+ mach_port_t send_target, mach_msg_bits_t send_msgh_bits);
+
+#define flick_mach3_rpc_macro(iscomplex) \
+{ \
+ kern_return_t result = flick_mach3_rpc(&_desc.d, _msg_request/*XXX*/, \
+ (iscomplex ? MACH_MSGH_BITS_COMPLEX : 0) \
+ | MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE));\
+}
+
+#endif /* _MACH_FLICK_MACH3_GLUE_H_ */
diff --git a/include/mach/flick_mach3mig_glue.h b/include/mach/flick_mach3mig_glue.h
new file mode 100644
index 0000000..c1ed04a
--- /dev/null
+++ b/include/mach/flick_mach3mig_glue.h
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 1995 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
+ */
+/*
+ * Glue for the Flick's Mach 3 backend. (Flick := Flexible IDL Compiler Kit.)
+ * This file is included from every stub source code (.c) file generated by that backend.
+ * Stubs are built primarily out of invocations of these macros.
+ */
+#ifndef _MACH_FLICK_MACH3MIG_GLUE_H_
+#define _MACH_FLICK_MACH3MIG_GLUE_H_
+
+#include <stdlib.h>
+#include <string.h>
+#include <mach/mig_errors.h>
+#include <mach/flick_mach3mig.h>
+
+
+#define FLICK_NO_MEMORY 499 /*XXX*/
+
+
+/*** Internal Flick data types ***/
+
+/* Each client stub allocates one of these on its stack first thing,
+ and holds all the important generic state throughout RPC processing. */
+struct flick_mach3mig_rpc_desc
+{
+ /* This is initially set to point to init_buf,
+ but is dynamically re-allocated if more space is needed. */
+ mig_reply_header_t *msg_buf;
+ vm_size_t msg_buf_size;
+
+ /* Before calling flick_mach3mig_rpc(),
+ the client stub sets this to the offset of the end of the data it marshaled.
+ It always starts marshaling just after the Mach message header. */
+ vm_size_t send_end_ofs;
+
+ /* flick_mach3mig_rpc() sets these to the offset of the data to unmarshal,
+ and the offset of the end of the data to unmarshal, respectively. */
+ vm_size_t rcv_ofs, rcv_end_ofs;
+
+ /* The actual size of this buffer varies from stub to stub. */
+ mig_reply_header_t init_buf;
+};
+
+/* Each server stub allocates one of these on its stack first thing,
+ and holds all the important generic state throughout RPC processing. */
+struct flick_mach3mig_rpc_serv_desc
+{
+ /* During decoding msg_buf is InHeadP;
+ during encoding msg_buf is OutHeadP.
+ msg_buf_size is always simply a "very large" constant -
+ i.e. we don't know how big the buffer is; we just assume it's big enough. */
+ mig_reply_header_t *msg_buf;
+ vm_size_t msg_buf_size;
+
+ /* flick_mach3mig_serv_start_encode() sets these
+ to the offset of the data to unmarshal,
+ and the offset of the end of the data to unmarshal, respectively. */
+ vm_size_t rcv_ofs, rcv_end_ofs;
+
+ /* After the reply message has been encoded,
+ this contains the offset of the end of the data it marshaled. */
+ vm_size_t send_end_ofs;
+};
+
+
+
+/*** Memory allocation/deallocation ***/
+
+#define flick_alloc_mach_vm(size) \
+({ \
+ vm_address_t addr; \
+ if (_err = vm_allocate(mach_task_self(), &addr, (size), 1)) return _err; \
+ (void*)addr; \
+})
+#define flick_free_mach_vm(addr, size) \
+ if (_err = vm_deallocate(mach_task_self(), (addr), (size))) return _err;
+
+
+/*** Encoding ***/
+
+#define flick_mach3mig_encode_target(_data, _adjust) \
+{ \
+ if (_adjust > 1) { \
+ if (_err = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, -(_adjust-1))) return _err; \
+ } \
+ _desc.d.msg_buf->Head.msgh_remote_port = (_data); \
+ _desc.d.msg_buf->Head.msgh_bits = MACH_MSGH_BITS( \
+ _adjust ? MACH_MSG_TYPE_MOVE_SEND : MACH_MSG_TYPE_COPY_SEND, 0); \
+}
+
+/* Primitive types with individual type descriptors. */
+#define flick_mach3mig_encode_new_glob(max_size) \
+{ \
+ while (_desc.d.send_end_ofs + (max_size) > _desc.d.msg_buf_size) \
+ if (_err = flick_mach3mig_rpc_grow_buf(&_desc)) return _err; \
+ _e_chunk = (void*)_desc.d.msg_buf + _desc.d.send_end_ofs; \
+}
+#define flick_mach3mig_encode_end_glob(max_size) \
+ _desc.d.send_end_ofs += (max_size);
+
+#define flick_mach3mig_encode_new_chunk(size) /* do nothing */
+#define flick_mach3mig_encode_end_chunk(size) (_e_chunk += (size))
+
+#define flick_mach3mig_encode_prim(_ofs, _data, _name, _bits, _ctype) \
+{ \
+ struct { mach_msg_type_t _t; _ctype _v; } *_p = (void*)(_e_chunk + _ofs); \
+ mach_msg_type_t _tmpl = { _name, _bits, 1, 1, 0, 0 }; \
+ _p->_t = _tmpl; _p->_v = (_data); \
+}
+#define flick_mach3mig_encode_boolean(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t);
+#define flick_mach3mig_encode_char8(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_CHAR, 8, signed8_t);
+#define flick_mach3mig_encode_char16(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t);
+#define flick_mach3mig_encode_signed8(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t);
+#define flick_mach3mig_encode_unsigned8(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t);
+#define flick_mach3mig_encode_signed16(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t);
+#define flick_mach3mig_encode_unsigned16(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t);
+#define flick_mach3mig_encode_signed32(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t);
+#define flick_mach3mig_encode_unsigned32(_ofs, _data) \
+ flick_mach3mig_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t);
+#define flick_mach3mig_encode_port(_ofs, _data, _adjust) \
+{ \
+ if (_adjust > 1) { \
+ if (_err = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, -(_adjust-1))) return _err; \
+ } \
+ flick_mach3mig_encode_prim(_ofs, _data, \
+ _adjust ? MACH_MSG_TYPE_MOVE_SEND : MACH_MSG_TYPE_COPY_SEND, \
+ 32, mach_port_t); \
+}
+
+/* Array type descriptors. */
+#define flick_mach3mig_array_encode_type(_ofs, _name, _bits, _ctype, _num, _inl) \
+{ \
+ mach_msg_type_t *_p = (void*)(_e_chunk + _ofs); \
+ mach_msg_type_t _tmpl = { _name, _bits, _num, _inl, 0, 0 }; \
+ *_p = _tmpl; \
+}
+#define flick_mach3mig_array_encode_long_type(_ofs, _name, _bits, _ctype, _num, _inl) \
+{ \
+ mach_msg_type_long_t *_p = (void*)(_e_chunk + _ofs); \
+ mach_msg_type_long_t _tmpl = { { 0, 0, 0, _inl, 1, 0 }, _name, _bits, _num}; \
+ *_p = _tmpl; \
+}
+#define flick_mach3mig_array_encode_boolean_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t, _num, _inl);
+#define flick_mach3mig_array_encode_char8_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_CHAR, 8, signed8_t, _num, _inl);
+#define flick_mach3mig_array_encode_char16_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t, _num, _inl);
+#define flick_mach3mig_array_encode_signed8_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t, _num, _inl);
+#define flick_mach3mig_array_encode_unsigned8_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t, _num, _inl);
+#define flick_mach3mig_array_encode_signed16_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t, _num, _inl);
+#define flick_mach3mig_array_encode_unsigned16_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t, _num, _inl);
+#define flick_mach3mig_array_encode_signed32_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t, _num, _inl);
+#define flick_mach3mig_array_encode_unsigned32_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_encode##_long(_ofs, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t, _num, _inl);
+
+/* Array elements. */
+#define flick_mach3mig_array_encode_new_glob(max_size) flick_mach3mig_encode_new_glob(max_size)
+#define flick_mach3mig_array_encode_end_glob(max_size) flick_mach3mig_encode_end_glob(max_size)
+#define flick_mach3mig_array_encode_new_chunk(size) flick_mach3mig_encode_new_chunk(size)
+#define flick_mach3mig_array_encode_end_chunk(size) flick_mach3mig_encode_end_chunk(size)
+
+#define flick_mach3mig_array_encode_prim(_ofs, _data, _name, _bits, _ctype) \
+{ \
+ _ctype *_p = (void*)(_e_chunk + _ofs); \
+ *_p = (_data); \
+}
+#define flick_mach3mig_array_encode_boolean(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t);
+#define flick_mach3mig_array_encode_char8(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_CHAR, 8, signed8_t);
+#define flick_mach3mig_array_encode_char16(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t);
+#define flick_mach3mig_array_encode_signed8(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t);
+#define flick_mach3mig_array_encode_unsigned8(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t);
+#define flick_mach3mig_array_encode_signed16(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t);
+#define flick_mach3mig_array_encode_unsigned16(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t);
+#define flick_mach3mig_array_encode_signed32(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t);
+#define flick_mach3mig_array_encode_unsigned32(_ofs, _data) \
+ flick_mach3mig_array_encode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t);
+#define flick_mach3mig_array_encode_port(_ofs, _data, _adjust) \
+{ \
+ if (_adjust > 1) { \
+ if (_err = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, -(_adjust-1))) return _err; \
+ } \
+ flick_mach3mig_array_encode_prim(_ofs, _data, \
+ _adjust ? MACH_MSG_TYPE_MOVE_SEND : MACH_MSG_TYPE_COPY_SEND, \
+ 32, mach_port_t); \
+}
+
+/* Out-of-line buffer support. */
+#define flick_mach3mig_array_encode_ool_start(_ofs, _size) \
+{ \
+ vm_address_t *_p = (void*)(_e_chunk + _ofs); \
+ struct { struct { void *msg_buf; vm_size_t msg_buf_size, send_end_ofs; } d; } _desc; \
+ void *_e_chunk; \
+ \
+ _desc.d.msg_buf_size = (_size); \
+ if (_err = vm_allocate(mach_task_self(), _p, _desc.d.msg_buf_size, 1)) \
+ return _err; \
+ _desc.d.msg_buf = (void*)*_p; _desc.d.send_end_ofs = 0;
+
+#define flick_mach3mig_array_encode_ool_end() \
+}
+
+
+
+/*** Decoding ***/
+
+#if TypeCheck
+#define flick_iftypecheck(code) code
+#else
+#define flick_iftypecheck(code)
+#endif
+
+/* Primitive types with individual type descriptors. */
+#define flick_mach3mig_decode_new_glob(max_size)
+#define flick_mach3mig_decode_end_glob(max_size)
+
+#define flick_mach3mig_decode_new_chunk(size) \
+{ \
+ flick_iftypecheck( \
+ if (_desc.d.rcv_ofs + (size) > _desc.d.rcv_end_ofs) \
+ return MIG_TYPE_ERROR; \
+ ); \
+ _d_chunk = (void*)_desc.d.msg_buf + _desc.d.rcv_ofs; \
+}
+#define flick_mach3mig_decode_end_chunk(size) \
+ _desc.d.rcv_ofs += (size);
+
+#define flick_mach3mig_decode_prim(_ofs, _data, _name, _bits, _ctype) \
+{ \
+ struct { mach_msg_type_t _t; _ctype _v; } *_p = (void*)(_d_chunk + _ofs); \
+ flick_iftypecheck( ({ \
+ mach_msg_type_t _tmpl = { _name, _bits, 1, 1, 0, 0 }; \
+ if (*((signed32_t*)&_tmpl) != *((signed32_t*)&_p->_t)) \
+ return MIG_TYPE_ERROR; \
+ )} ) \
+ (_data) = _p->_v; \
+}
+#define flick_mach3mig_decode_boolean(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t);
+#define flick_mach3mig_decode_char8(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_CHAR, 8, signed8_t);
+#define flick_mach3mig_decode_char16(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t);
+#define flick_mach3mig_decode_signed8(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t);
+#define flick_mach3mig_decode_unsigned8(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t);
+#define flick_mach3mig_decode_signed16(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t);
+#define flick_mach3mig_decode_unsigned16(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t);
+#define flick_mach3mig_decode_signed32(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t);
+#define flick_mach3mig_decode_unsigned32(_ofs, _data) \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t);
+#define flick_mach3mig_decode_port(_ofs, _data, _adjust) \
+{ \
+ flick_mach3mig_decode_prim(_ofs, _data, MACH_MSG_TYPE_PORT_SEND, 32, mach_port_t); \
+ if (_adjust != 1) { \
+ if (_err = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, _adjust-1)) return _err; \
+ } \
+}
+
+/* Array type descriptors. */
+#define flick_mach3mig_array_decode_type(_ofs, _name, _bits, _ctype, _num, _inl) \
+{ \
+ mach_msg_type_t *_p = (void*)(_e_chunk + _ofs); \
+ flick_iftypecheck( ({ \
+ mach_msg_type_t _tmpl = { _name, _bits, _num, _inl, 0, 0 }; \
+ if (*((signed32_t*)&_tmpl) != *((signed32_t*)_p)) \
+ return MIG_TYPE_ERROR; \
+ )} ) \
+}
+#define flick_mach3mig_array_decode_long_type(_ofs, _name, _bits, _ctype, _num, _inl) \
+{ \
+ mach_msg_type_long_t *_p = (void*)(_e_chunk + _ofs); \
+ flick_iftypecheck( ({ \
+ mach_msg_type_long_t _tmpl = { { 0, 0, 0, _inl, 1, 0 }, _name, _bits, _num}; \
+ if (memcmp(&_tmpl, _p, sizeof(_tmpl))) \
+ return MIG_TYPE_ERROR; \
+ )} ) \
+}
+#define flick_mach3mig_array_decode_boolean_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t, _num, _inl);
+#define flick_mach3mig_array_decode_char8_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_CHAR, 8, signed8_t, _num, _inl);
+#define flick_mach3mig_array_decode_char16_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t, _num, _inl);
+#define flick_mach3mig_array_decode_signed8_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t, _num, _inl);
+#define flick_mach3mig_array_decode_unsigned8_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t, _num, _inl);
+#define flick_mach3mig_array_decode_signed16_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t, _num, _inl);
+#define flick_mach3mig_array_decode_unsigned16_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t, _num, _inl);
+#define flick_mach3mig_array_decode_signed32_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t, _num, _inl);
+#define flick_mach3mig_array_decode_unsigned32_type(_ofs, _num, _inl, _long) \
+ flick_mach3mig_array_decode##_long(_ofs, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t, _num, _inl);
+
+/* Array elements. */
+#define flick_mach3mig_array_decode_new_glob(max_size) flick_mach3mig_decode_new_glob(max_size)
+#define flick_mach3mig_array_decode_end_glob(max_size) flick_mach3mig_decode_end_glob(max_size)
+#define flick_mach3mig_array_decode_new_chunk(size) flick_mach3mig_decode_new_chunk(size)
+#define flick_mach3mig_array_decode_end_chunk(size) flick_mach3mig_decode_end_chunk(size)
+
+#define flick_mach3mig_array_decode_prim(_ofs, _data, _name, _bits, _ctype) \
+{ \
+ _ctype *_p = (void*)(_d_chunk + _ofs); \
+ (_data) = *_p; \
+}
+#define flick_mach3mig_array_decode_boolean(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_BOOLEAN, 32, signed32_t);
+#define flick_mach3mig_array_decode_char8(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_CHAR, 8, signed8_t);
+#define flick_mach3mig_array_decode_char16(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 8, signed16_t);
+#define flick_mach3mig_array_decode_signed8(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, signed8_t);
+#define flick_mach3mig_array_decode_unsigned8(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_8, 8, unsigned8_t);
+#define flick_mach3mig_array_decode_signed16(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, signed16_t);
+#define flick_mach3mig_array_decode_unsigned16(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_16, 16, unsigned16_t);
+#define flick_mach3mig_array_decode_signed32(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, signed32_t);
+#define flick_mach3mig_array_decode_unsigned32(_ofs, _data) \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_INTEGER_32, 32, unsigned32_t);
+#define flick_mach3mig_array_decode_port(_ofs, _data, _adjust) \
+{ \
+ flick_mach3mig_array_decode_prim(_ofs, _data, MACH_MSG_TYPE_PORT_SEND, 32, mach_port_t); \
+ if (_adjust != 1) { \
+ kern_return_t res = mach_port_mod_refs(mach_task_self(), (_data), \
+ MACH_PORT_RIGHT_SEND, _adjust-1); \
+ } \
+}
+
+/* Out-of-line buffer support. */
+#define flick_mach3mig_array_decode_ool_start(_ofs, _size) \
+{ \
+ vm_address_t *_p = (void*)(_e_chunk + _ofs); \
+ struct { struct { void *msg_buf; vm_size_t rcv_ofs, rcv_end_ofs; } d; } _desc; \
+ void *_e_chunk; \
+ \
+ _desc.d.msg_buf = (void*)*_p; _desc.d.rcv_ofs = 0; _desc.d.rcv_end_ofs = (_size);\
+
+#define flick_mach3mig_array_decode_ool_end() \
+ if (_err = vm_deallocate(mach_task_self(), *_p, _desc.d.rcv_end_ofs)) \
+ return _err; \
+}
+
+
+/*** Client-side support ***/
+
+mach_msg_return_t flick_mach3mig_rpc(struct flick_mach3mig_rpc_desc *rpc);
+
+#define flick_mach3mig_rpc_macro(iscomplex) \
+{ \
+ _desc.d.msg_buf->Head.msgh_bits |= \
+ MACH_MSGH_BITS(0, MACH_MSG_TYPE_MAKE_SEND_ONCE) \
+ | (iscomplex ? MACH_MSGH_BITS_COMPLEX : 0); \
+ if (_err = flick_mach3mig_rpc(&_desc.d)) return _err; \
+}
+
+#define flick_mach3mig_send_macro(iscomplex) \
+{ \
+ _desc.d.msg_buf->Head.msgh_bits |= (iscomplex ? MACH_MSGH_BITS_COMPLEX : 0); \
+ if (_err = flick_mach3mig_rpc(&_desc.d)) return _err; \
+}
+
+
+/*** Server-side support ***/
+
+#define flick_mach3mig_serv_start_decode() \
+{ \
+ _desc.d.msg_buf = (mig_reply_header_t*)InHeadP; \
+ _desc.d.msg_buf_size = 0x7fffffff; \
+ _desc.d.rcv_ofs = sizeof(mach_msg_header_t); \
+ _desc.d.rcv_end_ofs = InHeadP->msgh_size; \
+}
+
+#define flick_mach3mig_serv_end_decode() /* do nothing */
+
+#define flick_mach3mig_serv_start_encode() \
+{ \
+ _desc.d.msg_buf = (mig_reply_header_t*)OutHeadP; \
+ _desc.d.send_end_ofs = sizeof(mig_reply_header_t); \
+}
+
+#define flick_mach3mig_serv_end_encode() \
+{ \
+ mach_msg_type_t _ret_tmpl = { MACH_MSG_TYPE_INTEGER_32, 32, 1, 1, 0, 0 }; \
+ OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0); \
+ OutHeadP->msgh_size = _desc.d.send_end_ofs; \
+ OutHeadP->msgh_remote_port = InHeadP->msgh_remote_port; \
+ OutHeadP->msgh_local_port = MACH_PORT_NULL; \
+ _desc.d.msg_buf->RetCodeType = _ret_tmpl; \
+ _desc.d.msg_buf->RetCode = _return; \
+}
+
+
+#endif /* _MACH_FLICK_MACH3MIG_GLUE_H_ */
diff --git a/include/mach/host_info.h b/include/mach/host_info.h
new file mode 100644
index 0000000..60a6aef
--- /dev/null
+++ b/include/mach/host_info.h
@@ -0,0 +1,93 @@
+/*
+ * 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];
+
+#define KERNEL_BOOT_INFO_MAX (4096)
+typedef char kernel_boot_info_t[KERNEL_BOOT_INFO_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 */
+ 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..2274328
--- /dev/null
+++ b/include/mach/kern_return.h
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+
+#endif /* _MACH_KERN_RETURN_H_ */
diff --git a/include/mach/lmm.h b/include/mach/lmm.h
new file mode 100644
index 0000000..f350329
--- /dev/null
+++ b/include/mach/lmm.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 1995 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
+ */
+/*
+ * Public header file for the List Memory Manager.
+ */
+#ifndef _MACH_LMM_H_
+#define _MACH_LMM_H_
+
+#include <mach/machine/vm_types.h>
+
+/* The contents of this structure is opaque to users. */
+typedef struct lmm
+{
+ struct lmm_region *regions;
+} lmm_t;
+
+#define LMM_INITIALIZER { 0 }
+
+typedef natural_t lmm_flags_t;
+typedef integer_t lmm_pri_t;
+
+void lmm_init(lmm_t *lmm);
+void lmm_add(lmm_t *lmm, vm_offset_t addr, vm_size_t size,
+ lmm_flags_t flags, lmm_pri_t pri);
+void *lmm_alloc(lmm_t *lmm, vm_size_t size, lmm_flags_t flags);
+void *lmm_alloc_aligned(lmm_t *lmm, vm_size_t size, lmm_flags_t flags,
+ int align_bits, vm_offset_t align_ofs);
+void *lmm_alloc_page(lmm_t *lmm, lmm_flags_t flags);
+void *lmm_alloc_gen(lmm_t *lmm, vm_size_t size, lmm_flags_t flags,
+ int align_bits, vm_offset_t align_ofs,
+ vm_offset_t bounds_min, vm_offset_t bounds_max);
+vm_size_t lmm_avail(lmm_t *lmm, lmm_flags_t flags);
+void lmm_find_free(lmm_t *lmm, vm_offset_t *inout_addr,
+ vm_size_t *out_size, lmm_flags_t *out_flags);
+void lmm_free(lmm_t *lmm, void *block, vm_size_t size);
+
+/* Only available if debugging turned on. */
+void lmm_dump(lmm_t *lmm);
+
+#endif /* _MACH_LMM_H_ */
diff --git a/include/mach/mach.defs b/include/mach/mach.defs
new file mode 100644
index 0000000..1e4429d
--- /dev/null
+++ b/include/mach/mach.defs
@@ -0,0 +1,958 @@
+/*
+ * 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.
+ */
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+
+simport <kern/compat_xxx_defs.h>; /* for obsolete routines */
+#endif /* MACH_KERNEL */
+
+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>
+
+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 */
+
+/*
+ * 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 */
+
+/*
+ * Provide the data contents of a range of the given memory
+ * object, with the access restriction specified. [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.]
+ */
+simpleroutine memory_object_data_provided(
+ memory_control : memory_object_control_t;
+ offset : vm_offset_t;
+ data : pointer_t;
+ lock_value : vm_prot_t);
+
+/*
+ * 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);
+
+/*
+ * 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);
+
+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.
+ */
+simpleroutine xxx_memory_object_lock_request(
+ memory_control : memory_object_control_t;
+ offset : vm_offset_t;
+ size : vm_size_t;
+ should_clean : boolean_t;
+ should_flush : boolean_t;
+ lock_value : vm_prot_t;
+ reply_to : mach_port_t =
+ MACH_MSG_TYPE_MAKE_SEND_ONCE|polymorphic);
+
+
+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);
+
+/* obsolete */
+routine xxx_task_get_emulation_vector(
+ task : task_t;
+ out vector_start : int;
+ out emulation_vector: xxx_emulation_vector_t, IsLong);
+
+/* obsolete */
+routine xxx_task_set_emulation_vector(
+ task : task_t;
+ vector_start : int;
+ emulation_vector: xxx_emulation_vector_t, IsLong);
+
+/*
+ * Returns information about the host on which the
+ * target object resides. [This object may be
+ * a task, thread, or memory_object_control port.]
+ */
+routine xxx_host_info(
+ target_task : mach_port_t;
+ out info : machine_info_data_t);
+
+/*
+ * Returns information about a particular processor on
+ * the host on which the target task resides.
+ */
+routine xxx_slot_info(
+ target_task : task_t;
+ slot : int;
+ out info : machine_slot_data_t);
+
+/*
+ * Performs control operations (currently only
+ * turning off or on) on a particular processor on
+ * the host on which the target task resides.
+ */
+routine xxx_cpu_control(
+ target_task : task_t;
+ cpu : int;
+ running : boolean_t);
+
+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 */
+
+/*
+ * 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);
+
+/* obsolete */
+routine xxx_task_info(
+ target_task : task_t;
+ flavor : int;
+ out task_info_out : task_info_t, IsLong);
+
+
+/*
+ * 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);
+
+/* obsolete */
+routine xxx_thread_get_state(
+ target_thread : thread_t;
+ flavor : int;
+ out old_state : thread_state_t, IsLong);
+
+/* obsolete */
+routine xxx_thread_set_state(
+ target_thread : thread_t;
+ flavor : int;
+ new_state : thread_state_t, IsLong);
+
+/*
+ * 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);
+
+/* obsolete */
+routine xxx_thread_info(
+ target_thread : thread_t;
+ flavor : int;
+ out thread_info_out : thread_info_t, IsLong);
+
+/*
+ * 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 */
+
+
+#if MACH_IPC_COMPAT
+
+/*
+ * 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 port_names(
+ task : ipc_space_t;
+ out port_names_p : port_name_array_t;
+ out port_types : port_type_array_t);
+
+/*
+ * Returns the type (set or port) for the port name
+ * within the target task.
+ */
+routine port_type(
+ task : ipc_space_t;
+ port_name : port_name_t;
+ out port_type_p : port_type_t);
+
+/*
+ * Changes the name by which a port (or port set) is known to
+ * the target task.
+ */
+routine port_rename(
+ task : ipc_space_t;
+ old_name : port_name_t;
+ new_name : port_name_t);
+
+/*
+ * Allocate a new port (with all rights) in the target task.
+ * The port name in that task is returned.
+ */
+routine port_allocate(
+ task : ipc_space_t;
+ out port_name : port_name_t);
+
+/*
+ * Deallocate the port with the given name from the target task.
+ */
+routine port_deallocate(
+ task : ipc_space_t;
+ port_name : port_name_t);
+
+/*
+ * Set the number of messages that may be queued to
+ * the port in the target task with the given name
+ * before further message queueing operations block.
+ * The target task must hold receive rights for the
+ * port named.
+ */
+routine port_set_backlog(
+ task : ipc_space_t;
+ port_name : port_name_t;
+ backlog : int);
+
+/*
+ * Return information about the port with the given
+ * name in the target task. Only the ownership and
+ * receive_rights results are meaningful unless the
+ * target task holds receive rights for the port.
+ */
+routine port_status(
+ task : ipc_space_t;
+ port_name : port_name_t;
+ out enabled : port_set_name_t;
+ out num_msgs : int;
+ out backlog : int;
+ out ownership : boolean_t;
+ out receive_rights : boolean_t);
+
+/*
+ * Allocate a new port set in the target task, returning
+ * the name of that new port set. [The new set is
+ * initially empty.]
+ */
+routine port_set_allocate(
+ task : ipc_space_t;
+ out set_name : port_set_name_t);
+
+/*
+ * Deallocate the named port set from the target task.
+ * Ports that are currently members of the named port
+ * set are first removed from the set.
+ */
+routine port_set_deallocate(
+ task : ipc_space_t;
+ set_name : port_set_name_t);
+
+/*
+ * Add the named port to the port set named within
+ * the target task. [If the port currently is a member
+ * of another port set, it is removed from that set.]
+ */
+routine port_set_add(
+ task : ipc_space_t;
+ set_name : port_set_name_t;
+ port_name : port_name_t);
+
+/*
+ * Remove the named port from the port set named within
+ * the target task.
+ */
+routine port_set_remove(
+ task : ipc_space_t;
+ port_name : port_name_t);
+
+/*
+ * Returns the current set of ports that are members
+ * of the named port set in the target task.
+ */
+routine port_set_status(
+ task : ipc_space_t;
+ set_name : port_set_name_t;
+ out members : port_name_array_t);
+
+/*
+ * Insert send rights for the specified port into
+ * the target task with the specified port name.
+ * [If the name is in use, or the target task already
+ * has another name for the specified port, then
+ * the operation will fail.]
+ */
+routine port_insert_send(
+ task : ipc_space_t;
+ my_port : port_t;
+ his_name : port_name_t);
+
+/*
+ * Returns send rights for the named port in the
+ * target task, removing that port name and port
+ * send rights from the target task. [If the
+ * target task holds receive rights for this port,
+ * the operation will fail.]
+ */
+routine port_extract_send(
+ task : ipc_space_t;
+ his_name : port_name_t;
+ out his_port : port_t);
+
+/*
+ * Insert receive rights for the specified port into
+ * the target task with the specified port name.
+ * [If the name is in use, or the target task already
+ * has another name for the specified port, then
+ * the operation will fail.
+ */
+routine port_insert_receive(
+ task : ipc_space_t;
+ my_port : port_all_t;
+ his_name : port_name_t);
+
+/*
+ * Returns receive rights for the named port in the
+ * target task, removing that port name and all port
+ * rights from the target task.
+ */
+routine port_extract_receive(
+ task : ipc_space_t;
+ his_name : port_name_t;
+ out his_port : port_all_t);
+
+#else MACH_IPC_COMPAT
+
+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 */
+
+#endif MACH_IPC_COMPAT
+
+/*
+ * 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
+
+/*
+ * 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);
+
+/*
+ * Make decisions regarding the use of the specified
+ * memory object.
+ */
+simpleroutine memory_object_set_attributes(
+ memory_control : memory_object_control_t;
+ object_ready : boolean_t;
+ may_cache : boolean_t;
+ copy_strategy : memory_object_copy_strategy_t);
+
+/*
+ */
+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);
+
+skip; /* old host_callout_statistics_reset */
+skip; /* old port_set_select */
+
+#if MACH_IPC_COMPAT
+
+/*
+ * Sets a backup port for the named port. The task
+ * must have receive rights for the named port.
+ * Returns the previous backup port, if any.
+ */
+
+routine port_set_backup(
+ task : ipc_space_t;
+ port_name : port_name_t;
+ backup : port_t = MACH_MSG_TYPE_MAKE_SEND
+ ctype: mach_port_t;
+ out previous : port_t);
+
+#else MACH_IPC_COMPAT
+
+skip; /* old port_set_backup */
+
+#endif MACH_IPC_COMPAT
+
+/*
+ * 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 */
+
+/*
+ * 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..e4f363f
--- /dev/null
+++ b/include/mach/mach4.defs
@@ -0,0 +1,82 @@
+/*
+ * 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_t = struct[3] of natural_t;
+type sampled_pc_array_t = array[*:512] of sampled_pc_t;
+type sampled_pc_seqno_t = unsigned;
+type sampled_pc_flavor_t = natural_t;
+
+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*/;
+#endif
diff --git a/include/mach/mach_host.defs b/include/mach/mach_host.defs
new file mode 100644
index 0000000..85ee4dc
--- /dev/null
+++ b/include/mach/mach_host.defs
@@ -0,0 +1,379 @@
+/*
+ * 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.
+ */
+
+#ifdef MACH_KERNEL
+simport <kern/compat_xxx_defs.h>; /* for obsolete routines */
+#endif
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif
+ mach_host 2600;
+
+/*
+ * Basic types
+ */
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+/*
+ * Get list of processors on this host.
+ */
+
+routine host_processors(
+ host_priv : host_priv_t;
+ out processor_list : processor_array_t);
+
+/* obsolete */
+routine yyy_host_info(
+ host : host_t;
+ flavor : int;
+ out host_info_out : host_info_t, IsLong);
+
+
+/* obsolete */
+routine yyy_processor_info(
+ processor : processor_t;
+ flavor : int;
+ out host : host_t;
+ out processor_info_out: processor_info_t, IsLong);
+
+/*
+ * Start processor.
+ */
+
+routine processor_start(
+ processor : processor_t);
+
+/*
+ * Exit processor -- may not be restartable.
+ */
+
+routine processor_exit(
+ processor : processor_t);
+
+/* obsolete */
+routine yyy_processor_control(
+ processor : processor_t;
+ processor_cmd : processor_info_t, IsLong);
+
+/*
+ * Get default processor set for host.
+ */
+routine processor_set_default(
+ host : host_t;
+ out default_set : processor_set_name_t);
+
+/*
+ * Get rights to default processor set for host.
+ * Replaced by host_processor_set_priv.
+ */
+routine xxx_processor_set_default_priv(
+ host : host_priv_t;
+ out default_set : processor_set_t);
+
+/*
+ * 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);
+
+/* obsolete */
+routine yyy_processor_set_info(
+ set_name : processor_set_name_t;
+ flavor : int;
+ out host : host_t;
+ out info_out : processor_set_info_t, IsLong);
+
+/*
+ * 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);
+
+/*
+ * Get string describing current kernel version.
+ */
+routine host_kernel_version(
+ host : host_t;
+ out kernel_version : kernel_version_t);
+
+/*
+ * 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_priv : host_priv_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);
+
+/*
+ * Get boot configuration information from kernel.
+ */
+routine host_get_boot_info(
+ host_priv : host_priv_t;
+ out boot_info : kernel_boot_info_t);
diff --git a/include/mach/mach_norma.defs b/include/mach/mach_norma.defs
new file mode 100644
index 0000000..01b3872
--- /dev/null
+++ b/include/mach/mach_norma.defs
@@ -0,0 +1,120 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991 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
+#if KERNEL_USER
+ KernelUser
+#endif
+#if KERNEL_SERVER
+ KernelServer
+#endif
+ mach_norma 555000;
+#ifdef KERNEL_USER
+userprefix r_;
+#endif
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+skip;
+
+/*
+ * Specify a node upon which children tasks will be created.
+ * This call exists only to allow testing with unmodified servers.
+ * Server developers should use norma_task_create instead.
+ */
+routine task_set_child_node(
+ target_task : task_t;
+ child_node : int);
+
+/*
+ * THIS CALL WILL BE ELIMINATED.
+ * Use norma_port_location_hint(,mach_task_self(),) instead.
+ */
+routine norma_node_self(
+ host : host_t;
+ out node : int);
+
+skip;
+
+skip;
+
+skip;
+
+/*
+ * (Used to be called task_create_remote.)
+ * Create a task on the given node, possibly inheriting memory.
+ * Same inheritance semantics as task_create, including inheritance
+ * of initial ports and emulation library.
+ * Setting child_node to node_self forces local task creation.
+ */
+routine norma_task_create(
+ target_task : task_t;
+ inherit_memory : boolean_t;
+ child_node : int;
+ out child_task : task_t);
+
+/*
+ * Get a given special port for a given node.
+ * Norma special ports are defined in norma_special_ports.h;
+ * examples include the master device port.
+ * There are a limited number of slots available for system servers.
+ *
+ * XXX MAX_SPECIAL_ID should be defined in norma_special_ports.h,
+ * XXX not just in norma/ipc_special.c!
+ * (MAX_SPECIAL_ID specifies total number of slots available)
+ */
+routine norma_get_special_port(
+ host_priv : host_priv_t;
+ node : int;
+ which : int;
+ out port : mach_port_t);
+
+/*
+ * Set a given special port for a given node.
+ * See norma_get_special_port.
+ */
+routine norma_set_special_port(
+ host_priv : host_priv_t;
+ which : int;
+ port : mach_port_t);
+
+skip;
+
+skip;
+
+skip;
+
+/*
+ * Return best guess of port's current location.
+ * Guaranteed to be a node where the port once was.
+ * Guaranteed to be accurate if port has never moved.
+ * Can be used to determine residence node for hosts, tasks, threads, etc.
+ */
+routine norma_port_location_hint(
+ task : task_t;
+ port : mach_port_t;
+ out node : int);
diff --git a/include/mach/mach_param.h b/include/mach/mach_param.h
new file mode 100644
index 0000000..ce02ed8
--- /dev/null
+++ b/include/mach/mach_param.h
@@ -0,0 +1,53 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#define TASK_PORT_REGISTER_MAX 4 /* Number of "registered" ports */
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+#define PORT_BACKLOG_DEFAULT 5
+#define PORT_BACKLOG_MAX 16
+
+#endif /* MACH_IPC_COMPAT */
+
+#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..e1f45e3
--- /dev/null
+++ b/include/mach/mach_port.defs
@@ -0,0 +1,346 @@
+/*
+ * 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
+ ctype: mach_port_array_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);
+
+/*
+ * Temporary compatibility call.
+ */
+
+routine old_mach_port_get_receive_status(
+ task : ipc_space_t;
+ name : mach_port_name_t;
+ out status : old_mach_port_status_t);
+
+/*
+ * 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
+ ctype: mach_port_array_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);
+
+#endif /* MIGRATING_THREADS */
+
diff --git a/include/mach/mach_traps.h b/include/mach/mach_traps.h
new file mode 100644
index 0000000..3303e32
--- /dev/null
+++ b/include/mach/mach_traps.h
@@ -0,0 +1,132 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#include <mach/port.h>
+
+mach_port_t mach_reply_port
+#ifdef LINTLIBRARY
+ ()
+ { return MACH_PORT_NULL; }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+mach_port_t mach_thread_self
+#ifdef LINTLIBRARY
+ ()
+ { return MACH_PORT_NULL; }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+#ifdef __386BSD__
+#undef mach_task_self
+#endif
+mach_port_t mach_task_self
+#ifdef LINTLIBRARY
+ ()
+ { return MACH_PORT_NULL; }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+mach_port_t mach_host_self
+#ifdef LINTLIBRARY
+ ()
+ { return MACH_PORT_NULL; }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+port_t task_self
+#ifdef LINTLIBRARY
+ ()
+ { return(PORT_NULL); }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+port_t task_notify
+#ifdef LINTLIBRARY
+ ()
+ { return(PORT_NULL); }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+port_t thread_self
+#ifdef LINTLIBRARY
+ ()
+ { return(PORT_NULL); }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+port_t thread_reply
+#ifdef LINTLIBRARY
+ ()
+ { return(PORT_NULL); }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+port_t host_self
+#ifdef LINTLIBRARY
+ ()
+ { return(PORT_NULL); }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+port_t host_priv_self
+#ifdef LINTLIBRARY
+ ()
+ { return(PORT_NULL); }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+
+#endif /* MACH_IPC_COMPAT */
+
+#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..6952272
--- /dev/null
+++ b/include/mach/mach_types.defs
@@ -0,0 +1,249 @@
+/*
+ * 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
+#include <norma_vm.h>
+#endif /* KERNEL_SERVER */
+
+type mach_port_status_t = struct[9] of integer_t;
+
+type old_mach_port_status_t = struct[8] of integer_t; /* compatibility */
+
+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 */
+ ;
+
+type vm_address_t = natural_t;
+type vm_offset_t = natural_t;
+type vm_size_t = natural_t;
+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 thread_info_t = array[*:1024] of natural_t;
+type thread_basic_info_data_t = struct[11] of integer_t;
+type thread_sched_info_data_t = struct[7] of integer_t;
+
+type task_info_t = array[*:1024] of natural_t;
+type task_basic_info_data_t = struct[8] of integer_t;
+type task_events_info = struct[7] of natural_t;
+type task_thread_times_info_data_t = struct[4] 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)
+#endif /* KERNEL_SERVER */
+ ;
+
+type memory_object_control_t = mach_port_t
+ ctype: mach_port_t
+#if KERNEL_SERVER
+#if NORMA_VM
+ intran: mach_xmm_obj_t xmm_kobj_lookup(mach_port_t)
+#else /* NORMA_VM */
+ intran: vm_object_t vm_object_lookup(mach_port_t)
+#endif /* NORMA_VM */
+#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 machine_info_data_t = struct[5] of integer_t;
+type machine_slot_data_t = struct[8] of integer_t;
+
+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 natural_t;
+type host_basic_info_data_t = struct[5] of integer_t;
+type host_sched_info_data_t = struct[2] of integer_t;
+type host_load_info_data_t = struct[6] 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 natural_t;
+type processor_basic_info_data_t = struct[5] 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 natural_t;
+type processor_set_basic_info_data_t = struct[5] of integer_t;
+type processor_set_sched_info_data_t = struct[2] of integer_t;
+
+
+type kernel_version_t = (MACH_MSG_TYPE_STRING, 512*8);
+
+type kernel_boot_info_t = (MACH_MSG_TYPE_STRING, 4096*8);
+
+type time_value_t = struct[2] of integer_t;
+
+type emulation_vector_t = ^array[] of vm_offset_t;
+
+type xxx_emulation_vector_t = array[*:1024] of vm_offset_t
+ ctype: emulation_vector_t;
+ /* XXX compatibility */
+
+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..1fa3292
--- /dev/null
+++ b/include/mach/mach_types.h
@@ -0,0 +1,93 @@
+/*
+ * 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>
+
+#ifdef MACH_KERNEL
+#include <kern/task.h> /* for task_array_t */
+#include <kern/thread.h> /* for thread_array_t */
+#include <kern/processor.h> /* for processor_array_t,
+ processor_set_array_t,
+ processor_set_name_array_t */
+#include <kern/syscall_emulation.h>
+ /* for emulation_vector_t */
+#include <norma_vm.h>
+#if NORMA_VM
+typedef struct xmm_obj *mach_xmm_obj_t;
+extern mach_xmm_obj_t xmm_kobj_lookup();
+#endif /* NORMA_VM */
+#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..a6100a2
--- /dev/null
+++ b/include/mach/machine.h
@@ -0,0 +1,267 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <cpus.h>
+#endif /* MACH_KERNEL */
+
+#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)
+
+/*
+ * 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..e64be87
--- /dev/null
+++ b/include/mach/memory_object.defs
@@ -0,0 +1,313 @@
+/*
+ * 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;
+
+#ifdef KERNEL
+#include <norma_vm.h>
+#if NORMA_VM
+userprefix k_;
+#endif NORMA_VM
+#endif KERNEL
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#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_set_attributes,
+ * specifying the "ready" parameter as TRUE. 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_set_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;
+#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_set_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_provided.]
+ */
+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);
+
+/*
+ * Write back modifications made to this portion of
+ * the memory object while in memory.
+ *
+ * Unless explicitly requested by a memory_object_lock_request
+ * (clean, but not flush), the kernel will not retain
+ * the data.
+ *
+ * [Reply should be vm_deallocate to release the data.]
+ */
+simpleroutine memory_object_data_write(
+ 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);
+
+/*
+ * Indicate that a previous memory_object_lock_reqeust 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;
+#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;
+#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 is used in place of data_write
+ * for objects initialized by object_ready instead of set_attributes.
+ * 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;
+#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..b4dd71f
--- /dev/null
+++ b/include/mach/memory_object.h
@@ -0,0 +1,83 @@
+/*
+ * 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>
+
+typedef mach_port_t memory_object_t;
+ /* Represents a memory object ... */
+ /* Used by user programs to specify */
+ /* the object to map; used by the */
+ /* kernel to retrieve or store data */
+
+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..eb2aea7
--- /dev/null
+++ b/include/mach/memory_object_default.defs
@@ -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.
+ */
+/*
+ * 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;
+
+#ifdef MACH_KERNEL
+#include <norma_vm.h>
+#if NORMA_VM
+userprefix k_;
+#endif NORMA_VM
+#endif MACH_KERNEL
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+#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_write.
+ */
+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_write 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..8f1860f
--- /dev/null
+++ b/include/mach/message.h
@@ -0,0 +1,750 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#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;
+
+typedef struct {
+ mach_msg_bits_t msgh_bits;
+ mach_msg_size_t msgh_size;
+ mach_port_t msgh_remote_port;
+ mach_port_t msgh_local_port;
+ mach_port_seqno_t msgh_seqno;
+ mach_msg_id_t msgh_id;
+} mach_msg_header_t;
+
+/*
+ * 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;
+
+typedef struct {
+ unsigned int msgt_name : 8,
+ msgt_size : 8,
+ msgt_number : 12,
+ msgt_inline : 1,
+ msgt_longform : 1,
+ msgt_deallocate : 1,
+ msgt_unused : 1;
+} mach_msg_type_t;
+
+typedef struct {
+ mach_msg_type_t msgtl_header;
+ unsigned short msgtl_name;
+ unsigned short msgtl_size;
+ natural_t msgtl_number;
+} mach_msg_type_long_t;
+
+
+/*
+ * 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_LAST 22 /* 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 */
+
+
+/*
+ * 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
+#if defined(c_plusplus) || defined(__STDC__)
+ (mach_msg_header_t *msg,
+ mach_msg_option_t option,
+ mach_msg_size_t send_size,
+ mach_msg_size_t rcv_size,
+ mach_port_t rcv_name,
+ mach_msg_timeout_t timeout,
+ mach_port_t notify);
+#else /* c_plusplus || __STDC__ */
+#ifdef LINTLIBRARY
+ (msg, option, send_size, rcv_size, rcv_name, timeout, notify)
+ mach_msg_header_t *msg;
+ mach_msg_option_t option;
+ mach_msg_size_t send_size;
+ mach_msg_size_t rcv_size
+ mach_port_t rcv_name;
+ mach_msg_timeout_t timeout;
+ mach_port_t notify;
+{ return MACH_RCV_SUCCESS; }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+extern mach_msg_return_t
+mach_msg
+#if defined(c_plusplus) || defined(__STDC__)
+ (mach_msg_header_t *msg,
+ mach_msg_option_t option,
+ mach_msg_size_t send_size,
+ mach_msg_size_t rcv_size,
+ mach_port_t rcv_name,
+ mach_msg_timeout_t timeout,
+ mach_port_t notify);
+#else /* c_plusplus || __STDC__ */
+#ifdef LINTLIBRARY
+ (msg, option, send_size, rcv_size, rcv_name, timeout, notify)
+ mach_msg_header_t *msg;
+ mach_msg_option_t option;
+ mach_msg_size_t send_size;
+ mach_msg_size_t rcv_size
+ mach_port_t rcv_name;
+ mach_msg_timeout_t timeout;
+ mach_port_t notify;
+{ return MACH_RCV_SUCCESS; }
+#else /* LINTLIBRARY */
+ ();
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+/*
+ * Message data structures.
+ *
+ * Messages consist of two parts: a fixed-size header, immediately
+ * followed by a variable-size array of typed data items.
+ *
+ */
+
+typedef unsigned int msg_size_t;
+
+typedef struct {
+ unsigned int msg_unused : 24,
+ msg_simple : 8;
+ msg_size_t msg_size;
+ integer_t msg_type;
+ port_t msg_local_port;
+ port_t msg_remote_port;
+ integer_t msg_id;
+} msg_header_t;
+
+#define MSG_SIZE_MAX 8192
+
+/*
+ * Known values for the msg_type field.
+ * These are Accent holdovers, which should be purged when possible.
+ *
+ * Only one bit in the msg_type field is used by the kernel.
+ * Others are available to user applications. See <msg_type.h>
+ * for system application-assigned values.
+ */
+
+#define MSG_TYPE_NORMAL 0
+#define MSG_TYPE_EMERGENCY 1
+
+/*
+ * Each data item is preceded by a description of that
+ * item, including what type of data, how big it is, and
+ * how many of them are present.
+ *
+ * The actual data will either follow this type
+ * descriptor ("inline") or will be specified by a pointer.
+ *
+ * If the type name, size, or number is too large to be encoded
+ * in this structure, the "longform" option may be selected,
+ * and those fields must immediately follow in full integer fields.
+ *
+ * For convenience, out-of-line data regions or port rights may
+ * be deallocated when the message is sent by specifying the
+ * "deallocate" field. Beware: if the data item in question is both
+ * out-of-line and contains port rights, then both will be deallocated.
+ */
+
+typedef struct {
+ unsigned int msg_type_name : 8, /* What kind of data */
+ msg_type_size : 8, /* How many bits is each item */
+ msg_type_number : 12, /* How many items are there */
+ msg_type_inline : 1, /* If true, data follows; else a pointer */
+ msg_type_longform : 1, /* Name, size, number follow: see above */
+ msg_type_deallocate : 1, /* Deallocate port rights or memory */
+ msg_type_unused : 1;
+} msg_type_t;
+
+typedef struct {
+ msg_type_t msg_type_header;
+ unsigned short msg_type_long_name;
+ unsigned short msg_type_long_size;
+ natural_t msg_type_long_number;
+} msg_type_long_t;
+
+/*
+ * Known values for the msg_type_name field.
+ *
+ * The only types known to the Mach kernel are
+ * the port types, and those types used in the
+ * kernel RPC interface.
+ */
+
+#define MSG_TYPE_UNSTRUCTURED 0
+#define MSG_TYPE_BIT 0
+#define MSG_TYPE_BOOLEAN 0
+#define MSG_TYPE_INTEGER_16 1
+#define MSG_TYPE_INTEGER_32 2
+#define MSG_TYPE_PORT_OWNERSHIP 3 /* obsolete */
+#define MSG_TYPE_PORT_RECEIVE 4 /* obsolete */
+#define MSG_TYPE_PORT_ALL 5
+#define MSG_TYPE_PORT 6
+#define MSG_TYPE_CHAR 8
+#define MSG_TYPE_BYTE 9
+#define MSG_TYPE_INTEGER_8 9
+#define MSG_TYPE_REAL 10
+#define MSG_TYPE_STRING 12
+#define MSG_TYPE_STRING_C 12
+/* MSG_TYPE_INVALID 13 unused */
+
+#define MSG_TYPE_INTERNAL_MEMORY MSG_TYPE_INTEGER_8
+
+#define MSG_TYPE_PORT_NAME 15 /* A capability name */
+#define MSG_TYPE_LAST 16 /* Last assigned */
+
+#define MSG_TYPE_POLYMORPHIC ((unsigned int) -1)
+
+/*
+ * Is a given item a port type?
+ */
+
+#define MSG_TYPE_PORT_ANY(x) \
+ (((x) == MSG_TYPE_PORT) || ((x) == MSG_TYPE_PORT_ALL))
+
+/*
+ * Other basic types
+ */
+
+typedef natural_t msg_timeout_t;
+
+/*
+ * Options to IPC primitives.
+ *
+ * These can be combined by or'ing; the combination RPC call
+ * uses both SEND_ and RCV_ options at once.
+ */
+
+typedef integer_t msg_option_t;
+
+#define MSG_OPTION_NONE 0x0000 /* Terminate only when message op works */
+
+#define SEND_TIMEOUT 0x0001 /* Terminate on timeout elapsed */
+#define SEND_NOTIFY 0x0002 /* Terminate with reply message if need be */
+
+#define SEND_INTERRUPT 0x0004 /* Terminate on software interrupt */
+
+#define RCV_TIMEOUT 0x0100 /* Terminate on timeout elapsed */
+#define RCV_NO_SENDERS 0x0200 /* Terminate if I'm the only sender left */
+#define RCV_INTERRUPT 0x0400 /* Terminate on software interrupt */
+
+/*
+ * Returns from IPC primitives.
+ *
+ * Values are separate in order to allow RPC users to
+ * distinguish which operation failed; for successful completion,
+ * this doesn't matter.
+ */
+
+typedef int msg_return_t;
+
+#define SEND_SUCCESS 0
+
+#define SEND_ERRORS_START -100
+#define SEND_INVALID_MEMORY -101 /* Message or OOL data invalid */
+#define SEND_INVALID_PORT -102 /* Reference to inacessible port */
+#define SEND_TIMED_OUT -103 /* Terminated due to timeout */
+#define SEND_WILL_NOTIFY -105 /* Msg accepted provisionally */
+#define SEND_NOTIFY_IN_PROGRESS -106 /* Already awaiting a notification */
+#define SEND_KERNEL_REFUSED -107 /* Message to the kernel refused */
+#define SEND_INTERRUPTED -108 /* Software interrupt during send */
+#define SEND_MSG_TOO_LARGE -109 /* Message specified was too large */
+#define SEND_MSG_TOO_SMALL -110 /* Data specified exceeds msg size */
+/* SEND_MSG_SIZE_CHANGE -111 Msg size changed during copy */
+#define SEND_ERRORS_END -111
+
+#define msg_return_send(x) ((x) < SEND_ERRORS_START && (x) > SEND_ERRORS_END)
+
+#define RCV_SUCCESS 0
+
+#define RCV_ERRORS_START -200
+#define RCV_INVALID_MEMORY -201
+#define RCV_INVALID_PORT -202
+#define RCV_TIMED_OUT -203
+#define RCV_TOO_LARGE -204 /* Msg structure too small for data */
+#define RCV_NOT_ENOUGH_MEMORY -205 /* Can't find space for OOL data */
+#define RCV_ONLY_SENDER -206 /* Receiver is only sender */
+#define RCV_INTERRUPTED -207
+#define RCV_PORT_CHANGE -208 /* Port was put in a set */
+#define RCV_ERRORS_END -209
+
+#define msg_return_rcv(x) ((x) < RCV_ERRORS_START && (x) > RCV_ERRORS_END)
+
+#define RPC_SUCCESS 0
+
+/*
+ * The IPC primitive functions themselves
+ */
+
+msg_return_t msg_send(
+#if defined(c_plusplus) || defined(__STDC__)
+ msg_header_t *header,
+ msg_option_t option,
+ msg_timeout_t timeout);
+#else /* c_plusplus || __STDC__ */
+#if LINTLIBRARY
+ header, option, timeout)
+ msg_header_t *header;
+ msg_option_t option;
+ msg_timeout_t timeout;
+ { return(SEND_SUCCESS); }
+#else /* LINTLIBRARY */
+ );
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+msg_return_t msg_receive(
+#if defined(c_plusplus) || defined(__STDC__)
+ msg_header_t *header,
+ msg_option_t option,
+ msg_timeout_t timeout);
+#else /* c_plusplus || __STDC__ */
+#if LINTLIBRARY
+ header, option, timeout)
+ msg_header_t *header;
+ msg_option_t option;
+ msg_timeout_t timeout;
+ { return(RCV_SUCCESS); }
+#else /* LINTLIBRARY */
+ );
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+msg_return_t msg_rpc(
+#if defined(c_plusplus) || defined(__STDC__)
+ msg_header_t *header, /* in/out */
+ msg_option_t option,
+ msg_size_t rcv_size,
+ msg_timeout_t send_timeout,
+ msg_timeout_t rcv_timeout);
+#else /* c_plusplus || __STDC__ */
+#if LINTLIBRARY
+ header, option, rcv_size,
+ send_timeout, rcv_timeout)
+ msg_header_t *header; /* in/out */
+ msg_option_t option;
+ msg_size_t rcv_size;
+ msg_timeout_t send_timeout;
+ msg_timeout_t rcv_timeout;
+ { return(RPC_SUCCESS); }
+#else /* LINTLIBRARY */
+ );
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+msg_return_t msg_send_trap(
+#if defined(c_plusplus) || defined(__STDC__)
+ msg_header_t *header,
+ msg_option_t option,
+ msg_size_t send_size,
+ msg_timeout_t timeout);
+#else /* c_plusplus || __STDC__ */
+#if LINTLIBRARY
+ header, option, send_size, timeout)
+ msg_header_t *header;
+ msg_option_t option;
+ msg_size_t send_size;
+ msg_timeout_t timeout;
+ { return(SEND_SUCCESS); }
+#else /* LINTLIBRARY */
+ );
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+msg_return_t msg_receive_trap(
+#if defined(c_plusplus) || defined(__STDC__)
+ msg_header_t *header,
+ msg_option_t option,
+ msg_size_t rcv_size,
+ port_name_t rcv_name,
+ msg_timeout_t timeout);
+#else /* c_plusplus || __STDC__ */
+#if LINTLIBRARY
+ header, option, rcv_size, rcv_name, timeout)
+ msg_header_t *header;
+ msg_option_t option;
+ msg_size_t rcv_size;
+ port_name_t rcv_name;
+ msg_timeout_t timeout;
+ { return(RCV_SUCCESS); }
+#else /* LINTLIBRARY */
+ );
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+msg_return_t msg_rpc_trap(
+#if defined(c_plusplus) || defined(__STDC__)
+ msg_header_t *header, /* in/out */
+ msg_option_t option,
+ msg_size_t send_size,
+ msg_size_t rcv_size,
+ msg_timeout_t send_timeout,
+ msg_timeout_t rcv_timeout);
+#else /* c_plusplus || __STDC__ */
+#if LINTLIBRARY
+ header, option, send_size, rcv_size,
+ send_timeout, rcv_timeout)
+ msg_header_t *header; /* in/out */
+ msg_option_t option;
+ msg_size_t send_size;
+ msg_size_t rcv_size;
+ msg_timeout_t send_timeout;
+ msg_timeout_t rcv_timeout;
+ { return(RPC_SUCCESS); }
+#else /* LINTLIBRARY */
+ );
+#endif /* LINTLIBRARY */
+#endif /* c_plusplus || __STDC__ */
+
+#endif /* MACH_IPC_COMPAT */
+
+#endif /* _MACH_MESSAGE_H_ */
diff --git a/include/mach/mig_errors.h b/include/mach/mig_errors.h
new file mode 100644
index 0000000..eec4c19
--- /dev/null
+++ b/include/mach/mig_errors.h
@@ -0,0 +1,105 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#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)();
+} 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
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+typedef struct {
+ msg_header_t Head;
+ msg_type_t RetCodeType;
+ kern_return_t RetCode;
+} death_pill_t;
+
+#endif /* MACH_IPC_COMPAT */
+
+#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..e19de97
--- /dev/null
+++ b/include/mach/mig_support.h
@@ -0,0 +1,67 @@
+/*
+ * 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 <mach/message.h>
+#include <mach/mach_types.h>
+
+#if defined(MACH_KERNEL)
+
+#if defined(bcopy)
+#else /* not defined(bcopy) */
+extern void bcopy(const void *, void *, vm_size_t);
+#define memcpy(_dst,_src,_len) bcopy((_src),(_dst),(_len))
+#endif /* defined(bcopy) */
+
+#endif /* defined(MACH_KERNEL) */
+
+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_t mig_get_reply_port(void);
+
+extern void mig_reply_setup(const mach_msg_header_t *_request,
+ mach_msg_header_t *reply);
+
+#ifndef MACH_KERNEL
+extern vm_size_t mig_strncpy(char *_dest, const char *_src, vm_size_t _len);
+#endif
+
+#endif /* not defined(_MACH_MIG_SUPPORT_H_) */
diff --git a/include/mach/msg_type.h b/include/mach/msg_type.h
new file mode 100644
index 0000000..3298fd5
--- /dev/null
+++ b/include/mach/msg_type.h
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+/*
+ * This file defines user msg types that may be ored into
+ * the msg_type field in a msg header. Values 0-5 are reserved
+ * for use by the kernel and are defined in message.h.
+ *
+ */
+
+#ifndef _MACH_MSG_TYPE_H_
+#define _MACH_MSG_TYPE_H_
+
+#define MSG_TYPE_CAMELOT (1 << 6)
+#define MSG_TYPE_ENCRYPTED (1 << 7)
+#define MSG_TYPE_RPC (1 << 8) /* Reply expected */
+
+#include <mach/message.h>
+
+#endif /* _MACH_MSG_TYPE_H_ */
diff --git a/include/mach/multiboot.h b/include/mach/multiboot.h
new file mode 100644
index 0000000..4ae6b2f
--- /dev/null
+++ b/include/mach/multiboot.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 1995-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_MULTIBOOT_H_
+#define _MACH_MULTIBOOT_H_
+
+#include <mach/machine/vm_types.h>
+#include <mach/machine/multiboot.h>
+
+struct multiboot_region
+{
+ vm_offset_t start;
+ vm_offset_t end;
+};
+
+struct multiboot_rlist
+{
+ int count;
+ vm_offset_t regions;
+};
+
+struct multiboot_module
+{
+ /* Location and size of the module. */
+ struct multiboot_region region;
+
+ /* Command-line associated with this boot module:
+ a null-terminated ASCII string.
+ Both start and end are 0 if there is no command line.
+ The end pointer points at least one byte past the terminating null. */
+ struct multiboot_region cmdline;
+
+ /* Reserved; boot loader must initialize to zero. */
+ natural_t pad[4];
+};
+
+struct multiboot_info
+{
+ /* List of available physical memory regions.
+ Can (and probably does) include the memory containing
+ the kernel, boot modules, this structure, etc. */
+ struct multiboot_rlist avail;
+
+ /* Physical memory region occupied by things the boot loader set up
+ and the OS shouldn't clobber at least until it's all done initializing itself.
+ This includes the kernel image, boot modules, these structures,
+ initial processor tables, etc. */
+ struct multiboot_rlist occupied;
+
+ /* Command-line for the OS kernel: a null-terminated ASCII string.
+ Both start and end are 0 if there is no command line.
+ The end pointer points at least one byte past the terminating null. */
+ struct multiboot_region cmdline;
+
+ /* Secondary boot modules loaded with this kernel image. */
+ int nmods;
+ vm_offset_t mods;
+
+ /* Reserved; boot loader must initialize to zero. */
+ natural_t pad[4];
+};
+
+#endif _MACH_MULTIBOOT_H_
+/*
+ * Copyright (c) 1995-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_MULTIBOOT_H_
+#define _MACH_MULTIBOOT_H_
+
+#include <mach/machine/vm_types.h>
+#include <mach/machine/multiboot.h>
+
+struct multiboot_region
+{
+ vm_offset_t start;
+ vm_offset_t end;
+};
+
+struct multiboot_rlist
+{
+ int count;
+ vm_offset_t regions;
+};
+
+struct multiboot_module
+{
+ /* Location and size of the module. */
+ struct multiboot_region region;
+
+ /* Command-line associated with this boot module:
+ a null-terminated ASCII string.
+ Both start and end are 0 if there is no command line.
+ The end pointer points at least one byte past the terminating null. */
+ struct multiboot_region cmdline;
+
+ /* Reserved; boot loader must initialize to zero. */
+ natural_t pad[4];
+};
+
+struct multiboot_info
+{
+ /* List of available physical memory regions.
+ Can (and probably does) include the memory containing
+ the kernel, boot modules, this structure, etc. */
+ struct multiboot_rlist avail;
+
+ /* Physical memory region occupied by things the boot loader set up
+ and the OS shouldn't clobber at least until it's all done initializing itself.
+ This includes the kernel image, boot modules, these structures,
+ initial processor tables, etc. */
+ struct multiboot_rlist occupied;
+
+ /* Command-line for the OS kernel: a null-terminated ASCII string.
+ Both start and end are 0 if there is no command line.
+ The end pointer points at least one byte past the terminating null. */
+ struct multiboot_region cmdline;
+
+ /* Secondary boot modules loaded with this kernel image. */
+ int nmods;
+ vm_offset_t mods;
+
+ /* Reserved; boot loader must initialize to zero. */
+ natural_t pad[4];
+};
+
+#endif _MACH_MULTIBOOT_H_
diff --git a/include/mach/norma_special_ports.h b/include/mach/norma_special_ports.h
new file mode 100644
index 0000000..e911467
--- /dev/null
+++ b/include/mach/norma_special_ports.h
@@ -0,0 +1,84 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991 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/norma_special_ports.h
+ *
+ * Defines codes for remote access to special ports. These are NOT
+ * port identifiers - they are only used for the norma_get_special_port
+ * and norma_set_special_port routines.
+ */
+
+#ifndef _MACH_NORMA_SPECIAL_PORTS_H_
+#define _MACH_NORMA_SPECIAL_PORTS_H_
+
+#define MAX_SPECIAL_KERNEL_ID 3
+#define MAX_SPECIAL_ID 32
+
+/*
+ * Provided by kernel
+ */
+#define NORMA_DEVICE_PORT 1
+#define NORMA_HOST_PORT 2
+#define NORMA_HOST_PRIV_PORT 3
+
+/*
+ * Not provided by kernel
+ */
+#define NORMA_NAMESERVER_PORT (1 + MAX_SPECIAL_KERNEL_ID)
+
+/*
+ * Definitions for ease of use.
+ *
+ * In the get call, the host parameter can be any host, but will generally
+ * be the local node host port. In the set call, the host must the per-node
+ * host port for the node being affected.
+ */
+
+#define norma_get_device_port(host, node, port) \
+ (norma_get_special_port((host), (node), NORMA_DEVICE_PORT, (port)))
+
+#define norma_set_device_port(host, port) \
+ (norma_set_special_port((host), NORMA_DEVICE_PORT, (port)))
+
+#define norma_get_host_port(host, node, port) \
+ (norma_get_special_port((host), (node), NORMA_HOST_PORT, (port)))
+
+#define norma_set_host_port(host, port) \
+ (norma_set_special_port((host), NORMA_HOST_PORT, (port)))
+
+#define norma_get_host_priv_port(host, node, port) \
+ (norma_get_special_port((host), (node), NORMA_HOST_PRIV_PORT, (port)))
+
+#define norma_set_host_priv_port(host, port) \
+ (norma_set_special_port((host), NORMA_HOST_PRIV_PORT, (port)))
+
+#define norma_get_nameserver_port(host, node, port) \
+ (norma_get_special_port((host), (node), NORMA_NAMESERVER_PORT, (port)))
+
+#define norma_set_nameserver_port(host, port) \
+ (norma_set_special_port((host), NORMA_NAMESERVER_PORT, (port)))
+
+#endif /* _MACH_NORMA_SPECIAL_PORTS_H_ */
diff --git a/include/mach/norma_task.defs b/include/mach/norma_task.defs
new file mode 100644
index 0000000..1ae5972
--- /dev/null
+++ b/include/mach/norma_task.defs
@@ -0,0 +1,43 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991 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
+#if KERNEL_USER
+ KernelUser
+#endif KERNEL_USER
+#if KERNEL_SERVER
+ KernelServer
+#endif KERNEL_SERVER
+ norma_task 666000;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+
+routine norma_task_create(
+ norma_task_server : mach_port_t;
+ target_task : mach_port_t;
+ inherit_memory : boolean_t;
+ out child_task : mach_port_t);
diff --git a/include/mach/notify.defs b/include/mach/notify.defs
new file mode 100644
index 0000000..e06f6b4
--- /dev/null
+++ b/include/mach/notify.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.
+ */
+
+subsystem notify 64;
+
+#include <mach/std_types.defs>
+
+#if SEQNOS
+serverprefix do_seqnos_;
+serverdemux seqnos_notify_server;
+#else SEQNOS
+serverprefix do_;
+serverdemux notify_server;
+#endif SEQNOS
+
+type notify_port_t = MACH_MSG_TYPE_MOVE_SEND_ONCE
+ ctype: mach_port_t;
+
+/* 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 SEQNOS
+ 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 SEQNOS
+ 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 SEQNOS
+ 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 SEQNOS
+ 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 SEQNOS
+ );
+
+/* MACH_NOTIFY_DEAD_NAME: 0110 */
+simpleroutine mach_notify_dead_name(
+ notify : notify_port_t;
+#if SEQNOS
+ msgseqno seqno : mach_port_seqno_t;
+#endif SEQNOS
+ name : mach_port_name_t);
diff --git a/include/mach/notify.h b/include/mach/notify.h
new file mode 100644
index 0000000..9fa65ad
--- /dev/null
+++ b/include/mach/notify.h
@@ -0,0 +1,122 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#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_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_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_t not_port;
+} mach_dead_name_notification_t;
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+/*
+ * Notifications sent upon interesting system events.
+ */
+
+#define NOTIFY_FIRST 0100
+#define NOTIFY_PORT_DELETED ( NOTIFY_FIRST + 001 )
+#define NOTIFY_MSG_ACCEPTED ( NOTIFY_FIRST + 002 )
+#define NOTIFY_OWNERSHIP_RIGHTS ( NOTIFY_FIRST + 003 )
+#define NOTIFY_RECEIVE_RIGHTS ( NOTIFY_FIRST + 004 )
+#define NOTIFY_PORT_DESTROYED ( NOTIFY_FIRST + 005 )
+#define NOTIFY_NO_MORE_SENDERS ( NOTIFY_FIRST + 006 )
+#define NOTIFY_LAST ( NOTIFY_FIRST + 015 )
+
+typedef struct {
+ msg_header_t notify_header;
+ msg_type_t notify_type;
+ port_t notify_port;
+} notification_t;
+
+#endif /* MACH_IPC_COMPAT */
+
+#endif /* _MACH_NOTIFY_H_ */
diff --git a/include/mach/pc_sample.h b/include/mach/pc_sample.h
new file mode 100644
index 0000000..662addb
--- /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 natural_t 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 {
+ natural_t id;
+ vm_offset_t pc;
+ 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..6b9de37
--- /dev/null
+++ b/include/mach/port.h
@@ -0,0 +1,189 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#include <mach/boolean.h>
+#include <mach/machine/vm_types.h>
+
+
+typedef natural_t mach_port_t;
+typedef mach_port_t *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 ((mach_port_t) 0)
+#define MACH_PORT_DEAD ((mach_port_t) ~0)
+
+#define MACH_PORT_VALID(name) \
+ (((name) != MACH_PORT_NULL) && ((name) != MACH_PORT_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_t mps_pset; /* containing port set */
+ mach_port_seqno_t mps_seqno; /* sequence number */
+/*mach_port_mscount_t*/natural_t mps_mscount; /* make-send count */
+/*mach_port_msgcount_t*/natural_t mps_qlimit; /* queue limit */
+/*mach_port_msgcount_t*/natural_t mps_msgcount; /* number in the queue */
+/*mach_port_rights_t*/natural_t mps_sorights; /* how many send-once rights */
+/*boolean_t*/natural_t mps_srights; /* do send rights exist? */
+/*boolean_t*/natural_t mps_pdrequest; /* port-deleted requested? */
+/*boolean_t*/natural_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)
+
+/*
+ * Compatibility definitions, for code written
+ * before there was an mps_seqno field.
+ */
+
+typedef struct old_mach_port_status {
+ mach_port_t mps_pset; /* containing port set */
+/*mach_port_mscount_t*/natural_t mps_mscount; /* make-send count */
+/*mach_port_msgcount_t*/natural_t mps_qlimit; /* queue limit */
+/*mach_port_msgcount_t*/natural_t mps_msgcount; /* number in the queue */
+/*mach_port_rights_t*/natural_t mps_sorights; /* how many send-once rights */
+/*boolean_t*/natural_t mps_srights; /* do send rights exist? */
+/*boolean_t*/natural_t mps_pdrequest; /* port-deleted requested? */
+/*boolean_t*/natural_t mps_nsrequest; /* no-senders requested? */
+} old_mach_port_status_t;
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+typedef integer_t port_name_t; /* A capability's name */
+typedef port_name_t port_set_name_t; /* Descriptive alias */
+typedef port_name_t *port_name_array_t;
+
+typedef integer_t port_type_t; /* What kind of capability? */
+typedef port_type_t *port_type_array_t;
+
+ /* Values for port_type_t */
+
+#define PORT_TYPE_NONE 0 /* No rights */
+#define PORT_TYPE_SEND 1 /* Send rights */
+#define PORT_TYPE_RECEIVE 3 /* obsolete */
+#define PORT_TYPE_OWN 5 /* obsolete */
+#define PORT_TYPE_RECEIVE_OWN 7 /* Send, receive, ownership */
+#define PORT_TYPE_SET 9 /* Set ownership */
+#define PORT_TYPE_LAST 10 /* Last assigned */
+
+typedef port_name_t port_t; /* Port with send rights */
+typedef port_t port_rcv_t; /* Port with receive rights */
+typedef port_t port_own_t; /* Port with ownership rights */
+typedef port_t port_all_t; /* Port with receive and ownership */
+typedef port_t *port_array_t;
+
+#define PORT_NULL ((port_name_t) 0) /* Used to denote no port; legal value */
+
+#endif /* MACH_IPC_COMPAT */
+
+#endif /* _MACH_PORT_H_ */
diff --git a/include/mach/proc_ops.h b/include/mach/proc_ops.h
new file mode 100644
index 0000000..a453ec8
--- /dev/null
+++ b/include/mach/proc_ops.h
@@ -0,0 +1,51 @@
+/*
+ * 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
+ */
+/*
+ * Simple operations that don't exist as primitives in C,
+ * but which processors often implement directly.
+ * This file contains default, "dumb" implementations;
+ * machine-independent code can override these with smarter implementations.
+ */
+#ifndef _MACH_PROC_OPS_H_
+#define _MACH_PROC_OPS_H_
+
+#include <mach/machine/vm_types.h>
+#include <mach/inline.h>
+
+/* Returns the bit number of the most-significant set bit in `val',
+ e.g. 0 for 1, 1 for 2-3, 2 for 4-7, etc.
+ If `val' is 0 (i.e. no bits are set), the behavior is undefined. */
+MACH_INLINE int find_msb_set(natural_t val)
+{
+ int msb;
+ for (msb = sizeof(val)*8-1; (val & ((natural_t)1 << msb)) == 0; msb--);
+ return msb;
+}
+
+/* Returns the bit number of the least-significant set bit in `val'.
+ If `val' is 0 (i.e. no bits are set), the behavior is undefined. */
+MACH_INLINE int find_lsb_set(natural_t val)
+{
+ int lsb;
+ for (lsb = 0; (val & ((natural_t)1 << lsb)) == 0; lsb++);
+ return lsb;
+}
+
+#endif _MACH_PROC_OPS_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..0eb4ce4
--- /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 occured: 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/rpc.h b/include/mach/rpc.h
new file mode 100644
index 0000000..d3098f8
--- /dev/null
+++ b/include/mach/rpc.h
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef MACH_RPC_H
+#define MACH_RPC_H
+
+#include <mach/kern_return.h>
+#include <mach/message.h>
+#include <mach/machine/rpc.h>
+
+/*
+ * Description of a port passed up by the leaky-register RPC path
+ * when it needs to perform translation.
+ */
+struct rpc_port_desc {
+ mach_port_t name;
+ mach_msg_type_name_t msgt_name;
+};
+
+#endif /* MACH_RPC_H */
diff --git a/include/mach/sa/a.out.h b/include/mach/sa/a.out.h
new file mode 100644
index 0000000..8ab8ba8
--- /dev/null
+++ b/include/mach/sa/a.out.h
@@ -0,0 +1,28 @@
+/*
+ * 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_SA_A_OUT_H_
+#define _MACH_SA_A_OUT_H_
+
+#include <mach/exec/a.out.h>
+
+#endif _MACH_SA_A_OUT_H_
diff --git a/include/mach/sa/alloca.h b/include/mach/sa/alloca.h
new file mode 100644
index 0000000..0a476b4
--- /dev/null
+++ b/include/mach/sa/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/mach/sa/assert.h b/include/mach/sa/assert.h
new file mode 100644
index 0000000..8c12f1c
--- /dev/null
+++ b/include/mach/sa/assert.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1995 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 _ASSERT_H_
+#define _ASSERT_H_
+
+#ifdef NDEBUG
+
+#define assert(ignore) ((void)0)
+
+#else
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+extern void panic(const char *format, ...);
+__END_DECLS
+
+#define assert(expression) \
+ ((void)((expression) ? 0 : (panic("%s:%u: failed assertion `%s'", \
+ __FILE__, __LINE__, #expression), 0)))
+
+#endif
+
+#endif /* _ASSERT_H_ */
diff --git a/include/mach/sa/ctype.h b/include/mach/sa/ctype.h
new file mode 100644
index 0000000..40b5366
--- /dev/null
+++ b/include/mach/sa/ctype.h
@@ -0,0 +1,59 @@
+/*
+ * 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_CTYPE_H_
+#define _MACH_CTYPE_H_
+
+#include <sys/cdefs.h>
+
+__INLINE_FUNC int isdigit(char c)
+{
+ return ((c) >= '0') && ((c) <= '9');
+}
+
+__INLINE_FUNC int isspace(char c)
+{
+ return ((c) == ' ') || ((c) == '\f')
+ || ((c) == '\n') || ((c) == '\r')
+ || ((c) == '\t') || ((c) == '\v');
+}
+
+__INLINE_FUNC int isalpha(char c)
+{
+ return (((c) >= 'a') && ((c) <= 'z'))
+ || (((c) >= 'A') && ((c) <= 'Z'));
+}
+
+__INLINE_FUNC int isalnum(char c)
+{
+ return isalpha(c) || isdigit(c);
+}
+
+__INLINE_FUNC int toupper(char c)
+{
+ return ((c >= 'a') && (c <= 'z')) ? (c - 'a' + 'A') : c;
+}
+
+__INLINE_FUNC int tolower(char c)
+{
+ return ((c >= 'A') && (c <= 'Z')) ? (c - 'A' + 'a') : c;
+}
+
+
+#endif _MACH_CTYPE_H_
diff --git a/include/mach/sa/errno.h b/include/mach/sa/errno.h
new file mode 100644
index 0000000..1e8be23
--- /dev/null
+++ b/include/mach/sa/errno.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1995 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
+ */
+/*
+ * This header file defines a set of POSIX errno values
+ * that fits consistently into the Mach error code "space" -
+ * i.e. these error code values can be mixed with kern_return_t's
+ * and mach_msg_return_t's and such without conflict.
+ * Higher-level services are not required to use these values
+ * (or, for that matter, any of the mach/sa header files),
+ * but if they use other values of their own choosing,
+ * those values may conflict with values in the Mach error code space,
+ * making it necessary to keep the different types of error codes separate.
+ *
+ * (For example, Lites uses BSD's errno values,
+ * which conflict with Mach's kern_return_t values,
+ * and therefore must carefully distinguish between BSD and Mach error codes
+ * and never return one type when the other is expected, etc. -
+ * we've found this to be a frequent source of bugs.)
+ *
+ * One (probably the main) disadvantage of using these error codes
+ * is that, since they don't start from around 0 like typical Unix errno values,
+ * it's impossible to provide a conventional Unix-style sys_errlist table for them.
+ * However, they are compatible with the POSIX-blessed strerror and perror routines.
+ */
+#ifndef _MACH_SA_ERRNO_H_
+#define _MACH_SA_ERRNO_H_
+
+extern int errno; /* global error number */
+
+/* ISO/ANSI C-1990 errors */
+#define EDOM 0xc001 /* Numerical argument out of domain */
+#define ERANGE 0xc002 /* Result too large */
+
+/* POSIX-1990 errors */
+#define E2BIG 0xc003 /* Argument list too long */
+#define EACCES 0xc004 /* Permission denied */
+#define EAGAIN 0xc005 /* Resource temporarily unavailable */
+#define EBADF 0xc006 /* Bad file descriptor */
+#define EBUSY 0xc007 /* Device busy */
+#define ECHILD 0xc008 /* No child processes */
+#define EDEADLK 0xc009 /* Resource deadlock avoided */
+#define EEXIST 0xc00a /* File exists */
+#define EFAULT 0xc00b /* Bad address */
+#define EFBIG 0xc00c /* File too large */
+#define EINTR 0xc00d /* Interrupted system call */
+#define EINVAL 0xc00e /* Invalid argument */
+#define EIO 0xc00f /* Input/output error */
+#define EISDIR 0xc010 /* Is a directory */
+#define EMFILE 0xc011 /* Too many open files */
+#define EMLINK 0xc012 /* Too many links */
+#define ENAMETOOLONG 0xc013 /* File name too long */
+#define ENFILE 0xc014 /* Too many open files in system */
+#define ENODEV 0xc015 /* Operation not supported by device */
+#define ENOENT 0xc016 /* No such file or directory */
+#define ENOEXEC 0xc017 /* Exec format error */
+#define ENOLCK 0xc018 /* No locks available */
+#define ENOMEM 0xc019 /* Cannot allocate memory */
+#define ENOSPC 0xc01a /* No space left on device */
+#define ENOSYS 0xc01b /* Function not implemented */
+#define ENOTDIR 0xc01c /* Not a directory */
+#define ENOTEMPTY 0xc01d /* Directory not empty */
+#define ENOTTY 0xc01e /* Inappropriate ioctl for device */
+#define ENXIO 0xc01f /* Device not configured */
+#define EPERM 0xc020 /* Operation not permitted */
+#define EPIPE 0xc021 /* Broken pipe */
+#define EROFS 0xc022 /* Read-only file system */
+#define ESPIPE 0xc023 /* Illegal seek */
+#define ESRCH 0xc024 /* No such process */
+#define EXDEV 0xc025 /* Cross-device link */
+
+/* POSIX-1993 errors */
+#define EBADMSG 0xc026
+#define ECANCELED 0xc027
+#define EINPROGRESS 0xc028
+#define EMSGSIZE 0xc029
+#define ENOTSUP 0xc02a
+
+#endif _MACH_SA_ERRNO_H_
diff --git a/include/mach/sa/fcntl.h b/include/mach/sa/fcntl.h
new file mode 100644
index 0000000..ac86fe3
--- /dev/null
+++ b/include/mach/sa/fcntl.h
@@ -0,0 +1,22 @@
+#ifndef _MACH_SA_FCNTL_H_
+#define _MACH_SA_FCNTL_H_
+
+#include <sys/cdefs.h>
+
+#define O_ACCMODE 0x0003
+#define O_RDONLY 0x0000
+#define O_WRONLY 0x0001
+#define O_RDWR 0x0002
+
+#define O_CREAT 0x0010
+#define O_TRUNC 0x0020
+#define O_APPEND 0x0040
+#define O_EXCL 0x0080
+
+__BEGIN_DECLS
+
+int open(const char *__name, int __mode, ...);
+
+__END_DECLS
+
+#endif /* _MACH_SA_FCNTL_H_ */
diff --git a/include/mach/sa/limits.h b/include/mach/sa/limits.h
new file mode 100644
index 0000000..f8dd03a
--- /dev/null
+++ b/include/mach/sa/limits.h
@@ -0,0 +1,32 @@
+/*
+ * 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_LIMITS_H_
+#define _MACH_LIMITS_H_
+
+/* This file is valid for typical 32-bit machines;
+ it should be overridden on 64-bit machines. */
+
+#define INT_MIN ((signed int)0x80000000)
+#define INT_MAX ((signed int)0x7fffffff)
+
+#define UINT_MIN ((unsigned int)0x00000000)
+#define UINT_MAX ((unsigned int)0xffffffff)
+
+#endif _MACH_LIMITS_H_
diff --git a/include/mach/sa/malloc.h b/include/mach/sa/malloc.h
new file mode 100644
index 0000000..3669046
--- /dev/null
+++ b/include/mach/sa/malloc.h
@@ -0,0 +1,51 @@
+/*
+ * 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_SA_MALLOC_H_
+#define _MACH_SA_MALLOC_H_
+
+#include <mach/machine/vm_types.h>
+#include <sys/cdefs.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef natural_t size_t;
+#endif
+
+/* The malloc package in the base C library
+ is implemented on top of the List Memory Manager,
+ and the underlying memory pool can be manipulated
+ directly with the LMM primitives using this lmm structure. */
+extern struct lmm malloc_lmm;
+
+__BEGIN_DECLS
+
+void *malloc(size_t size);
+void *calloc(size_t nelt, size_t eltsize);
+void *realloc(void *buf, size_t new_size);
+void free(void *buf);
+
+/* malloc() and realloc() call this routine when they're about to fail;
+ it should try to scare up more memory and add it to the malloc_lmm.
+ Returns nonzero if it succeeds in finding more memory. */
+int morecore(size_t size);
+
+__END_DECLS
+
+#endif _MACH_SA_MALLOC_H_
diff --git a/include/mach/sa/memory.h b/include/mach/sa/memory.h
new file mode 100644
index 0000000..e2060ea
--- /dev/null
+++ b/include/mach/sa/memory.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_MEMORY_H_
+#define _MACH_MEMORY_H_
+
+#include <string.h>
+
+#endif _MACH_MEMORY_H_
diff --git a/include/mach/sa/stddef.h b/include/mach/sa/stddef.h
new file mode 100644
index 0000000..9da5de0
--- /dev/null
+++ b/include/mach/sa/stddef.h
@@ -0,0 +1,24 @@
+/*
+ * 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_STDDEF_H_
+#define _MACH_STDDEF_H_
+
+
+#endif _MACH_STDDEF_H_
diff --git a/include/mach/sa/stdio.h b/include/mach/sa/stdio.h
new file mode 100644
index 0000000..d8f7201
--- /dev/null
+++ b/include/mach/sa/stdio.h
@@ -0,0 +1,72 @@
+/*
+ * 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_SA_STDIO_H
+#define _MACH_SA_STDIO_H
+
+#include <sys/cdefs.h>
+
+/* This is a very naive standard I/O implementation
+ which simply chains to the low-level I/O routines
+ without doing any buffering or anything. */
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+typedef struct
+{
+ int fd;
+} FILE;
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#ifndef EOF
+#define EOF -1
+#endif
+
+__BEGIN_DECLS
+
+int putchar(int c);
+int puts(const char *str);
+int printf(const char *format, ...);
+int sprintf(char *dest, const char *format, ...);
+FILE *fopen(const char *path, const char *mode);
+int fclose(FILE *stream);
+int fread(void *buf, int size, int count, FILE *stream);
+int fwrite(void *buf, int size, int count, FILE *stream);
+int fputc(int c, FILE *stream);
+int fgetc(FILE *stream);
+int fprintf(FILE *stream, const char *format, ...);
+int fscanf(FILE *stream, const char *format, ...);
+int feof(FILE *stream);
+long ftell(FILE *stream);
+void rewind(FILE *stream);
+int rename(const char *from, const char *to);
+
+#define putc(c, stream) fputc(c, stream)
+
+__END_DECLS
+
+#endif _MACH_SA_STDIO_H
diff --git a/include/mach/sa/stdlib.h b/include/mach/sa/stdlib.h
new file mode 100644
index 0000000..29d3eaf
--- /dev/null
+++ b/include/mach/sa/stdlib.h
@@ -0,0 +1,56 @@
+/*
+ * 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_SA_STDLIB_H_
+#define _MACH_SA_STDLIB_H_
+
+#include <mach/machine/vm_types.h>
+#include <sys/cdefs.h>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef natural_t size_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+__BEGIN_DECLS
+
+int rand(void);
+
+long atol(const char *str);
+#define atoi(str) ((int)atol(str))
+
+#define abs(n) __builtin_abs(n)
+
+void exit(int status);
+
+void srand(unsigned seed);
+int rand(void);
+
+void *malloc(size_t size);
+void *calloc(size_t nelt, size_t eltsize);
+void *realloc(void *buf, size_t new_size);
+void free(void *buf);
+
+__END_DECLS
+
+#endif _MACH_SA_STDLIB_H_
diff --git a/include/mach/sa/string.h b/include/mach/sa/string.h
new file mode 100644
index 0000000..45fc137
--- /dev/null
+++ b/include/mach/sa/string.h
@@ -0,0 +1,56 @@
+/*
+ * 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_STRING_H_
+#define _MACH_STRING_H_
+
+#include <sys/cdefs.h>
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+__BEGIN_DECLS
+
+__DECL(char *,strdup(const char *s));
+__DECL(char *,strcat(char *dest, const char *src));
+__DECL(int,strcmp(const char *a, const char *b));
+__DECL(int,strncpy(char *dest, const char *src, int n));
+__DECL(int,strncmp(const char *a, const char *b, int n));
+
+__DECL(char *,strchr(const char *s, int c));
+__DECL(char *,strrchr(const char *s, int c));
+__DECL(char *,index(const char *s, int c));
+__DECL(char *,rindex(const char *s, int c));
+__DECL(void *,strstr(const char *haystack, const char *needle));
+
+#ifndef __GNUC__
+__DECL(void *,memcpy(void *to, const void *from, unsigned int n));
+#endif
+__DECL(void *,memset(void *to, int ch, unsigned int n));
+
+__DECL(void,bcopy(const void *from, void *to, unsigned int n));
+__DECL(void,bzero(void *to, unsigned int n));
+
+__END_DECLS
+
+#endif _MACH_STRING_H_
diff --git a/include/mach/sa/strings.h b/include/mach/sa/strings.h
new file mode 100644
index 0000000..67b502e
--- /dev/null
+++ b/include/mach/sa/strings.h
@@ -0,0 +1,28 @@
+/*
+ * 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_STRINGS_H_
+#define _MACH_STRINGS_H_
+
+#include <string.h>
+
+#endif _MACH_STRINGS_H_
diff --git a/include/mach/sa/sys/cdefs.h b/include/mach/sa/sys/cdefs.h
new file mode 100644
index 0000000..1e804ad
--- /dev/null
+++ b/include/mach/sa/sys/cdefs.h
@@ -0,0 +1,48 @@
+/*
+ * 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
+ */
+/*
+ * Common private header file used by the mach/sa headers.
+ * This header file does not cause any non-POSIX-reserved symbols to be defined.
+ */
+#ifndef _MACH_SA_SYS_CDEFS_H_
+#define _MACH_SA_SYS_CDEFS_H_
+
+#ifdef __cplusplus
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+#ifndef __DECL
+#define __DECL(rettype, decl) \
+ extern rettype __##decl; \
+ extern rettype decl;
+#endif
+
+#ifndef __INLINE_FUNC
+#define __INLINE_FUNC static __inline
+#endif
+
+#endif /* _MACH_SA_SYS_CDEFS_H_ */
diff --git a/include/mach/sa/sys/ioctl.h b/include/mach/sa/sys/ioctl.h
new file mode 100644
index 0000000..732494d
--- /dev/null
+++ b/include/mach/sa/sys/ioctl.h
@@ -0,0 +1,52 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991 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.
+ */
+/*
+ * Format definitions for 'ioctl' commands in device definitions.
+ *
+ * From BSD4.4.
+ */
+
+#ifndef _MACH_SYS_IOCTL_H_
+#define _MACH_SYS_IOCTL_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))
+
+#endif _MACH_SYS_IOCTL_H_
diff --git a/include/mach/sa/sys/mman.h b/include/mach/sa/sys/mman.h
new file mode 100644
index 0000000..3400d30
--- /dev/null
+++ b/include/mach/sa/sys/mman.h
@@ -0,0 +1,41 @@
+/*
+ * 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_SA_SYS_MMAN_H_
+#define _MACH_SA_SYS_MMAN_H_
+
+/*
+ * Protections are chosen from these bits, or-ed together.
+ * NB: These are the same values as the VM_PROT_xxx definitions,
+ * and they can be used interchangeably.
+ */
+#define PROT_READ 0x01 /* pages can be read */
+#define PROT_WRITE 0x02 /* pages can be written */
+#define PROT_EXEC 0x04 /* pages can be executed */
+
+/*
+ * Flags for the mlockall() call.
+ */
+#define MCL_CURRENT 0x0001 /* lock all currently mapped memory */
+#define MCL_FUTURE 0x0002 /* lock all memory mapped in the future */
+
+#endif _MACH_SA_SYS_MMAN_H_
diff --git a/include/mach/sa/sys/reboot.h b/include/mach/sa/sys/reboot.h
new file mode 100644
index 0000000..d74ed98
--- /dev/null
+++ b/include/mach/sa/sys/reboot.h
@@ -0,0 +1,123 @@
+/*
+ * 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 are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * @(#)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/mach/sa/sys/signal.h b/include/mach/sa/sys/signal.h
new file mode 100644
index 0000000..c3c1206
--- /dev/null
+++ b/include/mach/sa/sys/signal.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 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.
+ *
+ * @(#)signal.h 8.2 (Berkeley) 1/21/94
+ * signal.h,v 1.2 1994/08/02 07:53:32 davidg Exp
+ */
+
+#ifndef _MACH_SA_SYS_SIGNAL_H_
+#define _MACH_SA_SYS_SIGNAL_H_
+
+#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
+
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
+#ifndef _POSIX_SOURCE
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#endif
+#define SIGABRT 6 /* abort() */
+#ifndef _POSIX_SOURCE
+#define SIGIOT SIGABRT /* compatibility */
+#define SIGEMT 7 /* EMT instruction */
+#endif
+#define SIGFPE 8 /* floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#ifndef _POSIX_SOURCE
+#define SIGBUS 10 /* bus error */
+#endif
+#define SIGSEGV 11 /* segmentation violation */
+#ifndef _POSIX_SOURCE
+#define SIGSYS 12 /* bad argument to system call */
+#endif
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
+#ifndef _POSIX_SOURCE
+#define SIGURG 16 /* urgent condition on IO channel */
+#endif
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#ifndef _POSIX_SOURCE
+#define SIGIO 23 /* input/output possible signal */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window size changes */
+#define SIGINFO 29 /* information request */
+#endif
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
+
+#if defined(_ANSI_SOURCE) || defined(__cplusplus)
+/*
+ * Language spec sez we must list exactly one parameter, even though we
+ * actually supply three. Ugh!
+ */
+#define SIG_DFL (void (*)(int))0
+#define SIG_IGN (void (*)(int))1
+#define SIG_ERR (void (*)(int))-1
+#else
+#define SIG_DFL (void (*)())0
+#define SIG_IGN (void (*)())1
+#define SIG_ERR (void (*)())-1
+#endif
+
+#ifndef _ANSI_SOURCE
+
+typedef unsigned int sigset_t;
+
+/*
+ * POSIX 1003.1b: Generic value to pass back to an application.
+ */
+union sigval
+{
+ int sival_int;
+ void *sival_ptr;
+};
+
+/*
+ * This structure is passed to signal handlers
+ * that use the new SA_SIGINFO calling convention (see below).
+ */
+typedef struct
+{
+ int si_signo;
+ int si_code;
+ union sigval si_value;
+} siginfo_t;
+
+/* Values for si_code, indicating the source of the signal */
+#define SI_USER 0 /* sent by kill(), raise(), or abort() */
+#define SI_QUEUE 1 /* sent by sigqueue() */
+#define SI_TIMER 2 /* generated by an expired timer */
+#define SI_ASYNCIO 3 /* generated by completion of an async i/o */
+#define SI_MESGQ 4 /* generated by the arrival of a message */
+#define SI_IRQ 5 /* hardware int dispatched to application */
+
+/*
+ * Signal vector "template" used in sigaction call.
+ */
+struct sigaction {
+ union { /* signal handler */
+ void (*sa_u_handler)();
+ void (*sa_u_sigaction)(int, siginfo_t *, void *);
+ } sa_u;
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+#define sa_handler sa_u.sa_u_handler
+#define sa_sigaction sa_u.sa_u_sigaction
+
+#ifndef _POSIX_SOURCE
+#define SA_ONSTACK 0x0001 /* take signal on signal stack */
+#define SA_RESTART 0x0002 /* restart system on signal return */
+#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
+#ifdef COMPAT_SUNOS
+#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
+#endif
+#endif
+#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
+#define SA_SIGINFO 0x0010 /* use sa_sigaction calling convention */
+
+/*
+ * Flags for sigprocmask:
+ */
+#define SIG_BLOCK 1 /* block specified signal set */
+#define SIG_UNBLOCK 2 /* unblock specified signal set */
+#define SIG_SETMASK 3 /* set specified signal set */
+
+/*
+ * POSIX 1003.1b:
+ * Used when requesting queued notification of an event,
+ * such as a timer expiration or a message arrival.
+ */
+struct sigevent
+{
+ int sigev_notify;
+ union
+ {
+ struct
+ {
+ int __signo;
+ union sigval __value;
+ } __sig;
+ struct
+ {
+ void (*__handler)(void);
+ void *__stack;
+ } __fastint;
+ } __u;
+};
+
+#define sigev_signo __u.__sig.__signo
+#define sigev_value __u.__sig.__value
+
+#define sigev_handler __u.__fastint.__handler
+#define sigev_stack __u.__fastint.__stack
+
+/* Values for sigev_notify */
+#define SIGEV_NONE 0
+#define SIGEV_SIGNAL 1
+#define SIGEV_FASTINT 2
+
+#endif /* !_ANSI_SOURCE */
+
+#endif /* !_MACH_SA_SYS_SIGNAL_H_ */
diff --git a/include/mach/sa/sys/stat.h b/include/mach/sa/sys/stat.h
new file mode 100644
index 0000000..81ca25d
--- /dev/null
+++ b/include/mach/sa/sys/stat.h
@@ -0,0 +1,126 @@
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 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.
+ *
+ * @(#)stat.h 8.6 (Berkeley) 3/8/94
+ * stat.h,v 1.5 1994/10/02 17:24:57 phk Exp
+ */
+
+#ifndef _MACH_SA_SYS_STAT_H_
+#define _MACH_SA_SYS_STAT_H_
+
+#include <sys/types.h>
+
+/*
+ * XXX we need this for struct timespec. We get miscellaneous namespace
+ * pollution with it. struct timespace itself is namespace pollution if
+ * _POSIX_SOURCE is defined.
+ */
+#include <sys/time.h>
+
+struct stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ time_t st_atime; /* time of last access */
+ time_t st_mtime; /* time of last data modification */
+ time_t st_ctime; /* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ unsigned long st_blocks; /* blocks allocated for file */
+ unsigned long st_blksize; /* optimal blocksize for I/O */
+};
+
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+#ifndef _POSIX_SOURCE
+#define S_ISTXT 0001000 /* sticky bit */
+#endif
+
+#define S_IRWXU 0000700 /* RWX mask for owner */
+#define S_IRUSR 0000400 /* R for owner */
+#define S_IWUSR 0000200 /* W for owner */
+#define S_IXUSR 0000100 /* X for owner */
+
+#define S_IRWXG 0000070 /* RWX mask for group */
+#define S_IRGRP 0000040 /* R for group */
+#define S_IWGRP 0000020 /* W for group */
+#define S_IXGRP 0000010 /* X for group */
+
+#define S_IRWXO 0000007 /* RWX mask for other */
+#define S_IROTH 0000004 /* R for other */
+#define S_IWOTH 0000002 /* W for other */
+#define S_IXOTH 0000001 /* X for other */
+
+#ifndef _POSIX_SOURCE
+#define S_IFMT 0170000 /* type of file mask */
+#define S_IFIFO 0010000 /* named pipe (fifo) */
+#define S_IFCHR 0020000 /* character special */
+#define S_IFDIR 0040000 /* directory */
+#define S_IFBLK 0060000 /* block special */
+#define S_IFREG 0100000 /* regular */
+#define S_IFLNK 0120000 /* symbolic link */
+#define S_IFSOCK 0140000 /* socket */
+#define S_ISVTX 0001000 /* save swapped text even after use */
+#endif
+
+#define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
+#define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
+#define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
+#define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
+#define S_ISFIFO(m) (((m) & 0170000) == 0010000 || \
+ ((m) & 0170000) == 0140000) /* fifo or socket */
+#ifndef _POSIX_SOURCE
+#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
+#define S_ISSOCK(m) (((m) & 0170000) == 0010000 || \
+ ((m) & 0170000) == 0140000) /* fifo or socket */
+#endif
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int chmod(const char *, mode_t);
+int fstat(int, struct stat *);
+int mkdir(const char *, mode_t);
+int mkfifo(const char *, mode_t);
+int stat(const char *, struct stat *);
+mode_t umask(mode_t);
+__END_DECLS
+
+#endif /* !_MACH_SA_SYS_STAT_H_ */
diff --git a/include/mach/sa/sys/termios.h b/include/mach/sa/sys/termios.h
new file mode 100644
index 0000000..2d2e4bd
--- /dev/null
+++ b/include/mach/sa/sys/termios.h
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 1988, 1989, 1993, 1994
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 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.
+ *
+ * @(#)termios.h 8.3 (Berkeley) 3/28/94
+ * termios.h,v 1.3 1994/08/02 07:53:46 davidg Exp
+ */
+
+#ifndef _MACH_SA_SYS_TERMIOS_H_
+#define _MACH_SA_SYS_TERMIOS_H_
+
+/*
+ * Special Control Characters
+ *
+ * Index into c_cc[] character array.
+ *
+ * Name Subscript Enabled by
+ */
+#define VEOF 0 /* ICANON */
+#define VEOL 1 /* ICANON */
+#define VERASE 3 /* ICANON */
+#define VKILL 5 /* ICANON */
+#define VINTR 8 /* ISIG */
+#define VQUIT 9 /* ISIG */
+#define VSUSP 10 /* ISIG */
+#define VSTART 12 /* IXON, IXOFF */
+#define VSTOP 13 /* IXON, IXOFF */
+#define VMIN 16 /* !ICANON */
+#define VTIME 17 /* !ICANON */
+#define NCCS 20
+
+#define _POSIX_VDISABLE ((unsigned char)'\377')
+
+/*
+ * Input flags - software input processing
+ */
+#define IGNBRK 0x00000001 /* ignore BREAK condition */
+#define BRKINT 0x00000002 /* map BREAK to SIGINTR */
+#define IGNPAR 0x00000004 /* ignore (discard) parity errors */
+#define PARMRK 0x00000008 /* mark parity and framing errors */
+#define INPCK 0x00000010 /* enable checking of parity errors */
+#define ISTRIP 0x00000020 /* strip 8th bit off chars */
+#define INLCR 0x00000040 /* map NL into CR */
+#define IGNCR 0x00000080 /* ignore CR */
+#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
+#define IXON 0x00000200 /* enable output flow control */
+#define IXOFF 0x00000400 /* enable input flow control */
+#ifndef _POSIX_SOURCE
+#define IXANY 0x00000800 /* any char will restart after stop */
+#define IMAXBEL 0x00002000 /* ring bell on input queue full */
+#endif /*_POSIX_SOURCE */
+
+/*
+ * Output flags - software output processing
+ */
+#define OPOST 0x00000001 /* enable following output processing */
+
+/*
+ * Control flags - hardware control of terminal
+ */
+#ifndef _POSIX_SOURCE
+#define CIGNORE 0x00000001 /* ignore control flags */
+#endif
+#define CSIZE 0x00000300 /* character size mask */
+#define CS5 0x00000000 /* 5 bits (pseudo) */
+#define CS6 0x00000100 /* 6 bits */
+#define CS7 0x00000200 /* 7 bits */
+#define CS8 0x00000300 /* 8 bits */
+#define CSTOPB 0x00000400 /* send 2 stop bits */
+#define CREAD 0x00000800 /* enable receiver */
+#define PARENB 0x00001000 /* parity enable */
+#define PARODD 0x00002000 /* odd parity, else even */
+#define HUPCL 0x00004000 /* hang up on last close */
+#define CLOCAL 0x00008000 /* ignore modem status lines */
+
+
+/*
+ * "Local" flags - dumping ground for other state
+ *
+ * Warning: some flags in this structure begin with
+ * the letter "I" and look like they belong in the
+ * input flag.
+ */
+
+#define ECHOE 0x00000002 /* visually erase chars */
+#define ECHOK 0x00000004 /* echo NL after line kill */
+#define ECHO 0x00000008 /* enable echoing */
+#define ECHONL 0x00000010 /* echo NL even if ECHO is off */
+#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
+#define ICANON 0x00000100 /* canonicalize input lines */
+#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
+#define EXTPROC 0x00000800 /* external processing */
+#define TOSTOP 0x00400000 /* stop background jobs from output */
+#ifndef _POSIX_SOURCE
+#define FLUSHO 0x00800000 /* output being flushed (state) */
+#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
+#define PENDIN 0x20000000 /* XXX retype pending input (state) */
+#endif /*_POSIX_SOURCE */
+#define NOFLSH 0x80000000 /* don't flush after interrupt */
+
+typedef unsigned long tcflag_t;
+typedef unsigned char cc_t;
+typedef long speed_t;
+
+struct termios {
+ tcflag_t c_iflag; /* input flags */
+ tcflag_t c_oflag; /* output flags */
+ tcflag_t c_cflag; /* control flags */
+ tcflag_t c_lflag; /* local flags */
+ cc_t c_cc[NCCS]; /* control chars */
+ long c_ispeed; /* input speed */
+ long c_ospeed; /* output speed */
+};
+
+/*
+ * Commands passed to tcsetattr() for setting the termios structure.
+ */
+#define TCSANOW 0 /* make change immediate */
+#define TCSADRAIN 1 /* drain output, then change */
+#define TCSAFLUSH 2 /* drain output, flush input */
+#ifndef _POSIX_SOURCE
+#define TCSASOFT 0x10 /* flag - don't alter h.w. state */
+#endif
+
+/*
+ * Standard speeds
+ */
+#define B0 0
+#define B50 50
+#define B75 75
+#define B110 110
+#define B134 134
+#define B150 150
+#define B200 200
+#define B300 300
+#define B600 600
+#define B1200 1200
+#define B1800 1800
+#define B2400 2400
+#define B4800 4800
+#define B9600 9600
+#define B19200 19200
+#define B38400 38400
+#ifndef _POSIX_SOURCE
+#define B7200 7200
+#define B14400 14400
+#define B28800 28800
+#define B57600 57600
+#define B76800 76800
+#define B115200 115200
+#define B230400 230400
+#define EXTA 19200
+#define EXTB 38400
+#endif /* !_POSIX_SOURCE */
+
+#define TCIFLUSH 1
+#define TCOFLUSH 2
+#define TCIOFLUSH 3
+#define TCOOFF 1
+#define TCOON 2
+#define TCIOFF 3
+#define TCION 4
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+speed_t cfgetispeed(const struct termios *);
+speed_t cfgetospeed(const struct termios *);
+int cfsetispeed(struct termios *, speed_t);
+int cfsetospeed(struct termios *, speed_t);
+int tcgetattr(int, struct termios *);
+int tcsetattr(int, int, const struct termios *);
+int tcdrain(int);
+int tcflow(int, int);
+int tcflush(int, int);
+int tcsendbreak(int, int);
+__END_DECLS
+
+#endif /* !_MACH_SA_SYS_TERMIOS_H_ */
diff --git a/include/mach/sa/sys/time.h b/include/mach/sa/sys/time.h
new file mode 100644
index 0000000..ab96678
--- /dev/null
+++ b/include/mach/sa/sys/time.h
@@ -0,0 +1,53 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991 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.
+ */
+/*
+ * Time-keeper for kernel IO devices.
+ *
+ * May or may not have any relation to wall-clock time.
+ */
+
+#ifndef _MACH_SA_SYS_TIME_H_
+#define _MACH_SA_SYS_TIME_H_
+
+#include <mach/time_value.h>
+
+extern time_value_t time;
+
+/*
+ * Definitions to keep old code happy.
+ */
+#define timeval_t time_value_t
+#define timeval time_value
+#define tv_sec seconds
+#define tv_usec microseconds
+
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+
+#endif _MACH_SA_SYS_TIME_H_
diff --git a/include/mach/sa/sys/types.h b/include/mach/sa/sys/types.h
new file mode 100644
index 0000000..6973f89
--- /dev/null
+++ b/include/mach/sa/sys/types.h
@@ -0,0 +1,91 @@
+/*
+ * 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>
+
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef natural_t 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 int 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 struct _quad_ {
+ unsigned int val[2]; /* 2 32-bit values make... */
+} quad; /* an 8-byte item */
+
+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_ */
diff --git a/include/mach/sa/time.h b/include/mach/sa/time.h
new file mode 100644
index 0000000..2f02622
--- /dev/null
+++ b/include/mach/sa/time.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 1995 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_SA_TIME_H
+#define _MACH_SA_TIME_H
+
+#endif /* _MACH_SA_TIME_H */
diff --git a/include/mach/sa/unistd.h b/include/mach/sa/unistd.h
new file mode 100644
index 0000000..d3c313d
--- /dev/null
+++ b/include/mach/sa/unistd.h
@@ -0,0 +1,18 @@
+#ifndef _UNISTD_H_
+#define _UNISTD_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+__DECL(int,close(int fd));
+__DECL(int,read(int fd, void *buf, unsigned int n));
+__DECL(int,write(int fd, const void *buf, unsigned int n));
+__DECL(off_t,lseek(int fd, off_t offset, int whence));
+__DECL(int,rename(const char *oldpath, const char *newpath));
+__DECL(void *,sbrk(int size));
+
+__END_DECLS
+
+#endif /* _UNISTD_H_ */
diff --git a/include/mach/std_types.defs b/include/mach/std_types.defs
new file mode 100644
index 0000000..aef7dba
--- /dev/null
+++ b/include/mach/std_types.defs
@@ -0,0 +1,131 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif
+
+type char = MACH_MSG_TYPE_CHAR;
+type short = MACH_MSG_TYPE_INTEGER_16;
+type int = MACH_MSG_TYPE_INTEGER_32;
+type int32 = MACH_MSG_TYPE_INTEGER_32;
+type int64 = MACH_MSG_TYPE_INTEGER_64;
+type boolean_t = MACH_MSG_TYPE_BOOLEAN;
+type unsigned = MACH_MSG_TYPE_INTEGER_32;
+type unsigned32 = MACH_MSG_TYPE_INTEGER_32;
+type unsigned64 = 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;
+type mach_port_array_t = array[] of mach_port_t;
+
+type mach_port_name_t = MACH_MSG_TYPE_PORT_NAME
+ ctype: mach_port_t;
+type mach_port_name_array_t = array[] of mach_port_name_t
+ ctype: mach_port_array_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;
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+type port_name_t = MSG_TYPE_PORT_NAME
+ ctype: mach_port_t;
+type port_name_array_t = ^array[] of port_name_t
+ ctype: mach_port_array_t;
+type port_type_t = int
+ ctype: mach_port_type_t;
+type port_type_array_t = ^array[] of port_type_t
+ ctype: mach_port_type_array_t;
+type port_set_name_t = port_name_t
+ ctype: mach_port_t;
+
+type port_t = MACH_MSG_TYPE_COPY_SEND
+ ctype: mach_port_t;
+type port_all_t = MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t;
+type port_rcv_t = MACH_MSG_TYPE_MOVE_RECEIVE
+ ctype: mach_port_t;
+type port_array_t = ^array[] of port_t
+ ctype: mach_port_array_t;
+
+#endif MACH_IPC_COMPAT
+
+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..f78e236
--- /dev/null
+++ b/include/mach/std_types.h
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+#ifdef MACH_KERNEL
+#include <ipc/ipc_port.h>
+#endif /* MACH_KERNEL */
+
+#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..03527a5
--- /dev/null
+++ b/include/mach/syscall_sw.h
@@ -0,0 +1,140 @@
+/*
+ * 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(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 */
+
+/* Traps for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+kernel_trap(task_self,-10,0)
+kernel_trap(thread_reply,-11,0)
+kernel_trap(task_notify,-12,0)
+kernel_trap(thread_self,-13,0)
+kernel_trap(msg_send_trap,-20,4)
+kernel_trap(msg_receive_trap,-21,5)
+kernel_trap(msg_rpc_trap,-22,6)
+kernel_trap(host_self,-55,0)
+
+#endif /* MACH_IPC_COMPAT */
+
+#ifdef FIPC
+kernel_trap(fipc_send,-96,4)
+kernel_trap(fipc_recv,-97,5)
+#endif
+
+#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..fdcbeb1
--- /dev/null
+++ b/include/mach/task_info.h
@@ -0,0 +1,111 @@
+/*
+ * 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 */
+ vm_size_t virtual_size; /* number of virtual pages */
+ vm_size_t resident_size; /* number of resident pages */
+ time_value_t user_time; /* total user run time for
+ terminated threads */
+ time_value_t system_time; /* total system run time for
+ terminated threads */
+};
+
+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(natural_t))
+
+
+#define TASK_EVENTS_INFO 2 /* various event counts */
+
+struct task_events_info {
+ natural_t faults; /* number of page faults */
+ natural_t zero_fills; /* number of zero fill pages */
+ natural_t reactivations; /* number of reactivated pages */
+ natural_t pageins; /* number of actual pageins */
+ natural_t cow_faults; /* number of copy-on-write faults */
+ natural_t messages_sent; /* number of messages sent */
+ 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(natural_t))
+
+#define TASK_THREAD_TIMES_INFO 3 /* total times for live threads -
+ only accurate if suspended */
+
+struct task_thread_times_info {
+ time_value_t user_time; /* total user run time for
+ live threads */
+ time_value_t system_time; /* 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(natural_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_special_ports.h b/include/mach/task_special_ports.h
new file mode 100644
index 0000000..682c7f6
--- /dev/null
+++ b/include/mach/task_special_ports.h
@@ -0,0 +1,86 @@
+/*
+ * 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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#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)))
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+#define TASK_NOTIFY_PORT 2 /* Task receives kernel IPC
+ notifications here. */
+
+#define task_get_notify_port(task, port) \
+ (task_get_special_port((task), TASK_NOTIFY_PORT, (port)))
+
+#define task_set_notify_port(task, port) \
+ (task_set_special_port((task), TASK_NOTIFY_PORT, (port)))
+
+#endif /* MACH_IPC_COMPAT */
+
+#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..2c79829
--- /dev/null
+++ b/include/mach/thread_info.h
@@ -0,0 +1,116 @@
+/*
+ * 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 {
+ time_value_t user_time; /* user run time */
+ 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 */
+};
+
+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 */
+};
+
+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..0ab3646
--- /dev/null
+++ b/include/mach/thread_special_ports.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/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_
+
+#ifdef MACH_KERNEL
+#include <mach_ipc_compat.h>
+#endif /* MACH_KERNEL */
+
+#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)))
+
+
+/* Definitions for the old IPC interface. */
+
+#if MACH_IPC_COMPAT
+
+#define THREAD_REPLY_PORT 2 /* Default reply port for the thread's
+ use. */
+
+#define thread_get_reply_port(thread, port) \
+ (thread_get_special_port((thread), THREAD_REPLY_PORT, (port)))
+
+#define thread_set_reply_port(thread, port) \
+ (thread_set_special_port((thread), THREAD_REPLY_PORT, (port)))
+
+#endif /* MACH_IPC_COMPAT */
+
+#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..2a2f091
--- /dev/null
+++ b/include/mach/time_value.h
@@ -0,0 +1,80 @@
+/*
+ * 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 time_value {
+ integer_t seconds;
+ integer_t microseconds;
+};
+typedef struct time_value time_value_t;
+
+/*
+ * Macros to manipulate time values. Assume that time values
+ * are normalized (microseconds <= 999999).
+ */
+#define TIME_MICROS_MAX (1000000)
+
+#define time_value_add_usec(val, micros) { \
+ if (((val)->microseconds += (micros)) \
+ >= TIME_MICROS_MAX) { \
+ (val)->microseconds -= TIME_MICROS_MAX; \
+ (val)->seconds++; \
+ } \
+}
+
+#define time_value_add(result, addend) { \
+ (result)->microseconds += (addend)->microseconds; \
+ (result)->seconds += (addend)->seconds; \
+ if ((result)->microseconds >= TIME_MICROS_MAX) { \
+ (result)->microseconds -= TIME_MICROS_MAX; \
+ (result)->seconds++; \
+ } \
+}
+
+/*
+ * Time value available through the mapped-time interface.
+ * Read this mapped value with
+ * do {
+ * secs = mtime->seconds;
+ * usecs = mtime->microseconds;
+ * } while (secs != mtime->check_seconds);
+ */
+
+typedef struct mapped_time_value {
+ integer_t seconds;
+ integer_t microseconds;
+ integer_t check_seconds;
+} mapped_time_value_t;
+
+#endif /* _MACH_TIME_VALUE_H_ */
diff --git a/include/mach/version.h b/include/mach/version.h
new file mode 100644
index 0000000..ec12ea7
--- /dev/null
+++ b/include/mach/version.h
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+#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
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_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..0360981
--- /dev/null
+++ b/include/mach/vm_param.h
@@ -0,0 +1,98 @@
+/*
+ * 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 refered 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))
+
+/*
+ * 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)
+
+#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_ */