summaryrefslogtreecommitdiff
path: root/i386/include/mach
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1997-02-25 21:28:37 +0000
committerThomas Bushnell <thomas@gnu.org>1997-02-25 21:28:37 +0000
commitf07a4c844da9f0ecae5bbee1ab94be56505f26f7 (patch)
tree12b07c7e578fc1a5f53dbfde2632408491ff2a70 /i386/include/mach
Initial source
Diffstat (limited to 'i386/include/mach')
-rw-r--r--i386/include/mach/i386/asm.h114
-rw-r--r--i386/include/mach/i386/bios.h64
-rw-r--r--i386/include/mach/i386/boolean.h37
-rw-r--r--i386/include/mach/i386/code16.h29
-rw-r--r--i386/include/mach/i386/cthreads.h58
-rw-r--r--i386/include/mach/i386/debug_reg.h196
-rw-r--r--i386/include/mach/i386/disk.h120
-rw-r--r--i386/include/mach/i386/dpmi.h537
-rw-r--r--i386/include/mach/i386/eflags.h49
-rw-r--r--i386/include/mach/i386/exception.h85
-rw-r--r--i386/include/mach/i386/exec/elf.h36
-rw-r--r--i386/include/mach/i386/far_ptr.h35
-rw-r--r--i386/include/mach/i386/fp_reg.h108
-rw-r--r--i386/include/mach/i386/ioccom.h32
-rw-r--r--i386/include/mach/i386/kern_return.h40
-rw-r--r--i386/include/mach/i386/mach_i386.defs68
-rw-r--r--i386/include/mach/i386/mach_i386_types.h49
-rwxr-xr-xi386/include/mach/i386/machine_types.defs71
-rw-r--r--i386/include/mach/i386/multiboot.h182
-rw-r--r--i386/include/mach/i386/paging.h134
-rw-r--r--i386/include/mach/i386/pio.h70
-rw-r--r--i386/include/mach/i386/pmode.h93
-rw-r--r--i386/include/mach/i386/proc_reg.h340
-rw-r--r--i386/include/mach/i386/rpc.h9
-rw-r--r--i386/include/mach/i386/seg.h190
-rw-r--r--i386/include/mach/i386/syscall_sw.h47
-rw-r--r--i386/include/mach/i386/thread_status.h147
-rw-r--r--i386/include/mach/i386/time_stamp.h29
-rw-r--r--i386/include/mach/i386/trap.h60
-rw-r--r--i386/include/mach/i386/tss.h67
-rw-r--r--i386/include/mach/i386/vcpi.h37
-rw-r--r--i386/include/mach/i386/vm_param.h73
-rw-r--r--i386/include/mach/i386/vm_types.h108
-rw-r--r--i386/include/mach/proc_ops.h40
-rw-r--r--i386/include/mach/sa/stdarg.h46
-rw-r--r--i386/include/mach/sa/sys/varargs.h41
-rw-r--r--i386/include/mach/setjmp.h58
37 files changed, 3499 insertions, 0 deletions
diff --git a/i386/include/mach/i386/asm.h b/i386/include/mach/i386/asm.h
new file mode 100644
index 0000000..c775535
--- /dev/null
+++ b/i386/include/mach/i386/asm.h
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+
+#define S_ARG0 4(%esp)
+#define S_ARG1 8(%esp)
+#define S_ARG2 12(%esp)
+#define S_ARG3 16(%esp)
+
+#define FRAME pushl %ebp; movl %esp, %ebp
+#define EMARF leave
+
+#define B_ARG0 8(%ebp)
+#define B_ARG1 12(%ebp)
+#define B_ARG2 16(%ebp)
+#define B_ARG3 20(%ebp)
+
+#ifdef i486
+#define TEXT_ALIGN 4
+#else
+#define TEXT_ALIGN 2
+#endif
+#define DATA_ALIGN 2
+#define ALIGN TEXT_ALIGN
+
+#define P2ALIGN(p2) .p2align p2 /* gas-specific */
+
+#define LCL(x) x
+
+#define LB(x,n) n
+#ifdef __STDC__
+#ifndef __ELF__
+#define EXT(x) _ ## x
+#define LEXT(x) _ ## x ## :
+#define SEXT(x) "_"#x
+#else
+#define EXT(x) x
+#define LEXT(x) x ## :
+#define SEXT(x) #x
+#endif
+#define LCLL(x) x ## :
+#define gLB(n) n ## :
+#define LBb(x,n) n ## b
+#define LBf(x,n) n ## f
+#else __STDC__
+#error XXX elf
+#define EXT(x) _/**/x
+#define LEXT(x) _/**/x/**/:
+#define LCLL(x) x/**/:
+#define gLB(n) n/**/:
+#define LBb(x,n) n/**/b
+#define LBf(x,n) n/**/f
+#endif __STDC__
+#define SVC .byte 0x9a; .long 0; .word 0x7
+
+#define String .ascii
+#define Value .word
+#define Times(a,b) (a*b)
+#define Divide(a,b) (a/b)
+
+#define INB inb %dx, %al
+#define OUTB outb %al, %dx
+#define INL inl %dx, %eax
+#define OUTL outl %eax, %dx
+
+#define data16 .byte 0x66
+#define addr16 .byte 0x67
+
+
+
+#ifdef GPROF
+
+#define MCOUNT .data; gLB(9) .long 0; .text; lea LBb(x, 9),%edx; call mcount
+#define ENTRY(x) .globl EXT(x); .p2align TEXT_ALIGN; LEXT(x) ; \
+ pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
+#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \
+ .p2align TEXT_ALIGN; LEXT(x) LEXT(y)
+#define ASENTRY(x) .globl x; .p2align TEXT_ALIGN; gLB(x) ; \
+ pushl %ebp; movl %esp, %ebp; MCOUNT; popl %ebp;
+
+#else GPROF
+
+#define MCOUNT
+#define ENTRY(x) .globl EXT(x); .p2align TEXT_ALIGN; LEXT(x)
+#define ENTRY2(x,y) .globl EXT(x); .globl EXT(y); \
+ .p2align TEXT_ALIGN; LEXT(x) LEXT(y)
+#define ASENTRY(x) .globl x; .p2align TEXT_ALIGN; gLB(x)
+#endif GPROF
+
+#define Entry(x) .globl EXT(x); .p2align TEXT_ALIGN; LEXT(x)
+#define DATA(x) .globl EXT(x); .p2align DATA_ALIGN; LEXT(x)
diff --git a/i386/include/mach/i386/bios.h b/i386/include/mach/i386/bios.h
new file mode 100644
index 0000000..6ad4445
--- /dev/null
+++ b/i386/include/mach/i386/bios.h
@@ -0,0 +1,64 @@
+/*
+ * 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_MACHINE_BIOS_
+#define _MACH_MACHINE_BIOS_
+
+/*
+ * To make a call to a 16-bit BIOS entrypoint,
+ * fill in one of these structures and call bios_call().
+ */
+struct bios_call_params
+{
+ union
+ {
+ struct
+ {
+ unsigned short ax;
+ unsigned short bx;
+ unsigned short cx;
+ unsigned short dx;
+ } w;
+ struct
+ {
+ unsigned char al;
+ unsigned char ah;
+ unsigned char bl;
+ unsigned char bh;
+ unsigned char cl;
+ unsigned char ch;
+ unsigned char dl;
+ unsigned char dh;
+ } b;
+ } u;
+ unsigned short si;
+ unsigned short di;
+ unsigned short bp;
+ unsigned short ds;
+ unsigned short es;
+ unsigned short flags;
+};
+
+void bios_call(unsigned char int_num, struct bios_call_params *bcp);
+
+#endif _MACH_MACHINE_BIOS_
diff --git a/i386/include/mach/i386/boolean.h b/i386/include/mach/i386/boolean.h
new file mode 100644
index 0000000..a33d007
--- /dev/null
+++ b/i386/include/mach/i386/boolean.h
@@ -0,0 +1,37 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: boolean.h
+ *
+ * Boolean type, for I386.
+ */
+
+#ifndef _MACH_I386_BOOLEAN_H_
+#define _MACH_I386_BOOLEAN_H_
+
+typedef int boolean_t;
+
+#endif /* _MACH_I386_BOOLEAN_H_ */
diff --git a/i386/include/mach/i386/code16.h b/i386/include/mach/i386/code16.h
new file mode 100644
index 0000000..7bc2dc1
--- /dev/null
+++ b/i386/include/mach/i386/code16.h
@@ -0,0 +1,29 @@
+/*
+ * 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_I386_CODE16_H_
+#define _MACH_I386_CODE16_H_
+
+/* Switch GAS into 16-bit mode. */
+#define CODE16 asm(".code16");
+
+/* Switch back to 32-bit mode. */
+#define CODE32 asm(".code32");
+
+#endif _MACH_I386_CODE16_H_
diff --git a/i386/include/mach/i386/cthreads.h b/i386/include/mach/i386/cthreads.h
new file mode 100644
index 0000000..62a29cb
--- /dev/null
+++ b/i386/include/mach/i386/cthreads.h
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+#ifndef _MACHINE_CTHREADS_H_
+#define _MACHINE_CTHREADS_H_
+
+typedef volatile int spin_lock_t;
+#define SPIN_LOCK_INITIALIZER 0
+#define spin_lock_init(s) (*(s) = 0)
+#define spin_lock_locked(s) (*(s) != 0)
+
+#ifdef __GNUC__
+
+#define spin_unlock(p) \
+ ({ register int _u__ ; \
+ __asm__ volatile("xorl %0, %0; \n\
+ xchgl %0, %1" \
+ : "=&r" (_u__), "=m" (*(p)) ); \
+ 0; })
+
+#define spin_try_lock(p)\
+ (!({ boolean_t _r__; \
+ __asm__ volatile("movl $1, %0; \n\
+ xchgl %0, %1" \
+ : "=&r" (_r__), "=m" (*(p)) ); \
+ _r__; }))
+
+#define cthread_sp() \
+ ({ int _sp__; \
+ __asm__("movl %%esp, %0" \
+ : "=g" (_sp__) ); \
+ _sp__; })
+
+#endif /* __GNUC__ */
+
+#endif _MACHINE_CTHREADS_H_
diff --git a/i386/include/mach/i386/debug_reg.h b/i386/include/mach/i386/debug_reg.h
new file mode 100644
index 0000000..ab4293a
--- /dev/null
+++ b/i386/include/mach/i386/debug_reg.h
@@ -0,0 +1,196 @@
+/*
+ * 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_I386_DEBUG_REG_H_
+#define _MACH_I386_DEBUG_REG_H_
+
+/* Bits in DR7 - debug control register */
+#define DR7_LEN3 0xc0000000
+#define DR7_RW3 0x30000000
+#define DR7_LEN2 0x0c000000
+#define DR7_RW2 0x03000000
+#define DR7_LEN1 0x00c00000
+#define DR7_RW1 0x00300000
+#define DR7_LEN0 0x000c0000
+#define DR7_RW0 0x00030000
+#define DR7_GD 0x00002000
+#define DR7_GE 0x00000200
+#define DR7_LE 0x00000100
+#define DR7_G3 0x00000080
+#define DR7_L3 0x00000040
+#define DR7_G2 0x00000020
+#define DR7_L2 0x00000010
+#define DR7_G1 0x00000008
+#define DR7_L1 0x00000004
+#define DR7_G0 0x00000002
+#define DR7_L0 0x00000001
+
+/* Shift values for multibit fields in DR7 */
+#define DR7_LEN3_SHIFT 30
+#define DR7_RW3_SHIFT 28
+#define DR7_LEN2_SHIFT 26
+#define DR7_RW2_SHIFT 24
+#define DR7_LEN1_SHIFT 22
+#define DR7_RW1_SHIFT 20
+#define DR7_LEN0_SHIFT 18
+#define DR7_RW0_SHIFT 16
+
+/* Values for LEN fields in DR7 */
+#define DR7_LEN_1 0
+#define DR7_LEN_2 1
+#define DR7_LEN_4 3
+
+/* Values for RW fields in DR7 */
+#define DR7_RW_INST 0 /* Break on instruction execution */
+#define DR7_RW_WRITE 1 /* Break on data writes */
+#define DR7_RW_IO 2 /* Break on I/O reads and writes (Pentium only) */
+#define DR7_RW_DATA 3 /* Break on data reads and writes */
+
+
+/* Bits in DR6 - debug status register */
+#define DR6_BT 0x00008000
+#define DR6_BS 0x00004000
+#define DR6_BD 0x00002000
+#define DR6_B3 0x00000008
+#define DR6_B2 0x00000004
+#define DR6_B1 0x00000002
+#define DR6_B0 0x00000001
+
+
+#include <mach/inline.h>
+
+/* Functions to set debug registers. */
+
+MACH_INLINE unsigned get_dr0()
+{
+ unsigned val;
+ asm volatile("movl %%dr0,%0" : "=r" (val));
+ return val;
+}
+
+MACH_INLINE unsigned get_dr1()
+{
+ unsigned val;
+ asm volatile("movl %%dr1,%0" : "=r" (val));
+ return val;
+}
+
+MACH_INLINE unsigned get_dr2()
+{
+ unsigned val;
+ asm volatile("movl %%dr2,%0" : "=r" (val));
+ return val;
+}
+
+MACH_INLINE unsigned get_dr3()
+{
+ unsigned val;
+ asm volatile("movl %%dr3,%0" : "=r" (val));
+ return val;
+}
+
+MACH_INLINE unsigned get_dr6()
+{
+ unsigned val;
+ asm volatile("movl %%dr6,%0" : "=r" (val));
+ return val;
+}
+
+MACH_INLINE unsigned get_dr7()
+{
+ unsigned val;
+ asm volatile("movl %%dr7,%0" : "=r" (val));
+ return val;
+}
+
+MACH_INLINE void set_dr0(unsigned val)
+{
+ asm volatile("movl %0,%%dr0" : : "r" (val));
+}
+
+
+/* Functions to read debug registers. */
+
+MACH_INLINE void set_dr1(unsigned val)
+{
+ asm volatile("movl %0,%%dr1" : : "r" (val));
+}
+
+MACH_INLINE void set_dr2(unsigned val)
+{
+ asm volatile("movl %0,%%dr2" : : "r" (val));
+}
+
+MACH_INLINE void set_dr3(unsigned val)
+{
+ asm volatile("movl %0,%%dr3" : : "r" (val));
+}
+
+MACH_INLINE void set_dr6(unsigned val)
+{
+ asm volatile("movl %0,%%dr6" : : "r" (val));
+}
+
+MACH_INLINE void set_dr7(unsigned val)
+{
+ asm volatile("movl %0,%%dr7" : : "r" (val));
+}
+
+
+/* Functions to set global breakpoints. */
+
+MACH_INLINE void set_b0(unsigned addr, unsigned len, unsigned rw)
+{
+ set_dr0(addr);
+ addr = ((get_dr7() & ~(DR7_LEN0 | DR7_RW0))
+ | (len << DR7_LEN0_SHIFT) | (rw << DR7_RW0_SHIFT)
+ | DR7_GE | DR7_G0);
+ set_dr7(addr);
+}
+
+MACH_INLINE void set_b1(unsigned addr, unsigned len, unsigned rw)
+{
+ set_dr1(addr);
+ set_dr7((get_dr7() & ~(DR7_LEN1 | DR7_RW1))
+ | (len << DR7_LEN1_SHIFT) | (rw << DR7_RW1_SHIFT)
+ | DR7_GE | DR7_G1);
+}
+
+MACH_INLINE void set_b2(unsigned addr, unsigned len, unsigned rw)
+{
+ set_dr2(addr);
+ set_dr7((get_dr7() & ~(DR7_LEN2 | DR7_RW2))
+ | (len << DR7_LEN2_SHIFT) | (rw << DR7_RW2_SHIFT)
+ | DR7_GE | DR7_G2);
+}
+
+MACH_INLINE void set_b3(unsigned addr, unsigned len, unsigned rw)
+{
+ set_dr3(addr);
+ set_dr7((get_dr7() & ~(DR7_LEN3 | DR7_RW3))
+ | (len << DR7_LEN3_SHIFT) | (rw << DR7_RW3_SHIFT)
+ | DR7_GE | DR7_G3);
+}
+
+
+
+#endif /* _MACH_I386_DEBUG_REG_H_ */
diff --git a/i386/include/mach/i386/disk.h b/i386/include/mach/i386/disk.h
new file mode 100644
index 0000000..40ed4fa
--- /dev/null
+++ b/i386/include/mach/i386/disk.h
@@ -0,0 +1,120 @@
+/*
+ * 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 1988, 1989 by Intel Corporation, Santa Clara, California.
+
+ 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 Intel
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+
+INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL INTEL 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.
+*/
+
+/*
+ * disk.h
+ */
+
+#if defined(__linux__) || defined(__masix__)
+#define PART_DISK 4 /* partition number for entire disk */
+#else
+#define PART_DISK 2 /* partition number for entire disk */
+#endif
+
+
+/* driver ioctl() commands */
+
+#define V_CONFIG _IOW('v',1,union io_arg)/* Configure Drive */
+#define V_REMOUNT _IO('v',2) /* Remount Drive */
+#define V_ADDBAD _IOW('v',3,union io_arg)/* Add Bad Sector */
+#define V_GETPARMS _IOR('v',4,struct disk_parms) /* Get drive/partition parameters */
+#define V_FORMAT _IOW('v',5,union io_arg)/* Format track(s) */
+#define V_PDLOC _IOR('v',6,int) /* Ask driver where pdinfo is on disk */
+
+#define V_ABS _IOW('v',9,int) /* set a sector for an absolute addr */
+#define V_RDABS _IOW('v',10,struct absio)/* Read a sector at an absolute addr */
+#define V_WRABS _IOW('v',11,struct absio)/* Write a sector to absolute addr */
+#define V_VERIFY _IOWR('v',12,union vfy_io)/* Read verify sector(s) */
+#define V_XFORMAT _IO('v',13) /* Selectively mark sectors as bad */
+#define V_SETPARMS _IOW('v',14,int) /* Set drivers parameters */
+
+
+/*
+ * Data structure for the V_VERIFY ioctl
+ */
+union vfy_io {
+ struct {
+ long abs_sec; /* absolute sector number */
+ u_short num_sec; /* number of sectors to verify */
+ u_short time_flg; /* flag to indicate time the ops */
+ }vfy_in;
+ struct {
+ long deltatime; /* duration of operation */
+ u_short err_code; /* reason for failure */
+ }vfy_out;
+};
+
+
+/* data structure returned by the Get Parameters ioctl: */
+struct disk_parms {
+/*00*/ char dp_type; /* Disk type (see below) */
+ u_char dp_heads; /* Number of heads */
+ u_short dp_cyls; /* Number of cylinders */
+/*04*/ u_char dp_sectors; /* Number of sectors/track */
+ u_short dp_secsiz; /* Number of bytes/sector */
+ /* for this partition: */
+/*08*/ u_short dp_ptag; /* Partition tag */
+ u_short dp_pflag; /* Partition flag */
+/*0c*/ long dp_pstartsec; /* Starting absolute sector number */
+/*10*/ long dp_pnumsec; /* Number of sectors */
+/*14*/ u_char dp_dosheads; /* Number of heads */
+ u_short dp_doscyls; /* Number of cylinders */
+/*18*/ u_char dp_dossectors; /* Number of sectors/track */
+};
+
+/* Disk types for disk_parms.dp_type: */
+#define DPT_WINI 1 /* Winchester disk */
+#define DPT_FLOPPY 2 /* Floppy */
+#define DPT_OTHER 3 /* Other type of disk */
+#define DPT_NOTDISK 0 /* Not a disk device */
+
+/* Data structure for V_RDABS/V_WRABS ioctl's */
+struct absio {
+ long abs_sec; /* Absolute sector number (from 0) */
+ char *abs_buf; /* Sector buffer */
+};
+
diff --git a/i386/include/mach/i386/dpmi.h b/i386/include/mach/i386/dpmi.h
new file mode 100644
index 0000000..51a638c
--- /dev/null
+++ b/i386/include/mach/i386/dpmi.h
@@ -0,0 +1,537 @@
+/*
+ * Copyright (c) 1996-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 _FLUX_KERNEL_I386_DOS_I16_DPMI_H_
+#define _FLUX_KERNEL_I386_DOS_I16_DPMI_H_
+
+#include <mach/inline.h>
+#include <mach/machine/seg.h>
+
+typedef unsigned short dpmi_error_t;
+
+#define DPMI_UNSUPPORTED_FUNCTION 0x8001
+#define DPMI_OBJECT_WRONG_STATE 0x8002
+#define DPMI_SYSTEM_INTEGRITY 0x8003
+#define DPMI_DEADLOCK 0x8004
+#define DPMI_SERIALIZATION_CANCELLED 0x8005
+#define DPMI_OUT_OF_RESOURCES 0x8010
+#define DPMI_DESCRIPTOR_UNAVAILABLE 0x8011
+#define DPMI_LINEAR_MEMORY_UNAVAILABLE 0x8012
+#define DPMI_PHYSICAL_MEMORY_UNAVAILABLE 0x8013
+#define DPMI_BACKING_STORE_UNAVAILABLE 0x8014
+#define DPMI_CALLBACK_UNAVAILABLE 0x8015
+#define DPMI_HANDLE_UNAVAILABLE 0x8016
+#define DPMI_MAX_LOCK_COUNT_EXCEEDED 0x8017
+#define DPMI_ALREADY_SERIALIZED_EXCLUSIVELY 0x8018
+#define DPMI_ALREADY_SERIALIZED_SHARED 0x8019
+#define DPMI_INVALID_VALUE 0x8021
+#define DPMI_INVALID_SELECTOR 0x8022
+#define DPMI_INVALID_HANDLE 0x8023
+#define DPMI_INVALID_CALLBACK 0x8024
+#define DPMI_INVALID_LINEAR_ADDRESS 0x8025
+#define DPMI_NOT_SUPPORTED_BY_HARDWARE 0x8026
+
+struct real_call_data; /*XXX*/
+
+MACH_INLINE dpmi_error_t dpmi_switch_to_pmode(
+ struct far_pointer_16 *pmode_entry_vector,
+ unsigned short host_data_seg)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ movw %3,%%es
+ lcallw %2
+ jc 1f
+ xorw %%ax,%%ax
+ 1: pushw %%ds
+ popw %%es
+ " : "=a" (err)
+ : "a" (1),
+ "m" (*pmode_entry_vector),
+ "rm" (host_data_seg));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_allocate_descriptors(
+ unsigned short count,
+ unsigned short *out_selector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ movw %%ax,%1
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=rm" (*out_selector)
+ : "a" (0x0000),
+ "c" (count));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_get_segment_base(
+ unsigned short selector,
+ unsigned long *out_base)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ shll $16,%ecx
+ movw %dx,%cx
+ 1:
+ " : "=a" (err),
+ "=c" (*out_base)
+ : "a" (0x0006),
+ "b" (selector)
+ : "edx");
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_set_segment_base(
+ unsigned short selector,
+ unsigned long base)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0007),
+ "b" (selector),
+ "c" (base >> 16),
+ "d" (base));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_set_segment_limit(
+ unsigned short selector,
+ unsigned limit)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0008),
+ "b" (selector),
+ "c" (limit >> 16),
+ "d" (limit));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_create_code_segment_alias(
+ unsigned short code_selector,
+ unsigned short *out_data_selector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ movw %%ax,%1
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=rm" (*out_data_selector)
+ : "a" (0x000a),
+ "b" (code_selector));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_get_descriptor(
+ unsigned short selector,
+ struct i386_descriptor *out_descriptor)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x000b),
+ "b" (selector),
+ "D" (out_descriptor));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_set_descriptor(
+ unsigned short selector,
+ struct i386_descriptor *descriptor)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x000c),
+ "b" (selector),
+ "D" (descriptor));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_allocate_specific_descriptor(
+ unsigned short selector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x000d),
+ "b" (selector));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_get_exception_handler(
+ unsigned char trapno,
+ struct far_pointer_32 *out_vector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=c" (out_vector->seg),
+ "=d" (out_vector->ofs)
+ : "a" (0x0202),
+ "b" (trapno));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_set_exception_handler(
+ unsigned char trapno,
+ struct far_pointer_32 *vector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0203),
+ "b" (trapno),
+ "c" (vector->seg),
+ "d" (vector->ofs));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_get_interrupt_handler(
+ unsigned char intvec,
+ struct far_pointer_32 *out_vector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=c" (out_vector->seg),
+ "=d" (out_vector->ofs)
+ : "a" (0x0204),
+ "b" (intvec));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_set_interrupt_handler(
+ unsigned char intvec,
+ struct far_pointer_32 *vector)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0205),
+ "b" (intvec),
+ "c" (vector->seg),
+ "d" (vector->ofs));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_simulate_real_mode_interrupt(
+ unsigned char intnum,
+ struct real_call_data *call_data)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0300),
+ "b" ((unsigned short)intnum),
+ "c" (0),
+ "D" (call_data));
+
+ return err;
+}
+
+struct dpmi_version_status
+{
+ unsigned char minor_version;
+ unsigned char major_version;
+ unsigned short flags;
+ unsigned char slave_pic_base;
+ unsigned char master_pic_base;
+ unsigned char processor_type;
+};
+
+MACH_INLINE void dpmi_get_version(struct dpmi_version_status *status)
+{
+ asm volatile("
+ int $0x31
+ " : "=a" (*((short*)&status->minor_version)),
+ "=b" (status->flags),
+ "=c" (status->processor_type),
+ "=d" (*((short*)&status->slave_pic_base))
+ : "a" (0x0400));
+}
+
+MACH_INLINE dpmi_error_t dpmi_allocate_memory(
+ unsigned size,
+ unsigned *out_linear_addr,
+ unsigned *out_mem_handle)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ shll $16,%%ebx
+ movw %%cx,%%bx
+ shll $16,%%esi
+ movw %%di,%%si
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=b" (*out_linear_addr),
+ "=S" (*out_mem_handle)
+ : "a" (0x0501),
+ "b" (size >> 16),
+ "c" (size)
+ : "ebx", "ecx", "esi", "edi");
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_free_memory(
+ unsigned mem_handle)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0502),
+ "S" (mem_handle >> 16),
+ "D" (mem_handle));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_allocate_linear_memory(
+ unsigned linear_addr,
+ unsigned size,
+ unsigned flags,
+ unsigned *out_linear_addr,
+ unsigned *out_mem_handle)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=b" (*out_linear_addr),
+ "=S" (*out_mem_handle)
+ : "a" (0x0504),
+ "b" (linear_addr),
+ "c" (size),
+ "d" (flags));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_resize_linear_memory(
+ unsigned handle,
+ unsigned new_size,
+ unsigned flags,
+ unsigned short *update_selector_array,
+ unsigned update_selector_count,
+ unsigned *out_new_linear_addr)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=b" (*out_new_linear_addr)
+ : "a" (0x0505),
+ "b" (update_selector_array),
+ "c" (new_size),
+ "d" (flags),
+ "S" (handle),
+ "D" (update_selector_count));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_map_conventional_memory(
+ unsigned handle,
+ vm_offset_t offset,
+ vm_offset_t low_addr,
+ vm_size_t page_count)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0509),
+ "S" (handle),
+ "b" (offset),
+ "c" (page_count),
+ "d" (low_addr));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_lock_linear_region(
+ vm_offset_t start_la,
+ vm_size_t size)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0600),
+ "b" (start_la >> 16),
+ "c" (start_la),
+ "S" (size >> 16),
+ "D" (size));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_unlock_linear_region(
+ vm_offset_t start_la,
+ vm_size_t size)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err)
+ : "a" (0x0601),
+ "b" (start_la >> 16),
+ "c" (start_la),
+ "S" (size >> 16),
+ "D" (size));
+
+ return err;
+}
+
+MACH_INLINE dpmi_error_t dpmi_get_page_size(
+ unsigned *out_page_size)
+{
+ dpmi_error_t err;
+
+ asm volatile("
+ int $0x31
+ jc 1f
+ shll $16,%%ebx
+ movw %%cx,%%bx
+ xorw %%ax,%%ax
+ 1:
+ " : "=a" (err),
+ "=b" (*out_page_size)
+ : "a" (0x0604)
+ : "ecx");
+
+ return err;
+}
+
+
+#endif /* _FLUX_KERNEL_I386_DOS_I16_DPMI_H_ */
diff --git a/i386/include/mach/i386/eflags.h b/i386/include/mach/i386/eflags.h
new file mode 100644
index 0000000..d7d54b2
--- /dev/null
+++ b/i386/include/mach/i386/eflags.h
@@ -0,0 +1,49 @@
+/*
+ * 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_I386_EFLAGS_H_
+#define _MACH_I386_EFLAGS_H_
+
+/*
+ * i386 flags register
+ */
+#define EFL_CF 0x00000001 /* carry */
+#define EFL_PF 0x00000004 /* parity of low 8 bits */
+#define EFL_AF 0x00000010 /* carry out of bit 3 */
+#define EFL_ZF 0x00000040 /* zero */
+#define EFL_SF 0x00000080 /* sign */
+#define EFL_TF 0x00000100 /* trace trap */
+#define EFL_IF 0x00000200 /* interrupt enable */
+#define EFL_DF 0x00000400 /* direction */
+#define EFL_OF 0x00000800 /* overflow */
+#define EFL_IOPL 0x00003000 /* IO privilege level: */
+#define EFL_IOPL_KERNEL 0x00000000 /* kernel */
+#define EFL_IOPL_USER 0x00003000 /* user */
+#define EFL_NT 0x00004000 /* nested task */
+#define EFL_RF 0x00010000 /* resume without tracing */
+#define EFL_VM 0x00020000 /* virtual 8086 mode */
+
+#endif _MACH_I386_EFLAGS_H_
diff --git a/i386/include/mach/i386/exception.h b/i386/include/mach/i386/exception.h
new file mode 100644
index 0000000..1aaf6c7
--- /dev/null
+++ b/i386/include/mach/i386/exception.h
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+/*
+ * Codes and subcodes for 80386 exceptions.
+ */
+
+/*
+ * EXC_BAD_INSTRUCTION
+ */
+
+#ifndef _MACH_I386_EXCEPTION_H_
+#define _MACH_I386_EXCEPTION_H_
+
+#define EXC_I386_INVOP 1
+
+/*
+ * EXC_ARITHMETIC
+ */
+
+#define EXC_I386_DIV 1
+#define EXC_I386_INTO 2
+#define EXC_I386_NOEXT 3
+#define EXC_I386_EXTOVR 4
+#define EXC_I386_EXTERR 5
+#define EXC_I386_EMERR 6
+#define EXC_I386_BOUND 7
+
+/*
+ * EXC_SOFTWARE
+ */
+
+/*
+ * EXC_BAD_ACCESS
+ */
+
+/*
+ * EXC_BREAKPOINT
+ */
+
+#define EXC_I386_SGL 1
+#define EXC_I386_BPT 2
+
+#define EXC_I386_DIVERR 0 /* divide by 0 eprror */
+#define EXC_I386_SGLSTP 1 /* single step */
+#define EXC_I386_NMIFLT 2 /* NMI */
+#define EXC_I386_BPTFLT 3 /* breakpoint fault */
+#define EXC_I386_INTOFLT 4 /* INTO overflow fault */
+#define EXC_I386_BOUNDFLT 5 /* BOUND instruction fault */
+#define EXC_I386_INVOPFLT 6 /* invalid opcode fault */
+#define EXC_I386_NOEXTFLT 7 /* extension not available fault*/
+#define EXC_I386_DBLFLT 8 /* double fault */
+#define EXC_I386_EXTOVRFLT 9 /* extension overrun fault */
+#define EXC_I386_INVTSSFLT 10 /* invalid TSS fault */
+#define EXC_I386_SEGNPFLT 11 /* segment not present fault */
+#define EXC_I386_STKFLT 12 /* stack fault */
+#define EXC_I386_GPFLT 13 /* general protection fault */
+#define EXC_I386_PGFLT 14 /* page fault */
+#define EXC_I386_EXTERRFLT 16 /* extension error fault */
+#define EXC_I386_ENDPERR 33 /* emulated extension error flt */
+#define EXC_I386_ENOEXTFLT 32 /* emulated ext not present */
+
+#endif /* _MACH_I386_EXCEPTION_H_ */
diff --git a/i386/include/mach/i386/exec/elf.h b/i386/include/mach/i386/exec/elf.h
new file mode 100644
index 0000000..5155b3d
--- /dev/null
+++ b/i386/include/mach/i386/exec/elf.h
@@ -0,0 +1,36 @@
+/*
+ * 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_I386_EXEC_ELF_H_
+#define _MACH_I386_EXEC_ELF_H_
+
+typedef unsigned long Elf32_Addr;
+typedef unsigned short Elf32_Half;
+typedef unsigned long Elf32_Off;
+typedef signed long Elf32_Sword;
+typedef unsigned long Elf32_Word;
+
+/* Architecture identification parameters for i386. */
+#define MY_EI_DATA ELFDATA2LSB
+#define MY_E_MACHINE EM_386
+
+#endif /* _MACH_I386_EXEC_ELF_H_ */
diff --git a/i386/include/mach/i386/far_ptr.h b/i386/include/mach/i386/far_ptr.h
new file mode 100644
index 0000000..e85962d
--- /dev/null
+++ b/i386/include/mach/i386/far_ptr.h
@@ -0,0 +1,35 @@
+/*
+ * 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_I386_FAR_PTR_H_
+#define _MACH_I386_FAR_PTR_H_
+
+struct far_pointer_16
+{
+ unsigned short ofs;
+ unsigned short seg;
+};
+
+struct far_pointer_32
+{
+ unsigned long ofs;
+ unsigned short seg;
+};
+
+#endif /* _MACH_I386_FAR_PTR_H_ */
diff --git a/i386/include/mach/i386/fp_reg.h b/i386/include/mach/i386/fp_reg.h
new file mode 100644
index 0000000..6fe7af5
--- /dev/null
+++ b/i386/include/mach/i386/fp_reg.h
@@ -0,0 +1,108 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1992-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_I386_FP_REG_H_
+#define _MACH_I386_FP_REG_H_
+/*
+ * Floating point registers and status, as saved
+ * and restored by FP save/restore instructions.
+ */
+struct i386_fp_save {
+ unsigned short fp_control; /* control */
+ unsigned short fp_unused_1;
+ unsigned short fp_status; /* status */
+ unsigned short fp_unused_2;
+ unsigned short fp_tag; /* register tags */
+ unsigned short fp_unused_3;
+ unsigned int fp_eip; /* eip at failed instruction */
+ unsigned short fp_cs; /* cs at failed instruction */
+ unsigned short fp_opcode; /* opcode of failed instruction */
+ unsigned int fp_dp; /* data address */
+ unsigned short fp_ds; /* data segment */
+ unsigned short fp_unused_4;
+};
+
+struct i386_fp_regs {
+ unsigned short fp_reg_word[5][8];
+ /* space for 8 80-bit FP registers */
+};
+
+/*
+ * Control register
+ */
+#define FPC_IE 0x0001 /* enable invalid operation
+ exception */
+#define FPC_IM FPC_IE
+#define FPC_DE 0x0002 /* enable denormalized operation
+ exception */
+#define FPC_DM FPC_DE
+#define FPC_ZE 0x0004 /* enable zero-divide exception */
+#define FPC_ZM FPC_ZE
+#define FPC_OE 0x0008 /* enable overflow exception */
+#define FPC_OM FPC_OE
+#define FPC_UE 0x0010 /* enable underflow exception */
+#define FPC_PE 0x0020 /* enable precision exception */
+#define FPC_PC 0x0300 /* precision control: */
+#define FPC_PC_24 0x0000 /* 24 bits */
+#define FPC_PC_53 0x0200 /* 53 bits */
+#define FPC_PC_64 0x0300 /* 64 bits */
+#define FPC_RC 0x0c00 /* rounding control: */
+#define FPC_RC_RN 0x0000 /* round to nearest or even */
+#define FPC_RC_RD 0x0400 /* round down */
+#define FPC_RC_RU 0x0800 /* round up */
+#define FPC_RC_CHOP 0x0c00 /* chop */
+#define FPC_IC 0x1000 /* infinity control (obsolete) */
+#define FPC_IC_PROJ 0x0000 /* projective infinity */
+#define FPC_IC_AFF 0x1000 /* affine infinity (std) */
+
+/*
+ * Status register
+ */
+#define FPS_IE 0x0001 /* invalid operation */
+#define FPS_DE 0x0002 /* denormalized operand */
+#define FPS_ZE 0x0004 /* divide by zero */
+#define FPS_OE 0x0008 /* overflow */
+#define FPS_UE 0x0010 /* underflow */
+#define FPS_PE 0x0020 /* precision */
+#define FPS_SF 0x0040 /* stack flag */
+#define FPS_ES 0x0080 /* error summary */
+#define FPS_C0 0x0100 /* condition code bit 0 */
+#define FPS_C1 0x0200 /* condition code bit 1 */
+#define FPS_C2 0x0400 /* condition code bit 2 */
+#define FPS_TOS 0x3800 /* top-of-stack pointer */
+#define FPS_TOS_SHIFT 11
+#define FPS_C3 0x4000 /* condition code bit 3 */
+#define FPS_BUSY 0x8000 /* FPU busy */
+
+/*
+ * Kind of floating-point support provided by kernel.
+ */
+#define FP_NO 0 /* no floating point */
+#define FP_SOFT 1 /* software FP emulator */
+#define FP_287 2 /* 80287 */
+#define FP_387 3 /* 80387 or 80486 */
+
+#endif /* _MACH_I386_FP_REG_H_ */
diff --git a/i386/include/mach/i386/ioccom.h b/i386/include/mach/i386/ioccom.h
new file mode 100644
index 0000000..17566a3
--- /dev/null
+++ b/i386/include/mach/i386/ioccom.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef __sys_ioccom_h
+#define __sys_ioccom_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 2 bits of the upper word are used
+ * to encode the in/out status of the parameter; for now
+ * we restrict parameters to at most 255 bytes.
+ */
+#define _IOCPARM_MASK 0xff /* parameters must be < 256 bytes */
+#define _IOC_VOID 0x20000000 /* no parameters */
+#define _IOC_OUT 0x40000000 /* copy out parameters */
+#define _IOC_IN 0x80000000 /* copy in parameters */
+#define _IOC_INOUT (_IOC_IN|_IOC_OUT)
+/* the 0x20000000 is so we can distinguish new ioctl's from old */
+#define _IO(x,y) (_IOC_VOID|('x'<<8)|y)
+#define _IOR(x,y,t) (_IOC_OUT|((sizeof(t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
+#define _IORN(x,y,t) (_IOC_OUT|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
+#define _IOW(x,y,t) (_IOC_IN|((sizeof(t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
+#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
+/* this should be _IORW, but stdio got there first */
+#define _IOWR(x,y,t) (_IOC_INOUT|((sizeof(t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
+#define _IOWRN(x,y,t) (_IOC_INOUT|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)
+
+#endif /* !__sys_ioccom_h */
diff --git a/i386/include/mach/i386/kern_return.h b/i386/include/mach/i386/kern_return.h
new file mode 100644
index 0000000..c51915d
--- /dev/null
+++ b/i386/include/mach/i386/kern_return.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.
+ */
+/*
+ * File: kern_return.h
+ * Author: Avadis Tevanian, Jr., Michael Wayne Young
+ * Date: 1985
+ *
+ * Machine-dependent kernel return definitions.
+ */
+
+#ifndef _MACH_I386_KERN_RETURN_H_
+#define _MACH_I386_KERN_RETURN_H_
+
+#ifndef ASSEMBLER
+typedef int kern_return_t;
+#endif /* ASSEMBLER */
+#endif /* _MACH_I386_KERN_RETURN_H_ */
diff --git a/i386/include/mach/i386/mach_i386.defs b/i386/include/mach/i386/mach_i386.defs
new file mode 100644
index 0000000..5c30b67
--- /dev/null
+++ b/i386/include/mach/i386/mach_i386.defs
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+/*
+ * Special functions for i386.
+ */
+
+subsystem
+#if KERNEL_SERVER
+ KernelServer
+#endif KERNEL_SERVER
+ mach_i386 3800;
+
+#include <mach/std_types.defs>
+#include <mach/mach_types.defs>
+#include <device/device_types.defs>
+
+type device_list_t = ^array[] of device_t;
+
+type descriptor_t = struct[2] of int;
+type descriptor_list_t = array[*] of descriptor_t;
+
+import <mach/machine/mach_i386_types.h>;
+
+routine i386_io_port_add(
+ target_thread : thread_t;
+ device : device_t);
+
+routine i386_io_port_remove(
+ target_thread : thread_t;
+ device : device_t);
+
+routine i386_io_port_list(
+ target_thread : thread_t;
+ out device_list : device_list_t);
+
+routine i386_set_ldt(
+ target_thread : thread_t;
+ first_selector : int;
+ desc_list : descriptor_list_t, serverCopy);
+
+routine i386_get_ldt(
+ target_thread : thread_t;
+ first_selector : int;
+ selector_count : int;
+ out desc_list : descriptor_list_t);
diff --git a/i386/include/mach/i386/mach_i386_types.h b/i386/include/mach/i386/mach_i386_types.h
new file mode 100644
index 0000000..43780a3
--- /dev/null
+++ b/i386/include/mach/i386/mach_i386_types.h
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+/*
+ * Type definitions for i386 interface routines.
+ */
+
+#ifndef _MACH_MACH_I386_TYPES_H_
+#define _MACH_MACH_I386_TYPES_H_
+
+/*
+ * Array of devices.
+ */
+typedef device_t *device_list_t;
+
+/*
+ * i386 segment descriptor.
+ */
+struct descriptor {
+ unsigned int low_word;
+ unsigned int high_word;
+};
+
+typedef struct descriptor descriptor_t;
+typedef struct descriptor *descriptor_list_t;
+
+#endif /* _MACH_MACH_I386_TYPES_H_ */
diff --git a/i386/include/mach/i386/machine_types.defs b/i386/include/mach/i386/machine_types.defs
new file mode 100755
index 0000000..991b740
--- /dev/null
+++ b/i386/include/mach/i386/machine_types.defs
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+/*
+ * File: mach/machine/machine_types.defs
+ * Author: Alessandro Forin
+ * Date: 7/92
+ *
+ * Header file for the basic, machine-dependent data types.
+ * Version for 32 bit architectures.
+ *
+ */
+
+#ifndef _MACHINE_MACHINE_TYPES_DEFS_
+#define _MACHINE_MACHINE_TYPES_DEFS_ 1
+
+/*
+ * A natural_t is the type for the native
+ * integer type, e.g. 32 or 64 or.. whatever
+ * register size the machine has. Unsigned, it is
+ * used for entities that might be either
+ * unsigned integers or pointers, and for
+ * type-casting between the two.
+ * For instance, the IPC system represents
+ * a port in user space as an integer and
+ * in kernel space as a pointer.
+ */
+type natural_t = unsigned32;
+
+/*
+ * An integer_t is the signed counterpart
+ * of the natural_t type. Both types are
+ * only supposed to be used to define
+ * other types in a machine-independent
+ * way.
+ */
+type integer_t = int32;
+
+
+#if MACH_IPC_COMPAT
+/*
+ * For the old IPC interface
+ */
+#define MSG_TYPE_PORT_NAME MACH_MSG_TYPE_INTEGER_32
+
+#endif /* MACH_IPC_COMPAT */
+
+
+#endif /* _MACHINE_MACHINE_TYPES_DEFS_ */
diff --git a/i386/include/mach/i386/multiboot.h b/i386/include/mach/i386/multiboot.h
new file mode 100644
index 0000000..e0db823
--- /dev/null
+++ b/i386/include/mach/i386/multiboot.h
@@ -0,0 +1,182 @@
+/*
+ * 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_I386_MULTIBOOT_H_
+#define _MACH_I386_MULTIBOOT_H_
+
+#include <mach/machine/vm_types.h>
+
+/* For a.out kernel boot images, the following header must appear
+ somewhere in the first 8192 bytes of the kernel image file. */
+struct multiboot_header
+{
+ /* Must be MULTIBOOT_MAGIC */
+ unsigned magic;
+
+ /* Feature flags - see below. */
+ unsigned flags;
+
+ /*
+ * Checksum
+ *
+ * The above fields plus this one must equal 0 mod 2^32.
+ */
+ unsigned checksum;
+
+ /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
+ vm_offset_t header_addr;
+ vm_offset_t load_addr;
+ vm_offset_t load_end_addr;
+ vm_offset_t bss_end_addr;
+ vm_offset_t entry;
+};
+
+/* The entire multiboot_header must be contained
+ within the first MULTIBOOT_SEARCH bytes of the kernel image. */
+#define MULTIBOOT_SEARCH 8192
+
+/* Magic value identifying the multiboot_header. */
+#define MULTIBOOT_MAGIC 0x1badb002
+
+/* Features flags for 'flags'.
+ If a boot loader sees a flag in MULTIBOOT_MUSTKNOW set
+ and it doesn't understand it, it must fail. */
+#define MULTIBOOT_MUSTKNOW 0x0000ffff
+
+/* Align all boot modules on page (4KB) boundaries. */
+#define MULTIBOOT_PAGE_ALIGN 0x00000001
+
+/* Must be provided memory information in multiboot_info structure */
+#define MULTIBOOT_MEMORY_INFO 0x00000002
+
+/* Use the load address fields above instead of the ones in the a.out header
+ to figure out what to load where, and what to do afterwards.
+ This should only be needed for a.out kernel images
+ (ELF and other formats can generally provide the needed information). */
+#define MULTIBOOT_AOUT_KLUDGE 0x00010000
+
+/* The boot loader passes this value in register EAX to signal the kernel
+ that the multiboot method is being used */
+#define MULTIBOOT_VALID 0x2badb002
+
+/* The boot loader passes this data structure to the kernel in
+ register EBX on entry. */
+struct multiboot_info
+{
+ /* These flags indicate which parts of the multiboot_info are valid;
+ see below for the actual flag bit definitions. */
+ unsigned flags;
+
+ /* Lower/Upper memory installed in the machine.
+ Valid only if MULTIBOOT_MEMORY is set in flags word above. */
+ vm_size_t mem_lower;
+ vm_size_t mem_upper;
+
+ /* BIOS disk device the kernel was loaded from.
+ Valid only if MULTIBOOT_BOOT_DEVICE is set in flags word above. */
+ unsigned char boot_device[4];
+
+ /* Command-line for the OS kernel: a null-terminated ASCII string.
+ Valid only if MULTIBOOT_CMDLINE is set in flags word above. */
+ vm_offset_t cmdline;
+
+ /* List of boot modules loaded with the kernel.
+ Valid only if MULTIBOOT_MODS is set in flags word above. */
+ unsigned mods_count;
+ vm_offset_t mods_addr;
+
+ /* Symbol information for a.out or ELF executables. */
+ union
+ {
+ struct
+ {
+ /* a.out symbol information valid only if MULTIBOOT_AOUT_SYMS
+ is set in flags word above. */
+ vm_size_t tabsize;
+ vm_size_t strsize;
+ vm_offset_t addr;
+ unsigned reserved;
+ } a;
+
+ struct
+ {
+ /* ELF section header information valid only if
+ MULTIBOOT_ELF_SHDR is set in flags word above. */
+ unsigned num;
+ vm_size_t size;
+ vm_offset_t addr;
+ unsigned shndx;
+ } e;
+ } syms;
+
+ /* Memory map buffer.
+ Valid only if MULTIBOOT_MEM_MAP is set in flags word above. */
+ vm_size_t mmap_count;
+ vm_offset_t mmap_addr;
+};
+
+#define MULTIBOOT_MEMORY 0x00000001
+#define MULTIBOOT_BOOT_DEVICE 0x00000002
+#define MULTIBOOT_CMDLINE 0x00000004
+#define MULTIBOOT_MODS 0x00000008
+#define MULTIBOOT_AOUT_SYMS 0x00000010
+#define MULTIBOOT_ELF_SHDR 0x00000020
+#define MULTIBOOT_MEM_MAP 0x00000040
+
+
+/* The mods_addr field above contains the physical address of the first
+ of 'mods_count' multiboot_module structures. */
+struct multiboot_module
+{
+ /* Physical start and end addresses of the module data itself. */
+ vm_offset_t mod_start;
+ vm_offset_t mod_end;
+
+ /* Arbitrary ASCII string associated with the module. */
+ vm_offset_t string;
+
+ /* Boot loader must set to 0; OS must ignore. */
+ unsigned reserved;
+};
+
+
+/* The mmap_addr field above contains the physical address of the first
+ of the AddrRangeDesc structure. "size" represents the size of the
+ rest of the structure and optional padding. The offset to the beginning
+ of the next structure is therefore "size + 4". */
+struct AddrRangeDesc
+{
+ unsigned long size;
+ unsigned long BaseAddrLow;
+ unsigned long BaseAddrHigh;
+ unsigned long LengthLow;
+ unsigned long LengthHigh;
+ unsigned long Type;
+
+ /* unspecified optional padding... */
+};
+
+/* usable memory "Type", all others are reserved. */
+#define MB_ARD_MEMORY 1
+
+
+#endif _MACH_I386_MULTIBOOT_H_
diff --git a/i386/include/mach/i386/paging.h b/i386/include/mach/i386/paging.h
new file mode 100644
index 0000000..e24136c
--- /dev/null
+++ b/i386/include/mach/i386/paging.h
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+/*
+ * Definitions relating to i386 page directories and page tables.
+ */
+#ifndef _MACH_I386_PAGING_H_
+#define _MACH_I386_PAGING_H_
+
+
+#define INTEL_OFFMASK 0xfff /* offset within page */
+#define PDESHIFT 22 /* page descriptor shift */
+#define PDEMASK 0x3ff /* mask for page descriptor index */
+#define PTESHIFT 12 /* page table shift */
+#define PTEMASK 0x3ff /* mask for page table index */
+
+/*
+ * Convert linear offset to page descriptor/page table index
+ */
+#define lin2pdenum(a) (((a) >> PDESHIFT) & PDEMASK)
+#define lin2ptenum(a) (((a) >> PTESHIFT) & PTEMASK)
+
+/*
+ * Convert page descriptor/page table index to linear address
+ */
+#define pdenum2lin(a) ((vm_offset_t)(a) << PDESHIFT)
+#define ptenum2lin(a) ((vm_offset_t)(a) << PTESHIFT)
+
+/*
+ * Number of ptes/pdes in a page table/directory.
+ */
+#define NPTES (i386_ptob(1)/sizeof(pt_entry_t))
+#define NPDES (i386_ptob(1)/sizeof(pt_entry_t))
+
+/*
+ * Hardware pte bit definitions (to be used directly on the ptes
+ * without using the bit fields).
+ */
+#define INTEL_PTE_VALID 0x00000001
+#define INTEL_PTE_WRITE 0x00000002
+#define INTEL_PTE_USER 0x00000004
+#define INTEL_PTE_WTHRU 0x00000008
+#define INTEL_PTE_NCACHE 0x00000010
+#define INTEL_PTE_REF 0x00000020
+#define INTEL_PTE_MOD 0x00000040
+#define INTEL_PTE_AVAIL 0x00000e00
+#define INTEL_PTE_PFN 0xfffff000
+
+/*
+ * Macros to translate between page table entry values
+ * and physical addresses.
+ */
+#define pa_to_pte(a) ((a) & INTEL_PTE_PFN)
+#define pte_to_pa(p) ((p) & INTEL_PTE_PFN)
+#define pte_increment_pa(p) ((p) += INTEL_OFFMASK+1)
+
+
+#ifndef ASSEMBLER
+
+#include <mach/inline.h>
+#include <mach/machine/vm_param.h>
+#include <mach/machine/proc_reg.h>
+
+/*
+ * i386/i486/i860 Page Table Entry
+ */
+typedef unsigned int pt_entry_t;
+#define PT_ENTRY_NULL ((pt_entry_t *) 0)
+
+
+/*
+ * Load page directory 'pdir' and turn paging on.
+ * Assumes that 'pdir' equivalently maps the physical memory
+ * that contains the currently executing code,
+ * the currently loaded GDT and IDT, etc.
+ */
+MACH_INLINE void i386_paging_enable(vm_offset_t pdir)
+{
+ /* Load the page directory. */
+ set_cr3(pdir);
+
+ /* Turn on paging. */
+ asm volatile("
+ movl %0,%%cr0
+ jmp 1f
+ 1:
+ " : : "r" (get_cr0() | CR0_PG));
+}
+
+/*
+ * Turn paging off.
+ * Assumes that the currently loaded page directory
+ * equivalently maps the physical memory
+ * that contains the currently executing code,
+ * the currently loaded GDT and IDT, etc.
+ */
+MACH_INLINE void i386_paging_disable(void)
+{
+ /* Turn paging off. */
+ asm volatile("
+ movl %0,%%cr0
+ jmp 1f
+ 1:
+ " : : "r" (get_cr0() & ~CR0_PG));
+
+ /* Flush the TLB. */
+ set_cr3(0);
+}
+
+#endif /* !ASSEMBLER */
+
+#endif _MACH_I386_PAGING_H_
diff --git a/i386/include/mach/i386/pio.h b/i386/include/mach/i386/pio.h
new file mode 100644
index 0000000..06311db
--- /dev/null
+++ b/i386/include/mach/i386/pio.h
@@ -0,0 +1,70 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_I386_PIO_H_
+#define _MACH_I386_PIO_H_
+
+#ifdef __GNUC__
+
+#define inl(port) \
+({ unsigned long _tmp__; \
+ asm volatile("inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(port))); \
+ _tmp__; })
+
+#define inw(port) \
+({ unsigned short _tmp__; \
+ asm volatile(".byte 0x66; inl %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(port))); \
+ _tmp__; })
+
+#define inb(port) \
+({ unsigned char _tmp__; \
+ asm volatile("inb %1, %0" : "=a" (_tmp__) : "d" ((unsigned short)(port))); \
+ _tmp__; })
+
+
+#define outl(port, val) \
+({ asm volatile("outl %0, %1" : : "a" (val) , "d" ((unsigned short)(port))); })
+
+
+#define outw(port, val) \
+({asm volatile(".byte 0x66; outl %0, %1" : : "a" ((unsigned short)(val)) , "d" ((unsigned short)(port))); })
+
+
+#define outb(port, val) \
+({ asm volatile("outb %0, %1" : : "a" ((unsigned char)(val)) , "d" ((unsigned short)(port))); })
+
+
+/* Inline code works just as well for 16-bit code as for 32-bit. */
+#define i16_inl(port) inl(port)
+#define i16_inw(port) inw(port)
+#define i16_inb(port) inb(port)
+#define i16_outl(port, val) outl(port, val)
+#define i16_outw(port, val) outw(port, val)
+#define i16_outb(port, val) outb(port, val)
+
+#endif __GNUC__
+
+#endif /* _MACH_I386_PIO_H_ */
diff --git a/i386/include/mach/i386/pmode.h b/i386/include/mach/i386/pmode.h
new file mode 100644
index 0000000..99b7d26
--- /dev/null
+++ b/i386/include/mach/i386/pmode.h
@@ -0,0 +1,93 @@
+/*
+ * 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_I386_PMODE_H_
+#define _MACH_I386_PMODE_H_
+
+#include <mach/inline.h>
+#include <mach/macro_help.h>
+#include <mach/machine/proc_reg.h>
+
+
+
+/* Enter protected mode on i386 machines.
+ Assumes:
+ * Running in real mode.
+ * Interrupts are turned off.
+ * A20 is enabled (if on a PC).
+ * A suitable GDT is already loaded.
+
+ You must supply a 16-bit code segment
+ equivalent to the real-mode code segment currently in use.
+
+ You must reload all segment registers except CS
+ immediately after invoking this macro.
+*/
+#define i16_enter_pmode(prot_cs) \
+MACRO_BEGIN \
+ /* Switch to protected mode. */ \
+ asm volatile("
+ movl %0,%%cr0
+ ljmp %1,$1f
+ 1:
+ " : : "r" (i16_get_cr0() | CR0_PE), "i" (KERNEL_16_CS)); \
+MACRO_END
+
+
+
+/* Leave protected mode and return to real mode.
+ Assumes:
+ * Running in protected mode
+ * Interrupts are turned off.
+ * Paging is turned off.
+ * All currently loaded segment registers
+ contain 16-bit segments with limits of 0xffff.
+
+ You must supply a real-mode code segment
+ equivalent to the protected-mode code segment currently in use.
+
+ You must reload all segment registers except CS
+ immediately after invoking this function.
+*/
+MACH_INLINE i16_leave_pmode(int real_cs)
+{
+ /* Switch back to real mode.
+ Note: switching to the real-mode code segment
+ _must_ be done with an _immediate_ far jump,
+ not an indirect far jump. At least on my Am386DX/40,
+ an indirect far jump leaves the code segment read-only. */
+ {
+ extern unsigned short real_jmp[];
+
+ real_jmp[3] = real_cs;
+ asm volatile("
+ movl %0,%%cr0
+ jmp 1f
+ 1:
+ real_jmp:
+ _real_jmp:
+ ljmp $0,$1f
+ 1:
+ " : : "r" (i16_get_cr0() & ~CR0_PE));
+ }
+}
+
+
+
+#endif _MACH_I386_PMODE_H_
diff --git a/i386/include/mach/i386/proc_reg.h b/i386/include/mach/i386/proc_reg.h
new file mode 100644
index 0000000..20196ed
--- /dev/null
+++ b/i386/include/mach/i386/proc_reg.h
@@ -0,0 +1,340 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * Processor registers for i386 and i486.
+ */
+#ifndef _MACH_I386_PROC_REG_H_
+#define _MACH_I386_PROC_REG_H_
+
+/*
+ * CR0
+ */
+#define CR0_PG 0x80000000 /* enable paging */
+#define CR0_CD 0x40000000 /* i486: cache disable */
+#define CR0_NW 0x20000000 /* i486: no write-through */
+#define CR0_AM 0x00040000 /* i486: alignment check mask */
+#define CR0_WP 0x00010000 /* i486: write-protect kernel access */
+#define CR0_NE 0x00000020 /* i486: handle numeric exceptions */
+#define CR0_ET 0x00000010 /* extension type is 80387 */
+ /* (not official) */
+#define CR0_TS 0x00000008 /* task switch */
+#define CR0_EM 0x00000004 /* emulate coprocessor */
+#define CR0_MP 0x00000002 /* monitor coprocessor */
+#define CR0_PE 0x00000001 /* enable protected mode */
+
+#ifndef ASSEMBLER
+#ifdef __GNUC__
+
+#include <mach/inline.h>
+
+
+/* Some processors, notably my Am386DX/40,
+ seem to have some rather subtle pipeline- or timing-related bugs
+ which case really weird things to happen with pushf's and popf's
+ that come too close together... */
+
+MACH_INLINE unsigned get_eflags()
+{
+ unsigned eflags;
+ asm volatile("
+ jmp 1f
+ 1: jmp 1f
+ 1: jmp 1f
+ 1: pushf
+ jmp 1f
+ 1: jmp 1f
+ 1: jmp 1f
+ 1: popl %0" : "=r" (eflags));
+ return eflags;
+}
+
+MACH_INLINE void set_eflags(unsigned eflags)
+{
+ asm volatile("
+ pushl %0
+ jmp 1f
+ 1: jmp 1f
+ 1: jmp 1f
+ 1: popf
+ jmp 1f
+ 1: jmp 1f
+ 1: jmp 1f
+ 1: " : : "r" (eflags));
+}
+
+MACH_INLINE void cli() { asm volatile("cli"); }
+MACH_INLINE void sti() { asm volatile("sti"); }
+MACH_INLINE void cld() { asm volatile("cld"); }
+MACH_INLINE void std() { asm volatile("std"); }
+MACH_INLINE void clts() { asm volatile("clts"); }
+
+MACH_INLINE unsigned short get_cs()
+{
+ unsigned short cs;
+ asm volatile("movw %%cs,%w0" : "=r" (cs));
+ return cs;
+}
+
+MACH_INLINE unsigned short get_ds()
+{
+ unsigned short ds;
+ asm volatile("movw %%ds,%w0" : "=r" (ds));
+ return ds;
+}
+MACH_INLINE void set_ds(unsigned short ds)
+{
+ asm volatile("movw %w0,%%ds" : : "r" (ds));
+}
+
+MACH_INLINE unsigned short get_es()
+{
+ unsigned short es;
+ asm volatile("movw %%es,%w0" : "=r" (es));
+ return es;
+}
+MACH_INLINE void set_es(unsigned short es)
+{
+ asm volatile("movw %w0,%%es" : : "r" (es));
+}
+
+MACH_INLINE unsigned short get_fs()
+{
+ unsigned short fs;
+ asm volatile("movw %%fs,%w0" : "=r" (fs));
+ return fs;
+}
+MACH_INLINE void set_fs(unsigned short fs)
+{
+ asm volatile("movw %w0,%%fs" : : "r" (fs));
+}
+
+MACH_INLINE unsigned short get_gs()
+{
+ unsigned short gs;
+ asm volatile("movw %%gs,%w0" : "=r" (gs));
+ return gs;
+}
+MACH_INLINE void set_gs(unsigned short gs)
+{
+ asm volatile("movw %w0,%%gs" : : "r" (gs));
+}
+
+MACH_INLINE unsigned short get_ss()
+{
+ unsigned short ss;
+ asm volatile("movw %%ss,%w0" : "=r" (ss));
+ return ss;
+}
+MACH_INLINE void set_ss(unsigned short ss)
+{
+ asm volatile("movw %w0,%%ss" : : "r" (ss));
+}
+
+#define get_eax() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%eax, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_ebx() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%ebx, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_ecx() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%ecx, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_edx() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%edx, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_esi() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%esi, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_edi() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%edi, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_ebp() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%ebp, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_esp() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("movl %%esp, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_eflags() \
+ ({ \
+ register unsigned int _temp__; \
+ asm volatile("pushf; popl %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_cr0() \
+ ({ \
+ register unsigned int _temp__; \
+ asm volatile("mov %%cr0, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define set_cr0(value) \
+ ({ \
+ register unsigned int _temp__ = (value); \
+ asm volatile("mov %0, %%cr0" : : "r" (_temp__)); \
+ })
+
+MACH_INLINE unsigned short get_msw()
+{
+ unsigned short msw;
+ asm volatile("smsw %0" : "=r" (msw));
+ return msw;
+}
+
+#define get_cr2() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("mov %%cr2, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define get_cr3() \
+ ({ \
+ register unsigned int _temp__; \
+ asm("mov %%cr3, %0" : "=r" (_temp__)); \
+ _temp__; \
+ })
+
+#define set_cr3(value) \
+ ({ \
+ register unsigned int _temp__ = (value); \
+ asm volatile("mov %0, %%cr3" : : "r" (_temp__)); \
+ })
+
+#define set_ts() \
+ set_cr0(get_cr0() | CR0_TS)
+
+#define clear_ts() \
+ asm volatile("clts")
+
+#define get_tr() \
+ ({ \
+ unsigned short _seg__; \
+ asm volatile("str %0" : "=rm" (_seg__) ); \
+ _seg__; \
+ })
+
+#define set_tr(seg) \
+ asm volatile("ltr %0" : : "rm" ((unsigned short)(seg)) )
+
+#define set_gdt(pseudo_desc) \
+ ({ \
+ asm volatile("lgdt %0" : : "m" ((pseudo_desc)->limit)); \
+ })
+
+#define set_idt(pseudo_desc) \
+ ({ \
+ asm volatile("lidt %0" : : "m" ((pseudo_desc)->limit)); \
+ })
+
+#define get_ldt() \
+ ({ \
+ unsigned short _seg__; \
+ asm volatile("sldt %0" : "=rm" (_seg__) ); \
+ _seg__; \
+ })
+
+#define set_ldt(seg) \
+ asm volatile("lldt %0" : : "rm" ((unsigned short)(seg)) )
+
+/* This doesn't set a processor register,
+ but it's often used immediately after setting one,
+ to flush the instruction queue. */
+#define flush_instr_queue() \
+ asm volatile("
+ jmp 0f
+ 0:
+ ")
+
+/* Inline functions work fine for 16-bit code as well. */
+#ifdef CODE16
+#define i16_get_eflags get_eflags
+#define i16_set_eflags set_eflags
+#define i16_cli cli
+#define i16_sti sti
+#define i16_cld cld
+#define i16_std std
+#define i16_clts clts
+#define i16_get_cs get_cs
+#define i16_set_cs set_cs
+#define i16_get_ds get_ds
+#define i16_set_ds set_ds
+#define i16_get_es get_es
+#define i16_set_es set_es
+#define i16_get_fs get_fs
+#define i16_set_fs set_fs
+#define i16_get_gs get_gs
+#define i16_set_gs set_gs
+#define i16_get_ss get_ss
+#define i16_set_ss set_ss
+#define i16_get_cr0 get_cr0
+#define i16_set_cr0 set_cr0
+#define i16_get_cr3 get_cr3
+#define i16_set_cr3 set_cr3
+#define i16_get_msw get_msw
+#define i16_set_gdt set_gdt
+#define i16_set_idt set_idt
+#define i16_set_ldt set_ldt
+#define i16_set_tr set_tr
+#define i16_flush_instr_queue flush_instr_queue
+#endif
+
+#endif /* __GNUC__ */
+#endif /* ASSEMBLER */
+
+#endif /* _MACH_I386_PROC_REG_H_ */
diff --git a/i386/include/mach/i386/rpc.h b/i386/include/mach/i386/rpc.h
new file mode 100644
index 0000000..71d31fb
--- /dev/null
+++ b/i386/include/mach/i386/rpc.h
@@ -0,0 +1,9 @@
+
+struct rpc_csig_action
+{
+};
+
+struct rpc_csig_entry
+{
+};
+
diff --git a/i386/include/mach/i386/seg.h b/i386/include/mach/i386/seg.h
new file mode 100644
index 0000000..31ada9e
--- /dev/null
+++ b/i386/include/mach/i386/seg.h
@@ -0,0 +1,190 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * Copyright (c) 1991 IBM Corporation
+ * 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,
+ * and that the name IBM not be used in advertising or publicity
+ * pertaining to distribution of the software without specific, written
+ * prior permission.
+ *
+ * CARNEGIE MELLON AND IBM ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON AND IBM 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.
+ */
+
+#ifndef _MACH_I386_SEG_H_
+#define _MACH_I386_SEG_H_
+
+
+/*
+ * i386 segmentation.
+ */
+
+#ifndef ASSEMBLER
+
+/*
+ * Real segment descriptor.
+ */
+struct i386_descriptor {
+ unsigned int limit_low:16, /* limit 0..15 */
+ base_low:16, /* base 0..15 */
+ base_med:8, /* base 16..23 */
+ access:8, /* access byte */
+ limit_high:4, /* limit 16..19 */
+ granularity:4, /* granularity */
+ base_high:8; /* base 24..31 */
+};
+
+struct i386_gate {
+ unsigned int offset_low:16, /* offset 0..15 */
+ selector:16,
+ word_count:8,
+ access:8,
+ offset_high:16; /* offset 16..31 */
+};
+
+#endif !ASSEMBLER
+
+#define SZ_32 0x4 /* 32-bit segment */
+#define SZ_16 0x0 /* 16-bit segment */
+#define SZ_G 0x8 /* 4K limit field */
+
+#define ACC_A 0x01 /* accessed */
+#define ACC_TYPE 0x1e /* type field: */
+
+#define ACC_TYPE_SYSTEM 0x00 /* system descriptors: */
+
+#define ACC_LDT 0x02 /* LDT */
+#define ACC_CALL_GATE_16 0x04 /* 16-bit call gate */
+#define ACC_TASK_GATE 0x05 /* task gate */
+#define ACC_TSS 0x09 /* task segment */
+#define ACC_CALL_GATE 0x0c /* call gate */
+#define ACC_INTR_GATE 0x0e /* interrupt gate */
+#define ACC_TRAP_GATE 0x0f /* trap gate */
+
+#define ACC_TSS_BUSY 0x02 /* task busy */
+
+#define ACC_TYPE_USER 0x10 /* user descriptors */
+
+#define ACC_DATA 0x10 /* data */
+#define ACC_DATA_W 0x12 /* data, writable */
+#define ACC_DATA_E 0x14 /* data, expand-down */
+#define ACC_DATA_EW 0x16 /* data, expand-down,
+ writable */
+#define ACC_CODE 0x18 /* code */
+#define ACC_CODE_R 0x1a /* code, readable */
+#define ACC_CODE_C 0x1c /* code, conforming */
+#define ACC_CODE_CR 0x1e /* code, conforming,
+ readable */
+#define ACC_PL 0x60 /* access rights: */
+#define ACC_PL_K 0x00 /* kernel access only */
+#define ACC_PL_U 0x60 /* user access */
+#define ACC_P 0x80 /* segment present */
+
+/*
+ * Components of a selector
+ */
+#define SEL_LDT 0x04 /* local selector */
+#define SEL_PL 0x03 /* privilege level: */
+#define SEL_PL_K 0x00 /* kernel selector */
+#define SEL_PL_U 0x03 /* user selector */
+
+/*
+ * Convert selector to descriptor table index.
+ */
+#define sel_idx(sel) ((sel)>>3)
+
+
+#ifndef ASSEMBLER
+
+#include <mach/inline.h>
+
+
+/* Format of a "pseudo-descriptor", used for loading the IDT and GDT. */
+struct pseudo_descriptor
+{
+ short pad;
+ unsigned short limit;
+ unsigned long linear_base;
+};
+
+
+/* Fill a segment descriptor. */
+MACH_INLINE void
+fill_descriptor(struct i386_descriptor *desc, unsigned base, unsigned limit,
+ unsigned char access, unsigned char sizebits)
+{
+ if (limit > 0xfffff)
+ {
+ limit >>= 12;
+ sizebits |= SZ_G;
+ }
+ desc->limit_low = limit & 0xffff;
+ desc->base_low = base & 0xffff;
+ desc->base_med = (base >> 16) & 0xff;
+ desc->access = access | ACC_P;
+ desc->limit_high = limit >> 16;
+ desc->granularity = sizebits;
+ desc->base_high = base >> 24;
+}
+
+/* Set the base address in a segment descriptor. */
+MACH_INLINE void
+fill_descriptor_base(struct i386_descriptor *desc, unsigned base)
+{
+ desc->base_low = base & 0xffff;
+ desc->base_med = (base >> 16) & 0xff;
+ desc->base_high = base >> 24;
+}
+
+/* Set the limit in a segment descriptor. */
+MACH_INLINE void
+fill_descriptor_limit(struct i386_descriptor *desc, unsigned limit)
+{
+ if (limit > 0xfffff)
+ {
+ limit >>= 12;
+ desc->granularity |= SZ_G;
+ }
+ else
+ desc->granularity &= ~SZ_G;
+ desc->limit_low = limit & 0xffff;
+ desc->limit_high = limit >> 16;
+}
+
+/* Fill a gate with particular values. */
+MACH_INLINE void
+fill_gate(struct i386_gate *gate, unsigned offset, unsigned short selector,
+ unsigned char access, unsigned char word_count)
+{
+ gate->offset_low = offset & 0xffff;
+ gate->selector = selector;
+ gate->word_count = word_count;
+ gate->access = access | ACC_P;
+ gate->offset_high = (offset >> 16) & 0xffff;
+}
+
+#ifdef CODE16
+#define i16_fill_descriptor fill_descriptor
+#define i16_fill_gate fill_gate
+#endif
+
+#endif !ASSEMBLER
+
+#endif /* _MACH_I386_SEG_H_ */
diff --git a/i386/include/mach/i386/syscall_sw.h b/i386/include/mach/i386/syscall_sw.h
new file mode 100644
index 0000000..6b937d9
--- /dev/null
+++ b/i386/include/mach/i386/syscall_sw.h
@@ -0,0 +1,47 @@
+/*
+ * 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_I386_SYSCALL_SW_H_
+#define _MACH_I386_SYSCALL_SW_H_
+
+#include <mach/machine/asm.h>
+
+#if BSD_TRAP
+#define kernel_trap(trap_name,trap_number,number_args) \
+ENTRY(trap_name) \
+ movl $ trap_number,%eax; \
+ SVC; \
+ jb LCL(cerror); \
+ ret;
+#else
+#define kernel_trap(trap_name,trap_number,number_args) \
+ENTRY(trap_name) \
+ movl $ trap_number,%eax; \
+ SVC; \
+ ret;
+#endif
+
+#endif /* _MACH_I386_SYSCALL_SW_H_ */
diff --git a/i386/include/mach/i386/thread_status.h b/i386/include/mach/i386/thread_status.h
new file mode 100644
index 0000000..cc3dc66
--- /dev/null
+++ b/i386/include/mach/i386/thread_status.h
@@ -0,0 +1,147 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: thread_status.h
+ * Author: Avadis Tevanian, Jr.
+ * Date: 1985
+ *
+ * This file contains the structure definitions for the thread
+ * state as applied to I386 processors.
+ */
+
+#ifndef _MACH_I386_THREAD_STATUS_H_
+#define _MACH_I386_THREAD_STATUS_H_
+
+#include <mach/machine/fp_reg.h>
+/*
+ * i386_thread_state this is the structure that is exported
+ * to user threads for use in status/mutate
+ * calls. This structure should never
+ * change.
+ *
+ * i386_float_state exported to use threads for access to
+ * floating point registers. Try not to
+ * change this one, either.
+ *
+ * i386_isa_port_map_state exported to user threads to allow
+ * selective in/out operations
+ *
+ */
+
+#define i386_THREAD_STATE 1
+#define i386_FLOAT_STATE 2
+#define i386_ISA_PORT_MAP_STATE 3
+#define i386_V86_ASSIST_STATE 4
+#define i386_REGS_SEGS_STATE 5
+
+/*
+ * This structure is used for both
+ * i386_THREAD_STATE and i386_REGS_SEGS_STATE.
+ */
+struct i386_thread_state {
+ unsigned int gs;
+ unsigned int fs;
+ unsigned int es;
+ unsigned int ds;
+ unsigned int edi;
+ unsigned int esi;
+ unsigned int ebp;
+ unsigned int esp;
+ unsigned int ebx;
+ unsigned int edx;
+ unsigned int ecx;
+ unsigned int eax;
+ unsigned int eip;
+ unsigned int cs;
+ unsigned int efl;
+ unsigned int uesp;
+ unsigned int ss;
+};
+#define i386_THREAD_STATE_COUNT (sizeof (struct i386_thread_state)/sizeof(unsigned int))
+
+/*
+ * Floating point state.
+ *
+ * fpkind tells in what way floating point operations are supported.
+ * See the values for fp_kind in <mach/i386/fp_reg.h>.
+ *
+ * If the kind is FP_NO, then calls to set the state will fail, and
+ * thread_getstatus will return garbage for the rest of the state.
+ * If "initialized" is false, then the rest of the state is garbage.
+ * Clients can set "initialized" to false to force the coprocessor to
+ * be reset.
+ * "exc_status" is non-zero if the thread has noticed (but not
+ * proceeded from) a coprocessor exception. It contains the status
+ * word with the exception bits set. The status word in "fp_status"
+ * will have the exception bits turned off. If an exception bit in
+ * "fp_status" is turned on, then "exc_status" should be zero. This
+ * happens when the coprocessor exception is noticed after the system
+ * has context switched to some other thread.
+ *
+ * If kind is FP_387, then "state" is a i387_state. Other kinds might
+ * also use i387_state, but somebody will have to verify it (XXX).
+ * Note that the registers are ordered from top-of-stack down, not
+ * according to physical register number.
+ */
+
+#define FP_STATE_BYTES \
+ (sizeof (struct i386_fp_save) + sizeof (struct i386_fp_regs))
+
+struct i386_float_state {
+ int fpkind; /* FP_NO..FP_387 (readonly) */
+ int initialized;
+ unsigned char hw_state[FP_STATE_BYTES]; /* actual "hardware" state */
+ int exc_status; /* exception status (readonly) */
+};
+#define i386_FLOAT_STATE_COUNT (sizeof(struct i386_float_state)/sizeof(unsigned int))
+
+
+#define PORT_MAP_BITS 0x400
+struct i386_isa_port_map_state {
+ unsigned char pm[PORT_MAP_BITS>>3];
+};
+
+#define i386_ISA_PORT_MAP_STATE_COUNT (sizeof(struct i386_isa_port_map_state)/sizeof(unsigned int))
+
+/*
+ * V8086 assist supplies a pointer to an interrupt
+ * descriptor table in task space.
+ */
+struct i386_v86_assist_state {
+ unsigned int int_table; /* interrupt table address */
+ int int_count; /* interrupt table size */
+};
+
+struct v86_interrupt_table {
+ unsigned int count; /* count of pending interrupts */
+ unsigned short mask; /* ignore this interrupt if true */
+ unsigned short vec; /* vector to take */
+};
+
+#define i386_V86_ASSIST_STATE_COUNT \
+ (sizeof(struct i386_v86_assist_state)/sizeof(unsigned int))
+
+#endif /* _MACH_I386_THREAD_STATUS_H_ */
diff --git a/i386/include/mach/i386/time_stamp.h b/i386/include/mach/i386/time_stamp.h
new file mode 100644
index 0000000..d6488e2
--- /dev/null
+++ b/i386/include/mach/i386/time_stamp.h
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+/*
+ * The I386 timestamp implementation uses the default, so we don't
+ * need to do anything here.
+ */
diff --git a/i386/include/mach/i386/trap.h b/i386/include/mach/i386/trap.h
new file mode 100644
index 0000000..58dc266
--- /dev/null
+++ b/i386/include/mach/i386/trap.h
@@ -0,0 +1,60 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+
+#ifndef _MACH_I386_TRAP_H_
+#define _MACH_I386_TRAP_H_
+
+/*
+ * Hardware trap vectors for i386.
+ */
+#define T_DIVIDE_ERROR 0
+#define T_DEBUG 1
+#define T_NMI 2 /* non-maskable interrupt */
+#define T_INT3 3 /* int 3 instruction */
+#define T_OVERFLOW 4 /* overflow test */
+#define T_OUT_OF_BOUNDS 5 /* bounds check */
+#define T_INVALID_OPCODE 6 /* invalid op code */
+#define T_NO_FPU 7 /* no floating point */
+#define T_DOUBLE_FAULT 8 /* double fault */
+#define T_FPU_FAULT 9
+/* 10 */
+#define T_SEGMENT_NOT_PRESENT 11
+#define T_STACK_FAULT 12
+#define T_GENERAL_PROTECTION 13
+#define T_PAGE_FAULT 14
+/* 15 */
+#define T_FLOATING_POINT_ERROR 16
+#define T_WATCHPOINT 17
+
+/*
+ * Page-fault trap codes.
+ */
+#define T_PF_PROT 0x1 /* protection violation */
+#define T_PF_WRITE 0x2 /* write access */
+#define T_PF_USER 0x4 /* from user state */
+
+
+#endif _MACH_I386_TRAP_H_
diff --git a/i386/include/mach/i386/tss.h b/i386/include/mach/i386/tss.h
new file mode 100644
index 0000000..c9a8298
--- /dev/null
+++ b/i386/include/mach/i386/tss.h
@@ -0,0 +1,67 @@
+/*
+ * 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_I386_TSS_H_
+#define _MACH_I386_TSS_H_
+
+/*
+ * i386 Task State Segment
+ */
+struct i386_tss {
+ int back_link; /* segment number of previous task,
+ if nested */
+ int esp0; /* initial stack pointer ... */
+ int ss0; /* and segment for ring 0 */
+ int esp1; /* initial stack pointer ... */
+ int ss1; /* and segment for ring 1 */
+ int esp2; /* initial stack pointer ... */
+ int ss2; /* and segment for ring 2 */
+ int cr3; /* CR3 - page table directory
+ physical address */
+ int eip;
+ int eflags;
+ int eax;
+ int ecx;
+ int edx;
+ int ebx;
+ int esp; /* current stack pointer */
+ int ebp;
+ int esi;
+ int edi;
+ int es;
+ int cs;
+ int ss; /* current stack segment */
+ int ds;
+ int fs;
+ int gs;
+ int ldt; /* local descriptor table segment */
+ unsigned short trace_trap; /* trap on switch to this task */
+ unsigned short io_bit_map_offset;
+ /* offset to start of IO permission
+ bit map */
+};
+
+#endif /* _MACH_I386_TSS_H_ */
diff --git a/i386/include/mach/i386/vcpi.h b/i386/include/mach/i386/vcpi.h
new file mode 100644
index 0000000..0c09ed0
--- /dev/null
+++ b/i386/include/mach/i386/vcpi.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 1996-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 _FLUX_INCLUDE_FLUX_I386_VCPI_H_
+#define _FLUX_INCLUDE_FLUX_I386_VCPI_H_
+
+struct vcpi_switch_data
+{
+ vm_offset_t phys_pdir;
+ vm_offset_t lin_gdt;
+ vm_offset_t lin_idt;
+ unsigned short ldt_sel;
+ unsigned short tss_sel;
+ unsigned long entry_eip;
+ unsigned short entry_cs;
+};
+
+#endif /* _FLUX_INCLUDE_FLUX_I386_VCPI_H_ */
diff --git a/i386/include/mach/i386/vm_param.h b/i386/include/mach/i386/vm_param.h
new file mode 100644
index 0000000..a6b1efd
--- /dev/null
+++ b/i386/include/mach/i386/vm_param.h
@@ -0,0 +1,73 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie Mellon
+ * the rights to redistribute these changes.
+ */
+/*
+ * File: vm_param.h
+ * Author: Avadis Tevanian, Jr.
+ * Date: 1985
+ *
+ * I386 machine dependent virtual memory parameters.
+ * Most of the declarations are preceeded by I386_ (or i386_)
+ * which is OK because only I386 specific code will be using
+ * them.
+ */
+
+#ifndef _MACH_I386_VM_PARAM_H_
+#define _MACH_I386_VM_PARAM_H_
+
+#include <mach/machine/vm_types.h>
+
+#define BYTE_SIZE 8 /* byte size in bits */
+
+#define I386_PGBYTES 4096 /* bytes per 80386 page */
+#define I386_PGSHIFT 12 /* number of bits to shift for pages */
+
+/* Virtual page size is the same as real page size - 4K is big enough. */
+#define PAGE_SHIFT I386_PGSHIFT
+
+/*
+ * Convert bytes to pages and convert pages to bytes.
+ * No rounding is used.
+ */
+
+#define i386_btop(x) (((unsigned)(x)) >> I386_PGSHIFT)
+#define i386_ptob(x) (((unsigned)(x)) << I386_PGSHIFT)
+
+/*
+ * 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 i386_round_page(x) ((((unsigned)(x)) + I386_PGBYTES - 1) & \
+ ~(I386_PGBYTES-1))
+#define i386_trunc_page(x) (((unsigned)(x)) & ~(I386_PGBYTES-1))
+
+/* User address spaces are 3GB each,
+ starting at virtual and linear address 0. */
+#define VM_MIN_ADDRESS ((vm_offset_t) 0)
+#define VM_MAX_ADDRESS ((vm_offset_t) 0xc0000000)
+
+#endif /* _MACH_I386_VM_PARAM_H_ */
diff --git a/i386/include/mach/i386/vm_types.h b/i386/include/mach/i386/vm_types.h
new file mode 100644
index 0000000..51fdca8
--- /dev/null
+++ b/i386/include/mach/i386/vm_types.h
@@ -0,0 +1,108 @@
+/*
+ * 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: vm_types.h
+ * Author: Avadis Tevanian, Jr.
+ * Date: 1985
+ *
+ * Header file for VM data types. I386 version.
+ */
+
+#ifndef _MACHINE_VM_TYPES_H_
+#define _MACHINE_VM_TYPES_H_ 1
+
+#ifdef ASSEMBLER
+#else ASSEMBLER
+
+/*
+ * A natural_t is the type for the native
+ * integer type, e.g. 32 or 64 or.. whatever
+ * register size the machine has. Unsigned, it is
+ * used for entities that might be either
+ * unsigned integers or pointers, and for
+ * type-casting between the two.
+ * For instance, the IPC system represents
+ * a port in user space as an integer and
+ * in kernel space as a pointer.
+ */
+typedef unsigned int natural_t;
+
+/*
+ * An integer_t is the signed counterpart
+ * of the natural_t type. Both types are
+ * only supposed to be used to define
+ * other types in a machine-independent
+ * way.
+ */
+typedef int integer_t;
+
+#ifndef _POSIX_SOURCE
+
+/*
+ * An int32 is an integer that is at least 32 bits wide
+ */
+typedef int int32;
+typedef unsigned int uint32;
+
+#endif /* _POSIX_SOURCE */
+
+/*
+ * A vm_offset_t is a type-neutral pointer,
+ * e.g. an offset into a virtual memory space.
+ */
+typedef natural_t vm_offset_t;
+
+/*
+ * A vm_size_t is the proper type for e.g.
+ * expressing the difference between two
+ * vm_offset_t entities.
+ */
+typedef natural_t vm_size_t;
+
+/*
+ * These types are _exactly_ as wide as indicated in their names.
+ */
+typedef signed char signed8_t;
+typedef signed short signed16_t;
+typedef signed long signed32_t;
+typedef signed long long signed64_t;
+typedef unsigned char unsigned8_t;
+typedef unsigned short unsigned16_t;
+typedef unsigned long unsigned32_t;
+typedef unsigned long long unsigned64_t;
+typedef float float32_t;
+typedef double float64_t;
+
+#endif /* ASSEMBLER */
+
+/*
+ * If composing messages by hand (please dont)
+ */
+
+#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32
+
+#endif /* _MACHINE_VM_TYPES_H_ */
+
diff --git a/i386/include/mach/proc_ops.h b/i386/include/mach/proc_ops.h
new file mode 100644
index 0000000..7c379cf
--- /dev/null
+++ b/i386/include/mach/proc_ops.h
@@ -0,0 +1,40 @@
+/*
+ * 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_I386_PROC_OPS_H_
+#define _MACH_I386_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;
+
+ asm("
+ bsr %0,%0
+ " : "=r" (msb) : "0" (val));
+
+ return msb;
+}
+
+#endif _MACH_I386_PROC_OPS_H_
diff --git a/i386/include/mach/sa/stdarg.h b/i386/include/mach/sa/stdarg.h
new file mode 100644
index 0000000..3288b93
--- /dev/null
+++ b/i386/include/mach/sa/stdarg.h
@@ -0,0 +1,46 @@
+/*
+ * Mach Operating System
+ * Copyright (c) 1993 Carnegie Mellon University.
+ * 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.
+ *
+ * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSS 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.
+ */
+#ifndef _MACH_SA_STDARG_H_
+#define _MACH_SA_STDARG_H_
+
+#define __va_size(type) ((sizeof(type)+3) & ~0x3)
+
+#ifndef _VA_LIST_
+#define _VA_LIST_
+typedef char *va_list;
+#endif
+
+#define va_start(pvar, lastarg) \
+ ((pvar) = (char*)(void*)&(lastarg) + __va_size(lastarg))
+#define va_end(pvar)
+#define va_arg(pvar,type) \
+ ((pvar) += __va_size(type), \
+ *((type *)((pvar) - __va_size(type))))
+
+#endif _MACH_SA_STDARG_H_
diff --git a/i386/include/mach/sa/sys/varargs.h b/i386/include/mach/sa/sys/varargs.h
new file mode 100644
index 0000000..ff953ea
--- /dev/null
+++ b/i386/include/mach/sa/sys/varargs.h
@@ -0,0 +1,41 @@
+/*
+ * 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 rights
+ * to redistribute these changes.
+ */
+/*
+ * varargs support for i386
+ */
+#ifndef _MACH_SYS_VARARGS_H_
+#define _MACH_SYS_VARARGS_H_
+
+#define va_dcl int va_alist;
+typedef char * va_list;
+
+#define va_start(pvar) (pvar) = (va_list)&va_alist
+#define va_end(pvar)
+#define va_arg(pvar,type) ( \
+ (pvar) += ((sizeof(type)+3) & ~0x3), \
+ *((type *)((pvar) - ((sizeof(type)+3) & ~0x3))) )
+
+#endif _MACH_SYS_VARARGS_H_
diff --git a/i386/include/mach/setjmp.h b/i386/include/mach/setjmp.h
new file mode 100644
index 0000000..6ea42c8
--- /dev/null
+++ b/i386/include/mach/setjmp.h
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+/*
+ * Setjmp/longjmp buffer for i386.
+ */
+#ifndef _MACH_SETJMP_H_PROCESSED_
+#define _MACH_SETJMP_H_PROCESSED_ 1
+
+/* XXX prefix these with mach_ so they don't interfere with higher layers?
+ This stuff is included by cthreads.h. */
+
+/* XXX The original definition of jmp_buf[] causes problems using
+ * libthreads when linked against NetBSD and FreeBSD's libc because
+ * it's too small. When cthreads calls _setjmp, it gets the libc
+ * version which saves more state than it's expecting and overwrites
+ * important cthread data. =( This definition is big enough for all
+ * known systems so far (Linux's is 6, FreeBSD's is 9 and NetBSD's is
+ * 10). This file really shouldn't even be here, since we should be
+ * using libc's setjmp.h.
+ */
+#if 0
+#define _JBLEN 6
+#else
+#define _JBLEN 10
+#endif
+
+typedef int jmp_buf[_JBLEN]; /* ebx, esi, edi, ebp, esp, eip */
+
+
+extern int setjmp (jmp_buf);
+extern void longjmp (jmp_buf, int);
+extern int _setjmp (jmp_buf);
+extern void _longjmp (jmp_buf, int);
+
+#endif /* _MACH_SETJMP_H_PROCESSED_ */