commit 03e9c04a454a17f4ca7c67eb5a87c251d9e8fac0
Author: Brad Neuman <bradneuman@gmail.com>
Date:   Tue Jan 26 20:27:37 2010 -0500

    untarred prex

diff --git a/prex-0.9.0/Makefile b/prex-0.9.0/Makefile
new file mode 100755
index 0000000..74f7618
--- /dev/null
+++ b/prex-0.9.0/Makefile
@@ -0,0 +1,5 @@
+SUBDIR:=	bsp sys usr
+SRCDIR:=	$(CURDIR)
+export SRCDIR
+
+include $(SRCDIR)/mk/image.mk
diff --git a/prex-0.9.0/bsp/Makefile b/prex-0.9.0/bsp/Makefile
new file mode 100755
index 0000000..f8077ad
--- /dev/null
+++ b/prex-0.9.0/bsp/Makefile
@@ -0,0 +1,5 @@
+include $(SRCDIR)/mk/own.mk
+
+SUBDIR:=	boot hal drv
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/bsp/boot/Makefile b/prex-0.9.0/bsp/boot/Makefile
new file mode 100755
index 0000000..9bb5aef
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/Makefile
@@ -0,0 +1,31 @@
+# Rules to compile boot loader
+
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	bootldr
+
+#MAP:=		bootldr.map
+#DISASM:= 	bootldr.lst
+#SYMBOL:=	bootldr.sym
+
+_KERNEL_:=	1
+DEFS+=		KERNEL
+
+include $(CURDIR)/$(ARCH)/$(PLATFORM)/Makefile.inc
+include $(CURDIR)/$(ARCH)/arch/Makefile.inc
+include $(CURDIR)/common/Makefile.inc
+
+LIBSDIR+=	$(SRCDIR)/conf
+INCSDIR+=	$(CURDIR)/include $(CURDIR)/$(ARCH)
+ifndef LDSCRIPT
+LDSCRIPT:=	$(CURDIR)/$(ARCH)/arch/boot.ld
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(OBJS) $(LIBS) $(LDSCRIPT)
+	$(call echo-file,LD     ,$@)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(OBJS) $(LIBS) $(PLATFORM_LIBS)
+	$(ASMGEN)
+	$(SYMGEN)
+	$(OBJCOPY) -O binary -R .note -R .comment -S $@
diff --git a/prex-0.9.0/bsp/boot/arm/arch/Makefile.inc b/prex-0.9.0/bsp/boot/arm/arch/Makefile.inc
new file mode 100755
index 0000000..348aac1
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/arch/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS+=		arm/arch/elf_reloc.c
diff --git a/prex-0.9.0/bsp/boot/arm/arch/boot.ld b/prex-0.9.0/bsp/boot/arm/arch/boot.ld
new file mode 100755
index 0000000..f35dc13
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/arch/boot.ld
@@ -0,0 +1,31 @@
+/*
+ * Linker script for boot loader
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SECTIONS {
+	. = CONFIG_LOADER_TEXT ;
+
+	.text . : {
+		*(.text)
+	}
+	. = ALIGN(4);
+	.rodata . : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+	. = ALIGN(4);
+	.data . : {
+		*(.data)
+	}
+	. = ALIGN(4);
+	.bss . : {
+		*(.bss)
+		*(COMMON)
+	}
+	. = CONFIG_LOADER_TEXT + 0x1fff;
+	.tail : {
+		*(.tail)
+	}
+}
diff --git a/prex-0.9.0/bsp/boot/arm/arch/elf_reloc.c b/prex-0.9.0/bsp/boot/arm/arch/elf_reloc.c
new file mode 100755
index 0000000..d47071d
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/arch/elf_reloc.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/elf.h>
+#include <boot.h>
+
+int
+relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sect)
+{
+	Elf32_Addr *where, tmp;
+	Elf32_Sword addend;
+
+	where = (Elf32_Addr *)(target_sect + rel->r_offset);
+
+	switch (ELF32_R_TYPE(rel->r_info)) {
+	case R_ARM_NONE:
+		break;
+	case R_ARM_ABS32:
+		*where += (vaddr_t)ptokv(sym_val);
+		ELFDBG(("R_ARM_ABS32: %lx -> %lx\n",
+			(long)where, (long)*where));
+		break;
+	case R_ARM_PC24:
+	case R_ARM_PLT32:
+	case R_ARM_CALL:
+	case R_ARM_JUMP24:
+		addend = (Elf32_Sword)(*where & 0x00ffffff);
+		if (addend & 0x00800000)
+			addend |= 0xff000000;
+		tmp = sym_val - (Elf32_Addr)where + (addend << 2);
+		tmp >>= 2;
+		*where = (*where & 0xff000000) | (tmp & 0x00ffffff);
+		ELFDBG(("R_ARM_PC24: %lx -> %lx\n",
+			(long)where, (long)*where));
+		break;
+	default:
+		ELFDBG(("Unkown relocation type=%d\n",
+			ELF32_R_TYPE(rel->r_info)));
+		panic("relocation fail");
+		return -1;
+	}
+	return 0;
+}
+
+int
+relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sec)
+{
+
+	panic("invalid relocation type");
+	return -1;
+}
diff --git a/prex-0.9.0/bsp/boot/arm/arch/head.S b/prex-0.9.0/bsp/boot/arm/arch/head.S
new file mode 100755
index 0000000..2fd1955
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/arch/head.S
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * head.S - generic header code for ARM platforms.
+ */
+
+#include <conf/config.h>
+#include <machine/memory.h>
+#include <machine/syspage.h>
+
+#define ENTRY(x) .global x; .align; x##:
+
+	.section ".text","ax"
+	.code 32
+/*
+ * Loader entry point
+ */
+ENTRY(boot_entry)
+	b	start_vector
+
+	.align
+	.code 32
+stack_end:	.word	(BOOTSTKTOP - KERNBASE)
+
+start_vector:
+	mov	r0, #0xd3		/* Enter SVC mode, Disable IRQ,FIQ */
+	msr	cpsr_c, r0
+	ldr	sp, stack_end
+
+	adr	r0, thumb_mode + 1
+	bx	r0
+	.code 16
+thumb_mode:
+
+	ldr	r0, =main
+	bx	r0			/* Change to ARM mode */
+
+	.section .tail,"ax"
+dummy:
+	.byte	0xff
+
+.end
diff --git a/prex-0.9.0/bsp/boot/arm/gba/Makefile.inc b/prex-0.9.0/bsp/boot/arm/gba/Makefile.inc
new file mode 100755
index 0000000..84906ac
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/gba/Makefile.inc
@@ -0,0 +1,5 @@
+
+SRCS:=		arm/gba/head.S \
+		arm/gba/startup.c \
+		arm/gba/debug.c
+
diff --git a/prex-0.9.0/bsp/boot/arm/gba/debug.c b/prex-0.9.0/bsp/boot/arm/gba/debug.c
new file mode 100755
index 0000000..a85df3b
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/gba/debug.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <boot.h>
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_VBA)
+extern void vba_putc(int);
+#endif
+
+/*
+ * Print one chracter
+ */
+void
+debug_putc(int c)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_VBA)
+	vba_putc(c);
+#endif
+}
+
+/*
+ * Initialize debug port.
+ */
+void
+debug_init(void)
+{
+	/* DO NOTHING */
+}
+
diff --git a/prex-0.9.0/bsp/boot/arm/gba/head.S b/prex-0.9.0/bsp/boot/arm/gba/head.S
new file mode 100755
index 0000000..90a1548
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/gba/head.S
@@ -0,0 +1,182 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * head.S - low level platform support
+ *
+ * This file contains the code from crt0.S which is released under
+ * public domain by Jeff Frohwein.
+ */
+
+/*-
+ * Memory usage:
+ *
+ * 0x02000000 - 0x0203ffff : EWRAM (256K)
+ * 0x03000000 - 0x03007fff : IWRAM (32K)
+ * 0x04000000 - 0x040003ff : I/O Register (1K)
+ * 0x05000000 - 0x050003ff : Palette RAM (1K)
+ * 0x06000000 - 0x06017fff : VRAM (96K)
+ *
+ * Note:
+ * 0x03007f00 - 0x03007fff is reserved by GBA BIOS.
+ */
+
+#include <conf/config.h>
+#include <machine/memory.h>
+#include <machine/syspage.h>
+
+#define ENTRY(x) .global x; .align; x##:
+
+	.section ".text","ax"
+	.code 32
+/*
+ * Loader start point
+ */
+ENTRY(boot_entry)
+	b	rom_header_end
+
+	/*
+	 * GBA ROM header
+	 */
+
+	/* Nintendo Logo Character Data (8000004h) */
+	.fill	156,1,0
+
+	/* Game Title (80000A0h) */
+	.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+	.byte	0x00,0x00,0x00,0x00
+
+	/* Game Code (80000ACh) */
+	.byte	0x00,0x00,0x00,0x00
+
+	/* Maker Code (80000B0h) */
+	.byte	0x30,0x31
+
+	/* Fixed Value (80000B2h) */
+	.byte	0x96
+
+	/* Main Unit Code (80000B3h) */
+	.byte	0x00
+
+	/* Device Type (80000B4h) */
+	.byte	0x00
+
+	/* Unused Data (7Byte) (80000B5h) */
+	.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00
+
+	/* Software Version No (80000BCh) */
+	.byte	0x00
+
+	/* Complement Check (80000BDh) */
+	.byte	0xf0
+
+	/* Checksum (80000BEh) */
+	.byte	0x00,0x00
+
+	.align
+	.code 32
+
+rom_header_end:
+	b	start_vector
+
+	.global __boot_method, __slave_number
+
+__boot_method:
+	.byte	0	/* boot method (0=ROM boot, 3=Multiplay boot) */
+__slave_number:
+	.byte	0	/* slave # (1=slave#1, 2=slave#2, 3=slave#3) */
+
+	.byte	0
+	.byte	0
+	.word	0
+	.word	0
+	.word	0
+	.word	0
+	.word	0
+	.word	0
+
+	.align
+	.code 32
+stack_top:	.word	(BOOTSTKTOP - KERNBASE)
+
+start_vector:
+	mov	r0, #0xd3		/* Enter SVC mode, Disable IRQ,FIQ */
+	msr	cpsr_c, r0
+	ldr	sp, stack_top
+
+	adr	r0, thumb_mode + 1
+	bx	r0
+	.code 16
+thumb_mode:
+
+/*
+ * Relocate the loader code
+ */
+	mov	r3, #0x40
+	lsl	r3, r3, #7  /* r3 = 0x2000 (8K) */
+	mov	r2, #3
+	lsl	r2, r2, #24 /* r2 = 0x3000000 */
+	lsl	r1, r3, #14 /* r1 = 0x8000000 */
+
+copy_loop:
+	ldmia	r1!, {r0}
+	stmia	r2!, {r0}
+	sub	r3, r3, #4
+	bne	copy_loop
+
+	ldr	r0, =main
+	bx	r0		/* Change to ARM mode */
+
+	.code 32
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_VBA)
+/*
+ * Put one character to Visual Boy Advance (VBA) emulator console.
+ *
+ * Important:
+ * This BIOS call is not supported by actual GBA BIOS. So, you must
+ * disable this function when you run it on actual GBA H/W.
+ * Otherwise, it will hang.
+ */
+putbuf:
+	.long	0
+
+ENTRY(vba_putc)
+	ldr	r1, =putbuf
+	str	r0, [r1]
+	mov	r0, r1
+	swi	$0xff0000
+	mov	pc, lr
+#endif
+
+	.section .tail,"ax"
+dummy:
+	.byte	0xff
+
+.end
diff --git a/prex-0.9.0/bsp/boot/arm/gba/startup.c b/prex-0.9.0/bsp/boot/arm/gba/startup.c
new file mode 100755
index 0000000..c679cad
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/gba/startup.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/bootinfo.h>
+#include <boot.h>
+
+/*
+ * Setup boot information.
+ */
+static void
+bootinfo_init(void)
+{
+       	struct bootinfo *bi = bootinfo;
+
+	/*
+	 * Screen size
+	 */
+	bi->video.text_x = 30;
+	bi->video.text_y = 20;
+
+	/*
+	 * EWRAM - 256K
+	 */
+	bi->ram[0].base = 0x2000000;
+	bi->ram[0].size = 0x40000;
+	bi->ram[0].type = MT_USABLE;
+
+	bi->nr_rams = 1;
+}
+
+void
+startup(void)
+{
+
+	bootinfo_init();
+}
diff --git a/prex-0.9.0/bsp/boot/arm/integrator/Makefile.inc b/prex-0.9.0/bsp/boot/arm/integrator/Makefile.inc
new file mode 100755
index 0000000..09a11b4
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/integrator/Makefile.inc
@@ -0,0 +1,5 @@
+
+SRCS:=		arm/arch/head.S \
+		arm/integrator/startup.c \
+		arm/integrator/debug.c
+
diff --git a/prex-0.9.0/bsp/boot/arm/integrator/debug.c b/prex-0.9.0/bsp/boot/arm/integrator/debug.c
new file mode 100755
index 0000000..5830fd1
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/integrator/debug.c
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <boot.h>
+
+#define UART_BASE	0x16000000
+#define UART_CLK	14745600
+#define BAUD_RATE	115200
+
+/* UART Registers */
+#define UART_DR		(*(volatile uint32_t *)(UART_BASE + 0x00))
+#define UART_RSR	(*(volatile uint32_t *)(UART_BASE + 0x04))
+#define UART_ECR	(*(volatile uint32_t *)(UART_BASE + 0x04))
+#define UART_FR		(*(volatile uint32_t *)(UART_BASE + 0x18))
+#define UART_IBRD	(*(volatile uint32_t *)(UART_BASE + 0x24))
+#define UART_FBRD	(*(volatile uint32_t *)(UART_BASE + 0x28))
+#define UART_LCRH	(*(volatile uint32_t *)(UART_BASE + 0x2c))
+#define UART_CR		(*(volatile uint32_t *)(UART_BASE + 0x30))
+#define UART_IMSC	(*(volatile uint32_t *)(UART_BASE + 0x38))
+#define UART_MIS	(*(volatile uint32_t *)(UART_BASE + 0x40))
+#define UART_ICR	(*(volatile uint32_t *)(UART_BASE + 0x44))
+
+/* Flag register */
+#define FR_RXFE		0x10	/* Receive FIFO empty */
+#define FR_TXFF		0x20	/* Transmit FIFO full */
+
+/* Masked interrupt status register */
+#define MIS_RX		0x10	/* Receive interrupt */
+#define MIS_TX		0x20	/* Transmit interrupt */
+
+/* Interrupt clear register */
+#define ICR_RX		0x10	/* Clear receive interrupt */
+#define ICR_TX		0x20	/* Clear transmit interrupt */
+
+/* Line control register (High) */
+#define LCRH_WLEN8	0x60	/* 8 bits */
+#define LCRH_FEN	0x10	/* Enable FIFO */
+
+/* Control register */
+#define CR_UARTEN	0x0001	/* UART enable */
+#define CR_TXE		0x0100	/* Transmit enable */
+#define CR_RXE		0x0200	/* Receive enable */
+
+/* Interrupt mask set/clear register */
+#define IMSC_RX		0x10	/* Receive interrupt mask */
+#define IMSC_TX		0x20	/* Transmit interrupt mask */
+
+/*
+ * Print one chracter
+ */
+void
+debug_putc(int c)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
+	while (UART_FR & FR_TXFF)
+		;
+	UART_DR = c;
+#endif
+}
+
+/*
+ * Initialize debug port.
+ */
+void
+debug_init(void)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
+	unsigned int divider;
+	unsigned int remainder;
+	unsigned int fraction;
+
+	UART_CR = 0x0;		/* Disable everything */
+	UART_ICR = 0x07ff;	/* Clear all interrupt status */
+
+	/*
+	 * Set baud rate:
+	 * IBRD = UART_CLK / (16 * BAUD_RATE)
+	 * FBRD = ROUND((64 * MOD(UART_CLK,(16 * BAUD_RATE))) / (16 * BAUD_RATE))
+	 */
+	divider = UART_CLK / (16 * BAUD_RATE);
+	remainder = UART_CLK % (16 * BAUD_RATE);
+	fraction = (8 * remainder / BAUD_RATE) >> 1;
+	fraction += (8 * remainder / BAUD_RATE) & 1;
+	UART_IBRD = divider;
+	UART_FBRD = fraction;
+
+	UART_LCRH = (LCRH_WLEN8 | LCRH_FEN);	/* N, 8, 1, FIFO enable */
+	UART_CR = (CR_RXE | CR_TXE | CR_UARTEN);	/* Enable UART */
+#endif
+}
diff --git a/prex-0.9.0/bsp/boot/arm/integrator/startup.c b/prex-0.9.0/bsp/boot/arm/integrator/startup.c
new file mode 100755
index 0000000..899c191
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/arm/integrator/startup.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/bootinfo.h>
+#include <boot.h>
+
+/*
+ * Setup boot information.
+ */
+static void
+bootinfo_init(void)
+{
+	struct bootinfo *bi = bootinfo;
+
+	/*
+	 * Screen size
+	 */
+	bi->video.text_x = 80;
+	bi->video.text_y = 25;
+
+	/*
+	 * On-board SSRAM - 4M
+	 */
+	bi->ram[0].base = 0;
+	bi->ram[0].size = 0x400000;
+	bi->ram[0].type = MT_USABLE;
+
+	bi->nr_rams = 1;
+}
+
+void
+startup(void)
+{
+
+	bootinfo_init();
+}
diff --git a/prex-0.9.0/bsp/boot/common/Makefile.inc b/prex-0.9.0/bsp/boot/common/Makefile.inc
new file mode 100755
index 0000000..6422f8a
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/Makefile.inc
@@ -0,0 +1,8 @@
+
+SRCS+=		common/main.c \
+		common/bootinfo.c \
+		common/load.c \
+		common/elf.c \
+		common/splash.c \
+		common/string.c \
+		common/printf.c
diff --git a/prex-0.9.0/bsp/boot/common/bootinfo.c b/prex-0.9.0/bsp/boot/common/bootinfo.c
new file mode 100755
index 0000000..8623ba4
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/bootinfo.c
@@ -0,0 +1,95 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * bootinfo.c - Boot information
+ */
+
+#include <boot.h>
+#include <sys/bootinfo.h>
+#include <machine/syspage.h>
+
+/*
+ * Boot information holds various platform dependent data that
+ * can be referred by kernel/drivers.
+ */
+struct bootinfo *const bootinfo = (struct bootinfo *)kvtop(BOOTINFO);
+
+
+#if defined(DEBUG) && defined(DEBUG_BOOTINFO)
+static void
+print_module(struct module *m)
+{
+
+	printf("%lx %lx %x %lx %lx %x %x %x %s\n",
+	       m->entry, m->phys, m->size,
+	       m->text, m->data, m->textsz,
+	       m->datasz, m->bsssz, m->name);
+}
+
+void
+dump_bootinfo(void)
+{
+	static const char strtype[][9] = \
+		{ "", "USABLE", "MEMHOLE", "RESERVED", "BOOTDISK" };
+	struct module *m;
+	struct bootinfo *bi = bootinfo;
+	int i;
+
+	printf("[Boot information]\n");
+
+	printf("nr_rams=%d\n", bi->nr_rams);
+	for (i = 0; i < bi->nr_rams; i++) {
+		if (bi->ram[i].type != 0) {
+			printf("ram[%d]:  base=%lx size=%x type=%s\n", i,
+			       bi->ram[i].base,
+			       bi->ram[i].size,
+			       strtype[bi->ram[i].type]);
+		}
+	}
+
+	printf("bootdisk: base=%lx size=%x\n",
+	       bi->bootdisk.base,
+	       bi->bootdisk.size);
+
+	printf("entry    phys     size     text     data     textsz   datasz   bsssz    module\n");
+	printf("-------- -------- -------- -------- -------- -------- -------- -------- ------\n");
+	print_module(&bi->kernel);
+	print_module(&bi->driver);
+
+	m = (struct module *)&bi->tasks[0];
+	for (i = 0; i < bi->nr_tasks; i++, m++)
+		print_module(m);
+}
+#else
+void
+dump_bootinfo(void)
+{
+}
+#endif
diff --git a/prex-0.9.0/bsp/boot/common/elf.c b/prex-0.9.0/bsp/boot/common/elf.c
new file mode 100755
index 0000000..a64fcac
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/elf.c
@@ -0,0 +1,372 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * elf.c - ELF file format support
+ */
+
+#include <boot.h>
+#include <load.h>
+#include <sys/elf.h>
+#include <elf_reloc.h>
+
+/* forward declarations */
+static int	load_executable(char *, struct module *);
+static int	load_relocatable(char *, struct module *);
+
+#define SHF_VALID	(SHF_ALLOC | SHF_EXECINSTR | SHF_ALLOC | SHF_WRITE)
+
+static char *sect_addr[32];	/* array of section address */
+static int strshndx;		/* index of string section */
+
+/*
+ * Load the program from specified ELF image stored in memory.
+ * The boot information is filled after loading the program.
+ */
+int
+load_elf(char *img, struct module *m)
+{
+	Elf32_Ehdr *ehdr;
+	Elf32_Phdr *phdr;
+
+	ELFDBG(("\nelf_load\n"));
+
+	ehdr = (Elf32_Ehdr *)img;
+
+	/*  Check ELF header */
+	if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) ||
+	    (ehdr->e_ident[EI_MAG1] != ELFMAG1) ||
+	    (ehdr->e_ident[EI_MAG2] != ELFMAG2) ||
+	    (ehdr->e_ident[EI_MAG3] != ELFMAG3)) {
+		DPRINTF(("Invalid ELF image\n"));
+		return -1;
+	}
+
+	phdr = (Elf32_Phdr *)((paddr_t)ehdr + ehdr->e_ehsize);
+
+	if (nr_img == 0) {
+		/*  Initialize the load address */
+		load_base = (vaddr_t)ptokv(phdr->p_paddr);
+		if (load_base == 0) {
+			DPRINTF(("Invalid load address\n"));
+			return -1;
+		}
+		ELFDBG(("kernel base=%lx\n", load_base));
+		load_start = load_base;
+	}
+	else if (nr_img == 1) {
+		/* 2nd image => Driver */
+		ELFDBG(("driver base=%lx\n", load_base));
+	}
+	else {
+		/* Other images => Boot tasks */
+		ELFDBG(("task base=%lx\n", load_base));
+	}
+
+	switch (ehdr->e_type) {
+	case ET_EXEC:
+		if (load_executable(img, m) != 0)
+			return -1;
+		break;
+	case ET_REL:
+		if (load_relocatable(img, m) != 0)
+			return -1;
+		break;
+	default:
+		ELFDBG(("Unsupported file type\n"));
+		return -1;
+	}
+	nr_img++;
+	return 0;
+}
+
+static int
+load_executable(char *img, struct module *m)
+{
+	Elf32_Ehdr *ehdr;
+	Elf32_Phdr *phdr;
+	paddr_t phys_base;
+	int i;
+
+	phys_base = load_base;
+	ehdr = (Elf32_Ehdr *)img;
+	phdr = (Elf32_Phdr *)((paddr_t)ehdr + ehdr->e_phoff);
+	m->phys = load_base;
+	phys_base = load_base;
+	ELFDBG(("phys addr=%lx\n", phys_base));
+
+	for (i = 0; i < (int)ehdr->e_phnum; i++, phdr++) {
+		if (phdr->p_type != PT_LOAD)
+			continue;
+
+		ELFDBG(("p_flags=%x\n", (int)phdr->p_flags));
+		ELFDBG(("p_align=%x\n", (int)phdr->p_align));
+		ELFDBG(("p_paddr=%x\n", phdr->p_paddr));
+
+		if (i >= 2) {
+			ELFDBG(("skipping extra phdr\n"));
+			continue;
+		}
+		if (phdr->p_flags & PF_X) {
+			/* Text */
+			m->text = phdr->p_vaddr;
+			m->textsz = (size_t)phdr->p_memsz;
+		} else {
+			/* Data & BSS */
+			m->data = phdr->p_vaddr;
+			m->datasz = (size_t)phdr->p_filesz;
+			m->bsssz =
+				(size_t)(phdr->p_memsz - phdr->p_filesz);
+			load_base = phys_base + (m->data - m->text);
+		}
+		if (phdr->p_filesz > 0) {
+			memcpy((char *)load_base, img + phdr->p_offset,
+			       (size_t)phdr->p_filesz);
+			ELFDBG(("load: offset=%lx size=%x\n",
+				 load_base, (int)phdr->p_filesz));
+		}
+		if (!(phdr->p_flags & PF_X)) {
+			if (m->bsssz > 0) {
+				/* Zero fill BSS */
+				memset((char *)load_base + m->datasz,
+				       0, m->bsssz);
+			}
+			load_base += phdr->p_memsz;
+		}
+	}
+	/* workaround for data/bss size is 0 */
+	if (m->data == 0)
+		load_base = phys_base + m->textsz;
+
+	load_base = round_page(load_base);
+	m->size = (size_t)(load_base - m->phys);
+	m->entry = ehdr->e_entry;
+	ELFDBG(("module size=%x entry=%lx\n", m->size, m->entry));
+
+	if (m->size == 0)
+		panic("Module size is 0!");
+	return 0;
+}
+
+static int
+relocate_section_rela(Elf32_Sym *sym_table, Elf32_Rela *rela,
+		      char *target_sect, int nr_reloc, char *strtab)
+{
+	Elf32_Sym *sym;
+	Elf32_Addr sym_val;
+	int i;
+
+	for (i = 0; i < nr_reloc; i++) {
+		sym = &sym_table[ELF32_R_SYM(rela->r_info)];
+		ELFDBG(("%s\n", strtab + sym->st_name));
+		if (sym->st_shndx != STN_UNDEF) {
+			sym_val = (Elf32_Addr)sect_addr[sym->st_shndx]
+				+ sym->st_value;
+			if (relocate_rela(rela, sym_val, target_sect) != 0)
+				return -1;
+		} else if (ELF32_ST_BIND(sym->st_info) != STB_WEAK) {
+			DPRINTF(("Undefined symbol for rela[%x] sym=%lx\n",
+				 i, (long)sym));
+			return -1;
+		} else {
+			DPRINTF(("Undefined weak symbol for rela[%x]\n", i));
+		}
+		rela++;
+	}
+	return 0;
+}
+
+static int
+relocate_section_rel(Elf32_Sym *sym_table, Elf32_Rel *rel,
+		     char *target_sect, int nr_reloc, char *strtab)
+{
+	Elf32_Sym *sym;
+	Elf32_Addr sym_val;
+	int i;
+
+	for (i = 0; i < nr_reloc; i++) {
+		sym = &sym_table[ELF32_R_SYM(rel->r_info)];
+		ELFDBG(("%s\n", strtab + sym->st_name));
+		if (sym->st_shndx != STN_UNDEF) {
+			sym_val = (Elf32_Addr)sect_addr[sym->st_shndx]
+				+ sym->st_value;
+			if (relocate_rel(rel, sym_val, target_sect) != 0)
+				return -1;
+		} else if (ELF32_ST_BIND(sym->st_info) != STB_WEAK) {
+			DPRINTF(("Undefined symbol for rel[%x] sym=%lx\n",
+				 i, (long)sym));
+			return -1;
+		} else {
+			DPRINTF(("Undefined weak symbol for rel[%x]\n", i));
+		}
+		rel++;
+	}
+	return 0;
+}
+
+static int
+relocate_section(char *img, Elf32_Shdr *shdr)
+{
+	Elf32_Sym *symtab;
+	char *target_sect;
+	int nr_reloc, error;
+	char *strtab;
+
+	ELFDBG(("relocate_section\n"));
+
+	if (shdr->sh_entsize == 0)
+		return 0;
+	if ((target_sect = sect_addr[shdr->sh_info]) == 0)
+		return -1;
+	if ((symtab = (Elf32_Sym *)sect_addr[shdr->sh_link]) == 0)
+		return -1;
+	if ((strtab = sect_addr[strshndx]) == 0)
+		return -1;
+	ELFDBG(("strtab=%x\n", strtab));
+
+	nr_reloc = (int)(shdr->sh_size / shdr->sh_entsize);
+	switch (shdr->sh_type) {
+	case SHT_REL:
+		error = relocate_section_rel(symtab,
+				(Elf32_Rel *)(img + shdr->sh_offset),
+				target_sect, nr_reloc, strtab);
+		break;
+
+	case SHT_RELA:
+		error = relocate_section_rela(symtab,
+				(Elf32_Rela *)(img + shdr->sh_offset),
+				target_sect, nr_reloc, strtab);
+		break;
+
+	default:
+		error = -1;
+		break;
+	}
+	return error;
+}
+
+static int
+load_relocatable(char *img, struct module *m)
+{
+	Elf32_Ehdr *ehdr;
+	Elf32_Shdr *shdr;
+	paddr_t sect_base, bss_base;
+	int i;
+
+	strshndx = 0;
+	ehdr = (Elf32_Ehdr *)img;
+	shdr = (Elf32_Shdr *)((paddr_t)ehdr + ehdr->e_shoff);
+	bss_base = 0;
+	m->phys = load_base;
+	ELFDBG(("phys addr=%lx\n", load_base));
+
+	/* Copy sections */
+	for (i = 0; i < (int)ehdr->e_shnum; i++, shdr++) {
+		sect_addr[i] = 0;
+		if (shdr->sh_type == SHT_PROGBITS) {
+
+			ELFDBG(("sh_addr=%x\n", shdr->sh_addr));
+			ELFDBG(("sh_size=%x\n", shdr->sh_size));
+			ELFDBG(("sh_offset=%x\n", shdr->sh_offset));
+			ELFDBG(("sh_flags=%x\n", shdr->sh_flags));
+
+			switch (shdr->sh_flags & SHF_VALID) {
+			case (SHF_ALLOC | SHF_EXECINSTR):
+				/* Text */
+				m->text = (vaddr_t)ptokv(load_base);
+				break;
+			case (SHF_ALLOC | SHF_WRITE):
+				/* Data */
+				if (m->data == 0) {
+					m->data = (vaddr_t)ptokv(load_base +
+								 shdr->sh_addr);
+				}
+				break;
+			case SHF_ALLOC:
+				/* rodata */
+				/* Note: rodata is treated as text. */
+				break;
+			default:
+				continue;
+			}
+			sect_base = load_base + shdr->sh_addr;
+			memcpy((char *)sect_base, img + shdr->sh_offset,
+			       (size_t)shdr->sh_size);
+			ELFDBG(("load: offset=%lx size=%x\n",
+				 sect_base, (int)shdr->sh_size));
+
+			sect_addr[i] = (char *)sect_base;
+		} else if (shdr->sh_type == SHT_NOBITS) {
+			/* BSS */
+			m->bsssz = (size_t)shdr->sh_size;
+			sect_base = load_base + shdr->sh_addr;
+			bss_base = sect_base;
+
+			/* Zero fill BSS */
+			memset((char *)bss_base, 0, (size_t)shdr->sh_size);
+
+			sect_addr[i] = (char *)sect_base;
+		} else if (shdr->sh_type == SHT_SYMTAB) {
+			/* Symbol table */
+			ELFDBG(("load: symtab index=%d link=%d\n",
+				i, shdr->sh_link));
+			sect_addr[i] = img + shdr->sh_offset;
+			if (strshndx != 0)
+				panic("Multiple symtab found!");
+			strshndx = (int)shdr->sh_link;
+		} else if (shdr->sh_type == SHT_STRTAB) {
+			/* String table */
+			sect_addr[i] = img + shdr->sh_offset;
+			ELFDBG(("load: strtab index=%d addr=%x\n",
+				i, sect_addr[i]));
+		}
+	}
+	m->textsz = (size_t)(m->data - m->text);
+	m->datasz = (size_t)((char *)ptokv(bss_base) - m->data);
+
+	load_base = bss_base + m->bsssz;
+	load_base = round_page(load_base);
+
+	ELFDBG(("module load_base=%lx text=%lx\n", load_base, m->text));
+	m->size = (size_t)(load_base - kvtop(m->text));
+	m->entry = (vaddr_t)ptokv(ehdr->e_entry + m->phys);
+	ELFDBG(("module size=%x entry=%lx\n", m->size, m->entry));
+
+	/* Process relocation */
+	shdr = (Elf32_Shdr *)((paddr_t)ehdr + ehdr->e_shoff);
+	for (i = 0; i < (int)ehdr->e_shnum; i++, shdr++) {
+		if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) {
+			if (relocate_section(img, shdr) != 0) {
+				DPRINTF(("Relocation error: module=%s\n", m->name));
+				return -1;
+			}
+		}
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/boot/common/load.c b/prex-0.9.0/bsp/boot/common/load.c
new file mode 100755
index 0000000..5927a33
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/load.c
@@ -0,0 +1,213 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * load.c - Load OS modules
+ */
+
+#include <boot.h>
+#include <load.h>
+#include <sys/ar.h>
+#include <sys/bootinfo.h>
+
+/* forward declarations */
+static int	load_module(struct ar_hdr *, struct module *);
+static void	setup_bootdisk(struct ar_hdr *);
+
+paddr_t	load_base;	/* current load address */
+paddr_t	load_start;	/* start address for loading */
+int	nr_img;		/* number of module images */
+
+
+/*
+ * Load OS images - kernel, driver and boot tasks.
+ *
+ * It reads each module file image and copy it to the appropriate
+ * memory area. The image is built as generic an archive (.a) file.
+ *
+ * The image information is stored into the boot information area.
+ */
+void
+load_os(void)
+{
+	char *hdr;
+	struct bootinfo *bi = bootinfo;
+	struct module *m;
+	char *magic;
+	int i;
+	long len;
+
+	/*
+	 * Initialize our data.
+	 */
+	load_base = 0;
+	load_start = 0;
+	nr_img = 0;
+
+	/*
+	 *  Sanity check of archive image.
+	 */
+	magic = (char *)kvtop(CONFIG_BOOTIMG_BASE);
+	if (strncmp(magic, ARMAG, 8))
+		panic("Invalid OS image");
+
+	/*
+	 * Load kernel module.
+	 */
+	hdr = (char *)((paddr_t)magic + 8);
+	if (load_module((struct ar_hdr *)hdr, &bi->kernel))
+		panic("Can not load kernel");
+
+	/*
+	 * Load driver module.
+	 */
+	len = atol((char *)&((struct ar_hdr *)hdr)->ar_size);
+	len += len % 2;	/* even alignment */
+	if (len == 0)
+		panic("Invalid driver image");
+	hdr = (char *)((paddr_t)hdr + sizeof(struct ar_hdr) + len);
+	if (load_module((struct ar_hdr *)hdr, &bi->driver))
+		panic("Can not load driver");
+
+	/*
+	 * Load boot tasks.
+	 */
+	i = 0;
+	m = (struct module *)&bi->tasks[0];
+	while (1) {
+		/* Proceed to next archive header */
+		len = atol((char *)&((struct ar_hdr *)hdr)->ar_size);
+		len += len % 2;	/* even alignment */
+		if (len == 0)
+			break;
+		hdr = (char *)((paddr_t)hdr + sizeof(struct ar_hdr) + len);
+
+		/* Check archive header */
+		if (strncmp((char *)&((struct ar_hdr *)hdr)->ar_fmag,
+			    ARFMAG, 2))
+			break;
+
+		/* Load boot disk image */
+		if (!strncmp((char *)&((struct ar_hdr *)hdr)->ar_name,
+			    "bootdisk.a", 10)) {
+			setup_bootdisk((struct ar_hdr *)hdr);
+			continue;
+		}
+
+		/* Load task */
+		if (load_module((struct ar_hdr *)hdr, m))
+			break;
+		i++;
+		m++;
+	}
+
+	bi->nr_tasks = i;
+
+	if (bi->nr_tasks == 0)
+		panic("No boot task found!");
+
+	/*
+	 * Reserve single memory block for all boot modules.
+	 * This includes kernel, driver, and boot tasks.
+	 */
+	i = bi->nr_rams;
+	bi->ram[i].base = load_start;
+	bi->ram[i].size = (size_t)(load_base - load_start);
+	bi->ram[i].type = MT_RESERVED;
+	bi->nr_rams++;
+}
+
+/*
+ * Load module.
+ * Return 0 on success, -1 on failure.
+ */
+static int
+load_module(struct ar_hdr *hdr, struct module *m)
+{
+	char *c;
+
+	if (strncmp((char *)&hdr->ar_fmag, ARFMAG, 2)) {
+		DPRINTF(("Invalid image %s\n", hdr->ar_name));
+		return -1;
+	}
+	strlcpy(m->name, hdr->ar_name, sizeof(m->name));
+	c = m->name;
+	while (*c != '/' && *c != ' ')
+		c++;
+	*c = '\0';
+
+ 	DPRINTF(("loading: hdr=%lx module=%lx name=%s\n",
+		 (paddr_t)hdr, (paddr_t)m, m->name));
+
+	if (load_elf((char *)hdr + sizeof(struct ar_hdr), m))
+		panic("Load error");
+
+	return 0;
+}
+
+/*
+ * Setup boot disk
+ */
+static void
+setup_bootdisk(struct ar_hdr *hdr)
+{
+	struct bootinfo *bi = bootinfo;
+	paddr_t base;
+	size_t size;
+
+	/*
+	 * Store image information.
+	 */
+	if (strncmp((char *)&hdr->ar_fmag, ARFMAG, 2)) {
+		DPRINTF(("Invalid bootdisk image\n"));
+		return;
+	}
+	size = (size_t)atol((char *)&hdr->ar_size);
+	size += size % 2;	/* even alignment */
+	if (size == 0) {
+		DPRINTF(("Size of bootdisk is zero\n"));
+		return;
+	}
+	base = (paddr_t)hdr + sizeof(struct ar_hdr);
+	bi->bootdisk.base = base;
+	bi->bootdisk.size = size;
+
+#if !defined(CONFIG_ROMBOOT)
+	/*
+	 * Reserve memory for boot disk if the image
+	 * was copied to RAM.
+	 */
+	bi->ram[bi->nr_rams].base = base;
+	bi->ram[bi->nr_rams].size = size;
+	bi->ram[bi->nr_rams].type = MT_BOOTDISK;
+	bi->nr_rams++;
+#endif
+	DPRINTF(("bootdisk base=%lx size=%lx\n",
+		 bi->bootdisk.base, bi->bootdisk.size));
+}
diff --git a/prex-0.9.0/bsp/boot/common/main.c b/prex-0.9.0/bsp/boot/common/main.c
new file mode 100755
index 0000000..2756e80
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/main.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * main.c - Boot loader main module.
+ */
+
+#include <boot.h>
+#include <machdep.h>
+#include <sys/bootinfo.h>
+#include "load.h"
+
+typedef void (*entry_t)(void);
+
+/*
+ * Loader main routine
+ *
+ * We assume that the following machine state has
+ * been already set before this routine.
+ *	- CPU is initialized.
+ *	- DRAM is configured.
+ *	- Loader BSS section is filled with 0.
+ *	- Loader stack is configured.
+ *	- All interrupts are disabled.
+ */
+int
+main(void)
+{
+	entry_t entry;
+
+	memset(bootinfo, 0, BOOTINFOSZ);
+
+	/*
+	 * Initialize debug port.
+	 */
+	debug_init();
+	DPRINTF(("Prex Boot Loader\n"));
+
+	/*
+	 * Do platform dependent initialization.
+	 */
+	startup();
+
+	/*
+	 * Show splash screen.
+	 */
+	splash();
+
+	/*
+	 * Load OS modules to appropriate locations.
+	 */
+	load_os();
+
+	/*
+	 * Dump boot infomation for debug.
+	 */
+	dump_bootinfo();
+
+	/*
+	 * Launch kernel.
+	 */
+	entry = (entry_t)kvtop(bootinfo->kernel.entry);
+	DPRINTF(("Entering kernel (at 0x%lx) ...\n\n", (long)entry));
+	(*entry)();
+
+	panic("Oops!");
+	/* NOTREACHED */
+	return 0;
+}
+
+/*
+ * panic - show error message and hang up.
+ */
+void
+panic(const char *msg)
+{
+
+	DPRINTF(("Panic: %s\n", msg));
+
+	for (;;) ;
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/bsp/boot/common/printf.c b/prex-0.9.0/bsp/boot/common/printf.c
new file mode 100755
index 0000000..305a8cb
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/printf.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * printf.c - print formatted string
+ */
+
+#include <sys/types.h>
+#include <machine/stdarg.h>
+#include <boot.h>
+#include <machdep.h>	/* for debug_putc */
+
+#ifdef DEBUG
+
+void
+printf(const char *fmt, ...)
+{
+	static const char digits[] = "0123456789abcdef";
+	va_list ap;
+	char buf[10];
+	char *s;
+	unsigned u;
+	int c, i, pad;
+
+	va_start(ap, fmt);
+	while ((c = *fmt++) != 0) {
+		if (c == '%') {
+			c = *fmt++;
+			/* ignore long */
+			if (c == 'l')
+				c = *fmt++;
+			switch (c) {
+			case 'c':
+				debug_putc(va_arg(ap, int));
+				continue;
+			case 's':
+				s = va_arg(ap, char *);
+				if (s == NULL)
+					s = "<NULL>";
+				for (; *s; s++) {
+					debug_putc((int)*s);
+				}
+				continue;
+			case 'd':
+				c = 'u';
+			case 'u':
+			case 'x':
+				u = va_arg(ap, unsigned);
+				s = buf;
+				if (c == 'u') {
+					do
+						*s++ = digits[u % 10U];
+					while (u /= 10U);
+				} else {
+					pad = 0;
+					for (i = 0; i < 8; i++) {
+						if (pad)
+							*s++ = '0';
+						else {
+							*s++ = digits[u % 16U];
+							if ((u /= 16U) == 0)
+								pad = 1;
+						}
+					}
+				}
+				while (--s >= buf)
+					debug_putc((int)*s);
+				continue;
+			}
+		}
+		if (c == '\n')
+			debug_putc('\r');
+		debug_putc((int)c);
+	}
+	va_end(ap);
+}
+
+#endif /* !DEBUG */
diff --git a/prex-0.9.0/bsp/boot/common/splash.c b/prex-0.9.0/bsp/boot/common/splash.c
new file mode 100755
index 0000000..a5a0b93
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/splash.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * splash.c - splash screen support.
+ */
+
+#include <boot.h>
+
+void
+splash(void)
+{
+#if defined(CONFIG_SPLASH)
+	/*
+	 * TODO: Show the vendor specific logo here...
+	 */
+#endif
+}
diff --git a/prex-0.9.0/bsp/boot/common/string.c b/prex-0.9.0/bsp/boot/common/string.c
new file mode 100755
index 0000000..33aff62
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/common/string.c
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * string.c - minimum string library
+ */
+
+#include <boot.h>
+
+/*
+ * Convert string to long interger
+ * This version does not support minus value.
+ */
+long
+atol(const char *str)
+{
+	long val = 0;
+
+	while (*str == ' ')
+		str++;
+	while (*str >= '0' && *str <= '9') {
+		val *= 10;
+		val += (long)(*str - '0');
+		str++;
+	}
+	return val;
+}
+
+/*
+ * Safer version of strncpy
+ * The destination string is always terminated with NULL character.
+ */
+size_t
+strlcpy(char *dest, const char *src, size_t count)
+{
+	char *d = dest;
+	const char *s = src;
+	size_t n = count;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0 && --n != 0) {
+		do {
+			if ((*d++ = *s++) == 0)
+				break;
+		} while (--n != 0);
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (count != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return (size_t)(s - src - 1);	/* count does not include NUL */
+}
+
+int
+strncmp(const char *src, const char *tgt, size_t count)
+{
+	signed char res = 0;
+
+	while (count) {
+		if ((res = *src - *tgt++) != 0 || !*src++)
+			break;
+		count--;
+	}
+	return res;
+}
+
+void *
+memcpy(void *dest, const void *src, size_t count)
+{
+	char *tmp = (char *)dest, *s = (char *)src;
+
+	while (count--)
+		*tmp++ = *s++;
+	return dest;
+}
+
+void *
+memset(void *dest, int ch, size_t count)
+{
+	char *p = (char *)dest;
+
+	while (count--)
+		*p++ = (char)ch;
+	return dest;
+}
diff --git a/prex-0.9.0/bsp/boot/include/boot.h b/prex-0.9.0/bsp/boot/include/boot.h
new file mode 100755
index 0000000..3a87e60
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/include/boot.h
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOOT_H
+#define _BOOT_H
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/bootinfo.h>
+
+/* #define DEBUG_ELF      1 */
+/* #define DEBUG_BOOTINFO 1 */
+
+#ifdef DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#ifdef DEBUG_ELF
+#define ELFDBG(a) printf a
+#else
+#define ELFDBG(a)
+#endif
+
+extern struct bootinfo *const bootinfo;
+
+__BEGIN_DECLS
+void	 panic(const char *);
+void	 dump_bootinfo(void);
+void	 splash(void);
+#ifdef DEBUG
+void	 printf(const char *, ...);
+#endif
+/* string.c */
+long	 atol(const char *);
+size_t	 strlcpy(char *, const char *, size_t);
+int	 strncmp(const char *, const char *, size_t);
+size_t	 strlcpy(char *, const char *, size_t);
+size_t	 strnlen(const char *, size_t);
+void	 *memcpy(void *, const void *, size_t);
+void	 *memset(void *, int, size_t);
+__END_DECLS
+
+#endif /* !_BOOT_H */
diff --git a/prex-0.9.0/bsp/boot/include/elf_reloc.h b/prex-0.9.0/bsp/boot/include/elf_reloc.h
new file mode 100755
index 0000000..6f4081f
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/include/elf_reloc.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOOT_ELF_RELOC_H
+#define _BOOT_ELF_RELOC_H
+
+#include <sys/elf.h>
+
+__BEGIN_DECLS
+int	relocate_rel(Elf32_Rel *, Elf32_Addr, char *);
+int	relocate_rela(Elf32_Rela *, Elf32_Addr, char *);
+__END_DECLS
+
+#endif /* !_BOOT_ELF_RELOC_H */
diff --git a/prex-0.9.0/bsp/boot/include/load.h b/prex-0.9.0/bsp/boot/include/load.h
new file mode 100755
index 0000000..6d5ed61
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/include/load.h
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOOT_LOAD_H
+#define _BOOT_LOAD_H
+
+#include <sys/cdefs.h>
+
+extern paddr_t	load_base;
+extern paddr_t	load_start;
+extern int	nr_img;
+
+__BEGIN_DECLS
+void	load_os(void);
+int	load_elf(char *, struct module *);
+__END_DECLS
+
+#endif /* !_BOOT_LOAD_H */
diff --git a/prex-0.9.0/bsp/boot/include/machdep.h b/prex-0.9.0/bsp/boot/include/machdep.h
new file mode 100755
index 0000000..b371535
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/include/machdep.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BOOT_MACHDEP_H
+#define _BOOT_MACHDEP_H
+
+__BEGIN_DECLS
+void	startup(void);
+void	debug_init(void);
+void	debug_putc(int);
+__END_DECLS
+
+#endif /* !_BOOT_MACHDEP_H */
diff --git a/prex-0.9.0/bsp/boot/ppc/arch/Makefile.inc b/prex-0.9.0/bsp/boot/ppc/arch/Makefile.inc
new file mode 100755
index 0000000..fe8258c
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/arch/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS+=		ppc/arch/elf_reloc.c
diff --git a/prex-0.9.0/bsp/boot/ppc/arch/boot.ld b/prex-0.9.0/bsp/boot/ppc/arch/boot.ld
new file mode 100755
index 0000000..ffd2ff4
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/arch/boot.ld
@@ -0,0 +1,35 @@
+/*
+ * Linker script for boot loader
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-powerpc")
+OUTPUT_ARCH(powerpc)
+
+SECTIONS {
+	. = CONFIG_LOADER_TEXT ;
+
+	.text . : {
+		*(.text)
+	}
+	. = ALIGN(4);
+	.rodata . : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+	. = ALIGN(4);
+	.data . : {
+		*(.data)
+		*(.sdata)
+		*(.sdata2)
+	}
+	. = ALIGN(4);
+	.bss . : {
+		*(.sbss)
+		*(.bss)
+		*(COMMON)
+	}
+	. = CONFIG_LOADER_TEXT + 0x1fff;
+	.tail : {
+		*(.tail)
+	}
+}
diff --git a/prex-0.9.0/bsp/boot/ppc/arch/elf_reloc.c b/prex-0.9.0/bsp/boot/ppc/arch/elf_reloc.c
new file mode 100755
index 0000000..bf0d0ee
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/arch/elf_reloc.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/elf.h>
+#include <boot.h>
+
+int
+relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sec)
+{
+
+	panic("invalid relocation type");
+	return -1;
+}
+
+int
+relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sect)
+{
+	Elf32_Addr *where;
+	uint32_t val;
+
+	where = (Elf32_Addr *)(target_sect + rela->r_offset);
+	val = sym_val + rela->r_addend;
+
+	switch (ELF32_R_TYPE(rela->r_info)) {
+	case R_PPC_NONE:
+		break;
+	case R_PPC_ADDR32:
+		ELFDBG(("R_PPC_ADDR32\n"));
+		*(uint32_t *)where = val;
+		break;
+	case R_PPC_ADDR16_LO:
+		ELFDBG(("R_PPC_ADDR16_LO\n"));
+		*(uint16_t *)where = (uint16_t)val;
+		break;
+	case R_PPC_ADDR16_HI:
+		ELFDBG(("R_PPC_ADDR16_HI\n"));
+		*(uint16_t *)where = (uint16_t)(val >> 16);
+		break;
+	case R_PPC_ADDR16_HA:
+		ELFDBG(("R_PPC_ADDR16_HA\n"));
+		*(uint16_t *)where = (uint16_t)((val + 0x8000) >> 16);
+		break;
+	case R_PPC_REL24:
+		ELFDBG(("R_PPC_REL24\n"));
+		*(uint32_t *)where =
+			(*(uint32_t *)where & ~0x03fffffc)
+			| ((val - (uint32_t)where)
+			   & 0x03fffffc);
+		break;
+	case R_PPC_REL32:
+		ELFDBG(("R_PPC_REL32\n"));
+		*(uint32_t *)where = val - (uint32_t)where;
+		break;
+	default:
+		ELFDBG(("Unkown relocation type=%d\n",
+			ELF32_R_TYPE(rela->r_info)));
+		panic("relocation fail");
+		return -1;
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/boot/ppc/prep/Makefile.inc b/prex-0.9.0/bsp/boot/ppc/prep/Makefile.inc
new file mode 100755
index 0000000..507189e
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/prep/Makefile.inc
@@ -0,0 +1,5 @@
+
+SRCS:=		ppc/prep/head.S \
+		ppc/prep/startup.c \
+		ppc/prep/debug.c
+
diff --git a/prex-0.9.0/bsp/boot/ppc/prep/Makefile.sysgen b/prex-0.9.0/bsp/boot/ppc/prep/Makefile.sysgen
new file mode 100755
index 0000000..7c2c37f
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/prep/Makefile.sysgen
@@ -0,0 +1,10 @@
+
+OSIMG:=		$(SRCDIR)/prexos
+PREPIMG:=	$(SRCDIR)/prexos.prep
+BOOTSECT:=	$(SRCDIR)/bsp/boot/$(ARCH)/tools/prepboot/bootsect.bin
+BOOTSECTO:=	$(SRCDIR)/bsp/boot/$(ARCH)/tools/prepboot/bootsect.o
+CLEANS+=	$(BOOTSECT) $(BOOTSECTO) $(PREPIMG)
+
+sysgen=		@($(MAKE) -C $(SRCDIR)/bsp/boot/$(ARCH)/tools/prepboot; \
+		  cat $(BOOTSECT) $(OSIMG) > $(PREPIMG);)
+
diff --git a/prex-0.9.0/bsp/boot/ppc/prep/debug.c b/prex-0.9.0/bsp/boot/ppc/prep/debug.c
new file mode 100755
index 0000000..46b2093
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/prep/debug.c
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <boot.h>
+
+
+#define SCREEN_80x25 1
+/* #define SCREEN_80x50 1 */
+
+#define COM_BASE	CONFIG_NS16550_BASE
+
+/* Register offsets */
+#define COM_RBR		(COM_BASE + 0x00)	/* receive buffer register */
+#define COM_THR		(COM_BASE + 0x00)	/* transmit holding register */
+#define COM_IER		(COM_BASE + 0x01)	/* interrupt enable register */
+#define COM_FCR		(COM_BASE + 0x02)	/* FIFO control register */
+#define COM_IIR		(COM_BASE + 0x02)	/* interrupt identification register */
+#define COM_LCR		(COM_BASE + 0x03)	/* line control register */
+#define COM_MCR		(COM_BASE + 0x04)	/* modem control register */
+#define COM_LSR		(COM_BASE + 0x05)	/* line status register */
+#define COM_MSR		(COM_BASE + 0x06)	/* modem status register */
+#define COM_DLL		(COM_BASE + 0x00)	/* divisor latch LSB (LCR[7] = 1) */
+#define COM_DLM		(COM_BASE + 0x01)	/* divisor latch MSB (LCR[7] = 1) */
+
+#ifdef DEBUG
+volatile u_char *ISA_io  = (u_char *)0x80000000;
+
+static void
+outb(int port, u_char val)
+{
+
+	ISA_io[port] = val;
+}
+
+static u_char
+inb(int port)
+{
+
+	return (ISA_io[port]);
+}
+#endif
+
+/*
+ * Print one chracter
+ */
+void
+debug_putc(int c)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
+	/*
+	 * output to serial port.
+	 */
+	while (!(inb(COM_LSR) & 0x20))
+		;
+	outb(COM_THR, (u_char)c);
+#endif
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_QEMU)
+	inb(0xf00); /* dummy */
+	outb(0xf00, (u_char)c);
+#endif
+}
+
+/*
+ * Initialize debug port.
+ */
+void
+debug_init(void)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
+	/*
+	 * Initialize serial port.
+	 */
+	if (inb(COM_LSR) == 0xff)
+		return;		/* Serial port is disabled */
+
+	outb(COM_IER, 0x00);	/* Disable interrupt */
+	outb(COM_LCR, 0x80);	/* Access baud rate */
+	outb(COM_DLL, 0x01);	/* 115200 baud */
+	outb(COM_DLM, 0x00);
+	outb(COM_LCR, 0x03);	/* N, 8, 1 */
+	outb(COM_MCR, 0x03);	/* Ready */
+	outb(COM_FCR, 0x00);	/* Disable FIFO */
+	inb(COM_RBR);
+	inb(COM_RBR);
+#endif
+}
diff --git a/prex-0.9.0/bsp/boot/ppc/prep/head.S b/prex-0.9.0/bsp/boot/ppc/prep/head.S
new file mode 100755
index 0000000..2d36d4e
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/prep/head.S
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * head.S - header code for PReP platforms.
+ */
+
+#include <conf/config.h>
+#include <machine/memory.h>
+#include <machine/syspage.h>
+
+
+#define BOOTSP		(BOOTSTKTOP - KERNBASE)
+
+#define MSR_EE		0x8000
+
+#define ENTRY(x) .global x; .align; x##:
+
+	.section ".text","ax"
+
+/*
+ * PReP data
+ */
+		.long	0x00040000	/* boot offset:	0x400 */
+		.long	0x00000800	/* boot size: 0x80000 */
+
+.org	0x200
+/*
+ * Loader entry point
+ */
+ENTRY(boot_entry)
+	/*
+	 * Disable interrupts
+	 */
+	mfmsr	%r3
+	andi.	%r3, %r3, ~MSR_EE@l
+	mtmsr	%r3
+
+	/*
+	 * Load the boot stack
+	 */
+	lis	r1, BOOTSP@ha
+	ori	r1, r1, BOOTSP@l
+	subi	r1, r1, 8
+
+	b	main
+
+	.section .tail,"ax"
+dummy:
+	.byte	0xff
+
+.end
diff --git a/prex-0.9.0/bsp/boot/ppc/prep/startup.c b/prex-0.9.0/bsp/boot/ppc/prep/startup.c
new file mode 100755
index 0000000..44a03fe
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/prep/startup.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/bootinfo.h>
+#include <boot.h>
+
+/*
+ * Setup boot information.
+ */
+static void
+bootinfo_init(void)
+{
+	struct bootinfo *bi = bootinfo;
+
+	/*
+	 * Screen size
+	 */
+	bi->video.text_x = 80;
+	bi->video.text_y = 25;
+
+	/*
+	 * Main RAM - 144M
+	 */
+	bi->ram[0].base = 0;
+	bi->ram[0].size = 0x9000000;
+	bi->ram[0].type = MT_USABLE;
+
+	bi->nr_rams = 1;
+}
+
+void
+startup(void)
+{
+
+	bootinfo_init();
+}
diff --git a/prex-0.9.0/bsp/boot/ppc/tools/prepboot/Makefile b/prex-0.9.0/bsp/boot/ppc/tools/prepboot/Makefile
new file mode 100755
index 0000000..18dd096
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/tools/prepboot/Makefile
@@ -0,0 +1,12 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	bootsect.bin
+OBJS:=		bootsect.o
+LDSCRIPT:=	bootsect.ld
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(OBJS) $(LDSCRIPT)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(OBJS)
+	$(OBJCOPY) -O binary -R .note -R .comment -S $@
+
diff --git a/prex-0.9.0/bsp/boot/ppc/tools/prepboot/bootsect.S b/prex-0.9.0/bsp/boot/ppc/tools/prepboot/bootsect.S
new file mode 100755
index 0000000..b71f762
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/tools/prepboot/bootsect.S
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * bootsect.s - Boot sector for PReP
+ */
+.text
+.align 1
+
+.global _start
+_start:
+
+/*
+ * MBR sector
+ */
+.org	446
+		.byte	0x80	/* indicator */
+		.byte	0	/* starting head */
+		.byte	2	/* starting sector */
+		.byte	0	/* starting cylinder */
+		.byte	0x41	/* partition type: PReP */
+		.byte	1	/* end head */
+		.byte	18	/* end sector */
+		.byte	79	/* end cylinder */
+		.long	0	/* absolute starting sector */
+		.long	2 * 18 * 80 - 1 /* partition size in sectors */
+.org	510
+		.word	0x55aa	/* magic */
diff --git a/prex-0.9.0/bsp/boot/ppc/tools/prepboot/bootsect.ld b/prex-0.9.0/bsp/boot/ppc/tools/prepboot/bootsect.ld
new file mode 100755
index 0000000..246c4ca
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/ppc/tools/prepboot/bootsect.ld
@@ -0,0 +1,7 @@
+SECTIONS {
+	. = 0;
+	.text . : {
+		*(.text)
+		__etext = . ;
+	}
+}
diff --git a/prex-0.9.0/bsp/boot/x86/arch/Makefile.inc b/prex-0.9.0/bsp/boot/x86/arch/Makefile.inc
new file mode 100755
index 0000000..12429d7
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/arch/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS+=		x86/arch/elf_reloc.c
diff --git a/prex-0.9.0/bsp/boot/x86/arch/boot.ld b/prex-0.9.0/bsp/boot/x86/arch/boot.ld
new file mode 100755
index 0000000..20786ec
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/arch/boot.ld
@@ -0,0 +1,31 @@
+/*
+ * Linker script for boot loader
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+SECTIONS {
+	. = CONFIG_LOADER_TEXT ;
+
+	.text . : {
+		*(.text)
+	}
+	. = ALIGN(4);
+	.rodata . : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+	. = ALIGN(4);
+	.data . : {
+		*(.data)
+	}
+	. = ALIGN(4);
+	.bss . : {
+		*(.bss)
+		*(COMMON)
+	}
+	. = CONFIG_LOADER_TEXT + 0x1fff;
+	.tail : {
+		*(.tail)
+	}
+}
diff --git a/prex-0.9.0/bsp/boot/x86/arch/elf_reloc.c b/prex-0.9.0/bsp/boot/x86/arch/elf_reloc.c
new file mode 100755
index 0000000..0b60fa8
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/arch/elf_reloc.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/elf.h>
+#include <boot.h>
+
+int
+relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sect)
+{
+	Elf32_Addr *where;
+
+	where = (Elf32_Addr *)(target_sect + rel->r_offset);
+
+	switch (ELF32_R_TYPE(rel->r_info)) {
+	case R_386_NONE:
+		break;
+	case R_386_32:
+		*where += (vaddr_t)ptokv(sym_val);
+		ELFDBG(("R_386_32: %lx -> %lx\n",
+			(long)where, (long)*where));
+		break;
+	case R_386_PC32:
+		*where += sym_val - (Elf32_Addr)where;
+		ELFDBG(("R_386_PC32: %lx -> %lx\n",
+			(long)where, (long)*where));
+		break;
+	default:
+		ELFDBG(("Unkown relocation type=%d\n",
+			ELF32_R_TYPE(rel->r_info)));
+		panic("relocation fail");
+		return -1;
+	}
+	return 0;
+}
+
+int
+relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sec)
+{
+
+	panic("invalid relocation type");
+	return -1;
+}
diff --git a/prex-0.9.0/bsp/boot/x86/pc/Makefile.inc b/prex-0.9.0/bsp/boot/x86/pc/Makefile.inc
new file mode 100755
index 0000000..56cbdfc
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/pc/Makefile.inc
@@ -0,0 +1,4 @@
+
+SRCS:=		x86/pc/head.S \
+		x86/pc/startup.c \
+		x86/pc/debug.c
diff --git a/prex-0.9.0/bsp/boot/x86/pc/debug.c b/prex-0.9.0/bsp/boot/x86/pc/debug.c
new file mode 100755
index 0000000..bce72a0
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/pc/debug.c
@@ -0,0 +1,103 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <boot.h>
+
+extern void	outb(int, u_char);
+extern u_char	inb(int);
+
+#define SCREEN_80x25 1
+/* #define SCREEN_80x50 1 */
+
+#define COM_BASE	CONFIG_NS16550_BASE
+
+/* Register offsets */
+#define COM_RBR		(COM_BASE + 0x00)	/* receive buffer register */
+#define COM_THR		(COM_BASE + 0x00)	/* transmit holding register */
+#define COM_IER		(COM_BASE + 0x01)	/* interrupt enable register */
+#define COM_FCR		(COM_BASE + 0x02)	/* FIFO control register */
+#define COM_IIR		(COM_BASE + 0x02)	/* interrupt identification register */
+#define COM_LCR		(COM_BASE + 0x03)	/* line control register */
+#define COM_MCR		(COM_BASE + 0x04)	/* modem control register */
+#define COM_LSR		(COM_BASE + 0x05)	/* line status register */
+#define COM_MSR		(COM_BASE + 0x06)	/* modem status register */
+#define COM_DLL		(COM_BASE + 0x00)	/* divisor latch LSB (LCR[7] = 1) */
+#define COM_DLM		(COM_BASE + 0x01)	/* divisor latch MSB (LCR[7] = 1) */
+
+/*
+ * Print one chracter
+ */
+void
+debug_putc(int c)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
+	/*
+	 * output to serial port.
+	 */
+	while (!(inb(COM_LSR) & 0x20))
+		;
+	outb(COM_THR, c);
+#endif
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_BOCHS)
+	/*
+	 * output to bochs emulater console.
+	 */
+	if (inb(0xe9) == 0xe9)
+		outb(0xe9, (u_char)c);
+#endif
+}
+
+/*
+ * Initialize debug port.
+ */
+void
+debug_init(void)
+{
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_SERIAL)
+	/*
+	 * Initialize serial port.
+	 */
+	if (inb(COM_LSR) == 0xff)
+		return;		/* Serial port is disabled */
+
+	outb(COM_IER, 0x00);	/* Disable interrupt */
+	outb(COM_LCR, 0x80);	/* Access baud rate */
+	outb(COM_DLL, 0x01);	/* 115200 baud */
+	outb(COM_DLM, 0x00);
+	outb(COM_LCR, 0x03);	/* N, 8, 1 */
+	outb(COM_MCR, 0x03);	/* Ready */
+	outb(COM_FCR, 0x00);	/* Disable FIFO */
+	inb(COM_RBR);
+	inb(COM_RBR);
+#endif
+}
diff --git a/prex-0.9.0/bsp/boot/x86/pc/head.S b/prex-0.9.0/bsp/boot/x86/pc/head.S
new file mode 100755
index 0000000..3459319
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/pc/head.S
@@ -0,0 +1,268 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * head.S - low level platform support
+ */
+
+#include <conf/config.h>
+#include <machine/memory.h>
+#include <machine/syspage.h>
+
+#define SCREEN_80x25 1
+/* #define SCREEN_80x50 1 */
+
+#define SEL_CODE32	0x10
+#define SEL_DATA32	0x18
+
+#define ENTRY(x) .global x; .align; x##:
+
+	.text
+	.code16
+
+/*
+ * boot_entry - Entry point for prex boot loader.
+ *
+ * We assume boot sector copied us at 0x30000.
+ */
+ENTRY(boot_entry)
+	cld
+	cli				/* Disable all interrupts */
+
+	/*
+	 * Relocate boot loader to 0x4000.
+	 */
+	movw	%cs, %ax
+	movw	%ax, %ds
+	xorw	%si, %si		/* Source address cs:0 */
+	movw	%si, %es
+	movw	$0x4000, %di		/* Destination */
+	movw	$0x800, %cx		/* size 8K */
+	rep	movsl
+	ljmp	$0x0000, $(reset_cs)
+reset_cs:
+	movw	%cs, %ax		/* Reset segment registers */
+	movw	%ax, %ds
+
+	xorw	%ax, %ax		/* Reset stack */
+	movw	%ax, %ss
+	movw	$(BOOTSTKTOP - KERNBASE), %sp
+
+	/*
+	 * Do 16-bit BIOS call here.
+	 */
+	call	setup_screen
+	call	get_memsize
+
+	/*
+	 * Switch to 32-bit protected mode.
+	 */
+	call	enable_a20		/* Enable A20 line */
+	lgdt	gdt_desc		/* Load GDT */
+
+	movl	%cr0, %eax		/* Set PE bit in CR0 */
+	orl	$0x1, %eax
+	movl	%eax, %cr0
+
+	.byte	0x66			/* 32-bit long jump to reset CS */
+	.byte	0xea
+	.long	go_prot
+	.word	SEL_CODE32
+	.code32
+.align 4
+go_prot:
+	movw	$(SEL_DATA32), %ax	/* Reset all segments */
+	movw	%ax, %ds
+	movw	%ax, %es
+	movw	%ax, %ss
+	movw	%ax, %fs
+	movw	%ax, %gs
+
+	/*
+	 * Relocate OS image.
+	 */
+	movl	$(CONFIG_BOOTIMG_BASE - KERNBASE), %edi	/* Destination */
+	movl	$0x32000, %esi		/* Source address: 0x32000 */
+	movl	$0x1B800, %ecx		/* size 0x6e000 */
+	rep	movsl
+
+	jmp	main			/* Jump to main routine in C */
+
+
+/*
+ * get_memsize - Get memory size
+ */
+	.code16
+get_memsize:
+	xorl	%eax, %eax
+	int	$0x12			/* Get conventional memory size */
+	movl	%eax, lo_mem		/* ax = K bytes */
+
+	mov	$0x88, %ah
+	int	$0x15
+	andb	$0xfc, %al		/* Adjust to page boundary */
+	movl	%eax, hi_mem		/* ax = K bytes at 100000h */
+	ret
+
+/*
+ * enable_a20 - Enable A20
+ */
+	.code16
+enable_a20:
+	call	empty_8042
+	movb	$0xd1, %al
+	outb	%al, $0x64
+	call	empty_8042
+	movb	$0xdf, %al
+	outb	%al, $0x60
+	call	empty_8042
+	call	wait_a20
+	ret
+
+/*
+ * empty_8042 - Empty 8042
+ */
+empty_8042:
+	inb	$0x64, %al
+	testb	$0x01, %al
+	jz	no_output
+	inb	$0x60, %al
+	jmp	empty_8042
+no_output:
+	testb	$0x02, %al
+	jnz	empty_8042
+	ret
+
+/*
+ * wait_a20 - Wait A20 ready
+ */
+wait_a20:
+        xorw    %ax, %ax
+        movw    %ax, %fs
+        movw    $0xffff, %ax
+        movw    %ax, %gs
+        movw    %fs:(0x0), %ax
+        cmp     %gs:(16), %ax
+        jne     a20_ready
+        movw    %dx, %ax
+        notw    %ax
+        movw    %ax, %fs:(0x0)
+        cmp     %gs:(16), %ax
+        mov     %fs:(0), %dx
+        jne     a20_ready
+        jmp	wait_a20
+a20_ready:
+        ret
+
+/*
+ * Setup screen
+ */
+setup_screen:
+	pushaw
+	pushw	%es
+	pushw	%ds
+	pushw	%bp
+	movb	$0x2e, %al		/* print '.' for verify */
+	movb	$0x0e, %ah
+	movw	$0x07, %bx
+	int	$0x10
+
+	movw	$0x3, %ax		/* Use mode-3 */
+	int	$0x10
+	movw	$0x1202, %ax		/* 400 scan lines */
+	movb	$0x30, %bl
+	int	$0x10
+#if SCREEN_80x50
+	movw	$0x1112, %ax		/* Load 8x8 character set */
+	movb	$0x0, %bl
+	int	$0x10
+	movw	$0x1201, %ax		/* Turn off cursor emulation */
+	movb	$0x34, %bl
+	int	$0x10
+	movb	$0x01, %ah		/* Set cursor type */
+	movw	$0x0607, %cx
+	int	$0x10
+#endif
+	popw	%bp
+	popw	%ds
+	popw	%es
+	popaw
+	ret
+
+	.code32
+
+ENTRY(outb)
+	movl	4(%esp), %edx
+	movl	8(%esp), %eax
+	outb	%al, %dx
+	ret
+
+ENTRY(inb)
+	movl	4(%esp), %edx
+	xorl	%eax, %eax
+	inb	%dx, %al
+	ret
+
+/*
+ * Data
+ */
+.align 16
+gdt:
+	.word 0x0,0x0,0x0,0x0		/* 0x00 - Null descritor */
+	.word 0x0,0x0,0x0,0x0		/* 0x08 - Null descritor */
+	.word 0xffff,0x0,0x9a00,0xcf	/* 0x10 - 32 bit code segment */
+	.word 0xffff,0x0,0x9200,0xcf	/* 0x18 - 32 bit data segment */
+	.word 0xffff,0x0,0x9a00,0x0	/* 0x20 - 16 bit code segment */
+	.word 0xffff,0x0,0x9200,0x0	/* 0x28 - 16 bit data segment */
+
+gdt_desc:
+	.word	0x2F			/* limit */
+	.long	gdt			/* address */
+
+	.word	0x0			/* alignment */
+idt_desc:
+	.word	0x0
+	.long	0x0
+
+e820_buf:
+	.space	20
+
+	.align 16
+	.global lo_mem, hi_mem
+lo_mem:
+	.long	0x0
+hi_mem:
+	.long	0x0
+
+/*
+ * Pad data
+ */
+	.section .tail,"a"
+dummy:
+	.byte	0xff
diff --git a/prex-0.9.0/bsp/boot/x86/pc/startup.c b/prex-0.9.0/bsp/boot/x86/pc/startup.c
new file mode 100755
index 0000000..4ba2a6c
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/pc/startup.c
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/bootinfo.h>
+#include <boot.h>
+
+#define SCREEN_80x25 1
+/* #define SCREEN_80x50 1 */
+
+extern paddr_t	lo_mem;
+extern paddr_t	hi_mem;
+
+/*
+ * Setup boot information.
+ *
+ * Note: We already got the memory size via BIOS call in head.S.
+ */
+static void
+bootinfo_init(void)
+{
+	struct bootinfo *bi = bootinfo;
+
+	/*
+	 * Screen size
+	 */
+#ifdef SCREEN_80x25
+	bi->video.text_x = 80;
+	bi->video.text_y = 25;
+#else
+	bi->video.text_x = 80;
+	bi->video.text_y = 50;
+#endif
+
+	/*
+	 * Main memory
+	 */
+	bi->ram[0].base = 0;
+	bi->ram[0].size = (size_t)((1024 + hi_mem) * 1024);
+	bi->ram[0].type = MT_USABLE;
+	bi->nr_rams = 1;
+
+	/*
+	 * Add BIOS ROM and VRAM area
+	 */
+	if (hi_mem != 0) {
+		bi->ram[1].base = lo_mem * 1024;
+		bi->ram[1].size = (size_t)((1024 - lo_mem) * 1024);
+		bi->ram[1].type = MT_MEMHOLE;
+		bi->nr_rams++;
+	}
+}
+
+void
+startup(void)
+{
+
+	bootinfo_init();
+}
diff --git a/prex-0.9.0/bsp/boot/x86/tools/bootsect/Makefile b/prex-0.9.0/bsp/boot/x86/tools/bootsect/Makefile
new file mode 100755
index 0000000..d912f4f
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/tools/bootsect/Makefile
@@ -0,0 +1,11 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	bootsect.bin
+OBJS:=		bootsect.o
+LDSCRIPT:=	bootsect.ld
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(OBJS) $(LDSCRIPT)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(OBJS)
+	$(OBJCOPY) -O binary -R .note -R .comment -S $@
diff --git a/prex-0.9.0/bsp/boot/x86/tools/bootsect/bootsect.S b/prex-0.9.0/bsp/boot/x86/tools/bootsect/bootsect.S
new file mode 100755
index 0000000..95f9910
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/tools/bootsect/bootsect.S
@@ -0,0 +1,440 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/**
+ * bootsect.S - Boot sector for FAT
+ *
+ * The boot sector is 512 byte code to load the OS image. It is loaded
+ * to address 0:7c00 by POST BIOS.
+ * The boot sector searches the target file within the root directory of
+ * FAT file system, and loads it to predefined memory address. Then, it
+ * jumps to the first byte of the loaded image.
+ *
+ * All disk access are done by using BIOS Int13h interface. The BIOS
+ * parameter block (BPB) has the disk/FAT information, and it exists
+ * in the first portion of the FAT boot sector. It must be filled by the
+ * FAT format utility, or the prex kernel install utility (mkboot.com).
+ * This program assumes that correct BPB is stored in the boot sector.
+ *
+ * Limitation:
+ *  - Support only FAT12/16. FAT32 is not supported.
+ *
+ * Memory usage:
+ *  > 5000 - 6FFF ... Disk work area
+ *  > 7000 - 7BFF ... Stack
+ *  > 7C00 - 7DFF ... This boot sector
+ *  >10000 -      ... FAT cache
+ *  >20000 -      ... Data cache
+ *  >30000 -      ... Image load address
+ */
+.code16
+.text
+.align 1
+
+# Memory locations
+#define BOOT_STACK		0x7c00
+
+#define LOAD_ADDR		0x30000
+#define ENTRY_SEG		0x3000
+#define ENTRY_OFF		0x0000
+
+#define WORK_AREA		0x5000
+#define FAT_SEG			0x1000
+#define DATA_SEG		0x2000
+
+#define LOAD_MAX		0xA0000
+
+# FAT Directory entry
+#define F_NAME			0
+#define F_ATTR			11
+#define F_RESERVED		12
+#define F_TIME			22
+#define F_DATA			24
+#define F_CLUSTER		26
+#define F_SIZE			28
+
+#define DIR_SIZE		32
+#define DIRENT_PER_SECTOR	16
+
+# BIOS parameter block (BPB) location (%bp points to 0x7c00)
+#define OEM_ID			0x03(%bp)
+#define BYTE_PER_SECTOR		0x0b(%bp)
+#define SECT_PER_CLUSTER	0x0d(%bp)
+#define RESERVED_SECTORS	0x0e(%bp)
+#define NUM_OF_FATS		0x10(%bp)
+#define ROOT_ENTRIES		0x11(%bp)
+#define TOTAL_SECTORS		0x13(%bp)
+#define MEDIA_DESCRIPTOR	0x15(%bp)
+#define SECTORS_PER_FAT		0x16(%bp)
+#define SECTORS_PER_TRACK	0x18(%bp)
+#define HEADS			0x1a(%bp)
+#define HIDDEN_SECTORS		0x1c(%bp)
+#define BIG_TOTAL_SECTORS	0x20(%bp)
+#define PHYSICAL_DRIVE		0x24(%bp)
+#define EXT_BOOT_SIGNATURE	0x26(%bp)
+#define SERIAL_NO		0x27(%bp)
+#define VOLUME_ID		0x2b(%bp)
+#define FILE_SYS_ID		0x36(%bp)
+
+#define FILE_SYS_ID_NUM		0x3a(%bp)
+
+# Local data area (Note: These data will overlap the existing code)
+#define FAT_START		0x40(%bp)
+#define DATA_START		0x44(%bp)
+
+.global _boot
+
+#
+# Boot the system
+#
+_boot:
+	jmp	start				# Skip BPB
+	nop					# Nop is for DOS compatibility
+
+#
+# BPB
+#
+	.ascii	"PREX1.00"
+.fill 0x33, 1, 0				# Drive parameter must be
+						# filled by intaller
+
+#
+# Setup stack and segment registers
+#
+start:
+	cli
+	cld					# Clear direction flag
+	xorl	%eax, %eax			# Set EAX to zero
+	movw	%ax, %ds
+	movw	%ax, %es
+	movw	%ax, %ss
+	movw	$(BOOT_STACK), %sp
+	movw	%sp, %bp			# EBP = Bios Parameter Block
+	sti
+
+#
+# Display boot message
+#
+	movw	$load_msg, %si
+	movw	$21, %cx
+	call	puts
+
+#
+# Store disk information
+#
+	movl	HIDDEN_SECTORS, %ebx		# Get hidden sector
+	movw	RESERVED_SECTORS, %ax		# Add reserved sector
+	addl	%eax, %ebx			# High 16 bit of EAX is 0
+	movl	%ebx, FAT_START			# FAT start = hidden + reserved
+
+	movzbw	NUM_OF_FATS, %ax		# Normally 2
+	mulw	SECTORS_PER_FAT			# AX = Num of sector of FATs
+	addl	%ebx, %eax			# EAX = Start of root directory
+
+	movw	ROOT_ENTRIES, %bx
+	shrw	$4, %bx				# / 16 = DIRENT_PER_SECTOR
+	movw	%bx, %cx			# CX = Num of sectors for root directory
+
+	addl	%eax, %ebx			# DATA start = FAT start + root
+	movl	%ebx, DATA_START		# Start sector of data area
+
+#
+# Find the OS image in the root directory
+#
+						# EAX = Start sector of root
+next_sector:
+	pushw	%cx
+	movl	$(WORK_AREA), %ebx
+	pushw	%bx
+	call	read_sector			# Read 1 sector in root
+	popw	%di				# DI = dir_entry
+	movw	$(DIRENT_PER_SECTOR), %cx	# CX = directory count
+next_entry:
+	cmpb	$0, (%di)			# End of dir entry ?
+	je	error				# Not found
+	testb	$0x18, F_ATTR(%di)		# Subdir or Volume ?
+	jnz	not_file			# Skip it
+	pusha
+	movw	$11, %cx			# File name + ext = 11 byte
+	movw	$image_name, %si
+	repe					# Compare file name
+	cmpsb
+	popa
+	je	found_file
+not_file:
+	addw	$(DIR_SIZE), %di		# Check next directory entry
+	loop	next_entry
+	popw	%cx
+	loop	next_sector
+						# Fall through
+#
+# Error case
+#
+error:
+	movw	$err_msg, %si
+	movw	$5, %cx
+	call	puts
+hang:
+	hlt
+	jmp	hang				# Stop here
+
+#
+# Load image
+#
+found_file:
+	movzwl	F_CLUSTER(%di), %eax		# EAX = 1st cluster of loader
+	movl	$(LOAD_ADDR), %ebx		# EBX = 32bit load address
+load_next:
+	call	read_cluster			# Read cluster of loader
+	call	next_cluster			# Get next cluster# in EAX
+	jb	load_next			# EOF ?
+
+#
+# Turn fdd motor off
+#
+	movw	$0x3f2, %dx
+	xorb	%al, %al
+	outb	%al, %dx
+
+#
+# Jump to loaded image
+#
+	ljmp	$0x3000, $0x0
+
+#
+# Puts - Print string
+#
+# Entry:
+#   SI - Pointer to message string
+#   CX - Number of character
+#
+puts:
+	lodsb
+	movb	$0x0e, %ah
+	movw	$0x0007, %bx
+	int	$0x10
+	loop	puts
+	ret
+
+#
+# next_cluster - Return next cluster
+#
+# Entry:
+#   EAX - Current cluter#
+#
+# Exit:
+#   AF - End of cluster
+#   EAX - Next cluter#
+#
+# Modified:
+#   Flags,CX,EDX,SI,DI
+#
+next_cluster:
+	pushl	%ebx
+	movw	%ax, %di			# Save cluster# in DI
+
+	movw	$0xfff8, %si			# Set default EOF to FAT16
+
+	movl	%eax, %ecx
+	shll	$1, %eax			# * 2
+
+	cmpb	$0x36, FILE_SYS_ID_NUM		# ID is 'FAT16' ?
+	je	fat_16
+	addl	%ecx, %eax			# * 3
+	shrl	$1, %eax			# / 2
+	movw	$0xff8, %si			# EOF for FAT12
+fat_16:
+						# EAX - Offset of FAT entry
+	xorw	%dx, %dx
+	divw	BYTE_PER_SECTOR
+	addl	FAT_START, %eax			# EAX = Sector# for FAT
+						# DX = Offset in sector
+	movl	$(WORK_AREA), %ebx
+	pushw	%bx
+	call	read_sector			# Read 2 sector for border
+	call	read_sector			# data
+	popw	%bx
+	addw	%dx, %bx
+	movw	(%bx), %ax
+	cmpw	$0xfff8, %si			# FAT16 ?
+	je	chk_end
+
+	shrw	$1, %di
+	jc	odd_pos
+	andb	$0x0f, %ah
+	jmp	chk_end
+odd_pos:
+	shrw	$4, %ax
+chk_end:
+	cmpw	%si, %ax
+	popl	%ebx
+	ret
+
+#
+# read_cluster - Read one cluster
+#
+# Entry:
+#   EBX - 32-bit pointer to buffer
+#   EAX - Cluster number
+#
+# Exit:
+#   EBX - Point to next buffer
+#
+# Modified:
+#   flags,ECX,ECX,EDX
+#
+read_cluster:
+	pushl	%eax
+	decw	%ax				# Translate clust# to sec#
+	decw	%ax
+	xorl	%ecx, %ecx
+	movb	SECT_PER_CLUSTER, %cl
+	mull	%ecx
+	addl	DATA_START, %eax		# EAX = Read sec#
+						# CX = Read sector size
+read_loop:
+	call	read_sector
+	cmpl	$(LOAD_MAX), %ebx
+	jae	error
+	loop	read_loop
+	popl	%eax
+	ret
+
+#
+# read_sector - Read one sector
+#
+# Entry:
+#   EBX - 32-bit pointer to buffer
+#   EAX - Logical sector# to read
+#
+# Exit:
+#   EBX - Pointer to next buffer
+#   EAX - Next sector
+#
+# Modified:
+#   Flags
+#
+read_sector:
+	pushal
+	pushw	%ds
+	pushw	%es
+
+	movl	%eax, %esi			# ESI = buffer
+
+	movzwl	SECTORS_PER_TRACK, %ecx		# Get sec/track
+	xorl	%edx, %edx
+	divl	%ecx				# EAX = track#
+						# DX = sec#
+	movw	$(DATA_SEG), %cx		# Check in cache
+	leaw	last_data, %di
+	cmpl	DATA_START, %esi
+	jae	data_reqest
+	movw	$(FAT_SEG), %cx
+	leaw	last_fat, %di
+data_reqest:
+						# CX = Cached segment
+	pushal					# [DI] = Cached track
+	movw	%cx, %es
+	xorw	%bx, %bx			# ES:BX = Cache address
+	cmpl	(%di), %eax			# Last track ?
+	je	hit_cache
+	movl	%eax, (%di)			# Save current track#
+	call	read_track
+hit_cache:
+	popal
+
+	pushw	%es
+	popw	%ds
+
+	shlw	$9, %dx				# sec# * 512
+	movw	%dx, %si			# DS:SI = Offset in cache
+
+	movw	%bx, %di			# [EBX] -> ES:[DI]
+	andw	$0xf, %di
+	shrl	$4, %ebx
+	movw	%bx, %es
+
+	mov	$512, %cx			# Copy 1 sector
+	rep
+	movsb
+
+	popw	%es
+	popw	%ds
+	popal
+
+	addl	$512, %ebx			# Next buffer
+	incl	%eax				# Next sector
+	ret
+
+#
+# read_track - Read one track
+#
+# Entry:
+#   ES:[BX] - Pointer to buffer
+#   EAX	    - Track number to read
+#
+# Exit:
+#   None
+#
+# Modified:
+#   Flags,EAX,ECX,EDX
+#
+read_track:
+	movzwl	HEADS, %ecx			# Get num of head
+	xorl	%edx, %edx
+	divl	%ecx				# AX = cyl#
+						# DL = head#
+
+	movb	%al, %ch			# CH = cyl# (low 8 bits)
+	andb	$3, %ah
+	shlb	$6, %ah
+	orb	$1, %ah
+	movb	%ah, %cl			# CL[7:6] = cyl# (high 2 bits)
+						# CL[5:0] = sec# = 1
+	movb	%dl, %dh			# DH = Head#
+	movw	SECTORS_PER_TRACK, %ax		# AL = Num of sectors to read
+	movb	$2, %ah				# AH = 02h (Read Disk Sectors)
+	movb	PHYSICAL_DRIVE, %dl		# DL = Drive#
+	int	$0x13				# Invoke Disk BIOS
+	jc	error
+	ret
+
+#
+# Local Data
+#
+last_fat:	.long	0xffffffff
+last_data:	.long	0xffffffff
+
+load_msg:	.ascii	"Loading "
+image_name:	.ascii	"PREXOS     "
+crlf:		.byte	0x0a, 0x0d
+err_msg:	.ascii	"Error"
+
+.org	510
+		.word	0xaa55
diff --git a/prex-0.9.0/bsp/boot/x86/tools/bootsect/bootsect.ld b/prex-0.9.0/bsp/boot/x86/tools/bootsect/bootsect.ld
new file mode 100755
index 0000000..021a140
--- /dev/null
+++ b/prex-0.9.0/bsp/boot/x86/tools/bootsect/bootsect.ld
@@ -0,0 +1,8 @@
+ENTRY(_boot)
+SECTIONS {
+	. = 0x7C00;
+	.text . : {
+		*(.text)
+		__etext = . ;
+	}
+}
diff --git a/prex-0.9.0/bsp/drv/Makefile b/prex-0.9.0/bsp/drv/Makefile
new file mode 100755
index 0000000..b470c39
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/Makefile
@@ -0,0 +1,42 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	drv.ko
+
+#MAP:= 		drv.map
+#DISASM:= 	drv.lst
+#SYMBOL:= 	drv.sym
+
+_RELOC_OBJ_:=	1
+_KERNEL_:=	1
+DEFS+=		KERNEL
+
+include $(CURDIR)/dev/base/Makefile.inc
+include $(CURDIR)/dev/block/Makefile.inc
+include $(CURDIR)/dev/cpufreq/Makefile.inc
+include $(CURDIR)/dev/dma/Makefile.inc
+include $(CURDIR)/dev/input/Makefile.inc
+include $(CURDIR)/dev/misc/Makefile.inc
+include $(CURDIR)/dev/rtc/Makefile.inc
+include $(CURDIR)/dev/serial/Makefile.inc
+include $(CURDIR)/dev/video/Makefile.inc
+
+include $(CURDIR)/lib/Makefile.inc
+-include $(CURDIR)/$(ARCH)/arch/Makefile.inc
+-include $(CURDIR)/$(ARCH)/$(PLATFORM)/Makefile.inc
+
+LIBSDIR+=	$(SRCDIR)/conf
+INCSDIR+=	$(CURDIR)/include $(CURDIR)/$(ARCH)/include
+ifndef LDSCRIPT
+LDSCRIPT:=	$(CURDIR)/$(ARCH)/arch/driver.ld
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET):  $(OBJS) $(LIBS) $(LDSCRIPT)
+	$(call echo-file,LD     ,$@)
+	$(LD) $(LDFLAGS_S) $(OUTPUT_OPTION) $(OBJS) $(LIBS) $(PLATFORM_LIBS)
+	$(RM) $@
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(OBJS) $(LIBS) $(PLATFORM_LIBS)
+	$(ASMGEN)
+	$(SYMGEN)
+	$(STRIP) --strip-debug --strip-unneeded $@
diff --git a/prex-0.9.0/bsp/drv/arm/arch/driver.ld b/prex-0.9.0/bsp/drv/arm/arch/driver.ld
new file mode 100755
index 0000000..49d0f7a
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/arch/driver.ld
@@ -0,0 +1,42 @@
+/*
+ * Linker script for driver
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(driver_main)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = SIZEOF_HEADERS ;
+
+	.text : {
+		*(.text)
+		*(.glue_7)
+		*(.glue_7t)
+	} : text = 0xff
+
+	. = ALIGN(4);
+
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	} : text
+
+        . = ALIGN(4);
+	.data : {
+		*(.data)
+	} : data
+
+        . = ALIGN(4);
+	.bss . : {
+		*(.bss)
+		*(COMMON)
+	}
+
+	/DISCARD/ : { *(.comment .note .debug_*) }
+}
diff --git a/prex-0.9.0/bsp/drv/arm/gba/Makefile.inc b/prex-0.9.0/bsp/drv/arm/gba/Makefile.inc
new file mode 100755
index 0000000..d8934ea
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/Makefile.inc
@@ -0,0 +1,4 @@
+
+SRCS-$(CONFIG_LCD)+=		arm/gba/lcd.c
+SRCS-$(CONFIG_KEYPAD)+=		arm/gba/keypad.c
+SRCS-$(CONFIG_SWKBD)+=		arm/gba/swkbd.c
diff --git a/prex-0.9.0/bsp/drv/arm/gba/font.h b/prex-0.9.0/bsp/drv/arm/gba/font.h
new file mode 100755
index 0000000..760db46
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/font.h
@@ -0,0 +1,163 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * font.h - minimum font for GBA
+ */
+
+const unsigned char font_bitmap[][8] = {
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00,},
+	{0x6C, 0x6C, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00,},
+	{0x10, 0x7C, 0xD0, 0x7C, 0x16, 0x7C, 0x10, 0x00,},
+	{0x62, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x46, 0x00,},
+	{0x38, 0x6C, 0x68, 0x76, 0xDC, 0xCC, 0x76, 0x00,},
+	{0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00,},
+	{0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00,},
+	{0x00, 0x6C, 0x38, 0xFE, 0x38, 0x6C, 0x00, 0x00,},
+	{0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x10,},
+	{0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,},
+	{0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00,},
+	{0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C, 0x00,},
+	{0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00,},
+	{0x7C, 0x06, 0x06, 0x3C, 0x60, 0x60, 0x7E, 0x00,},
+	{0x7C, 0x06, 0x06, 0x1C, 0x06, 0x06, 0x7C, 0x00,},
+	{0x66, 0x66, 0x66, 0x7E, 0x06, 0x06, 0x06, 0x00,},
+	{0x7E, 0x60, 0x60, 0x7C, 0x06, 0x06, 0x7C, 0x00,},
+	{0x3E, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00,},
+	{0x7E, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00,},
+	{0x3C, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x7C, 0x00,},
+	{0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00,},
+	{0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x10,},
+	{0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00,},
+	{0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00,},
+	{0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00,},
+	{0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18, 0x00,},
+	{0x3C, 0x66, 0x6E, 0x6E, 0x6E, 0x60, 0x3E, 0x00,},
+	{0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00,},
+	{0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00,},
+	{0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00,},
+	{0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00,},
+	{0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x7E, 0x00,},
+	{0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x60, 0x00,},
+	{0x3C, 0x66, 0x60, 0x6E, 0x66, 0x66, 0x3C, 0x00,},
+	{0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00,},
+	{0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00,},
+	{0x0E, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3C, 0x00,},
+	{0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00,},
+	{0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00,},
+	{0xC6, 0xEE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0x00,},
+	{0x66, 0x76, 0x7E, 0x6E, 0x66, 0x66, 0x66, 0x00,},
+	{0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00,},
+	{0x3C, 0x66, 0x66, 0x66, 0x6E, 0x6E, 0x3E, 0x00,},
+	{0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x00,},
+	{0x3E, 0x60, 0x60, 0x3C, 0x06, 0x06, 0x7C, 0x00,},
+	{0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x00,},
+	{0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00,},
+	{0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x00,},
+	{0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00,},
+	{0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00,},
+	{0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00,},
+	{0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00,},
+	{0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00,},
+	{0x10, 0x38, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,},
+	{0x18, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00,},
+	{0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x00,},
+	{0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x00,},
+	{0x06, 0x06, 0x3E, 0x66, 0x66, 0x66, 0x3E, 0x00,},
+	{0x00, 0x00, 0x3C, 0x66, 0x7C, 0x60, 0x3E, 0x00,},
+	{0x0E, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x3C, 0x00,},
+	{0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x7C,},
+	{0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00,},
+	{0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x70,},
+	{0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x00,},
+	{0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1C, 0x00,},
+	{0x00, 0x00, 0xCC, 0xFE, 0xD6, 0xC6, 0xC6, 0x00,},
+	{0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00,},
+	{0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60,},
+	{0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x06,},
+	{0x00, 0x00, 0x36, 0x38, 0x30, 0x30, 0x30, 0x00,},
+	{0x00, 0x00, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x00,},
+	{0x18, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x0C, 0x00,},
+	{0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x00,},
+	{0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0xEC, 0x00,},
+	{0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x00,},
+	{0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x7C,},
+	{0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x7E, 0x00,},
+	{0x1C, 0x30, 0x30, 0x60, 0x30, 0x30, 0x1C, 0x00,},
+	{0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x38, 0x0C, 0x0C, 0x06, 0x0C, 0x0C, 0x38, 0x00,},
+	{0x32, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55,},
+};
diff --git a/prex-0.9.0/bsp/drv/arm/gba/kbd_img.h b/prex-0.9.0/bsp/drv/arm/gba/kbd_img.h
new file mode 100755
index 0000000..1fca727
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/kbd_img.h
@@ -0,0 +1,428 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * kbd_img.h
+ */
+
+const unsigned char cursor_bitmap[] = {
+
+/*
+ * Cursor size 09
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 11
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x07,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 12
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x0F,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 13
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 15
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x7F,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 17
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 19
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x07,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+/*
+ * Cursor size 52
+ */
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x1F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+};
+
+
+/*
+ * Keyboard 1 (normal)
+ */
+const unsigned char kbd1_bitmap[] = {
+
+0xFF,0xFF,0xFF,0x0F,0xEF,0xEF,0xEF,0xEF,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEE,0x6D,0xEF,
+0xFF,0xFF,0xFF,0x00,0xEF,0x2E,0xEE,0x6E,
+0xFF,0xFF,0xFF,0x00,0xEF,0x2C,0xEB,0x2C,
+0xFF,0xFF,0xFF,0x00,0xEF,0xAC,0xAB,0xAC,
+0xFF,0xFF,0xFF,0x00,0xEF,0x2D,0xAD,0x2D,
+0xFF,0xFF,0xFF,0x00,0xEF,0x68,0xAF,0x2C,
+0xFF,0xFF,0xFF,0x00,0xEF,0x2C,0xEF,0xEC,
+
+0xFF,0xFF,0xFF,0x00,0xEF,0x68,0xAB,0x6D,
+0xFF,0xFF,0xFF,0x00,0xEF,0x6C,0xAB,0x6C,
+0xFF,0xFF,0xFF,0x00,0xEF,0x6C,0xAB,0xA8,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEC,0xEB,0x6B,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEF,0x6F,0xEC,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEF,0xEC,0x6F,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFD,0xFE,0x00,
+0xFF,0xFF,0xFF,0xF8,0xFB,0xFB,0xFB,0xFB,
+
+0xEF,0xEF,0xEF,0x0F,0xEF,0x2F,0xEF,0xEF,
+0xEF,0xEF,0xEF,0x00,0xFF,0xB8,0xAE,0x26,
+0xAE,0x2E,0xEF,0x00,0xFB,0x1B,0x6B,0x6A,
+0xEF,0x28,0xEF,0x00,0xFB,0xAB,0xAB,0xAB,
+0x2B,0xEC,0xEF,0x00,0xFB,0x1A,0xEA,0x0A,
+0xE8,0x2D,0xEF,0x00,0xFB,0x2B,0xCA,0xEA,
+0xAB,0x6C,0xEF,0x00,0xFB,0xBA,0x0B,0xBB,
+0xEB,0xEC,0xEF,0x00,0xFB,0xEB,0xEA,0x1B,
+
+0xAE,0x6E,0xEF,0x00,0xFB,0xEA,0xEA,0xEA,
+0xEB,0x6C,0xEF,0x00,0xFB,0xBA,0xFA,0xBA,
+0xAB,0x6C,0xEF,0x00,0xFB,0x1B,0xEB,0xEB,
+0xEB,0xEC,0xEF,0x00,0xFB,0x0B,0xEA,0x0A,
+0x6F,0xEF,0xEF,0x00,0xFB,0x3B,0xBA,0xBB,
+0xEC,0xEF,0xEF,0x00,0xFB,0x9B,0xBB,0xBB,
+0xFE,0xFD,0xFF,0x00,0xFB,0xEB,0xDB,0xBB,
+0xFB,0xFB,0xFB,0xF8,0xFB,0xFB,0xFB,0xFB,
+
+0xEF,0xEF,0xEF,0x0F,0xEF,0x6F,0xAF,0xAF,
+0xAA,0x22,0xFF,0x00,0xFF,0xF8,0xBF,0x9F,
+0x1A,0x7A,0xFB,0x00,0xEF,0x6F,0xE8,0x6A,
+0xAB,0x5B,0xFB,0x00,0xEF,0x6C,0xAB,0x68,
+0xEA,0x1B,0xFB,0x00,0xEF,0xE8,0x6F,0xAC,
+0xEB,0xEA,0xFB,0x00,0xEF,0xEB,0x68,0x2B,
+0xBB,0x7B,0xFB,0x00,0xEF,0x68,0xAF,0x6C,
+0xFB,0x0A,0xFB,0x00,0xEF,0xAC,0xAB,0x28,
+
+0x6A,0x9B,0xFB,0x00,0xEF,0xEF,0xEC,0xEB,
+0xBA,0xBA,0xFB,0x00,0xEF,0xAD,0xAF,0xAD,
+0xEB,0x1B,0xFB,0x00,0xEF,0xEB,0xED,0xEE,
+0xEA,0xEB,0xFB,0x00,0xEF,0xEE,0xEE,0xEE,
+0xBB,0x3B,0xFB,0x00,0xEF,0xEF,0xEE,0xEF,
+0xBB,0x9B,0xFB,0x00,0xEF,0xEE,0xEE,0x6F,
+0x7B,0xFB,0xFB,0x00,0xFF,0xBD,0xBE,0x80,
+0xFB,0xFA,0xFB,0xF8,0xFB,0xFB,0xFB,0xFB,
+
+0xAF,0x6F,0xEF,0x0F,0xEF,0x2F,0xAF,0x2F,
+0xAF,0x88,0xFF,0x00,0xFF,0xFA,0xBB,0xE2,
+0xA8,0x6E,0xEF,0x00,0xBF,0xBD,0xB6,0xA2,
+0xEB,0x28,0xEF,0x00,0xBF,0xA0,0xB7,0xBB,
+0xAB,0x6C,0xEF,0x00,0xBF,0xAE,0xB5,0xBB,
+0x6B,0x68,0xEF,0x00,0xBF,0xB1,0xAE,0xBE,
+0xEF,0x6F,0xEF,0x00,0xBF,0xAE,0xAE,0xB5,
+0xAB,0xAC,0xEF,0x00,0xBF,0xBE,0xBE,0xB0,
+
+0xAB,0x6B,0xEF,0x00,0xBF,0xB0,0xAE,0xAE,
+0x2D,0xAC,0xEF,0x00,0xBF,0xB5,0xAA,0xAA,
+0xED,0xEB,0xEF,0x00,0xBF,0xBF,0xBF,0xBF,
+0xEE,0x6D,0xEF,0x00,0xBF,0xBF,0xBF,0xBF,
+0xEE,0xEF,0xEF,0x00,0xBF,0xAF,0xB7,0xBB,
+0xEF,0xEF,0xEF,0x00,0xFF,0x8A,0xAA,0xAA,
+0xFE,0xFD,0xFF,0x00,0xFE,0x32,0xAA,0xAA,
+0xFB,0xFB,0xFB,0xF8,0xFB,0xFA,0xFA,0xFA,
+
+0xEF,0x2F,0xEF,0x0F,0xEF,0x2F,0xAF,0x2F,
+0xAA,0xAA,0xFF,0x00,0x7F,0x49,0x6D,0x69,
+0xB4,0xB6,0xBF,0x00,0xFF,0x45,0x55,0x55,
+0xBD,0xA0,0xBF,0x00,0xFB,0xCA,0xAB,0xAA,
+0xB5,0xAE,0xBF,0x00,0xBF,0xA8,0xAA,0xA8,
+0xAE,0xB1,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xB5,0xBB,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAE,0xB0,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+
+0xAE,0xAE,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAA,0xAA,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xBB,0xBD,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xBF,0xBB,0xBF,0x00,0xFB,0xBB,0xBB,0xAB,
+0xBD,0xBE,0xBF,0x00,0xFB,0xBB,0x1B,0xAA,
+0x8A,0xE8,0xFF,0x00,0xFB,0xBB,0xDB,0x0A,
+0xAA,0xB2,0xFE,0x00,0xFB,0xBB,0x7B,0x0A,
+0xFA,0xFA,0xFB,0xF8,0xFB,0xFB,0xFB,0xFA,
+
+0xAF,0x2F,0xEF,0x0F,0xFF,0xFF,0xFF,0xFF,
+0x6B,0x49,0x7F,0x00,0xFF,0xFF,0xFF,0xFF,
+0xD5,0x55,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAA,0xCA,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAE,0xA8,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0x1B,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xBB,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xDB,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0x7B,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFB,0xFB,0xFB,0xF8,0xFF,0xFF,0xFF,0xFF,
+
+};
+
+
+/*
+ * Keyboard 2 (Shifted)
+ */
+const unsigned char kbd2_bitmap[] = {
+
+
+0xFF,0xFF,0xFF,0x0F,0xEF,0x6F,0xAF,0xEF,
+0xFF,0xFF,0xFF,0x00,0xEF,0xED,0xEE,0xEF,
+0xFF,0xFF,0xFF,0x00,0xEF,0x6E,0xAE,0xAE,
+0xFF,0xFF,0xFF,0x00,0xEF,0x68,0x2A,0x68,
+0xFF,0xFF,0xFF,0x00,0xEF,0x6D,0xA8,0x2D,
+0xFF,0xFF,0xFF,0x00,0xEF,0xA8,0xEE,0xE8,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEB,0x6D,0xEE,
+0xFF,0xFF,0xFF,0x00,0xEF,0x6E,0xAD,0x6F,
+
+0xFF,0xFF,0xFF,0x00,0xEF,0xEE,0xAD,0x6A,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEE,0x6A,0x6C,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEE,0xEF,0xEF,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEE,0xED,0xED,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEF,0xEF,0x2F,
+0xFF,0xFF,0xFF,0x00,0xEF,0xEE,0xEE,0x68,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFD,0xFE,0x00,
+0xFF,0xFF,0xFF,0xF8,0xFB,0xFB,0xFB,0xFB,
+
+0xEF,0xEF,0xEF,0x0F,0xEF,0x2F,0xEF,0xEF,
+0xEF,0xEF,0xEF,0x00,0xFF,0xB8,0xAE,0x26,
+0xAF,0x6E,0xEF,0x00,0xFB,0x1B,0xEB,0xAA,
+0x2F,0x6C,0xEF,0x00,0xFB,0xEB,0xEA,0xAA,
+0xE8,0x2D,0xEF,0x00,0xFB,0x0A,0xEA,0x0A,
+0x6A,0xAC,0xEF,0x00,0xFB,0x0A,0xEB,0x0B,
+0xEF,0xEB,0xEF,0x00,0xFB,0x0B,0xBA,0xBB,
+0xAF,0x2F,0xEF,0x00,0xFB,0xEA,0xEB,0x5B,
+
+0xAD,0xEA,0xEF,0x00,0xFB,0xEA,0xEA,0xEB,
+0x6A,0xEE,0xEF,0x00,0xFB,0xBA,0xBA,0xBA,
+0xEF,0xEE,0xEF,0x00,0xFB,0x1B,0xEB,0xEB,
+0xED,0x2E,0xEF,0x00,0xFB,0x0B,0xEA,0xEA,
+0xEF,0xE8,0xEF,0x00,0xFB,0x3B,0xBA,0xDA,
+0xEE,0xEE,0xEF,0x00,0xFB,0x9B,0xBB,0x7B,
+0xFE,0xFD,0xFF,0x00,0xFB,0xBB,0xBB,0xFB,
+0xFB,0xFB,0xFB,0xF8,0xFB,0xFB,0xFB,0xFB,
+
+0xEF,0xEF,0xEF,0x0F,0xEF,0x6F,0xAF,0xAF,
+0xAA,0x22,0xFF,0x00,0xFF,0xF8,0xBF,0x9F,
+0x6A,0x9A,0xFB,0x00,0xEF,0x6F,0xA8,0xAA,
+0x4B,0xEA,0xFB,0x00,0xEF,0x6C,0xAB,0x6B,
+0xEA,0x0A,0xFB,0x00,0xEF,0x28,0xAF,0xAC,
+0xEB,0xEA,0xFB,0x00,0xEF,0x2C,0xAB,0x2B,
+0xBA,0xBA,0xFB,0x00,0xEF,0x68,0xAF,0xAC,
+0xBB,0xBB,0xFB,0x00,0xEF,0xA8,0xAF,0x28,
+
+0xEB,0x1B,0xFB,0x00,0xEF,0x6B,0xEB,0xE8,
+0xBA,0xBB,0xFB,0x00,0xEF,0xA8,0xAB,0xAB,
+0xEB,0x1B,0xFB,0x00,0xEF,0xAB,0xAD,0xAE,
+0x0A,0xEB,0xFB,0x00,0xEF,0xEF,0xEF,0xEF,
+0xBB,0x3B,0xFB,0x00,0xEF,0x6F,0x6E,0xEF,
+0xBB,0x9B,0xFB,0x00,0xEF,0xED,0xED,0x6F,
+0xBB,0xBB,0xFB,0x00,0xFF,0xBD,0xBE,0x80,
+0xFB,0xFB,0xFB,0xF8,0xFB,0xFB,0xFB,0xFB,
+
+0xAF,0x6F,0xEF,0x0F,0xEF,0x2F,0xAF,0x2F,
+0xAF,0x88,0xFF,0x00,0xFF,0xFA,0xBB,0xE2,
+0x28,0xAE,0xEF,0x00,0xBF,0xBD,0xB6,0xA2,
+0xE8,0x2B,0xEF,0x00,0xBF,0xA0,0xB7,0xBB,
+0xAB,0x2C,0xEF,0x00,0xBF,0xAE,0xB5,0xBB,
+0xAB,0xAC,0xEF,0x00,0xBF,0xA1,0xBE,0xBE,
+0xAF,0x6F,0xEF,0x00,0xBF,0xAE,0xAE,0xB5,
+0xAB,0xA8,0xEF,0x00,0xBF,0xB0,0xAE,0xB0,
+
+0xAB,0x6B,0xEF,0x00,0xBF,0xAE,0xAC,0xAA,
+0x2B,0xAC,0xEF,0x00,0xBF,0xAE,0xA4,0xAA,
+0xAD,0x2B,0xEF,0x00,0xBF,0xB7,0xBB,0xBD,
+0xEF,0xE8,0xEF,0x00,0xBF,0xBD,0xBB,0xB7,
+0xEE,0xEF,0xEF,0x00,0xBF,0xB1,0xAE,0xB3,
+0xEF,0xEF,0xEF,0x00,0xFF,0x8A,0xAA,0xAA,
+0xFE,0xFD,0xFF,0x00,0xFE,0x32,0xAA,0xAA,
+0xFB,0xFB,0xFB,0xF8,0xFB,0xFA,0xFA,0xFA,
+
+0xEF,0x2F,0xEF,0x0F,0xEF,0x2F,0xAF,0x2F,
+0xAA,0xAA,0xFF,0x00,0x7F,0x49,0x6D,0x69,
+0xB4,0xB6,0xBF,0x00,0xFF,0x45,0x55,0x55,
+0xBD,0xA0,0xBF,0x00,0xFB,0xCA,0xAB,0xAA,
+0xB5,0xAE,0xBF,0x00,0xBF,0xA8,0xAA,0xA8,
+0xBE,0xA1,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xB5,0xBB,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAE,0xB0,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+
+0xA6,0xAE,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAE,0xAE,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xBB,0xB7,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xBB,0xBD,0xBF,0x00,0xFB,0xBB,0xBB,0xAB,
+0xBF,0xBB,0xBF,0x00,0xFB,0xBB,0x1B,0xAA,
+0x8A,0xE8,0xFF,0x00,0xFB,0xBB,0xDB,0x0A,
+0xAA,0xB2,0xFE,0x00,0xFB,0xBB,0x7B,0x0A,
+0xFA,0xFA,0xFB,0xF8,0xFB,0xFB,0xFB,0xFA,
+
+0xAF,0x2F,0xEF,0x0F,0xFF,0xFF,0xFF,0xFF,
+0x6B,0x49,0x7F,0x00,0xFF,0xFF,0xFF,0xFF,
+0xD5,0x55,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAA,0xCA,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xAE,0xA8,0xBF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFF,0xFF,0xFF,0x00,0xFF,0xFF,0xFF,0xFF,
+0x1B,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xBB,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xDB,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0x7B,0xBB,0xFB,0x00,0xFF,0xFF,0xFF,0xFF,
+0xFB,0xFB,0xFB,0xF8,0xFF,0xFF,0xFF,0xFF,
+
+};
diff --git a/prex-0.9.0/bsp/drv/arm/gba/keymap.h b/prex-0.9.0/bsp/drv/arm/gba/keymap.h
new file mode 100755
index 0000000..c880344
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/keymap.h
@@ -0,0 +1,121 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * keymap.h - Keyboard mapping
+ */
+#include <sys/keycode.h>
+
+struct _key_info {
+	int pos_x;	/* Cursor position */
+	int width;	/* Cursor width */
+	u_char normal;	/* Normal code */
+	u_char shifted;	/* Shifted code */
+};
+
+const struct _key_info key_info[5][14] =
+	{{{0,   9,  '`', '~'},
+	  {8,   9,  '1', '!'},
+	  {16,  9,  '2', '@'},
+	  {24,  9,  '3', '#'},
+	  {32,  9,  '4', '$'},
+	  {40,  9,  '5', '%'},
+	  {48,  9,  '6', '^'},
+	  {56,  9,  '7', '&'},
+	  {64,  9,  '8', '*'},
+	  {72,  9,  '9', '('},
+	  {80,  9,  '0', ')'},
+	  {88,  9,  '-', '_'},
+	  {96,  9,  '=', '+'},
+	  {104, 15, '\b', '\b'}}, /* back space */
+
+	 {{0,   15, '\t', '\t'}, /* tab */
+	  {14,  9,  'q', 'Q'},
+	  {22,  9,  'w', 'W'},
+	  {30,  9,  'e', 'E'},
+	  {38,  9,  'r', 'R'},
+	  {46,  9,  't', 'T'},
+	  {54,  9,  'y', 'Y'},
+	  {62,  9,  'u', 'U'},
+	  {70,  9,  'i', 'I'},
+	  {78,  9,  'o', 'O'},
+	  {86,  9,  'p', 'P'},
+	  {94,  9,  '[', '{'},
+	  {102, 9,  ']', '}'},
+	  {110, 9,  '\\', '|'}},
+
+	 {{0,   17, K_CAPS, K_CAPS},
+	  {16,  9,  'a', 'A'},
+	  {24,  9,  's', 'S'},
+	  {32,  9,  'd', 'D'},
+	  {40,  9,  'f', 'F'},
+	  {48,  9,  'g', 'G'},
+	  {56,  9,  'h', 'H'},
+	  {64,  9,  'j', 'J'},
+	  {72,  9,  'k', 'K'},
+	  {80,  9,  'l', 'L'},
+	  {88,  9,  ';', ':'},
+	  {96,  9,  '\'','"'},
+	  {104, 15, '\n', '\n'},
+	  {0,   0,  0,   0}}, /* dummy */
+
+	 {{0,   19, K_SHFT, K_SHFT},
+	  {18,  9,  'z', 'Z'},
+	  {26,  9,  'x', 'X'},
+	  {34,  9,  'c', 'C'},
+	  {42,  9,  'v', 'V'},
+	  {50,  9,  'b', 'B'},
+	  {58,  9,  'n', 'N'},
+	  {66,  9,  'm', 'M'},
+	  {74,  9,  ',', '<'},
+	  {82,  9,  '.', '>'},
+	  {90,  9,  '/', '?'},
+	  {98,  11, K_PGUP, K_PGUP}, /* special */
+	  {108, 11, K_PGDN, K_PGDN}, /* special */
+	  {0,   0,  0,   0}}, /* dummy */
+
+	 {{0,   12, 0x1b, 0x1b}, /* escape */
+	  {11,  12, K_INS, K_INS},
+	  {22,  13, 0x7f, 0x7f}, /* delete */
+	  {34,  53, ' ', ' '},
+	  {34,  53, ' ', ' '},
+	  {34,  53, ' ', ' '},
+	  {34,  53, ' ', ' '},
+	  {34,  53, ' ', ' '},
+	  {34,  53, ' ', ' '},
+	  {86,  9,  K_DOWN, K_DOWN},
+	  {94,  9,  K_UP,   K_UP  },
+	  {102, 9,  K_LEFT, K_LEFT},
+	  {110, 9,  K_RGHT, K_RGHT},
+	  {0,   0,  0,   0}}, /* dummy */
+};
+
+/* Maximum colum number for each row */
+u_int max_x[] = {13,13,12,12,12};
+
diff --git a/prex-0.9.0/bsp/drv/arm/gba/keypad.c b/prex-0.9.0/bsp/drv/arm/gba/keypad.c
new file mode 100755
index 0000000..f1058a0
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/keypad.c
@@ -0,0 +1,146 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * keypad.c - GBA gamepad driver
+ */
+
+#include <driver.h>
+#include <sys/keycode.h>
+#include "swkbd.h"
+
+/* Parameters */
+#define KEYPAD_IRQ	12
+
+/* Registers for gamepad control */
+#define REG_KEYSTS	(*(volatile uint16_t *)0x4000130)
+#define REG_KEYCNT	(*(volatile uint16_t *)0x4000132)
+
+/* KEY_STS/KEY_CNT */
+#define KEY_A		0x0001
+#define KEY_B		0x0002
+#define KEY_SELECT	0x0004
+#define KEY_START	0x0008
+#define KEY_RIGHT	0x0010
+#define KEY_LEFT	0x0020
+#define KEY_UP		0x0040
+#define KEY_DOWN	0x0080
+#define KEY_R		0x0100
+#define KEY_L		0x0200
+
+#define KEY_ALL		0x03ff
+
+/* KEY_CNT value */
+#define KEYIRQ_EN	0x4000	/* 0=Disable, 1=Enable */
+#define KEYIRQ_COND	0x8000  /* 0=Logical OR, 1=Logical AND */
+
+
+struct keypad_softc {
+	device_t	dev;
+	irq_t		irq;
+};
+
+static int keypad_init(struct driver *);
+
+static struct devops keypad_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver keypad_driver = {
+	/* name */	"keypad",
+	/* devops */	&keypad_devops,
+	/* devsz */	sizeof(struct keypad_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	keypad_init,
+	/* shutdown */	NULL,
+};
+
+/*
+ * Interrupt service routine
+ */
+static int
+keypad_isr(void *arg)
+{
+	uint16_t sts;
+
+	sts = ~REG_KEYSTS & KEY_ALL;
+
+	if (sts == (KEY_SELECT|KEY_START))
+		machine_powerdown(PWR_REBOOT);
+
+	if (sts & KEY_A)
+		swkbd_input('A');
+	if (sts & KEY_B)
+		swkbd_input('B');
+	if (sts & KEY_SELECT)
+		swkbd_input('\t');
+	if (sts & KEY_START)
+		swkbd_input('\n');
+	if (sts & KEY_RIGHT)
+		swkbd_input(K_RGHT);
+	if (sts & KEY_LEFT)
+		swkbd_input(K_LEFT);
+	if (sts & KEY_UP)
+		swkbd_input(K_UP);
+	if (sts & KEY_DOWN)
+		swkbd_input(K_DOWN);
+	if (sts & KEY_R)
+		swkbd_input('R');
+	if (sts & KEY_L)
+		swkbd_input('L');
+
+	return 0;
+}
+
+int
+keypad_init(struct driver *self)
+{
+	struct keypad_softc *sc;
+	device_t dev;
+
+	dev = device_create(self, "keypad", D_CHR);
+	sc = device_private(dev);
+
+	/*
+	 * Setup isr
+	 */
+	REG_KEYCNT = 0;	/* disable irq */
+	sc->irq = irq_attach(KEYPAD_IRQ, IPL_INPUT, 0, keypad_isr,
+			     IST_NONE, sc);
+	REG_KEYCNT = KEY_ALL | KEYIRQ_EN;
+
+	return 0;
+}
+
diff --git a/prex-0.9.0/bsp/drv/arm/gba/lcd.c b/prex-0.9.0/bsp/drv/arm/gba/lcd.c
new file mode 100755
index 0000000..7a67a8b
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/lcd.c
@@ -0,0 +1,194 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * lcd.c - GBA LCD video driver
+ */
+
+#include <driver.h>
+#include <wscons.h>
+#include "lcd.h"
+#include "font.h"
+
+/* #define DEBUG_LCD 1 */
+
+#ifdef DEBUG_LCD
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+struct lcd_softc {
+	device_t	dev;
+	uint16_t	*vram;
+};
+
+static int	lcd_init(struct driver *);
+static void	lcd_cursor(void*, int, int);
+static void	lcd_putc(void *, int, int, int);
+static void	lcd_copyrows(void *,int, int, int);
+static void	lcd_eraserows(void *,int, int);
+static void	lcd_set_attr(void *, int);
+static void	lcd_get_cursor(void *, int *, int *);
+
+static struct devops lcd_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver lcd_driver = {
+	/* name */	"lcd",
+	/* devops */	&lcd_devops,
+	/* devsz */	sizeof(struct lcd_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	lcd_init,
+	/* shutdown */	NULL,
+};
+
+static struct wscons_video_ops wscons_lcd_ops = {
+	lcd_cursor,		/* cursor */
+	lcd_putc,		/* putc */
+	lcd_copyrows,		/* copyrows */
+	lcd_eraserows,		/* eraserows */
+	lcd_set_attr,		/* set_attr */
+	lcd_get_cursor,		/* get_cursor */
+};
+
+static void
+lcd_cursor(void *aux, int row, int col)
+{
+
+	/* DO NOTHING */
+}
+
+static void
+lcd_putc(void *aux, int row, int col, int ch)
+{
+	struct lcd_softc *sc = aux;
+
+	sc->vram[row * VSCR_COLS + col] = ch;
+}
+
+static void
+lcd_copyrows(void *aux, int srcrow, int dstrow, int nrows)
+{
+	struct lcd_softc *sc = aux;
+	int i;
+
+	for (i = 0; i < nrows * VSCR_COLS; i++) {
+		sc->vram[dstrow * VSCR_COLS + i] =
+			sc->vram[srcrow * VSCR_COLS + i];
+	}
+}
+
+static void
+lcd_eraserows(void *aux, int row, int nrows)
+{
+	struct lcd_softc *sc = aux;
+	int i, start, end;
+
+	start = row * VSCR_COLS;
+	end = start + nrows * VSCR_COLS;
+
+	for (i = start; i < end; i++)
+		sc->vram[i] = ' ';
+}
+
+static void
+lcd_set_attr(void *aux, int attr)
+{
+
+	/* DO NOTHING */
+}
+
+static void
+lcd_get_cursor(void *aux, int *col, int *row)
+{
+
+	*col = 0;
+	*row = 0;
+}
+
+static void
+lcd_init_font(void)
+{
+	int i, row, col, bit, val = 0;
+	uint16_t *tile = CONSOLE_TILE;
+
+	for (i = 0; i < 128; i++) {
+		for (row = 0; row < 8; row++) {
+			for (col = 7; col >= 0; col--) {
+				bit = (font_bitmap[i][row] & (1 << col)) ? 2 : 1;
+				if (col % 2)
+					val = bit;
+				else
+					tile[(i * 32) + (row * 4) + ((7 - col) / 2)] =
+						val + (bit << 8);
+			}
+		}
+	}
+}
+
+static void
+lcd_init_screen(void)
+{
+	uint16_t *pal = BG_PALETTE;
+
+	/* Initialize palette */
+	pal[0] = 0;		/* Transparent */
+	pal[1] = RGB(0,0,0);	/* Black */
+	pal[2] = RGB(31,31,31);	/* White */
+
+	/* Setup lcd */
+	REG_BG3CNT = 0x1080;	/* Size0, 256color, priority0 */
+	REG_DISPCNT = 0x0800;	/* Mode0, BG3 */
+}
+
+static int
+lcd_init(struct driver *self)
+{
+	device_t dev;
+	struct lcd_softc *sc;
+
+	dev = device_create(self, "lcd", D_CHR|D_TTY);
+
+	sc = device_private(dev);
+	sc->vram = CONSOLE_MAP;
+
+	lcd_init_font();
+	lcd_init_screen();
+
+	wscons_attach_video(&wscons_lcd_ops, sc);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/arm/gba/lcd.h b/prex-0.9.0/bsp/drv/arm/gba/lcd.h
new file mode 100755
index 0000000..1966246
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/lcd.h
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * lcd.h - GBA LCD definition
+ */
+
+/**
+ * Memo: Map/Tile Location
+ *
+ *  BG1 ... Keyboard1 (normal)
+ *  BG2 ... Keyboard2 (shifted)
+ *  BG3 ... Text
+ *
+ *  +------------+ 6010000
+ *  |            |
+ *  |            |
+ *  |            |
+ *  |            |
+ *  |            |
+ *  +------------+ 600C000
+ *  |  BG2 MAP   |
+ *  +------------+ 600A000
+ *  |  BG1 MAP   |
+ *  +------------+ 6009000
+ *  |  BG3 MAP   |
+ *  +------------+ 6008000
+ *  |   Tile 2   |
+ *  |(KBD2)      |
+ *  |- - - - - - | 6006000
+ *  |            |
+ *  |(KBD1)      |
+ *  +------------+ 6004000
+ *  |   Tile 1   |
+ *  |            |
+ *  |            |
+ *  |            |
+ *  |(Font)      |
+ *  +------------+ 6000000
+ */
+
+#define VSCR_COLS	32
+#define SCR_COLS	30
+#define SCR_ROWS	20
+
+/* Registers for keypad control */
+#define REG_DISPCNT	(*(volatile uint16_t *)0x4000000)
+#define REG_BG0CNT	(*(volatile uint16_t *)0x4000008)
+#define REG_BG1CNT	(*(volatile uint16_t *)0x400000A)
+#define REG_BG2CNT	(*(volatile uint16_t *)0x400000C)
+#define REG_BG3CNT	(*(volatile uint16_t *)0x400000E)
+
+#define BG_PALETTE	(uint16_t *)0x5000000
+
+#define CONSOLE_TILE	(uint16_t *)0x6000000
+#define CONSOLE_MAP	(uint16_t *)0x6008000
+
+#define KBD1_TILE	(uint16_t *)0x6004000
+#define KBD2_TILE	(uint16_t *)0x6006000
+#define KBD1_MAP	(uint16_t *)0x6009000
+#define KBD2_MAP	(uint16_t *)0x600A000
+
+#define OAM		(uint16_t *)0x7000000
+#define SPL_PALETTE	(uint16_t *)0x5000200
+#define CURSOR_DATA	(uint16_t *)0x6010000
+
+
+#define	RGB(r, g, b)	(((b) << 10) + ((g) << 5) + (r))
diff --git a/prex-0.9.0/bsp/drv/arm/gba/swkbd.c b/prex-0.9.0/bsp/drv/arm/gba/swkbd.c
new file mode 100755
index 0000000..fa15516
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/swkbd.c
@@ -0,0 +1,500 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * swkbd.c - GBA software keyboard driver
+ */
+
+/**
+ * This driver emulates a generic keyboard by using GBA keypad.
+ *
+ * <Key assign>
+ *
+ * On-screen keyboard:
+ *
+ *  A        : Select pointed key
+ *  B        : Enter key
+ *  Select   : Hide virtual keyboard
+ *  Start    :
+ *  Right    : Move keyboard cursor right
+ *  Left     : Move keyboard cursor left
+ *  Up       : Move keyboard cursor up
+ *  Down     : Move keyboard cursor down
+ *  Button R : Toggle shift state
+ *  Button L : Toggle shift state
+ *
+ * No on-screen keyboard:
+ *
+ *  A        : A key
+ *  B        : B key
+ *  Select   : Show virtual keyboard
+ *  Start    : Enter key
+ *  Right    : Right key
+ *  Left     : Left key
+ *  Up       : Up key
+ *  Down     : Down key
+ *  Button R : R key
+ *  Button L : L Key
+ *
+ */
+
+#include <driver.h>
+#include <sys/keycode.h>
+#include <wscons.h>
+#include "lcd.h"
+#include "kbd_img.h"
+#include "keymap.h"
+
+/*
+ * Since GBA does not kick interrupt for the button release, we have
+ * to wait for a while after button is pressed. Otherwise, many key
+ * events are queued by one button press.
+ */
+#define CURSOR_WAIT	100	/* 100 msec */
+#define BUTTON_WAIT	200	/* 200 msec */
+
+struct swkbd_softc {
+	device_t	dev;		/* device object */
+	irq_t		irq;		/* irq handle */
+	timer_t		timer;		/* timer to prevent chattering */
+
+	int		kbd_on;		/* 0: direct input, 1: virtual KBD */
+	int		kbd_page;	/* video page to display keyboard */
+	int		ignore_key;	/* ignore key input if true */
+	u_int		pos_x;		/* cursor x position */
+	u_int		pos_y;		/* cursor y position */
+	int		cursor_type;	/* current cursor type */
+
+	int		shift;		/* shift key state */
+	int		alt;		/* alt key state */
+	int		ctrl;		/* control key state */
+	int		capslk;		/* caps lock key staet */
+};
+
+static int	swkbd_init(struct driver *);
+static void	swkbd_move_cursor(void);
+
+static struct devops swkbd_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver swkbd_driver = {
+	/* name */	"swkbd",
+	/* devops */	&swkbd_devops,
+	/* devsz */	sizeof(struct swkbd_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	swkbd_init,
+	/* shutdown */	NULL,
+};
+
+
+static struct swkbd_softc *swkbd_softc;
+
+
+/*
+ * Select keyboard page.
+ *
+ *   Page0 ... Text only
+ *   Page1 ... Text & Normal keyboard
+ *   Page2 ... Text & Shifted keyboard
+ */
+static void
+swkbd_select_page(int page)
+{
+
+	if (page == 0)
+		REG_DISPCNT = 0x0840;	/* only BG3 */
+	else if (page == 1) {
+		REG_DISPCNT = 0x1A40;	/* use BG1&3 */
+		swkbd_move_cursor();
+	} else {
+		REG_DISPCNT = 0x1C40;	/* use BG2&3 */
+		swkbd_move_cursor();
+	}
+	swkbd_softc->kbd_page = page;
+}
+
+/*
+ * Toggle keyboard type: normal or shift.
+ */
+static void
+swkbd_toggle_shift(void)
+{
+	struct swkbd_softc *sc = swkbd_softc;
+	int page;
+
+	if (sc->kbd_page == 0)
+		return;
+	if (sc->capslk)
+		page = sc->shift ? 1 : 2;
+	else
+		page = sc->shift ? 2 : 1;
+	swkbd_select_page(page);
+}
+
+/*
+ * Timer call back handler.
+ * Just clear ignoring flag.
+ */
+static void
+swkbd_timeout(void *arg)
+{
+	struct swkbd_softc *sc = arg;
+
+	sc->ignore_key = 0;
+}
+
+/*
+ * Move cursor to point key.
+ */
+static void
+swkbd_move_cursor(void)
+{
+	struct swkbd_softc *sc = swkbd_softc;
+	uint16_t *oam = OAM;
+	struct _key_info *ki;
+	int x, y;
+	int curcur;	/* current cursor */
+	int newcur;	/* new cursor */
+
+	curcur = sc->cursor_type;
+
+	ki = (struct _key_info *)&key_info[sc->pos_y][sc->pos_x];
+	x = ki->pos_x + 108;
+	y = sc->pos_y * 8 + 11;
+
+	newcur = 0;
+	switch (ki->width) {
+	case 9: newcur = 0; break;
+	case 11: newcur = 1; break;
+	case 12: newcur = 2; break;
+	case 13: newcur = 3; break;
+	case 15: newcur = 4; break;
+	case 17: newcur = 5; break;
+	case 19: newcur = 6; break;
+	case 53: newcur = 7; break;
+	}
+	if (newcur != curcur) {
+		oam[curcur * 4] = (uint16_t)((oam[curcur * 4] & 0xff00) | 160);
+		oam[curcur * 4 + 1] = (uint16_t)((oam[curcur * 4 + 1] & 0xfe00) | 240);
+		sc->cursor_type = newcur;
+	}
+	oam[newcur * 4] = (uint16_t)((oam[newcur * 4] & 0xff00) | y);
+	oam[newcur * 4 + 1] = (uint16_t)((oam[newcur * 4 + 1] & 0xfe00) | x);
+}
+
+/*
+ * Process key press
+ */
+static void
+swkbd_key_press(void)
+{
+	struct swkbd_softc *sc = swkbd_softc;
+	struct _key_info *ki;
+	u_char ac;
+
+	ki = (struct _key_info *)&key_info[sc->pos_y][sc->pos_x];
+	ac = ki->normal;
+
+	/* Check meta key */
+	switch (ac) {
+	case K_SHFT:
+		sc->shift = !sc->shift;
+		swkbd_toggle_shift();
+		return;
+	case K_CTRL:
+		sc->ctrl = !sc->ctrl;
+		return;
+	case K_ALT:
+		sc->alt = !sc->alt;
+		return;
+	case K_CAPS:
+		sc->capslk = !sc->capslk;
+		swkbd_toggle_shift();
+		return;
+	}
+	/* Check ctrl & shift state */
+	if (sc->ctrl) {
+		if (ac >= 'a' && ac <= 'z')
+			ac = ac - 'a' + 0x01;
+		else if (ac == '\\')
+			ac = 0x1c;
+		else
+			ac = 0;
+	} else if (sc->kbd_page == 2)
+		ac = ki->shifted;
+
+	if (ac == 0)
+		return;
+
+	/* Check caps lock state */
+	if (sc->capslk) {
+		if (ac >= 'A' && ac <= 'Z')
+			ac += 'a' - 'A';
+		else if (ac >= 'a' && ac <= 'z')
+			ac -= 'a' - 'A';
+	}
+
+	/* Check alt key */
+	if (sc->alt)
+		ac |= 0x80;
+
+	wscons_kbd_input(ac);
+
+	/*
+	 * Reset meta key status
+	 */
+	if (sc->shift) {
+		sc->shift = 0;
+		swkbd_toggle_shift();
+	}
+	if (sc->ctrl)
+		sc->ctrl = 0;
+	if (sc->alt)
+		sc->alt = 0;
+}
+
+/*
+ * Input handler
+ * This routine will be called by gamepad ISR.
+ */
+void
+swkbd_input(u_char c)
+{
+	struct swkbd_softc *sc = swkbd_softc;
+	int move = 0;
+	int timeout = BUTTON_WAIT;
+
+	if (sc->ignore_key)
+		return;
+
+	/* Select key */
+	if (c == '\t') {
+		sc->kbd_on = !sc->kbd_on;
+		swkbd_select_page(sc->kbd_on);
+
+		/* Reset meta status */
+		sc->shift = 0;
+		sc->alt = 0;
+		sc->ctrl = 0;
+		sc->capslk = 0;
+		goto out;
+	}
+
+	/* Direct input */
+	if (!sc->kbd_on) {
+		wscons_kbd_input(c);
+		goto out;
+	}
+
+	switch (c) {
+	case K_LEFT:
+		if (sc->pos_x > 0) {
+			if (sc->pos_y == 4 && sc->pos_x >=4 && sc->pos_x <= 8)
+				sc->pos_x = 3;
+			sc->pos_x--;
+			move = 1;
+		}
+		break;
+	case K_RGHT:
+		if (sc->pos_x < max_x[sc->pos_y]) {
+			if (sc->pos_y == 4 && sc->pos_x > 3 && sc->pos_x <= 7)
+				sc->pos_x = 8;
+			sc->pos_x++;
+			move = 1;
+		}
+		break;
+	case K_UP:
+		if (sc->pos_y > 0 ) {
+			sc->pos_y--;
+			move = 1;
+			if (sc->pos_x > max_x[sc->pos_y])
+				sc->pos_x = max_x[sc->pos_y];
+		}
+		break;
+	case K_DOWN:
+		if (sc->pos_y < 4) {
+			sc->pos_y++;
+			move = 1;
+			if (sc->pos_x > max_x[sc->pos_y])
+				sc->pos_x = max_x[sc->pos_y];
+		}
+		break;
+	case 'A':
+		swkbd_key_press();
+		break;
+	case 'B':
+		wscons_kbd_input('\n');
+		break;
+	case 'R':
+	case 'L':
+		sc->shift = sc->shift ? 0 : 1;
+		swkbd_toggle_shift();
+		break;
+	}
+	if (move) {
+		timeout = CURSOR_WAIT;
+		swkbd_move_cursor();
+	}
+out:
+	sc->ignore_key = 1;
+	timer_callout(&sc->timer, timeout, &swkbd_timeout, sc);
+	return;
+}
+
+/*
+ * Init keyboard image
+ */
+static void
+swkbd_init_image(void)
+{
+	uint8_t bit;
+	uint16_t val1, val2;
+	uint16_t *pal = BG_PALETTE;
+	uint16_t *tile1 = KBD1_TILE;
+	uint16_t *tile2 = KBD2_TILE;
+	uint16_t *map1 = KBD1_MAP;
+	uint16_t *map2 = KBD2_MAP;
+	int i, j, row, col;
+
+	/* Load tiles for keyboard image */
+	for (i = 0; i < 32; i++)
+		tile1[i] = 0;
+
+	for (i = 0; i < 64 * 12; i++) {
+		bit = 0x01;
+		for (j = 0; j < 4; j++) {
+			val1 = kbd1_bitmap[i] & bit ? 0xff : 0x03;
+			val2 = kbd2_bitmap[i] & bit ? 0xff : 0x03;
+			bit = bit << 1;
+			val1 |= kbd1_bitmap[i] & bit ? 0xff00 : 0x0300;
+			val2 |= kbd2_bitmap[i] & bit ? 0xff00 : 0x0300;
+			bit = bit << 1;
+			tile1[i * 4 + 32 + j] = val1;
+			tile2[i * 4 + j] = val2;
+		}
+	}
+
+
+	/* Setup map */
+	i = 1;
+	for (row = 1; row < 7; row++) {
+		for (col = 13; col < 29; col++) {
+			map1[row * 32 + col] = (uint16_t)i;
+			map2[row * 32 + col] = (uint16_t)(i + 127);
+			i++;
+		}
+	}
+
+	pal[3] = RGB(0,0,31);	/* Kbd bg color */
+	pal[255] = RGB(28,28,28);	/* Kbd color */
+
+	/* Setup video */
+	REG_BG1CNT = 0x1284;	/* Size0, 256color, priority0 */
+	REG_BG2CNT = 0x1484;	/* Size0, 256color, priority0 */
+
+	swkbd_select_page(1);
+}
+
+/*
+ * Initialize keyboard cursor
+ */
+static void
+swkbd_init_cursor(void)
+{
+	int i, j;
+	uint8_t bit;
+	uint16_t val;
+	uint16_t *oam = OAM;
+	uint16_t *cur = CURSOR_DATA;
+	uint16_t *pal = SPL_PALETTE;
+
+	/* Move out all objects */
+	for (i = 0; i < 128; i++) {
+		oam[0] = 160;
+		oam[1] = 240;
+		oam += 4;
+	}
+	/* Load cursor splite */
+	for (i = 0; i < 64 * 7 + 64 * 8; i++) {
+		bit = 0x01;
+		for (j = 0; j < 4; j++) {
+			val = cursor_bitmap[i] & bit ? 0xff : 0;
+			bit = bit << 1;
+			val |= cursor_bitmap[i] & bit ? 0xff00 : 0;
+			bit = bit << 1;
+			cur[i * 4 + j] = val;
+		}
+	}
+
+	/* Setup cursors */
+	oam = OAM;
+	for (i = 0; i < 7; i++) {
+		oam[0] = (uint16_t)(0x6000 + 160); /* 256 color, Horizontal */
+		oam[1] = (uint16_t)(0x8000 + 240); /* 32x16 */
+		oam[2] = (uint16_t)(i * 16); /* Tile number */
+		oam += 4;
+	}
+	/* for space key */
+	oam[0] = 0x6000 + 160; /* 256 color, Horizontal */
+	oam[1] = 0xC000 + 240; /* 64x32 */
+	oam[2] = 112;
+
+	pal[255] = RGB(31,0,0);	/* cursor color */
+}
+
+/*
+ * Initialize
+ */
+static int
+swkbd_init(struct driver *self)
+{
+	struct swkbd_softc *sc;
+	device_t dev;
+
+	dev = device_create(self, "swkbd", D_CHR);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->kbd_on = 1;
+
+	swkbd_softc = sc;
+
+	swkbd_init_cursor();
+	swkbd_init_image();
+	swkbd_move_cursor();
+
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/arm/gba/swkbd.h b/prex-0.9.0/bsp/drv/arm/gba/swkbd.h
new file mode 100755
index 0000000..eee1224
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/gba/swkbd.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SWKBD_H
+#define _SWKBD_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	swkbd_input(u_char);
+__END_DECLS
+
+#endif /* !_SWKBD_H */
diff --git a/prex-0.9.0/bsp/drv/arm/include/busio.h b/prex-0.9.0/bsp/drv/arm/include/busio.h
new file mode 100755
index 0000000..eed9db3
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/include/busio.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * busio.h - BUS i/o operations
+ */
+
+#ifndef _ARM_BUSIO_H
+#define _ARM_BUSIO_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#define bus_read_8(addr)	(*((volatile uint8_t *)(addr)))
+#define bus_read_16(addr)	(*((volatile uint16_t *)(addr)))
+#define bus_read_32(addr)	(*((volatile uint32_t *)(addr)))
+
+#define bus_write_8(addr, val)	(*((volatile uint8_t *)(addr)) = (val))
+#define bus_write_16(addr, val)	(*((volatile uint16_t *)(addr)) = (val))
+#define bus_write_32(addr, val)	(*((volatile uint32_t *)(addr)) = (val))
+
+#endif /* !_ARM_BUSIO_H */
diff --git a/prex-0.9.0/bsp/drv/arm/include/dkient.h b/prex-0.9.0/bsp/drv/arm/include/dkient.h
new file mode 100755
index 0000000..73a5bcb
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/arm/include/dkient.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Stub to call kernel device interface
+ */
+#define STUB(index, func) .global func;\
+ENTRY(func) \
+	ldr	ip, =dki_table	; \
+	ldr	ip, [ip]	; \
+	ldr	ip, [ip, #(index*4)]	; \
+	mov	pc, ip
diff --git a/prex-0.9.0/bsp/drv/dev/base/Makefile.inc b/prex-0.9.0/bsp/drv/dev/base/Makefile.inc
new file mode 100755
index 0000000..5f4f8d5
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/Makefile.inc
@@ -0,0 +1,12 @@
+
+SRCS+=			dev/base/main.c \
+			dev/base/init.c \
+			dev/base/tty.c
+
+SRCS-$(CONFIG_PM)+=	dev/base/pm.c
+SRCS-$(CONFIG_CONS)+=	dev/base/cons.c
+SRCS-$(CONFIG_WSCONS)+=	dev/base/wscons.c
+
+ifeq ($(DEBUG),1)
+SRCS-$(CONFIG_KD)+=	dev/base/kd.c
+endif
diff --git a/prex-0.9.0/bsp/drv/dev/base/cons.c b/prex-0.9.0/bsp/drv/dev/base/cons.c
new file mode 100755
index 0000000..faff3e5
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/cons.c
@@ -0,0 +1,204 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cons.c - console redirection driver
+ */
+
+#include <driver.h>
+#include <cons.h>
+#include <sys/dbgctl.h>
+
+static int cons_open(device_t, int);
+static int cons_close(device_t);
+static int cons_read(device_t, char *, size_t *, int);
+static int cons_write(device_t, char *, size_t *, int);
+static int cons_ioctl(device_t, u_long, void *);
+static int cons_devctl(device_t, u_long, void *);
+static int cons_init(struct driver *);
+
+static struct devops cons_devops = {
+	/* open */	cons_open,
+	/* close */	cons_close,
+	/* read */	cons_read,
+	/* write */	cons_write,
+	/* ioctl */	cons_ioctl,
+	/* devctl */	cons_devctl,
+};
+
+struct driver cons_driver = {
+	/* name */	"cons",
+	/* devops */	&cons_devops,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	cons_init,
+	/* unload */	NULL,
+};
+
+static struct diag_ops cons_diag_ops = {
+	/* puts */	cons_puts,
+};
+
+static struct consdev *consdev;		/* console device info */
+
+static int
+cons_open(device_t dev, int mode)
+{
+
+	ASSERT(consdev != NULL);
+	dev = consdev->dev;
+	return consdev->devops->open(dev, mode);
+}
+
+static int
+cons_close(device_t dev)
+{
+
+	ASSERT(consdev != NULL);
+	dev = consdev->dev;
+	return consdev->devops->close(dev);
+}
+
+static int
+cons_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	ASSERT(consdev != NULL);
+	dev = consdev->dev;
+	return consdev->devops->read(dev, buf, nbyte, blkno);
+}
+
+static int
+cons_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	ASSERT(consdev != NULL);
+	dev = consdev->dev;
+	return consdev->devops->write(dev, buf, nbyte, blkno);
+}
+
+static int
+cons_ioctl(device_t dev, u_long cmd, void *arg)
+{
+
+	ASSERT(consdev != NULL);
+	dev = consdev->dev;
+	return consdev->devops->ioctl(dev, cmd, arg);
+}
+
+static int
+cons_devctl(device_t dev, u_long cmd, void *arg)
+{
+
+	ASSERT(consdev != NULL);
+	dev = consdev->dev;
+	return consdev->devops->devctl(dev, cmd, arg);
+}
+
+/*
+ * Poll (busy wait) for a input and return the input key.
+ * cons_pollc() must be called before cons_getc() could be used.
+ * cons_getc() should be used only for kernel deugger.
+ */
+int
+cons_getc(void)
+{
+
+	ASSERT(consdev != NULL);
+	return consdev->cngetc(consdev->dev);
+}
+
+/*
+ * Switch the console driver to polling mode if on is non-zero, or
+ * back to interrupt driven mode if on is zero.
+ * cons_pollc() should be used only for kernel deugger.
+ */
+void
+cons_pollc(int on)
+{
+
+	ASSERT(consdev != NULL);
+	consdev->cnpollc(consdev->dev, on);
+}
+
+/*
+ * Console character output routine.
+ */
+void
+cons_putc(int c)
+{
+
+	ASSERT(consdev != NULL);
+	if (c) {
+		consdev->cnputc(consdev->dev, c);
+		if (c == '\n')
+			consdev->cnputc(consdev->dev, '\r');
+	}
+}
+
+void
+cons_puts(char *str)
+{
+
+	ASSERT(consdev != NULL);
+
+	consdev->cnpollc(consdev->dev, 1);
+	while (*str) {
+		consdev->cnputc(consdev->dev, *str);
+		if (*str == '\n')
+			consdev->cnputc(consdev->dev, '\r');
+		str++;
+	}
+	consdev->cnpollc(consdev->dev, 0);
+}
+
+void
+cons_attach(struct consdev *cdev, int diag)
+{
+
+	if (consdev != NULL)
+		return;
+	consdev = cdev;
+
+	/*
+	 * Set console port as diag port.
+	 */
+	if (diag)
+		dbgctl(DBGC_SETDIAG, &cons_diag_ops);
+}
+
+int
+cons_init(struct driver *self)
+{
+
+	consdev = NULL;
+	device_create(self, "console", D_CHR|D_TTY);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/base/init.c b/prex-0.9.0/bsp/drv/dev/base/init.c
new file mode 100755
index 0000000..14e3477
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/init.c
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * init.c - driver initialization routine
+ */
+
+#include <driver.h>
+#include <cons.h>
+#include <dki.h>
+#include <kd.h>
+#include <conf/drvtab.h>
+
+#ifdef DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define NDRIVERS	(int)(sizeof(driver_table) / sizeof(driver_table[0]))
+
+
+/*
+ * Call xxx_probe routine for all drivers.
+ */
+void
+driver_probe(void)
+{
+	struct driver *dp;
+	int i;
+
+	DPRINTF(("Probing devices...\n"));
+
+	for (i = 0; i < NDRIVERS; i++) {
+		dp = driver_table[i];
+		ASSERT(dp != NULL);
+
+		if (dp->probe != NULL) {
+			if (dp->probe(dp) == 0)
+				dp->flags |= DS_ALIVE;
+		} else {
+			/*
+			 * No probe method. Mark it alive.
+			 */
+			dp->flags |= DS_ALIVE;
+		}
+	}
+}
+
+/*
+ * Call xxx_init routine for all living drivers.
+ */
+void
+driver_init(void)
+{
+	struct driver *dp;
+	int i;
+
+	for (i = 0; i < NDRIVERS; i++) {
+		dp = driver_table[i];
+
+		/* All drivers must have init method */
+		ASSERT(dp->init != NULL);
+
+		if (dp->flags & DS_ALIVE) {
+			DPRINTF(("Initializing %s\n", dp->name));
+			if (dp->init(dp) == 0)
+				dp->flags |= DS_ACTIVE;
+		}
+	}
+}
+
+/*
+ * Call xxx_unload routine for all active drivers.
+ */
+void
+driver_shutdown(void)
+{
+	struct driver *dp;
+	int i;
+
+	DPRINTF(("Shutting down...\n"));
+	for (i = NDRIVERS - 1; i >= 0; i--) {
+		dp = driver_table[i];
+		if (dp == NULL)
+			break;
+		/*
+		 * Process only active drivers.
+		 */
+		if (dp->flags & DS_ACTIVE) {
+			DPRINTF(("Unloading %s\n", dp->name));
+			if (dp->unload != NULL)
+				dp->unload(dp);
+		}
+	}
+}
+
+#if defined(DEBUG) && defined(CONFIG_KD)
+void
+driver_dump(void)
+{
+	struct driver *dp;
+	int i = 0;
+
+	printf("Driver table:\n");
+	printf(" probe    init     unload   devops   flags    name\n");
+	printf(" -------- -------- -------- -------- -------- -----------\n");
+
+	for (i = 0; i < NDRIVERS; i++) {
+		dp = driver_table[i];
+		printf(" %08lx %08lx %08lx %08lx %08lx %s\n",
+		       (long)dp->probe, (long)dp->init, (long)dp->unload,
+		       (long)dp->devops,(long) dp->flags, dp->name);
+	}
+}
+#endif
diff --git a/prex-0.9.0/bsp/drv/dev/base/kd.c b/prex-0.9.0/bsp/drv/dev/base/kd.c
new file mode 100755
index 0000000..5379474
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/kd.c
@@ -0,0 +1,740 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * kd.c - kernel debugger.
+ */
+
+#include <driver.h>
+#include <sys/sysinfo.h>
+#include <sys/power.h>
+#include <sys/dbgctl.h>
+#include <sys/endian.h>
+
+#include <devctl.h>
+#include <cons.h>
+#include <pm.h>
+
+#define ARGMAX		32
+
+static void kd_abort(void);
+
+static int kd_null(int, char **);
+static int kd_help(int, char **);
+static int kd_continue(int, char **);
+static int kd_reboot(int, char **);
+static int kd_mstat(int, char **);
+static int kd_thread(int, char **);
+static int kd_task(int, char **);
+static int kd_vm(int, char **);
+static int kd_device(int, char **);
+static int kd_driver(int, char **);
+static int kd_irq(int, char **);
+static int kd_trap(int, char **);
+static int kd_devstat(int, char **);
+static int kd_trace(int, char **);
+static int kd_examine(int, char **);
+static int kd_write(int, char **);
+
+struct cmd_entry {
+	const char	*cmd;
+	int		(*func)(int, char **);
+	const char	*usage;
+};
+
+static const struct cmd_entry cmd_table[] = {
+	{ "help"	,kd_help	,"This help" },
+	{ "continue"	,kd_continue	,"Continue execution [c]" },
+	{ "reboot"	,kd_reboot	,"Reboot system" },
+	{ "mstat" 	,kd_mstat	,"Display memory usage" },
+	{ "thread"	,kd_thread	,"Display thread information" },
+	{ "task"	,kd_task	,"Display task information" },
+	{ "vm"		,kd_vm		,"Dump all VM segments" },
+	{ "device"	,kd_device	,"Display list of devices" },
+	{ "driver"	,kd_driver	,"Display list of drivers" },
+	{ "irq"		,kd_irq		,"Display interrupt information" },
+	{ "trap"	,kd_trap	,"Dump current trap frame" },
+	{ "devstat"	,kd_devstat	,"Dump all device state" },
+	{ "trace"	,kd_trace	,"Set trace flag for task" },
+	{ "examine"	,kd_examine	,"Examine data (x [/fmt] [addr])" },
+	{ "write"	,kd_write	,"Write data (w [/size] addr val)" },
+	/* command alias section */
+	{ "?"		,kd_help	,NULL },
+	{ "x"		,kd_examine	,NULL },
+	{ "w"		,kd_write	,NULL },
+	{ "c"		,kd_continue	,NULL },
+	{ NULL		,kd_null	,NULL },
+};
+
+/*
+ * Errors
+ */
+#define KERR_SYNTAX	1
+#define KERR_TOOMANY	2
+#define KERR_INVAL	3
+#define KERR_BADADDR	4
+#define KERR_NOFUNC	5
+#define KERR_NOMEM	6
+
+static const char *kd_errname[] = {
+	"",
+	"Syntax error",
+	"Too many arguments",
+	"Invalid argument",
+	"No physical memory",
+	"Function not supported",
+	"Out of memory",
+};
+
+#define KERR_MAX	(int)(sizeof(kd_errname) / sizeof(char *))
+
+
+static dpc_t	kd_dpc;			/* dpc for debugger */
+
+static struct abort_ops kd_abort_ops = {
+	/* abort */	kd_abort,
+};
+
+static int
+kd_null(int argc, char **argv)
+{
+	return 0;
+}
+
+static void
+kd_error(int id)
+{
+
+	if (id < KERR_MAX)
+		printf("%s\n", kd_errname[id]);
+}
+
+/*
+ * Get taks id from its name.
+ */
+static task_t
+kd_lookup_task(char *name)
+{
+	struct taskinfo ti;
+	task_t task = TASK_NULL;
+	int rc;
+
+	rc = 0;
+	ti.cookie = 0;
+	do {
+		rc = sysinfo(INFO_TASK, &ti);
+		if (!rc && !strncmp(ti.taskname, name, MAXTASKNAME)) {
+			task = ti.id;
+		}
+	} while (rc == 0);
+	return task;
+}
+
+
+static int
+kd_help(int argc, char **argv)
+{
+	int i = 0;
+
+	while (cmd_table[i].cmd != NULL) {
+		if (cmd_table[i].usage)
+			printf(" %10s -- %s.\n", cmd_table[i].cmd,
+			       cmd_table[i].usage);
+		i++;
+	}
+	printf("\nuse `-?` to find out more about each command.\n");
+	return 0;
+}
+
+static int
+kd_continue(int argc, char **argv)
+{
+
+	return -1;
+}
+
+static int
+kd_reboot(int argc, char **argv)
+{
+
+#ifdef CONFIG_PM
+	pm_set_power(PWR_REBOOT);
+#else
+	machine_powerdown(PWR_REBOOT);
+#endif
+	return 0;
+}
+
+static int
+kd_mstat(int argc, char **argv)
+{
+	struct meminfo info;
+
+	/* Get memory information from kernel. */
+	sysinfo(INFO_MEMORY, &info);
+
+	printf("Memory usage:\n");
+	printf(" Used     :%8ld KB\n", (info.total - info.free) / 1024);
+	printf(" Free     :%8ld KB\n", info.free / 1024);
+	printf(" Total    :%8ld KB\n", info.total / 1024);
+	printf(" Bootdisk :%8ld KB\n", info.bootdisk / 1024);
+	return 0;
+}
+
+static int
+kd_thread(int argc, char **argv)
+{
+	const char state[][4] = \
+		{ "RUN", "SLP", "SUS", "S&S", "EXT" };
+	const char pol[][5] = { "FIFO", "RR  " };
+	struct threadinfo ti;
+	int rc;
+
+	printf("Thread list:\n");
+	printf(" thread   task         stat pol  pri base     time "
+	       "suscnt sleep event\n");
+	printf(" -------- ------------ ---- ---- --- ---- -------- "
+	       "------ ------------\n");
+
+	rc = 0;
+	ti.cookie = 0;
+	do {
+		/* Get thread information from kernel. */
+		rc = sysinfo(INFO_THREAD, &ti);
+		if (!rc) {
+			printf(" %08lx %12s %s%c %s  %3d  %3d %8d %6d %s\n",
+			       ti.id, ti.taskname, state[ti.state],
+			       ti.active ? '*' : ' ',
+			       pol[ti.policy], ti.priority, ti.basepri,
+			       ti.time, ti.suscnt, ti.slpevt);
+		}
+	} while (rc == 0);
+
+	return 0;
+}
+
+static int
+kd_task(int argc, char **argv)
+{
+	struct taskinfo ti;
+	int rc;
+
+	printf("Task list:\n");
+	printf(" task      name     nthreads flags    suscnt capability   vmsize\n");
+	printf(" --------- -------- -------- -------- ------ ---------- --------\n");
+
+	rc = 0;
+	ti.cookie = 0;
+	do {
+		/* Get task information from kernel. */
+		rc = sysinfo(INFO_TASK, &ti);
+		if (!rc) {
+			printf(" %08lx%c %8s %8d %08x %6d   %08x %8d\n",
+			       ti.id, ti.active ? '*' : ' ', ti.taskname,
+			       ti.nthreads, ti.flags, ti.suscnt,
+			       ti.capability, ti.vmsize);
+		}
+	} while (rc == 0);
+
+	return 0;
+}
+
+static void
+kd_vm_region(task_t task)
+{
+	struct vminfo vi;
+	char flags[6];
+	int rc;
+
+	printf(" virtual  physical     size flags\n");
+	printf(" -------- -------- -------- -----\n");
+
+	rc = 0;
+	vi.cookie = 0;
+	do {
+		/* Get task information from kernel. */
+		vi.task = task;
+		rc = sysinfo(INFO_VM, &vi);
+		if (!rc) {
+			if (vi.flags != VF_FREE) {
+				strlcpy(flags, "-----", sizeof(flags));
+				if (vi.flags & VF_READ)
+					flags[0] = 'R';
+				if (vi.flags & VF_WRITE)
+					flags[1] = 'W';
+				if (vi.flags & VF_EXEC)
+					flags[2] = 'E';
+				if (vi.flags & VF_SHARED)
+					flags[3] = 'S';
+				if (vi.flags & VF_MAPPED)
+					flags[4] = 'M';
+				printf(" %08lx %08lx %8x %s\n",
+				       (long)vi.virt, (long)vi.phys,
+				       vi.size, flags);
+			}
+		}
+	} while (rc == 0);
+}
+
+static int
+kd_vm(int argc, char **argv)
+{
+	struct taskinfo ti;
+	int rc;
+
+	printf("VM information:\n");
+
+	rc = 0;
+	ti.cookie = 0;
+	do {
+		/* Get task information from kernel. */
+		rc = sysinfo(INFO_TASK, &ti);
+		if (!rc) {
+			if (ti.vmsize != 0) {
+				printf("\ntask=%08lx name=%s total=%dK bytes\n",
+				       ti.id, ti.taskname, ti.vmsize / 1024);
+				kd_vm_region(ti.id);
+			}
+		}
+	} while (rc == 0);
+
+	return 0;
+}
+
+static int
+kd_device(int argc, char **argv)
+{
+	struct devinfo di;
+	char flags[6];
+	int rc;
+
+	printf("Device list:\n");
+	printf(" device   name         flags\n");
+	printf(" -------- ------------ -----\n");
+
+	rc = 0;
+	di.cookie = 0;
+	do {
+		/* Get device information from kernel. */
+		rc = sysinfo(INFO_DEVICE, &di);
+		if (!rc) {
+			strlcpy(flags, "-----", sizeof(flags));
+			if (di.flags & D_CHR)
+				flags[0] = 'C';
+			if (di.flags & D_BLK)
+				flags[1] = 'B';
+			if (di.flags & D_REM)
+				flags[2] = 'R';
+			if (di.flags & D_PROT)
+				flags[3] = 'P';
+			if (di.flags & D_TTY)
+				flags[4] = 'T';
+
+			printf(" %08lx %12s %s\n", di.id, di.name, flags);
+		}
+	} while (rc == 0);
+
+	return 0;
+}
+
+static int
+kd_driver(int argc, char **argv)
+{
+
+	driver_dump();
+	return 0;
+}
+
+static int
+kd_irq(int argc, char **argv)
+{
+	struct irqinfo ii;
+	int rc;
+
+	printf("Interrupt table:\n");
+	printf(" vector count    pending IST pri thread\n");
+	printf(" ------ -------- ----------- --- --------\n");
+
+	rc = 0;
+	ii.cookie = 0;
+	do {
+		rc = sysinfo(INFO_IRQ, &ii);
+		if (!rc) {
+			printf("   %4d %8d    %8d %3d %08lx\n",
+			       ii.vector, ii.count, ii.istreq,
+			       ii.priority, (long)ii.thread);
+		}
+	} while (rc == 0);
+
+	return 0;
+}
+
+static int
+kd_trap(int argc, char **argv)
+{
+
+	printf("Trap frame:\n");
+
+	dbgctl(DBGC_DUMPTRAP, NULL);
+	return 0;
+}
+
+static int
+kd_devstat(int argc, char **argv)
+{
+
+	printf("Device state:\n");
+
+	device_broadcast(DEVCTL_DBG_DEVSTAT, NULL, 1);
+	return 0;
+}
+
+static int
+kd_trace(int argc, char **argv)
+{
+	task_t task;
+
+	if (argc != 2 || !strncmp(argv[1], "-?", 2)) {
+		printf("usage: trace taskname\n");
+		return 0;
+	}
+
+	task = kd_lookup_task(argv[1]);
+	if (task == TASK_NULL)
+		return KERR_INVAL;
+
+	printf("Toggle trace flag: %s (%08lx)\n", argv[1], (long)task);
+	dbgctl(DBGC_TRACE, (void *)task);
+
+	return 0;
+}
+
+static int
+kd_examine(int argc, char **argv)
+{
+	char *p;
+	u_char *kp;
+	static u_long len = 16;
+	static u_long cnt;
+	static vaddr_t addr;
+	static int size = 4;
+	static char fmt = '*';
+
+	p = argv[1];
+	switch (argc) {
+	case 1:
+		/* Use previous address and format */
+		p = NULL;
+		break;
+	case 2:
+		p = argv[1];
+		len = 16;
+		break;
+	case 3:
+		if (*p != '/')
+			return KERR_INVAL;
+		p++;
+		switch (*p) {
+		case 'c':
+		case 'b':
+		case 'h':
+		case 'w':
+			fmt = *p;
+			p++;
+			break;
+		}
+		len = strtoul(p, NULL, 16);
+		if (len == ULONG_MAX)
+			return KERR_INVAL;
+		p = argv[2];
+		break;
+	default:
+		return KERR_SYNTAX;
+	}
+	if (p != NULL) {
+		addr = strtoul(p, NULL, 16);
+		if (addr == ULONG_MAX)
+			return KERR_INVAL;
+	}
+
+	if ((kp = kmem_map((void *)addr, (size_t)len)) == NULL)
+		return KERR_BADADDR;
+
+	for (cnt = 0; cnt < len;) {
+		if ((cnt % 16) == 0)
+			printf("\n%08lx: ", (long)addr);
+
+		switch (fmt) {
+		case 'c':
+			printf("%c", *kp);
+			size = 1;
+			break;
+		case 'b':
+			printf("%02x ", *kp);
+			size = 1;
+			break;
+		case 'h':
+			printf("%04x ", *(u_short *)kp);
+			size = 2;
+			break;
+		case 'w':
+		default:
+			printf("%08lx ", *(u_long *)kp);
+			size = 4;
+			break;
+		}
+		addr += size;
+		kp += size;
+		cnt += size;
+	}
+	return 0;
+}
+
+static int
+kd_write(int argc, char **argv)
+{
+	vaddr_t addr;
+	int size = 4;
+	u_char *kp;
+	char *p, *pa, *pv;
+	u_long val;
+	int i;
+
+	if (argc < 3)
+		return KERR_INVAL;
+
+	pa = argv[1];
+	pv = argv[2];
+
+	if (argc == 4) {
+		p = argv[1];
+		if (*p != '/')
+			return KERR_INVAL;
+		p++;
+		switch (*p) {
+		case 'b':
+			size = 1;
+			break;
+		case 'h':
+			size = 2;
+			break;
+		case 'w':
+			size = 4;
+			break;
+		default:
+			return KERR_INVAL;
+		}
+		pa = argv[2];
+		pv = argv[3];
+	}
+	addr = strtoul(pa, NULL, 16);
+	if (addr == ULONG_MAX)
+		return KERR_INVAL;
+
+	val = strtoul(pv, NULL, 16);
+	if (val == ULONG_MAX)
+		return KERR_INVAL;
+
+	if ((kp = kmem_map((void *)addr, (size_t)size)) == NULL)
+		return KERR_BADADDR;
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+	for (i = 0; i < size; i++) {
+#else /* BYTE_ORDER == BIG_ENDIAN */
+	for (i = size; i-- > 0;) {
+#endif /* BYTE_ORDER */
+		/* FIXME: need to check alignment...  */
+		*(char *)((char *)addr + i) = (char)(val & 0xff);
+		val >>= 8;
+	}
+
+	return 0;
+}
+
+static int
+kd_dispatch(int argc, char **argv)
+{
+	int i = 0;
+	int error = 0;
+
+	while (cmd_table[i].cmd != NULL) {
+		if (!strncmp(argv[0], cmd_table[i].cmd, LINE_MAX)) {
+			error = (cmd_table[i].func)(argc, argv);
+			break;
+		}
+		i++;
+	}
+	if (cmd_table[i].cmd == NULL)
+		error = KERR_SYNTAX;
+
+	if (error > 0 && error <= KERR_MAX)
+		kd_error(error);
+
+	if (error == -1)
+		return -1;
+	return 0;
+}
+
+static int
+kd_parse_line(char *line)
+{
+	static char *args[ARGMAX];
+	char *p, *word = NULL;
+	int argc = 0;
+	int rc = 0;
+
+	if (line[0] != ' ' && line[0] != '\t')
+		word = line;
+
+	p = line;
+	while (*p) {
+		if (word == NULL) {
+			/* Skip white space. */
+			if (*p != ' ' && *p != '\t')
+				word = p;
+		} else {
+			if (*p == ' ' || *p == '\t') {
+				*p = '\0';
+				args[argc++] = word;
+				word = NULL;
+				if (argc >= ARGMAX - 1) {
+					kd_error(KERR_TOOMANY);
+					return 0;
+				}
+			}
+		}
+		p++;
+	}
+	if (word)
+		args[argc++] = word;
+	args[argc] = NULL;
+
+	if (argc) {
+		if (kd_dispatch(argc, args))
+			rc = 1;
+	}
+	return rc;
+}
+
+static void
+kd_read_line(char *line)
+{
+	int c, pos = 0;
+	char *p = line;
+
+	for (;;) {
+		c = cons_getc();
+
+		switch(c) {
+		case '\n':
+		case '\r':
+			*p = '\0';
+			printf("\n");
+			return;
+		case '\b':
+		case 127:
+			if (pos > 0) {
+				*p = '\0';
+				p--;
+				pos--;
+				printf("\b");
+				printf(" ");
+				printf("\b");
+			}
+			break;
+		default:
+			*p = (char)c;
+			p++;
+			pos++;
+			if (pos > LINE_MAX) {
+				*p = '\0';
+				return;
+			}
+			printf("%c", c);
+			break;
+		}
+	}
+}
+
+void
+kd_invoke(void *arg)
+{
+	static char line[LINE_MAX];
+	int s;
+
+	printf("\n-------------------------------\n");
+	printf(" Entering debugger.\n");
+	printf(" Type 'help' to list commands.\n");
+	printf("-------------------------------\n");
+
+	s = spl0();
+
+	/* Set input device to polling mode. */
+	cons_pollc(1);
+
+	for (;;) {
+		printf("\n[kd] ");
+		kd_read_line(line);
+		if (kd_parse_line(line))
+			break;
+	}
+	cons_pollc(0);
+	splx(s);
+}
+
+/*
+ * User can enter kd by pressing ctrl+k key at any time.
+ */
+void
+kd_enter(void)
+{
+
+	/* Call back in DPC level */
+	sched_dpc(&kd_dpc, &kd_invoke, NULL);
+}
+
+/*
+ * Callback handler for abort.
+ */
+void
+kd_abort(void)
+{
+
+	kd_invoke(NULL);
+}
+
+void
+kd_init(void)
+{
+
+	/*
+	 * Install abort handler to catch assert & panic events.
+	 */
+	dbgctl(DBGC_SETABORT, &kd_abort_ops);
+}
diff --git a/prex-0.9.0/bsp/drv/dev/base/main.c b/prex-0.9.0/bsp/drv/dev/base/main.c
new file mode 100755
index 0000000..ba03ded
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/main.c
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * main.c - driver main routine
+ */
+
+#include <driver.h>
+#include <cons.h>
+#include <kd.h>
+
+#ifdef DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+dkifn_t	*dki_table;		/* pointer to DKI function table */
+
+/*
+ * Entry point of driver module
+ */
+void
+driver_main(dkifn_t *dkient)
+{
+
+	dki_table = dkient;
+
+	DPRINTF(("Prex driver module built: " __DATE__ "\n"));
+
+#if defined(DEBUG) && defined(CONFIG_KD)
+	kd_init();
+#endif
+	calibrate_delay();
+
+	driver_probe();
+	driver_init();
+
+	DPRINTF(("Driver initialized\n"));
+}
diff --git a/prex-0.9.0/bsp/drv/dev/base/pm.c b/prex-0.9.0/bsp/drv/dev/base/pm.c
new file mode 100755
index 0000000..f0244da
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/pm.c
@@ -0,0 +1,526 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pm.c - power management driver
+ */
+
+#include <sys/ioctl.h>
+#include <sys/capability.h>
+#include <sys/power.h>
+#include <sys/signal.h>
+#include <driver.h>
+#include <devctl.h>
+#include <cons.h>
+#include <pm.h>
+
+/* #define DEBUG_PM 1 */
+
+#ifdef DEBUG_PM
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+struct pm_softc {
+	device_t	dev;		/* device object */
+	int		isopen;		/* number of open counts */
+	int		policy;		/* power management policy */
+	int		timer_active;	/* true if pm timer is staring */
+	timer_t		timer;		/* pm timer */
+	u_long		idlecnt;	/* idle counter in sec */
+	u_long		dimtime;	/* auto dim (lcd off) time in sec */
+	u_long		sustime;	/* auto suspend time in sec */
+	task_t		powtask;	/* task for power server */
+	int		lcd_on;		/* true if lcd is off */
+	device_t	lcd_dev;	/* lcd device */
+	int		lastevt;	/* last event */
+};
+
+static int	pm_open(device_t, int);
+static int	pm_close(device_t);
+static int	pm_ioctl(device_t, u_long, void *);
+static int	pm_init(struct driver *);
+static void	pm_stop_timer(void);
+static void	pm_update_timer(void);
+static void	pm_timeout(void *);
+
+
+static struct devops pm_devops = {
+	/* open */	pm_open,
+	/* close */	pm_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	pm_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver pm_driver = {
+	/* name */	"pm",
+	/* devops */	&pm_devops,
+	/* devsz */	sizeof(struct pm_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	pm_init,
+	/* unload */	NULL,
+};
+
+/*
+ * Pointer to the PM state.  There can be only one PM instance.
+ */
+static struct pm_softc *pm_softc;
+
+static int
+pm_open(device_t dev, int mode)
+{
+	struct pm_softc *sc = pm_softc;
+
+	if (!task_capable(CAP_POWERMGMT))
+		return EPERM;
+
+	if (sc->isopen > 0)
+		return EBUSY;
+
+	sc->isopen++;
+	return 0;
+}
+
+static int
+pm_close(device_t dev)
+{
+	struct pm_softc *sc = pm_softc;
+
+	if (!task_capable(CAP_POWERMGMT))
+		return EPERM;
+
+	if (sc->isopen != 1)
+		return EINVAL;
+
+	sc->isopen--;
+	return 0;
+}
+
+static int
+pm_ioctl(device_t dev, u_long cmd, void *arg)
+{
+	struct pm_softc *sc = pm_softc;
+	int error = 0;
+	int policy, state, event;
+
+	if (!task_capable(CAP_POWERMGMT))
+		return EPERM;
+
+	switch (cmd) {
+
+	case PMIOC_CONNECT:
+		/* Connection request from the power server */
+		if (copyin(arg, &sc->powtask, sizeof(task_t)))
+			return EFAULT;
+		DPRINTF(("pm: connect power server\n"));
+		break;
+
+	case PMIOC_QUERY_EVENT:
+		event = sc->lastevt;
+		sc->lastevt = PME_NO_EVENT;
+		if (copyout(&event, arg, sizeof(int)))
+			return EFAULT;
+		DPRINTF(("pm: query event=%d\n", event));
+		break;
+
+	case PMIOC_SET_POWER:
+		if (copyin(arg, &state, sizeof(int)))
+			return EFAULT;
+
+		switch (state) {
+		case PWR_SUSPEND:
+		case PWR_OFF:
+		case PWR_REBOOT:
+			pm_set_power(state);
+			break;
+		default:
+			error = EINVAL;
+			break;
+		}
+		break;
+
+	case PMIOC_GET_POLICY:
+		if (copyout(&sc->policy, arg, sizeof(int)))
+			return EFAULT;
+		DPRINTF(("pm: get policy %d\n", sc->policy));
+		break;
+
+	case PMIOC_SET_POLICY:
+		if (copyin(arg, &policy, sizeof(int)))
+			return EFAULT;
+		if (policy != PM_POWERSAVE && policy != PM_PERFORMANCE)
+			return EINVAL;
+
+		DPRINTF(("pm: set policy %d\n", policy));
+
+		if (policy == sc->policy) {
+			/* same policy */
+			break;
+		}
+		/* Call devctl() routine for all devices */
+		device_broadcast(DEVCTL_PM_CHGPOLICY, &policy, 1);
+
+		sc->policy = policy;
+		if (policy == PM_POWERSAVE)
+			pm_update_timer();
+		else
+			pm_stop_timer();
+		break;
+
+	case PMIOC_GET_SUSTMR:
+		if (copyout(&sc->sustime, arg, sizeof(u_long)))
+			return EFAULT;
+		break;
+
+	case PMIOC_SET_SUSTMR:
+		if (copyin(arg, &sc->sustime, sizeof(u_long)))
+			return EFAULT;
+		DPRINTF(("pm: set sustmr=%d\n", sc->sustime));
+		pm_update_timer();
+		break;
+
+	case PMIOC_GET_DIMTMR:
+		if (copyout(&sc->dimtime, arg, sizeof(u_long)))
+			return EFAULT;
+		break;
+
+	case PMIOC_SET_DIMTMR:
+		if (copyin(arg, &sc->dimtime, sizeof(u_long)))
+			return EFAULT;
+		DPRINTF(("pm: set dimtmr=%d\n", sc->dimtime));
+		pm_update_timer();
+		break;
+
+	default:
+		return EINVAL;
+	}
+	return error;
+}
+
+
+static void
+pm_stop_timer(void)
+{
+	struct pm_softc *sc = pm_softc;
+	int s;
+
+	DPRINTF(("pm: stop timer\n"));
+
+	s = splhigh();
+	if (sc->timer_active) {
+		timer_stop(&sc->timer);
+		sc->idlecnt = 0;
+		sc->timer_active = 0;
+	}
+	splx(s);
+}
+
+static void
+pm_update_timer(void)
+{
+	struct pm_softc *sc = pm_softc;
+	int s;
+
+	if (sc->policy != PM_POWERSAVE)
+		return;
+
+	s = splhigh();
+	sc->idlecnt = 0;
+	if (sc->timer_active) {
+		if (sc->sustime == 0 && sc->dimtime == 0)
+			timer_stop(&sc->timer);
+	} else {
+		if (sc->sustime != 0 || sc->dimtime != 0) {
+			DPRINTF(("pm: start timer\n"));
+			timer_callout(&sc->timer, 1000, &pm_timeout, sc);
+		      	sc->timer_active = 1;
+		}
+	}
+}
+
+
+static int
+pm_suspend(void)
+{
+	int error;
+
+	DPRINTF(("pm: suspend system...\n"));
+
+	pm_stop_timer();
+	error = device_broadcast(DEVCTL_PM_POWERDOWN, NULL, 1);
+	if (error) {
+		device_broadcast(DEVCTL_PM_POWERUP, NULL, 1);
+		return error;
+	}
+	machine_powerdown(PWR_SUSPEND);
+	return 0;
+}
+
+static int
+pm_resume(void)
+{
+
+	DPRINTF(("pm: resume...\n"));
+
+	device_broadcast(DEVCTL_PM_POWERUP, NULL, 1);
+	pm_update_timer();
+	return 0;
+}
+
+static int
+pm_poweroff(void)
+{
+
+	DPRINTF(("pm: power off...\n"));
+
+	pm_stop_timer();
+	device_broadcast(DEVCTL_PM_POWERDOWN, NULL, 1);
+	driver_shutdown();
+
+#ifdef CONFIG_CONS
+	cons_puts("\nThe system is halted. You can turn off power.");
+#endif
+	machine_powerdown(PWR_OFF);
+
+	/* NOTREACHED */
+	return 0;
+}
+
+static int
+pm_reboot(void)
+{
+
+	DPRINTF(("pm: rebooting...\n"));
+
+	pm_stop_timer();
+	device_broadcast(DEVCTL_PM_POWERDOWN, NULL, 1);
+	driver_shutdown();
+	machine_powerdown(PWR_REBOOT);
+
+	/* NOTREACHED */
+	return 0;
+}
+
+static void
+pm_lcd_off(void)
+{
+	struct pm_softc *sc = pm_softc;
+
+	DPRINTF(("pm: LCD off\n"));
+
+	if (sc->lcd_dev != NODEV && sc->lcd_on) {
+		device_control(sc->lcd_dev, DEVCTL_PM_LCDOFF, NULL);
+		if (sc->sustime == 0)
+			pm_stop_timer();
+		sc->lcd_on = 0;
+	}
+}
+
+static void
+pm_lcd_on(void)
+{
+	struct pm_softc *sc = pm_softc;
+
+	DPRINTF(("pm: LCD on\n"));
+
+	if (sc->lcd_dev != NODEV && !sc->lcd_on) {
+		device_control(sc->lcd_dev, DEVCTL_PM_LCDON, NULL);
+		pm_update_timer();
+		sc->lcd_on = 1;
+	}
+}
+
+static void
+pm_timeout(void *arg)
+{
+	struct pm_softc *sc = arg;
+	int s, reload;
+
+	s = splhigh();
+	sc->idlecnt++;
+	splx(s);
+
+	DPRINTF(("pm: idlecnt=%d\n", sc->idlecnt));
+
+	if (sc->sustime != 0 && sc->idlecnt >= sc->sustime) {
+#ifdef CONFIG_CONS
+		cons_puts("\nThe system is about to suspend...");
+#endif
+		pm_suspend();
+	} else {
+		reload = 0;
+		if (sc->dimtime != 0 && sc->idlecnt >= sc->dimtime) {
+			pm_lcd_off();
+			if (sc->sustime != 0)
+				reload = 1;
+		} else
+			reload = 1;
+
+		if (reload)
+			timer_callout(&sc->timer, 1000, &pm_timeout, sc);
+	}
+}
+
+/*
+ * PM service for other drivers.
+ */
+int
+pm_set_power(int state)
+{
+	int error;
+
+	switch (state) {
+	case PWR_ON:
+		error = pm_resume();
+		break;
+	case PWR_SUSPEND:
+		error = pm_suspend();
+		break;
+	case PWR_OFF:
+		error = pm_poweroff();
+		break;
+	case PWR_REBOOT:
+		error = pm_reboot();
+		break;
+	default:
+		error = EINVAL;
+	}
+	return error;
+}
+
+/*
+ * PM event notification.
+ */
+void
+pm_notify(int event)
+{
+	struct pm_softc *sc = pm_softc;
+	int s;
+
+	if (event == PME_USER_ACTIVITY) {
+		/*
+		 * Reload suspend timer for user activity.
+		 */
+		s = splhigh();
+		sc->idlecnt = 0;
+		splx(s);
+
+		if (!sc->lcd_on)
+			pm_lcd_on();
+		return;
+	}
+
+	DPRINTF(("pm: notify %d\n", event));
+
+	if (sc->powtask != TASK_NULL) {
+		/*
+		 * Power server exists.
+		 */
+		switch (event) {
+		case PME_PWRBTN_PRESS:
+		case PME_SLPBTN_PRESS:
+		case PME_LOW_BATTERY:
+		case PME_LCD_CLOSE:
+			/*
+			 * Post an exception to the power server.
+			 * Then, the power server will query PM event.
+			 */
+			sc->lastevt = event;
+			DPRINTF(("pm: post %d\n", event));
+			exception_post(sc->powtask, SIGPWR);
+			break;
+		case PME_LCD_OPEN:
+			sc->lastevt = PME_NO_EVENT;
+			pm_lcd_on();
+			break;
+		}
+	} else {
+		/*
+		 * No power server.
+		 * Map power event to default action.
+		 */
+		switch (event) {
+		case PME_PWRBTN_PRESS:
+			pm_poweroff();
+			break;
+		case PME_SLPBTN_PRESS:
+		case PME_LOW_BATTERY:
+			pm_suspend();
+			break;
+		case PME_LCD_OPEN:
+			pm_lcd_on();
+			break;
+		case PME_LCD_CLOSE:
+			pm_lcd_off();
+			break;
+		}
+	}
+}
+
+void
+pm_attach_lcd(device_t dev)
+{
+
+	ASSERT(pm_softc != NULL);
+
+	pm_softc->lcd_dev = dev;
+}
+
+static int
+pm_init(struct driver *self)
+{
+	struct pm_softc *sc;
+	device_t dev;
+
+	/* Create device object */
+	dev = device_create(self, "pm", D_CHR|D_PROT);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->isopen = 0;
+	sc->policy = DEFAULT_POWER_POLICY;
+	sc->idlecnt = 0;
+	sc->dimtime = 0;
+	sc->sustime = 0;
+	sc->timer_active = 0;
+	sc->powtask = TASK_NULL;
+	sc->lcd_dev = NODEV;
+	sc->lcd_on = 1;
+	sc->lastevt = PME_NO_EVENT;
+
+	pm_softc = sc;
+
+	DPRINTF(("Power policy: %s mode\n",
+		 (sc->policy == PM_POWERSAVE) ? "power save" : "performance"));
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/base/tty.c b/prex-0.9.0/bsp/drv/dev/base/tty.c
new file mode 100755
index 0000000..212202d
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/tty.c
@@ -0,0 +1,632 @@
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)tty.c	8.13 (Berkeley) 1/9/95
+ */
+
+/* Modified for Prex by Kohsuke Ohtani. */
+
+/*
+ * tty.c - TTY device helper
+ */
+
+#include <driver.h>
+#include <sys/signal.h>
+#include <sys/termios.h>
+#include <tty.h>
+#include <pm.h>
+#include <kd.h>
+
+/* #define DEBUG_TTY 1 */
+
+#ifdef DEBUG_TTY
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define	FREAD		0x0001
+#define	FWRITE		0x0002
+
+static void tty_output(int c, struct tty *tp);
+
+/* default control characters */
+static const cc_t	ttydefchars[NCCS] = TTYDEFCHARS;
+
+#define is_ctrl(c)   ((c) < 32 || (c) == 0x7f)
+
+/*
+ * TTY queue operations
+ */
+#define ttyq_next(i)	(((i) + 1) & (TTYQ_SIZE - 1))
+#define ttyq_prev(i)	(((i) - 1) & (TTYQ_SIZE - 1))
+#define ttyq_full(q)	((q)->tq_count >= TTYQ_SIZE)
+#define ttyq_empty(q)	((q)->tq_count == 0)
+
+/*
+ * Get a character from a queue.
+ */
+int
+tty_getc(struct tty_queue *tq)
+{
+	char c;
+	int s;
+
+	s = splhigh();
+	if (ttyq_empty(tq)) {
+		splx(s);
+		return -1;
+	}
+	c = tq->tq_buf[tq->tq_head];
+	tq->tq_head = ttyq_next(tq->tq_head);
+	tq->tq_count--;
+	splx(s);
+	return (int)c;
+}
+
+/*
+ * Put a character into a queue.
+ */
+static void
+tty_putc(int c, struct tty_queue *tq)
+{
+	int s;
+
+	s = splhigh();
+	if (ttyq_full(tq)) {
+		splx(s);
+		return;
+	}
+	tq->tq_buf[tq->tq_tail] = (char)(c & 0xff);
+	tq->tq_tail = ttyq_next(tq->tq_tail);
+	tq->tq_count++;
+	splx(s);
+}
+
+/*
+ * Remove the last character in a queue and return it.
+ */
+static int
+tty_unputc(struct tty_queue *tq)
+{
+	char c;
+	int s;
+
+	if (ttyq_empty(tq))
+		return -1;
+	s = splhigh();
+	tq->tq_tail = ttyq_prev(tq->tq_tail);
+	c = tq->tq_buf[tq->tq_tail];
+	tq->tq_count--;
+	splx(s);
+	return (int)c;
+}
+
+/*
+ * Put the chars in the from queue on the end of the to queue.
+ */
+static void
+tty_catq(struct tty_queue *from, struct tty_queue *to)
+{
+	int c;
+
+	while ((c = tty_getc(from)) != -1)
+		tty_putc(c, to);
+}
+
+/*
+ * Rubout one character from the rawq of tp
+ */
+static void
+tty_rubout(int c, struct tty *tp)
+{
+
+	if (!(tp->t_lflag & ECHO))
+		return;
+	if (tp->t_lflag & ECHOE) {
+		tty_output('\b', tp);
+		tty_output(' ', tp);
+		tty_output('\b', tp);
+	} else
+		tty_output(tp->t_cc[VERASE], tp);
+}
+
+/*
+ * Echo char
+ */
+static void
+tty_echo(int c, struct tty *tp)
+{
+
+	if (!(tp->t_lflag & ECHO)) {
+		if (c == '\n' && (tp->t_lflag & ECHONL))
+			tty_output('\n', tp);
+		return;
+	}
+	if (is_ctrl(c) && c != '\n' && c != '\t' && c != '\b') {
+		tty_output('^', tp);
+		tty_output(c + 'A' - 1, tp);
+	} else
+		tty_output(c, tp);
+}
+
+/*
+ * Start output.
+ */
+static void
+tty_start(struct tty *tp)
+{
+
+	DPRINTF(("tty_start\n"));
+
+	if (tp->t_state & (TS_TTSTOP|TS_BUSY))
+		return;
+	if (tp->t_oproc)
+		(*tp->t_oproc)(tp);
+}
+
+/*
+ * Flush tty read and/or write queues, notifying anyone waiting.
+ */
+static void
+tty_flush(struct tty *tp, int rw)
+{
+
+	DPRINTF(("tty_flush rw=%d\n", rw));
+
+	if (rw & FREAD) {
+		while (tty_getc(&tp->t_canq) != -1)
+			;
+		while (tty_getc(&tp->t_rawq) != -1)
+			;
+		sched_wakeup(&tp->t_input);
+	}
+	if (rw & FWRITE) {
+		tp->t_state &= ~TS_TTSTOP;
+		tty_start(tp);
+	}
+}
+
+/*
+ * Output is completed.
+ */
+void
+tty_done(struct tty *tp)
+{
+
+	if (tp->t_outq.tq_count == 0)
+		tp->t_state &= ~TS_BUSY;
+	if (tp->t_state & TS_ASLEEP) {
+		tp->t_state &= ~TS_ASLEEP;
+		sched_wakeup(&tp->t_output);
+	}
+}
+
+/*
+ * Wait for output to drain.
+ */
+static void
+tty_wait(struct tty *tp)
+{
+
+	/*	DPRINTF(("tty_wait\n")); */
+
+	if ((tp->t_outq.tq_count > 0) && tp->t_oproc) {
+		tp->t_state |= TS_BUSY;
+		while (1) {
+			(*tp->t_oproc)(tp);
+			if ((tp->t_state & TS_BUSY) == 0)
+				break;
+			tp->t_state |= TS_ASLEEP;
+			sched_sleep(&tp->t_output);
+		}
+	}
+}
+
+/*
+ * Send TTY signal at DPC level.
+ */
+static void
+tty_signal(void *arg)
+{
+	struct tty *tp = arg;
+
+	DPRINTF(("tty_signal sig=%d\n", tp->t_signo));
+	exception_post(tp->t_sigtask, tp->t_signo);
+}
+
+/*
+ * Process input of a single character received on a tty.
+ * echo if required.
+ * This may be called with interrupt level.
+ */
+void
+tty_input(int c, struct tty *tp)
+{
+	unsigned char *cc;
+	tcflag_t iflag, lflag;
+	int sig = -1;
+
+	DPRINTF(("tty_input: %d\n", c));
+
+	/* Reload power management timer */
+	pm_notify(PME_USER_ACTIVITY);
+
+	lflag = tp->t_lflag;
+	iflag = tp->t_iflag;
+	cc = tp->t_cc;
+
+#if defined(DEBUG) && defined(CONFIG_KD)
+	if (c == cc[VDDB]) {
+		kd_enter();
+		tty_flush(tp, FREAD | FWRITE);
+		goto endcase;
+	}
+#endif /* !CONFIG_KD*/
+
+	/* IGNCR, ICRNL, INLCR */
+	if (c == '\r') {
+		if (iflag & IGNCR)
+			goto endcase;
+		else if (iflag & ICRNL)
+			c = '\n';
+	} else if (c == '\n' && (iflag & INLCR))
+		c = '\r';
+
+	if (iflag & IXON) {
+		/* stop (^S) */
+		if (c == cc[VSTOP]) {
+			if (!(tp->t_state & TS_TTSTOP)) {
+				tp->t_state |= TS_TTSTOP;
+				return;
+			}
+			if (c != cc[VSTART])
+				return;
+			/* if VSTART == VSTOP then toggle */
+			goto endcase;
+		}
+		/* start (^Q) */
+		if (c == cc[VSTART])
+			goto restartoutput;
+	}
+	if (lflag & ICANON) {
+		/* erase (^H / ^?) or backspace */
+		if (c == cc[VERASE] || c == '\b') {
+			if (!ttyq_empty(&tp->t_rawq))
+				tty_rubout(tty_unputc(&tp->t_rawq), tp);
+			goto endcase;
+		}
+		/* kill (^U) */
+		if (c == cc[VKILL]) {
+			while (!ttyq_empty(&tp->t_rawq))
+				tty_rubout(tty_unputc(&tp->t_rawq), tp);
+			goto endcase;
+		}
+	}
+	if (lflag & ISIG) {
+		/* quit (^C) */
+		if (c == cc[VINTR] || c == cc[VQUIT]) {
+			if (!(lflag & NOFLSH)) {
+				tp->t_state |= TS_ISIG;
+				tty_flush(tp, FREAD | FWRITE);
+			}
+			tty_echo(c, tp);
+			sig = (c == cc[VINTR]) ? SIGINT : SIGQUIT;
+			goto endcase;
+		}
+		/* suspend (^Z) */
+		if (c == cc[VSUSP]) {
+			if (!(lflag & NOFLSH)) {
+				tp->t_state |= TS_ISIG;
+				tty_flush(tp, FREAD | FWRITE);
+			}
+			tty_echo(c, tp);
+			sig = SIGTSTP;
+			goto endcase;
+		}
+	}
+
+	/*
+	 * Check for input buffer overflow
+	 */
+	if (ttyq_full(&tp->t_rawq)) {
+		tty_flush(tp, FREAD | FWRITE);
+		goto endcase;
+	}
+	tty_putc(c, &tp->t_rawq);
+
+	if (lflag & ICANON) {
+		if (c == '\n' || c == cc[VEOF] || c == cc[VEOL]) {
+			tty_catq(&tp->t_rawq, &tp->t_canq);
+			sched_wakeup(&tp->t_input);
+		}
+	} else
+		sched_wakeup(&tp->t_input);
+
+	if (lflag & ECHO)
+		tty_echo(c, tp);
+ endcase:
+	/*
+	 * IXANY means allow any character to restart output.
+	 */
+	if ((tp->t_state & TS_TTSTOP) && (iflag & IXANY) == 0 &&
+	    cc[VSTART] != cc[VSTOP])
+		return;
+ restartoutput:
+	tp->t_state &= ~TS_TTSTOP;
+
+	if (sig != -1) {
+		if (tp->t_sigtask) {
+			tp->t_signo = sig;
+			sched_dpc(&tp->t_dpc, &tty_signal, tp);
+		}
+	}
+	tty_start(tp);
+}
+
+/*
+ * Output a single character on a tty, doing output processing
+ * as needed (expanding tabs, newline processing, etc.).
+ */
+static void
+tty_output(int c, struct tty *tp)
+{
+	int i, col;
+
+	if ((tp->t_lflag & ICANON) == 0) {
+		tty_putc(c, &tp->t_outq);
+		return;
+	}
+	/* Expand tab */
+	if (c == '\t' && (tp->t_oflag & OXTABS)) {
+		i = 8 - (tp->t_column & 7);
+		tp->t_column += i;
+		do
+			tty_putc(' ', &tp->t_outq);
+		while (--i > 0);
+		return;
+	}
+	/* Translate newline into "\r\n" */
+	if (c == '\n' && (tp->t_oflag & ONLCR))
+		tty_putc('\r', &tp->t_outq);
+
+	tty_putc(c, &tp->t_outq);
+
+	col = tp->t_column;
+	switch (c) {
+	case '\b':	/* back space */
+		if (col > 0)
+			--col;
+		break;
+	case '\t':	/* tab */
+		col = (col + 8) & ~7;
+		break;
+	case '\n':	/* newline */
+		col = 0;
+		break;
+	case '\r':	/* return */
+		col = 0;
+		break;
+	default:
+		if (!is_ctrl(c))
+		    ++col;
+		break;
+	}
+	tp->t_column = col;
+	return;
+}
+
+/*
+ * Process a read call on a tty device.
+ */
+int
+tty_read(struct tty *tp, char *buf, size_t *nbyte)
+{
+	unsigned char *cc;
+	struct tty_queue *qp;
+	int rc, tmp;
+	u_char c;
+	size_t count = 0;
+	tcflag_t lflag;
+
+	DPRINTF(("tty_read\n"));
+
+	lflag = tp->t_lflag;
+	cc = tp->t_cc;
+	qp = (lflag & ICANON) ? &tp->t_canq : &tp->t_rawq;
+
+	/* If there is no input, wait it */
+	while (ttyq_empty(qp)) {
+		rc = sched_sleep(&tp->t_input);
+		if (rc == SLP_INTR || tp->t_state & TS_ISIG) {
+			tp->t_state &= ~TS_ISIG;
+			return EINTR;
+		}
+	}
+	while (count < *nbyte) {
+		if ((tmp = tty_getc(qp)) == -1)
+			break;
+		c = (u_char)tmp;
+		if (c == cc[VEOF] && (lflag & ICANON))
+			break;
+		count++;
+		if (copyout(&c, buf, 1))
+			return EFAULT;
+		if ((lflag & ICANON) && (c == '\n' || c == cc[VEOL]))
+			break;
+		buf++;
+	}
+	*nbyte = count;
+	return 0;
+}
+
+/*
+ * Process a write call on a tty device.
+ */
+int
+tty_write(struct tty *tp, char *buf, size_t *nbyte)
+{
+	size_t remain, count = 0;
+	u_char c;
+
+	DPRINTF(("tty_write\n"));
+
+	remain = *nbyte;
+	while (remain > 0) {
+		if (tp->t_outq.tq_count > TTYQ_HIWAT) {
+			tty_start(tp);
+			if (tp->t_outq.tq_count <= TTYQ_HIWAT)
+				continue;
+			tp->t_state |= TS_ASLEEP;
+			sched_sleep(&tp->t_output);
+			continue;
+		}
+		if (copyin(buf, &c, 1))
+			return EFAULT;
+		tty_output((int)c, tp);
+		buf++;
+		remain--;
+		count++;
+	}
+	tty_start(tp);
+	*nbyte = count;
+	return 0;
+}
+
+/*
+ * Ioctls for all tty devices.
+ */
+int
+tty_ioctl(struct tty *tp, u_long cmd, void *data)
+{
+	int flags;
+	struct tty_queue *qp;
+
+	switch (cmd) {
+	case TIOCGETA:
+		if (copyout(&tp->t_termios, data,
+				 sizeof(struct termios)))
+			return EFAULT;
+		break;
+	case TIOCSETAW:
+	case TIOCSETAF:
+		tty_wait(tp);
+		if (cmd == TIOCSETAF)
+			tty_flush(tp, FREAD);
+		/* FALLTHROUGH */
+	case TIOCSETA:
+		if (copyin(data, &tp->t_termios,
+			   sizeof(struct termios)))
+			return EFAULT;
+		break;
+	case TIOCSPGRP:			/* set pgrp of tty */
+		if (copyin(data, &tp->t_pgid, sizeof(pid_t)))
+			return EFAULT;
+		break;
+	case TIOCGPGRP:
+		if (copyout(&tp->t_pgid, data, sizeof(pid_t)))
+			return EFAULT;
+		break;
+	case TIOCFLUSH:
+		if (copyin(data, &flags, sizeof(flags)))
+			return EFAULT;
+		if (flags == 0)
+			flags = FREAD | FWRITE;
+		else
+			flags &= FREAD | FWRITE;
+		tty_flush(tp, flags);
+		break;
+	case TIOCSTART:
+		if (tp->t_state & TS_TTSTOP) {
+			tp->t_state &= ~TS_TTSTOP;
+			tty_start(tp);
+		}
+		break;
+	case TIOCSTOP:
+		if (!(tp->t_state & TS_TTSTOP)) {
+			tp->t_state |= TS_TTSTOP;
+		}
+		break;
+	case TIOCGWINSZ:
+		if (copyout(&tp->t_winsize, data,
+			    sizeof(struct winsize)))
+			return EFAULT;
+		break;
+	case TIOCSWINSZ:
+		if (copyin(data, &tp->t_winsize,
+			   sizeof(struct winsize)))
+			return EFAULT;
+		break;
+	case TIOCSETSIGT:	/* Prex */
+		if (copyin(data, &tp->t_sigtask, sizeof(task_t)))
+			return EFAULT;
+		break;
+	case TIOCINQ:
+		qp = (tp->t_lflag & ICANON) ? &tp->t_canq : &tp->t_rawq;
+		if (copyout(&qp->tq_count, data, sizeof(int)))
+			return EFAULT;
+		break;
+	case TIOCOUTQ:
+		if (copyout(&tp->t_outq.tq_count, data, sizeof(int)))
+			return EFAULT;
+		break;
+	}
+	return 0;
+}
+
+/*
+ * Attach a tty to the tty list.
+ */
+void
+tty_attach(struct tty *tp)
+{
+	struct bootinfo *bi;
+
+	/* Initialize tty */
+	memset(tp, 0, sizeof(struct tty));
+	memcpy(&tp->t_termios.c_cc, ttydefchars, sizeof(ttydefchars));
+
+	event_init(&tp->t_input, "TTY input");
+	event_init(&tp->t_output, "TTY output");
+
+	tp->t_iflag = TTYDEF_IFLAG;
+	tp->t_oflag = TTYDEF_OFLAG;
+	tp->t_cflag = TTYDEF_CFLAG;
+	tp->t_lflag = TTYDEF_LFLAG;
+	tp->t_ispeed = TTYDEF_SPEED;
+	tp->t_ospeed = TTYDEF_SPEED;
+
+	machine_bootinfo(&bi);
+	tp->t_winsize.ws_row = (u_short)bi->video.text_y;
+	tp->t_winsize.ws_col = (u_short)bi->video.text_x;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/base/wscons.c b/prex-0.9.0/bsp/drv/dev/base/wscons.c
new file mode 100755
index 0000000..d1ea552
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/base/wscons.c
@@ -0,0 +1,498 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * wscons.c - "Workstation console" multiplexor driver.
+ */
+
+#include <driver.h>
+#include <cons.h>
+#include <tty.h>
+#include <wscons.h>
+
+/* #define DEBUG_WSCONS 1 */
+
+#ifdef DEBUG_WSCONS
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+struct esc_state {
+	int		index;
+	int		arg1;
+	int		arg2;
+	int		argc;
+	int		saved_col;
+	int		saved_row;
+};
+
+struct wscons_softc {
+	device_t	dev;		/* our device */
+	struct tty	tty;		/* associated tty */
+	int		row;		/* current row */
+	int		col;		/* current col */
+	int		nrows;		/* number of rows */
+	int		ncols;		/* number of cols */
+	int		attr;		/* current attribute */
+	struct esc_state esc;		/* escape state */
+	struct wscons_video_ops *vid_ops; /* video operations */
+	struct wscons_kbd_ops   *kbd_ops; /* keyboard operations */
+	void		*vid_aux;	/* video private data */
+	void		*kbd_aux;	/* keyboard private data */
+};
+
+static int	wscons_init(struct driver *);
+static int	wscons_read(device_t, char *, size_t *, int);
+static int	wscons_write(device_t, char *, size_t *, int);
+static int	wscons_ioctl(device_t, u_long, void *);
+
+static int	wscons_cngetc(device_t);
+static void	wscons_cnputc(device_t, int);
+static void	wscons_cnpollc(device_t, int);
+
+
+static struct devops wscons_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	wscons_read,
+	/* write */	wscons_write,
+	/* ioctl */	wscons_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver wscons_driver = {
+	/* name */	"wscons",
+	/* devops */	&wscons_devops,
+	/* devsz */	sizeof(struct wscons_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	wscons_init,
+	/* unload */	NULL,
+};
+
+static struct consdev wsconsdev = {
+	/* dev */	NODEV,
+	/* devops */	&wscons_devops,
+	/* cngetc */	wscons_cngetc,
+	/* cnputc */	wscons_cnputc,
+	/* cnpollc */	wscons_cnpollc,
+};
+
+static const u_short ansi_colors[] = {0, 4, 2, 6, 1, 5, 3, 7};
+
+/*
+ * Pointer to the wscons state. There can be only one instance.
+ */
+static struct wscons_softc *wscons_softc;
+
+
+static int
+wscons_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct tty *tty = &wscons_softc->tty;
+
+	return tty_read(tty, buf, nbyte);
+}
+
+static int
+wscons_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct tty *tty = &wscons_softc->tty;
+
+	return tty_write(tty, buf, nbyte);
+}
+
+static int
+wscons_ioctl(device_t dev, u_long cmd, void *arg)
+{
+	struct tty *tty = &wscons_softc->tty;
+
+	return tty_ioctl(tty, cmd, arg);
+}
+
+static void
+wscons_move_cursor(struct wscons_softc *sc)
+{
+	struct wscons_video_ops *vops = sc->vid_ops;
+
+	vops->cursor(sc->vid_aux, sc->row, sc->col);
+}
+
+static void
+wscons_set_attr(struct wscons_softc *sc)
+{
+	struct wscons_video_ops *vops = sc->vid_ops;
+
+	vops->set_attr(sc->vid_aux, sc->attr);
+}
+
+static void
+wscons_clear(struct wscons_softc *sc)
+{
+	struct wscons_video_ops *vops = sc->vid_ops;
+
+	vops->eraserows(sc->vid_aux, 0, sc->nrows);
+	sc->col = 0;
+	sc->row = 0;
+	wscons_move_cursor(sc);
+}
+
+static void
+wscons_scrollup(struct wscons_softc *sc)
+{
+	struct wscons_video_ops *vops = sc->vid_ops;
+
+	vops->copyrows(sc->vid_aux, 1, 0, sc->nrows - 1);
+	vops->eraserows(sc->vid_aux, sc->nrows - 1, 1);
+}
+
+static void
+wscons_newline(struct wscons_softc *sc)
+{
+
+	sc->col = 0;
+	sc->row++;
+	if (sc->row >= sc->nrows) {
+		sc->row = sc->nrows - 1;
+		wscons_scrollup(sc);
+	}
+}
+
+/*
+ * Check for escape code sequence.
+ * Rreturn true if escape
+ *
+ * <Support list>
+ *  ESC[#;#H or	: moves cursor to line #, column #
+ *  ESC[#;#f
+ *  ESC[#A	: moves cursor up # lines
+ *  ESC[#B	: moves cursor down # lines
+ *  ESC[#C	: moves cursor right # spaces
+ *  ESC[#D	: moves cursor left # spaces
+ *  ESC[#;#R	: reports current cursor line & column
+ *  ESC[s	: save cursor position for recall later
+ *  ESC[u	: return to saved cursor position
+ *  ESC[2J	: clear screen and home cursor
+ *  ESC[K	: clear to end of line
+ *  ESC[#m	: attribute (0=attribure off, 4=underline, 5=blink)
+ */
+static int
+wscons_check_escape(struct wscons_softc *sc, char c)
+{
+	struct esc_state *esc = &sc->esc;
+	int move = 0;
+	int val;
+	u_short color;
+
+	if (c == 033) {
+		esc->index = 1;
+		esc->argc = 0;
+		return 1;
+	}
+	if (esc->index == 0)
+		return 0;
+
+	if (c >= '0' && c <= '9') {
+		val = c - '0';
+		switch (esc->argc) {
+		case 0:
+			esc->arg1 = val;
+			esc->index++;
+			break;
+		case 1:
+			esc->arg1 = esc->arg1 * 10 + val;
+			break;
+		case 2:
+			esc->arg2 = val;
+			esc->index++;
+			break;
+		case 3:
+			esc->arg2 = esc->arg2 * 10 + val;
+			break;
+		default:
+			goto reset;
+		}
+		esc->argc++;
+		return 1;
+	}
+
+	esc->index++;
+
+	switch (esc->index) {
+        case 2:
+		if (c != '[')
+			goto reset;
+		return 1;
+	case 3:
+		switch (c) {
+		case 's':	/* Save cursor position */
+			esc->saved_col = sc->col;
+			esc->saved_row = sc->row;
+			printf("TTY: save %d %d\n", sc->col, sc->row);
+			break;
+		case 'u':	/* Return to saved cursor position */
+			sc->col = esc->saved_col;
+			sc->row = esc->saved_row;
+			printf("TTY: restore %d %d\n", sc->col, sc->row);
+			wscons_move_cursor(sc);
+			break;
+		case 'K':	/* Clear to end of line */
+			break;
+		}
+		goto reset;
+	case 4:
+		switch (c) {
+		case 'A':	/* Move cursor up # lines */
+			sc->row -= esc->arg1;
+			if (sc->row < 0)
+				sc->row = 0;
+			move = 1;
+			break;
+		case 'B':	/* Move cursor down # lines */
+			sc->row += esc->arg1;
+			if (sc->row >= sc->nrows)
+				sc->row = sc->nrows - 1;
+			move = 1;
+			break;
+		case 'C':	/* Move cursor forward # spaces */
+			sc->col += esc->arg1;
+			if (sc->col >= sc->ncols)
+				sc->col = sc->ncols - 1;
+			move = 1;
+			break;
+		case 'D':	/* Move cursor back # spaces */
+			sc->col -= esc->arg1;
+			if (sc->col < 0)
+				sc->col = 0;
+			move = 1;
+			break;
+		case ';':
+			if (esc->argc == 1)
+				esc->argc = 2;
+			return 1;
+		case 'J':
+			if (esc->arg1 == 2)	/* Clear screen */
+				wscons_clear(sc);
+			break;
+		case 'm':	/* Change attribute */
+			switch (esc->arg1) {
+			case 0:		/* reset */
+				sc->attr = 0x0F;
+				break;
+			case 1:		/* bold */
+				sc->attr = 0x0F;
+				break;
+			case 4:		/* under line */
+				break;
+			case 5:		/* blink */
+				sc->attr |= 0x80;
+				break;
+			case 30: case 31: case 32: case 33:
+			case 34: case 35: case 36: case 37:
+				color = ansi_colors[esc->arg1 - 30];
+				sc->attr = (sc->attr & 0xf0) | color;
+				break;
+			case 40: case 41: case 42: case 43:
+			case 44: case 45: case 46: case 47:
+				color = ansi_colors[esc->arg1 - 40];
+				sc->attr = (sc->attr & 0x0f) | (color << 4);
+				break;
+			}
+			wscons_set_attr(sc);
+			break;
+
+		}
+		if (move)
+			wscons_move_cursor(sc);
+		goto reset;
+	case 6:
+		switch (c) {
+		case 'H':	/* Cursor position */
+		case 'f':
+			sc->row = esc->arg1;
+			sc->col = esc->arg2;
+			if (sc->row >= sc->nrows)
+				sc->row = sc->nrows - 1;
+			if (sc->col >= sc->ncols)
+				sc->col = sc->ncols - 1;
+			wscons_move_cursor(sc);
+			break;
+		case 'R':
+			/* XXX */
+			break;
+		}
+		goto reset;
+	default:
+		goto reset;
+	}
+	/* NOTREACHED */
+ reset:
+	esc->index = 0;
+	esc->argc = 0;
+	return 1;
+}
+
+static void
+wscons_putc(int c)
+{
+	struct wscons_softc *sc = wscons_softc;
+	struct wscons_video_ops *vops = sc->vid_ops;
+
+	if (wscons_check_escape(sc, c))
+		return;
+
+	switch (c) {
+	case '\n':
+		wscons_newline(sc);
+		return;
+	case '\r':
+		sc->col = 0;
+		return;
+	case '\b':
+		if (sc->col == 0)
+			return;
+		sc->col--;
+		return;
+	}
+
+	vops->putc(sc->vid_aux, sc->row, sc->col, c);
+
+	sc->col++;
+	if (sc->col >= sc->ncols) {
+		sc->col = 0;
+		sc->row++;
+		if (sc->row >= sc->nrows) {
+			sc->row = sc->nrows - 1;
+			wscons_scrollup(sc);
+		}
+	}
+}
+
+/*
+ * Start output operation.
+ */
+static void
+wscons_start(struct tty *tp)
+{
+	struct wscons_softc *sc = wscons_softc;
+	int c;
+
+	while ((c = tty_getc(&tp->t_outq)) >= 0)
+		wscons_putc(c);
+
+	wscons_move_cursor(sc);
+	tty_done(tp);
+}
+
+static int
+wscons_cngetc(device_t dev)
+{
+	struct wscons_softc *sc = wscons_softc;
+	struct wscons_kbd_ops *kops = sc->kbd_ops;
+
+	return kops->getc(sc->kbd_aux);
+}
+
+static void
+wscons_cnputc(device_t dev, int c)
+{
+	struct wscons_softc *sc = wscons_softc;
+
+	wscons_putc(c);
+	wscons_move_cursor(sc);
+}
+
+static void
+wscons_cnpollc(device_t dev, int on)
+{
+	struct wscons_softc *sc = wscons_softc;
+	struct wscons_kbd_ops *kops = sc->kbd_ops;
+
+	kops->set_poll(sc->kbd_aux, on);
+}
+
+void
+wscons_kbd_input(int c)
+{
+	struct wscons_softc *sc = wscons_softc;
+
+	tty_input(c, &sc->tty);
+}
+
+void
+wscons_attach_video(struct wscons_video_ops *ops, void *aux)
+{
+	struct wscons_softc *sc = wscons_softc;
+	int diag = 0;
+
+	sc->vid_ops = ops;
+	sc->vid_aux = aux;
+	ops->get_cursor(aux, &sc->col, &sc->row);
+
+#ifdef CONFIG_DIAG_SCREEN
+	diag = 1;
+#endif
+	wsconsdev.dev = sc->dev;
+	cons_attach(&wsconsdev, diag);
+}
+
+void
+wscons_attach_kbd(struct wscons_kbd_ops *ops, void *aux)
+{
+	struct wscons_softc *sc = wscons_softc;
+
+	sc->kbd_ops = ops;
+	sc->kbd_aux = aux;
+}
+
+static int
+wscons_init(struct driver *self)
+{
+	struct bootinfo *bi;
+	struct wscons_softc *sc;
+	device_t dev;
+
+	dev = device_create(self, "tty", D_CHR|D_TTY);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->esc.index = 0;
+	sc->attr = 0x0f;
+	wscons_softc = sc;
+
+	tty_attach(&sc->tty);
+	sc->tty.t_dev = dev;
+	sc->tty.t_oproc = wscons_start;
+
+	machine_bootinfo(&bi);
+	sc->nrows = bi->video.text_y;
+	sc->ncols = bi->video.text_x;
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/block/Makefile.inc b/prex-0.9.0/bsp/drv/dev/block/Makefile.inc
new file mode 100755
index 0000000..6cbf489
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/block/Makefile.inc
@@ -0,0 +1,3 @@
+
+SRCS-$(CONFIG_RAMDISK)+=	dev/block/ramdisk.c
+SRCS-$(CONFIG_FDD)+=		dev/block/fdd.c
diff --git a/prex-0.9.0/bsp/drv/dev/block/fdd.c b/prex-0.9.0/bsp/drv/dev/block/fdd.c
new file mode 100755
index 0000000..564a26b
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/block/fdd.c
@@ -0,0 +1,725 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fdd.c - Floppy disk drive (Intel 82078 FDC)
+ */
+
+/*
+ *  State transition table:
+ *
+ *    State     Interrupt Timeout   Error
+ *    --------- --------- --------- ---------
+ *    Off       N/A       On        N/A
+ *    On        N/A       Reset     N/A
+ *    Reset     Recal     Off       N/A
+ *    Recal     Seek      Off       Off
+ *    Seek      IO        Reset     Off
+ *    IO        Ready     Reset     Off
+ *    Ready     N/A       Off       N/A
+ *
+ */
+
+#include <driver.h>
+
+/* #define DEBUG_FDD 1 */
+
+#ifdef DEBUG_FDD
+#define DPRINTF(a)	printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define FDC_IRQ		6	/* IRQ6 */
+#define FDC_DMA		2	/* DMA2 */
+
+#define SECTOR_SIZE	512
+#define TRACK_SIZE	(SECTOR_SIZE * 18)
+#define INVALID_TRACK	-1
+
+/* I/O ports */
+#define FDC_DOR		0x3f2	/* digital output register */
+#define FDC_MSR		0x3f4	/* main status register (in) */
+#define FDC_DSR		0x3f4	/* data rate select register (out) */
+#define FDC_DAT		0x3f5	/* data register */
+#define FDC_DIR		0x3f7	/* digital input register (in) */
+#define FDC_CCR		0x3f7	/* configuration control register (out) */
+
+/* Command bytes */
+#define CMD_SPECIFY	0x03	/* specify drive timing */
+#define CMD_DRVSTS	0x04
+#define CMD_WRITE	0xc5	/* sector write, multi-track */
+#define CMD_READ	0xe6	/* sector read */
+#define CMD_RECAL	0x07	/* recalibrate */
+#define CMD_SENSE	0x08	/* sense interrupt status */
+#define CMD_FORMAT	0x4d	/* format track */
+#define CMD_SEEK	0x0f	/* seek track */
+#define CMD_VERSION	0x10	/* FDC version */
+
+/* Floppy Drive Geometries */
+#define FDG_HEADS	2
+#define FDG_TRACKS	80
+#define FDG_SECTORS	18
+#define FDG_GAP3FMT	0x54
+#define FDG_GAP3RW	0x1b
+
+/* FDC state */
+#define FDS_OFF		0	/* motor off */
+#define FDS_ON		1	/* motor on */
+#define FDS_RESET	2	/* reset */
+#define FDS_RECAL	3	/* recalibrate */
+#define FDS_SEEK	4	/* seek */
+#define FDS_IO		5	/* read/write */
+#define FDS_READY	6	/* ready */
+
+struct fdd_softc {
+	device_t	dev;		/* device object */
+	int		isopen;		/* number of open counts */
+	int		track;		/* Current track for read buffer */
+	struct irp	irp;		/* I/O request packet */
+	dma_t		dma;		/* DMA handle */
+	irq_t		irq;		/* interrupt handle */
+	timer_t		tmr;		/* timer id */
+	int		stat;		/* current state */
+	void		*rbuf;		/* DMA buffer for read (1 track) */
+	void		*wbuf;		/* DMA buffer for write (1 sector) */
+	u_char		result[7];	/* result from fdc */
+};
+
+static void	fdc_timeout(void *);
+
+static int	fdd_open(device_t, int);
+static int	fdd_close(device_t);
+static int	fdd_read(device_t, char *, size_t *, int);
+static int	fdd_write(device_t, char *, size_t *, int);
+static int	fdd_probe(struct driver *);
+static int	fdd_init(struct driver *);
+
+
+static struct devops fdd_devops = {
+	/* open */	fdd_open,
+	/* close */	fdd_close,
+	/* read */	fdd_read,
+	/* write */	fdd_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver fdd_driver = {
+	/* name */	"fdd",
+	/* devsops */	&fdd_devops,
+	/* devsz */	sizeof(struct fdd_softc),
+	/* flags */	0,
+	/* probe */	fdd_probe,
+	/* init */	fdd_init,
+	/* shutdown */	NULL,
+};
+
+
+/*
+ * Send data to FDC
+ * Return -1 on failure
+ */
+static int
+fdc_out(int dat)
+{
+	int i;
+
+	for (i = 0; i < 100000; i++) {
+		if ((bus_read_8(FDC_MSR) & 0xc0) == 0x80) {
+			delay_usec(1);
+			bus_write_8(FDC_DAT, (u_char)(dat & 0xff));
+			delay_usec(1);
+			return 0;
+		}
+	}
+	DPRINTF(("fdc: timeout msr=%x\n", bus_read_8(FDC_MSR)));
+	return -1;
+}
+
+/* Return number of result bytes */
+static int
+fdc_result(struct fdd_softc *sc)
+{
+	int i, msr, index = 0;
+
+	for (i = 0; i < 50000; i++) {	/* timeout=500msec */
+		msr = bus_read_8(FDC_MSR);
+		if ((msr & 0xd0) == 0x80) {
+			return index;
+		}
+		if ((msr & 0xd0) == 0xd0) {
+			if (index > 6) {
+				DPRINTF(("fdc: overrun\n"));
+				return -1;
+			}
+			sc->result[index++] = bus_read_8(FDC_DAT);
+		}
+		delay_usec(10);
+	}
+	DPRINTF(("fdc: timeout\n"));
+	return -1;
+}
+
+/*
+ * Stop motor. (No interrupt)
+ */
+static void
+fdc_off(struct fdd_softc *sc)
+{
+	DPRINTF(("fdc: motor off\n"));
+
+	sc->stat = FDS_OFF;
+	timer_stop(&sc->tmr);
+	bus_write_8(FDC_DOR, 0x0c);
+	delay_usec(1);
+}
+
+/*
+ * Start motor and wait 250msec. (No interrupt)
+ */
+static void
+fdc_on(struct fdd_softc *sc)
+{
+	DPRINTF(("fdc: motor on\n"));
+
+	sc->stat = FDS_ON;
+	bus_write_8(FDC_DOR, 0x1c);
+	delay_usec(1);
+
+	timer_callout(&sc->tmr, 250, &fdc_timeout, sc);
+}
+
+static void
+fdc_error(struct fdd_softc *sc, int error)
+{
+	struct irp *irp = &sc->irp;
+
+	DPRINTF(("fdc: error=%d\n", error));
+
+	dma_stop(sc->dma);
+	irp->error = error;
+	sched_wakeup(&irp->iocomp);
+	fdc_off(sc);
+}
+
+/*
+ * Reset FDC and wait an intterupt.
+ * Timeout is 500msec.
+ */
+static void
+fdc_reset(struct fdd_softc *sc)
+{
+	DPRINTF(("fdc: reset\n"));
+
+	sc->stat = FDS_RESET;
+	timer_callout(&sc->tmr, 500, &fdc_timeout, sc);
+	bus_write_8(FDC_DOR, 0x18);	/* motor0 enable, DMA enable */
+	delay_usec(20);			/* wait 20 usec while reset */
+	bus_write_8(FDC_DOR, 0x1c);	/* clear reset */
+	delay_usec(1);
+}
+
+/*
+ * Recalibrate FDC and wait an interrupt.
+ * Timeout is 5sec.
+ */
+static void
+fdc_recal(struct fdd_softc *sc)
+{
+	DPRINTF(("fdc: recalibrate\n"));
+
+	sc->stat = FDS_RECAL;
+	timer_callout(&sc->tmr, 5000, &fdc_timeout, sc);
+	fdc_out(CMD_RECAL);
+	fdc_out(0);		/* Drive 0 */
+}
+
+/*
+ * Seek FDC and wait an interrupt.
+ * Timeout is 4sec.
+ */
+static void
+fdc_seek(struct fdd_softc *sc)
+{
+	struct irp *irp = &sc->irp;
+	int head, track;
+
+	DPRINTF(("fdc: seek\n"));
+	sc->stat = FDS_SEEK;
+	head = (irp->blkno % (FDG_SECTORS * FDG_HEADS)) / FDG_SECTORS;
+	track = irp->blkno / (FDG_SECTORS * FDG_HEADS);
+
+	timer_callout(&sc->tmr, 4000, &fdc_timeout, sc);
+
+	fdc_out(CMD_SPECIFY);	/* specify command parameter */
+	fdc_out(0xd1);		/* Step rate = 3msec, Head unload time = 16msec */
+	fdc_out(0x02);		/* Head load time = 2msec, Dma on (0) */
+
+	fdc_out(CMD_SEEK);
+	fdc_out(head << 2);
+	fdc_out(track);
+}
+
+/*
+ * Read/write data and wait an interrupt.
+ * Timeout is 2sec.
+ */
+static void
+fdc_io(struct fdd_softc *sc)
+{
+	struct irp *irp = &sc->irp;
+	int head, track, sect;
+	u_long io_size;
+	int read;
+
+	DPRINTF(("fdc: read/write\n"));
+	sc->stat = FDS_IO;
+
+	head = (irp->blkno % (FDG_SECTORS * FDG_HEADS)) / FDG_SECTORS;
+	track = irp->blkno / (FDG_SECTORS * FDG_HEADS);
+	sect = irp->blkno % FDG_SECTORS + 1;
+	io_size = irp->blksz * SECTOR_SIZE;
+	read = (irp->cmd == IO_READ) ? 1 : 0;
+
+	DPRINTF(("fdc: hd=%x trk=%x sec=%x size=%d read=%d\n",
+		 head, track, sect, io_size, read));
+
+	timer_callout(&sc->tmr, 2000, &fdc_timeout, sc);
+
+	dma_setup(sc->dma, irp->buf, io_size, read);
+
+	/* Send command */
+	fdc_out(read ? CMD_READ : CMD_WRITE);
+	fdc_out(head << 2);
+	fdc_out(track);
+	fdc_out(head);
+	fdc_out(sect);
+	fdc_out(2);		/* sector size = 512 bytes */
+	fdc_out(FDG_SECTORS);
+	fdc_out(FDG_GAP3RW);
+	fdc_out(0xff);
+}
+
+/*
+ * Wake up iorequester.
+ * FDC motor is set to off after 5sec.
+ */
+static void
+fdc_ready(struct fdd_softc *sc)
+{
+	struct irp *irp = &sc->irp;
+
+	DPRINTF(("fdc: wakeup requester\n"));
+
+	sc->stat = FDS_READY;
+	sched_wakeup(&irp->iocomp);
+	timer_callout(&sc->tmr, 5000, &fdc_timeout, sc);
+}
+
+/*
+ * Timeout handler
+ */
+static void
+fdc_timeout(void *arg)
+{
+	struct fdd_softc *sc = arg;
+	struct irp *irp = &sc->irp;
+
+	DPRINTF(("fdc: stat=%d\n", sc->stat));
+
+	switch (sc->stat) {
+	case FDS_ON:
+		fdc_reset(sc);
+		break;
+	case FDS_RESET:
+	case FDS_RECAL:
+		DPRINTF(("fdc: reset/recal timeout\n"));
+		fdc_error(sc, EIO);
+		break;
+	case FDS_SEEK:
+	case FDS_IO:
+		DPRINTF(("fdc: seek/io timeout retry=%d\n", irp->nr_retry));
+		if (++irp->ntries <= 3)
+			fdc_reset(sc);
+		else
+			fdc_error(sc, EIO);
+		break;
+	case FDS_READY:
+		fdc_off(sc);
+		break;
+	default:
+		panic("fdc: unknown timeout");
+	}
+}
+
+/*
+ * Interrupt service routine
+ * Do not change the fdc_stat in isr.
+ */
+static int
+fdc_isr(void *arg)
+{
+	struct fdd_softc *sc = arg;
+	struct irp *irp = &sc->irp;
+
+	DPRINTF(("fdc_stat=%d\n", sc->stat));
+
+	timer_stop(&sc->tmr);
+
+	switch (sc->stat) {
+	case FDS_IO:
+		dma_stop(sc->dma);
+		/* Fall through */
+	case FDS_RESET:
+	case FDS_RECAL:
+	case FDS_SEEK:
+		if (irp->cmd == IO_NONE) {
+			DPRINTF(("fdc: invalid interrupt\n"));
+			timer_stop(&sc->tmr);
+			break;
+		}
+		return INT_CONTINUE;
+	case FDS_OFF:
+		break;
+	default:
+		DPRINTF(("fdc: unknown interrupt\n"));
+		break;
+	}
+	return 0;
+}
+
+/*
+ * Interrupt service thread
+ * This is called when command completion.
+ */
+static void
+fdc_ist(void *arg)
+{
+	struct fdd_softc *sc = arg;
+	struct irp *irp = &sc->irp;
+	int i;
+
+	DPRINTF(("fdc_stat=%d\n", sc->stat));
+	if (irp->cmd == IO_NONE)
+		return;
+
+	switch (sc->stat) {
+	case FDS_RESET:
+		/* clear output buffer */
+		for (i = 0; i < 4; i++) {
+			fdc_out(CMD_SENSE);
+			fdc_result(sc);
+		}
+		fdc_recal(sc);
+		break;
+	case FDS_RECAL:
+		fdc_out(CMD_SENSE);
+		fdc_result(sc);
+		if ((sc->result[0] & 0xf8) != 0x20) {
+			DPRINTF(("fdc: recal error\n"));
+			fdc_error(sc, EIO);
+			break;
+		}
+		fdc_seek(sc);
+		break;
+	case FDS_SEEK:
+		fdc_out(CMD_SENSE);
+		fdc_result(sc);
+		if ((sc->result[0] & 0xf8) != 0x20) {
+			DPRINTF(("fdc: seek error\n"));
+			if (++irp->ntries <= 3)
+				fdc_reset(sc);
+			else
+				fdc_error(sc, EIO);
+			break;
+		}
+		fdc_io(sc);
+		break;
+	case FDS_IO:
+		fdc_result(sc);
+		if ((sc->result[0] & 0xd8) != 0x00) {
+			if (++irp->ntries <= 3)
+				fdc_reset(sc);
+			else
+				fdc_error(sc, EIO);
+			break;
+		}
+		DPRINTF(("fdc: i/o complete\n"));
+		fdc_ready(sc);
+		break;
+	case FDS_OFF:
+		/* Ignore */
+		break;
+	default:
+		ASSERT(0);
+	}
+}
+
+
+static int
+fdd_open(device_t dev, int mode)
+{
+	struct fdd_softc *sc = device_private(dev);
+
+	if (sc->isopen > 0)
+		return EBUSY;
+
+	sc->isopen++;
+	sc->irp.cmd = IO_NONE;
+	return 0;
+}
+
+static int
+fdd_close(device_t dev)
+{
+	struct fdd_softc *sc = device_private(dev);
+
+	if (sc->isopen != 1)
+		return EINVAL;
+
+	sc->isopen--;
+	sc->irp.cmd = IO_NONE;
+
+	fdc_off(sc);
+	return 0;
+}
+
+/*
+ * Common routine for read/write
+ */
+static int
+fdd_rw(struct fdd_softc *sc, int cmd, char *buf, u_long blksz, int blkno)
+{
+	struct irp *irp = &sc->irp;
+	int error;
+
+	DPRINTF(("fdd_rw: cmd=%x buf=%x blksz=%d blkno=%x\n",
+		 cmd, buf, blksz, blkno));
+
+	irp->cmd = cmd;
+	irp->ntries = 0;
+	irp->blkno = blkno;
+	irp->blksz = blksz;
+	irp->buf = buf;
+	irp->error = 0;
+
+	sched_lock();
+	if (sc->stat == FDS_OFF)
+		fdc_on(sc);
+	else
+		fdc_seek(sc);
+
+	if (sched_sleep(&irp->iocomp) == SLP_INTR)
+		error = EINTR;
+	else
+		error = irp->error;
+
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Read
+ *
+ * Error:
+ *  EINTR   ... Interrupted by signal
+ *  EIO     ... Low level I/O error
+ *  ENXIO   ... Write protected
+ *  EFAULT  ... No physical memory is mapped to buffer
+ */
+static int
+fdd_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct fdd_softc *sc = device_private(dev);
+	char *kbuf;
+	int track, sect, error;
+	u_int i, nr_sect;
+
+	DPRINTF(("fdd_read: buf=%x nbyte=%d blkno=%x\n", buf, *nbyte, blkno));
+
+	/* Check overrun */
+	if (blkno > FDG_HEADS * FDG_TRACKS * FDG_SECTORS)
+		return EIO;
+
+	/* Translate buffer address to kernel address */
+	if ((kbuf = kmem_map(buf, *nbyte)) == NULL)
+		return EFAULT;
+
+	nr_sect = *nbyte / SECTOR_SIZE;
+	error = 0;
+	for (i = 0; i < nr_sect; i++) {
+		/* Translate the logical sector# to logical track#/sector#. */
+		track = blkno / FDG_SECTORS;
+		sect = blkno % FDG_SECTORS;
+
+		/*
+		 * If target sector does not exist in buffer,
+		 * read 1 track (18 sectors) at once.
+		 */
+		if (track != sc->track) {
+			error = fdd_rw(sc, IO_READ, sc->rbuf, FDG_SECTORS,
+				       track * FDG_SECTORS);
+			if (error != 0) {
+				sc->track = INVALID_TRACK;
+				break;
+			}
+			sc->track = track;
+		}
+		memcpy(kbuf, (char *)sc->rbuf + sect * SECTOR_SIZE,
+		       SECTOR_SIZE);
+		blkno++;
+		kbuf += SECTOR_SIZE;
+	}
+	*nbyte = i * SECTOR_SIZE;
+	return error;
+}
+
+/*
+ * Write
+ *
+ * Error:
+ *  EINTR   ... Interrupted by signal
+ *  EIO     ... Low level I/O error
+ *  ENXIO   ... Write protected
+ *  EFAULT  ... No physical memory is mapped to buffer
+ */
+static int
+fdd_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct fdd_softc *sc = device_private(dev);
+	char *kbuf, *wbuf;
+	int track, sect, error;
+	u_int i, nr_sect;
+
+	DPRINTF(("fdd_write: buf=%x nbyte=%d blkno=%x\n", buf, *nbyte, blkno));
+
+	/* Check overrun */
+	if (blkno > FDG_HEADS * FDG_TRACKS * FDG_SECTORS)
+		return EIO;
+
+	/* Translate buffer address to kernel address */
+	if ((kbuf = kmem_map(buf, *nbyte)) == NULL)
+		return EFAULT;
+
+	nr_sect = *nbyte / SECTOR_SIZE;
+	error = 0;
+	for (i = 0; i < nr_sect; i++) {
+		/* Translate the logical sector# to track#/sector#. */
+		track = blkno / FDG_SECTORS;
+		sect = blkno % FDG_SECTORS;
+
+		/*
+		 * If target sector exists in read buffer, use it as
+		 * write buffer to keep the cache cohrency.
+		 */
+		if (track == sc->track)
+			wbuf = (char *)sc->rbuf + sect * SECTOR_SIZE;
+		else
+			wbuf = sc->wbuf;
+
+		memcpy(wbuf, kbuf, SECTOR_SIZE);
+		error = fdd_rw(sc, IO_WRITE, wbuf, 1, blkno);
+		if (error != 0) {
+			sc->track = INVALID_TRACK;
+			break;
+		}
+		blkno++;
+		kbuf += SECTOR_SIZE;
+	}
+	*nbyte = i * SECTOR_SIZE;
+
+	DPRINTF(("fdd_write: error=%d\n", error));
+	return error;
+}
+
+static int
+fdd_probe(struct driver *self)
+{
+
+	if (bus_read_8(FDC_MSR) == 0xff) {
+		printf("Floppy drive not found!\n");
+		return ENXIO;
+	}
+	return 0;
+}
+
+static int
+fdd_init(struct driver *self)
+{
+	struct fdd_softc *sc;
+	struct irp *irp;
+	device_t dev;
+	char *buf;
+	int i;
+
+	dev = device_create(self, "fd0", D_BLK|D_PROT);
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->isopen = 0;
+
+	/* Initialize I/O request packet */
+	irp = &sc->irp;
+	irp->cmd = IO_NONE;
+	event_init(&irp->iocomp, "fdd i/o");
+
+	/*
+	 * Allocate physical pages for DMA buffer.
+	 * Buffer: 1 track for read, 1 sector for write.
+	 */
+	buf = dma_alloc(TRACK_SIZE + SECTOR_SIZE);
+	ASSERT(buf != NULL);
+	sc->rbuf = buf;
+	sc->wbuf = buf + TRACK_SIZE;
+	sc->dma = dma_attach(FDC_DMA);
+
+	/*
+	 * Attach IRQ.
+	 */
+	sc->irq = irq_attach(FDC_IRQ, IPL_BLOCK, 0, fdc_isr, fdc_ist, sc);
+
+	sc->stat = FDS_OFF;
+	sc->track = INVALID_TRACK;
+
+	/* Reset FDC */
+	bus_write_8(FDC_DOR, 0x08);
+	delay_usec(20);
+	bus_write_8(FDC_DOR, 0x0C);
+	delay_usec(1);
+
+	/* Data rate 500k bps */
+	bus_write_8(FDC_CCR, 0x00);
+
+	/* Clear output buffer */
+	for (i = 0; i < 4; i++) {
+		fdc_out(CMD_SENSE);
+		fdc_result(sc);
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/block/ramdisk.c b/prex-0.9.0/bsp/drv/dev/block/ramdisk.c
new file mode 100755
index 0000000..d069a04
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/block/ramdisk.c
@@ -0,0 +1,176 @@
+/*-
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ramdisk.c - RAM disk driver
+ */
+
+#include <driver.h>
+
+/* #define DEBUG_RAMDISK 1 */
+
+#ifdef DEBUG_RAMDISK
+#define DPRINTF(a)	printf a
+#else
+#define DPRINTF(a)
+#endif
+
+/* Block size */
+#define BSIZE		512
+
+struct ramdisk_softc {
+	device_t	dev;		/* device object */
+	char		*addr;		/* base address of image */
+	size_t		size;		/* image size */
+};
+
+static int ramdisk_read(device_t, char *, size_t *, int);
+static int ramdisk_write(device_t, char *, size_t *, int);
+static int ramdisk_probe(struct driver *);
+static int ramdisk_init(struct driver *);
+
+static struct devops ramdisk_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	ramdisk_read,
+	/* write */	ramdisk_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver ramdisk_driver = {
+	/* name */	"ramdisk",
+	/* devops */	&ramdisk_devops,
+	/* devsz */	sizeof(struct ramdisk_softc),
+	/* flags */	0,
+	/* probe */	ramdisk_probe,
+	/* init */	ramdisk_init,
+	/* shutdown */	NULL,
+};
+
+static int
+ramdisk_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct ramdisk_softc *sc = device_private(dev);
+	int offset = blkno * BSIZE;
+	void *kbuf;
+	size_t nr_read;
+
+	DPRINTF(("ramdisk_read: buf=%x nbyte=%d blkno=%x\n",
+		 buf, *nbyte, blkno));
+
+	/* Check overrun */
+	if (offset > (int)sc->size) {
+		DPRINTF(("ramdisk_read: overrun!\n"));
+		return EIO;
+	}
+	nr_read = *nbyte;
+	if (offset + nr_read > (int)sc->size)
+		nr_read = sc->size - offset;
+
+	/* Translate buffer address to kernel address */
+	if ((kbuf = kmem_map(buf, nr_read)) == NULL) {
+		return EFAULT;
+	}
+
+	/* Copy data */
+	memcpy(kbuf, sc->addr + offset, nr_read);
+	*nbyte = nr_read;
+	return 0;
+}
+
+static int
+ramdisk_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct ramdisk_softc *sc = device_private(dev);
+	int offset = blkno * BSIZE;
+	void *kbuf;
+	size_t nr_write;
+
+	DPRINTF(("ramdisk_write: buf=%x nbyte=%d blkno=%x\n",
+		 buf, *nbyte, blkno));
+
+	/* Check overrun */
+	if (offset > (int)sc->size)
+		return EIO;
+	nr_write = *nbyte;
+	if (offset + nr_write > (int)sc->size)
+		nr_write = sc->size - offset;
+
+	/* Translate buffer address to kernel address */
+	if ((kbuf = kmem_map(buf, nr_write)) == NULL)
+		return EFAULT;
+
+	/* Copy data */
+	memcpy(sc->addr + offset, kbuf, nr_write);
+	*nbyte = nr_write;
+	return 0;
+}
+
+static int
+ramdisk_probe(struct driver *self)
+{
+	struct bootinfo *bi;
+	struct physmem *phys;
+
+	machine_bootinfo(&bi);
+	phys = &bi->bootdisk;
+	if (phys->size == 0) {
+#ifdef DEBUG
+		printf("ramdisk: no bootdisk found...\n");
+#endif
+		return ENXIO;
+	}
+	return 0;
+}
+
+static int
+ramdisk_init(struct driver *self)
+{
+	struct ramdisk_softc *sc;
+	struct bootinfo *bi;
+	struct physmem *phys;
+	device_t dev;
+
+	machine_bootinfo(&bi);
+	phys = &bi->bootdisk;
+
+	dev = device_create(self, "ram0", D_BLK|D_PROT);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->addr = (char *)ptokv(phys->base);
+	sc->size = (size_t)phys->size;
+
+#ifdef DEBUG
+	printf("RAM disk at 0x%08x (%dK bytes)\n",
+	       (u_int)sc->addr, sc->size/1024);
+#endif
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/cpufreq/Makefile.inc b/prex-0.9.0/bsp/drv/dev/cpufreq/Makefile.inc
new file mode 100755
index 0000000..b1562af
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/cpufreq/Makefile.inc
@@ -0,0 +1,3 @@
+
+SRCS-$(CONFIG_CPUFREQ)+=	dev/cpufreq/cpufreq.c
+SRCS-$(CONFIG_EST)+=		dev/cpufreq/est.c
diff --git a/prex-0.9.0/bsp/drv/dev/cpufreq/cpufreq.c b/prex-0.9.0/bsp/drv/dev/cpufreq/cpufreq.c
new file mode 100755
index 0000000..2949979
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/cpufreq/cpufreq.c
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2007-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpufreq.c - CPU frequency control driver
+ */
+
+/*
+ * Dynamic voltage scaling (DVS)
+ *
+ * DVS is widely used with mobile systems to save the processor
+ * power consumption, with minimum impact on performance.
+ * The basic idea is come from the fact the power consumption is
+ * proportional to V^2 x f, where V is voltage and f is frequency.
+ * Since processor does not always require the full performance,
+ * we can reduce power consumption by lowering voltage and frequeceny.
+ */
+
+#include <sys/ioctl.h>
+#include <sys/power.h>
+#include <driver.h>
+#include <sys/sysinfo.h>
+#include <devctl.h>
+#include <cpufreq.h>
+
+/* #define DEBUG_CPUFREQ 1 */
+
+#ifdef DEBUG_CPUFREQ
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+/*
+ * DVS parameters
+ */
+#define SAMPLING_RATE		50	/* msec */
+#define SAMPLING_TICK		mstohz(SAMPLING_RATE)
+#define WEIGHT			3
+
+struct cpufreq_softc {
+	int		enable;		/* true if enabled */
+	device_t	dev;		/* device object */
+	struct timer	timer;		/* performance sampling timer */
+	struct cpufreq_ops *ops;	/* low level h/w operations */
+};
+
+static int cpufreq_ioctl(device_t, u_long, void *);
+static int cpufreq_devctl(device_t, u_long, void *);
+static int cpufreq_init(struct driver *);
+
+
+static struct devops cpufreq_devops= {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	cpufreq_ioctl,
+	/* devctl */	cpufreq_devctl,
+};
+
+struct driver cpufreq_driver = {
+	/* name */	"cpufreq",
+	/* devops */	&cpufreq_devops,
+	/* devsz */	sizeof(struct cpufreq_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	cpufreq_init,
+	/* shutdown */	NULL,
+};
+
+/*
+ * DVS related data
+ */
+static u_long	last_cputicks;
+static u_long	last_idleticks;
+static int	cur_speed;	/* current CPU speed (%) */
+static int	max_speed;	/* maximum CPU speed (%) */
+static int	min_speed;	/* minimum CPU speed (%) */
+static u_long	avg_workload;	/* average workload */
+static u_long	avg_deadline;	/* average deadline */
+static u_long	excess_cycles;	/* cycles left over from the last interval */
+
+/*
+ * Predict max CPU speed.
+ *
+ * DVS Algorithm: AVG<3>
+ *
+ *  Computes an exponentially moving average of the previous intervals.
+ *  <wight> is the relative weighting of past intervals relative to
+ *  the current interval.
+ *
+ *   predict = (weight x current + past) / (weight + 1)
+ *
+ * Refernce:
+ *   K.Govil, E.Chan, H.Wasserman,
+ *   "Comparing Algorithm for Dynamic Speed-Setting of a Low-Power CPU".
+ *   Proc. 1st Int'l Conference on Mobile Computing and Networking,
+ *   Nov 1995.
+ */
+static void
+cpufreq_predict_max_speed(u_long run_cycles, u_long idle_cycles)
+{
+	u_long new_workload, new_deadline;
+
+	new_workload = run_cycles * cur_speed;
+	new_deadline = (run_cycles + idle_cycles) * cur_speed;
+
+	avg_workload = (avg_workload * WEIGHT + new_workload) / (WEIGHT + 1);
+	avg_deadline = (avg_deadline * WEIGHT + new_deadline) / (WEIGHT + 1);
+
+	max_speed = (int)(avg_workload * 100 / avg_deadline);
+	if (max_speed < 50)
+		max_speed = 50;
+
+	DPRINTF(("cpufreq: new_workload=%u new_deadline=%u\n",
+		 new_workload, new_deadline));
+	DPRINTF(("cpufreq: avg_workload=%u avg_deadline=%u\n",
+		 avg_workload, avg_deadline));
+	DPRINTF(("cpufreq: max_speed=%d\n", max_speed));
+}
+
+/*
+ * Predict CPU speed.
+ *
+ * DVS Algorithm: Weiser Style
+ *
+ *  If the utilization prediction x is high (over 70%), increase the
+ *  speed by 20% of the maximum speed. If the utilization prediction
+ *  is low (under 50%), decrease the speed by (60 - x)% of the
+ *  maximum speed.
+ *
+ *  excess_cycles is defined as the number of uncompleted run cycles
+ *  from the last interval. For example, if we find 70% activity
+ *  when runnig at full speed, and their processor speed was set to
+ *  50% during that interval, excess_cycles is set to 20%. This
+ *  value (20%) is used to calculate the processor speed in the next
+ *  interval.
+ *
+ * Refernce:
+ *   M.Weiser, B.Welch, A.Demers, and S.Shenker,
+ *   "Scheduling for Reduced CPU Energy", In Proceedings of the
+ *   1st Symposium on Operating Systems Design and Implementation,
+ *   pages 13-23, November 1994.
+ */
+static int
+cpufreq_predict_cpu_speed(u_long run_cycles, u_long idle_cycles)
+{
+	u_long next_excess;
+	u_int run_percent;
+	u_int new_speed = cur_speed;
+
+	run_cycles += excess_cycles;
+	run_percent = (int)((run_cycles * 100) / (idle_cycles + run_cycles));
+
+	next_excess = run_cycles -
+		cur_speed * (run_cycles + idle_cycles) / 100;
+	if (next_excess < 0)
+		next_excess = 0;
+
+	if (excess_cycles > idle_cycles)
+		new_speed = 100;
+	else if (run_percent > 70)
+		new_speed = cur_speed + 20;
+	else if (run_percent < 50)
+		new_speed = cur_speed - (60 - run_percent);
+
+	if (new_speed > max_speed)
+		new_speed = max_speed;
+	if (new_speed < min_speed)
+		new_speed = min_speed;
+
+	DPRINTF(("cpufreq: run_percent=%d next_excess=%d new_speed=%d\n\n",
+		 run_percent, next_excess, new_speed));
+
+	excess_cycles = next_excess;
+
+	return new_speed;
+}
+
+/*
+ * Timer callback routine.
+ */
+static void
+cpufreq_timeout(void *arg)
+{
+	struct cpufreq_softc *sc = arg;
+	struct timerinfo info;
+	int new_speed;
+	u_long idle_cycles, run_cycles;
+
+	/*
+	 * Get run/idle cycles.
+	 */
+	sysinfo(INFO_TIMER, &info);
+	idle_cycles = info.idleticks - last_idleticks;
+	run_cycles = info.cputicks - last_cputicks - idle_cycles;
+
+	DPRINTF(("cpufreq: run_cycles=%d idle_cycles=%d cur_speed=%d\n",
+		 run_cycles, idle_cycles, cur_speed));
+
+	/*
+	 * Predict max CPU speed.
+	 */
+	cpufreq_predict_max_speed(run_cycles, idle_cycles);
+
+	/*
+	 * Predict next CPU speed.
+	 */
+	new_speed = cpufreq_predict_cpu_speed(run_cycles, idle_cycles);
+	if (new_speed != cur_speed) {
+		sc->ops->setperf(new_speed);
+		cur_speed = sc->ops->getperf();
+	}
+
+	last_cputicks = info.cputicks;
+	last_idleticks = info.idleticks;
+
+	timer_callout(&sc->timer, SAMPLING_RATE, &cpufreq_timeout, sc);
+}
+
+/*
+ * Enable DVS operation
+ */
+static void
+cpufreq_enable(struct cpufreq_softc *sc)
+{
+	struct timerinfo info;
+
+	ASSERT(sc->ops != NULL);
+
+	DPRINTF(("cpufreq: enable\n"));
+
+	if (sc->enable)
+		return;
+	sc->enable = 1;
+
+	/*
+	 * Initialize DVS parameters.
+	 */
+	sysinfo(INFO_TIMER, &info);
+	last_cputicks = info.cputicks;
+	last_idleticks = info.idleticks;
+
+	max_speed = 100;	/* max 100% */
+	min_speed = 5;		/* min   5% */
+	cur_speed = sc->ops->getperf();
+
+	excess_cycles = 0;
+	avg_workload = SAMPLING_TICK * 100;
+	avg_deadline = SAMPLING_TICK * 100;
+
+	timer_callout(&sc->timer, SAMPLING_RATE, &cpufreq_timeout, sc);
+}
+
+/*
+ * Disable DVS operation
+ */
+static void
+cpufreq_disable(struct cpufreq_softc *sc)
+{
+
+	DPRINTF(("cpufreq: disable\n"));
+
+	if (!sc->enable)
+		return;
+	sc->enable = 0;
+
+	timer_stop(&sc->timer);
+
+	/* Set CPU speed to 100% */
+	sc->ops->setperf(100);
+	cur_speed = 100;
+}
+
+static int
+cpufreq_ioctl(device_t dev, u_long cmd, void *arg)
+{
+	struct cpufreq_softc *sc = device_private(dev);
+	struct cpufreqinfo info;
+
+	if (sc->ops == NULL)
+		return EINVAL;
+
+	switch (cmd) {
+	case CFIOC_GET_INFO:
+		sc->ops->getinfo(&info);
+		if (copyout(&info, arg, sizeof(info)))
+			return EFAULT;
+		break;
+	default:
+		return EINVAL;
+	}
+	return 0;
+}
+
+static int
+cpufreq_devctl(device_t dev, u_long cmd, void *arg)
+{
+	struct cpufreq_softc *sc = device_private(dev);
+	int error = 0;
+	int policy;
+
+	DPRINTF(("cpufreq: devctl cmd=%d\n", cmd));
+
+	if (sc->ops == NULL)
+		return 0;
+
+	switch (cmd) {
+	case DEVCTL_PM_CHGPOLICY:
+		DPRINTF(("cpufreq: change policy\n"));
+		policy = *(int *)arg;
+		DPRINTF(("cpufreq: policy=%d\n", policy));
+		if (policy == PM_POWERSAVE)
+			cpufreq_enable(sc);
+		else
+			cpufreq_disable(sc);
+		break;
+	}
+	return error;
+}
+
+void
+cpufreq_attach(struct cpufreq_ops *ops)
+{
+	struct cpufreq_softc *sc;
+	device_t dev;
+	int policy;
+
+	DPRINTF(("cpufreq: attach ops=%x\n", ops));
+
+	dev = device_create(&cpufreq_driver, "cpufreq", D_CHR|D_PROT);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->enable = 0;
+	sc->ops = ops;
+	cur_speed = 100;
+
+	policy = DEFAULT_POWER_POLICY;
+	if (policy == PM_POWERSAVE)
+		cpufreq_enable(sc);
+}
+
+static int
+cpufreq_init(struct driver *self)
+{
+
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/cpufreq/est.c b/prex-0.9.0/bsp/drv/dev/cpufreq/est.c
new file mode 100755
index 0000000..8f97f05
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/cpufreq/est.c
@@ -0,0 +1,595 @@
+/*	$OpenBSD: est.c,v 1.11 2005/03/07 06:59:14 mbalmer Exp $ */
+/*
+ * Copyright (c) 2003 Michael Eriksson.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * This is a driver for Intel's Enhanced SpeedStep, as implemented in
+ * Pentium M processors.
+ *
+ * Reference documentation:
+ *
+ * - IA-32 Intel Architecture Software Developer's Manual, Volume 3:
+ *   System Programming Guide.
+ *   Section 13.14, Enhanced Intel SpeedStep technology.
+ *   Table B-2, MSRs in Pentium M Processors.
+ *   http://www.intel.com/design/pentium4/manuals/245472.htm
+ *
+ * - Intel Pentium M Processor Datasheet.
+ *   Table 5, Voltage and Current Specifications.
+ *   http://www.intel.com/design/mobile/datashts/252612.htm
+ *
+ * - Intel Pentium M Processor on 90 nm Process with 2-MB L2 Cache Datasheet
+ *   Table 3-4, Voltage and Current Specifications.
+ *   http://www.intel.com/design/mobile/datashts/302189.htm
+ *
+ * - Linux cpufreq patches, speedstep-centrino.c.
+ *   Encoding of MSR_PERF_CTL and MSR_PERF_STATUS.
+ *   http://www.codemonkey.org.uk/projects/cpufreq/cpufreq-2.4.22-pre6-1.gz
+ */
+
+/*
+ * est.c - Intel enhanced speedstep driver from OpenBSD.
+ */
+
+#include <driver.h>
+#include <cpufreq.h>
+#include <cpufunc.h>
+#include <sys/ioctl.h>
+
+/* #define DEBUG_EST 1 */
+
+#ifdef DEBUG_EST
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+/* Status/control registers (from the IA-32 System Programming Guide). */
+#define MSR_PERF_STATUS		0x198
+#define MSR_PERF_CTL		0x199
+
+/* Register and bit for enabling SpeedStep. */
+#define MSR_MISC_ENABLE		0x1a0
+#define MSR_SS_ENABLE		(1<<16)
+
+static int	est_probe(struct driver *);
+static int	est_init(struct driver *);
+static int	est_setperf(int);
+static int	est_getperf(void);
+static void	est_getinfo(struct cpufreqinfo *);
+static int	est_identify(char *);
+
+static struct cpufreq_ops est_ops = {
+	/* setperf */	est_setperf,
+	/* getpref */	est_getperf,
+	/* getinfo */	est_getinfo,
+};
+
+struct driver est_driver = {
+	/* name */	"est",
+	/* devops */	NULL,
+	/* flags */	0,
+	/* flags */	0,
+	/* probe */	est_probe,
+	/* init */	est_init,
+	/* shutdown */	NULL,
+};
+
+/*
+ * Frequency tables
+ */
+struct fq_info {
+	int	mhz;
+	int	mv;
+};
+
+/* Ultra Low Voltage Intel Pentium M processor 900 MHz */
+static const struct fq_info pentium_m_900[] = {
+	{  900, 1004 },
+	{  800,  988 },
+	{  600,  844 },
+};
+
+/* Ultra Low Voltage Intel Pentium M processor 1.00 GHz */
+static const struct fq_info pentium_m_1000[] = {
+	{ 1000, 1004 },
+	{  900,  988 },
+	{  800,  972 },
+	{  600,  844 },
+};
+
+/* Low Voltage Intel Pentium M processor 1.10 GHz */
+static const struct fq_info pentium_m_1100[] = {
+	{ 1100, 1180 },
+	{ 1000, 1164 },
+	{  900, 1100 },
+	{  800, 1020 },
+	{  600,  956 },
+};
+
+/* Low Voltage Intel Pentium M processor 1.20 GHz */
+static const struct fq_info pentium_m_1200[] = {
+	{ 1200, 1180 },
+	{ 1100, 1164 },
+	{ 1000, 1100 },
+	{  900, 1020 },
+	{  800, 1004 },
+	{  600,  956 },
+};
+
+/* Intel Pentium M processor 1.30 GHz */
+static const struct fq_info pentium_m_1300[] = {
+	{ 1300, 1388 },
+	{ 1200, 1356 },
+	{ 1000, 1292 },
+	{  800, 1260 },
+	{  600,  956 },
+};
+
+/* Intel Pentium M processor 1.40 GHz */
+static const struct fq_info pentium_m_1400[] = {
+	{ 1400, 1484 },
+	{ 1200, 1436 },
+	{ 1000, 1308 },
+	{  800, 1180 },
+	{  600,  956 }
+};
+
+/* Intel Pentium M processor 1.50 GHz */
+static const struct fq_info pentium_m_1500[] = {
+	{ 1500, 1484 },
+	{ 1400, 1452 },
+	{ 1200, 1356 },
+	{ 1000, 1228 },
+	{  800, 1116 },
+	{  600,  956 }
+};
+
+/* Intel Pentium M processor 1.60 GHz */
+static const struct fq_info pentium_m_1600[] = {
+	{ 1600, 1484 },
+	{ 1400, 1420 },
+	{ 1200, 1276 },
+	{ 1000, 1164 },
+	{  800, 1036 },
+	{  600,  956 }
+};
+
+/* Intel Pentium M processor 1.70 GHz */
+static const struct fq_info pentium_m_1700[] = {
+	{ 1700, 1484 },
+	{ 1400, 1308 },
+	{ 1200, 1228 },
+	{ 1000, 1116 },
+	{  800, 1004 },
+	{  600,  956 }
+};
+
+
+/* Intel Pentium M processor 723 1.0 GHz */
+static const struct fq_info pentium_m_n723[] = {
+	{ 1000,  940 },
+	{  900,  908 },
+	{  800,  876 },
+	{  600,  812 }
+};
+
+/* Intel Pentium M processor 733 1.1 GHz */
+static const struct fq_info pentium_m_n733[] = {
+	{ 1100,  940 },
+	{ 1000,  924 },
+	{  900,  892 },
+	{  800,  876 },
+	{  600,  812 }
+};
+
+/* Intel Pentium M processor 753 1.2 GHz */
+static const struct fq_info pentium_m_n753[] = {
+	{ 1200,  940 },
+	{ 1100,  924 },
+	{ 1000,  908 },
+	{  900,  876 },
+	{  800,  860 },
+	{  600,  812 }
+};
+
+/* Intel Pentium M processor 738 1.4 GHz */
+static const struct fq_info pentium_m_n738[] = {
+	{ 1400, 1116 },
+	{ 1300, 1116 },
+	{ 1200, 1100 },
+	{ 1100, 1068 },
+	{ 1000, 1052 },
+	{  900, 1036 },
+	{  800, 1020 },
+	{  600,  988 }
+};
+
+#if 0
+/* Intel Pentium M processor 758 1.5 GHz */
+static const struct fq_info pentium_m_n758[] = {
+	{ 1500, 1116 },
+	{ 1400, 1116 },
+	{ 1300, 1100 },
+	{ 1200, 1084 },
+	{ 1100, 1068 },
+	{ 1000, 1052 },
+	{  900, 1036 },
+	{  800, 1020 },
+	{  600,  988 }
+};
+#endif
+
+/* Intel Pentium M processor 715 1.5 GHz */
+static const struct fq_info pentium_m_n715[] = {
+	{ 1500, 1340 },
+	{ 1200, 1228 },
+	{ 1000, 1148 },
+	{  800, 1068 },
+	{  600,  988 }
+};
+
+/* Intel Pentium M processor 725 1.6 GHz */
+static const struct fq_info pentium_m_n725[] = {
+	{ 1600, 1340 },
+	{ 1400, 1276 },
+	{ 1200, 1212 },
+	{ 1000, 1132 },
+	{  800, 1068 },
+	{  600,  988 }
+};
+
+/* Intel Pentium M processor 735 1.7 GHz */
+static const struct fq_info pentium_m_n735[] = {
+	{ 1700, 1340 },
+	{ 1400, 1244 },
+	{ 1200, 1180 },
+	{ 1000, 1116 },
+	{  800, 1052 },
+	{  600,  988 }
+};
+
+/* Intel Pentium M processor 745 1.8 GHz */
+static const struct fq_info pentium_m_n745[] = {
+	{ 1800, 1340 },
+	{ 1600, 1292 },
+	{ 1400, 1228 },
+	{ 1200, 1164 },
+	{ 1000, 1116 },
+	{  800, 1052 },
+	{  600,  988 }
+};
+
+/* Intel Pentium M processor 755 2.0 GHz */
+static const struct fq_info pentium_m_n755[] = {
+	{ 2000, 1340 },
+	{ 1800, 1292 },
+	{ 1600, 1244 },
+	{ 1400, 1196 },
+	{ 1200, 1148 },
+	{ 1000, 1100 },
+	{  800, 1052 },
+	{  600,  988 }
+};
+
+/* Intel Pentium M processor 765 2.1 GHz */
+static const struct fq_info pentium_m_n765[] = {
+	{ 2100, 1340 },
+	{ 1800, 1276 },
+	{ 1600, 1228 },
+	{ 1400, 1180 },
+	{ 1200, 1132 },
+	{ 1000, 1084 },
+	{  800, 1036 },
+	{  600,  988 }
+};
+
+struct fqlist {
+	const char *brand_tag;
+	const struct fq_info *table;
+	int n;
+};
+
+static const struct fqlist pentium_m[] = {
+#define ENTRY(s, v)	{ s, v, (int)(sizeof(v) / sizeof((v)[0])) }
+	ENTRY(" 900", pentium_m_900),
+	ENTRY("1000", pentium_m_1000),
+	ENTRY("1100", pentium_m_1100),
+	ENTRY("1200", pentium_m_1200),
+	ENTRY("1300", pentium_m_1300),
+	ENTRY("1400", pentium_m_1400),
+	ENTRY("1500", pentium_m_1500),
+	ENTRY("1600", pentium_m_1600),
+	ENTRY("1700", pentium_m_1700),
+#undef ENTRY
+};
+
+static const struct fqlist pentium_m_dothan[] = {
+#define ENTRY(s, v)	{ s, v, (int)(sizeof(v) / sizeof((v)[0])) }
+	ENTRY("1.00", pentium_m_n723),
+	ENTRY("1.10", pentium_m_n733),
+	ENTRY("1.20", pentium_m_n753),
+	ENTRY("1.40", pentium_m_n738),
+#if 0
+	ENTRY("1.50", pentium_m_n758),
+#endif
+	ENTRY("1.50", pentium_m_n715),
+	ENTRY("1.60", pentium_m_n725),
+	ENTRY("1.70", pentium_m_n735),
+	ENTRY("1.80", pentium_m_n745),
+	ENTRY("2.00", pentium_m_n755),
+	ENTRY("2.10", pentium_m_n765),
+#undef ENTRY
+};
+
+struct est_cpu {
+	const char *brand_prefix;
+	const char *brand_suffix;
+	const struct fqlist *list;
+	int n;
+};
+
+static const struct est_cpu est_cpus[] = {
+	{
+		"Intel(R) Pentium(R) M processor ", "MHz",
+		pentium_m,
+		(int)(sizeof(pentium_m) / sizeof(pentium_m[0]))
+	},
+	{
+		"Intel(R) Pentium(R) M processor ", "GHz",
+		pentium_m_dothan,
+		(int)(sizeof(pentium_m_dothan) / sizeof(pentium_m_dothan[0]))
+	},
+};
+
+#define NESTCPUS	  (int)(sizeof(est_cpus) / sizeof(est_cpus[0]))
+
+
+#define MSRVALUE(mhz, mv)	((((mhz) / 100) << 8) | (((mv) - 700) / 16))
+#define MSR2MHZ(msr)		(int)((((u_int) (msr) >> 8) & 0xff) * 100)
+#define MSR2MV(msr)		(((int) (msr) & 0xff) * 16 + 700)
+
+static const struct fqlist *est_fqlist;
+
+static int	maxfreq;	/* max speed in Mhz */
+static int	maxvolts;	/* max voltage in mV */
+static int	curfreq;	/* current speed in Mhz */
+static int	curvolts;	/* current voltage in mV */
+#ifdef CONFIG_DVS_EMULATION
+static int	bochs;		/* true if bochs is active */
+#endif
+
+/*
+ * Set CPU performance
+ *
+ * @level: percent of cpu speed
+ */
+static int
+est_setperf(int level)
+{
+	int i;
+	int fq, max_mhz;
+	u_int msr_lo, msr_hi;
+
+	max_mhz = est_fqlist->table[0].mhz;
+	fq = max_mhz * level / 100;
+
+	for (i = est_fqlist->n - 1; i > 0; i--)
+		if (est_fqlist->table[i].mhz >= fq)
+			break;
+
+	if (est_fqlist->table[i].mhz == curfreq)
+		return 0;
+
+	curfreq = est_fqlist->table[i].mhz;
+	curvolts = est_fqlist->table[i].mv;
+#ifdef DEBUG_EST
+	DPRINTF(("setperf: %dMHz %dmV\n", curfreq, curvolts));
+#endif
+#ifdef CONFIG_DVS_EMULATION
+	if (bochs)
+		return 0;
+#endif
+	rdmsr(MSR_PERF_CTL, &msr_lo, &msr_hi);
+	msr_lo = (msr_lo & ~0xffff) |
+		MSRVALUE(est_fqlist->table[i].mhz, est_fqlist->table[i].mv);
+	wrmsr(MSR_PERF_CTL, msr_lo, msr_hi);
+	return 0;
+}
+
+/*
+ * Get CPU performance
+ */
+static int
+est_getperf(void)
+{
+	int max_mhz;
+	int level;
+
+	max_mhz = est_fqlist->table[0].mhz;
+	ASSERT(max_mhz);
+	level = curfreq * 100 / max_mhz;
+	return level;
+}
+
+static void
+est_getinfo(struct cpufreqinfo *info)
+{
+
+	info->maxfreq = maxfreq;
+	info->maxvolts = maxvolts;
+	info->freq = curfreq;
+	info->volts = curvolts;
+}
+
+static int
+est_identify(char *brand_str)
+{
+	int i, j, mhz, mv;
+	size_t len;
+	const struct est_cpu *cpu;
+	u_int msr_lo, msr_hi;
+	char *tag;
+	const struct fqlist *fql;
+
+	DPRINTF(("CPU brand: %s\n", brand_str));
+
+#ifdef CONFIG_DVS_EMULATION
+	if (bochs) {
+		msr_lo = 0x1031;
+		cpu = &est_cpus[0];
+		est_fqlist = &cpu->list[7];
+	} else
+		rdmsr(MSR_PERF_STATUS, &msr_lo, &msr_hi);
+#else
+	rdmsr(MSR_PERF_STATUS, &msr_lo, &msr_hi);
+#endif
+	mhz = MSR2MHZ(msr_lo);
+	mv = MSR2MV(msr_lo);
+
+#ifdef CONFIG_DVS_EMULATION
+	if (!bochs) {
+#endif
+	/*
+	 * Look for a CPU matching brand_str.
+	 */
+	for (i = 0; est_fqlist == NULL && i < NESTCPUS; i++) {
+		cpu = &est_cpus[i];
+		len = strnlen(cpu->brand_prefix, 48);
+		if (strncmp(cpu->brand_prefix, brand_str, len) != 0)
+			continue;
+		tag = brand_str + len;
+		for (j = 0; j < cpu->n; j++) {
+			fql = &cpu->list[j];
+			len = strnlen(fql->brand_tag, 48);
+			if (!strncmp(fql->brand_tag, tag, len) &&
+			    !strncmp(cpu->brand_suffix, tag + len, 48)) {
+				est_fqlist = fql;
+				break;
+			}
+		}
+	}
+	if (est_fqlist == NULL) {
+		DPRINTF(("Unknown EST cpu, no changes possible\n"));
+		return ENXIO;
+	}
+
+	/*
+	 * Check that the current operating point is in our list.
+	 */
+	for (i = est_fqlist->n - 1; i >= 0; i--)
+		if (est_fqlist->table[i].mhz == mhz)
+			break;
+	if (i < 0) {
+		DPRINTF((" (not in table)\n"));
+		return ENXIO;
+	}
+#ifdef CONFIG_DVS_EMULATION
+	}
+#endif
+	/*
+	 * Store current state
+	 */
+	maxfreq = est_fqlist->table[0].mhz;
+	maxvolts = est_fqlist->table[0].mv;
+	curfreq = mhz;
+	curvolts = mv;
+	return 0;
+}
+
+static int
+est_probe(struct driver *self)
+{
+	u_int regs[4];
+	char brand_str[49];
+	char *p, *q;
+	u_int cpu_id;
+
+#ifdef CONFIG_DVS_EMULATION
+	bochs = 0;
+	if (bus_read_8(0xe9) == 0xe9) {
+		/*
+		 * Detect Bochs. Fake the cpuid value.
+		 */
+		bochs = 1;
+		cpu_id = 0x6d6;
+		strlcpy(brand_str,
+			"Intel(R) Pentium(R) M processor 1600MHz",
+			sizeof(brand_str));
+		DPRINTF(("CPU ID: %08x\n", cpu_id));
+		return est_identify(brand_str);
+	}
+#endif
+	/*
+	 * Check enhanced speed step capability
+	 */
+	cpuid(1, regs);
+	cpu_id = regs[0];
+	DPRINTF(("CPU ID: %08x\n", cpu_id));
+	if ((regs[2] & 0x80) == 0) {
+		DPRINTF(("cpu: clock control not supported\n"));
+		return ENXIO;
+	}
+
+	/*
+	 * Get CPU brand string
+	 */
+	cpuid(0x80000002, regs);
+	memcpy(brand_str, regs, sizeof(regs));
+	cpuid(0x80000003, regs);
+	memcpy(brand_str + 16, regs, sizeof(regs));
+	cpuid(0x80000004, regs);
+	memcpy(brand_str + 32, regs, sizeof(regs));
+
+	/* Store string with lef-align */
+	p = q = brand_str;
+	while (*p == ' ')
+		p++;
+	while (*p)
+		*q++ = *p++;
+	*q = '\0';
+
+	return est_identify(brand_str);
+}
+
+static int
+est_init(struct driver *self)
+{
+#ifdef DEBUG
+	int i;
+#endif
+
+	cpufreq_attach(&est_ops);
+
+#ifdef DEBUG
+	printf("Enhanced SpeedStep %d MHz (%d mV)\n", curfreq, curvolts);
+	printf("Speeds: ");
+	for (i = 0; i < est_fqlist->n; i++)
+		printf("%d%s", est_fqlist->table[i].mhz,
+		       i < est_fqlist->n - 1 ? ", " : " MHz\n");
+#endif
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/dma/Makefile.inc b/prex-0.9.0/bsp/drv/dev/dma/Makefile.inc
new file mode 100755
index 0000000..c3eed5e
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/dma/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_I8237)+=		dev/dma/i8237.c
diff --git a/prex-0.9.0/bsp/drv/dev/dma/i8237.c b/prex-0.9.0/bsp/drv/dev/dma/i8237.c
new file mode 100755
index 0000000..c57257f
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/dma/i8237.c
@@ -0,0 +1,285 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * i8237.c - Intel 8237 DMA controller
+ */
+
+/**
+ *  Memo:
+ *
+ *  [Mode Register]
+ *
+ *      Bits     Function
+ *      -------- Mode Selection
+ *      00          Demand Mode
+ *      01          Single Mode
+ *      10          Block Mode
+ *      11          Cascade Mode
+ *      -------- Address Increment/Decrement
+ *        1         Address Decrement
+ *        0         Address Increment
+ *      -------- Auto-Initialization Enable
+ *         1        Auto-Initialization DMA
+ *         0        Single-Cycle DMA
+ *      -------- Transfer Type
+ *          00      Verify
+ *          01      Write
+ *          10      Read
+ *          11      Illegal
+ *      -------- Channel Selection
+ *            00    Channel 0 (4)
+ *            01    Channel 1 (5)
+ *            10    Channel 2 (6)
+ *            11    Channel 3 (7)
+ *
+ *  [Single Mask Register]
+ *
+ *      Bits     Function
+ *      --------
+ *      00000    Unused, Set to 0
+ *      -------- Set/Clear Mask
+ *           1      Set (Disable Channel)
+ *           0      Clear (Enable Channel)
+ *      -------- Channel Selection
+ *            00    Channel 0 (4)
+ *            01    Channel 1 (5)
+ *            10    Channel 2 (6)
+ *            11    Channel 3 (7)
+ *
+ *
+ */
+
+#include <sys/cdefs.h>
+#include <driver.h>
+#include <cpufunc.h>
+
+#ifdef DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define NR_DMAS		8
+
+#define DMA_MAX		(1024 * 64)
+#define DMA_MASK	(DMA_MAX-1)
+#define DMA_ALIGN(n)	((((paddr_t)(n)) + DMA_MASK) & ~DMA_MASK)
+
+void		dma_stop(dma_t handle);
+static int	dma_init(struct driver *self);
+
+
+/*
+ * DMA descriptor
+ */
+struct dma {
+	int	chan;		/* dma channel */
+	int	in_use;		/* true if used */
+};
+
+/*
+ * DMA i/o port
+ */
+struct dma_port {
+	int	mask;
+	int	mode;
+	int	clear;
+	int	addr;
+	int	count;
+	int	page;
+};
+
+static const struct dma_port dma_regs[] = {
+/*	mask,  mode,  clear, addr,  count, page */
+	{0x0a, 0x0b, 0x0c, 0x00, 0x01, 0x87},	/* Channel 0 */
+	{0x0a, 0x0b, 0x0c, 0x02, 0x03, 0x83},	/* Channel 1 */
+	{0x0a, 0x0b, 0x0c, 0x04, 0x05, 0x81},	/* Channel 2 */
+	{0x0a, 0x0b, 0x0c, 0x06, 0x07, 0x82},	/* Channel 3 */
+	{0xd4, 0xd6, 0xd8, 0xc0, 0xc2, 0x8f},	/* Channel 4 (n/a) */
+	{0xd4, 0xd6, 0xd8, 0xc4, 0xc6, 0x8b},	/* Channel 5 */
+	{0xd4, 0xd6, 0xd8, 0xc8, 0xca, 0x89},	/* Channel 6 */
+	{0xd4, 0xd6, 0xd8, 0xcc, 0xce, 0x8a},	/* Channel 7 */
+};
+
+static struct dma dma_table[NR_DMAS];
+
+struct driver i8237_driver = {
+	/* name */	"dma",
+	/* devsops */	NULL,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	dma_init,
+	/* shutdown */	NULL,
+};
+
+
+/*
+ * Attach dma.
+ * Return dma handle on success, or panic on failure.
+ * DMA4 can not be used with pc.
+ */
+dma_t
+dma_attach(int chan)
+{
+	struct dma *dma;
+	int s;
+
+	ASSERT(chan >= 0 && chan < NR_DMAS);
+	ASSERT(chan != 4);
+	DPRINTF(("DMA%d attached\n", chan));
+
+	s = splhigh();
+	dma = &dma_table[chan];
+	if (dma->in_use) {
+		panic("dma_attach");
+	} else {
+		dma->chan = chan;
+		dma->in_use = 1;
+	}
+	dma_stop((dma_t)dma);
+	splx(s);
+	return (dma_t)dma;
+}
+
+/*
+ * Detach dma.
+ */
+void
+dma_detach(dma_t handle)
+{
+	struct dma *dma = (struct dma *)handle;
+	int s;
+
+	ASSERT(dma->in_use);
+	DPRINTF(("DMA%d detached\n", dma->chan));
+
+	s = splhigh();
+	dma->in_use = 0;
+	splx(s);
+}
+
+void
+dma_setup(dma_t handle, void *addr, u_long count, int read)
+{
+	struct dma *dma = (struct dma *)handle;
+	const struct dma_port *regs;
+	u_int chan, bits, mode;
+	paddr_t paddr;
+	int s;
+
+	ASSERT(handle);
+	paddr = kvtop(addr);
+
+	/* dma address must be under 16M. */
+	ASSERT(paddr < 0xffffff);
+
+	s = splhigh();
+
+	chan = (u_int)dma->chan;
+	regs = &dma_regs[chan];
+	bits = (chan < 4) ? chan : chan >> 2;
+	mode = read ? 0x44U : 0x48U;
+	count--;
+
+	bus_write_8(regs->mask, bits | 0x04);	/* Disable channel */
+	bus_write_8(regs->clear, 0x00);		/* Clear byte pointer flip-flop */
+	bus_write_8(regs->mode, bits | mode);	/* Set mode */
+	bus_write_8(regs->addr, (u_char)((paddr >> 0) & 0xff));	/* Address low */
+	bus_write_8(regs->addr, (u_char)((paddr >> 8) & 0xff));	/* Address high */
+	bus_write_8(regs->page, (u_char)((paddr >> 16) & 0xff));	/* Page address */
+	bus_write_8(regs->clear, 0x00);		/* Clear byte pointer flip-flop */
+	bus_write_8(regs->count, (u_char)((count >> 0) & 0xff));	/* Count low */
+	bus_write_8(regs->count, (u_char)((count >> 8) & 0xff));	/* Count high */
+	bus_write_8(regs->mask, bits);		/* Enable channel */
+
+	splx(s);
+}
+
+void
+dma_stop(dma_t handle)
+{
+	struct dma *dma = (struct dma *)handle;
+	u_int chan;
+	u_int bits;
+	int s;
+
+	ASSERT(handle);
+	s = splhigh();
+	chan = (u_int)dma->chan;
+
+	bits = (chan < 4) ? chan : chan >> 2;
+	bus_write_8(dma_regs[chan].mask, bits | 0x04);	/* Disable channel */
+	splx(s);
+}
+
+/*
+ * Allocate DMA buffer
+ *
+ * Return page address in 64K byte boundary.
+ * The caller must deallocate the pages by using page_free().
+ */
+void *
+dma_alloc(size_t size)
+{
+	paddr_t tmp, base;
+
+	if (size > DMA_MAX)
+		return NULL;
+
+	sched_lock();
+
+	/*
+	 * Try to allocate temporary buffer for enough size (64K + size).
+	 */
+	size = round_page(size);
+	tmp = page_alloc((size_t)(DMA_MAX + size));
+	if (tmp == 0) {
+		sched_unlock();
+		return NULL;
+	}
+	page_free(tmp, (size_t)(DMA_MAX + size));
+
+	/*
+	 * Now, we know the free address with 64k boundary.
+	 */
+	base = DMA_ALIGN(tmp);
+	page_reserve(base, size);
+
+	sched_unlock();
+	return ptokv(base);
+}
+
+static int
+dma_init(struct driver *self)
+{
+
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/input/Makefile.inc b/prex-0.9.0/bsp/drv/dev/input/Makefile.inc
new file mode 100755
index 0000000..ebe4bdd
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/input/Makefile.inc
@@ -0,0 +1,3 @@
+
+SRCS-$(CONFIG_PCKBD)+=		dev/input/pckbd.c
+SRCS-$(CONFIG_PSAUX)+=		dev/input/psaux.c
diff --git a/prex-0.9.0/bsp/drv/dev/input/i8042.h b/prex-0.9.0/bsp/drv/dev/input/i8042.h
new file mode 100755
index 0000000..f22c33e
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/input/i8042.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _KMC_H
+#define _KMC_H
+/*
+ * i8042 Keyboard Mouse Controller definition
+ */
+
+/* I/O ports */
+#define KMC_DATA	0x60
+#define KMC_PORTB	0x61
+#define KMC_CMD		0x64
+#define KMC_STS		0x64
+
+/* Status */
+#define STS_PERR	0x80	/* Parity error */
+#define STS_TMO		0x40	/* Timeout */
+#define STS_AUXOBF	0x20	/* Mouse OBF */
+#define STS_INH		0x10	/* 0: inhibit  1: no-inhibit */
+#define STS_SYS		0x04	/* 0: power up  1:Init comp */
+#define STS_IBF		0x02	/* Input (to kbd) buffer full */
+#define STS_OBF		0x01	/* Output (from kbd) buffer full */
+
+/* Command */
+#define CMD_READ_CMD	0x20
+#define CMD_WRITE_CMD	0x60
+#define CMD_AUX_DIS	0xa7
+#define CMD_AUX_EN	0xa8
+#define CMD_KBD_DIS	0xad
+#define CMD_KBD_EN	0xae
+#define CMD_READ_OPORT	0xd0
+#define CMD_WRITE_OPORT	0xd1
+#define CMD_WRITE_AUX	0xd4
+
+/* Auxillary device command */
+#define AUX_ENABLE	0xf4
+#define AUX_DISABLE	0xf5
+#define AUX_RESET	0xff
+
+/*
+ * wait_obf: Wait output buffer full
+ * wait_obe: Wait input buffer empty
+ * wait_ibf: Wait input buffer full
+ * wait_ibe: Wait input buffer empty
+ */
+#define kmc_wait_obf()	while ((bus_read_8(KMC_STS) & STS_OBF) == 0)
+#define kmc_wait_obe()	while (bus_read_8(KMC_STS) & STS_OBF)
+#define kmc_wait_ibf()	while ((bus_read_8(KMC_STS) & STS_IBF) == 0)
+#define kmc_wait_ibe()	while (bus_read_8(KMC_STS) & STS_IBF)
+
+#endif /* !_KMC_H */
diff --git a/prex-0.9.0/bsp/drv/dev/input/pckbd.c b/prex-0.9.0/bsp/drv/dev/input/pckbd.c
new file mode 100755
index 0000000..68e09ae
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/input/pckbd.c
@@ -0,0 +1,294 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pckbd.c - PC/AT keyboard driver
+ */
+
+#include <driver.h>
+#include <sys/keycode.h>
+#include <wscons.h>
+#include <pm.h>
+
+#include "i8042.h"
+
+/* Parameters */
+#define KBD_IRQ		1
+
+struct pckbd_softc {
+	device_t	dev;		/* device object */
+	irq_t		irq;		/* irq handle */
+	int		polling;	/* true if polling mode */
+	u_char		led_sts;	/* keyboard LED status */
+	int		shift;		/* shift key state */
+	int		alt;		/* alt key state */
+	int		ctrl;		/* control key state */
+	int		capslk;		/* caps lock key staet */
+};
+
+static int	pckbd_init(struct driver *);
+static int	pckbd_getc(void *);
+static void	pckbd_set_poll(void *, int);
+
+struct driver pckbd_driver = {
+	/* name */	"pckbd",
+	/* devops */	NULL,
+	/* devsz */	sizeof(struct pckbd_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	pckbd_init,
+	/* shutdown */	NULL,
+};
+
+static struct wscons_kbd_ops wscons_pckbd_ops = {
+	/* getc */	pckbd_getc,
+	/* set_poll */	pckbd_set_poll,
+};
+
+/*
+ * Key map
+ */
+static const u_char key_map[] = {
+	0,      0x1b,   '1',    '2',    '3',    '4',    '5',    '6',
+	'7',    '8',    '9',    '0',    '-',    '=',    '\b',   '\t',
+	'q',    'w',    'e',    'r',    't',    'y',    'u',    'i',
+	'o',    'p',    '[',    ']',    '\n',   K_CTRL, 'a',    's',
+	'd',    'f',    'g',    'h',    'j',    'k',    'l',    ';',
+	'\'',   '`',    K_SHFT, '\\',   'z',    'x',    'c',    'v',
+	'b',    'n',    'm',    ',',    '.',    '/',    K_SHFT, '*',
+	K_ALT,  ' ',    K_CAPS, K_F1,   K_F2,   K_F3,   K_F4,   K_F5,
+	K_F6,   K_F7,   K_F8,   K_F9,   K_F10,  0,      0,      K_HOME,
+	K_UP,   K_PGUP, 0,      K_LEFT, 0,      K_RGHT, 0,      K_END,
+	K_DOWN, K_PGDN, K_INS,  0x7f,   K_F11,  K_F12
+};
+
+#define KEY_MAX (sizeof(key_map) / sizeof(char))
+
+static const u_char shift_map[] = {
+	0,      0x1b,   '!',    '@',    '#',    '$',    '%',    '^',
+	'&',    '*',    '(',    ')',    '_',    '+',    '\b',   '\t',
+	'Q',    'W',    'E',    'R',    'T',    'Y',    'U',    'I',
+	'O',    'P',    '{',    '}',    '\n',   K_CTRL, 'A',    'S',
+	'D',    'F',    'G',    'H',    'J',    'K',    'L',    ':',
+	'"',    '~',    0,      '|',    'Z',    'X',    'C',    'V',
+	'B',    'N',    'M',    '<',    '>',    '?',    0,      '*',
+	K_ALT,  ' ',    0,      0,      0,      0,      0,      0,
+	0,      0,      0,      0,      0,      0,      0,      K_HOME,
+	K_UP,   K_PGUP, 0,      K_LEFT, 0,      K_RGHT, 0,      K_END,
+	K_DOWN, K_PGDN, K_INS,  0x7f,   0,      0
+};
+
+/*
+ * Send command to keyboard controller
+ */
+static void
+kmc_send_cmd(u_char cmd)
+{
+
+	kmc_wait_ibe();
+	bus_write_8(KMC_CMD, cmd);
+}
+
+/*
+ * Update LEDs for current modifier state.
+ */
+static void
+pckbd_set_leds(struct pckbd_softc *sc)
+{
+	u_char val = 0;
+
+	/* Update LEDs */
+	if (sc->capslk)
+		val |= 0x04;
+	if (sc->led_sts != val) {
+		sc->led_sts = val;
+		bus_write_8(KMC_DATA, 0xed);
+		while (bus_read_8(KMC_STS) & 2);
+		bus_write_8(KMC_DATA, val);
+		while (bus_read_8(KMC_STS) & 2);
+	}
+}
+
+/*
+ * Scan key input. Returns ascii code.
+ */
+static int
+pckbd_scan_key(struct pckbd_softc *sc)
+{
+	u_char scan, ascii, val;
+	int press;
+
+ again:
+	/* Get scan code */
+	kmc_wait_obf();
+	scan = bus_read_8(KMC_DATA);
+
+	/* Send ack to the controller */
+	val = bus_read_8(KMC_PORTB);
+	bus_write_8(KMC_PORTB, val | 0x80);
+	bus_write_8(KMC_PORTB, val);
+
+	/* Convert scan code to ascii */
+	press = scan & 0x80 ? 0 : 1;
+	scan = scan & 0x7f;
+	if (scan >= KEY_MAX)
+		goto again;
+	ascii = key_map[scan];
+
+	/* Check meta key */
+	switch (ascii) {
+	case K_SHFT:
+		sc->shift = press;
+		return 0;
+	case K_CTRL:
+		sc->ctrl = press;
+		return 0;
+	case K_ALT:
+		sc->alt = press;
+		return 0;
+	case K_CAPS:
+		sc->capslk = !sc->capslk;
+		pckbd_set_leds(sc);
+		return 0;
+	}
+
+	/* Ignore key release */
+	if (!press)
+		return 0;
+
+	if (ascii >= 0x80)
+		return ascii;
+
+	/* Check Alt+Ctrl+Del */
+	if (sc->alt && sc->ctrl && ascii == 0x7f) {
+#ifdef CONFIG_PM
+		pm_set_power(PWR_REBOOT);
+#else
+		machine_powerdown(PWR_REBOOT);
+#endif
+	}
+
+	/* Check ctrl & shift state */
+	if (sc->ctrl) {
+		if (ascii >= 'a' && ascii <= 'z')
+			ascii = ascii - 'a' + 0x01;
+		else if (ascii == '\\')
+			ascii = 0x1c;
+		else
+			ascii = 0;
+	} else if (sc->shift)
+		ascii = shift_map[scan];
+
+	if (ascii == 0)
+		return 0;
+
+	/* Check caps lock state */
+	if (sc->capslk) {
+		if (ascii >= 'A' && ascii <= 'Z')
+			ascii += 'a' - 'A';
+		else if (ascii >= 'a' && ascii <= 'z')
+			ascii -= 'a' - 'A';
+	}
+
+	/* Check alt key */
+	if (sc->alt)
+		ascii |= 0x80;
+
+	/* Insert key to queue */
+	return ascii;
+}
+
+/*
+ * Interrupt service routine
+ */
+static int
+pckbd_isr(void *arg)
+{
+	struct pckbd_softc *sc = arg;
+	int c;
+
+	c = pckbd_scan_key(sc);
+	if (c != 0)
+		wscons_kbd_input(c);
+	return 0;
+}
+
+static int
+pckbd_getc(void *aux)
+{
+	struct pckbd_softc *sc = aux;
+	int c;
+	int s;
+
+	sc->alt = 0;
+	sc->ctrl = 0;
+	sc->shift = 0;
+
+	s = splhigh();
+	while ((c = pckbd_scan_key(sc)) == 0) ;
+	splx(s);
+	return c;
+}
+
+static void
+pckbd_set_poll(void *aux, int on)
+{
+	struct pckbd_softc *sc = aux;
+
+	sc->polling = on;
+}
+
+static int
+pckbd_init(struct driver *self)
+{
+	struct pckbd_softc *sc;
+	device_t dev;
+
+	dev = device_create(self, "kbd", D_CHR);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->polling = 0;
+	sc->led_sts = 0;
+
+	/* Disable keyboard controller */
+	kmc_send_cmd(CMD_KBD_DIS);
+
+	sc->irq = irq_attach(KBD_IRQ, IPL_INPUT, 0, pckbd_isr, IST_NONE, sc);
+
+	/* Discard garbage data */
+	while (bus_read_8(KMC_STS) & STS_OBF)
+		bus_read_8(KMC_DATA);
+
+	/* Enable keyboard controller */
+	kmc_send_cmd(CMD_KBD_EN);
+
+	wscons_attach_kbd(&wscons_pckbd_ops, sc);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/input/psaux.c b/prex-0.9.0/bsp/drv/dev/input/psaux.c
new file mode 100755
index 0000000..5ee79c0
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/input/psaux.c
@@ -0,0 +1,232 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * psaux.c - ps2 mouse support
+ */
+
+/*
+ * PS/2 mouse packet
+ *
+ *         Bit7   Bit6   Bit5   Bit4   Bit3  Bit2   Bit1   Bit0
+ *  ------ ------ ------ ------ ------ ----- ------ ------ ------
+ *  Byte 1 Yovf   Xovf   Ysign  Xsign    1   MidBtn RgtBtn LftBtn
+ *  Byte 2 X movement
+ *  Byte 3 Y movement
+ */
+
+#include <driver.h>
+
+#include "i8042.h"
+
+/* #define DEBUG_MOUSE 1 */
+
+#ifdef DEBUG_MOUSE
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define MOUSE_IRQ	12
+
+struct psaux_softc {
+	device_t	dev;		/* device object */
+	irq_t		irq;		/* handle for mouse irq */
+	u_char		packet[3];	/* mouse packet */
+	int		index;
+};
+
+static int psaux_init(struct driver *);
+static int psaux_open(device_t, int);
+static int psaux_close(device_t);
+static int psaux_read(device_t, char *, size_t *, int);
+
+static struct devops psaux_devops = {
+	/* open */	psaux_open,
+	/* close */	psaux_close,
+	/* read */	psaux_read,
+	/* write */	no_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver psaux_driver = {
+	/* name */	"psaux",
+	/* devops */	&psaux_devops,
+	/* devsz */	sizeof(struct psaux_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	psaux_init,
+	/* shutdown */	NULL,
+};
+
+/*
+ * Write aux device command
+ */
+static void
+kmc_send_auxcmd(u_char val)
+{
+
+	DPRINTF(("kmc_send_auxcmd: %x\n", val));
+	kmc_wait_ibe();
+	bus_write_8(KMC_CMD, 0x60);
+	kmc_wait_ibe();
+	bus_write_8(KMC_DATA, val);
+}
+
+/*
+ * Returns 0 on success, -1 on failure.
+ */
+static int
+kmc_write_aux(u_char val)
+{
+	int rc = -1;
+	int s;
+
+	DPRINTF(("kmc_write_aux: val=%x\n", val));
+	s = splhigh();
+
+	/* Write the value to the device */
+	kmc_wait_ibe();
+	bus_write_8(KMC_CMD, 0xd4);
+	kmc_wait_ibe();
+	bus_write_8(KMC_DATA, val);
+
+	/* Get the ack */
+	kmc_wait_obf();
+	if ((bus_read_8(KMC_STS) & 0x20) == 0x20) {
+		if (bus_read_8(KMC_DATA) == 0xfa)
+			rc = 0;
+	}
+	splx(s);
+#ifdef DEBUG_MOUSE
+	if (rc)
+		printf("kmc_write_aux: error val=%x\n", val);
+#endif
+	return rc;
+}
+
+/*
+ * Interrupt handler
+ */
+static int
+psaux_isr(void *arg)
+{
+	struct psaux_softc *sc = arg;
+	u_char dat, id;
+
+	if ((bus_read_8(KMC_STS) & 0x21) != 0x21)
+		return 0;
+
+	dat = bus_read_8(KMC_DATA);
+	if (dat == 0xaa) {	/* BAT comp (reconnect) ? */
+		DPRINTF(("BAT comp"));
+		sc->index = 0;
+		kmc_wait_obf();
+		if ((bus_read_8(KMC_STS) & 0x20) == 0x20) {
+			id = bus_read_8(KMC_DATA);
+			DPRINTF(("Mouse ID=%x\n", id));
+		}
+		kmc_write_aux(0xf4);	/* Enable aux device */
+		return 0;
+	}
+
+	sc->packet[sc->index++] = dat;
+	if (sc->index < 3)
+		return 0;
+	sc->index = 0;
+	DPRINTF(("mouse packet %x:%d:%d\n", sc->packet[0],
+		 sc->packet[1], sc->packet[2]));
+	return 0;
+}
+
+/*
+ * Open
+ */
+static int
+psaux_open(device_t dev, int mode)
+{
+
+	DPRINTF(("psaux_open: dev=%x\n", dev));
+	return 0;
+}
+
+/*
+ * Close
+ */
+static int
+psaux_close(device_t dev)
+{
+	DPRINTF(("psaux_close: dev=%x\n", dev));
+	return 0;
+}
+
+/*
+ * Read
+ */
+static int
+psaux_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	return 0;
+}
+
+static int
+psaux_init(struct driver *self)
+{
+	struct psaux_softc *sc;
+	device_t dev;
+
+#ifdef DEBUG
+	printf("Mouse sampling rate=100 samples/sec\n");
+#endif
+	dev = device_create(self, "mouse", D_CHR);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->index = 0;
+
+	/* Allocate IRQ */
+	sc->irq = irq_attach(MOUSE_IRQ, IPL_INPUT, 0, psaux_isr,
+			     IST_NONE, sc);
+
+	kmc_wait_ibe();
+	bus_write_8(KMC_CMD, 0xa8);	/* Enable aux */
+
+	kmc_write_aux(0xf3);	/* Set sample rate */
+	kmc_write_aux(100);	/* 100 samples/sec */
+
+	kmc_write_aux(0xe8);	/* Set resolution */
+	kmc_write_aux(3);	/* 8 counts per mm */
+	kmc_write_aux(0xe7);	/* 2:1 scaling */
+
+	kmc_write_aux(0xf4);	/* Enable aux device */
+	kmc_send_auxcmd(0x47);	/* Enable controller ints */
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/misc/Makefile.inc b/prex-0.9.0/bsp/drv/dev/misc/Makefile.inc
new file mode 100755
index 0000000..9b19193
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/misc/Makefile.inc
@@ -0,0 +1,4 @@
+
+SRCS-$(CONFIG_NULL)+=	dev/misc/null.c
+SRCS-$(CONFIG_ZERO)+=	dev/misc/zero.c
+SRCS-$(CONFIG_RANDOM)+=	dev/misc/random.c
diff --git a/prex-0.9.0/bsp/drv/dev/misc/null.c b/prex-0.9.0/bsp/drv/dev/misc/null.c
new file mode 100755
index 0000000..23eb05b
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/misc/null.c
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * null.c - null device
+ */
+
+#include <driver.h>
+
+static int null_read(device_t, char *, size_t *, int);
+static int null_write(device_t, char *, size_t *, int);
+static int null_init(struct driver *);
+
+static struct devops null_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	null_read,
+	/* write */	null_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver null_driver = {
+	/* name */	"null",
+	/* devops */	&null_devops,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	null_init,
+	/* shutdown */	NULL,
+};
+
+/*
+ * Always returns 0 bytes as the read size.
+ */
+static int
+null_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	*nbyte = 0;
+	return 0;
+}
+
+/*
+ * Data written to this device is discarded.
+ */
+static int
+null_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	return 0;
+}
+
+static int
+null_init(struct driver *self)
+{
+
+	device_create(self, "null", D_CHR);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/misc/random.c b/prex-0.9.0/bsp/drv/dev/misc/random.c
new file mode 100755
index 0000000..91dc5ce
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/misc/random.c
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * null.c - /dev/random device
+ */
+
+#include <driver.h>
+
+static int random_read(device_t, char *, size_t *, int);
+static int random_init(struct driver *);
+
+static struct devops random_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	random_read,
+	/* write */	no_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver random_driver = {
+	/* name */	"null",
+	/* devops */	&random_devops,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	random_init,
+	/* shutdown */	NULL,
+};
+
+static int
+random_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	/* TODO */
+
+	*nbyte = 0;
+	return 0;
+}
+
+static int
+random_init(struct driver *self)
+{
+
+	device_create(self, "random", D_CHR);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/misc/zero.c b/prex-0.9.0/bsp/drv/dev/misc/zero.c
new file mode 100755
index 0000000..3dea4d7
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/misc/zero.c
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * zero.c - zero device
+ */
+
+#include <driver.h>
+
+static int zero_read(device_t, char *, size_t *, int);
+static int zero_write(device_t, char *, size_t *, int);
+static int zero_init(struct driver *);
+
+static struct devops zero_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	zero_read,
+	/* write */	zero_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver zero_driver = {
+	/* name */	"zero",
+	/* devops */	&zero_devops,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	zero_init,
+	/* shutdown */	NULL,
+};
+
+/*
+ * Reading from this device will just fill the buffer with zero.
+ */
+static int
+zero_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	void *p;
+
+	/* Translate buffer address to kernel address. */
+	if ((p = kmem_map(buf, *nbyte)) == NULL)
+		return EFAULT;
+
+	memset(p, 0, *nbyte);
+	return 0;
+}
+
+/*
+ * Writing data to this device is ignored.
+ */
+static int
+zero_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+
+	return 0;
+}
+
+static int
+zero_init(struct driver *self)
+{
+
+	device_create(self, "zero", D_CHR);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/rtc/Makefile.inc b/prex-0.9.0/bsp/drv/dev/rtc/Makefile.inc
new file mode 100755
index 0000000..3ce7187
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/rtc/Makefile.inc
@@ -0,0 +1,4 @@
+
+SRCS-$(CONFIG_RTC)+=		dev/rtc/rtc.c
+SRCS-$(CONFIG_MC146818)+=	dev/rtc/mc146818.c
+SRCS-$(CONFIG_PL030)+=		dev/rtc/pl030.c
diff --git a/prex-0.9.0/bsp/drv/dev/rtc/mc146818.c b/prex-0.9.0/bsp/drv/dev/rtc/mc146818.c
new file mode 100755
index 0000000..6019cb0
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/rtc/mc146818.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mc146818.c - mc146818 and compatible RTC
+ */
+
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include <driver.h>
+#include <rtc.h>
+
+
+#define RTC_INDEX	(CONFIG_MC146818_BASE + 0)
+#define RTC_DATA	(CONFIG_MC146818_BASE + 1)
+
+#define RTC_SEC		0x00
+#define RTC_MIN		0x02
+#define RTC_HOUR	0x04
+#define RTC_DOW		0x06	/* day of week */
+#define RTC_DAY		0x07
+#define RTC_MON		0x08
+#define RTC_YEAR	0x09
+#define RTC_STS_A	0x0a
+#define RTC_UIP		  0x80
+#define RTC_STS_B	0x0b
+#define RTC_BCD		  0x04
+
+static int	mc146818_init(struct driver *);
+static int	mc146818_gettime(void *, struct timeval *);
+static int	mc146818_settime(void *, struct timeval *);
+
+
+struct driver mc146818_driver = {
+	/* name */	"mc146818",
+	/* devops */	NULL,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	mc146818_init,
+	/* shutdown */	NULL,
+};
+
+struct rtc_ops mc146818_ops = {
+	/* gettime */	mc146818_gettime,
+	/* settime */	mc146818_settime,
+};
+
+static u_char
+mc_read(u_char index)
+{
+	u_char val;
+	int s;
+
+	s = splhigh();
+	bus_write_8(RTC_INDEX, index);
+	val = bus_read_8(RTC_DATA);
+	splx(s);
+	return val;
+}
+
+#if 0
+static void
+mc_write(u_char index, u_char val)
+{
+	int s;
+
+	s = splhigh();
+	bus_write_8(RTC_INDEX, index);
+	bus_write_8(RTC_DATA, val);
+	splx(s);
+}
+#endif
+
+static int
+mc146818_gettime(void *aux, struct timeval *tv)
+{
+	struct clock_ymdhms cy;
+	int i;
+
+	/* Wait until data ready */
+	for (i = 0; i < 1000000; i++)
+		if (!(mc_read(RTC_STS_A) & RTC_UIP))
+			break;
+
+	cy.nsec = 0;
+	cy.sec = mc_read(RTC_SEC);
+	cy.min = mc_read(RTC_MIN);
+	cy.hour = mc_read(RTC_HOUR);
+	cy.dow = mc_read(RTC_DOW);
+	cy.day = mc_read(RTC_DAY);
+	cy.mon = mc_read(RTC_MON);
+	cy.year = mc_read(RTC_YEAR);
+
+	if (!(mc_read(RTC_STS_B) & RTC_BCD)) {
+		cy.sec = FROMBCD(cy.sec);
+		cy.min = FROMBCD(cy.min);
+		cy.hour = FROMBCD(cy.hour);
+		cy.day = FROMBCD(cy.day);
+		cy.mon = FROMBCD(cy.mon);
+		cy.year = FROMBCD(cy.year);
+	}
+	if (cy.year < 80)
+		cy.year += 2000;
+	else
+		cy.year += 1900;
+#ifdef DEBUG
+	printf("rtc: system time was %d/%d/%d %d:%d:%d\n",
+		cy.year, cy.mon, cy.day, cy.hour, cy.min, cy.sec);
+#endif
+	tv->tv_usec = 0;
+	tv->tv_sec = rtc_ymdhms_to_secs(&cy);
+	return 0;
+}
+
+static int
+mc146818_settime(void *aux, struct timeval *ts)
+{
+	return 0;
+}
+
+static int
+mc146818_init(struct driver *self)
+{
+
+	rtc_attach(&mc146818_ops, NULL);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/rtc/pl030.c b/prex-0.9.0/bsp/drv/dev/rtc/pl030.c
new file mode 100755
index 0000000..8a867b1
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/rtc/pl030.c
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pl030.c - ARM PrimeCell PL030 RTC
+ */
+
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include <driver.h>
+#include <rtc.h>
+
+#define RTC_BASE	CONFIG_PL030_BASE
+
+#define RTC_DR		(RTC_BASE + 0x00)
+#define RTC_MR		(RTC_BASE + 0x04)
+#define RTC_STAT	(RTC_BASE + 0x08)
+#define RTC_EOI		(RTC_BASE + 0x08)
+#define RTC_LR		(RTC_BASE + 0x0c)
+#define RTC_CR		(RTC_BASE + 0x10)
+
+static int	pl030_init(struct driver *);
+static int	pl030_gettime(void *, struct timeval *);
+static int	pl030_settime(void *, struct timeval *);
+
+
+struct driver pl030_driver = {
+	/* name */	"pl030",
+	/* devops */	NULL,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	pl030_init,
+	/* shutdown */	NULL,
+};
+
+struct rtc_ops pl030_ops = {
+	/* gettime */	pl030_gettime,
+	/* settime */	pl030_settime,
+};
+
+static int
+pl030_gettime(void *aux, struct timeval *tv)
+{
+
+	tv->tv_usec = 0;
+	tv->tv_sec = bus_read_32(RTC_DR);
+	printf("******* sec=%d\n", tv->tv_sec);
+	return 0;
+}
+
+static int
+pl030_settime(void *aux, struct timeval *ts)
+{
+	return 0;
+}
+
+static int
+pl030_init(struct driver *self)
+{
+
+	rtc_attach(&pl030_ops, NULL);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/rtc/rtc.c b/prex-0.9.0/bsp/drv/dev/rtc/rtc.c
new file mode 100755
index 0000000..cffbb01
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/rtc/rtc.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: Utah $Hdr: clock.c 1.18 91/01/21$
+ *
+ *	@(#)clock.c	8.2 (Berkeley) 1/12/94
+ */
+
+/* Modified for Prex by Kohsuke Ohtani */
+
+/*
+ * rtc.c - machine independent RTC driver
+ */
+
+#include <sys/time.h>
+#include <sys/ioctl.h>
+
+#include <driver.h>
+#include <rtc.h>
+
+#define FEBRUARY	2
+#define	days_in_year(a) 	(leapyear(a) ? 366 : 365)
+#define	days_in_month(a) 	(month_days[(a) - 1])
+
+struct rtc_softc {
+	device_t	dev;		/* device object */
+	struct rtc_ops	*ops;		/* rtc operations */
+	void		*aux;		/* cookie data */
+	time_t		boot_sec;	/* Time (sec) at system boot */
+	u_long		boot_ticks;	/* Time (ticks) at system boot */
+};
+
+static int rtc_ioctl(device_t, u_long, void *);
+static int rtc_init(struct driver *);
+
+static struct devops rtc_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	rtc_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver rtc_driver = {
+	/* name */	"rtc",
+	/* devops */	&rtc_devops,
+	/* devsz */	sizeof(struct rtc_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	rtc_init,
+	/* shutdown */	NULL,
+};
+
+static const int month_days[12] = {
+	31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+static int
+leapyear(u_int year)
+{
+	int rv = 0;
+
+	if ((year & 3) == 0) {
+		rv = 1;
+		if ((year % 100) == 0) {
+			rv = 0;
+			if ((year % 400) == 0)
+				rv = 1;
+		}
+	}
+	return (rv);
+}
+
+time_t
+rtc_ymdhms_to_secs(struct clock_ymdhms *dt)
+{
+	time_t secs;
+	u_int i, year, days;
+
+	year = dt->year;
+
+	/*
+	 * Compute days since start of time.
+	 * First from years, then from months.
+	 */
+	days = 0;
+	for (i = POSIX_BASE_YEAR; i < year; i++)
+		days += days_in_year(i);
+	if (leapyear(year) && dt->mon > FEBRUARY)
+		days++;
+
+	/* Months */
+	for (i = 1; i < dt->mon; i++)
+	  	days += days_in_month(i);
+	days += (dt->day - 1);
+
+	/* Add hours, minutes, seconds. */
+	secs = (time_t)(((days * 24 + dt->hour) * 60 + dt->min)
+			* 60 + dt->sec);
+
+	return (secs);
+}
+
+/* This function uses a copy of month_days[] */
+#undef	days_in_month
+#define	days_in_month(a) 	(mthdays[(a) - 1])
+
+void
+rtc_secs_to_ymdhms(time_t secs, struct clock_ymdhms *dt)
+{
+	u_int mthdays[12];
+	u_int i, days;
+	u_int rsec;	/* remainder seconds */
+
+	memcpy(mthdays, month_days, sizeof(mthdays));
+
+	days = secs / SECDAY;
+	rsec = secs % SECDAY;
+
+	/* Day of week (Note: 1/1/1970 was a Thursday) */
+	dt->dow = (days + 4) % 7;
+
+	/* Subtract out whole years, counting them in i. */
+	for (i = POSIX_BASE_YEAR; days >= days_in_year(i); i++)
+		days -= days_in_year(i);
+	dt->year = (u_short)i;
+
+	/* Subtract out whole months, counting them in i. */
+	if (leapyear(i))
+		days_in_month(FEBRUARY) = 29;
+	for (i = 1; days >= days_in_month(i); i++)
+		days -= days_in_month(i);
+	dt->mon = i;
+
+	/* Days are what is left over (+1) from all that. */
+	dt->day = days + 1;
+
+	/* Hours, minutes, seconds are easy */
+	dt->hour = rsec / 3600;
+	rsec = rsec % 3600;
+	dt->min  = rsec / 60;
+	rsec = rsec % 60;
+	dt->sec  = rsec;
+}
+
+static int
+rtc_ioctl(device_t dev, u_long cmd, void *arg)
+{
+	struct rtc_softc *sc = device_private(dev);
+	struct timeval tv;
+	int error = 0;
+	u_long msec;
+
+	switch (cmd) {
+	case RTCIOC_GET_TIME:
+		/*
+		 * Calculate current time (sec/usec) from
+		 * boot time and current tick count.
+		 */
+		msec = hztoms(timer_ticks() - sc->boot_ticks);
+		tv.tv_sec = sc->boot_sec + (msec / 1000);
+		tv.tv_usec = (long)((msec * 1000) % 1000000);
+		if (copyout(&tv, arg, sizeof(tv)))
+			return EFAULT;
+		break;
+
+	case RTCIOC_SET_TIME:
+		/*
+		 * TODO: We need new capability to set time.
+		 */
+		error = EINVAL;
+		break;
+	default:
+		return EINVAL;
+	}
+	return error;
+}
+
+void
+rtc_attach(struct rtc_ops *ops, void *aux)
+{
+	struct rtc_softc *sc;
+	device_t dev;
+	struct timeval tv;
+
+	dev = device_create(&rtc_driver, "rtc", D_CHR);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->ops = ops;
+	sc->aux = aux;
+
+	/* Save boot time for later use. */
+	ops->gettime(aux, &tv);
+	sc->boot_sec = tv.tv_sec;
+	sc->boot_ticks = timer_ticks();
+}
+
+static int
+rtc_init(struct driver *self)
+{
+
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/serial/Makefile.inc b/prex-0.9.0/bsp/drv/dev/serial/Makefile.inc
new file mode 100755
index 0000000..b59ed71
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/serial/Makefile.inc
@@ -0,0 +1,4 @@
+
+SRCS-$(CONFIG_SERIAL)+=		dev/serial/serial.c
+SRCS-$(CONFIG_NS16550)+=	dev/serial/ns16550.c
+SRCS-$(CONFIG_PL011)+=		dev/serial/pl011.c
diff --git a/prex-0.9.0/bsp/drv/dev/serial/ns16550.c b/prex-0.9.0/bsp/drv/dev/serial/ns16550.c
new file mode 100755
index 0000000..f53427a
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/serial/ns16550.c
@@ -0,0 +1,219 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ns16550.c - NS16550 serial driver
+ */
+
+#include <driver.h>
+#include <tty.h>
+#include <serial.h>
+
+/* #define DEBUG_NS16550 1 */
+
+#ifdef DEBUG_NS16550
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define COM_BASE	CONFIG_NS16550_BASE
+#define COM_IRQ		CONFIG_NS16550_IRQ
+
+/* Register offsets */
+#define COM_RBR		(COM_BASE + 0x00)	/* receive buffer register */
+#define COM_THR		(COM_BASE + 0x00)	/* transmit holding register */
+#define COM_IER		(COM_BASE + 0x01)	/* interrupt enable register */
+#define COM_FCR		(COM_BASE + 0x02)	/* FIFO control register */
+#define COM_IIR		(COM_BASE + 0x02)	/* interrupt identification register */
+#define COM_LCR		(COM_BASE + 0x03)	/* line control register */
+#define COM_MCR		(COM_BASE + 0x04)	/* modem control register */
+#define COM_LSR		(COM_BASE + 0x05)	/* line status register */
+#define COM_MSR		(COM_BASE + 0x06)	/* modem status register */
+#define COM_DLL		(COM_BASE + 0x00)	/* divisor latch LSB (LCR[7] = 1) */
+#define COM_DLM		(COM_BASE + 0x01)	/* divisor latch MSB (LCR[7] = 1) */
+
+/* Interrupt enable register */
+#define	IER_RDA		0x01	/* enable receive data available */
+#define	IER_THRE	0x02	/* enable transmitter holding register empty */
+#define	IER_RLS		0x04	/* enable recieve line status */
+#define	IER_RMS		0x08	/* enable receive modem status */
+
+/* Interrupt identification register */
+#define	IIR_MSR		0x00	/* modem status change */
+#define	IIR_IP		0x01	/* 0 when interrupt pending */
+#define	IIR_TXB		0x02	/* transmitter holding register empty */
+#define	IIR_RXB		0x04	/* received data available */
+#define	IIR_LSR		0x06	/* line status change */
+#define	IIR_MASK	0x07	/* mask off just the meaningful bits */
+
+/* line status register */
+#define	LSR_RCV_FIFO	0x80
+#define	LSR_TSRE	0x40	/* Transmitter empty: byte sent */
+#define	LSR_TXRDY	0x20	/* Transmitter buffer empty */
+#define	LSR_BI		0x10	/* Break detected */
+#define	LSR_FE		0x08	/* Framing error: bad stop bit */
+#define	LSR_PE		0x04	/* Parity error */
+#define	LSR_OE		0x02	/* Overrun, lost incoming byte */
+#define	LSR_RXRDY	0x01	/* Byte ready in Receive Buffer */
+#define	LSR_RCV_MASK	0x1f	/* Mask for incoming data or error */
+
+/* Forward functions */
+static int	ns16550_probe(struct driver *);
+static int	ns16550_init(struct driver *);
+
+static void	ns16550_xmt_char(struct serial_port *, char);
+static char	ns16550_rcv_char(struct serial_port *);
+static void	ns16550_set_poll(struct serial_port *, int);
+static void	ns16550_start(struct serial_port *);
+static void	ns16550_stop(struct serial_port *);
+
+
+struct driver ns16550_driver = {
+	/* name */	"ns16550",
+	/* devops */	NULL,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	ns16550_probe,
+	/* init */	ns16550_init,
+	/* unload */	NULL,
+};
+
+static struct serial_ops ns16550_ops = {
+	/* xmt_char */	ns16550_xmt_char,
+	/* rcv_char */	ns16550_rcv_char,
+	/* set_poll */	ns16550_set_poll,
+	/* start */	ns16550_start,
+	/* stop */	ns16550_stop,
+};
+
+
+static struct serial_port ns16550_port;
+
+
+static void
+ns16550_xmt_char(struct serial_port *sp, char c)
+{
+
+	while (!(bus_read_8(COM_LSR) & LSR_TXRDY))
+		;
+	bus_write_8(COM_THR, c);
+}
+
+static char
+ns16550_rcv_char(struct serial_port *sp)
+{
+
+	while (!(bus_read_8(COM_LSR) & LSR_RXRDY))
+		;
+	return bus_read_8(COM_RBR);
+}
+
+static void
+ns16550_set_poll(struct serial_port *sp, int on)
+{
+
+	if (on) {
+		/* Disable interrupt for polling mode. */
+		bus_write_8(COM_IER, 0x00);
+	} else {
+		/* enable interrupt again */
+		bus_write_8(COM_IER, IER_RDA|IER_THRE|IER_RLS);
+	}
+}
+
+static int
+ns16550_isr(void *arg)
+{
+	struct serial_port *sp = arg;
+
+	switch (bus_read_8(COM_IIR) & IIR_MASK) {
+	case IIR_MSR:		/* Modem status change */
+		break;
+	case IIR_LSR:		/* Line status change */
+		bus_read_8(COM_LSR);
+		break;
+	case IIR_TXB:		/* Transmitter holding register empty */
+		serial_xmt_done(sp);
+		break;
+	case IIR_RXB:		/* Received data available */
+		bus_read_8(COM_LSR);
+		serial_rcv_char(sp, bus_read_8(COM_RBR));
+		break;
+	}
+	return 0;
+}
+
+static void
+ns16550_start(struct serial_port *sp)
+{
+	int s;
+
+	bus_write_8(COM_IER, 0x00);	/* Disable interrupt */
+	bus_write_8(COM_LCR, 0x80);	/* Access baud rate */
+	bus_write_8(COM_DLL, 0x01);	/* 115200 baud */
+	bus_write_8(COM_DLM, 0x00);
+	bus_write_8(COM_LCR, 0x03);	/* N, 8, 1 */
+	bus_write_8(COM_FCR, 0x06);	/* Disable & clear FIFO */
+
+	sp->irq = irq_attach(COM_IRQ, IPL_COMM, 0, ns16550_isr,
+			     IST_NONE, sp);
+
+	s = splhigh();
+	bus_write_8(COM_MCR, 0x0b);  /* Enable OUT2 interrupt */
+	bus_write_8(COM_IER, IER_RDA|IER_THRE|IER_RLS);  /* Enable interrupt */
+	bus_read_8(COM_IIR);
+	splx(s);
+}
+
+static void
+ns16550_stop(struct serial_port *sp)
+{
+
+	/* Disable all interrupts */
+	bus_write_8(COM_IER, 0x00);
+}
+
+
+static int
+ns16550_probe(struct driver *self)
+{
+
+	if (bus_read_8(COM_LSR) == 0xff)
+		return ENXIO;	/* Port is disabled */
+	return 0;
+}
+
+static int
+ns16550_init(struct driver *self)
+{
+
+	serial_attach(&ns16550_ops, &ns16550_port);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/serial/pl011.c b/prex-0.9.0/bsp/drv/dev/serial/pl011.c
new file mode 100755
index 0000000..17d8907
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/serial/pl011.c
@@ -0,0 +1,234 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pl011.c - ARM PrimeCell PL011 UART
+ */
+
+#include <driver.h>
+#include <tty.h>
+#include <serial.h>
+
+/* #define DEBUG_PL011 1 */
+
+#ifdef DEBUG_PL011
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define UART_BASE	CONFIG_PL011_BASE
+#define UART_IRQ	CONFIG_PL011_IRQ
+#define UART_CLK	14745600
+#define BAUD_RATE	115200
+
+/* UART Registers */
+#define UART_DR		(UART_BASE + 0x00)
+#define UART_RSR	(UART_BASE + 0x04)
+#define UART_ECR	(UART_BASE + 0x04)
+#define UART_FR		(UART_BASE + 0x18)
+#define UART_IBRD	(UART_BASE + 0x24)
+#define UART_FBRD	(UART_BASE + 0x28)
+#define UART_LCRH	(UART_BASE + 0x2c)
+#define UART_CR		(UART_BASE + 0x30)
+#define UART_IMSC	(UART_BASE + 0x38)
+#define UART_MIS	(UART_BASE + 0x40)
+#define UART_ICR	(UART_BASE + 0x44)
+
+/* Flag register */
+#define FR_RXFE		0x10	/* Receive FIFO empty */
+#define FR_TXFF		0x20	/* Transmit FIFO full */
+
+/* Masked interrupt status register */
+#define MIS_RX		0x10	/* Receive interrupt */
+#define MIS_TX		0x20	/* Transmit interrupt */
+
+/* Interrupt clear register */
+#define ICR_RX		0x10	/* Clear receive interrupt */
+#define ICR_TX		0x20	/* Clear transmit interrupt */
+
+/* Line control register (High) */
+#define LCRH_WLEN8	0x60	/* 8 bits */
+#define LCRH_FEN	0x10	/* Enable FIFO */
+
+/* Control register */
+#define CR_UARTEN	0x0001	/* UART enable */
+#define CR_TXE		0x0100	/* Transmit enable */
+#define CR_RXE		0x0200	/* Receive enable */
+
+/* Interrupt mask set/clear register */
+#define IMSC_RX		0x10	/* Receive interrupt mask */
+#define IMSC_TX		0x20	/* Transmit interrupt mask */
+
+/* Forward functions */
+static int	pl011_init(struct driver *);
+static void	pl011_xmt_char(struct serial_port *, char);
+static char	pl011_rcv_char(struct serial_port *);
+static void	pl011_set_poll(struct serial_port *, int);
+static void	pl011_start(struct serial_port *);
+static void	pl011_stop(struct serial_port *);
+
+
+struct driver pl011_driver = {
+	/* name */	"pl011",
+	/* devops */	NULL,
+	/* devsz */	0,
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	pl011_init,
+	/* detach */	NULL,
+};
+
+static struct serial_ops pl011_ops = {
+	/* xmt_char */	pl011_xmt_char,
+	/* rcv_char */	pl011_rcv_char,
+	/* set_poll */	pl011_set_poll,
+	/* start */	pl011_start,
+	/* stop */	pl011_stop,
+};
+
+static struct serial_port pl011_port;
+
+
+static void
+pl011_xmt_char(struct serial_port *sp, char c)
+{
+
+	while (bus_read_32(UART_FR) & FR_TXFF)
+		;
+	bus_write_32(UART_DR, (uint32_t)c);
+}
+
+static char
+pl011_rcv_char(struct serial_port *sp)
+{
+	char c;
+
+	while (bus_read_32(UART_FR) & FR_RXFE)
+		;
+	c = bus_read_32(UART_DR) & 0xff;
+	return c;
+}
+
+static void
+pl011_set_poll(struct serial_port *sp, int on)
+{
+
+	if (on) {
+		/*
+		 * Disable interrupt for polling mode.
+		 */
+		bus_write_32(UART_IMSC, 0);
+	} else
+		bus_write_32(UART_IMSC, (IMSC_RX | IMSC_TX));
+}
+
+static int
+pl011_isr(void *arg)
+{
+	struct serial_port *sp = arg;
+	int c;
+	uint32_t mis;
+
+	mis = bus_read_32(UART_MIS);
+
+	if (mis & MIS_RX) {
+		/*
+		 * Receive interrupt
+		 */
+		while (bus_read_32(UART_FR) & FR_RXFE)
+			;
+		do {
+			c = bus_read_32(UART_DR);
+			serial_rcv_char(sp, c);
+		} while ((bus_read_32(UART_FR) & FR_RXFE) == 0);
+
+		/* Clear interrupt status */
+		bus_write_32(UART_ICR, ICR_RX);
+	}
+	if (mis & MIS_TX) {
+		/*
+		 * Transmit interrupt
+		 */
+		serial_xmt_done(sp);
+
+		/* Clear interrupt status */
+		bus_write_32(UART_ICR, ICR_TX);
+	}
+	return 0;
+}
+
+static void
+pl011_start(struct serial_port *sp)
+{
+	uint32_t divider, remainder, fraction;
+
+	bus_write_32(UART_CR, 0);	/* Disable everything */
+	bus_write_32(UART_ICR, 0x07ff);	/* Clear all interrupt status */
+
+	/*
+	 * Set baud rate:
+	 * IBRD = UART_CLK / (16 * BAUD_RATE)
+	 * FBRD = ROUND((64 * MOD(UART_CLK,(16 * BAUD_RATE))) / (16 * BAUD_RATE))
+	 */
+	divider = UART_CLK / (16 * BAUD_RATE);
+	remainder = UART_CLK % (16 * BAUD_RATE);
+	fraction = (8 * remainder / BAUD_RATE) >> 1;
+	fraction += (8 * remainder / BAUD_RATE) & 1;
+	bus_write_32(UART_IBRD, divider);
+	bus_write_32(UART_FBRD, fraction);
+
+	/* Set N, 8, 1, FIFO enable */
+	bus_write_32(UART_LCRH, (LCRH_WLEN8 | LCRH_FEN));
+
+	/* Enable UART */
+	bus_write_32(UART_CR, (CR_RXE | CR_TXE | CR_UARTEN));
+
+	/* Install interrupt handler */
+	sp->irq = irq_attach(UART_IRQ, IPL_COMM, 0, pl011_isr, IST_NONE, sp);
+
+	/* Enable TX/RX interrupt */
+	bus_write_32(UART_IMSC, (IMSC_RX | IMSC_TX));
+}
+
+static void
+pl011_stop(struct serial_port *sp)
+{
+
+	bus_write_32(UART_IMSC, 0);	/* Disable all interrupts */
+	bus_write_32(UART_CR, 0);	/* Disable everything */
+}
+
+static int
+pl011_init(struct driver *self)
+{
+
+	serial_attach(&pl011_ops, &pl011_port);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/serial/serial.c b/prex-0.9.0/bsp/drv/dev/serial/serial.c
new file mode 100755
index 0000000..7fe2458
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/serial/serial.c
@@ -0,0 +1,213 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * serial.c - machine independent driver for serial port.
+ */
+
+#include <driver.h>
+#include <sys/ioctl.h>
+#include <tty.h>
+#include <cons.h>
+#include <serial.h>
+
+/* #define DEBUG_SERIAL 1 */
+
+#ifdef DEBUG_SERIAL
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+struct serial_softc {
+	device_t	dev;		/* device object */
+	struct tty	tty;		/* tty structure */
+	struct serial_port *port;	/* port setting */
+	struct serial_ops  *ops;	/* h/w operation */
+};
+
+/* Forward functions */
+static int	serial_init(struct driver *);
+static int	serial_read(device_t, char *, size_t *, int);
+static int	serial_write(device_t, char *, size_t *, int);
+static int	serial_ioctl(device_t, u_long, void *);
+
+static int	serial_cngetc(device_t);
+static void	serial_cnputc(device_t, int);
+static void	serial_cnpollc(device_t, int);
+
+
+static struct devops serial_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	serial_read,
+	/* write */	serial_write,
+	/* ioctl */	serial_ioctl,
+	/* devctl */	no_devctl,
+};
+
+struct driver serial_driver = {
+	/* name */	"serial",
+	/* devops */	&serial_devops,
+	/* devsz */	sizeof(struct serial_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	serial_init,
+	/* unload */	NULL,
+};
+
+static struct consdev serial_consdev = {
+	/* dev */	NODEV,
+	/* devops */	&serial_devops,
+	/* cngetc */	serial_cngetc,
+	/* cnputc */	serial_cnputc,
+	/* cnpollc */	serial_cnpollc,
+};
+
+
+static int
+serial_read(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct serial_softc *sc = device_private(dev);
+
+	return tty_read(&sc->tty, buf, nbyte);
+}
+
+static int
+serial_write(device_t dev, char *buf, size_t *nbyte, int blkno)
+{
+	struct serial_softc *sc = device_private(dev);
+
+	return tty_write(&sc->tty, buf, nbyte);
+}
+
+static int
+serial_ioctl(device_t dev, u_long cmd, void *arg)
+{
+	struct serial_softc *sc = device_private(dev);
+
+	return tty_ioctl(&sc->tty, cmd, arg);
+}
+
+/*
+ * Start TTY output operation.
+ */
+static void
+serial_start(struct tty *tp)
+{
+	struct serial_softc *sc = device_private(tp->t_dev);
+	struct serial_port *port = sc->port;
+	int c;
+
+	while ((c = tty_getc(&tp->t_outq)) >= 0)
+		sc->ops->xmt_char(port, c);
+}
+
+/*
+ * Output completed.
+ */
+void
+serial_xmt_done(struct serial_port *port)
+{
+
+	tty_done(port->tty);
+}
+
+/*
+ * Character input.
+ */
+void
+serial_rcv_char(struct serial_port *port, char c)
+{
+
+	tty_input(c, port->tty);
+}
+
+static int
+serial_cngetc(device_t dev)
+{
+	struct serial_softc *sc = device_private(dev);
+	struct serial_port *port = sc->port;
+
+	return sc->ops->rcv_char(port);
+}
+
+static void
+serial_cnputc(device_t dev, int c)
+{
+	struct serial_softc *sc = device_private(dev);
+	struct serial_port *port = sc->port;
+
+	sc->ops->xmt_char(port, c);
+}
+
+static void
+serial_cnpollc(device_t dev, int on)
+{
+	struct serial_softc *sc = device_private(dev);
+	struct serial_port *port = sc->port;
+
+	sc->ops->set_poll(port, on);
+}
+
+void
+serial_attach(struct serial_ops *ops, struct serial_port *port)
+{
+	struct serial_softc *sc;
+	device_t dev;
+	int diag = 0;
+
+	dev = device_create(&serial_driver, "tty", D_CHR|D_TTY);
+
+	sc = device_private(dev);
+	sc->dev = dev;
+	sc->ops = ops;
+	sc->port = port;
+
+	tty_attach(&sc->tty);
+	sc->tty.t_dev = dev;
+	sc->tty.t_oproc = serial_start;
+
+	/* Start device */
+	port->tty = &sc->tty;
+	ops->start(port);
+
+#ifdef CONFIG_DIAG_SERIAL
+	diag = 1;
+#endif
+	serial_consdev.dev = dev;
+	cons_attach(&serial_consdev, diag);
+}
+
+static int
+serial_init(struct driver *self)
+{
+
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/dev/video/Makefile.inc b/prex-0.9.0/bsp/drv/dev/video/Makefile.inc
new file mode 100755
index 0000000..e0aa282
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/video/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_VGA)+=		dev/video/vga.c
diff --git a/prex-0.9.0/bsp/drv/dev/video/vga.c b/prex-0.9.0/bsp/drv/dev/video/vga.c
new file mode 100755
index 0000000..5a6fc4f
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/dev/video/vga.c
@@ -0,0 +1,256 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vga.c - vga driver
+ */
+
+#include <driver.h>
+#include <wscons.h>
+#include <devctl.h>
+#include <pm.h>
+
+/* #define DEBUG_VGA 1 */
+
+#ifdef DEBUG_VGA
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+#define CRTC_INDEX	0x3d4
+#define CRTC_DATA	0x3d5
+#define SEQ_INDEX	0x3c4
+#define SEQ_DATA	0x3c5
+
+#define VID_RAM		0xB8000
+
+struct vga_softc {
+	device_t	dev;
+	short		*vram;
+	int		cols;
+	int		attr;
+	int		blank;
+};
+
+static int	vga_devctl(device_t, u_long, void *);
+static int	vga_init(struct driver *);
+static void	vga_cursor(void*, int, int);
+static void	vga_putc(void *, int, int, int);
+static void	vga_copyrows(void *,int, int, int);
+static void	vga_eraserows(void *,int, int);
+static void	vga_set_attr(void *, int);
+static void	vga_get_cursor(void *, int *, int *);
+
+static struct devops vga_devops = {
+	/* open */	no_open,
+	/* close */	no_close,
+	/* read */	no_read,
+	/* write */	no_write,
+	/* ioctl */	no_ioctl,
+	/* devctl */	vga_devctl,
+};
+
+struct driver vga_driver = {
+	/* name */	"vga",
+	/* devops */	&vga_devops,
+	/* devsz */	sizeof(struct vga_softc),
+	/* flags */	0,
+	/* probe */	NULL,
+	/* init */	vga_init,
+	/* shutdown */	NULL,
+};
+
+static struct wscons_video_ops wscons_vga_ops = {
+	vga_cursor,	/* cursor */
+	vga_putc,	/* putc */
+	vga_copyrows,	/* copyrows */
+	vga_eraserows,	/* eraserows */
+	vga_set_attr,	/* set_attr */
+	vga_get_cursor,	/* set_cursor */
+};
+
+
+static u_char
+crtc_read(u_char index)
+{
+
+	bus_write_8(CRTC_INDEX, index);
+	return bus_read_8(CRTC_DATA);
+}
+
+static void
+crtc_write(u_char index, u_char val)
+{
+
+	bus_write_8(CRTC_INDEX, index);
+	bus_write_8(CRTC_DATA, val);
+}
+
+static void
+vga_on(void)
+{
+	u_char val;
+
+	bus_write_8(SEQ_INDEX, 1);
+	val = bus_read_8(SEQ_DATA);
+	bus_write_8(SEQ_DATA, val & ~0x20);
+}
+
+static void
+vga_off(void)
+{
+	u_char val;
+
+	bus_write_8(SEQ_INDEX, 1);
+	val = bus_read_8(SEQ_DATA);
+	bus_write_8(SEQ_DATA, val | 0x20);
+}
+
+static void
+vga_cursor(void *aux, int row, int col)
+{
+	struct vga_softc *sc = aux;
+	int pos, s;
+
+	pos = row * sc->cols + col;
+
+	s = splhigh();
+	crtc_write(0x0e, (u_char)((pos >> 8) & 0xff));
+	crtc_write(0x0f, (u_char)(pos & 0xff));
+	splx(s);
+}
+
+static void
+vga_putc(void *aux, int row, int col, int ch)
+{
+	struct vga_softc *sc = aux;
+
+	sc->vram[row * sc->cols + col] = ch | (sc->attr << 8);
+}
+
+static void
+vga_copyrows(void *aux, int srcrow, int dstrow, int nrows)
+{
+	struct vga_softc *sc = aux;
+
+	memcpy(sc->vram + dstrow * sc->cols,
+	       sc->vram + srcrow * sc->cols,
+	       (size_t)nrows * sc->cols * 2);
+}
+
+static void
+vga_eraserows(void *aux, int row, int nrows)
+{
+	struct vga_softc *sc = aux;
+	int i, start, end;
+
+	start = row * sc->cols;
+	end = start + nrows * sc->cols;
+
+	for (i = start; i < end; i++)
+		sc->vram[i] = ' ' | (sc->attr << 8);
+}
+
+static void
+vga_set_attr(void *aux, int attr)
+{
+	struct vga_softc *sc = aux;
+
+	sc->attr = attr;
+}
+
+
+static void
+vga_get_cursor(void *aux, int *col, int *row)
+{
+	struct vga_softc *sc = aux;
+	u_int offset;
+	int s;
+
+	s = splhigh();
+	offset = crtc_read(0x0e);
+	offset <<= 8;
+	offset += crtc_read(0x0f);
+	*col = (int)offset % sc->cols;
+	*row = (int)offset / sc->cols;
+	splx(s);
+}
+
+static int
+vga_devctl(device_t dev, u_long cmd, void *arg)
+{
+	struct vga_softc *sc = device_private(dev);
+	int s;
+
+	DPRINTF(("vga: devctl cmd=%x\n", cmd));
+
+	s = splhigh();
+	switch (cmd) {
+	case DEVCTL_PM_LCDOFF:
+		if (!sc->blank) {
+			DPRINTF(("vga: LCD off\n"));
+			vga_off();
+			sc->blank = 1;
+		}
+		break;
+	case DEVCTL_PM_LCDON:
+		if (sc->blank) {
+			vga_on();
+			sc->blank = 0;
+			DPRINTF(("vga: LCD on\n"));
+		}
+		break;
+	}
+	splx(s);
+	return 0;
+}
+
+static int
+vga_init(struct driver *self)
+{
+	device_t dev;
+	struct bootinfo *bi;
+	struct vga_softc *sc;
+
+	machine_bootinfo(&bi);
+
+	dev = device_create(self, "vga", D_CHR);
+
+	sc = device_private(dev);
+	sc->vram = ptokv(VID_RAM);
+	sc->cols = bi->video.text_x;
+	sc->attr = 0x0f;
+	sc->blank = 0;
+
+	wscons_attach_video(&wscons_vga_ops, sc);
+
+	pm_attach_lcd(dev);
+	return 0;
+}
diff --git a/prex-0.9.0/bsp/drv/include/cons.h b/prex-0.9.0/bsp/drv/include/cons.h
new file mode 100755
index 0000000..8ecfd70
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/cons.h
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _CONS_H
+#define _CONS_H
+
+#include <sys/cdefs.h>
+
+struct consdev {
+	device_t	dev;		/* device */
+	struct devops	*devops;	/* device operations */
+	int	(*cngetc)(device_t dev);          /* kernel getchar */
+	void	(*cnputc)(device_t dev, int ch);  /* kernel putchar */
+	void	(*cnpollc)(device_t dev, int on); /* polling control */
+};
+
+__BEGIN_DECLS
+int	cons_getc(void);
+void	cons_putc(int);
+void	cons_pollc(int);
+void	cons_puts(char *);
+void	cons_attach(struct consdev *, int);
+__END_DECLS
+
+#endif /* !_CONS_H */
diff --git a/prex-0.9.0/bsp/drv/include/cpufreq.h b/prex-0.9.0/bsp/drv/include/cpufreq.h
new file mode 100755
index 0000000..06f8a04
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/cpufreq.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _CPUFREQ_H
+#define _CPUFRQE_H
+
+#include <sys/cdefs.h>
+#include <sys/ioctl.h>
+
+struct cpufreq_ops {
+	int	(*setperf)(int speed);
+	int	(*getperf)(void);
+	void	(*getinfo)(struct cpufreqinfo *info);
+};
+
+__BEGIN_DECLS
+void	cpufreq_attach(struct cpufreq_ops *);
+__END_DECLS
+
+#endif /* !_CPUFREQ_H */
diff --git a/prex-0.9.0/bsp/drv/include/ddi.h b/prex-0.9.0/bsp/drv/include/ddi.h
new file mode 100755
index 0000000..e3d6778
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/ddi.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ddi.h - Device Driver Interface
+ */
+
+#ifndef _DDI_H
+#define _DDI_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <machine/stdarg.h>
+#include <dki.h>
+#include <busio.h>		/* bus_read/bus_write */
+
+#ifdef DEBUG
+#define ASSERT(exp) do { if (!(exp)) \
+			     assert(__FILE__, __LINE__, #exp); } while (0)
+#else
+#define ASSERT(exp) ((void)0)
+#endif
+
+
+/*
+ * I/O request packet
+ */
+struct irp {
+	int	cmd;		/* I/O command */
+	int	blkno;		/* block number */
+	u_long	blksz;		/* block size */
+	void	*buf;		/* I/O buffer */
+	int	ntries;		/* retry count */
+	int	error;		/* error status */
+	struct event iocomp;	/* I/O completion event */
+};
+
+/*
+ * I/O command
+ */
+#define IO_NONE		0
+#define IO_READ		1
+#define IO_WRITE	2
+#define IO_FORMAT	3	/* not supported */
+#define IO_CANCEL	4
+
+
+__BEGIN_DECLS
+void	 driver_shutdown(void);
+void	 calibrate_delay(void);
+void	 delay_usec(u_long usec);
+
+int	 enodev(void);
+int	 nullop(void);
+
+dma_t	 dma_attach(int chan);
+void	 dma_detach(dma_t handle);
+void	 dma_setup(dma_t handle, void *addr, u_long count, int read);
+void	 dma_stop(dma_t handle);
+void	*dma_alloc(size_t size);
+
+long	 atol(const char *str);
+char	*strncpy(char *dest, const char *src, size_t count);
+int	 strncmp(const char *src, const char *tgt, size_t count);
+size_t	 strlcpy(char *dest, const char *src, size_t count);
+size_t	 strnlen(const char *str, size_t max);
+void	 *memcpy(void *dest, const void *src, size_t count);
+void	 *memset(void *dest, int ch, size_t count);
+
+u_long	 strtoul(const char *nptr, char **endptr, int base);
+
+int	 isalnum(int c);
+int	 isalpha(int c);
+int	 isblank(int c);
+int	 isupper(int c);
+int	 islower(int c);
+int	 isspace(int c);
+int	 isdigit(int c);
+int	 isxdigit(int c);
+int	 isprint(int c);
+
+#ifdef DEBUG
+void	 assert(const char *, int, const char *);
+#endif
+__END_DECLS
+
+#endif /* !_DDI_H */
diff --git a/prex-0.9.0/bsp/drv/include/devctl.h b/prex-0.9.0/bsp/drv/include/devctl.h
new file mode 100755
index 0000000..d408a10
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/devctl.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEVCTL_H
+#define _DEVCTL_H
+
+/*
+ * Device control code
+ */
+#define	_DEVC(group,num)	(u_long)(((group) << 16) | (num))
+
+/*
+ * Power management
+ */
+#define DEVCTL_PM_POWERDOWN	_DEVC('P', 0)	/* power down */
+#define DEVCTL_PM_POWERUP	_DEVC('P', 1)	/* power up */
+#define DEVCTL_PM_CHGPOLICY	_DEVC('P', 2)	/* change power policy */
+#define DEVCTL_PM_LCDOFF	_DEVC('P', 3)	/* lcd off */
+#define DEVCTL_PM_LCDON		_DEVC('P', 4)	/* lcd on */
+#define DEVCTL_PM_CHGFREQ	_DEVC('P', 5)	/* change cpu frequency */
+
+/*
+ * Plug and play
+ */
+#define DEVCTL_PNP_ATTACH	_DEVC('N', 0)	/* device attach */
+#define DEVCTL_PNP_DETACH	_DEVC('N', 1)	/* device detach */
+#define DEVCTL_PNP_INSERT	_DEVC('N', 2)	/* media insertion */
+#define DEVCTL_PNP_REMOVE	_DEVC('N', 3)	/* media removal */
+
+/*
+ * Debug
+ */
+#define DEVCTL_DBG_DEVSTAT	_DEVC('D', 0)	/* dump device state */
+#define DEVCTL_DBG_ENTERKD	_DEVC('D', 1)	/* entering kernel debugger */
+#define DEVCTL_DBG_EXITKD	_DEVC('D', 2)	/* eixt kernel debugger */
+
+#endif /* !_DEVCTL_H */
diff --git a/prex-0.9.0/bsp/drv/include/dki.h b/prex-0.9.0/bsp/drv/include/dki.h
new file mode 100755
index 0000000..3183f1f
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/dki.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * dki.h - Driver-Kernel Interface
+ */
+
+#ifndef _DKI_H
+#define _DKI_H
+
+#include <types.h>
+#include <sys/queue.h>
+#include <sys/dbgctl.h>
+#include <sys/bootinfo.h>
+#include <sys/ipl.h>
+#include <sys/power.h>
+#include <sys/capability.h>
+#include <sys/device.h>
+
+extern dkifn_t	*dki_table;		/* pointer to DKI function table */
+
+/*
+ * Device open mode
+ */
+#define DO_RDONLY	0x0
+#define DO_WRONLY	0x1
+#define DO_RDWR		0x2
+#define DO_RWMASK	0x3
+
+/*
+ * Return value of ISR
+ */
+#define INT_DONE	0	/* done */
+#define INT_ERROR	1	/* error */
+#define INT_CONTINUE	2	/* continue to IST */
+
+/* No IST for irq_attach() */
+#define IST_NONE        ((void (*)(void *)) -1)
+
+/*
+ * Event for sleep/wakeup
+ */
+struct event {
+	struct queue	sleepq;		/* queue for waiting thread */
+	const char	*name;		/* pointer to event name string */
+};
+
+#define event_init(event, evt_name) \
+    do { list_init(&(event)->sleepq); (event)->name = evt_name; } while (0)
+
+/*
+ * Sleep result
+ */
+#define SLP_SUCCESS	0
+#define SLP_BREAK	1
+#define SLP_TIMEOUT	2
+#define SLP_INVAL	3
+#define SLP_INTR	4
+
+/*
+ * DPC (Deferred Procedure Call) object
+ * The data member is private to kernel.
+ */
+struct dpc {
+	void	*_data[5];
+};
+
+typedef struct dpc	dpc_t;
+
+/*
+ * Timer structure
+ * The data member is private to kernel.
+ */
+struct timer {
+	void	*_data[10];
+};
+
+typedef struct timer	timer_t;
+
+__BEGIN_DECLS
+device_t device_create(struct driver *, const char *, int);
+int	 device_destroy(device_t);
+device_t device_lookup(const char *);
+int	 device_control(device_t, u_long, void *);
+int	 device_broadcast(u_long, void *, int);
+void	*device_private(device_t);
+
+int	 copyin(const void *, void *, size_t);
+int	 copyout(const void *, void *, size_t);
+int	 copyinstr(const void *, void *, size_t);
+
+void	*kmem_alloc(size_t);
+void	 kmem_free(void *);
+void	*kmem_map(void *, size_t);
+
+paddr_t	 page_alloc(psize_t);
+void	 page_free(paddr_t, psize_t);
+void	 page_reserve(paddr_t, psize_t);
+
+irq_t	 irq_attach(int, int, int, int (*)(void *), void (*)(void *), void *);
+void	 irq_detach(irq_t);
+
+int	 spl0(void);
+int	 splhigh(void);
+void	 splx(int);
+
+void	 timer_callout(timer_t *, u_long, void (*)(void *), void *);
+void	 timer_stop(timer_t *);
+u_long	 timer_delay(u_long);
+u_long	 timer_ticks(void);
+
+void	 sched_lock(void);
+void	 sched_unlock(void);
+int	 sched_tsleep(struct event *, u_long);
+void	 sched_wakeup(struct event *);
+void	 sched_dpc(struct dpc *, void (*)(void *), void *);
+#define	 sched_sleep(event)  sched_tsleep((event), 0)
+
+int	 task_capable(cap_t);
+int	 exception_post(task_t, int);
+void	 machine_bootinfo(struct bootinfo **);
+void	 machine_powerdown(int);
+int	 sysinfo(int, void *);
+void	 panic(const char *);
+void	 printf(const char *, ...);
+void	 dbgctl(int, void *);
+__END_DECLS
+
+#endif /* !_DKI_H */
diff --git a/prex-0.9.0/bsp/drv/include/driver.h b/prex-0.9.0/bsp/drv/include/driver.h
new file mode 100755
index 0000000..262ece7
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/driver.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DRIVER_H
+#define _DRIVER_H
+
+#include <conf/config.h>
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <sys/list.h>
+#include <sys/queue.h>
+#include <sys/bootinfo.h>
+#include <sys/device.h>
+#include <dki.h>
+#include <ddi.h>
+
+
+__BEGIN_DECLS
+void	driver_probe(void);
+void	driver_init(void);
+void	driver_shutdown(void);
+void	driver_dump(void);
+__END_DECLS
+
+#endif /* !_DRIVER_H */
diff --git a/prex-0.9.0/bsp/drv/include/kd.h b/prex-0.9.0/bsp/drv/include/kd.h
new file mode 100755
index 0000000..a1149f2
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/kd.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _KD_H
+#define _KD_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	kd_init(void);
+void	kd_enter(void);
+__END_DECLS
+
+#endif /* !_KD_H */
diff --git a/prex-0.9.0/bsp/drv/include/pm.h b/prex-0.9.0/bsp/drv/include/pm.h
new file mode 100755
index 0000000..8475063
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/pm.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PM_H
+#define _PM_H
+
+#include <sys/cdefs.h>
+#include <sys/power.h>
+
+__BEGIN_DECLS
+#ifdef CONFIG_PM
+void	pm_notify(int event);
+int	pm_set_power(int);
+void	pm_attach_lcd(device_t);
+#else
+#define pm_notify(e)		do {} while (0)
+#define pm_set_power(p)		do {} while (0)
+#define pm_attach_lcd(d)	do {} while (0)
+#endif
+__END_DECLS
+
+#endif /* !_PM_H */
diff --git a/prex-0.9.0/bsp/drv/include/rtc.h b/prex-0.9.0/bsp/drv/include/rtc.h
new file mode 100755
index 0000000..91b731f
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/rtc.h
@@ -0,0 +1,80 @@
+/*	$OpenBSD: time.h,v 1.25 2007/05/09 17:42:19 deraadt Exp $	*/
+/*	$NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $	*/
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.2 (Berkeley) 7/10/94
+ */
+
+/* Modified for Prex by Kohsuke Ohtani */
+
+#ifndef _RTC_H
+#define _RTC_H
+
+#include <sys/cdefs.h>
+
+struct rtc_ops {
+	int	(*gettime)(void *aux, struct timeval *tv);
+	int	(*settime)(void *aux, struct timeval *tv);
+};
+
+/*
+ * "POSIX time" to/from "YY/MM/DD/hh/mm/ss"
+ */
+struct clock_ymdhms {
+        u_short		year;
+        u_char		mon;
+        u_char		day;
+        u_char		dow;	/* Day of week */
+        u_char		hour;
+        u_char		min;
+        u_char		sec;
+        u_char		nsec;
+};
+
+/*
+ * BCD to decimal and decimal to BCD.
+ */
+#define FROMBCD(x)      (u_char)(((x) >> 4) * 10 + ((x) & 0xf))
+#define TOBCD(x)        (u_char)(((x) / 10 * 16) + ((x) % 10))
+
+/* Some handy constants. */
+#define SECDAY          86400L
+#define SECYR           (SECDAY * 365)
+
+/* Traditional POSIX base year */
+#define POSIX_BASE_YEAR 1970
+
+__BEGIN_DECLS
+time_t	rtc_ymdhms_to_secs(struct clock_ymdhms *dt);
+void	rtc_secs_to_ymdhms(time_t secs, struct clock_ymdhms *dt);
+void	rtc_attach(struct rtc_ops *ops, void *aux);
+__END_DECLS
+
+#endif /* !_RTC_H */
diff --git a/prex-0.9.0/bsp/drv/include/serial.h b/prex-0.9.0/bsp/drv/include/serial.h
new file mode 100755
index 0000000..d0219dd
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/serial.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SERIAL_H
+#define _SERIAL_H
+
+#include <sys/cdefs.h>
+#include <tty.h>
+
+struct serial_port {
+	irq_t		irq;
+	struct tty 	*tty;
+};
+
+struct serial_ops {
+	void	(*xmt_char)(struct serial_port *port, char c);
+	char	(*rcv_char)(struct serial_port *port);
+	void	(*set_poll)(struct serial_port *port, int on);
+	void	(*start)(struct serial_port *port);
+	void	(*stop)(struct serial_port *port);
+};
+
+__BEGIN_DECLS
+void	serial_attach(struct serial_ops *, struct serial_port *);
+void	serial_xmt_done(struct serial_port *);
+void	serial_rcv_char(struct serial_port *, char);
+__END_DECLS
+
+#endif /* !_SERIAL_H */
diff --git a/prex-0.9.0/bsp/drv/include/tty.h b/prex-0.9.0/bsp/drv/include/tty.h
new file mode 100755
index 0000000..e28b94a
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/tty.h
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)tty.h	8.7 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_TTY_H_
+#define _SYS_TTY_H_
+
+#include <sys/cdefs.h>
+#include <sys/termios.h>
+#include <sys/syslimits.h>
+
+#define TTYQ_SIZE	MAX_INPUT
+#define TTYQ_HIWAT	(TTYQ_SIZE - 10)
+
+struct tty_queue {
+	char	tq_buf[TTYQ_SIZE];
+	int	tq_head;
+	int	tq_tail;
+	int	tq_count;
+};
+
+/*
+ * Per-tty structure.
+ */
+struct tty {
+	struct tty_queue t_rawq;	/* raw input queue */
+	struct tty_queue t_canq;	/* canonical queue */
+	struct tty_queue t_outq;	/* ouput queue */
+	struct termios	t_termios;	/* termios state */
+	struct winsize	t_winsize;	/* window size */
+	struct event	t_input;	/* event for input data ready */
+	struct event	t_output;	/* event for output completion */
+	void (*t_oproc)(struct tty *);	/* routine to start output */
+	device_t	t_dev;		/* device */
+	int		t_state;	/* driver state */
+	int		t_column;	/* tty output column */
+	pid_t		t_pgid;		/* foreground process group. */
+	task_t		t_sigtask;	/* task to dispatch the tty signal */
+	int		t_signo;	/* pending signal# */
+	struct dpc	t_dpc;		/* dpc for tty */
+};
+
+#define	t_iflag		t_termios.c_iflag
+#define	t_oflag		t_termios.c_oflag
+#define	t_cflag		t_termios.c_cflag
+#define	t_lflag		t_termios.c_lflag
+#define	t_cc		t_termios.c_cc
+#define	t_ispeed	t_termios.c_ispeed
+#define	t_ospeed	t_termios.c_ospeed
+
+/* These flags are kept in t_state. */
+#define	TS_ASLEEP	0x00001		/* Process waiting for tty. */
+#define	TS_BUSY		0x00004		/* Draining output. */
+#define	TS_TIMEOUT	0x00100		/* Wait for output char processing. */
+#define	TS_TTSTOP	0x00200		/* Output paused. */
+#define	TS_ISIG		0x00400		/* Input is interrupted by signal. */
+
+__BEGIN_DECLS
+int	 tty_read(struct tty *, char *, size_t *);
+int	 tty_write(struct tty *, char *, size_t *);
+int	 tty_ioctl(struct tty *, u_long, void *);
+void	 tty_input(int, struct tty *);
+int	 tty_getc(struct tty_queue *);
+void	 tty_done(struct tty *);
+void	 tty_attach(struct tty *);
+__END_DECLS
+
+#endif /* !_SYS_TTY_H_ */
diff --git a/prex-0.9.0/bsp/drv/include/types.h b/prex-0.9.0/bsp/drv/include/types.h
new file mode 100755
index 0000000..b192d09
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/types.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <sys/types.h>
+
+typedef unsigned long	task_t;
+typedef unsigned long	thread_t;
+typedef unsigned long	device_t;
+typedef unsigned long	irq_t;
+typedef unsigned long	dma_t;
+
+#define NODMA		((dma_t)-1)
+
+#endif /* !_TYPES_H */
diff --git a/prex-0.9.0/bsp/drv/include/wscons.h b/prex-0.9.0/bsp/drv/include/wscons.h
new file mode 100755
index 0000000..9127230
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/include/wscons.h
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _WSCONS_H
+#define _WSCONS_H
+
+#include <sys/cdefs.h>
+
+/*
+ * Video interface
+ */
+struct wscons_video_ops {
+	void	(*cursor)    (void *aux, int row, int col);
+	void	(*putc)      (void *aux, int row, int col, int ch);
+	void	(*copyrows)  (void *aux, int srcrow, int dstrow, int nrows);
+	void	(*eraserows) (void *aux, int row, int nrows);
+	void	(*set_attr)  (void *aux, int attr);
+	void	(*get_cursor)(void *aux, int *col, int *row);
+};
+
+/*
+ * Keyboard interface
+ */
+struct wscons_kbd_ops {
+	int	(*getc)     (void *aux);
+	void	(*set_poll) (void *aux, int on);
+};
+
+__BEGIN_DECLS
+void	wscons_attach_video(struct wscons_video_ops *, void *aux);
+void	wscons_attach_kbd(struct wscons_kbd_ops *, void *aux);
+void	wscons_kbd_input(int);
+__END_DECLS
+
+#endif /* !_WSCONS_H */
diff --git a/prex-0.9.0/bsp/drv/lib/Makefile.inc b/prex-0.9.0/bsp/drv/lib/Makefile.inc
new file mode 100755
index 0000000..aeb8c1c
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/Makefile.inc
@@ -0,0 +1,10 @@
+
+SRCS+=		lib/dkient.S \
+		lib/queue.c \
+		lib/assert.c \
+		lib/endian.c \
+		lib/string.c \
+		lib/strtoul.c \
+		lib/ctype.c \
+		lib/delay.c \
+		lib/noop.c
diff --git a/prex-0.9.0/bsp/drv/lib/assert.c b/prex-0.9.0/bsp/drv/lib/assert.c
new file mode 100755
index 0000000..d0343c0
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/assert.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * assert.c - assertion routine
+ */
+
+#include <driver.h>
+
+/*
+ * Assertion routine
+ *
+ * Do not call this routine, but use ASSERT() macro.
+ * assert() is called only when the expression is
+ * false in ASSERT() macro.
+ */
+void
+assert(const char *file, int line, const char *exp)
+{
+
+#ifdef DEBUG
+	printf("\nAssertion failed: %s line:%d '%s'\n", file, line, exp);
+#endif
+	panic("driver panic");
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/bsp/drv/lib/ctype.c b/prex-0.9.0/bsp/drv/lib/ctype.c
new file mode 100755
index 0000000..65011f2
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/ctype.c
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <ddi.h>
+
+
+int
+isalnum(int c)
+{
+	return (isalpha(c) || isdigit(c));
+}
+
+int
+isalpha(int c)
+{
+	return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
+}
+
+int
+isblank(int c)
+{
+	return (c == ' ' || c == '\t');
+}
+
+int
+isupper(int c)
+{
+	return (c >= 'A' && c <= 'Z');
+}
+
+int
+islower(int c)
+{
+	return (c >= 'a' && c <= 'z');
+}
+
+int
+isspace(int c)
+{
+	return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
+}
+
+int
+isdigit(int c)
+{
+	return (c >= '0' && c <= '9');
+}
+
+int
+isxdigit(int c)
+{
+	return (isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
+}
+
+int
+isprint(int c)
+{
+	return (c >= 0x20 && c <= 0x7E);
+}
diff --git a/prex-0.9.0/bsp/drv/lib/delay.c b/prex-0.9.0/bsp/drv/lib/delay.c
new file mode 100755
index 0000000..8a3ae6f
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/delay.c
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * delay.c - driver delay routine
+ */
+
+#include <driver.h>
+
+#ifdef DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+
+static u_long delay_count;	/* Loop count for 1ms */
+
+static
+void delay_loop(u_long count)
+{
+	volatile u_long i;
+
+	for (i = 0; i < count; i++);
+}
+
+/*
+ * Delay micro seconds (non-blocking)
+ * timer_udelay() can be called from ISR at interrupt level.
+ */
+void
+delay_usec(u_long usec)
+{
+
+	delay_loop(delay_count * usec / 1000);
+}
+
+/*
+ * Compute the loop count for 1ms.
+ * Assumes clock interrupt is enabled.
+ */
+void
+calibrate_delay(void)
+{
+	u_long ticks, test_bit;
+
+	DPRINTF(("Calibrating delay loop... "));
+	delay_count = 1;
+	for (;;) {
+		delay_count <<= 1;
+
+		ticks = timer_ticks();
+		while (ticks == timer_ticks());
+
+		ticks = timer_ticks();
+		delay_loop(delay_count);
+		if (ticks != timer_ticks())
+			break;
+	}
+	delay_count >>= 1;
+	test_bit = delay_count;
+
+	for (;;) {
+		test_bit >>= 1;
+		if (test_bit == 0)
+			break;
+		delay_count |= test_bit;
+
+		ticks = timer_ticks();
+		while (ticks == timer_ticks());
+
+		ticks = timer_ticks();
+		delay_loop(delay_count);
+		if (ticks != timer_ticks())
+			delay_count &= ~test_bit;
+	}
+	delay_count *= 1000;	/* count per 1sec */
+	delay_count /= 1000;	/* count per 1ms */
+	DPRINTF(("ok count=%ld\n", delay_count));
+}
diff --git a/prex-0.9.0/bsp/drv/lib/dkient.S b/prex-0.9.0/bsp/drv/lib/dkient.S
new file mode 100755
index 0000000..93caad4
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/dkient.S
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * dki.S - driver kernel interface
+ */
+
+#include <machine/asm.h>
+#include <dkient.h>
+
+STUB( 0, copyin)
+STUB( 1, copyout)
+STUB( 2, copyinstr)
+STUB( 3, kmem_alloc)
+STUB( 4, kmem_free)
+STUB( 5, kmem_map)
+STUB( 6, page_alloc)
+STUB( 7, page_free)
+STUB( 8, page_reserve)
+STUB( 9, irq_attach)
+STUB(10, irq_detach)
+STUB(11, spl0)
+STUB(12, splhigh)
+STUB(13, splx)
+STUB(14, timer_callout)
+STUB(15, timer_stop)
+STUB(16, timer_delay)
+STUB(17, timer_ticks)
+STUB(18, sched_lock)
+STUB(19, sched_unlock)
+STUB(20, sched_tsleep)
+STUB(21, sched_wakeup)
+STUB(22, sched_dpc)
+STUB(23, task_capable)
+STUB(24, exception_post)
+STUB(25, device_create)
+STUB(26, device_destroy)
+STUB(27, device_lookup)
+STUB(28, device_control)
+STUB(29, device_broadcast)
+STUB(30, device_private)
+STUB(31, machine_bootinfo)
+STUB(32, machine_powerdown)
+STUB(33, sysinfo)
+STUB(34, panic)
+STUB(35, printf)
+STUB(36, dbgctl)
diff --git a/prex-0.9.0/bsp/drv/lib/endian.c b/prex-0.9.0/bsp/drv/lib/endian.c
new file mode 100755
index 0000000..712d05b
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/endian.c
@@ -0,0 +1,47 @@
+/*
+ * Written by J.T. Conklin <jtc@NetBSD.org>.
+ * Public domain.
+ */
+
+#include <driver.h>
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#undef htonl
+#undef htons
+#undef ntohl
+#undef ntohs
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+uint32_t
+htonl(uint32_t x)
+{
+
+	u_char *s = (u_char *)&x;
+	return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
+}
+
+uint16_t
+htons(uint16_t x)
+{
+
+	u_char *s = (u_char *) &x;
+	return (uint16_t)(s[0] << 8 | s[1]);
+}
+
+uint32_t
+ntohl(uint32_t x)
+{
+
+	u_char *s = (u_char *)&x;
+	return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
+}
+
+uint16_t
+ntohs(uint16_t x)
+{
+
+	u_char *s = (u_char *) &x;
+	return (uint16_t)(s[0] << 8 | s[1]);
+}
+#endif
diff --git a/prex-0.9.0/bsp/drv/lib/noop.c b/prex-0.9.0/bsp/drv/lib/noop.c
new file mode 100755
index 0000000..57e0e09
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/noop.c
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <driver.h>
+
+/*
+ * nonexistent device call.
+ */
+int
+enodev(void)
+{
+
+	return ENODEV;
+}
+
+/*
+ * Generic null operation, always returns success.
+ */
+int
+nullop(void)
+{
+
+	return 0;
+}
+
diff --git a/prex-0.9.0/bsp/drv/lib/queue.c b/prex-0.9.0/bsp/drv/lib/queue.c
new file mode 100755
index 0000000..3c13cb0
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/queue.c
@@ -0,0 +1,83 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * queue.c - generic queue management library
+ */
+#include <sys/queue.h>
+
+/*
+ * Insert element at tail of queue
+ */
+void
+enqueue(queue_t head, queue_t item)
+{
+	item->next = head;
+	item->prev = head->prev;
+	item->prev->next = item;
+	head->prev = item;
+}
+
+/*
+ * Remove and return element of head of queue
+ */
+queue_t
+dequeue(queue_t head)
+{
+	queue_t item;
+
+	if (head->next == head)
+		return ((queue_t)0);
+	item = head->next;
+	item->next->prev = head;
+	head->next = item->next;
+	return item;
+}
+
+/*
+ * Insert element after specified element
+ */
+void
+queue_insert(queue_t prev, queue_t item)
+{
+	item->prev = prev;
+	item->next = prev->next;
+	prev->next->prev = item;
+	prev->next = item;
+}
+
+/*
+ * Remove specified element from queue
+ */
+void
+queue_remove(queue_t item)
+{
+	item->prev->next = item->next;
+	item->next->prev = item->prev;
+}
diff --git a/prex-0.9.0/bsp/drv/lib/string.c b/prex-0.9.0/bsp/drv/lib/string.c
new file mode 100755
index 0000000..a98a407
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/string.c
@@ -0,0 +1,120 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <ddi.h>
+
+/*
+ * Convert string to long integer
+ * This version does not support minus value.
+ */
+long
+atol(const char *str)
+{
+	long val = 0;
+
+	while (*str == ' ')
+		str++;
+	while (*str >= '0' && *str <= '9') {
+		val *= 10;
+		val += (*str - '0');
+		str++;
+	}
+	return val;
+}
+
+size_t
+strnlen(const char *str, size_t count)
+{
+	const char *tmp;
+
+	for (tmp = str; count-- && *tmp != '\0'; ++tmp);
+	return (size_t)(tmp - str);
+}
+
+char *
+strncpy(char *dest, const char *src, size_t count)
+{
+	char *tmp = dest;
+
+	while (count-- && (*dest++ = *src++) != '\0');
+	return tmp;
+}
+
+int
+strncmp(const char *src, const char *tgt, size_t count)
+{
+	signed char res = 0;
+
+	while (count) {
+		if ((res = *src - *tgt++) != 0 || !*src++)
+			break;
+		count--;
+	}
+	return res;
+}
+
+/* Safer version of strncpy */
+size_t
+strlcpy(char *dest, const char *src, size_t count)
+{
+	const char *p = src;
+
+	while (count-- && (*dest++ = *src++) != '\0');
+
+	if (count == 0) {
+		*dest = '\0';
+		while (*src++);
+	}
+	return (size_t)(src - p - 1); /* count does not include NULL */
+}
+
+void *
+memcpy(void *dest, const void *src, size_t count)
+{
+	char *tmp = (char *)dest, *s = (char *)src;
+
+	ASSERT(count != 0);
+
+	while (count--)
+		*tmp++ = *s++;
+	return dest;
+}
+
+void *
+memset(void *dest, int ch, size_t count)
+{
+	char *p = (char *)dest;
+
+	ASSERT(count != 0);
+
+	while (count--)
+		*p++ = (char)ch;
+	return dest;
+}
diff --git a/prex-0.9.0/bsp/drv/lib/strtoul.c b/prex-0.9.0/bsp/drv/lib/strtoul.c
new file mode 100755
index 0000000..10eaf82
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/lib/strtoul.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ddi.h>
+#include <machine/limits.h>
+
+/*
+ * Convert a string to an unsigned long integer.
+ *
+ * Ignores `locale' stuff.  Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ *
+ * return ULONG_MAX if error.
+ */
+unsigned long
+strtoul(const char *nptr, char **endptr, int base)
+{
+	const char *s;
+	unsigned long acc, cutoff;
+	int c;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtol for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = (unsigned char) *s++;
+	} while (isspace(c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == '+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == '0' && (*s == 'x' || *s == 'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == '0' ? 8 : 10;
+
+	cutoff = ULONG_MAX / base;
+	cutlim = (int)(ULONG_MAX % (unsigned long)base);
+	for (acc = 0, any = 0;; c = (unsigned char) *s++) {
+		if (isdigit(c))
+			c -= '0';
+		else if (isalpha(c))
+			c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0)
+			continue;
+		if (acc > cutoff || (acc == cutoff && c > cutlim)) {
+			any = -1;
+			acc = ULONG_MAX;
+		} else {
+			any = 1;
+			acc *= (unsigned long)base;
+			acc += c;
+		}
+	}
+	if (neg && any > 0)
+		acc = -acc;
+	if (endptr != 0)
+		/* LINTED interface specification */
+		*endptr = (char *)(any ? s - 1 : nptr);
+	return (acc);
+}
diff --git a/prex-0.9.0/bsp/drv/ppc/arch/driver.ld b/prex-0.9.0/bsp/drv/ppc/arch/driver.ld
new file mode 100755
index 0000000..6e74465
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/ppc/arch/driver.ld
@@ -0,0 +1,34 @@
+/*
+ * Linker script for driver
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-powerpc")
+OUTPUT_ARCH(powerpc)
+ENTRY(driver_main)
+SECTIONS
+{
+	. = SIZEOF_HEADERS ;
+
+	.text . : {
+		*(.text)
+	}
+	. = ALIGN(4);
+	.rodata . : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+	. = ALIGN(4);
+	.data . : {
+		*(.data)
+		*(.sdata)
+		*(.sdata2)
+	}
+	. = ALIGN(4);
+	.bss . : {
+		*(.sbss)
+		*(.bss)
+		*(COMMON)
+	}
+
+	/DISCARD/ : { *(.comment .note .debug_*) }
+}
diff --git a/prex-0.9.0/bsp/drv/ppc/include/busio.h b/prex-0.9.0/bsp/drv/ppc/include/busio.h
new file mode 100755
index 0000000..435bc40
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/ppc/include/busio.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * busio.h - BUS i/o operations
+ */
+
+#ifndef _ARM_BUSIO_H
+#define _ARM_BUSIO_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/* temp!! */
+#define IOBASE	0x80000000
+
+#define bus_read_8(addr)	(*((volatile uint8_t *)(IOBASE+addr)))
+#define bus_read_16(addr)	(*((volatile uint16_t *)(IOBASE+addr)))
+#define bus_read_32(addr)	(*((volatile uint32_t *)(IOBASE+addr)))
+
+#define bus_write_8(addr, val)	(*((volatile uint8_t *)(IOBASE+addr)) = (val))
+#define bus_write_16(addr, val)	(*((volatile uint16_t *)(IOBASE+addr)) = (val))
+#define bus_write_32(addr, val)	(*((volatile uint32_t *)(IOBASE+addr)) = (val))
+
+#endif /* !_ARM_BUSIO_H */
diff --git a/prex-0.9.0/bsp/drv/ppc/include/dkient.h b/prex-0.9.0/bsp/drv/ppc/include/dkient.h
new file mode 100755
index 0000000..200186a
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/ppc/include/dkient.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Stub to call kernel device interface
+ */
+#define STUB(index, func) .global func;\
+ENTRY(func) \
+	lis	r11, dki_table@h; \
+	ori	r11, r11, dki_table@l; \
+	lwz	r11, 0(r11); \
+	li	r0, index * 4; \
+	lwzx	r11, r11, r0; \
+	mtctr	r11; \
+	bctr
diff --git a/prex-0.9.0/bsp/drv/x86/arch/Makefile.inc b/prex-0.9.0/bsp/drv/x86/arch/Makefile.inc
new file mode 100755
index 0000000..db130ca
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/arch/Makefile.inc
@@ -0,0 +1,4 @@
+
+SRCS+=			x86/arch/cpufunc.S \
+			x86/arch/busio.S
+
diff --git a/prex-0.9.0/bsp/drv/x86/arch/busio.S b/prex-0.9.0/bsp/drv/x86/arch/busio.S
new file mode 100755
index 0000000..2bfad38
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/arch/busio.S
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+
+ENTRY(bus_write_8)
+	movl	4(%esp), %edx
+	movl	8(%esp), %eax
+	outb	%al, %dx
+	ret
+
+ENTRY(bus_write_16)
+	movl	4(%esp), %edx
+	movl	8(%esp), %eax
+	outw	%ax, %dx
+	ret
+
+ENTRY(bus_write_32)
+	movl	4(%esp), %edx
+	movl	8(%esp), %eax
+	outl	%eax, %dx
+	ret
+
+ENTRY(bus_read_8)
+	movl	4(%esp), %edx
+	xorl	%eax, %eax
+	inb	%dx, %al
+	ret
+
+ENTRY(bus_read_16)
+	movl	4(%esp), %edx
+	xorl	%eax, %eax
+	inw	%dx, %ax
+	ret
+
+ENTRY(bus_read_32)
+	movl	4(%esp), %edx
+	inl	%dx, %eax
+	ret
+
diff --git a/prex-0.9.0/bsp/drv/x86/arch/cpufunc.S b/prex-0.9.0/bsp/drv/x86/arch/cpufunc.S
new file mode 100755
index 0000000..d98eb1e
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/arch/cpufunc.S
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+
+ENTRY(breakpoint)
+	int	$3
+	ret
+
+ENTRY(rdmsr)
+	movl	4(%esp), %ecx
+	rdmsr
+	movl	8(%esp), %ecx
+	movl	%eax, (%ecx)
+	movl	12(%esp), %ecx
+	movl	%edx, (%ecx)
+	ret
+
+ENTRY(wrmsr)
+	movl	4(%esp), %ecx
+	movl	8(%esp), %eax
+	movl	12(%esp), %edx
+	wrmsr
+	ret
+
+ENTRY(cpuid)
+	pushl	%ebx
+	pushl	%edi
+	movl	12(%esp), %eax
+	movl	16(%esp), %edi
+	cpuid
+	movl	%eax, 0(%edi)
+	movl	%ebx, 4(%edi)
+	movl	%ecx, 8(%edi)
+	movl	%edx, 12(%edi)
+	popl	%edi
+	popl	%ebx
+	ret
diff --git a/prex-0.9.0/bsp/drv/x86/arch/driver.ld b/prex-0.9.0/bsp/drv/x86/arch/driver.ld
new file mode 100755
index 0000000..333cd71
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/arch/driver.ld
@@ -0,0 +1,37 @@
+/*
+ * Linker script for driver
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(driver_main)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = SIZEOF_HEADERS ;
+
+	.text : {
+		*(.text)
+	} : text = 0x9090
+
+	. = ALIGN(32);
+	.rodata : {
+		*(.rodata*)
+		*(.rodata.*)
+	} : text
+
+	. = ALIGN(32);
+	.data : {
+		*(.data*)
+	} : data
+
+	.bss . : {
+		*(.bss*)
+		*(COMMON)
+	}
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/bsp/drv/x86/include/busio.h b/prex-0.9.0/bsp/drv/x86/include/busio.h
new file mode 100755
index 0000000..8f78fa2
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/include/busio.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * busio.h - BUS i/o operations
+ */
+
+#ifndef _X86_BUSIO_H
+#define _X86_BUSIO_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+void	 bus_write_8(int addr, uint8_t val);
+void	 bus_write_16(int addr, uint16_t val);
+void	 bus_write_32(int addr, uint32_t val);
+
+uint8_t	 bus_read_8(int addr);
+uint16_t bus_read_16(int addr);
+uint32_t bus_read_32(int addr);
+__END_DECLS
+
+#endif /* !_X86_BUSIO_H */
diff --git a/prex-0.9.0/bsp/drv/x86/include/cpufunc.h b/prex-0.9.0/bsp/drv/x86/include/cpufunc.h
new file mode 100755
index 0000000..c3c2473
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/include/cpufunc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_CPUFUNC_H
+#define _X86_CPUFUNC_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+void	 wrmsr(u_int, u_int, u_int);
+void	 rdmsr(u_int, u_int *, u_int *);
+void	 cpuid(u_int eax, u_int *p);
+__END_DECLS
+
+#endif	/* !_X86_CPUFUNC_H */
diff --git a/prex-0.9.0/bsp/drv/x86/include/dkient.h b/prex-0.9.0/bsp/drv/x86/include/dkient.h
new file mode 100755
index 0000000..0f640ec
--- /dev/null
+++ b/prex-0.9.0/bsp/drv/x86/include/dkient.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Stub to call kernel device interface
+ */
+#define STUB(index, func) .global func;\
+ENTRY(func) \
+	movl	dki_table, %eax; \
+	add	$(index * 4), %eax; \
+	jmp	*(%eax);
diff --git a/prex-0.9.0/bsp/hal/Makefile b/prex-0.9.0/bsp/hal/Makefile
new file mode 100755
index 0000000..3a3518d
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/Makefile
@@ -0,0 +1,13 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	hal.o
+
+_KERNEL_:=	1
+DEFS+=		KERNEL
+
+include $(CURDIR)/$(ARCH)/$(PLATFORM)/Makefile.inc
+
+INCSDIR+=	$(CURDIR)/$(ARCH)/include \
+		$(SRCDIR)/sys/include
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/bsp/hal/arm/arch/context.c b/prex-0.9.0/bsp/hal/arm/arch/context.c
new file mode 100755
index 0000000..75abe11
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/context.c
@@ -0,0 +1,191 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * context.c - context management routines
+ */
+
+/*
+ * The context consists of kernel/user mode registers, and
+ * kernel stack. The user mode registers are always saved to the
+ * kernel stack when processor enters kernel mode by H/W or S/W events.
+ *
+ * The user mode registers are located in the interrupt/trap frame
+ * at the top of the kernel stack. Before the control returns to user
+ * mode next time, these register value will be restored automatically.
+ *
+ * All thread owns its context to keep its execution state. The
+ * scheduler will switch the context to change an active thread.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <cpu.h>
+#include <context.h>
+#include <locore.h>
+#include <trap.h>
+
+/*
+ * Set data to the specific register stored in context.
+ *
+ * Note: When user mode program counter is set, all register
+ * values except stack pointer are reset to default value.
+ */
+void
+context_set(context_t ctx, int type, register_t val)
+{
+	struct kern_regs *k;
+	struct cpu_regs *u;
+
+	k = &ctx->kregs;
+
+	switch (type) {
+	case CTX_KSTACK:
+		/* Set kernel mode stack pointer */
+		ctx->uregs = (struct cpu_regs *)
+			((vaddr_t)val - sizeof(struct cpu_regs));
+		k->sp = (uint32_t)ctx->uregs;
+
+		/* Reset minimum user mode registers */
+		u = ctx->uregs;
+		u->r0 = 0;
+		u->r1 = 0x11111111;
+		u->r2 = 0x22222222;
+		u->r3 = 0x33333333;
+		u->svc_sp = (uint32_t)val;
+		u->cpsr = PSR_APP_MODE;	/* FIQ/IRQ is enabled */
+		break;
+
+	case CTX_KENTRY:
+		/* Kernel mode program counter */
+		k->lr = (uint32_t)&kernel_thread_entry;
+		k->r4 = (uint32_t)val;
+		break;
+
+	case CTX_KARG:
+		/* Kernel mode argument */
+		k->r5 = (uint32_t)val;
+		break;
+
+	case CTX_USTACK:
+		/* User mode stack pointer */
+		u = ctx->uregs;
+		u->sp = (uint32_t)val;
+		break;
+
+	case CTX_UENTRY:
+		/* User mode program counter */
+		u = ctx->uregs;
+		u->cpsr = PSR_APP_MODE;	/* FIQ/IRQ is enabled */
+		u->pc = (uint32_t)val;
+		u->lr = 0x12345678;
+		break;
+
+	case CTX_UARG:
+		/* User mode argument */
+		u = ctx->uregs;
+		u->r0 = (uint32_t)val;		/* Argument 1 */
+		break;
+
+	default:
+		/* invalid */
+		break;
+	}
+}
+
+/*
+ * Switch to new context
+ *
+ * Kernel mode registers and kernel stack pointer are switched to
+ * the next context.
+ *
+ * It is assumed all interrupts are disabled by caller.
+ *
+ * TODO: FPU context is not switched as of now.
+ */
+void
+context_switch(context_t prev, context_t next)
+{
+
+	cpu_switch(&prev->kregs, &next->kregs);
+}
+
+/*
+ * Save user mode context to handle exceptions.
+ *
+ * Copy current user mode registers in the kernel stack to the user
+ * mode stack. The user stack pointer is adjusted for this area.
+ * So that the exception handler can get the register state of
+ * the target thread.
+ *
+ * It builds arguments for the exception handler in the following
+ * format.
+ *
+ *   void exception_handler(int exc, void *regs);
+ */
+void
+context_save(context_t ctx)
+{
+	struct cpu_regs *cur, *sav;
+
+	/* Copy current register context into user mode stack */
+	cur = ctx->uregs;
+	sav = (struct cpu_regs *)(cur->sp - sizeof(struct cpu_regs));
+	copyout(cur, sav, sizeof(*sav));
+
+	ctx->saved_regs = sav;
+
+	/* Adjust stack pointer */
+	cur->sp = (uint32_t)sav - sizeof(uint32_t);
+}
+
+/*
+ * Restore register context to return from the exception handler.
+ */
+void
+context_restore(context_t ctx)
+{
+	struct cpu_regs *cur;
+
+	/* Restore user mode context */
+	cur = ctx->uregs;
+	copyin(ctx->saved_regs, cur, sizeof(*cur));
+
+	/* Correct some registers for fail safe */
+	cur->cpsr = (cur->cpsr & ~PSR_MODE) | PSR_APP_MODE;
+}
+
+void
+context_dump(context_t ctx)
+{
+
+#ifdef DEBUG
+	trap_dump(ctx->uregs);
+#endif
+}
diff --git a/prex-0.9.0/bsp/hal/arm/arch/cpu.c b/prex-0.9.0/bsp/hal/arm/arch/cpu.c
new file mode 100755
index 0000000..655e249
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/cpu.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpu.c - cpu specific code
+ */
+
+#include <kernel.h>
+#include <cpu.h>
+#include <locore.h>
+#include <cpufunc.h>
+
+void
+cpu_init(void)
+{
+
+}
diff --git a/prex-0.9.0/bsp/hal/arm/arch/cpufunc.S b/prex-0.9.0/bsp/hal/arm/arch/cpufunc.S
new file mode 100755
index 0000000..5db3118
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/cpufunc.S
@@ -0,0 +1,110 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpufunc.S - ARM specific CPU functions
+ */
+
+#include <conf/config.h>
+#include <machine/asm.h>
+#include <cpu.h>
+
+	.section ".text","ax"
+	.code 32
+
+ENTRY(cpu_idle)
+#if 0
+	mcr	p15, 0, r0, c7, c0, 4	/* Wait for interrupt */
+#endif
+	mov	pc, lr
+
+/*
+ * Fault information
+ */
+ENTRY(get_faultstatus)
+	mrc	p15, 0, r0, c5, c0, 0
+	mov	pc, lr
+
+ENTRY(get_faultaddress)
+	mrc	p15, 0, r0, c6, c0, 0
+	mov	pc, lr
+
+
+#ifdef CONFIG_MMU
+/*
+ * Get TTB - Translation Table Base register
+ */
+ENTRY(get_ttb)
+	mrc	p15, 0, r0, c2, c0, 0
+	mov	pc, lr
+
+/*
+ * Set TTB
+ */
+ENTRY(set_ttb)
+	mcr	p15, 0, r0, c2, c0, 0	/* load new TTB */
+	mcr	p15, 0, r0, c8, c7, 0	/* invalidate I+D TLBs */
+	nop
+	nop
+	nop
+	mov	pc, lr
+
+/*
+ * Switch TTB for context switch
+ */
+ENTRY(switch_ttb)
+	mcr	p15, 0, r0, c7, c5, 0	/* flush I cache */
+	mcr	p15, 0, r0, c7, c6, 0	/* flush D cache */
+	mcr	p15, 0, r0, c7, c10, 4	/* drain the write buffer */
+	mcr	p15, 0, r0, c2, c0, 0	/* set the new TTB */
+	mcr	p15, 0, r0, c8, c7, 0	/* and flush the I+D tlbs */
+	nop
+	nop
+	nop
+	mov	pc, lr
+
+/*
+ * Flush TLB
+ */
+ENTRY(flush_tlb)
+	mcr	p15, 0, r0, c8, c7, 0	/* invalidate I+D TLBs */
+	mov	pc, lr
+
+#endif /* !CONFIG_MMU */
+
+/*
+ * Flush all cache
+ */
+ENTRY(flush_cache)
+	mcr	p15, 0, r0, c7, c5, 0	/* flush I cache */
+	mcr	p15, 0, r0, c7, c6, 0	/* flush D cache */
+	mcr	p15, 0, r0, c7, c10, 4	/* drain write buffer */
+	mov	pc, lr
+
+	.end
diff --git a/prex-0.9.0/bsp/hal/arm/arch/kern.ld b/prex-0.9.0/bsp/hal/arm/arch/kern.ld
new file mode 100755
index 0000000..e1a4395
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/kern.ld
@@ -0,0 +1,43 @@
+/*
+ * Linker script for kernel
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(kernel_start)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = CONFIG_KERNEL_TEXT + SIZEOF_HEADERS;
+
+	.text : {
+		*(.text)
+		*(.glue_7)
+		*(.glue_7t)
+	} : text = 0xff
+
+	. = ALIGN(4);
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	} : text
+
+	.data ALIGN(4) : {
+		*(.data)
+	} : data = 0xff
+
+	. = ALIGN(4);
+	__bss = . ;
+	.bss .    : {
+		*(.bss)
+		*(COMMON)
+	}
+	. = ALIGN(4);
+	__end = . ;
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/bsp/hal/arm/arch/locore.S b/prex-0.9.0/bsp/hal/arm/arch/locore.S
new file mode 100755
index 0000000..0988e0f
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/locore.S
@@ -0,0 +1,628 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * locore.S - low level platform support
+ */
+
+#include <conf/config.h>
+#include <machine/asm.h>
+#include <machine/syspage.h>
+#include <machine/memory.h>
+#include <sys/errno.h>
+#include <context.h>
+#include <trap.h>
+#include <cpu.h>
+
+	.section ".text","ax"
+	.code 32
+
+/*
+ * Kernel start point
+ */
+ENTRY(kernel_start)
+#ifdef CONFIG_MMU
+	b	reset_entry		/* Relative jump */
+#endif
+vector_start:
+	/*
+	 * Exception vector
+	 *
+	 * This table will be copied to an appropriate location.
+	 * (the location is platform specific.)
+	 */
+	ldr	pc, reset_target	/* 0x00 mode: svc */
+	ldr	pc, undefined_target	/* 0x04 mode: ? */
+	ldr	pc, swi_target		/* 0x08 mode: svc */
+	ldr	pc, prefetch_target	/* 0x0c mode: abort */
+	ldr	pc, abort_target	/* 0x10 mode: abort */
+	nop				/* 0x14 reserved */
+	ldr	pc, irq_target		/* 0x18 mode: irq */
+	ldr	pc, fiq_target		/* 0x1c mode: fiq */
+
+reset_target:		.word	reset_entry
+undefined_target:	.word	undefined_entry
+swi_target:		.word	syscall_entry
+prefetch_target:	.word	prefetch_entry
+abort_target:		.word	abort_entry
+irq_target:		.word	interrupt_entry
+fiq_target:		.word	fiq_entry
+
+vector_end:
+
+	.global bootinfo
+bootinfo:		.word	BOOTINFO
+boot_stack:		.word	BOOTSTKTOP
+int_stack:		.word	INTSTKTOP - 0x100
+irq_mode_stack:		.word	INTSTKTOP
+sys_mode_stack:		.word	SYSSTKTOP
+abort_mode_stack:	.word	ABTSTKTOP
+irq_nesting:	 	.word	irq_nesting_value
+curspl:	 		.word	curspl_value
+init_done:	 	.word	init_done_value
+#ifdef CONFIG_MMU
+reload_pc_target:	.word	reload_pc
+#endif
+
+ENTRY(reset_entry)
+	/*
+	 * Setup stack pointer for each processor mode
+	 */
+	mov	r0, #(PSR_IRQ_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
+	msr	cpsr, r0
+	ldr	sp, irq_mode_stack	/* Set IRQ mode stack */
+
+	mov	r0, #(PSR_UND_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
+	msr	cpsr, r0
+	ldr	sp, abort_mode_stack	/* Set Undefined mode stack */
+
+	mov	r0, #(PSR_ABT_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
+	msr	cpsr, r0
+	ldr	sp, abort_mode_stack	/* Set Abort mode stack */
+
+	mov	r0, #(PSR_SYS_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
+	msr	cpsr, r0
+	ldr	sp, sys_mode_stack	/* Set SYS mode stack */
+
+	mov	r0, #(PSR_SVC_MODE|PSR_FIQ_DIS|PSR_IRQ_DIS)
+	msr	cpsr, r0
+	ldr	sp, boot_stack		/* Set SVC mode stack */
+
+	/* It's svc mode now. */
+
+#ifdef CONFIG_MMU
+	/*
+	 * Setup control register
+	 */
+	mov	r0, #CTL_DEFAULT
+	mcr	p15, 0, r0, c1, c0, 0
+
+	/*
+	 * Initialize page table
+	 * The physical address 0-4M is mapped on virtual address 2G.
+	 */
+	mov	r1, #BOOT_PGD_PHYS		/* Clear page directory */
+	mov	r2, #(BOOT_PGD_PHYS + 0x4000)	/* +16k */
+	mov	r0, #0
+1:
+	str	r0, [r1], #4
+	teq	r1, r2
+	bne	1b
+
+	mov	r1, #(BOOT_PGD_PHYS + 0x2000) /* Set PTE0 address in pgd */
+	mov	r0, #BOOT_PTE0_PHYS	/* WBUF/CACHE/SYSTEM attribute */
+	orr	r0, r0, #0x03
+	str	r0, [r1]
+
+	mov	r1, #BOOT_PTE0_PHYS	/* Fill boot page table entry */
+	add	r2, r1, #0x1000
+	mov	r0, #0x1e
+1:
+	str	r0, [r1], #4
+	add	r0, r0, #0x1000
+	teq	r1, r2
+	bne	1b
+
+	/*
+	 * Enable paging
+	 * The physical address 0-4M is temporarily mapped to virtial
+	 * address 0-4M. This is needed to enable paging.
+	 */
+	mov	r1, #BOOT_PGD_PHYS	/* Set PTE0 address in pgd */
+	mov	r0, #BOOT_PTE0_PHYS	/* WBUF/CACHE/SYSTEM attribute */
+	orr	r0, r0, #0x03
+	str	r0, [r1]
+
+	mov	r0, #0
+	mcr	p15, 0, r0, c7, c10, 4	/* drain write buffer */
+	mcr	p15, 0, r0, c8, c7, 0	/* flush I,D TLBs */
+	mov	r1, #BOOT_PGD_PHYS
+	mcr	p15, 0, r1, c2, c0, 0	/* load page table pointer */
+	mov	r0, #-1
+	mcr	p15, 0, r0, c3, c0	/* load domain access register */
+	mrc	p15, 0, r0, c1, c0, 0
+	orr	r0, r0, #0x1000		/* I-cache enable */
+	orr	r0, r0, #0x003d		/* Write buffer, mmu */
+	mcr	p15, 0, r0, c1, c0, 0
+
+	/*
+	 * Reload PC register for virutal address.
+	 */
+	ldr	pc, reload_pc_target	/* Reset pc here */
+reload_pc:
+
+	/*
+	 * Unmap 0-4M.
+	 * Since the first page must be accessible for exception
+	 * vector, we have to map it later.
+	 */
+	mov	r1, #BOOT_PGD_PHYS	/* Set PTE0 address in pgd */
+	add	r1, r1, #KERNBASE
+	mov	r0, #0
+	str	r0, [r1]
+	mcr	p15, 0, r0, c8, c7, 0	/* flush I,D TLBs */
+
+#endif /* !CONFIG_MMU */
+
+	/*
+	 * Clear kernel BSS
+	 */
+	ldr	r1, =__bss
+	ldr	r2, =__end
+	mov	r0, #0
+	cmp	r1, r2
+	beq	2f
+1:
+	str	r0, [r1], #4
+	cmp	r1, r2
+	bls	1b
+2:
+
+	/*
+	 * Initilize spl.
+	 */
+	ldr	r1, curspl		/* curspl = 15 */
+	mov	r2, #15
+	str	r2, [r1]
+
+	/*
+	 * Jump to kernel main routine
+	 */
+	b	main
+
+/*
+ * Relocate exception vector
+ *
+ * void vector_copy(vaddr_t dest);
+ */
+ENTRY(vector_copy)
+	ldr	r1, =vector_start
+	ldr	r2, =vector_end
+1:
+	ldmia	r1!, {r3}
+	stmia	r0!, {r3}
+	teq	r1, r2
+	bne	1b
+	mov	pc, lr
+
+#ifdef CONFIG_CACHE
+/*
+ * Enable cache
+ */
+ENTRY(cache_init)
+	mov	pc, lr
+#endif
+
+/*
+ * Interrupt entry point
+ */
+/*
+ * Memo: GBA BIOS interrupt handler.
+ *
+ *	stmfd	sp!, {r0-r3,r12,lr}
+ *	mov	r0, #0x4000000
+ *	adr	lr, IntRet
+ *	ldr	pc, [r0,#-4] @ pc = [0x3007ffc]
+ *IntRet:
+ *	ldmfd	sp!, {r0-r3,r12,lr}
+ *	subs	pc, lr, #4
+ */
+ENTRY(interrupt_entry)
+#ifdef __gba__
+	ldmfd	sp!, {r0-r3,r12,lr}	/* Discard GBA BIOS's stack */
+#endif
+	stmfd	sp, {r0-r4}		/* Save work registers */
+	sub	r4, sp, #(4*5)		/* r4: Pointer to saved registers */
+	mrs	r0, spsr		/* r0: cpsr */
+	sub	r3, lr, #4		/* r3: original pc */
+
+	mrs	r1, cpsr		/* Set processor to SVC mode */
+	bic	r1, r1, #PSR_MODE
+	orr	r1, r1, #PSR_SVC_MODE
+	msr	cpsr_c, r1
+
+	mov	r1, sp			/* r1: svc_sp */
+	mov	r2, lr			/* r2: svc_lr */
+	stmfd	sp!, {r0-r3}		/* Push cpsr, svc_sp, svc_lr, pc */
+	ldmfd	r4, {r0-r4}		/* Restore work registers */
+	sub	sp, sp, #(4*15)
+	stmia	sp, {r0-r14}^		/* Push r0-r14 */
+	nop				/* Instruction gap for stm^ */
+
+	ldr	r4, irq_nesting   	/* Increment IRQ nesting level */
+	ldr	r5, [r4]		/* r5: Previous nesting level */
+	add	r0, r5, #1
+ 	str	r0, [r4]
+
+	mov	r7, sp			/* Save stack */
+	ldr	r3, int_stack		/* Adjust stack for IRQ */
+	cmp	r5, #0			/* Outermost interrupt? */
+	moveq	sp, r3			/* If outermost, switch stack */
+	bleq	sched_lock		/* If outermost, lock scheduler */
+	bl	interrupt_handler	/* Call main interrupt handler */
+
+	mov	sp, r7			/* Restore stack */
+	str	r5, [r4]		/* Restore IRQ nesting level */
+	cmp	r5, #0			/* Outermost interrupt? */
+	bne	interrupt_ret
+	bl	sched_unlock		/* Try to preempt */
+
+	ldr	r0, [sp, #REG_CPSR]	/* Get previous mode */
+	and	r0, r0, #PSR_MODE
+	cmp	r0, #PSR_APP_MODE	/* Return to application mode? */
+	bne	interrupt_ret
+
+	mrs	r5, cpsr		/* Enable IRQ */
+	bic	r4, r5, #0xc0
+	msr	cpsr_c, r4
+	bl	exception_deliver	/* Check exception */
+	msr	cpsr_c, r5		/* Restore IRQ */
+interrupt_ret:
+	mov	r0, sp
+ 	ldr	r1, [r0, #REG_CPSR]	/* Restore spsr */
+ 	msr	spsr_all, r1
+ 	ldmfd	r0, {r0-r14}^		/* Restore user mode registers */
+	nop				/* Instruction gap for ldm^ */
+	add	sp, sp, #(4*16)
+	ldmia	sp, {sp, lr, pc}^	/* Restore lr and exit */
+
+/*
+ * System call entry
+ */
+	.global syscall_ret
+ENTRY(syscall_entry)
+#ifdef __gba__
+	mov	r5, lr			/* Syscall stub already saved r5 */
+	mrs	r12, cpsr		/* Set processor to SVC mode */
+	bic	r12, r12, #PSR_MODE
+	orr	r12, r12, #PSR_SVC_MODE
+	msr	cpsr_c, r12
+	mov	lr, r5
+#endif
+	sub	sp, sp, #CTXREGS	/* Adjust stack */
+	stmia	sp, {r0-r14}^		/* Push r0-r14 */
+	nop				/* Instruction gap for stm^ */
+	mrs	r5, spsr		/* Push cpsr */
+	str	r5, [sp, #REG_CPSR]
+	add	r5, sp, #CTXREGS
+	str	r5, [sp, #REG_SVCSP]	/* Push svc_sp */
+	str	lr, [sp, #REG_SVCLR]	/* Push svc_lr */
+	str	lr, [sp, #REG_PC]	/* Push pc */
+#ifndef __gba__
+	ldr	r4, [lr, #-4]		/* Get SWI number */
+	bic	r4, r4, #0xff000000
+
+	mrs	r5, cpsr		/* Enable IRQ */
+	bic	r5, r5, #0xc0
+	msr	cpsr_c, r5
+#endif
+
+	stmfd	sp!, {r4}
+	bl	syscall_handler		/* System call dispatcher */
+	ldmfd	sp!, {r4}
+
+	cmp	r4, #0			/* Skip storing error if exception_return */
+	strne	r0, [sp]		/* Set return value to r0 */
+	bl	exception_deliver	/* Check exception */
+syscall_ret:
+	mrs	r5, cpsr		/* Disable IRQ */
+	orr	r5, r5, #0xc0
+	msr	cpsr_c, r5
+	mov	r5, sp
+	ldr	r1, [r5, #REG_CPSR]	/* Restore spsr */
+	msr	spsr_all, r1
+ 	ldmfd	r5, {r0-r14}^		/* Restore user mode registers */
+	nop				/* Instruction gap for ldm^ */
+	add	sp, sp, #REG_SVCSP
+	ldmia	sp, {sp, lr, pc}^	/* Restore lr and exit */
+
+/*
+ * Undefined instruction
+ */
+ENTRY(undefined_entry)
+	sub	sp, sp, #CTXREGS	/* Adjust stack */
+	stmia	sp, {r0-r14}^		/* Push r0-r14 */
+	nop				/* Instruction gap for stm^ */
+	mov	r0, #TRAP_UNDEFINED
+	b	trap_common
+
+/*
+ * Prefetch abort
+ */
+ENTRY(prefetch_entry)
+	sub	lr, lr, #8		/* Adjust the lr */
+	sub	sp, sp, #CTXREGS	/* Adjust stack */
+	stmia	sp, {r0-r14}^		/* Push r0-r14 */
+	nop				/* Instruction gap for stm^ */
+	mov	r0, #TRAP_PREFETCH_ABORT
+	b	trap_common
+
+/*
+ * Data abort
+ */
+ENTRY(abort_entry)
+	sub	lr, lr, #4		/* Adjust the lr */
+	sub	sp, sp, #CTXREGS	/* Adjust stack */
+	stmia	sp, {r0-r14}^		/* Push r0-r14 */
+	nop				/* Instruction gap for stm^ */
+	mov	r0, #TRAP_DATA_ABORT
+	b	trap_common
+
+/*
+ * Common entry for all traps
+ * r0 - trap type
+ */
+ENTRY(trap_common)
+	add	r5, sp, #CTXREGS
+	str	r5, [sp, #REG_SVCSP]	/* Push svc_sp */
+	str	lr, [sp, #REG_PC]	/* Push pc */
+	mrs	r5, spsr		/* Push cpsr */
+	str	r5, [sp, #REG_CPSR]
+
+	str	r0, [sp, #REG_R0]	/* Set trap type to R0 */
+	mov	r0, sp
+	bl	trap_handler
+
+	mov	r5, sp
+	ldr	r1, [r5, #REG_CPSR]	/* Restore cpsr */
+	msr	spsr_all, r1
+	ldr	lr, [r5, #REG_PC]	/* Restore pc (lr) */
+	ldr	sp, [r5, #REG_SVCSP]	/* Restore svc_sp */
+	ldmfd	r5, {r0-r14}^		/* Restore user mode registers */
+	nop				/* Instruction gap for ldm^ */
+	movs	pc, lr			/* Exit, with restoring cpsr */
+
+ENTRY(fiq_entry)
+	b	fiq_entry		/* Not support... */
+
+/*
+ * Switch register context.
+ * r0 = previous kern_regs, r1 = next kern_regs
+ * Interrupts must be disabled by caller.
+ *
+ * syntax - void cpu_switch(kern_regs *prev, kern_regs *next)
+ *
+ * Note: GCC uses r0-r3,r12 as scratch registers
+ */
+ENTRY(cpu_switch)
+	stmia	r0, {r4-r11, sp, lr}	/* Save previous register context */
+	ldmia	r1, {r4-r11, sp, pc}	/* Restore next register context */
+
+/*
+ * Entry point for kernel thread
+ */
+ENTRY(kernel_thread_entry)
+	mov	r0, r5			/* Set argument */
+	mov	pc, r4			/* Jump to kernel thread */
+1:
+	b	1b
+
+
+/*
+ * Copy data from user to kernel space.
+ * Returns 0 on success, or EFAULT on page fault.
+ *
+ *  syntax - int copyin(const void *uaddr, void *kaddr, size_t len)
+ */
+	.global known_fault1
+ENTRY(copyin)
+ 	mov	r12, sp
+ 	stmdb	sp!, {r4, r11, r12, lr, pc}
+ 	sub	r11, r12, #4
+	cmp	r0, #(USERLIMIT)
+	bhi	copy_fault
+ 	mov	r12, #0
+ 	b	2f
+1:
+	ldrb	r3, [r12, r0]
+known_fault1:				/* May be fault here */
+ 	strb	r3, [r12, r1]
+ 	add	r12, r12, #1
+2:
+	subs	r2, r2, #1
+ 	bcs	1b
+	mov	r0, #0			/* Set no error */
+ 	ldmia	sp, {r4, r11, sp, pc}
+
+/*
+ * Copy data to user from kernel space.
+ * Returns 0 on success, or EFAULT on page fault.
+ *
+ *  syntax - int copyout(const void *kaddr, void *uaddr, size_t len)
+ */
+	.global known_fault2
+ENTRY(copyout)
+ 	mov	r12, sp
+ 	stmdb	sp!, {r4, r11, r12, lr, pc}
+ 	sub	r11, r12, #4
+	cmp	r1, #(USERLIMIT)
+	bhi	copy_fault
+ 	mov	r12, #0
+ 	b	2f
+1:
+	ldrb	r3, [r12, r0]
+known_fault2:				/* May be fault here */
+ 	strb	r3, [r12, r1]
+ 	add	r12, r12, #1
+2:
+	subs	r2, r2, #1
+ 	bcs	1b
+	mov	r0, #0			/* Set no error */
+ 	ldmia	sp, {r4, r11, sp, pc}
+
+/*
+ * copyinstr - Copy string from user space.
+ * Returns 0 on success, or EFAULT on page fault, or ENAMETOOLONG.
+ *
+ *  syntax - int copyinstr(const char *uaddr, void *kaddr, size_t len);
+ */
+	.global known_fault3
+ENTRY(copyinstr)
+ 	mov	r12, sp
+ 	stmdb	sp!, {r4, r11, r12, lr, pc}
+ 	sub	r11, r12, #4
+	cmp	r0, #(USERLIMIT)
+	bhi	copy_fault
+ 	mov	r12, #0
+ 	b	2f
+1:
+	ldrb	r3, [r12, r0]
+known_fault3:				/* May be fault here */
+ 	strb	r3, [r12, r1]
+	cmp	r3, #0
+	beq	3f
+ 	add	r12, r12, #1
+2:
+	subs	r2, r2, #1
+ 	bcs	1b
+	mov	r0, #(ENAMETOOLONG)
+	b	4f
+3:
+	mov	r0, #0			/* Set no error */
+4:
+ 	ldmia	sp, {r4, r11, sp, pc}
+
+/*
+ * Fault entry for user access
+ */
+ENTRY(copy_fault)
+	mov	r0, #(EFAULT)
+ 	ldmia	sp, {r4, r11, sp, pc}
+
+
+/*
+ * int spl0(void);
+ */
+ENTRY(spl0)
+	ldr	r1, curspl		/* curspl = 0 */
+	ldr	r0, [r1]
+	mov	r2, #0
+	str	r2, [r1]
+
+	mrs	r1, cpsr		/* Enable interrupt */
+	bic	r1, r1, #0xc0
+	msr	cpsr_c, r1
+	mov	pc, lr
+
+/*
+ * int splhigh(void);
+ */
+ENTRY(splhigh)
+	mrs	r1, cpsr		/* Disable interrupt */
+	orr	r1, r1, #0xc0
+	msr	cpsr_c, r1
+
+	ldr	r1, curspl		/* curspl = 15 */
+	ldr	r0, [r1]
+	mov	r2, #15
+	str	r2, [r1]
+	mov	pc, lr
+
+/*
+ * void splx(int s);
+ */
+ENTRY(splx)
+	mov	r3, r0			/* r3: new spl */
+	ldr	r1, curspl
+	ldr	r0, [r1]
+	cmp	r3, r0
+	moveq	pc, lr			/* Return if equal */
+	str	r3, [r1]
+
+	cmp	r3, #0
+	mrs	r1, cpsr
+	bic	r1, r1, #0xc0
+	orrne	r1, r1, #0xc0		/* Disable interrupt if curspl != 0 */
+	msr	cpsr_c, r1
+	mov	pc, lr
+
+
+/*
+ * void sploff(void);
+ */
+ENTRY(sploff)
+	mrs	r0, cpsr
+	orr	r0, r0, #0xc0
+	msr	cpsr_c, r0
+	mov	pc, lr
+
+/*
+ * void splon(void);
+ */
+ENTRY(splon)
+	mrs	r0, cpsr
+	bic	r0, r0, #0xc0
+	msr	cpsr_c, r0
+	mov	pc, lr
+
+/*
+ * Interrupt nest counter.
+ *
+ * This counter is incremented in the entry of interrupt handler
+ * to switch the interrupt stack. Since all interrupt handlers
+ * share same one interrupt stack, each handler must pay attention
+ * to the stack overflow.
+ */
+	.section ".bss"
+irq_nesting_value:
+	.long	0
+
+/*
+ * Current spl
+ */
+curspl_value:
+	.long	0
+
+/*
+ * Init flag for debug
+ */
+init_done_value:
+	.long	0
+
+	.end
diff --git a/prex-0.9.0/bsp/hal/arm/arch/mmu.c b/prex-0.9.0/bsp/hal/arm/arch/mmu.c
new file mode 100755
index 0000000..84f2ec8
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/mmu.c
@@ -0,0 +1,325 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mmu.c - memory management unit support routines
+ */
+
+/*
+ * This module provides virtual/physical address translation for
+ * ARM MMU. This kernel will do only page level translation
+ * and protection and it does not use ARM protection domain.
+ */
+
+#include <machine/syspage.h>
+#include <kernel.h>
+#include <page.h>
+#include <mmu.h>
+#include <cpu.h>
+#include <cpufunc.h>
+
+#define L1TBL_MASK	(L1TBL_SIZE - 1)
+#define PGD_ALIGN(n)	((((paddr_t)(n)) + L1TBL_MASK) & ~L1TBL_MASK)
+
+/*
+ * Boot page directory.
+ * This works as a template for all page directory in the system.
+ */
+static pgd_t boot_pgd = (pgd_t)BOOT_PGD;
+
+/*
+ * Allocate pgd
+ *
+ * The page directory for ARM must be aligned in 16K bytes
+ * boundary. So, we allocates 32K bytes first, and use
+ * 16K-aligned area in it.
+ */
+static paddr_t
+alloc_pgd(void)
+{
+	paddr_t pg, pgd;
+	size_t gap;
+
+	/* Allocate 32K first. */
+	if ((pg = page_alloc(L1TBL_SIZE * 2)) == 0)
+		return 0;
+
+	/* Find 16K aligned pointer */
+	pgd = PGD_ALIGN(pg);
+
+	/* Release un-needed area */
+	gap = (size_t)(pgd - pg);
+	if (gap != 0)
+		page_free(pg, gap);
+	page_free((paddr_t)(pgd + L1TBL_SIZE), (size_t)(L1TBL_SIZE - gap));
+
+	return pgd;
+}
+
+/*
+ * Map physical memory range into virtual address
+ *
+ * Returns 0 on success, or ENOMEM on failure.
+ *
+ * Map type can be one of the following type.
+ *   PG_UNMAP  - Remove mapping
+ *   PG_READ   - Read only mapping
+ *   PG_WRITE  - Read/write allowed
+ *   PG_SYSTEM - Kernel page
+ *   PG_IO     - I/O memory
+ *
+ * Setup the appropriate page tables for mapping. If there is no
+ * page table for the specified address, new page table is
+ * allocated.
+ *
+ * This routine does not return any error even if the specified
+ * address has been already mapped to other physical address.
+ * In this case, it will just override the existing mapping.
+ *
+ * In order to unmap the page, pg_type is specified as 0.  But,
+ * the page tables are not released even if there is no valid
+ * page entry in it. All page tables are released when mmu_delmap()
+ * is called when task is terminated.
+ */
+int
+mmu_map(pgd_t pgd, paddr_t pa, vaddr_t va, size_t size, int type)
+{
+	uint32_t pte_flag = 0;
+	pte_t pte;
+	paddr_t pg;	/* page */
+
+	pa = round_page(pa);
+	va = round_page(va);
+	size = trunc_page(size);
+
+	/*
+	 * Set page flag
+	 */
+	switch (type) {
+	case PG_UNMAP:
+		pte_flag = 0;
+		break;
+	case PG_READ:
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_WBUF | PTE_CACHE |
+				      PTE_USER_RO);
+		break;
+	case PG_WRITE:
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_WBUF | PTE_CACHE |
+				      PTE_USER_RW);
+		break;
+	case PG_SYSTEM:
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_WBUF | PTE_CACHE |
+				      PTE_SYSTEM);
+		break;
+	case PG_IOMEM:
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_SYSTEM);
+		break;
+	default:
+		panic("mmu_map");
+	}
+	/*
+	 * Map all pages
+	 */
+	flush_tlb();
+
+	while (size > 0) {
+		if (pte_present(pgd, va)) {
+			/* Page table already exists for the address */
+			pte = vtopte(pgd, va);
+		} else {
+			ASSERT(pte_flag != 0);
+			if ((pg = page_alloc(L2TBL_SIZE)) == 0) {
+				DPRINTF(("Error: MMU mapping failed\n"));
+				return ENOMEM;
+			}
+			pgd[PAGE_DIR(va)] = (uint32_t)pg | PDE_PRESENT;
+			pte = (pte_t)ptokv(pg);
+			memset(pte, 0, L2TBL_SIZE);
+		}
+		/* Set new entry into page table */
+		pte[PAGE_TABLE(va)] = (uint32_t)pa | pte_flag;
+
+		/* Process next page */
+		pa += PAGE_SIZE;
+		va += PAGE_SIZE;
+		size -= PAGE_SIZE;
+	}
+	flush_tlb();
+	return 0;
+}
+
+/*
+ * Create new page map.
+ *
+ * Returns a page directory on success, or NULL on failure.  This
+ * routine is called when new task is created. All page map must
+ * have the same kernel page table in it. So, the kernel page
+ * tables are copied to newly created map.
+ */
+pgd_t
+mmu_newmap(void)
+{
+	paddr_t pg;
+	pgd_t pgd;
+	int i;
+
+	if ((pg = alloc_pgd()) == 0)
+		return NO_PGD;
+	pgd = (pgd_t)ptokv(pg);
+	memset(pgd, 0, L1TBL_SIZE);
+
+	/* Copy kernel page tables */
+	i = PAGE_DIR(KERNBASE);
+	memcpy(&pgd[i], &boot_pgd[i], (size_t)(L1TBL_SIZE - i * 4));
+
+	/* Map vector page (address 0) */
+	mmu_map(pgd, 0, 0, PAGE_SIZE, PG_SYSTEM);
+	return pgd;
+}
+
+/*
+ * Terminate all page mapping.
+ */
+void
+mmu_terminate(pgd_t pgd)
+{
+	int i;
+	pte_t pte;
+
+	flush_tlb();
+
+	/* Release all user page table */
+	for (i = 0; i < PAGE_DIR(KERNBASE); i++) {
+		pte = (pte_t)pgd[i];
+		if (pte != 0)
+			page_free(((paddr_t)pte & PTE_ADDRESS),
+				  L2TBL_SIZE);
+	}
+	/* Release page directory */
+	page_free(kvtop(pgd), L1TBL_SIZE);
+}
+
+/*
+ * Switch to new page directory
+ *
+ * This is called when context is switched.
+ * Whole TLB/cache must be flushed after loading
+ * TLTB register
+ */
+void
+mmu_switch(pgd_t pgd)
+{
+	paddr_t phys = kvtop(pgd);
+
+	if (phys != get_ttb())
+		switch_ttb(phys);
+}
+
+/*
+ * Returns the physical address for the specified virtual address.
+ * This routine checks if the virtual area actually exist.
+ * It returns NULL if at least one page is not mapped.
+ */
+paddr_t
+mmu_extract(pgd_t pgd, vaddr_t virt, size_t size)
+{
+	pte_t pte;
+	vaddr_t start, end, pg;
+	paddr_t pa;
+
+	start = trunc_page(virt);
+	end = trunc_page(virt + size - 1);
+
+	/* Check all pages exist */
+	for (pg = start; pg <= end; pg += PAGE_SIZE) {
+		if (!pte_present(pgd, pg))
+			return 0;
+		pte = vtopte(pgd, pg);
+		if (!page_present(pte, pg))
+			return 0;
+	}
+
+	/* Get physical address */
+	pte = vtopte(pgd, start);
+	pa = (paddr_t)ptetopg(pte, start);
+	return pa + (paddr_t)(virt - start);
+}
+
+/*
+ * Map I/O memory for diagnostic device at very early stage.
+ */
+void
+mmu_premap(paddr_t phys, vaddr_t virt)
+{
+	pte_t pte = (pte_t)BOOT_PTE1;
+
+	memset(pte, 0, L2TBL_SIZE);
+	boot_pgd[PAGE_DIR(virt)] = (uint32_t)kvtop(pte) | PDE_PRESENT;
+	pte[PAGE_TABLE(virt)] = (uint32_t)phys | PTE_PRESENT | PTE_SYSTEM;
+	flush_tlb();
+}
+
+/*
+ * Initialize mmu
+ *
+ * Paging is already enabled in locore.S. And, physical address
+ * 0-4M has been already mapped into kernel space in locore.S.
+ * Now, all physical memory is mapped into kernel virtual address
+ * as straight 1:1 mapping. User mode access is not allowed for
+ * these kernel pages.
+ * page_init() must be called before calling this routine.
+ */
+void
+mmu_init(struct mmumap *mmumap_table)
+{
+	struct mmumap *map;
+	int map_type = 0;
+
+	for (map = mmumap_table; map->type != 0; map++) {
+		switch (map->type) {
+		case VMT_RAM:
+		case VMT_ROM:
+		case VMT_DMA:
+			map_type = PG_SYSTEM;
+			break;
+		case VMT_IO:
+			map_type = PG_IOMEM;
+			break;
+		}
+
+		if (mmu_map(boot_pgd, map->phys, map->virt,
+			    map->size, map_type))
+			panic("mmu_init");
+	}
+	/*
+	 * Map vector page.
+	 */
+	if (mmu_map(boot_pgd, 0, CONFIG_ARM_VECTORS, PAGE_SIZE, PG_SYSTEM))
+		panic("mmu_init");
+}
diff --git a/prex-0.9.0/bsp/hal/arm/arch/trap.c b/prex-0.9.0/bsp/hal/arm/arch/trap.c
new file mode 100755
index 0000000..1df4c8a
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/arch/trap.c
@@ -0,0 +1,124 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * trap.c - called from the abort handler when a processor detect abort.
+ */
+
+#include <sys/signal.h>
+#include <kernel.h>
+#include <task.h>
+#include <hal.h>
+#include <exception.h>
+#include <cpu.h>
+#include <trap.h>
+#include <cpufunc.h>
+#include <context.h>
+#include <locore.h>
+
+#ifdef DEBUG
+/*
+ * Trap name
+ */
+static char *const trap_name[] = {
+	"Undefined Instruction",
+	"Prefetch Abort",
+	"Data Abort"
+};
+#define MAXTRAP (sizeof(trap_name) / sizeof(void *) - 1)
+#endif	/* !DEBUG */
+
+/*
+ * abort/exception mapping table.
+ * ARM exception is translated to the architecture
+ * independent exception code.
+ */
+static const int exception_map[] = {
+	SIGILL,		/* Undefined instruction */
+	SIGSEGV,	/* Prefech abort */
+	SIGSEGV,	/* Data abort */
+};
+
+/*
+ * Trap handler
+ * Invoke the exception handler if it is needed.
+ */
+void
+trap_handler(struct cpu_regs *regs)
+{
+	u_long trap_no = regs->r0;
+
+	if ((regs->cpsr & PSR_MODE) == PSR_SVC_MODE &&
+	    trap_no == TRAP_DATA_ABORT &&
+	    (regs->pc - 4 == (uint32_t)known_fault1 ||
+	     regs->pc - 4 == (uint32_t)known_fault2 ||
+	     regs->pc - 4 == (uint32_t)known_fault3)) {
+		DPRINTF(("\n*** Detect Fault! address=%x task=%s ***\n",
+			 get_faultaddress(), curtask->name));
+		regs->pc = (uint32_t)copy_fault;
+		return;
+	}
+#ifdef DEBUG
+	printf("=============================\n");
+	printf("Trap %x: %s\n", (u_int)trap_no, trap_name[trap_no]);
+	if (trap_no == TRAP_DATA_ABORT)
+		printf(" Fault address=%x\n", get_faultaddress());
+	else if (trap_no == TRAP_PREFETCH_ABORT)
+		printf(" Fault address=%x\n", regs->pc);
+	printf("=============================\n");
+
+	trap_dump(regs);
+	for (;;) ;
+#endif
+	if ((regs->cpsr & PSR_MODE) != PSR_USR_MODE)
+		panic("Kernel exception");
+
+	exception_mark(exception_map[trap_no]);
+	exception_deliver();
+}
+
+#ifdef DEBUG
+void
+trap_dump(struct cpu_regs *r)
+{
+
+	printf("Trap frame %x\n", r);
+	printf(" r0  %08x r1  %08x r2  %08x r3  %08x r4  %08x r5  %08x\n",
+	       r->r0, r->r1, r->r2, r->r3, r->r4, r->r5);
+	printf(" r6  %08x r7  %08x r8  %08x r9  %08x r10 %08x r11 %08x\n",
+	       r->r6, r->r7, r->r8, r->r9, r->r10, r->r11);
+	printf(" r12 %08x sp  %08x lr  %08x pc  %08x cpsr %08x\n",
+	       r->r12, r->sp, r->lr, r->pc, r->cpsr);
+
+	printf(" >> interrupt is %s\n",
+	       (r->cpsr & PSR_INT_MASK) ? "disabled" : "enabled");
+
+	printf(" >> task=%s\n", curtask->name);
+}
+#endif /* !DEBUG */
diff --git a/prex-0.9.0/bsp/hal/arm/gba/Makefile.inc b/prex-0.9.0/bsp/hal/arm/gba/Makefile.inc
new file mode 100755
index 0000000..616a97e
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/Makefile.inc
@@ -0,0 +1,14 @@
+
+SRCS:=		arm/arch/locore.S \
+		arm/gba/locore_gba.S \
+		arm/arch/cpufunc.S \
+		arm/arch/cpu.c \
+		arm/arch/trap.c \
+		arm/arch/context.c \
+		arm/gba/interrupt.c \
+		arm/gba/clock.c \
+		arm/gba/machdep.c
+
+ifeq ($(DEBUG),1)
+SRCS+=		arm/gba/diag.c
+endif
diff --git a/prex-0.9.0/bsp/hal/arm/gba/clock.c b/prex-0.9.0/bsp/hal/arm/gba/clock.c
new file mode 100755
index 0000000..ec97f5a
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/clock.c
@@ -0,0 +1,102 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * clock.c - clock driver
+ */
+
+#include <sys/ipl.h>
+#include <kernel.h>
+#include <timer.h>
+#include <irq.h>
+#include <cpufunc.h>
+
+
+/* Interrupt vector for timer (TMR0 of GBA) */
+#define CLOCK_IRQ	3
+
+/* The clock rate per second ... 2^24 */
+#define CLOCK_RATE	16777216L
+
+/* The initial counter value */
+#define TIMER_COUNT	(0xffff - (CLOCK_RATE / 64 / HZ))
+
+/* GBA timer registers */
+#define TMR0_COUNT	(*(volatile uint16_t *)0x4000100)
+#define TMR0_CTRL	(*(volatile uint16_t *)0x4000102)
+
+/* Timer frequency */
+#define TMR_1_CLOCK	0x0000
+#define TMR_64_CLOCK	0x0001
+#define TMR_256_CLOCK	0x0002
+#define TMR_1024_CLOCK	0x0003
+
+/* Cascade switch */
+#define TMR_CASCADE	0x0004
+
+/* Interrupt for overflow */
+#define	TMR_IRQEN	0x0040
+
+/* Timer switch */
+#define TMR_EN		0x0080
+
+/*
+ * Clock interrupt service routine.
+ * No H/W reprogram is required.
+ */
+static int
+clock_isr(void *arg)
+{
+
+	splhigh();
+	timer_handler();
+	spl0();
+	return INT_DONE;
+}
+
+/*
+ * Initialize clock H/W chip.
+ * Setup clock tick rate and install clock ISR.
+ */
+void
+clock_init(void)
+{
+	irq_t clock_irq;
+
+	/* Setup counter value */
+	TMR0_COUNT = TIMER_COUNT;
+	TMR0_CTRL = (uint16_t)(TMR_IRQEN | TMR_64_CLOCK);
+
+	/* Install ISR */
+	clock_irq = irq_attach(CLOCK_IRQ, IPL_CLOCK, 0, &clock_isr,
+			       IST_NONE, NULL);
+
+	/* Enable timer */
+	TMR0_CTRL |= TMR_EN;
+}
diff --git a/prex-0.9.0/bsp/hal/arm/gba/diag.c b/prex-0.9.0/bsp/hal/arm/gba/diag.c
new file mode 100755
index 0000000..dc42650
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/diag.c
@@ -0,0 +1,196 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * diag.c - diagnostic message support
+ */
+
+#include <sys/bootinfo.h>
+#include <kernel.h>
+#include <cpufunc.h>
+
+#ifdef CONFIG_DIAG_SCREEN
+
+#include "font.h"
+
+#define VSCR_COLS	32
+#define SCR_COLS	30
+#define SCR_ROWS	20
+
+/* Registers for keypad control */
+#define REG_DISPCNT	(*(volatile u_short *)0x4000000)
+#define REG_BG0CNT	(*(volatile u_short *)0x4000008)
+
+#define BG_PALETTE	(u_short *)0x5000000
+#define VRAM_TILE	(u_short *)0x6000000
+#define VRAM_MAP	(u_short *)0x6008000
+
+#define	RGB(r, g, b)	(((b) << 10) + ((g) << 5) + (r))
+
+static u_short *vram = VRAM_MAP;
+static int pos_x;
+static int pos_y;
+
+static void
+screen_scroll_up(void)
+{
+	int i;
+
+	for (i = 0; i < VSCR_COLS * (SCR_ROWS - 1); i++)
+		vram[i] = vram[i + VSCR_COLS];
+	for (i = 0; i < VSCR_COLS; i++)
+		vram[VSCR_COLS * (SCR_ROWS - 1) + i] = ' ';
+}
+
+static void
+screen_newline(void)
+{
+
+	pos_x = 0;
+	pos_y++;
+	if (pos_y >= SCR_ROWS) {
+		pos_y = SCR_ROWS - 1;
+		screen_scroll_up();
+	}
+}
+
+static void
+screen_putc(char c)
+{
+
+	switch (c) {
+	case '\n':
+		screen_newline();
+		return;
+	case '\r':
+		pos_x = 0;
+		return;
+	case '\b':
+		if (pos_x == 0)
+			return;
+		pos_x--;
+		return;
+	}
+	vram[pos_y * VSCR_COLS + pos_x] = c;
+	pos_x++;
+	if (pos_x >= SCR_COLS) {
+		pos_x = 0;
+		pos_y++;
+		if (pos_y >= SCR_ROWS) {
+			pos_y = SCR_ROWS - 1;
+			screen_scroll_up();
+		}
+	}
+}
+
+/*
+ * Init font
+ */
+static void
+screen_init_font(void)
+{
+	int i, row, col, bit, val = 0;
+	u_short *tile = VRAM_TILE;
+
+	for (i = 0; i < 256; i++) {
+		for (row = 0; row < 8; row++) {
+			for (col = 7; col >= 0; col--) {
+				bit = (font_bitmap[i][row] &
+				       (1 << col)) ? 2 : 1;
+				if (col % 2)
+					val = bit;
+				else {
+					tile[(i * 32) +
+					     (row * 4) + ((7 - col) / 2)] =
+						val + (bit << 8);
+				}
+			}
+		}
+	}
+}
+
+/*
+ * Init screen
+ */
+static void
+screen_init_screen(void)
+{
+	u_short *pal = BG_PALETTE;
+
+	/* Initialize palette */
+	pal[0] = 0;		/* Transparent */
+	pal[1] = RGB(0,0,0);	/* Black */
+	pal[2] = RGB(31,31,31);	/* White */
+
+	/* Setup video */
+	REG_DISPCNT = 0x0100;	/* Mode0, BG0 */
+	REG_BG0CNT = 0x1080;	/* Size0, 256color */
+}
+
+void
+diag_puts(char *buf)
+{
+
+	while (*buf)
+		screen_putc(*buf++);
+}
+
+/*
+ * Init
+ */
+void
+diag_init(void)
+{
+
+	screen_init_font();
+	screen_init_screen();
+}
+
+#endif	/* !CONFIG_DIAG_SCREEN */
+
+
+#ifdef CONFIG_DIAG_VBA
+extern void vba_puts(char *);
+
+void
+diag_puts(char *str)
+{
+
+	vba_puts(str);
+}
+
+/*
+ * Init
+ */
+void
+diag_init(void)
+{
+
+}
+#endif	/* !CONFIG_DIAG_VBA */
diff --git a/prex-0.9.0/bsp/hal/arm/gba/font.h b/prex-0.9.0/bsp/hal/arm/gba/font.h
new file mode 100755
index 0000000..f8a0102
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/font.h
@@ -0,0 +1,163 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * font.h - minimum font for GBA
+ */
+
+const unsigned char font_bitmap[][8] = {
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00,},
+	{0x6C, 0x6C, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00,},
+	{0x10, 0x7C, 0xD0, 0x7C, 0x16, 0x7C, 0x10, 0x00,},
+	{0x62, 0x66, 0x0C, 0x18, 0x30, 0x66, 0x46, 0x00,},
+	{0x38, 0x6C, 0x68, 0x76, 0xDC, 0xCC, 0x76, 0x00,},
+	{0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x0C, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00,},
+	{0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00,},
+	{0x00, 0x6C, 0x38, 0xFE, 0x38, 0x6C, 0x00, 0x00,},
+	{0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x10,},
+	{0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,},
+	{0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00,},
+	{0x3C, 0x66, 0x6E, 0x76, 0x66, 0x66, 0x3C, 0x00,},
+	{0x18, 0x18, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00,},
+	{0x7C, 0x06, 0x06, 0x3C, 0x60, 0x60, 0x7E, 0x00,},
+	{0x7C, 0x06, 0x06, 0x1C, 0x06, 0x06, 0x7C, 0x00,},
+	{0x66, 0x66, 0x66, 0x7E, 0x06, 0x06, 0x06, 0x00,},
+	{0x7E, 0x60, 0x60, 0x7C, 0x06, 0x06, 0x7C, 0x00,},
+	{0x3E, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00,},
+	{0x7E, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00,},
+	{0x3C, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x7C, 0x00,},
+	{0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00,},
+	{0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x10,},
+	{0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x00,},
+	{0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00,},
+	{0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x00,},
+	{0x3C, 0x66, 0x06, 0x1C, 0x18, 0x00, 0x18, 0x00,},
+	{0x3C, 0x66, 0x6E, 0x6E, 0x6E, 0x60, 0x3E, 0x00,},
+	{0x3C, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00,},
+	{0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 0x00,},
+	{0x3C, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3C, 0x00,},
+	{0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00,},
+	{0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x7E, 0x00,},
+	{0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x60, 0x00,},
+	{0x3C, 0x66, 0x60, 0x6E, 0x66, 0x66, 0x3C, 0x00,},
+	{0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00,},
+	{0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00,},
+	{0x0E, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3C, 0x00,},
+	{0x66, 0x6C, 0x78, 0x70, 0x78, 0x6C, 0x66, 0x00,},
+	{0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00,},
+	{0xC6, 0xEE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0x00,},
+	{0x66, 0x76, 0x7E, 0x6E, 0x66, 0x66, 0x66, 0x00,},
+	{0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x00,},
+	{0x3C, 0x66, 0x66, 0x66, 0x6E, 0x6E, 0x3E, 0x00,},
+	{0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x00,},
+	{0x3E, 0x60, 0x60, 0x3C, 0x06, 0x06, 0x7C, 0x00,},
+	{0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x66, 0x66, 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x00,},
+	{0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 0x00,},
+	{0x66, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x66, 0x00,},
+	{0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x00,},
+	{0x7E, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x7E, 0x00,},
+	{0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00,},
+	{0x40, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00,},
+	{0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00,},
+	{0x10, 0x38, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,},
+	{0x18, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00,},
+	{0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x7C, 0x00,},
+	{0x00, 0x00, 0x3C, 0x66, 0x60, 0x66, 0x3C, 0x00,},
+	{0x06, 0x06, 0x3E, 0x66, 0x66, 0x66, 0x3E, 0x00,},
+	{0x00, 0x00, 0x3C, 0x66, 0x7C, 0x60, 0x3E, 0x00,},
+	{0x0E, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x3C, 0x00,},
+	{0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x7C,},
+	{0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00,},
+	{0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x70,},
+	{0x60, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0x00,},
+	{0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1C, 0x00,},
+	{0x00, 0x00, 0xCC, 0xFE, 0xD6, 0xC6, 0xC6, 0x00,},
+	{0x00, 0x00, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x00,},
+	{0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x00, 0x00, 0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60,},
+	{0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x06,},
+	{0x00, 0x00, 0x36, 0x38, 0x30, 0x30, 0x30, 0x00,},
+	{0x00, 0x00, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x00,},
+	{0x18, 0x18, 0x18, 0x3C, 0x18, 0x18, 0x0C, 0x00,},
+	{0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00,},
+	{0x00, 0x00, 0x66, 0x66, 0x3C, 0x3C, 0x18, 0x00,},
+	{0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0xEC, 0x00,},
+	{0x00, 0x00, 0x66, 0x3C, 0x18, 0x3C, 0x66, 0x00,},
+	{0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x7C,},
+	{0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x7E, 0x00,},
+	{0x1C, 0x30, 0x30, 0x60, 0x30, 0x30, 0x1C, 0x00,},
+	{0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,},
+	{0x38, 0x0C, 0x0C, 0x06, 0x0C, 0x0C, 0x38, 0x00,},
+	{0x32, 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
+	{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,},
+};
diff --git a/prex-0.9.0/bsp/hal/arm/gba/interrupt.c b/prex-0.9.0/bsp/hal/arm/gba/interrupt.c
new file mode 100755
index 0000000..620da50
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/interrupt.c
@@ -0,0 +1,218 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * interrupt.c - interrupt handling routines for GBA
+ */
+
+#include <sys/ipl.h>
+#include <kernel.h>
+#include <hal.h>
+#include <irq.h>
+#include <locore.h>
+#include <cpufunc.h>
+#include <context.h>
+
+/* Number of IRQ lines */
+#define NIRQS		14
+
+/* Interrupt hook vector */
+#define IRQ_VECTOR	*(uint32_t *)0x3007ffc
+
+/* Registers for interrupt control unit - enable/flag/master */
+#define ICU_IE		(*(volatile uint16_t *)0x4000200)
+#define ICU_IF		(*(volatile uint16_t *)0x4000202)
+#define ICU_IME		(*(volatile uint16_t *)0x4000208)
+
+/* ICU_IE */
+#define IRQ_VALID	0x3fff
+
+/* ICU_IME */
+#define IRQ_OFF		0
+#define IRQ_ON		1
+
+/*
+ * Interrupt priority level
+ *
+ * Each interrupt has its logical priority level, with 0 being
+ * the lowest priority. While some ISR is running, all lower
+ * priority interrupts are masked off.
+ */
+volatile int irq_level;
+
+/*
+ * Interrupt mapping table
+ */
+static int ipl_table[NIRQS];		/* Vector -> level */
+static uint16_t mask_table[NIPLS];	/* Level -> mask */
+
+/*
+ * Set mask for current ipl
+ */
+#define update_mask()	ICU_IE = mask_table[irq_level]
+
+/*
+ * Unmask interrupt in PIC for specified irq.
+ * The interrupt mask table is also updated.
+ * Assumes CPU interrupt is disabled in caller.
+ */
+void
+interrupt_unmask(int vector, int level)
+{
+	int i;
+	uint16_t unmask = (uint16_t)1 << vector;
+
+	/* Save level mapping */
+	ipl_table[vector] = level;
+
+	/*
+	 * Unmask target interrupt for all
+	 * lower interrupt levels.
+	 */
+	for (i = 0; i < level; i++)
+		mask_table[i] |= unmask;
+	update_mask();
+}
+
+/*
+ * Mask interrupt in PIC for specified irq.
+ * Interrupt must be disabled when this routine is called.
+ */
+void
+interrupt_mask(int vector)
+{
+	int i, level;
+	u_int mask = (uint16_t)~(1 << vector);
+
+	level = ipl_table[vector];
+	for (i = 0; i < level; i++)
+		mask_table[i] &= mask;
+	ipl_table[vector] = IPL_NONE;
+	update_mask();
+}
+
+/*
+ * Setup interrupt mode.
+ * Select whether an interrupt trigger is edge or level.
+ */
+void
+interrupt_setup(int vector, int mode)
+{
+	/* nop */
+}
+
+/*
+ * Dispatch interrupt
+ */
+void
+interrupt_dispatch(int vector)
+{
+	int old_ipl;
+
+	/* Save & update interrupt level */
+	old_ipl = irq_level;
+	irq_level = ipl_table[vector];
+	update_mask();
+
+	/* Send acknowledge to ICU for this irq */
+	ICU_IF = (uint16_t)(1 << vector);
+
+	/* Allow another interrupt that has higher priority */
+	splon();
+
+	/* Dispatch interrupt */
+	irq_handler(vector);
+
+	sploff();
+
+	/* Restore interrupt level */
+	irq_level = old_ipl;
+	update_mask();
+}
+
+/*
+ * Common interrupt handler.
+ */
+void
+interrupt_handler(void)
+{
+	uint16_t bits;
+	int vector;
+
+	bits = ICU_IF;
+retry:
+	for (vector = 0; vector < NIRQS; vector++) {
+		if (bits & (uint16_t)(1 << vector))
+			break;
+	}
+	if (vector == NIRQS)
+		goto out;
+
+	interrupt_dispatch(vector);
+
+	/*
+	 * Multiple interrupts can be fired in case of GBA.
+	 * So, we have to check the interrupt status, again.
+	 */
+	bits = ICU_IF;
+	if (bits & IRQ_VALID)
+		goto retry;
+out:
+	return;
+}
+
+/*
+ * Initialize interrupt controllers.
+ * All interrupts will be masked off.
+ */
+void
+interrupt_init(void)
+{
+	int i;
+
+	irq_level = IPL_NONE;
+
+	for (i = 0; i < NIRQS; i++)
+		ipl_table[i] = IPL_NONE;
+
+	for (i = 0; i < NIPLS; i++)
+		mask_table[i] = 0;
+
+	ICU_IME = IRQ_OFF;
+
+	/*
+	 * Since GBA has its own interrupt vector in ROM area,
+	 * we can not modify it. Instead, the GBA BIOS will
+	 * call the user's interrupt hook routine placed in
+	 * the address in 0x3007ffc.
+	 */
+	IRQ_VECTOR = (uint32_t)interrupt_entry; /* Interrupt hook address */
+	ICU_IE = 0;			/* Mask all interrupts */
+	ICU_IME = IRQ_ON;
+}
diff --git a/prex-0.9.0/bsp/hal/arm/gba/locore_gba.S b/prex-0.9.0/bsp/hal/arm/gba/locore_gba.S
new file mode 100755
index 0000000..9d19823
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/locore_gba.S
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * locore_machdep.S - GBA routines
+ */
+
+#include <conf/config.h>
+#include <machine/asm.h>
+
+	.section ".text","ax"
+	.code 32
+
+ENTRY(machine_idle)
+	swi	$0x20000
+	mov	pc, lr
+
+ENTRY(machine_reset)
+	swi	0
+
+#if defined(DEBUG) && defined(CONFIG_DIAG_VBA)
+ENTRY(vba_puts)
+	swi	$0xff0000
+	mov	pc, lr
+#endif
+
+	.end
diff --git a/prex-0.9.0/bsp/hal/arm/gba/machdep.c b/prex-0.9.0/bsp/hal/arm/gba/machdep.c
new file mode 100755
index 0000000..307c3a9
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/gba/machdep.c
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * machdep.c - machine-dependent routines for GBA
+ */
+
+#include <machine/syspage.h>
+#include <sys/power.h>
+#include <sys/bootinfo.h>
+#include <kernel.h>
+#include <cpu.h>
+#include <cpufunc.h>
+#include <locore.h>
+
+/*
+ * Power down system.
+ */
+void
+machine_powerdown(int state)
+{
+
+	DPRINTF(("Power down machine\n"));
+
+	splhigh();
+	for (;;)
+		cpu_idle();
+}
+
+/*
+ * Return pointer to the boot information.
+ */
+void
+machine_bootinfo(struct bootinfo **bip)
+{
+	ASSERT(bip != NULL);
+
+	*bip = (struct bootinfo *)BOOTINFO;
+}
+
+void
+machine_abort(void)
+{
+
+	for (;;)
+		cpu_idle();
+}
+
+/*
+ * Machine-dependent startup code
+ */
+void
+machine_startup(void)
+{
+
+	/*
+	 * Initialize CPU and basic hardware.
+	 */
+	cpu_init();
+}
diff --git a/prex-0.9.0/bsp/hal/arm/include/context.h b/prex-0.9.0/bsp/hal/arm/include/context.h
new file mode 100755
index 0000000..62438d2
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/include/context.h
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_CONTEXT_H
+#define _ARM_CONTEXT_H
+
+#ifndef __ASSEMBLY__
+#include <sys/types.h>
+
+/**
+ * ARM register reference:
+ *
+ *  Name    Number	ARM Procedure Calling Standard Role
+ *
+ *  a1	    r0		argument 1 / integer result / scratch register / argc
+ *  a2	    r1		argument 2 / scratch register / argv
+ *  a3	    r2		argument 3 / scratch register / envp
+ *  a4	    r3		argument 4 / scratch register
+ *  v1	    r4		register variable
+ *  v2	    r5		register variable
+ *  v3	    r6		register variable
+ *  v4	    r7		register variable
+ *  v5	    r8		register variable
+ *  sb/v6   r9		static base / register variable
+ *  sl/v7   r10		stack limit / stack chunk handle / reg. variable
+ *  fp	    r11		frame pointer
+ *  ip	    r12		scratch register / new-sb in inter-link-unit calls
+ *  sp	    r13		lower end of current stack frame
+ *  lr	    r14		link address / scratch register
+ *  pc	    r15		program counter
+ */
+
+/*
+ * Common register frame for trap/interrupt.
+ * These cpu state are saved into top of the kernel stack in
+ * trap/interrupt entries. Since the arguments of system calls are
+ * passed via registers, the system call library is completely
+ * dependent on this register format.
+ */
+struct cpu_regs {
+	uint32_t	r0;	/*  +0 (00) */
+	uint32_t	r1;	/*  +4 (04) */
+	uint32_t	r2;	/*  +8 (08) */
+	uint32_t	r3;	/* +12 (0C) */
+	uint32_t	r4;	/* +16 (10) */
+	uint32_t	r5;	/* +20 (14) */
+	uint32_t	r6;	/* +24 (18) */
+	uint32_t	r7;	/* +28 (1C) */
+	uint32_t	r8;	/* +32 (20) */
+	uint32_t	r9;	/* +36 (24) */
+	uint32_t	r10;	/* +40 (28) */
+	uint32_t	r11; 	/* +44 (2C) */
+	uint32_t	r12;	/* +48 (30) */
+	uint32_t	sp;	/* +52 (34) */
+	uint32_t	lr;	/* +56 (38) */
+	uint32_t	cpsr;	/* +60 (3C) */
+	uint32_t	svc_sp;	/* +64 (40) */
+	uint32_t	svc_lr;	/* +68 (44) */
+	uint32_t	pc;	/* +72 (48) */
+};
+
+/*
+ * Kernel mode context for context switching.
+ */
+struct kern_regs {
+	uint32_t	r4;
+	uint32_t	r5;
+	uint32_t	r6;
+	uint32_t	r7;
+	uint32_t	r8;
+	uint32_t	r9;
+	uint32_t	r10;
+	uint32_t	r11;
+	uint32_t	sp;
+	uint32_t	lr;
+};
+
+/*
+ * Processor context
+ */
+struct context {
+	struct kern_regs kregs;		/* kernel mode registers */
+	struct cpu_regs	*uregs;		/* user mode registers */
+	struct cpu_regs	*saved_regs;	/* savecd user mode registers */
+};
+
+typedef struct context *context_t;	/* context id */
+
+#endif /* !__ASSEMBLY__ */
+
+/*
+ * Register offset in cpu_regs
+ */
+#define REG_R0		0x00
+#define REG_R1		0x04
+#define REG_R2		0x08
+#define REG_R3		0x0c
+#define REG_R4		0x10
+#define REG_R5		0x14
+#define REG_R6		0x18
+#define REG_R7		0x1c
+#define REG_R8		0x20
+#define REG_R9		0x24
+#define REG_R10		0x28
+#define REG_R11		0x2c
+#define REG_R12		0x30
+#define REG_SP		0x34
+#define REG_LR		0x38
+#define REG_CPSR	0x3c
+#define REG_SVCSP	0x40
+#define REG_SVCLR	0x44
+#define REG_PC		0x48
+
+#define CTXREGS		(4*19)
+
+#endif /* !_ARM_ARCH_H */
diff --git a/prex-0.9.0/bsp/hal/arm/include/cpu.h b/prex-0.9.0/bsp/hal/arm/include/cpu.h
new file mode 100755
index 0000000..8f6feeb
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/include/cpu.h
@@ -0,0 +1,83 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_CPU_H
+#define _ARM_CPU_H
+
+/*
+ * Processor Status Register
+ */
+#define PSR_MODE	0x0000001f
+#define PSR_USR_MODE	0x00000010
+#define PSR_FIQ_MODE	0x00000011
+#define PSR_IRQ_MODE	0x00000012
+#define PSR_SVC_MODE	0x00000013
+#define PSR_ABT_MODE	0x00000017
+#define PSR_UND_MODE	0x0000001b
+#define PSR_SYS_MODE	0x0000001f
+
+#define PSR_THUMB	0x00000020
+
+#define PSR_INT_MASK	0x000000c0
+#define PSR_FIQ_DIS	0x00000040
+#define PSR_IRQ_DIS	0x00000080
+
+#ifdef __gba__
+#define PSR_APP_MODE	PSR_SYS_MODE
+#else
+#define PSR_APP_MODE	PSR_USR_MODE
+#endif
+
+/*
+ * Contorl register CP15 register 1
+ */
+#define CTL_MMU		0x000000001	/* M: MMU/Protection unit enable */
+#define CTL_AFLT	0x000000002	/* A: Alignment fault enable */
+#define CTL_CACHE	0x000000004	/* C: Cache enable */
+#define CTL_WBUF	0x000000008	/* W: Write buffer enable */
+#define CTL_32BP	0x000000010	/* P: 32-bit exception handlers */
+#define CTL_32BD	0x000000020	/* D: 32-bit addressing */
+#define CTL_LABT	0x000000040	/* L: Late abort enable */
+#define CTL_BIGEND	0x000000080	/* B: Big-endian mode */
+#define CTL_SYSP	0x000000100	/* S: System protection bit */
+#define CTL_ROMP	0x000000200	/* R: ROM protection bit */
+#define CTL_BPRD	0x000000800	/* Z: Branch prediction enable */
+#define CTL_ICACHE	0x000001000	/* I: Instruction cache enable */
+#define CTL_HIVEC	0x000002000	/* V: Vector relocation */
+
+#define CTL_DEFAULT	(CTL_32BP | CTL_32BD | CTL_LABT)
+
+#ifndef __ASSEMBLY__
+
+__BEGIN_DECLS
+void	 cpu_init(void);
+__END_DECLS
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_ARM_CPU_H */
diff --git a/prex-0.9.0/bsp/hal/arm/include/cpufunc.h b/prex-0.9.0/bsp/hal/arm/include/cpufunc.h
new file mode 100755
index 0000000..9f912ca
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/include/cpufunc.h
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_CPUFUNC_H
+#define _ARM_CPUFUNC_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+void	 cpu_idle(void);
+int	 get_faultstatus(void);
+void	*get_faultaddress(void);
+paddr_t	 get_ttb(void);
+void	 set_ttb(paddr_t);
+void	 switch_ttb(paddr_t);
+void	 flush_tlb(void);
+void	 flush_cache(void);
+__END_DECLS
+
+#endif /* !_ARM_CPUFUNC_H */
diff --git a/prex-0.9.0/bsp/hal/arm/include/locore.h b/prex-0.9.0/bsp/hal/arm/include/locore.h
new file mode 100755
index 0000000..78456f3
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/include/locore.h
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_LOCORE_H
+#define _ARM_LOCORE_H
+
+#include <sys/cdefs.h>
+#include <context.h>
+
+__BEGIN_DECLS
+void	 syscall_ret(void);
+void	 kernel_thread_entry(void);
+void	 cpu_switch(struct kern_regs *, struct kern_regs *);
+void	 interrupt_entry(void);
+void	 vector_copy(vaddr_t);
+void	 cpu_init(void);
+void	 known_fault1(void);
+void	 known_fault2(void);
+void	 known_fault3(void);
+void	 copy_fault(void);
+void	 cache_init(void);
+void	 sploff(void);
+void	 splon(void);
+__END_DECLS
+
+#endif /* !_ARM_LOCORE_H */
diff --git a/prex-0.9.0/bsp/hal/arm/include/mmu.h b/prex-0.9.0/bsp/hal/arm/include/mmu.h
new file mode 100755
index 0000000..b8bd437
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/include/mmu.h
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_MMU_H
+#define _ARM_MMU_H
+
+#include <sys/types.h>
+
+typedef uint32_t	*pgd_t;		/* page directory */
+typedef uint32_t	*pte_t;		/* page table entry */
+
+#define L1TBL_SIZE	0x4000
+#define L2TBL_SIZE	0x1000
+
+/*
+ * Page directory entry (L1)
+ */
+#define PDE_PRESENT	0x00000003
+#define PDE_ADDRESS	0xfffff000
+
+/*
+ * Page table entry (L2)
+ */
+#define PTE_PRESENT	0x00000002
+#define PTE_WBUF	0x00000004
+#define PTE_CACHE	0x00000008
+#define PTE_SYSTEM	0x00000010
+#define PTE_USER_RO	0x00000020
+#define PTE_USER_RW	0x00000030
+#define PTE_ATTR_MASK	0x00000030
+#define PTE_ADDRESS	0xfffffc00
+
+/*
+ *  Virtual and physical address translation
+ */
+#define PAGE_DIR(virt)      (int)((((vaddr_t)(virt)) >> 20) & 0xfff)
+#define PAGE_TABLE(virt)    (int)((((vaddr_t)(virt)) >> 12) & 0xff)
+
+#define pte_present(pgd, virt)  (pgd[PAGE_DIR(virt)] & PDE_PRESENT)
+
+#define page_present(pte, virt) (pte[PAGE_TABLE(virt)] & PTE_PRESENT)
+
+#define vtopte(pgd, virt) \
+            (pte_t)ptokv((pgd)[PAGE_DIR(virt)] & PDE_ADDRESS)
+
+#define ptetopg(pte, virt) \
+            ((pte)[PAGE_TABLE(virt)] & PTE_ADDRESS)
+
+
+#endif /* !_ARM_MMU_H */
diff --git a/prex-0.9.0/bsp/hal/arm/include/trap.h b/prex-0.9.0/bsp/hal/arm/include/trap.h
new file mode 100755
index 0000000..fed490f
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/include/trap.h
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_TRAP_H
+#define _ARM_TRAP_H
+
+/*
+ * Trap ID
+ */
+#define TRAP_UNDEFINED		0
+#define TRAP_PREFETCH_ABORT	1
+#define TRAP_DATA_ABORT		2
+
+#ifndef __ASSEMBLY__
+
+__BEGIN_DECLS
+void	 trap_handler(struct cpu_regs *);
+void	 trap_dump(struct cpu_regs *);
+__END_DECLS
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_ARM_TRAP_H */
diff --git a/prex-0.9.0/bsp/hal/arm/integrator/Makefile.inc b/prex-0.9.0/bsp/hal/arm/integrator/Makefile.inc
new file mode 100755
index 0000000..63e0195
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/integrator/Makefile.inc
@@ -0,0 +1,16 @@
+
+SRCS:=		arm/arch/locore.S \
+		arm/arch/cpufunc.S \
+		arm/arch/cpu.c \
+		arm/arch/trap.c \
+		arm/arch/context.c \
+		arm/integrator/interrupt.c \
+		arm/integrator/clock.c \
+		arm/integrator/machdep.c
+
+ifeq ($(CONFIG_MMU),y)
+SRCS+=		arm/arch/mmu.c
+endif
+ifeq ($(DEBUG),1)
+SRCS+=		arm/integrator/diag.c
+endif
diff --git a/prex-0.9.0/bsp/hal/arm/integrator/clock.c b/prex-0.9.0/bsp/hal/arm/integrator/clock.c
new file mode 100755
index 0000000..d9d13ab
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/integrator/clock.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * clock.c - clock driver
+ */
+
+#include <kernel.h>
+#include <timer.h>
+#include <irq.h>
+#include <cpufunc.h>
+#include <sys/ipl.h>
+
+#include "platform.h"
+
+/* Interrupt vector for timer (TMR1) */
+#define CLOCK_IRQ	6
+
+/* The clock rate per second - 1Mhz */
+#define CLOCK_RATE	1000000L
+
+/* The initial counter value */
+#define TIMER_COUNT	(CLOCK_RATE / HZ)
+
+/* Timer 1 registers */
+#define TMR_LOAD	(*(volatile uint32_t *)(TIMER_BASE + 0x100))
+#define TMR_VAL		(*(volatile uint32_t *)(TIMER_BASE + 0x104))
+#define TMR_CTRL	(*(volatile uint32_t *)(TIMER_BASE + 0x108))
+#define TMR_CLR		(*(volatile uint32_t *)(TIMER_BASE + 0x10c))
+
+/* Timer control register */
+#define TCTRL_DISABLE	0x00
+#define TCTRL_ENABLE	0x80
+#define TCTRL_PERIODIC	0x40
+#define TCTRL_INTEN	0x20
+#define TCTRL_SCALE256	0x08
+#define TCTRL_SCALE16	0x04
+#define TCTRL_32BIT	0x02
+#define TCTRL_ONESHOT	0x01
+
+/*
+ * Clock interrupt service routine.
+ * No H/W reprogram is required.
+ */
+static int
+clock_isr(void *arg)
+{
+
+	splhigh();
+	timer_handler();
+	TMR_CLR = 0x01;	/* Clear timer interrupt */
+	spl0();
+	return INT_DONE;
+}
+
+/*
+ * Initialize clock H/W chip.
+ * Setup clock tick rate and install clock ISR.
+ */
+void
+clock_init(void)
+{
+	irq_t clock_irq;
+
+	/* Setup counter value */
+	TMR_CTRL = TCTRL_DISABLE;
+	TMR_LOAD = TIMER_COUNT;
+	TMR_CTRL |= (TCTRL_ENABLE | TCTRL_PERIODIC);
+
+	/* Install ISR */
+	clock_irq = irq_attach(CLOCK_IRQ, IPL_CLOCK, 0, &clock_isr,
+			       IST_NONE, NULL);
+
+	/* Enable timer interrupt */
+	TMR_CTRL |= TCTRL_INTEN;
+
+	DPRINTF(("Clock rate: %d ticks/sec\n", CONFIG_HZ));
+}
diff --git a/prex-0.9.0/bsp/hal/arm/integrator/diag.c b/prex-0.9.0/bsp/hal/arm/integrator/diag.c
new file mode 100755
index 0000000..91c084d
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/integrator/diag.c
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * diag.c - diagnostic message support
+ */
+
+#include <sys/bootinfo.h>
+#include <kernel.h>
+#include <cpufunc.h>
+
+#include "platform.h"
+
+#define UART_FR		(*(volatile uint32_t *)(UART_BASE + 0x18))
+#define UART_DR		(*(volatile uint32_t *)(UART_BASE + 0x00))
+
+/* Flag register */
+#define FR_RXFE		0x10	/* Receive FIFO empty */
+#define FR_TXFF		0x20	/* Transmit FIFO full */
+
+static void
+serial_putc(char c)
+{
+
+	while (UART_FR & FR_TXFF)
+		;
+	UART_DR = (uint32_t)c;
+}
+
+void
+diag_puts(char *buf)
+{
+
+	while (*buf) {
+		if (*buf == '\n')
+			serial_putc('\r');
+		serial_putc(*buf++);
+	}
+}
+
+void
+diag_init(void)
+{
+
+#ifdef CONFIG_MMU
+	mmu_premap(0x16000000, UART_BASE);
+#endif
+}
diff --git a/prex-0.9.0/bsp/hal/arm/integrator/interrupt.c b/prex-0.9.0/bsp/hal/arm/integrator/interrupt.c
new file mode 100755
index 0000000..dfddda1
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/integrator/interrupt.c
@@ -0,0 +1,188 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * interrupt.c - interrupt handling routines
+ */
+
+#include <sys/ipl.h>
+#include <kernel.h>
+#include <hal.h>
+#include <irq.h>
+#include <cpufunc.h>
+#include <context.h>
+#include <locore.h>
+
+#include "platform.h"
+
+/* Number of IRQ lines */
+#define NIRQS		29
+
+/* Registers for interrupt control unit - enable/flag/master */
+#define ICU_IRQSTS	(*(volatile uint32_t *)(ICU_BASE + 0x00))
+#define ICU_IRQEN	(*(volatile uint32_t *)(ICU_BASE + 0x08))
+#define ICU_IRQENSET	(*(volatile uint32_t *)(ICU_BASE + 0x08))
+#define ICU_IRQENCLR	(*(volatile uint32_t *)(ICU_BASE + 0x0C))
+
+/*
+ * Interrupt Priority Level
+ *
+ * Each interrupt has its logical priority level, with 0 being
+ * the lowest priority. While some ISR is running, all lower
+ * priority interrupts are masked off.
+ */
+volatile int irq_level;
+
+/*
+ * Interrupt mapping table
+ */
+static int ipl_table[NIRQS];		/* vector -> level */
+static uint32_t mask_table[NIPLS];	/* level -> mask */
+
+/*
+ * Set mask for current ipl
+ */
+static void
+update_mask(void)
+{
+	u_int mask = mask_table[irq_level];
+
+	ICU_IRQENCLR = ~mask;
+	ICU_IRQENSET = mask;
+}
+
+/*
+ * Unmask interrupt in ICU for specified irq.
+ * The interrupt mask table is also updated.
+ * Assumes CPU interrupt is disabled in caller.
+ */
+void
+interrupt_unmask(int vector, int level)
+{
+	int i;
+	uint32_t unmask = (uint32_t)1 << vector;
+
+	/* Save level mapping */
+	ipl_table[vector] = level;
+
+	/*
+	 * Unmask the target interrupt for all
+	 * lower interrupt levels.
+	 */
+	for (i = 0; i < level; i++)
+		mask_table[i] |= unmask;
+	update_mask();
+}
+
+/*
+ * Mask interrupt in ICU for specified irq.
+ * Interrupt must be disabled when this routine is called.
+ */
+void
+interrupt_mask(int vector)
+{
+	int i, level;
+	u_int mask = (uint16_t)~(1 << vector);
+
+	level = ipl_table[vector];
+	for (i = 0; i < level; i++)
+		mask_table[i] &= mask;
+	ipl_table[vector] = IPL_NONE;
+	update_mask();
+}
+
+/*
+ * Setup interrupt mode.
+ * Select whether an interrupt trigger is edge or level.
+ */
+void
+interrupt_setup(int vector, int mode)
+{
+	/* nop */
+}
+
+/*
+ * Common interrupt handler.
+ */
+void
+interrupt_handler(void)
+{
+	uint32_t bits;
+	int vector, old_ipl, new_ipl;
+
+	/* Get interrupt source */
+	bits = ICU_IRQSTS;
+	for (vector = 0; vector < NIRQS; vector++) {
+		if (bits & (uint32_t)(1 << vector))
+			break;
+	}
+	if (vector == NIRQS)
+		goto out;
+
+	/* Adjust interrupt level */
+	old_ipl = irq_level;
+	new_ipl = ipl_table[vector];
+	if (new_ipl > old_ipl)		/* Ignore spurious interrupt */
+		irq_level = new_ipl;
+	update_mask();
+
+	/* Allow another interrupt that has higher priority */
+	splon();
+
+	/* Dispatch interrupt */
+	irq_handler(vector);
+
+	sploff();
+
+	/* Restore interrupt level */
+	irq_level = old_ipl;
+	update_mask();
+out:
+	return;
+}
+
+/*
+ * Initialize interrupt controllers.
+ * All interrupts will be masked off.
+ */
+void
+interrupt_init(void)
+{
+	int i;
+
+	irq_level = IPL_NONE;
+
+	for (i = 0; i < NIRQS; i++)
+		ipl_table[i] = IPL_NONE;
+
+	for (i = 0; i < NIPLS; i++)
+		mask_table[i] = 0;
+
+	ICU_IRQENCLR = 0xffff;		/* Mask all interrupts */
+}
diff --git a/prex-0.9.0/bsp/hal/arm/integrator/machdep.c b/prex-0.9.0/bsp/hal/arm/integrator/machdep.c
new file mode 100755
index 0000000..82d65f5
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/integrator/machdep.c
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * machdep.c - machine-dependent routines for ARM Integrator-CP
+ */
+
+#include <machine/syspage.h>
+#include <sys/power.h>
+#include <sys/bootinfo.h>
+#include <kernel.h>
+#include <page.h>
+#include <mmu.h>
+#include <cpu.h>
+#include <cpufunc.h>
+#include <locore.h>
+
+#include "platform.h"
+
+/* System control reg */
+#define SC_CTRL		(*(volatile uint32_t *)(FPGA_BASE + 0x0c))
+
+#define SCCTRL_SOFTRESET	0x08
+
+#ifdef CONFIG_MMU
+/*
+ * Virtual and physical address mapping
+ *
+ *      { virtual, physical, size, type }
+ */
+struct mmumap mmumap_table[] =
+{
+	/*
+	 * Internal SRAM (4M)
+	 */
+	{ 0x80000000, 0x00000000, 0x400000, VMT_RAM },
+
+	/*
+	 * FPGA core control (4K)
+	 */
+	{ 0xD0000000, 0x10000000, 0x1000, VMT_IO },
+
+	/*
+	 * Counter/Timers (1M)
+	 */
+	{ 0xD3000000, 0x13000000, 0x100000, VMT_IO },
+
+	/*
+	 * Interrupt controller (1M)
+	 */
+	{ 0xD4000000, 0x14000000, 0x100000, VMT_IO },
+
+	/*
+	 * Real-time clock (1M)
+	 */
+	{ 0xD5000000, 0x15000000, 0x100000, VMT_IO },
+
+	/*
+	 * UART 0 (1M)
+	 */
+	{ 0xD6000000, 0x16000000, 0x100000, VMT_IO },
+
+	{ 0,0,0,0 }
+};
+#endif
+
+/*
+ * Idle
+ */
+void
+machine_idle(void)
+{
+
+	cpu_idle();
+}
+
+/*
+ * Reset system.
+ */
+static void
+machine_reset(void)
+{
+
+	SC_CTRL = SCCTRL_SOFTRESET;
+
+	for (;;) ;
+	/* NOTREACHED */
+}
+
+/*
+ * Set system power
+ */
+void
+machine_powerdown(int state)
+{
+
+	splhigh();
+
+	DPRINTF(("Power down machine\n"));
+
+	switch (state) {
+	case PWR_OFF:
+		for (;;)
+			cpu_idle();
+		/* NOTREACHED */
+		break;
+	case PWR_REBOOT:
+		machine_reset();
+		/* NOTREACHED */
+		break;
+	}
+}
+
+/*
+ * Return pointer to the boot information.
+ */
+void
+machine_bootinfo(struct bootinfo **bip)
+{
+
+	*bip = (struct bootinfo *)BOOTINFO;
+}
+
+void
+machine_abort(void)
+{
+
+	for (;;)
+		cpu_idle();
+}
+
+/*
+ * Machine-dependent startup code
+ */
+void
+machine_startup(void)
+{
+
+	/*
+	 * Initialize CPU and basic hardware.
+	 */
+	cpu_init();
+	cache_init();
+
+	/*
+	 * Reserve system pages.
+	 */
+	page_reserve(kvtop(SYSPAGE), SYSPAGESZ);
+
+	/*
+	 * Setup vector page.
+	 */
+	vector_copy((vaddr_t)ptokv(CONFIG_ARM_VECTORS));
+
+#ifdef CONFIG_MMU
+	/*
+	 * Initialize MMU
+	 */
+	mmu_init(mmumap_table);
+#endif
+}
diff --git a/prex-0.9.0/bsp/hal/arm/integrator/platform.h b/prex-0.9.0/bsp/hal/arm/integrator/platform.h
new file mode 100755
index 0000000..970aefd
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/arm/integrator/platform.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _INTEGRATOR_PLATFORM_H
+#define _INTEGRATOR_PLATFORM_H
+
+/* number of interrupt vectors */
+#define NIRQS		29
+
+#ifdef CONFIG_MMU
+#define CM_IOMEM_BASE	0xc0000000
+#else
+#define CM_IOMEM_BASE	0
+#endif
+
+#define FPGA_BASE	(CM_IOMEM_BASE + 0x10000000)
+#define TIMER_BASE	(CM_IOMEM_BASE + 0x13000000)
+#define ICU_BASE	(CM_IOMEM_BASE + 0x14000000)
+#define UART_BASE	(CM_IOMEM_BASE + 0x16000000)
+
+#endif /* !_INTEGRATOR_PLATFORM_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/clock.c b/prex-0.9.0/bsp/hal/ppc/arch/clock.c
new file mode 100755
index 0000000..9cfd91a
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/clock.c
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * clock.c - clock driver for Power PC decrementer.
+ */
+
+#include <sys/ipl.h>
+#include <kernel.h>
+#include <timer.h>
+#include <irq.h>
+#include <cpufunc.h>
+#include <sys/ipl.h>
+
+#define DECR_COUNT	1000
+
+/*
+ * Timer handler.
+ */
+int
+clock_isr(void *arg)
+{
+	int s;
+
+	/* Reset decrementer */
+	set_decr(DECR_COUNT);
+
+	s = splhigh();
+	timer_handler();
+	splx(s);
+
+	return INT_DONE;
+}
+
+/*
+ * Initialize clock H/W.
+ */
+void
+clock_init(void)
+{
+
+	DPRINTF(("clock_init\n"));
+	set_decr(DECR_COUNT);
+}
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/context.c b/prex-0.9.0/bsp/hal/ppc/arch/context.c
new file mode 100755
index 0000000..1f2aaf1
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/context.c
@@ -0,0 +1,197 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * context.c - context management routines
+ */
+
+/*
+ * The context consists of kernel/user mode registers, and kernel
+ * stack. The user mode registers are always saved to the kernel
+ * stack when processor enters kernel mode by H/W or S/W events.
+ *
+ * The user mode registers are located in the interrupt/trap
+ * frame at the top of the kernel stack. Before the control
+ * returns to user mode next time, these register value will be
+ * restored automatically.
+ *
+ * All thread owns its context to keep its execution state. The
+ * scheduler will switch the context to change an active thread.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <cpu.h>
+#include <context.h>
+#include <locore.h>
+#include <trap.h>
+
+/*
+ * Set user mode registers into the specific context.
+ *
+ * Note: When user mode program counter is set, all register
+ * values except a stack pointer are reset to default value.
+ */
+void
+context_set(context_t ctx, int type, register_t val)
+{
+	struct kern_regs *k;
+	struct cpu_regs *u;
+	uint32_t *argp;
+
+	k = &ctx->kregs;
+
+	switch (type) {
+	case CTX_KSTACK:
+		/* Adjust stack for C code */
+		val -= STKFRAME_LEN;
+
+		/* Set kernel mode stack pointer */
+		ctx->uregs = (struct cpu_regs *)
+				((uint32_t)val - sizeof(struct cpu_regs));
+
+		k->sp = (uint32_t)ctx->uregs;
+		k->kstack = (uint32_t)val;
+
+		/* Reset minimum user mode registers */
+		u = ctx->uregs;
+		u->gr[3] = 0x11111111;
+		u->gr[4] = 0x22222222;
+		u->gr[5] = 0x33333333;
+		u->srr1 = MSR_DFLT;
+		break;
+
+	case CTX_KENTRY:
+		/* Kernel mode program counter */
+		k->lr = (uint32_t)val;
+		break;
+
+	case CTX_KARG:
+		/* Kernel mode argument */
+		argp = (uint32_t *)(k->sp + sizeof(uint32_t) * 2);
+		*argp = (uint32_t)val;
+		break;
+
+	case CTX_USTACK:
+		/* User mode stack pointer */
+		u = ctx->uregs;
+		u->gr[1] = (uint32_t)val;
+		break;
+
+	case CTX_UENTRY:
+		/* User mode program counter */
+		u = ctx->uregs;
+		u->srr0 = (uint32_t)val;
+		u->srr1 = MSR_DFLT;
+		break;
+
+	case CTX_UARG:
+		/* User mode argument */
+		u = ctx->uregs;
+		u->gr[3] = (uint32_t)val;
+		argp = (uint32_t *)(u->gr[1] + sizeof(uint32_t));
+		copyout(&val, argp, sizeof(uint32_t));
+		break;
+
+	default:
+		/* invalid */
+		break;
+	}
+}
+
+/*
+ * Switch to new context
+ *
+ * Kernel mode registers and kernel stack pointer are switched to
+ * the next context.
+ *
+ * It is assumed all interrupts are disabled by caller.
+ *
+ * TODO: FPU context is not switched as of now.
+ */
+void
+context_switch(context_t prev, context_t next)
+{
+
+	cpu_switch(&prev->kregs, &next->kregs);
+}
+
+/*
+ * Save user mode context to handle exceptions.
+ *
+ * Copy current user mode registers in the kernel stack to the
+ * user mode stack. The user stack pointer is adjusted for this
+ * area. So that the exception handler can get the register
+ * state of the target thread.
+ *
+ * It builds arguments for the exception handler in the following
+ * format.
+ *
+ *   void exception_handler(int exc, void *regs);
+ */
+void
+context_save(context_t ctx)
+{
+	struct cpu_regs *cur, *sav;
+
+	/* Copy current register context into user mode stack */
+	cur = ctx->uregs;
+	sav = (struct cpu_regs *)(cur->gr[1] - sizeof(struct cpu_regs));
+	copyout(cur, sav, sizeof(*sav));
+
+	ctx->saved_regs = sav;
+
+	/* Adjust stack pointer */
+	cur->gr[1] = (uint32_t)sav - sizeof(uint32_t);
+}
+
+/*
+ * Restore register context to return from the exception handler.
+ */
+void
+context_restore(context_t ctx)
+{
+	struct cpu_regs *cur;
+
+	/* Restore user mode context */
+	cur = ctx->uregs;
+	copyin(ctx->saved_regs, cur, sizeof(*cur));
+
+	/* Correct some registers for fail safe */
+	cur->srr1 |= MSR_DFLT;
+}
+
+void
+context_dump(context_t ctx)
+{
+
+#ifdef DEBUG
+	trap_dump(ctx->uregs);
+#endif
+}
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/cpu.c b/prex-0.9.0/bsp/hal/ppc/arch/cpu.c
new file mode 100755
index 0000000..c21a64d
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/cpu.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpu.c - cpu dependent routines
+ */
+
+#include <kernel.h>
+#include <cpu.h>
+#include <locore.h>
+#include <cpufunc.h>
+
+static int curspl = 15;
+
+int
+splhigh(void)
+{
+	int oldspl = curspl;
+
+	sploff();
+	curspl = 15;
+	return oldspl;
+}
+
+int
+spl0(void)
+{
+	int oldspl = curspl;
+
+	curspl = 0;
+	splon();
+	return oldspl;
+}
+
+void
+splx(int s)
+{
+
+	curspl = s;
+	if (curspl == 0)
+		splon();
+	else
+		sploff();
+}
+
+
+int
+copyin(const void *uaddr, void *kaddr, size_t len)
+{
+
+	if (user_area(uaddr) && user_area(uaddr + len)) {
+		memcpy(kaddr, uaddr, len);
+		return 0;
+	}
+	return EFAULT;
+}
+
+int
+copyout(const void *kaddr, void *uaddr, size_t len)
+{
+
+	if (user_area(uaddr) && user_area(uaddr + len)) {
+		memcpy(uaddr, kaddr, len);
+		return 0;
+	}
+	return EFAULT;
+}
+
+int
+copyinstr(const void *uaddr, void *kaddr, size_t len)
+{
+
+	if (user_area(uaddr) && user_area(uaddr + len)) {
+		strlcpy(kaddr, uaddr, len);
+		return 0;
+	}
+	return EFAULT;
+}
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/cpufunc.S b/prex-0.9.0/bsp/hal/ppc/arch/cpufunc.S
new file mode 100755
index 0000000..61dcd7a
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/cpufunc.S
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpufunc.S - Functions to provide access to PPC specific instructions.
+ */
+
+#include <conf/config.h>
+#include <machine/asm.h>
+#include <cpu.h>
+
+/*
+ * uint32 get_decr(void);
+ */
+ENTRY(get_decr)
+	mfdec	r3
+	blr
+
+/*
+ * void set_decr(uint32_t);
+ */
+ENTRY(set_decr)
+	mtdec	r3
+	blr
+
+/*
+ * void cpu_idle(void);
+ */
+ENTRY(cpu_idle)
+	mfmsr	r3
+	ori	r3, r3, MSR_EE@l	/* enable ints */
+	mtmsr	r3
+	isync
+	sync
+
+	mfmsr	%r3
+	oris	r3, r3, MSR_POW@h	/* set low power mode */
+	mtmsr	r3
+	isync
+	blr
+
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/kern.ld b/prex-0.9.0/bsp/hal/ppc/arch/kern.ld
new file mode 100755
index 0000000..5bab8b1
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/kern.ld
@@ -0,0 +1,44 @@
+/*
+ * Linker script for kernel
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
+OUTPUT_ARCH(powerpc)
+ENTRY(kernel_start)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = CONFIG_KERNEL_TEXT + SIZEOF_HEADERS;
+
+	.text : {
+		*(.text)
+	} : text = 0x9090
+
+	. = ALIGN(32);
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	} : text
+
+	. = ALIGN(32);
+	.data : {
+		*(.data)
+		*(.sdata)
+		*(.sdata2)
+	} : data
+
+	__bss = .;
+	.bss .    : {
+		*(.sbss)
+		*(.bss)
+		*(COMMON)
+	}
+	. = ALIGN(32 / 8);
+	__end = .;
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/locore.S b/prex-0.9.0/bsp/hal/ppc/arch/locore.S
new file mode 100755
index 0000000..4f82b54
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/locore.S
@@ -0,0 +1,463 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * locore.S - low level platform support
+ */
+
+/*
+ * Memo: SPRG usage
+ *  SPRG0 - kernel stack pointer
+ *  SPRG1 - saved stack pointer
+ *  SPRG2 - interrupt nest counter
+ *  SPRG3 - scratch pad
+ */
+
+#include <conf/config.h>
+#include <machine/asm.h>
+#include <machine/syspage.h>
+#include <machine/memory.h>
+#include <sys/errno.h>
+#include <context.h>
+#include <trap.h>
+#include <cpu.h>
+
+	.section ".text","ax"
+
+#define ABS_JUMP(target) \
+	lis	r12, (target)@ha ; \
+	ori	r12, r12, (target)@l ; \
+	mtctr	r12 ;\
+	bctr
+
+/*
+ * Macro to save all registers.
+ */
+#define SAVE_ALL \
+	subi	r1, r1, CTXREGS; \
+	stw	r0, REG_R0(r1); \
+	stw	r2, REG_R2(r1); \
+	stw	r3, REG_R3(r1); \
+	stw	r4, REG_R4(r1); \
+	stw	r5, REG_R5(r1); \
+	stw	r6, REG_R6(r1); \
+	stw	r7, REG_R7(r1); \
+	stw	r8, REG_R8(r1); \
+	stw	r9, REG_R9(r1); \
+	stw	r10, REG_R10(r1); \
+	stw	r11, REG_R11(r1); \
+	stw	r12, REG_R12(r1); \
+	stw	r13, REG_R13(r1); \
+	stw	r14, REG_R14(r1); \
+	stw	r15, REG_R15(r1); \
+	stw	r16, REG_R16(r1); \
+	stw	r17, REG_R17(r1); \
+	stw	r18, REG_R18(r1); \
+	stw	r19, REG_R19(r1); \
+	stw	r20, REG_R20(r1); \
+	stw	r21, REG_R21(r1); \
+	stw	r22, REG_R22(r1); \
+	stw	r23, REG_R23(r1); \
+	stw	r24, REG_R24(r1); \
+	stw	r25, REG_R25(r1); \
+	stw	r26, REG_R26(r1); \
+	stw	r27, REG_R27(r1); \
+	stw	r28, REG_R28(r1); \
+	stw	r29, REG_R29(r1); \
+	stw	r30, REG_R30(r1); \
+	stw	r31, REG_R31(r1); \
+	mfsprg1	r10; 			/* Get saved sp */ \
+	stw	r10, REG_R1(r1); \
+	mfspr	r10, SPR_SRR0; \
+	stw	r10, REG_SRR0(r1); \
+	mfspr	r10, SPR_SRR1; \
+	stw	r10, REG_SRR1(r1); \
+	mfspr	r10, SPR_LR; \
+	stw	r10, REG_LR(r1); \
+	mfspr	r10, SPR_CTR; \
+	stw	r10, REG_CTR(r1); \
+	mfspr	r10, SPR_XER; \
+	stw	r10, REG_XER(r1); \
+	mfspr	r10, SPR_LR; \
+	stw	r10, REG_LR(r1); \
+	mfcr	r10; \
+	stw	r10, REG_CR(r1);
+
+/*
+ * Macro to restore all registers.
+ */
+#define RESTORE_ALL \
+	lwz	r10, REG_SRR0(r1); \
+	mtspr	SPR_SRR0, r10; \
+	lwz	r10, REG_SRR1(r1); \
+	mtspr	SPR_SRR1, r10; \
+	lwz	r10, REG_LR(r1); \
+	mtspr	SPR_LR, r10; \
+	lwz	r10, REG_XER(r1); \
+	mtspr	SPR_XER, r10; \
+	lwz	r10, REG_CTR(r1); \
+	mtspr	SPR_CTR, r10; \
+	lwz	r10, REG_LR(r1); \
+	mtspr	SPR_LR, r10; \
+	lwz	r10, REG_CR(r1); \
+	mtcr	r10; \
+	lwz	r10, REG_R1(r1); \
+	mtsprg1	r10; 			/* Restore saved sp */ \
+	lwz	r0, REG_R0(r1); \
+	lwz	r2, REG_R2(r1); \
+	lwz	r3, REG_R3(r1); \
+	lwz	r4, REG_R4(r1); \
+	lwz	r5, REG_R5(r1); \
+	lwz	r6, REG_R6(r1); \
+	lwz	r7, REG_R7(r1); \
+	lwz	r8, REG_R8(r1); \
+	lwz	r9, REG_R9(r1); \
+	lwz	r10, REG_R10(r1); \
+	lwz	r11, REG_R11(r1); \
+	lwz	r12, REG_R12(r1); \
+	lwz	r13, REG_R13(r1); \
+	lwz	r14, REG_R14(r1); \
+	lwz	r15, REG_R15(r1); \
+	lwz	r16, REG_R16(r1); \
+	lwz	r17, REG_R17(r1); \
+	lwz	r18, REG_R18(r1); \
+	lwz	r19, REG_R19(r1); \
+	lwz	r20, REG_R20(r1); \
+	lwz	r21, REG_R21(r1); \
+	lwz	r22, REG_R22(r1); \
+	lwz	r23, REG_R23(r1); \
+	lwz	r24, REG_R24(r1); \
+	lwz	r25, REG_R25(r1); \
+	lwz	r26, REG_R26(r1); \
+	lwz	r27, REG_R27(r1); \
+	lwz	r28, REG_R28(r1); \
+	lwz	r29, REG_R29(r1); \
+	lwz	r30, REG_R30(r1); \
+	lwz	r31, REG_R31(r1);
+
+/*
+ * Macro to build an exception entry.
+ * We assume interrupts are disabled.
+ */
+#define EXCEPTION_ENTRY(offset, name, id, xfer) \
+	.skip offset - (. - exception_vector); \
+exception_##name: \
+	mtsprg1 r1;		/* sprg1: current sp */ \
+	mtsprg3	r10; 		/* sprg3: saved r10 */ \
+	mfcr	r10; 		/* r10:	saved cr */ \
+	mfsrr1	r1; 		/* Get msr */ \
+	mtcr	r1; \
+	bt	17, 1f;		/* Exception from user mode? */ \
+	mfsprg1	r1; 		/* Kernel mode => restore orignal sp */ \
+	b	2f; \
+1:	mfsprg0	r1; 		/* User mode => Load kernel stack */ \
+2:	mtcr	r10; 		/* Restore cr */ \
+	mfsprg3 r10;		/* Restore r10 */ \
+	SAVE_ALL ; \
+	li	r10, id; \
+	ABS_JUMP(xfer);
+
+#define INTR_ENTRY(offset, name, id) \
+		EXCEPTION_ENTRY(offset, name, id, interrupt_common)
+
+#define TRAP_ENTRY(offset, name, id) \
+		EXCEPTION_ENTRY(offset, name, id, trap_common)
+
+/*
+ * Macro to build a system call entry.
+ */
+#define SYSC_ENTRY(offset, name, id) \
+	.skip offset - (. - exception_vector); \
+exception_##name: \
+	mtsprg1 r1;		/* sprg1: current sp */ \
+	mfsprg0	r1; 		/* Load kernel stack */ \
+	SAVE_ALL ; \
+	li	r10, id; \
+	ABS_JUMP(syscall_entry);
+
+/*
+ * Exception vectors
+ */
+.globl	exception_vector
+exception_vector:
+	.long	0
+
+	.skip 0x100 - (. - exception_vector); \
+ENTRY(system_reset)
+	ABS_JUMP(kernel_start)
+
+TRAP_ENTRY(0x200, machine_check  ,TRAP_MACHINE_CHECK)
+TRAP_ENTRY(0x300, dsi            ,TRAP_DSI)
+TRAP_ENTRY(0x400, isi            ,TRAP_ISI)
+INTR_ENTRY(0x500, external_intr  ,TRAP_EXT_INTERRUPT)
+TRAP_ENTRY(0x600, alignment      ,TRAP_ALIGNMENT)
+TRAP_ENTRY(0x700, program        ,TRAP_PROGRAM)
+TRAP_ENTRY(0x800, fp_unavailable ,TRAP_FP_UNAVAILABLE)
+INTR_ENTRY(0x900, decrementer    ,TRAP_DECREMENTER)
+SYSC_ENTRY(0xc00, syscall        ,TRAP_SYSTEM_CALL)
+TRAP_ENTRY(0xd00, trace          ,TRAP_TRACE)
+TRAP_ENTRY(0xe00, fp_assist      ,TRAP_FP_ASSIST)
+
+.globl	exception_vector_end
+exception_vector_end:
+
+
+/*
+ * Kernel start point
+ */
+ENTRY(kernel_start)
+	/*
+	 * Setup CPU registers.
+	 */
+	li	r3, MSR_IP		/* Establish default MSR value */
+	mtmsr	r3
+
+	li	r3, 0			/* Init interrupt nest count */
+	mtspr	SPR_SPRG2, r3
+
+	li	r3, 0			/* Reset timebase */
+	mttbl	r3
+	mttbu	r3
+	mttbl	r3
+
+	/*
+	 * Init boot stack
+	 */
+	lis	r1, BOOTSTKTOP@ha
+	addi	r1, r1, BOOTSTKTOP@l
+	subi	r1, r1, 16
+
+	mtspr	SPR_SPRG0, r1		/* Keep kernel stack */
+
+	/*
+	 * Clear kernel BSS
+	 */
+	lis	r3, __bss@ha
+	addi	r3, r3, __bss@l
+	lis	r4, __end@ha
+	addi	r4, r4, __end@l
+	li	r0, 0
+1:
+	stwu	r0, 4(r3)
+	cmplw	cr0, r3, r4
+	blt	1b
+
+	/*
+	 * Call kernel main routine
+	 */
+	b	main
+	/* NOTREACHED */
+
+
+/*
+ * Common entry for interrupts.
+ * r3 - trap id
+ */
+ENTRY(interrupt_common)
+	stw	r10, CTX_TRAPNO(r1)
+
+	mfsprg2	r28			/* r28: current IRQ nesting level */
+	addi	r3, r28, 1		/* Increment IRQ nesting level */
+	mtsprg2	r3
+
+	mfmsr	r29			/* r29: current msr value */
+	isync
+	mr	r30, r1			/* r30: trap frame */
+	subi	r1, r1, STKFRAME_LEN	/* Adjust stack frame for C routine */
+
+	cmpwi	cr0, r28, 0		/* Outermost interrupt? */
+	bne	1f
+	bl	sched_lock		/* If outermost, lock scheduler */
+1:
+	mr	r3, r30
+	bl	interrupt_handler	/* Call main interrupt handler */
+
+	mtsprg2	r28			/* Restore IRQ nesting level */
+	cmpwi	cr0, r28, 0		/* Outermost interrupt? */
+	bne	interrupt_ret
+	bl	sched_unlock		/* Try to preempt */
+
+	mtcr	r29			/* Exception from user mode? */
+	bf	17, interrupt_ret	/* Exit if it's from kernel mode */
+
+	mfmsr	r27			/* Enable IRQ */
+	andi.	r4, r27, ~MSR_EE@l
+	mtmsr	r4
+	bl	exception_deliver	/* Check exception */
+	mtmsr	r27			/* Disable IRQ */
+interrupt_ret:
+	mr	r1, r30			/* Restore stack */
+	RESTORE_ALL
+	mfsprg1	r1			/* restore original sp */
+	rfi
+
+/*
+ * System call entry
+ */
+	.global syscall_ret
+ENTRY(syscall_entry)
+ 	stw	r10, CTX_TRAPNO(r1)
+
+	mfmsr	r29			/* r29: current msr value */
+	mr	r30, r1			/* r30: trap frame */
+	subi	r1, r1, STKFRAME_LEN	/* Adjust stack frame for C routine */
+
+	mfmsr	r27			/* Enable IRQ */
+	andi.	r27, r27, ~MSR_EE@l
+	mtmsr	r27
+
+	mr	r26, r0			/* r26: saved syscall number */
+	mr	r7, r0
+	bl	syscall_handler		/* System call dispatcher */
+
+	cmpwi	cr0, r26, 0		/* exception_return? */
+	beq	1f			/* Skip storing error if so */
+ 	stw	r3, REG_R3(30)		/* Set return value */
+1:
+	bl	exception_deliver	/* Check exception */
+	mr	r1, r30			/* Restore stack */
+syscall_ret:
+	mfmsr	r27			/* Disable IRQ */
+	ori	r27, r27, MSR_EE@l
+	mtmsr	r27
+	RESTORE_ALL
+	mfsprg1	r1			/* Restore original sp */
+	rfi
+
+/*
+ * Common entry for exceptions.
+ * r3 - trap id
+ */
+ENTRY(trap_common)
+	stw	r10, CTX_TRAPNO(r1)
+
+	mfsprg2	r3			/* increment nest counter */
+	addi	r3, r3, 1
+	mtsprg2	r3
+
+	mr	r3, r1
+	subi	r1, r1, STKFRAME_LEN
+	bl	trap_handler
+	addi	r1, r1, STKFRAME_LEN
+
+	mfsprg2	r3			/* decrement nest counter */
+	addi	r3, r3, -1
+	mtsprg2	r3
+
+	RESTORE_ALL
+	mfsprg1	r1			/* restore original sp */
+	rfi
+
+/*
+ * Switch register context.
+ * r3 = previous kern_regs, r4 = next kern_regs
+ * Interrupts must be disabled by caller.
+ *
+ * syntax - void cpu_switch(kern_regs *prev, kern_regs *next)
+ *
+ * Note: GCC uses r0-r12 as scratch registers
+ */
+ENTRY(cpu_switch)
+	isync
+	stw	r13, 0x00(r3)
+	stw	r14, 0x04(r3)
+	stw	r15, 0x08(r3)
+	stw	r16, 0x0c(r3)
+	stw	r17, 0x10(r3)
+	stw	r18, 0x14(r3)
+	stw	r19, 0x18(r3)
+	stw	r20, 0x1c(r3)
+	stw	r21, 0x20(r3)
+	stw	r22, 0x24(r3)
+	stw	r23, 0x28(r3)
+	stw	r24, 0x2c(r3)
+	stw	r25, 0x30(r3)
+	stw	r26, 0x34(r3)
+	stw	r27, 0x38(r3)
+	stw	r28, 0x3c(r3)
+	stw	r29, 0x40(r3)
+	stw	r30, 0x44(r3)
+	stw	r31, 0x48(r3)
+	stw	r2,  0x4c(r3)
+	stw	r1,  0x50(r3)
+	mflr	r5
+	stw	r5,  0x54(r3)
+	mfcr	r5
+	stw	r5,  0x58(r3)
+	mfsprg0	r5			/* Save kernel stack */
+	stw	r5,  0x5c(r3)
+
+	lwz	r13, 0x00(r4)
+	lwz	r14, 0x04(r4)
+	lwz	r15, 0x08(r4)
+	lwz	r16, 0x0c(r4)
+	lwz	r17, 0x10(r4)
+	lwz	r18, 0x14(r4)
+	lwz	r19, 0x18(r4)
+	lwz	r20, 0x1c(r4)
+	lwz	r21, 0x20(r4)
+	lwz	r22, 0x24(r4)
+	lwz	r23, 0x28(r4)
+	lwz	r24, 0x2c(r4)
+	lwz	r25, 0x30(r4)
+	lwz	r26, 0x34(r4)
+	lwz	r27, 0x38(r4)
+	lwz	r28, 0x3c(r4)
+	lwz	r29, 0x40(r4)
+	lwz	r30, 0x44(r4)
+	lwz	r31, 0x48(r4)
+	lwz	r2,  0x4c(r4)
+	lwz	r1,  0x50(r4)
+	lwz	r5,  0x54(r4)
+	mtlr	r5
+	lwz	r5,  0x58(r4)
+	mtcr	r5
+	lwz	r5,  0x5c(r4)
+	mtsprg0	r5			/* Restore kernel stack */
+	isync
+	blr
+
+/*
+ * void sploff(void);
+ */
+ENTRY(sploff)
+	mfmsr	r3
+	andi.	r4, r3, ~MSR_EE@l
+	mtmsr	r4
+	blr
+
+/*
+ * void splon(void);
+ */
+ENTRY(splon)
+	mfmsr	r3
+	ori	r4, r3, MSR_EE@l
+	mtmsr	r4
+	blr
+
diff --git a/prex-0.9.0/bsp/hal/ppc/arch/trap.c b/prex-0.9.0/bsp/hal/ppc/arch/trap.c
new file mode 100755
index 0000000..2377012
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/arch/trap.c
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * trap.c - called from the trap handler when a processor trap occurs.
+ */
+
+#include <kernel.h>
+#include <task.h>
+#include <hal.h>
+#include <exception.h>
+#include <cpu.h>
+#include <trap.h>
+#include <cpufunc.h>
+#include <context.h>
+#include <locore.h>
+
+#include <sys/signal.h>
+
+#ifdef DEBUG
+/*
+ * Trap name.
+ */
+static const char *const trap_name[] = {
+	"",				/*  0 */
+	"System reset",			/*  1 */
+	"Machine check",		/*  2 */
+	"DSI",				/*  3 */
+	"ISI",				/*  4 */
+	"External interrupt",		/*  5 */
+	"Alignment",			/*  6 */
+	"Program",			/*  7 */
+	"Floating point unavailable",	/*  8 */
+	"Decrementer",			/*  9 */
+	"Reserved",			/*  a */
+	"Reserved",			/*  b */
+	"System call",			/*  c */
+	"Trace",			/*  d */
+	"Floating point assist",	/*  e */
+};
+#define MAXTRAP (sizeof(trap_name) / sizeof(void *) - 1)
+#endif	/* DEBUG */
+
+/*
+ * Exception mapping table.
+ * PPC exception is translated to the architecture
+ * independent exception code.
+ */
+static const int exception_map[] = {
+	SIGILL,
+	SIGILL,
+	SIGSEGV,	/* machine check */
+	SIGSEGV,	/* address error (store) */
+	SIGBUS,		/* instruction bus error */
+	SIGINT,		/* external interrupt */
+	SIGBUS,		/* alingment */
+	SIGTRAP,	/* breakpoint trap */
+	SIGFPE,		/* fpu unavail */
+	SIGALRM,	/* decrementer */
+	SIGILL,		/* reserved */
+	SIGILL,		/* reserved */
+	SIGCHLD,	/* syscall */
+	SIGTRAP,	/* debug trap */
+	SIGFPE,		/* fp assist */
+};
+
+/*
+ * Trap handler
+ * Invoke the exception handler if it is needed.
+ */
+void
+trap_handler(struct cpu_regs *regs)
+{
+	uint32_t trap_no = regs->trap_no;
+
+#ifdef DEBUG
+	printf("============================\n");
+	printf("Trap %x: %s\n", trap_no, trap_name[trap_no]);
+	printf("============================\n");
+
+	trap_dump(regs);
+	for (;;) ;
+#endif
+	if ((regs->srr1 & MSR_PR) != MSR_PR)
+		panic("Kernel exception");
+
+	exception_mark(exception_map[trap_no]);
+	exception_deliver();
+}
+
+#ifdef DEBUG
+void
+trap_dump(struct cpu_regs *r)
+{
+
+	printf("Trap frame %x\n", r);
+	printf(" r0  %08x r1  %08x r2  %08x r3  %08x r4  %08x r5  %08x\n",
+	       r->gr[0], r->gr[1], r->gr[2], r->gr[3], r->gr[4], r->gr[5]);
+	printf(" r6  %08x r7  %08x r8  %08x r9  %08x r10 %08x r11 %08x\n",
+	       r->gr[6], r->gr[7], r->gr[8], r->gr[9], r->gr[10], r->gr[11]);
+	printf(" r12 %08x r13 %08x r14 %08x r15 %08x r16 %08x r17 %08x\n",
+	       r->gr[12], r->gr[13], r->gr[14], r->gr[15], r->gr[16], r->gr[17]);
+	printf(" r18 %08x r19 %08x r20 %08x r21 %08x r22 %08x r23 %08x\n",
+	       r->gr[18], r->gr[19], r->gr[20], r->gr[21], r->gr[22], r->gr[23]);
+	printf(" r24 %08x r25 %08x r26 %08x r27 %08x r28 %08x r29 %08x\n",
+	       r->gr[24], r->gr[25], r->gr[26], r->gr[27], r->gr[28], r->gr[29]);
+	printf(" r30 %08x r31 %08x lr  %08x cr  %08x xer %08x ctr %08x\n",
+	       r->gr[30], r->gr[31], r->lr, r->cr, r->xer, r->ctr);
+	printf(" srr0 %08x srr1 %08x\n", r->srr0, r->srr1);
+
+	printf(" >> interrupt is %s\n",
+	       (r->srr1 & MSR_EE) ? "enabled" : "disabled");
+
+	printf(" >> task=%s\n", curtask->name);
+}
+#endif /* !DEBUG */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/clock.h b/prex-0.9.0/bsp/hal/ppc/include/clock.h
new file mode 100755
index 0000000..4207a1d
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/clock.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_CLOCK_H
+#define _PPC_CLOCK_H
+
+#include <sys/cdefs.h>
+
+#ifndef __ASSEMBLY__
+
+__BEGIN_DECLS
+int	clock_isr(void *);
+__END_DECLS
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_PPC_CLOCK_H */
+
diff --git a/prex-0.9.0/bsp/hal/ppc/include/context.h b/prex-0.9.0/bsp/hal/ppc/include/context.h
new file mode 100755
index 0000000..4be73b3
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/context.h
@@ -0,0 +1,122 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_CONTEXT_H
+#define _PPC_CONTEXT_H
+
+#ifndef __ASSEMBLY__
+
+#include <sys/types.h>
+
+/*
+ * Common register frame for trap/interrupt.
+ * These cpu state are saved into top of the kernel stack in
+ * trap/interrupt entries. Since the arguments of system calls are
+ * passed via registers, the system call library is completely
+ * dependent on this register format.
+ */
+struct cpu_regs {
+	uint32_t	gr[32];		/* R0-R31 */
+	uint32_t	lr;
+	uint32_t	cr;
+	uint32_t	xer;
+	uint32_t	ctr;
+	uint32_t	srr0;
+	uint32_t	srr1;
+	uint32_t	trap_no;	/* trap number */
+};
+
+/*
+ * Kernel mode context for context switching.
+ */
+struct kern_regs {
+	uint32_t	gr[19];		/* R13-R31 */
+	uint32_t	r2;
+	uint32_t	sp;
+	uint32_t	lr;
+	uint32_t	cr;
+	uint32_t	kstack;		/* kernel stack */
+};
+
+/*
+ * Processor context
+ */
+struct context {
+	struct kern_regs kregs;		/* kernel mode registers */
+	struct cpu_regs	*uregs;		/* user mode registers */
+	struct cpu_regs	*saved_regs;	/* saved user mode registers */
+};
+
+typedef struct context *context_t;	/* context id */
+
+#endif /* !__ASSEMBLY__ */
+
+#define REG_R0		0x00
+#define REG_R1		0x04
+#define REG_R2		0x08
+#define REG_R3		0x0c
+#define REG_R4		0x10
+#define REG_R5		0x14
+#define REG_R6		0x18
+#define REG_R7		0x1c
+#define REG_R8		0x20
+#define REG_R9		0x24
+#define REG_R10		0x28
+#define REG_R11		0x2c
+#define REG_R12		0x30
+#define REG_R13		0x34
+#define REG_R14		0x38
+#define REG_R15		0x3c
+#define REG_R16		0x40
+#define REG_R17		0x44
+#define REG_R18		0x48
+#define REG_R19		0x4c
+#define REG_R20		0x50
+#define REG_R21		0x54
+#define REG_R22		0x58
+#define REG_R23		0x5c
+#define REG_R24		0x60
+#define REG_R25		0x64
+#define REG_R26		0x68
+#define REG_R27		0x6c
+#define REG_R28		0x70
+#define REG_R29		0x74
+#define REG_R30		0x78
+#define REG_R31		0x7c
+#define REG_LR		0x80
+#define REG_CR		0x84
+#define REG_XER		0x88
+#define REG_CTR		0x8c
+#define REG_SRR0	0x90
+#define REG_SRR1	0x94
+#define CTX_TRAPNO	0x98
+
+#define CTXREGS		(4*39)
+
+#endif /* !_PPC_CONTEXT_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/cpu.h b/prex-0.9.0/bsp/hal/ppc/include/cpu.h
new file mode 100755
index 0000000..b79969c
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/cpu.h
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_CPU_H
+#define _PPC_CPU_H
+
+#include <sys/cdefs.h>
+
+#define STKFRAME_LEN	8		/* length for stack frame */
+
+/*
+ * Flags in MSR
+ */
+#define	MSR_LE		0x00000001	/* little-endian mode enable */
+#define	MSR_RI		0x00000002	/* recoverable exception */
+#define	MSR_DR		0x00000010	/* data address translation */
+#define	MSR_IR		0x00000020	/* instruction address translation */
+#define	MSR_IP		0x00000040	/* exception prefix */
+#define	MSR_FE1		0x00000100	/* floating-point exception mode 1 */
+#define	MSR_BE		0x00000200	/* branch trace enable */
+#define	MSR_SE		0x00000400	/* single-step trace enable */
+#define	MSR_FE0		0x00000800	/* floating-point exception mode 0 */
+#define	MSR_ME		0x00001000	/* machine check enable */
+#define	MSR_FP		0x00002000	/* floating-point available */
+#define	MSR_PR		0x00004000	/* privilege level (1:USR) */
+#define	MSR_EE		0x00008000	/* external interrupt enable */
+#define	MSR_ILE		0x00010000	/* exception little-endian mode (1:LE) */
+#define	MSR_POW		0x00040000	/* power management enable */
+
+
+/* default msr for starting user program */
+#if 0
+#ifdef CONFIG_MMU
+#define MSR_DFLT	(uint32_t)(MSR_EE | MSR_PR | MSR_ME | MSR_IR | MSR_DR)
+#else
+#define MSR_DFLT	(uint32_t)(MSR_EE | MSR_PR | MSR_ME)
+#endif
+#endif
+#define MSR_DFLT	(uint32_t)(MSR_EE | MSR_PR)
+
+/*
+ * Special Purpose Register declarations.
+ */
+#define	SPR_XER			  1	/* fixed point exception register */
+#define	SPR_LR			  8	/* link register */
+#define	SPR_CTR			  9	/* count register */
+#define	SPR_DSISR		 18	/* DSI exception register */
+#define	SPR_DAR			 19	/* data access register */
+#define	SPR_DEC			 22	/* decrementer register */
+#define	SPR_SRR0		 26	/* save/restore register 0 */
+#define	SPR_SRR1		 27	/* save/restore register 1 */
+#define	SPR_SPRG0		272	/* SPR general 0 */
+#define	SPR_SPRG1		273	/* SPR general 1 */
+#define	SPR_SPRG2		274	/* SPR general 2 */
+#define	SPR_SPRG3		275	/* SPR general 3 */
+#define	SPR_PVR			287	/* processor version register */
+
+
+#ifndef __ASSEMBLY__
+
+__BEGIN_DECLS
+void	 outb(int, u_char);
+u_char	 inb(int);
+__END_DECLS
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_PPC_CPU_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/cpufunc.h b/prex-0.9.0/bsp/hal/ppc/include/cpufunc.h
new file mode 100755
index 0000000..d6029bf
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/cpufunc.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_CPUFUNC_H
+#define _PPC_CPUFUNC_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+uint32_t get_decr(void);
+void	 set_decr(uint32_t);
+void	 cpu_idle(void);
+__END_DECLS
+
+#endif /* !_PPC_CPUFUNC_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/io.h b/prex-0.9.0/bsp/hal/ppc/include/io.h
new file mode 100755
index 0000000..9ab97e5
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/io.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_IO_H
+#define _PPC_IO_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	 outb(int, u_char);
+u_char	 inb(int);
+__END_DECLS
+
+#endif /* !_PPC_IO_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/locore.h b/prex-0.9.0/bsp/hal/ppc/include/locore.h
new file mode 100755
index 0000000..574c67d
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/locore.h
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_LOCORE_H
+#define _PPC_LOCORE_H
+
+#include <sys/cdefs.h>
+#include <context.h>
+
+__BEGIN_DECLS
+void	syscall_entry(void);
+void	syscall_ret(void);
+void	cpu_switch(struct kern_regs *, struct kern_regs *);
+void	cpu_reset(void);
+void	splon(void);
+void	sploff(void);
+__END_DECLS
+
+#define cache_init()	((void)0)
+
+#endif /* !_PPC_LOCORE_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/mmu.h b/prex-0.9.0/bsp/hal/ppc/include/mmu.h
new file mode 100755
index 0000000..e5fce21
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/mmu.h
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_MMU_H
+#define _PPC_MMU_H
+
+#include <sys/types.h>
+
+typedef uint32_t	*pgd_t;		/* page directory */
+
+struct pte {
+	uint32_t	pte_hi;
+	uint32_t	pte_lo;
+};
+
+typedef struct pte	*pte_t;		/* page table entry */
+
+/*
+ * Page table entry
+ */
+/* high word: */
+#define PTE_VALID	0x00000001	/* valid */
+#define	PTE_VSID	0x7fffff80	/* virtual segment */
+#define	PTE_HID		0x00000040	/* hash */
+#define	PTE_API		0x0000003f	/* abbreviated page index */
+
+/* low word: */
+#define	PTE_RPN		0xfffff000	/* real page number */
+#define	PTE_REF		0x00000100	/* reference */
+#define	PTE_CHG		0x00000080	/* change */
+#define	PTE_WIMG	0x00000078	/* memory/cache control */
+#define	PTE_PP		0x00000003	/* page protection */
+
+/*
+ *  Virtual and physical address translation
+ */
+#define PAGE_DIR(virt)
+#define PAGE_TABLE(virt)
+
+#define pte_present(pgd, virt)
+
+#define page_present(pte, virt)
+
+#define vtopte(pgd, virt)
+
+#define ptetopg(pte, virt)
+
+#endif /* !_PPC_MMU_H */
diff --git a/prex-0.9.0/bsp/hal/ppc/include/trap.h b/prex-0.9.0/bsp/hal/ppc/include/trap.h
new file mode 100755
index 0000000..80e8325
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/include/trap.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_TRAP_H
+#define _PPC_TRAP_H
+
+#include <sys/cdefs.h>
+
+/*
+ * Trap ID
+ */
+#define TRAP_SYSTEM_RESET	1
+#define TRAP_MACHINE_CHECK	2
+#define TRAP_DSI		3
+#define TRAP_ISI		4
+#define TRAP_EXT_INTERRUPT	5
+#define TRAP_ALIGNMENT		6
+#define TRAP_PROGRAM		7
+#define TRAP_FP_UNAVAILABLE	8
+#define TRAP_DECREMENTER	9
+#define TRAP_RESERVED0		10
+#define TRAP_RESERVED1		11
+#define TRAP_SYSTEM_CALL	12
+#define TRAP_TRACE		13
+#define TRAP_FP_ASSIST		14
+
+
+#ifndef __ASSEMBLY__
+
+__BEGIN_DECLS
+void	 trap_handler(struct cpu_regs *);
+void	 trap_dump(struct cpu_regs *);
+__END_DECLS
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_PPC_TRAP_H */
+
diff --git a/prex-0.9.0/bsp/hal/ppc/prep/Makefile.inc b/prex-0.9.0/bsp/hal/ppc/prep/Makefile.inc
new file mode 100755
index 0000000..370d2bd
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/prep/Makefile.inc
@@ -0,0 +1,17 @@
+
+SRCS:=		ppc/arch/locore.S \
+		ppc/arch/cpufunc.S \
+		ppc/arch/trap.c \
+		ppc/arch/context.c \
+		ppc/arch/cpu.c \
+		ppc/arch/clock.c \
+		ppc/prep/io.c \
+		ppc/prep/machdep.c \
+		ppc/prep/interrupt.c
+
+ifeq ($(CONFIG_MMU),y)
+SRCS+=		ppc/arch/mmu_oea.c
+endif
+ifeq ($(DEBUG),1)
+SRCS+=		ppc/prep/diag.c
+endif
diff --git a/prex-0.9.0/bsp/hal/ppc/prep/diag.c b/prex-0.9.0/bsp/hal/ppc/prep/diag.c
new file mode 100755
index 0000000..7102458
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/prep/diag.c
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * diag.c - diagnostic message support
+ */
+
+#include <sys/bootinfo.h>
+#include <kernel.h>
+#include <cpufunc.h>
+#include <io.h>
+
+#ifdef CONFIG_DIAG_SERIAL
+
+#define COM_BASE	CONFIG_NS16550_BASE
+#define COM_THR		(COM_BASE + 0x00)	/* transmit holding register */
+#define COM_LSR		(COM_BASE + 0x05)	/* line status register */
+
+static void
+serial_putc(char c)
+{
+
+	while (!(inb(COM_LSR) & 0x20))
+		;
+	outb(COM_THR, c);
+}
+
+void
+diag_puts(char *str)
+{
+
+	while (*str) {
+		if (*str == '\n')
+			serial_putc('\r');
+		serial_putc(*str++);
+	}
+}
+
+/*
+ * We assume the serial port has already been initialized by
+ * the boot loader.
+ */
+void
+diag_init(void)
+{
+	/* DO NOTHING */
+}
+#endif	/* !CONFIG_DIAG_SERIAL */
+
+#ifdef CONFIG_DIAG_QEMU
+void
+diag_puts(char *str)
+{
+
+	while (*str) {
+		/* Write to the qemu debug port. */
+		outb(0xf00, (u_char)*str++);
+	}
+}
+
+void
+diag_init(void)
+{
+}
+#endif	/* !CONFIG_DIAG_QEMU */
diff --git a/prex-0.9.0/bsp/hal/ppc/prep/interrupt.c b/prex-0.9.0/bsp/hal/ppc/prep/interrupt.c
new file mode 100755
index 0000000..317a876
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/prep/interrupt.c
@@ -0,0 +1,238 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * interrupt.c - interrupt management routines for intel 8259 chip
+ */
+
+#include <kernel.h>
+#include <hal.h>
+#include <irq.h>
+#include <io.h>
+#include <cpufunc.h>
+#include <context.h>
+#include <trap.h>
+#include <clock.h>
+#include <locore.h>
+#include <sys/ipl.h>
+
+/* Number of IRQ lines */
+#define NIRQS		16
+
+/* I/O address for master/slave programmable interrupt controller */
+#define PIC_M           0x20
+#define PIC_S           0xa0
+
+/* Edge/level control register */
+#define ELCR            0x4d0
+
+/*
+ * Interrupt priority level
+ *
+ * Each interrupt has its logical priority level, with 0 being
+ * the highest priority. While some ISR is running, all lower
+ * priority interrupts are masked off.
+ */
+static volatile int irq_level;
+
+/*
+ * Interrupt mapping table
+ */
+static int	ipl_table[NIRQS];	/* Vector -> level */
+static u_int	mask_table[NIPLS];	/* Level -> mask */
+
+/*
+ * Set mask for current ipl
+ */
+static void
+update_mask(void)
+{
+	u_int mask = mask_table[irq_level];
+
+	outb(PIC_M + 1, mask & 0xff);
+	outb(PIC_S + 1, mask >> 8);
+}
+
+/*
+ * Unmask interrupt in PIC for specified irq.
+ * The interrupt mask table is also updated.
+ * Assumed CPU interrupt is disabled in caller.
+ */
+void
+interrupt_unmask(int vector, int level)
+{
+	u_int unmask = (u_int)~(1 << vector);
+	int i, s;
+
+	s = splhigh();
+	ipl_table[vector] = level;
+	/*
+	 * Unmask target interrupt for all
+	 * lower interrupt levels.
+	 */
+	for (i = 0; i < level; i++)
+		mask_table[i] &= unmask;
+	update_mask();
+	splx(s);
+}
+
+/*
+ * Mask interrupt in PIC for specified irq.
+ * Interrupt must be disabled when this routine is called.
+ */
+void
+interrupt_mask(int vector)
+{
+	u_int mask = (u_int)(1 << vector);
+	int i, level, s;
+
+	s = splhigh();
+	level = ipl_table[vector];
+	for (i = 0; i < level; i++)
+		mask_table[i] |= mask;
+	ipl_table[vector] = IPL_NONE;
+	update_mask();
+	splx(s);
+}
+
+/*
+ * Setup interrupt mode.
+ * Select whether an interrupt trigger is edge or level.
+ */
+void
+interrupt_setup(int vector, int mode)
+{
+	int port, s;
+	u_int bit;
+	u_char val;
+
+	s = splhigh();
+	port = vector < 8 ? ELCR : ELCR + 1;
+	bit = (u_int)(1 << (vector & 7));
+
+	val = inb(port);
+	if (mode == IMODE_LEVEL)
+		val |= bit;
+	else
+		val &= ~bit;
+	outb(port, val);
+	splx(s);
+}
+
+/*
+ * Get interrupt source.
+ */
+static int
+interrupt_lookup(void)
+{
+	int irq;
+
+	outb(PIC_M, 0x0c);	/* poll and ack */
+	irq = inb(PIC_M) & 7;
+	if (irq == 2) {
+		outb(PIC_S, 0x0c);
+		irq = (inb(PIC_M) & 7) + 8;
+	}
+	return irq;
+}
+
+/*
+ * Common interrupt handler.
+ *
+ * This routine is called from the low level interrupt routine
+ * written in assemble code. The interrupt flag is automatically
+ * disabled by h/w in CPU when the interrupt is occurred. The
+ * target interrupt will be masked in ICU while the irq handler
+ * is called.
+ */
+void
+interrupt_handler(struct cpu_regs *regs)
+{
+	int vector;
+	int old_ipl, new_ipl;
+
+	/* Handle decrementer interrupt */
+	if (regs->trap_no == TRAP_DECREMENTER) {
+		clock_isr(NULL);
+		return;
+	}
+
+	/* Find pending interrupt */
+	vector = interrupt_lookup();
+
+	/* Adjust interrupt level */
+	old_ipl = irq_level;
+	new_ipl = ipl_table[vector];
+	if (new_ipl > old_ipl)		/* Ignore spurious interrupt */
+		irq_level = new_ipl;
+	update_mask();
+
+	/* Dispatch interrupt */
+	splon();
+	irq_handler(vector);
+	sploff();
+
+	/* Restore interrupt level */
+	irq_level = old_ipl;
+	update_mask();
+}
+
+/*
+ * Initialize 8259 interrupt controllers.
+ * All interrupts will be masked off in ICU.
+ */
+void
+interrupt_init(void)
+{
+	int i;
+
+	irq_level = IPL_NONE;
+
+	for (i = 0; i < NIRQS; i++)
+		ipl_table[i] = IPL_NONE;
+
+	for (i = 0; i < NIPLS; i++)
+		mask_table[i] = 0xfffb;
+
+	outb(PIC_M, 0x11);	/* Start initialization edge, master */
+	outb(PIC_M + 1, 0x00);	/* Set h/w vector = 0x0 */
+	outb(PIC_M + 1, 0x04);	/* Chain to slave (IRQ2) */
+	outb(PIC_M + 1, 0x01);	/* 8086 mode */
+
+	outb(PIC_S, 0x11);	/* Start initialization edge, master */
+	outb(PIC_S + 1, 0x08);	/* Set h/w vector = 0x8 */
+	outb(PIC_S + 1, 0x02);	/* Slave (cascade) */
+	outb(PIC_S + 1, 0x01);	/* 8086 mode */
+
+	outb(PIC_S, 0x0b);	/* Read ISR by default */
+	outb(PIC_M, 0x0b);	/* Read ISR by default */
+
+	outb(PIC_S + 1, 0xff);	/* Mask all */
+	outb(PIC_M + 1, 0xfb);	/* Mask all except IRQ2 (cascade) */
+}
diff --git a/prex-0.9.0/bsp/hal/ppc/prep/io.c b/prex-0.9.0/bsp/hal/ppc/prep/io.c
new file mode 100755
index 0000000..4e342e7
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/prep/io.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * io.c - i/o access routines
+ */
+
+#include <kernel.h>
+
+volatile u_char *ISA_io  = (u_char *)0x80000000;
+
+void
+outb(int port, u_char val)
+{
+
+	ISA_io[port] = val;
+}
+
+u_char
+inb(int port)
+{
+
+	return (ISA_io[port]);
+}
diff --git a/prex-0.9.0/bsp/hal/ppc/prep/machdep.c b/prex-0.9.0/bsp/hal/ppc/prep/machdep.c
new file mode 100755
index 0000000..2a118a8
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/ppc/prep/machdep.c
@@ -0,0 +1,165 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * machdep.c - machine-dependent routines for PPC PReP
+ */
+
+#include <machine/syspage.h>
+#include <sys/power.h>
+#include <sys/bootinfo.h>
+#include <kernel.h>
+#include <page.h>
+#include <mmu.h>
+#include <cpu.h>
+#include <io.h>
+#include <cpufunc.h>
+#include <locore.h>
+
+extern void *exception_vector;
+extern void *exception_vector_end;
+
+#ifdef CONFIG_MMU
+/*
+ * Virtual and physical address mapping
+ *
+ *      { virtual, physical, size, type }
+ */
+struct mmumap mmumap_table[] =
+{
+	/*
+	 * Physical memory
+	 */
+	{ 0x80000000, 0x00000000, 0x9000000, VMT_RAM },
+
+	/*
+	 * ISA I/O space
+	 */
+	{ 0xf0000000, 0x80000000, 0xf000, VMT_IO },
+
+	{ 0,0,0,0 }
+};
+#endif
+
+/*
+ * Idle
+ */
+void
+machine_idle(void)
+{
+
+	cpu_idle();
+}
+
+/*
+ * Cause PReP machine reset.
+ */
+static void
+machine_reset(void)
+{
+	u_char val;
+
+	val = inb(0x92);
+	val &= ~1UL;
+	outb(0x92, val);
+
+	val = inb(0x92);
+	val |= 1;
+	outb(0x92, val);
+
+	/* NOTREACHED */
+}
+
+/*
+ * Set system power
+ */
+void
+machine_powerdown(int state)
+{
+
+	DPRINTF(("Power down machine\n"));
+
+	splhigh();
+
+	switch (state) {
+	case PWR_SUSPEND:
+	case PWR_OFF:
+		for (;;)
+			cpu_idle();
+		/* NOTREACHED */
+		break;
+	case PWR_REBOOT:
+		machine_reset();
+		/* NOTREACHED */
+		break;
+	}
+}
+
+/*
+ * Return pointer to the boot information.
+ */
+void
+machine_bootinfo(struct bootinfo **bip)
+{
+
+	*bip = (struct bootinfo *)BOOTINFO;
+}
+
+void
+machine_abort(void)
+{
+
+	for (;;) ;
+}
+
+/*
+ * Machine-dependent startup code
+ */
+void
+machine_startup(void)
+{
+	void *vector_offset = 0;
+
+	/*
+	 * Reserve system pages.
+	 */
+	page_reserve(kvtop(SYSPAGE), SYSPAGESZ);
+
+	/*
+	 * Copy exception vectors.
+	 */
+	memcpy(vector_offset, &exception_vector, 0x3000);
+
+#ifdef CONFIG_MMU
+	/*
+	 * Initialize MMU
+	 */
+	mmu_init(mmumap_table);
+#endif
+}
diff --git a/prex-0.9.0/bsp/hal/x86/arch/context.c b/prex-0.9.0/bsp/hal/x86/arch/context.c
new file mode 100755
index 0000000..da7b3c0
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/context.c
@@ -0,0 +1,209 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * context.c - context management routines
+ */
+
+/*
+ * The context consists of kernel/user mode registers, and kernel
+ * stack. The user mode registers are always saved to the kernel
+ * stack when processor enters kernel mode by H/W or S/W events.
+ *
+ * The user mode registers are located in the interrupt/trap
+ * frame at the top of the kernel stack. Before the control
+ * returns to user mode next time, these register value will be
+ * restored automatically.
+ *
+ * All thread owns its context to keep its execution state. The
+ * scheduler will switch the context to change an active thread.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <cpu.h>
+#include <trap.h>
+#include <context.h>
+#include <locore.h>
+
+/*
+ * Set user mode registers into the specific context.
+ *
+ * Note: When user mode program counter is set, all register
+ * values except a stack pointer are reset to default value.
+ */
+void
+context_set(context_t ctx, int type, register_t val)
+{
+	struct kern_regs *k;
+	struct cpu_regs *u;
+	uint32_t *argp;
+
+	k = &ctx->kregs;
+
+	switch (type) {
+	case CTX_KSTACK:
+		/* Set kernel mode stack pointer */
+		ctx->uregs = (struct cpu_regs *)
+				((uint32_t)val - sizeof(struct cpu_regs));
+		ctx->esp0 = (uint32_t)val;
+
+		k->eip = (uint32_t)&syscall_ret;
+		k->esp = (uint32_t)ctx->uregs - sizeof(uint32_t);
+
+		/* Reset minimum user mode registers */
+		u = ctx->uregs;
+		u->eax = 0;
+		u->eflags = (uint32_t)(EFL_IF | EFL_IOPL_KERN);
+		break;
+
+	case CTX_KENTRY:
+		/* Kernel mode program counter */
+		k->eip = (uint32_t)val;
+		break;
+
+	case CTX_KARG:
+		/* Kernel mode argument */
+		argp = (uint32_t *)(k->esp + sizeof(uint32_t) * 2);
+		*argp = (uint32_t)val;
+		break;
+
+	case CTX_USTACK:
+		/* User mode stack pointer */
+		u = ctx->uregs;
+		u->esp = (uint32_t)val;
+		u->ss = (uint32_t)(USER_DS | 3); /* fail safe */
+		break;
+
+	case CTX_UENTRY:
+		/* User mode program counter */
+		u = ctx->uregs;
+		u->eip = (uint32_t)val;
+		u->cs = (uint32_t)(USER_CS | 3);
+		u->ds = u->es = (uint32_t)(USER_DS | 3);
+		u->eflags = (uint32_t)(EFL_IF | EFL_IOPL_KERN);
+		u->eax = u->ebx = u->ecx = u->edx =
+			u->edi = u->esi = u->ebp = 0;
+		break;
+
+	case CTX_UARG:
+		/* User mode argument */
+		u = ctx->uregs;
+		argp = (uint32_t *)(u->esp + sizeof(uint32_t));
+		copyout(&val, argp, sizeof(uint32_t));
+		break;
+
+	default:
+		/* invalid */
+		break;
+	}
+}
+
+/*
+ * Switch to new context
+ *
+ * Kernel mode registers and kernel stack pointer are switched to
+ * the next context.
+ *
+ * We don't use x86 task switch mechanism to minimize the context
+ * space. The system has only one TSS(task state segment), and
+ * the context switching is done by changing the register value
+ * in this TSS. Processor will reload them automatically when it
+ * enters to the kernel mode in next time.
+ *
+ * It is assumed all interrupts are disabled by caller.
+ *
+ * TODO: FPU context is not switched as of now.
+ */
+void
+context_switch(context_t prev, context_t next)
+{
+	/* Set kernel stack pointer in TSS (esp0). */
+	tss_set((uint32_t)next->esp0);
+
+	/* Save the previous context, and restore the next context */
+	cpu_switch(&prev->kregs, &next->kregs);
+}
+
+/*
+ * Save user mode context to handle exceptions.
+ *
+ * Copy current user mode registers in the kernel stack to the
+ * user mode stack. The user stack pointer is adjusted for this
+ * area. So that the exception handler can get the register
+ * state of the target thread.
+ *
+ * It builds arguments for the exception handler in the following
+ * format.
+ *
+ *   void exception_handler(int exc, void *regs);
+ */
+void
+context_save(context_t ctx)
+{
+	struct cpu_regs *cur, *sav;
+
+	/* Copy current register context into user mode stack */
+	cur = ctx->uregs;
+	sav = (struct cpu_regs *)(cur->esp - sizeof(*sav));
+	copyout(cur, sav, sizeof(*sav));
+
+
+	ctx->saved_regs = sav;
+
+	/* Adjust stack pointer */
+	cur->esp = (uint32_t)sav - (sizeof(uint32_t) * 2);
+}
+
+/*
+ * Restore register context to return from the exception handler.
+ */
+void
+context_restore(context_t ctx)
+{
+	struct cpu_regs *cur;
+
+	/* Restore user mode context */
+	cur = ctx->uregs;
+	copyin(ctx->saved_regs, cur, sizeof(*cur));
+
+	/* Correct some registers for fail safe */
+	cur->cs = (uint32_t)(USER_CS | 3);
+	cur->ss = cur->ds = cur->es = (uint32_t)(USER_DS | 3);
+	cur->eflags |= EFL_IF;
+}
+
+void
+context_dump(context_t ctx)
+{
+
+#ifdef DEBUG
+	trap_dump(ctx->uregs);
+#endif
+}
diff --git a/prex-0.9.0/bsp/hal/x86/arch/cpu.c b/prex-0.9.0/bsp/hal/x86/arch/cpu.c
new file mode 100755
index 0000000..1dec36a
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/cpu.c
@@ -0,0 +1,225 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpu.c - cpu dependent routines for Intel x86
+ */
+
+#include <machine/syspage.h>
+#include <kernel.h>
+#include <cpu.h>
+#include <locore.h>
+#include <cpufunc.h>
+
+typedef void (*trapfn_t)(void);
+
+/*
+ * Descriptors
+ */
+static struct seg_desc gdt[NGDTS];
+static struct gate_desc idt[NIDTS];
+static struct tss tss;
+
+/*
+ * Interrupt table
+ */
+static const trapfn_t intr_table[] = {
+	intr_0, intr_1, intr_2, intr_3,	intr_4, intr_5, intr_6,
+	intr_7, intr_8, intr_9, intr_10, intr_11, intr_12, intr_13,
+	intr_14, intr_15
+};
+
+/*
+ * Trap table
+ */
+static const trapfn_t trap_table[] = {
+	trap_0, trap_1, trap_2, trap_3,	trap_4, trap_5, trap_6,
+	trap_7,	trap_8, trap_9, trap_10, trap_11, trap_12, trap_13,
+	trap_14, trap_15, trap_16, trap_17, trap_18
+};
+#define NTRAPS	(int)(sizeof(trap_table) / sizeof(void *))
+
+/*
+ * Set kernel stack pointer in TSS (task state segment).
+ * An actual value of the register is automatically set when
+ * CPU enters kernel mode next time.
+ */
+void
+tss_set(uint32_t kstack)
+{
+
+	tss.esp0 = kstack;
+}
+
+/*
+ * tss_get() returns current esp0 value for trap handler.
+ */
+uint32_t
+tss_get(void)
+{
+
+	return tss.esp0;
+}
+
+/*
+ * Set GDT (global descriptor table) members into specified vector
+ */
+static void
+gdt_set(int vec, void *base, size_t limit, int type, u_int size)
+{
+	struct seg_desc *seg = &gdt[vec];
+
+	if (limit > 0xfffff) {
+		limit >>= 12;
+		size |= SIZE_4K;
+	}
+	seg->limit_lo = limit;
+	seg->base_lo = (u_int)base & 0xffff;
+	seg->base_mid = ((u_int)base >> 16) & 0xff;
+	seg->limit_hi = limit >> 16;
+	seg->base_hi = (u_int)base >> 24;
+	seg->type = (u_int)type | ST_PRESENT;
+	seg->size = size;
+}
+
+/*
+ * Set IDT (interrupt descriptor table) members into specified vector
+ */
+static void
+idt_set(int vec, trapfn_t off, u_int sel, int type)
+{
+	struct gate_desc *gate = &idt[vec];
+
+	gate->offset_lo = (u_int)off & 0xffff;
+	gate->selector = sel;
+	gate->nr_copy = 0;
+	gate->type = (u_int)type | ST_PRESENT;
+	gate->offset_hi = (u_int)off >> 16;
+}
+
+/*
+ * Setup the GDT and load it.
+ */
+static void
+gdt_init(void)
+{
+	struct desc_p gdt_p;
+
+	/* Set system vectors */
+	gdt_set(KERNEL_CS / 8, 0, 0xffffffff, ST_KERN | ST_CODE_R, SIZE_32);
+	gdt_set(KERNEL_DS / 8, 0, 0xffffffff, ST_KERN | ST_DATA_W, SIZE_32);
+	gdt_set(USER_CS / 8, 0, 0xffffffff, ST_USER | ST_CODE_R, SIZE_32);
+	gdt_set(USER_DS / 8, 0, 0xffffffff, ST_USER | ST_DATA_W, SIZE_32);
+
+	/* Clear TSS Busy */
+	gdt[KERNEL_TSS / 8].type &= ~ST_TSS_BUSY;
+
+	/* Load GDT */
+	gdt_p.limit = (uint16_t)(sizeof(gdt) - 1);
+	gdt_p.base = (uint32_t)&gdt;
+	load_gdt(&gdt_p);
+}
+
+/*
+ * Setup the interrupt descriptor table and load it.
+ *
+ * IDT layout:
+ *  0x00 - 0x12 ... S/W trap
+ *  0x13 - 0x1f ... Intel reserved
+ *  0x20 - 0x3f ... H/W interrupt
+ *  0x40        ... System call trap
+ */
+static void
+idt_init(void)
+{
+	struct desc_p idt_p;
+	int i;
+
+	/* Fill all vectors with default handler */
+	for (i = 0; i < NIDTS; i++)
+		idt_set(i, trap_default, KERNEL_CS, ST_KERN | ST_TRAP_GATE);
+
+	/* Setup trap handlers */
+	for (i = 0; i < NTRAPS; i++)
+		idt_set(i, trap_table[i], KERNEL_CS, ST_KERN | ST_TRAP_GATE);
+
+	/* Setup interrupt handlers */
+	for (i = 0; i < 16; i++)
+		idt_set(0x20 + i, intr_table[i], KERNEL_CS,
+			ST_KERN | ST_INTR_GATE);
+
+	/* Setup debug trap */
+	idt_set(3, trap_3, KERNEL_CS, ST_USER | ST_TRAP_GATE);
+
+	/* Setup system call handler */
+	idt_set(SYSCALL_INT, syscall_entry, KERNEL_CS,
+		ST_USER | ST_TRAP_GATE);
+
+	/* Load IDT */
+	idt_p.limit = (uint16_t)(sizeof(idt) - 1);
+	idt_p.base = (uint32_t)&idt;
+	load_idt(&idt_p);
+}
+
+/*
+ * Initialize the task state segment.
+ * Only one static TSS is used for all contexts.
+ */
+static void
+tss_init(void)
+{
+
+	gdt_set(KERNEL_TSS / 8, &tss, sizeof(struct tss) - 1,
+		ST_KERN | ST_TSS, 0);
+	/* Setup TSS */
+	memset(&tss, 0, sizeof(struct tss));
+	tss.ss0 = KERNEL_DS;
+	tss.esp0 = (uint32_t)BOOTSTKTOP;
+	tss.cs = (uint32_t)USER_CS | 3;
+	tss.ds = tss.es = tss.ss = tss.fs = tss.gs = (uint32_t)USER_CS | 3;
+	tss.io_bitmap_offset = INVALID_IO_BITMAP;
+	load_tr(KERNEL_TSS);
+}
+
+/*
+ * Initialize CPU state.
+ * Setup segment and interrupt descriptor.
+ */
+void
+cpu_init(void)
+{
+
+	/*
+	 * Initialize descriptors.
+	 * Setup segment and interrupt descriptor.
+	 */
+	gdt_init();
+	idt_init();
+	tss_init();
+}
diff --git a/prex-0.9.0/bsp/hal/x86/arch/cpufunc.S b/prex-0.9.0/bsp/hal/x86/arch/cpufunc.S
new file mode 100755
index 0000000..b306498
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/cpufunc.S
@@ -0,0 +1,120 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpufunc.S - Functions to provide access to i386 specific instructions.
+ */
+
+#include <machine/asm.h>
+#include <cpu.h>
+
+	.section ".text"
+
+ENTRY(cpu_idle)
+	sti
+	hlt
+	ret
+
+ENTRY(flush_tlb)
+	movl	%cr3, %eax
+	movl	%eax, %cr3
+	ret
+
+ENTRY(flush_cache)
+	wbinvd
+	ret
+
+ENTRY(load_tr)
+	movl	4(%esp), %eax
+	ltr	%ax
+	ret
+
+ENTRY(load_gdt)
+	movl	4(%esp), %eax
+	lgdt	(%eax)
+	jmp	1f			/* Flush the prefetch queue */
+	nop
+1:
+	movl	$(KERNEL_DS), %eax
+	movl	%eax, %ds
+	movl	%eax, %es
+	movl	%eax, %fs
+	movl	%eax, %gs
+	movl	%eax, %ss
+	movl	$(KERNEL_CS), %eax
+	pushl	%eax
+	pushl	$2f
+	lret
+2:
+	ret
+
+ENTRY(load_idt)
+	movl	4(%esp), %eax
+	lidt	(%eax)
+	ret
+
+ENTRY(get_cr2)
+	movl	%cr2, %eax
+	ret
+
+ENTRY(set_cr3)
+	movl	4(%esp), %eax
+	movl	%eax, %cr3
+	ret
+
+ENTRY(get_cr3)
+	movl	%cr3, %eax
+	ret
+
+ENTRY(outb)
+	movl	4(%esp), %edx
+	movl	8(%esp), %eax
+	outb	%al, %dx
+	ret
+
+ENTRY(inb)
+	movl	4(%esp), %edx
+	xorl	%eax, %eax
+	inb	%dx, %al
+	ret
+
+ENTRY(outb_p)
+	movl	4(%esp), %edx
+	movl	8(%esp), %eax
+	outb	%al, %dx
+	outb	%al, $0x80
+	ret
+
+ENTRY(inb_p)
+	movl	4(%esp), %edx
+	xorl	%eax, %eax
+	inb	%dx, %al
+	outb	%al, $0x80
+	ret
+
diff --git a/prex-0.9.0/bsp/hal/x86/arch/kern.ld b/prex-0.9.0/bsp/hal/x86/arch/kern.ld
new file mode 100755
index 0000000..40e7d82
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/kern.ld
@@ -0,0 +1,41 @@
+/*
+ * Linker script for kernel
+ */
+INCLUDE config.ld
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(kernel_start)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = CONFIG_KERNEL_TEXT + SIZEOF_HEADERS;
+
+	.text : {
+		*(.text)
+	} : text = 0x9090
+
+	. = ALIGN(32);
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	} : text
+
+	. = ALIGN(32);
+	.data : {
+		*(.data)
+	} : data
+
+	__bss = .;
+	.bss .    : {
+		*(.bss)
+		*(COMMON)
+	}
+	. = ALIGN(32 / 8);
+	__end = .;
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/bsp/hal/x86/arch/locore.S b/prex-0.9.0/bsp/hal/x86/arch/locore.S
new file mode 100755
index 0000000..acf5dbb
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/locore.S
@@ -0,0 +1,561 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * locore.S - low level platform support
+ */
+
+#include <conf/config.h>
+#include <machine/asm.h>
+#include <machine/syspage.h>
+#include <machine/memory.h>
+#include <sys/errno.h>
+#include <cpu.h>
+
+/*
+ * Macro to save/restore registers
+ *
+ * This macro builds the trap frame by pushing registers.
+ * If you change the push order of these macro, you must change the
+ * trap frame structure in arch.h. In addition, the system call stub
+ * will depend on this register format.
+ */
+#define SAVE_ALL \
+	cld; \
+	pushl	%es; \
+	pushl	%ds; \
+	pushl	%ebp; \
+	pushl	%edi; \
+	pushl	%eax; \
+	pushl	%esi; \
+	pushl	%edx; \
+	pushl	%ecx; \
+	pushl	%ebx;
+
+#define RESTORE_ALL \
+	popl	%ebx; \
+	popl	%ecx; \
+	popl	%edx; \
+	popl	%esi; \
+	popl	%eax; \
+	popl	%edi; \
+	popl	%ebp; \
+	popl	%ds; \
+	popl	%es;
+
+#define SETUP_SEG \
+	movl	$(KERNEL_DS), %edx; \
+	movl	%edx, %ds; \
+	movl	%edx, %es;
+
+	.section ".text"
+
+/*
+ * Kernel start point
+ *
+ * The kernel assumes that the following state is already set by
+ * the kernel loader.
+ * - CPU is in protected mode
+ * - Segment registers are set as 32-bit flat segment
+ * - A20 line is enabled for 32-bit addressing
+ * - Paging is turned off
+ * - The boot information is loaded to address 1000h-1fffh
+ */
+/*
+ * Note: The linker will generate an address for kernel_start as 0x80010000.
+ * But, the loader will load the kernel to 0x10000 (physical address).
+ * So, the linear address pointer can not be used until paging is enabled.
+ */
+ENTRY(kernel_start)
+	cli				/* Disable interrupt */
+	cld
+
+	/*
+	 * Setup CPU registers.
+	 */
+	movl	%cr0, %eax		/* Enable kernel write protection */
+	orl	$(CR0_WP), %eax
+	movl	%eax, %cr0
+
+	pushfl				/* Clear nested task, iopl = 0 */
+	popl	%eax
+	andl	$~(EFL_IOPL|EFL_NT), %eax
+	pushl	%eax
+	popfl
+
+#ifdef CONFIG_MMU
+	/*
+	 * Initialize page table.
+	 * The physical address 0-4M is mapped on virtual address 2G.
+	 */
+	movl	$(BOOT_PGD_PHYS), %edi	/* Setup kernel page directory */
+	xorl	%eax, %eax		/* Invalidate all address */
+	movl	$0x1000, %ecx
+	rep
+	stosb
+	movl	$(BOOT_PGD_PHYS+0x800), %edi
+	movl	$(BOOT_PTE0_PHYS+0x07), (%edi)
+	movl	$1024, %ecx		/* Fill boot page table entry */
+	movl	$(BOOT_PTE0_PHYS), %edi
+	movl	$0007, %eax
+fill_pte0:
+	stosl
+	add	$0x1000, %eax		/* Process next page */
+	loop	fill_pte0
+
+	/*
+	 * Enable paging.
+	 * The physical address 0-4M is temporarily mapped to virtial
+	 * address 0-4M. This is needed to enable paging.
+	 */
+	movl	$(BOOT_PGD_PHYS), %edi	/* Map address 0-4M */
+	movl	$(BOOT_PTE0_PHYS+0x07), (%edi)
+	movl	$(BOOT_PGD_PHYS), %eax	/* Set page directory pointer */
+	movl	%eax, %cr3
+	movl	%cr0, %eax		/* Enable paging bit */
+	orl	$(CR0_PG), %eax
+	movl	%eax, %cr0
+	jmp	pipeline_flush		/* Flush processor pipeline */
+pipeline_flush:
+	movl	$cs_reset, %eax
+	jmp	*%eax
+cs_reset:
+	movl	$(BOOT_PGD), %edi	/* Unmap 0-4M */
+	movl	$0, (%edi)
+	movl	%cr3, %eax
+	movl	%eax, %cr3
+
+#endif /* CONFIG_MMU */
+
+	/*
+	 * Clear kernel BSS
+	 */
+	xorl	%eax, %eax
+	movl	$__bss, %edi
+	movl	$__end, %ecx
+	subl	%edi, %ecx
+	rep
+	stosb
+
+	/*
+	 * Setup boot stack
+	 */
+	movl	$(BOOTSTK), %edi
+	movl	$(BOOTSTKSZ), %ecx
+	rep
+	stosb
+	movl	$(BOOTSTKTOP), %esp
+	movl	%esp, %ebp
+
+	movl	$15, curspl
+
+	/*
+	 * Call kernel main routine
+	 */
+	call	main
+	/* NOTREACHED */
+	cli
+	hlt
+
+/*
+ * Common entry for all interrupts
+ * Setup interrupt stack for outermost interrupt.
+ * The code should be written to prevent the stack overflow
+ * by continuous interrupt as much as it can.
+ */
+ENTRY(interrupt_common)
+	SAVE_ALL
+	SETUP_SEG
+	incl	irq_nesting		/* Increment nesting level */
+	cmpl	$1, irq_nesting		/* Outermost interrupt ? */
+	jne	nested_irq
+	mov	%esp, %ebp		/* Save current stack */
+	movl	$(INTSTKTOP), %esp	/* Switch stack */
+	call	sched_lock		/* Lock scheduler */
+	pushl	%ebp			/* Push trap frame */
+	call	interrupt_handler	/* Process interrupt */
+	movl	%ebp, %esp		/* Restore original stack */
+	decl	irq_nesting
+	call	sched_unlock		/* Try to preempt */
+	testl	$3, 0x30(%esp)		/* Return to kernel mode ? */
+	jz	interrupt_ret		/* Skip exception if kernel mode */
+	sti
+	call	exception_deliver	/* Check exception */
+interrupt_ret:
+	cli
+	RESTORE_ALL
+	addl	$8, %esp
+	iret
+nested_irq:
+	push	%esp			/* Push trap frame */
+	call	interrupt_handler	/* Process interrupt */
+	addl	$4, %esp
+	decl	irq_nesting
+	jmp	interrupt_ret
+
+/*
+ * Macro to build interrupt entry
+ */
+#define INTR_ENTRY(irq) \
+ENTRY(intr_##irq) \
+	pushl	$0; \
+	pushl	$(irq); \
+	jmp	interrupt_common
+
+INTR_ENTRY(0)
+INTR_ENTRY(1)
+INTR_ENTRY(2)
+INTR_ENTRY(3)
+INTR_ENTRY(4)
+INTR_ENTRY(5)
+INTR_ENTRY(6)
+INTR_ENTRY(7)
+INTR_ENTRY(8)
+INTR_ENTRY(9)
+INTR_ENTRY(10)
+INTR_ENTRY(11)
+INTR_ENTRY(12)
+INTR_ENTRY(13)
+INTR_ENTRY(14)
+INTR_ENTRY(15)
+
+/*
+ * Common entry for all traps
+ * New thread will start from trap_ret.
+ */
+ENTRY(trap_common)
+	SAVE_ALL
+	SETUP_SEG
+	pushl	%esp
+	call	trap_handler
+	addl	$4, %esp
+trap_ret:
+	RESTORE_ALL
+	addl	$8, %esp
+	iret
+
+/*
+ * Default trap entry
+ */
+ENTRY(trap_default)
+	pushl	$0
+	pushl	$(INVALID_INT)
+	jmp	trap_common
+
+/*
+ * Macro to build trap entry
+ * Some trap will push the error code into stack.
+ */
+#define TRAP_ENTRY(id) \
+ENTRY(trap_##id) \
+	pushl	$0; \
+	pushl	$(id); \
+	jmp	trap_common;
+
+#define TRAP_ERR_ENTRY(id) \
+ENTRY(trap_##id) \
+	pushl	$(id); \
+	jmp	trap_common;
+
+TRAP_ENTRY    ( 0)		/* Divide error */
+TRAP_ENTRY    ( 1)		/* Debug trap */
+TRAP_ENTRY    ( 2)		/* NMI */
+TRAP_ENTRY    ( 3)		/* Breakpoint */
+TRAP_ENTRY    ( 4)		/* Overflow */
+TRAP_ENTRY    ( 5)		/* Bounds check */
+TRAP_ENTRY    ( 6)		/* Invalid opecode */
+TRAP_ENTRY    ( 7)		/* Device not available */
+TRAP_ERR_ENTRY( 8)		/* Double fault */
+TRAP_ERR_ENTRY( 9)		/* Coprocessor overrun */
+TRAP_ERR_ENTRY(10)		/* Invalid TSS */
+TRAP_ERR_ENTRY(11)		/* Segment not present */
+TRAP_ERR_ENTRY(12)		/* Stack bounds */
+TRAP_ERR_ENTRY(13)		/* General Protection */
+TRAP_ERR_ENTRY(14)		/* Page fault */
+TRAP_ENTRY    (15)		/* (reserved) */
+TRAP_ENTRY    (16)		/* Coprocessor error */
+TRAP_ERR_ENTRY(17)		/* Alignment check */
+TRAP_ERR_ENTRY(18)		/* Cache flush denied */
+
+
+/*
+ * System call entry
+ */
+	.global syscall_ret
+ENTRY(syscall_entry)
+	pushl	$0			/* Dummy for error code */
+	pushl	$(SYSCALL_INT)		/* Trap number */
+	SAVE_ALL
+	SETUP_SEG
+	call	syscall_handler
+	cmpl	$0, 0x10(%esp)		/* Skip setting eax if exception_return */
+	je	1f
+	movl	%eax, 0x10(%esp)	/* Set return value to eax */
+1:
+	call	exception_deliver	/* Check exception */
+syscall_ret:
+	RESTORE_ALL
+	addl	$8, %esp		/* Discard err/trap no */
+	iret
+
+/*
+ * Switch register context.
+ * Interrupts must be disabled by caller.
+ *
+ * syntax - void cpu_switch(kern_regs *prev, kern_regs *next)
+ *
+ * Note: GCC assumes ebx,ebp,edi,esi registers are not changed in each routine.
+ */
+ENTRY(cpu_switch)
+	movl	4(%esp), %ecx		/* Point ecx to previous registers */
+	movl	(%esp), %eax		/* Get return address */
+	movl	%eax, 0(%ecx)		/* Save it as eip */
+	movl	%ebx, 4(%ecx)		/* Save ebx */
+	movl	%edi, 8(%ecx)		/* Save edi */
+	movl	%esi, 12(%ecx)		/* Save esi */
+	movl	%ebp, 16(%ecx)		/* Save ebp */
+	movl	%esp, 20(%ecx)		/* Save esp */
+	movl	8(%esp), %ecx		/* Point ecx to next registers */
+	movl	4(%ecx), %ebx		/* Restore ebx */
+	movl	8(%ecx), %edi		/* Restore edi */
+	movl	12(%ecx), %esi		/* Restore esp */
+	movl	16(%ecx), %ebp		/* Restore ebp */
+	movl	20(%ecx), %esp		/* Restore esp */
+	movl	0(%ecx), %eax		/* Get eip */
+	movl	%eax, (%esp)		/* Restore it as return address */
+	ret
+
+/*
+ * Copy data from user to kernel space.
+ * Returns 0 on success, or EFAULT on page fault.
+ *
+ *  syntax - int copyin(const void *uaddr, void *kaddr, size_t len)
+ */
+	.global known_fault1
+ENTRY(copyin)
+	pushl	%esi
+	pushl	%edi
+	pushl	$(EFAULT)		/* Set EFAULT as default return */
+
+	movl	16(%esp), %esi
+	movl	20(%esp), %edi
+	movl	24(%esp), %ecx
+
+	movl	%esi, %edx		/* Check if valid user address */
+	addl	%ecx, %edx
+	jc	copy_fault
+	cmpl	$(USERLIMIT), %edx	/* User area? */
+	jae	copy_fault
+	cld
+known_fault1:				/* May be fault here */
+	rep
+	movsb
+
+	popl	%eax
+	xorl	%eax, %eax		/* Set no error */
+	popl	%edi
+	popl	%esi
+	ret
+
+/*
+ * Copy data to user from kernel space.
+ * Returns 0 on success, or EFAULT on page fault.
+ *
+ *  syntax - int copyout(const void *kaddr, void *uaddr, size_t len)
+ */
+	.global known_fault2
+ENTRY(copyout)
+	pushl	%esi
+	pushl	%edi
+	pushl	$(EFAULT)		/* Set EFAULT as default return */
+
+	movl	16(%esp), %esi
+	movl	20(%esp), %edi
+	movl	24(%esp), %ecx
+
+	movl	%edi, %edx
+	addl	%ecx, %edx
+	jc	copy_fault
+	cmpl	$(USERLIMIT), %edx	/* User area? */
+	jae	copy_fault
+	cld
+known_fault2:				/* May be fault here */
+	rep
+	movsb
+
+	popl	%eax
+	xorl	%eax, %eax		/* Set no error */
+	popl	%edi
+	popl	%esi
+	ret
+
+/**
+ * copyinstr - Copy string from user space.
+ * Returns 0 on success, or EFAULT on page fault, or ENAMETOOLONG.
+ *
+ *  syntax - int copyinstr(const char *uaddr, void *kaddr, size_t len);
+ *
+ * Note: The returned length value does NOT include the NULL terminator.
+ */
+	.global known_fault3
+ENTRY(copyinstr)
+	pushl	%esi
+	pushl	%edi
+	pushl	$(EFAULT)		/* Set EFAULT as default return */
+
+	movl	16(%esp), %esi
+	movl	20(%esp), %edi
+	movl	24(%esp), %ecx
+
+	movl	%esi, %edx		/* Check if valid user address */
+	addl	%ecx, %edx
+	jc	copy_fault
+	cmpl	$(USERLIMIT), %edx	/* User area? */
+	jae	copy_fault
+	cld
+	jmp	2f
+1:
+	decl	%ecx
+	jz	copyin_toolong
+2:
+known_fault3:				/* May be fault here */
+	lodsb
+	stosb
+	testb	%al, %al
+	jnz	1b
+
+	popl	%eax
+	xorl	%eax, %eax		/* Set no error */
+	popl	%edi
+	popl	%esi
+	ret
+
+copyin_toolong:
+	popl	%eax
+	movl	$(ENAMETOOLONG), %eax
+	popl	%edi
+	popl	%esi
+	ret
+
+/*
+ * Fault entry for user access
+ */
+ENTRY(copy_fault)
+	popl	%eax			/* Get return value from stack */
+	popl	%edi
+	popl	%esi
+	ret
+
+/*
+ * Reset cpu
+ * Use triple fault
+ */
+ENTRY(cpu_reset)
+	cli
+	movl	$null_idt, %eax		/* Reset by triple fault */
+	lidt	(%eax)
+	int	$3
+	hlt
+
+	.align 4
+null_idt:
+	.word	0
+	.long	0
+
+/*
+ * Initialize cache.
+ */
+ENTRY(cache_init)
+	movl	%cr0, %eax		/* Clear cache disable bit */
+	andl	$~(CR0_CD), %eax
+	movl	%eax, %cr0
+	ret
+
+/*
+ * void splx(int s);
+ */
+ENTRY(splx)
+	cli
+	movl	4(%esp), %eax
+	movl	%eax, curspl
+	cmpl	$0, %eax
+	ja	1f
+	sti
+1:
+	ret
+
+/*
+ * int splhigh(void);
+ */
+ENTRY(splhigh)
+	cli
+	movl	curspl, %eax
+	movl	$15, curspl
+	ret
+
+/*
+ * int spl0(void);
+ */
+ENTRY(spl0)
+	movl	curspl, %eax
+	movl	$0, curspl
+	sti
+	ret
+
+/*
+ * Disable interrupts
+ */
+ENTRY(sploff)
+	cli
+	ret
+
+/*
+ * Enable interrupts
+ */
+ENTRY(splon)
+	sti
+	ret
+
+/*
+ * Interrupt nest counter.
+ *
+ * This counter is incremented in the entry of interrupt handler
+ * to switch the interrupt stack. Since all interrupt handlers
+ * share same one interrupt stack, each handler must pay attention
+ * to the stack overflow.
+ */
+	.section ".bss"
+irq_nesting:
+	.long	0
+
+/*
+ * Current spl
+ */
+curspl:
+	.long	0
diff --git a/prex-0.9.0/bsp/hal/x86/arch/mmu.c b/prex-0.9.0/bsp/hal/x86/arch/mmu.c
new file mode 100755
index 0000000..ce34ebc
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/mmu.c
@@ -0,0 +1,281 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mmu.c - memory management unit support routines
+ */
+
+/*
+ * This module provides virtual/physical address translation for
+ * intel x86 MMU. This kernel will do only page level translation
+ * and protection and it does not use x86 segment mechanism.
+ */
+
+#include <machine/syspage.h>
+#include <kernel.h>
+#include <page.h>
+#include <mmu.h>
+#include <cpu.h>
+#include <cpufunc.h>
+
+/*
+ * Boot page directory.
+ * This works as a template for all page directory.
+ */
+static pgd_t boot_pgd = (pgd_t)BOOT_PGD;
+
+/*
+ * Map physical memory range into virtual address
+ *
+ * Returns 0 on success, or ENOMEM on failure.
+ *
+ * Map type can be one of the following type.
+ *   PG_UNMAP  - Remove mapping
+ *   PG_READ   - Read only mapping
+ *   PG_WRITE  - Read/write allowed
+ *   PG_KERNEL - Kernel page
+ *   PG_IO     - I/O memory
+ *
+ * Setup the appropriate page tables for mapping. If there is no
+ * page table for the specified address, new page table is
+ * allocated.
+ *
+ * This routine does not return any error even if the specified
+ * address has been already mapped to other physical address.
+ * In this case, it will just override the existing mapping.
+ *
+ * In order to unmap the page, pg_type is specified as 0.  But,
+ * the page tables are not released even if there is no valid
+ * page entry in it. All page tables are released when mmu_delmap()
+ * is called when task is terminated.
+ *
+ * TODO: TLB should be flushed for specific page by invalpg in
+ * case of i486.
+ */
+int
+mmu_map(pgd_t pgd, paddr_t pa, vaddr_t va, size_t size, int type)
+{
+	uint32_t pte_flag = 0;
+	uint32_t pde_flag = 0;
+	pte_t pte;
+	paddr_t pg;
+
+	pa = round_page(pa);
+	va = round_page(va);
+	size = trunc_page(size);
+
+	/*
+	 * Set page flag
+	 */
+	switch (type) {
+	case PG_UNMAP:
+		pte_flag = 0;
+		pde_flag = (uint32_t)(PDE_PRESENT | PDE_WRITE | PDE_USER);
+		break;
+	case PG_READ:
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_USER);
+		pde_flag = (uint32_t)(PDE_PRESENT | PDE_WRITE | PDE_USER);
+		break;
+	case PG_WRITE:
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_WRITE | PTE_USER);
+		pde_flag = (uint32_t)(PDE_PRESENT | PDE_WRITE | PDE_USER);
+		break;
+	case PG_SYSTEM:
+		pde_flag = (uint32_t)(PDE_PRESENT | PDE_WRITE);
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_WRITE);
+		break;
+	case PG_IOMEM:
+		pde_flag = (uint32_t)(PDE_PRESENT | PDE_WRITE);
+		pte_flag = (uint32_t)(PTE_PRESENT | PTE_WRITE | PTE_NCACHE);
+		break;
+	default:
+		panic("mmu_map");
+	}
+	/*
+	 * Map all pages
+	 */
+	while (size > 0) {
+		if (pte_present(pgd, va)) {
+			/* Page table already exists for the address */
+			pte = vtopte(pgd, va);
+		} else {
+			ASSERT(pte_flag != 0);
+			if ((pg = page_alloc(PAGE_SIZE)) == 0) {
+				DPRINTF(("Error: MMU mapping failed\n"));
+				return ENOMEM;
+			}
+			pgd[PAGE_DIR(va)] = (uint32_t)pg | pde_flag;
+			pte = (pte_t)ptokv(pg);
+			memset(pte, 0, PAGE_SIZE);
+		}
+		/* Set new entry into page table */
+		pte[PAGE_TABLE(va)] = (uint32_t)pa | pte_flag;
+
+		/* Process next page */
+		pa += PAGE_SIZE;
+		va += PAGE_SIZE;
+		size -= PAGE_SIZE;
+	}
+	flush_tlb();
+	return 0;
+}
+
+/*
+ * Create new page map.
+ *
+ * Returns a page directory on success, or NULL on failure.  This
+ * routine is called when new task is created. All page map must
+ * have the same kernel page table in it. So, the kernel page
+ * tables are copied to newly created map.
+ */
+pgd_t
+mmu_newmap(void)
+{
+	paddr_t pg;
+	pgd_t pgd;
+	int i;
+
+	/* Allocate page directory */
+	if ((pg = page_alloc(PAGE_SIZE)) == 0)
+		return NO_PGD;
+	pgd = (pgd_t)ptokv(pg);
+	memset(pgd, 0, PAGE_SIZE);
+
+	/* Copy kernel page tables */
+	i = PAGE_DIR(KERNBASE);
+	memcpy(&pgd[i], &boot_pgd[i], (size_t)(1024 - i));
+	return pgd;
+}
+
+/*
+ * Terminate all page mapping.
+ */
+void
+mmu_terminate(pgd_t pgd)
+{
+	int i;
+	pte_t pte;
+
+	flush_tlb();
+
+	/* Release all user page table */
+	for (i = 0; i < PAGE_DIR(KERNBASE); i++) {
+		pte = (pte_t)pgd[i];
+		if (pte != 0)
+			page_free((paddr_t)((paddr_t)pte & PTE_ADDRESS),
+				  PAGE_SIZE);
+	}
+	/* Release page directory */
+	page_free(kvtop(pgd), PAGE_SIZE);
+}
+
+/*
+ * Switch to new page directory
+ *
+ * This is called when context is switched.
+ * Whole TLB are flushed automatically by loading
+ * CR3 register.
+ */
+void
+mmu_switch(pgd_t pgd)
+{
+	uint32_t phys = (uint32_t)kvtop(pgd);
+
+	if (phys != get_cr3())
+		set_cr3(phys);
+}
+
+/*
+ * Returns the physical address for the specified virtual address.
+ * This routine checks if the virtual area actually exist.
+ * It returns 0 if at least one page is not mapped.
+ */
+paddr_t
+mmu_extract(pgd_t pgd, vaddr_t va, size_t size)
+{
+	pte_t pte;
+	vaddr_t start, end, pg;
+	paddr_t pa;
+
+	start = trunc_page(va);
+	end = trunc_page(va + size - 1);
+
+	/* Check all pages exist */
+	for (pg = start; pg <= end; pg += PAGE_SIZE) {
+		if (!pte_present(pgd, pg))
+			return 0;
+		pte = vtopte(pgd, pg);
+		if (!page_present(pte, pg))
+			return 0;
+	}
+
+	/* Get physical address */
+	pte = vtopte(pgd, start);
+	pa = (paddr_t)ptetopg(pte, start);
+	return pa + (paddr_t)(va - start);
+}
+
+/*
+ * Initialize mmu
+ *
+ * Paging is already enabled in locore.S. And, physical address
+ * 0-4M has been already mapped into kernel space in locore.S.
+ * Now, all physical memory is mapped into kernel virtual address
+ * as straight 1:1 mapping. User mode access is not allowed for
+ * these kernel pages.
+ * page_init() must be called before calling this routine.
+ *
+ * Note: This routine requires 4K bytes to map 4M bytes memory. So,
+ * if the system has a lot of RAM, the "used memory" by kernel will
+ * become large, too. For example, page table requires 512K bytes
+ * for 512M bytes system RAM.
+ */
+void
+mmu_init(struct mmumap *mmumap_table)
+{
+	struct mmumap *map;
+	int map_type = 0;
+
+	for (map = mmumap_table; map->type != 0; map++) {
+		switch (map->type) {
+		case VMT_RAM:
+		case VMT_ROM:
+		case VMT_DMA:
+			map_type = PG_SYSTEM;
+			break;
+		case VMT_IO:
+			map_type = PG_IOMEM;
+			break;
+		}
+
+		if (mmu_map(boot_pgd, map->phys, map->virt,
+			    (size_t)map->size, map_type))
+			panic("mmu_init");
+	}
+}
diff --git a/prex-0.9.0/bsp/hal/x86/arch/trap.c b/prex-0.9.0/bsp/hal/x86/arch/trap.c
new file mode 100755
index 0000000..9187696
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/arch/trap.c
@@ -0,0 +1,193 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * trap.c - called from the trap handler when a processor trap occurs.
+ */
+
+#include <sys/signal.h>
+#include <kernel.h>
+#include <hal.h>
+#include <exception.h>
+#include <task.h>
+#include <cpu.h>
+#include <trap.h>
+#include <cpufunc.h>
+#include <context.h>
+#include <locore.h>
+
+#ifdef DEBUG
+/*
+ * Trap name.
+ */
+static const char *const trap_name[] = {
+	"Divide error",		/*  0 */
+	"Debug trap",		/*  1 */
+	"NMI",			/*  2 */
+	"Breakpoint",		/*  3 */
+	"Overflow",		/*  4 */
+	"Bounds check",		/*  5 */
+	"Invalid opecode",	/*  6 */
+	"Device not available",	/*  7 */
+	"Double fault",		/*  8 */
+	"Coprocessor overrun",	/*  9 */
+	"Invalid TSS",		/* 10 */
+	"Segment not present",	/* 11 */
+	"Stack bounds",		/* 12 */
+	"General Protection",	/* 13 */
+	"Page fault",		/* 14 */
+	"Reserved",		/* 15 */
+	"Coprocessor error",	/* 16 */
+	"Alignment check",	/* 17 */
+	"Cache flush denied"	/* 18 */
+};
+#define MAXTRAP (sizeof(trap_name) / sizeof(void *) - 1)
+#endif	/* DEBUG */
+
+/*
+ * Trap/exception mapping table.
+ * x86 trap code is translated to the architecture
+ * independent exception code.
+ */
+static const int exception_map[] = {
+	SIGFPE,		/*  0: Divide error */
+	SIGTRAP,	/*  1: Debug trap */
+	SIGILL,		/*  2: NMI */
+	SIGTRAP,	/*  3: Breakpoint */
+	SIGFPE,		/*  4: Overflow */
+	SIGILL,		/*  5: Bounds check */
+	SIGILL,		/*  6: Invalid opecode */
+	SIGFPE,		/*  7: Device not available */
+	SIGILL,		/*  8: Double fault */
+	SIGFPE,		/*  9: Coprocessor overrun */
+	SIGSEGV,	/* 10: Invalid TSS */
+	SIGSEGV,	/* 11: Segment not present */
+	SIGSEGV,	/* 12: Stack bounds */
+	SIGILL,		/* 13: General Protection fault */
+	SIGSEGV,	/* 14: Page fault */
+	SIGILL,		/* 15: Reserved */
+	SIGFPE,		/* 16: Coprocessor error */
+	SIGILL,		/* 17: Alignment check */
+	SIGILL,		/* 18: Cache flush denied */
+};
+
+/*
+ * Trap handler
+ * Invoke the exception handler if it is needed.
+ */
+void
+trap_handler(struct cpu_regs *regs)
+{
+	u_long trap_no = regs->trap_no;
+
+	if (trap_no > 18)
+		panic("Unknown trap");
+	else if (trap_no == 2)
+		panic("NMI");
+
+	/*
+	 * Check whether this trap is kernel page fault caused
+	 * by known routine to access user space like copyin().
+	 * If so, we change the return address of this exception.
+	 */
+	if (trap_no == 14 && regs->cs == KERNEL_CS &&
+	    (regs->eip == (uint32_t)known_fault1 ||
+	     regs->eip == (uint32_t)known_fault2 ||
+	     regs->eip == (uint32_t)known_fault3)) {
+		DPRINTF(("\n*** Detect Fault! address=%x task=%s ***\n",
+			 get_cr2(), curtask->name));
+		regs->eip = (uint32_t)copy_fault;
+		return;
+	}
+#ifdef DEBUG
+	printf("============================\n");
+	printf("Trap %x: %s\n", (u_int)trap_no, trap_name[trap_no]);
+	if (trap_no == 14)
+		printf(" Fault address=%x\n", get_cr2());
+	printf("============================\n");
+	trap_dump(regs);
+	if (regs->cs == KERNEL_CS) {
+		printf("Trap in kernel!\n");
+		interrupt_mask(0);
+		spl0();
+	}
+	for (;;) ;
+#endif
+	if (regs->cs == KERNEL_CS)
+		panic("Kernel exception");
+
+	exception_mark(exception_map[trap_no]);
+	exception_deliver();
+}
+
+#ifdef DEBUG
+void
+trap_dump(struct cpu_regs *r)
+{
+	uint32_t ss, esp, *fp;
+	u_int i;
+	int spl;
+
+	/* Get current spl */
+	spl = splhigh();
+	splx(spl);
+
+	if (r->cs & 3) {
+		ss = r->ss;
+		esp = r->esp;
+	} else {
+		ss = r->ds;
+		esp = (uint32_t)r;
+	}
+	printf("Trap frame %08lx error %x\n", (long)r, r->err_code);
+	printf(" eax %08x ebx %08x ecx %08x edx %08x esi %08x edi %08x\n",
+	       r->eax, r->ebx, r->ecx, r->edx, r->esi, r->edi);
+	printf(" eip %08x esp %08x ebp %08x eflags %08x\n",
+	       r->eip, esp, r->ebp, r->eflags);
+	printf(" cs  %08x ss  %08x ds  %08x es  %08x esp0 %08x\n",
+	       r->cs, ss, r->ds, r->es, tss_get());
+
+	printf(" >> interrupt is %s\n", (spl == 0) ? "enabled" : "disabled");
+
+	printf(" >> task=%s\n", curtask->name);
+
+	if (r->cs == KERNEL_CS) {
+		printf("Stack trace:\n");
+		fp = (uint32_t *)r->ebp;
+		for (i = 0; i < 8; i++) {
+			if (user_area(fp))
+				break;
+			fp = (uint32_t *)(*fp);	/* XXX: may cause fault */
+			if (!(*(fp + 1) && *fp))
+				break;
+			printf(" %08x\n", *(fp + 1));
+		}
+	}
+}
+#endif /* !DEBUG */
diff --git a/prex-0.9.0/bsp/hal/x86/include/context.h b/prex-0.9.0/bsp/hal/x86/include/context.h
new file mode 100755
index 0000000..66d98d3
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/include/context.h
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_CONTEXT_H
+#define _X86_CONTEXT_H
+
+#include <sys/types.h>
+
+/*
+ * Common register frame for trap/interrupt.
+ * These cpu state are saved into top of the kernel stack in
+ * trap/interrupt entries. Since the arguments of system calls are
+ * passed via registers, the system call library is completely
+ * dependent on this register format.
+ *
+ * The value of ss & esp are not valid for kernel mode trap
+ * because these are set only when privilege level is changed.
+ */
+struct cpu_regs {
+	uint32_t	ebx;		/*  +0 (00) --- s/w trap frame --- */
+	uint32_t	ecx;		/*  +4 (04) */
+	uint32_t	edx;		/*  +8 (08) */
+	uint32_t	esi;		/* +12 (0C) */
+	uint32_t	eax;		/* +16 (10) */
+	uint32_t	edi;		/* +20 (14) */
+	uint32_t	ebp;		/* +24 (18) */
+	uint32_t	ds;		/* +28 (1C) */
+	uint32_t	es;		/* +32 (20) */
+	uint32_t	trap_no;	/* +36 (24) --- h/w trap frame --- */
+	uint32_t	err_code;	/* +40 (28) */
+	uint32_t	eip;		/* +44 (2C) */
+	uint32_t	cs;		/* +48 (30) */
+	uint32_t	eflags;		/* +52 (34) */
+	uint32_t	esp;		/* +56 (38) */
+	uint32_t	ss;		/* +60 (3C) */
+};
+
+/*
+ * Kernel mode context for context switching.
+ */
+struct kern_regs {
+	uint32_t	eip;		/*  +0 (00) */
+	uint32_t	ebx;		/*  +4 (04) */
+	uint32_t	edi;		/*  +8 (08) */
+	uint32_t	esi;		/* +12 (0C) */
+	uint32_t	ebp;		/* +16 (10) */
+	uint32_t	esp;		/* +20 (14) */
+};
+
+/*
+ * FPU register for fsave/frstor
+ */
+struct fpu_regs {
+	uint32_t	ctrl_word;
+	uint32_t	stat_word;
+	uint32_t	tag_word;
+	uint32_t	ip_offset;
+	uint32_t	cs_sel;
+	uint32_t	op_offset;
+	uint32_t	op_sel;
+	uint32_t	st[20];
+};
+
+/*
+ * Processor context
+ */
+struct context {
+	struct kern_regs kregs;		/* kernel mode registers */
+	struct cpu_regs	*uregs;		/* user mode registers */
+	struct cpu_regs	*saved_regs;	/* saved user mode registers */
+#ifdef CONFIG_FPU
+	struct fpu_regs	*fregs;		/* co-processor registers */
+#endif
+	uint32_t	 esp0;		/* top of kernel stack */
+};
+
+typedef struct context *context_t;	/* context id */
+
+#endif /* !_X86_CONTEXT_H */
diff --git a/prex-0.9.0/bsp/hal/x86/include/cpu.h b/prex-0.9.0/bsp/hal/x86/include/cpu.h
new file mode 100755
index 0000000..ca94707
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/include/cpu.h
@@ -0,0 +1,204 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_CPU_H
+#define _X86_CPU_H
+
+#include <sys/cdefs.h>	/* for __packed */
+
+/*
+ * GDTs
+ */
+#define KERNEL_CS	0x10
+#define KERNEL_DS	0x18
+#define USER_CS		0x20
+#define USER_DS		0x28
+#define KERNEL_TSS	0x38
+
+#define NGDTS		8
+
+/*
+ * IDTs
+ */
+#define NIDTS		0x41
+#define SYSCALL_INT	0x40
+#define INVALID_INT	0xFF
+
+/*
+ * x86 flags register
+ */
+#define EFL_CF		0x00000001	/* Carry */
+#define EFL_PF		0x00000004	/* Parity */
+#define EFL_AF		0x00000010	/* Carry */
+#define EFL_ZF		0x00000040	/* Zero */
+#define EFL_SF		0x00000080	/* Sign */
+#define EFL_TF		0x00000100	/* 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_KERN	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 */
+#define EFL_AC		0x00040000	/* Alignment Check */
+
+/*
+ * CR0 register
+ */
+#define CR0_PG		0x80000000	/* enable paging */
+#define CR0_CD		0x40000000	/* cache disable */
+#define CR0_NW		0x20000000	/* no write-through */
+#define CR0_AM		0x00040000	/* alignment check mask */
+#define CR0_WP		0x00010000	/* write-protect kernel access */
+#define CR0_NE		0x00000020	/* handle numeric exceptions */
+#define CR0_ET		0x00000010	/* extension type is 80387 coprocessor */
+#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 __ASSEMBLY__
+
+#include <sys/types.h>
+#include <context.h>
+
+#if defined(__SUNPRO_C)
+#pragma pack(1)
+#endif
+
+/*
+ * Segment Descriptor
+ */
+struct seg_desc {
+	u_int limit_lo:16;	/* segment limit (lsb) */
+	u_int base_lo:16;	/* segment base address (lsb) */
+	u_int base_mid:8;	/* segment base address (middle) */
+	u_int type:8;		/* type */
+	u_int limit_hi:4;	/* segment limit (msb) */
+	u_int size:4;		/* size */
+	u_int base_hi:8;	/* segment base address (msb) */
+} __packed;
+
+/*
+ * Gate Descriptor
+ */
+struct gate_desc {
+	u_int offset_lo:16;	/* gate offset (lsb) */
+	u_int selector:16;	/* gate segment selector */
+	u_int nr_copy:8;	/* stack copy count */
+	u_int type:8;		/* type */
+	u_int offset_hi:16;	/* gate offset (msb) */
+} __packed;
+
+/*
+ * Linear memory description for lgdt and lidt instructions.
+ */
+struct desc_p {
+	uint16_t limit;
+	uint32_t base;
+} __packed;
+
+/*
+ * Segment size
+ */
+#define SIZE_32		0x4	/* 32-bit segment */
+#define SIZE_16		0x0	/* 16-bit segment */
+#define SIZE_4K		0x8	/* 4K limit field */
+
+/*
+ * Segment type
+ */
+#define ST_ACC		0x01	/* accessed */
+#define ST_LDT		0x02	/* LDT */
+#define ST_CALL_GATE_16	0x04	/* 16-bit call gate */
+#define ST_TASK_GATE	0x05	/* task gate */
+#define ST_TSS		0x09	/* task segment */
+#define ST_CALL_GATE	0x0c	/* call gate */
+#define ST_INTR_GATE	0x0e	/* interrupt gate */
+#define ST_TRAP_GATE	0x0f	/* trap gate */
+
+#define ST_TSS_BUSY	0x02	/* task busy */
+
+#define ST_DATA		0x10	/* data */
+#define ST_DATA_W	0x12	/* data, writable */
+#define ST_DATA_E	0x14	/* data, expand-down */
+#define ST_DATA_EW	0x16	/* data, expand-down, writable */
+
+#define ST_CODE		0x18	/* code */
+#define ST_CODE_R	0x1a	/* code, readable */
+#define ST_CODE_C	0x1c	/* code, conforming */
+#define ST_CODE_CR	0x1e	/* code, conforming, readable */
+
+#define ST_KERN		0x00	/* kernel access only */
+#define ST_USER		0x60	/* user access */
+
+#define ST_PRESENT	0x80	/* segment present */
+
+/*
+ * Task State Segment (TSS)
+ */
+
+#define IO_BITMAP_SIZE		(65536/8 + 1)
+#define INVALID_IO_BITMAP	0x8000
+
+struct tss {
+	uint32_t back_link;
+	uint32_t esp0, ss0;
+	uint32_t esp1, ss1;
+	uint32_t esp2, ss2;
+	uint32_t cr3;
+	uint32_t eip;
+	uint32_t eflags;
+	uint32_t eax, ecx, edx, ebx;
+	uint32_t esp, ebp, esi, edi;
+	uint32_t es, cs, ss, ds, fs, gs;
+	uint32_t ldt;
+	uint16_t dbg_trace;
+	uint16_t io_bitmap_offset;
+#if 0
+	uint32_t io_bitmap[IO_BITMAP_SIZE/4+1];
+	uint32_t pad[5];
+#endif
+} __packed;
+
+
+#if defined(__SUNPRO_C)
+#pragma pack()
+#endif
+
+__BEGIN_DECLS
+void	 tss_set(uint32_t);
+uint32_t tss_get(void);
+void	 cpu_init(void);
+__END_DECLS
+
+#endif /* !__ASSEMBLY__ */
+#endif /* !_X86_CPU_H */
diff --git a/prex-0.9.0/bsp/hal/x86/include/cpufunc.h b/prex-0.9.0/bsp/hal/x86/include/cpufunc.h
new file mode 100755
index 0000000..42cb541
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/include/cpufunc.h
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_CPUFUNC_H
+#define _X86_CPUFUNC_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+void	 cpu_idle(void);
+void	 flush_tlb(void);
+void	 flush_cache(void);
+void	 load_tr(uint32_t);
+void	 load_gdt(void *);
+void	 load_idt(void *);
+uint32_t get_cr2(void);
+void	 set_cr3(uint32_t);
+uint32_t get_cr3(void);
+void	 outb(int, u_char);
+u_char	 inb(int);
+void	 outb_p(int, u_char);
+u_char	 inb_p(int);
+__END_DECLS
+
+#endif /* !_X86_CPUFUNC_H */
diff --git a/prex-0.9.0/bsp/hal/x86/include/locore.h b/prex-0.9.0/bsp/hal/x86/include/locore.h
new file mode 100755
index 0000000..d291dd0
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/include/locore.h
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_LOCORE_H
+#define _X86_LOCORE_H
+
+#include <sys/cdefs.h>
+#include <context.h>
+
+__BEGIN_DECLS
+void	intr_0(void);
+void	intr_1(void);
+void	intr_2(void);
+void	intr_3(void);
+void	intr_4(void);
+void	intr_5(void);
+void	intr_6(void);
+void	intr_7(void);
+void	intr_8(void);
+void	intr_9(void);
+void	intr_10(void);
+void	intr_11(void);
+void	intr_12(void);
+void	intr_13(void);
+void	intr_14(void);
+void	intr_15(void);
+void	trap_default(void);
+void	trap_0(void);
+void	trap_1(void);
+void	trap_2(void);
+void	trap_3(void);
+void	trap_4(void);
+void	trap_5(void);
+void	trap_6(void);
+void	trap_7(void);
+void	trap_8(void);
+void	trap_9(void);
+void	trap_10(void);
+void	trap_11(void);
+void	trap_12(void);
+void	trap_13(void);
+void	trap_14(void);
+void	trap_15(void);
+void	trap_16(void);
+void	trap_17(void);
+void	trap_18(void);
+void	syscall_entry(void);
+void	syscall_ret(void);
+void	cpu_switch(struct kern_regs *, struct kern_regs *);
+void	known_fault1(void);
+void	known_fault2(void);
+void	known_fault3(void);
+void	copy_fault(void);
+void	cpu_reset(void);
+void	cache_init(void);
+void	sploff(void);
+void	splon(void);
+__END_DECLS
+
+#endif /* !_X86_LOCORE_H */
diff --git a/prex-0.9.0/bsp/hal/x86/include/mmu.h b/prex-0.9.0/bsp/hal/x86/include/mmu.h
new file mode 100755
index 0000000..94e8a20
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/include/mmu.h
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_MMU_H
+#define _X86_MMU_H
+
+#include <sys/types.h>
+
+typedef uint32_t	*pgd_t;		/* page directory */
+typedef uint32_t	*pte_t;		/* page table entry */
+
+/*
+ * Page directory entry
+ */
+#define PDE_PRESENT	0x00000001
+#define PDE_WRITE	0x00000002
+#define PDE_USER	0x00000004
+#define PDE_WTHRU	0x00000008
+#define PDE_NCACHE	0x00000010
+#define PDE_ACCESS	0x00000020
+#define PDE_SIZE	0x00000080
+#define PDE_AVAIL	0x00000e00
+#define PDE_ADDRESS	0xfffff000
+
+/*
+ * Page table entry
+ */
+#define PTE_PRESENT	0x00000001
+#define PTE_WRITE	0x00000002
+#define PTE_USER	0x00000004
+#define PTE_WTHRU	0x00000008
+#define PTE_NCACHE	0x00000010
+#define PTE_ACCESS	0x00000020
+#define PTE_DIRTY	0x00000040
+#define PTE_AVAIL	0x00000e00
+#define PTE_ADDRESS	0xfffff000
+
+/*
+ *  Virtual and physical address translation
+ */
+#define PAGE_DIR(virt)      (int)((((vaddr_t)(virt)) >> 22) & 0x3ff)
+#define PAGE_TABLE(virt)    (int)((((vaddr_t)(virt)) >> 12) & 0x3ff)
+
+#define pte_present(pgd, virt)  (pgd[PAGE_DIR(virt)] & PDE_PRESENT)
+
+#define page_present(pte, virt) (pte[PAGE_TABLE(virt)] & PTE_PRESENT)
+
+#define vtopte(pgd, virt) \
+            (pte_t)ptokv(((uint32_t *)pgd)[PAGE_DIR(virt)] & PDE_ADDRESS)
+
+#define ptetopg(pte, virt) \
+            ((pte)[PAGE_TABLE(virt)] & PTE_ADDRESS)
+
+#endif /* !_X86_MMU_H */
diff --git a/prex-0.9.0/bsp/hal/x86/include/trap.h b/prex-0.9.0/bsp/hal/x86/include/trap.h
new file mode 100755
index 0000000..bee6467
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/include/trap.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_TRAP_H
+#define _X86_TRAP_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	 trap_handler(struct cpu_regs *);
+void	 trap_dump(struct cpu_regs *);
+__END_DECLS
+
+#endif /* !_X86_TRAP_H */
diff --git a/prex-0.9.0/bsp/hal/x86/pc/Makefile.inc b/prex-0.9.0/bsp/hal/x86/pc/Makefile.inc
new file mode 100755
index 0000000..cba9bc3
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/pc/Makefile.inc
@@ -0,0 +1,16 @@
+
+SRCS:=		x86/arch/locore.S \
+		x86/arch/cpufunc.S \
+		x86/arch/cpu.c \
+		x86/arch/trap.c \
+		x86/arch/context.c \
+		x86/pc/interrupt.c \
+		x86/pc/clock.c \
+		x86/pc/machdep.c
+
+ifeq ($(CONFIG_MMU),y)
+SRCS+=		x86/arch/mmu.c
+endif
+ifeq ($(DEBUG),1)
+SRCS+=		x86/pc/diag.c
+endif
diff --git a/prex-0.9.0/bsp/hal/x86/pc/clock.c b/prex-0.9.0/bsp/hal/x86/pc/clock.c
new file mode 100755
index 0000000..83d062e
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/pc/clock.c
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * clock.c - clock driver for i8254.
+ */
+
+#include <kernel.h>
+#include <timer.h>
+#include <irq.h>
+#include <sys/ipl.h>
+#include <cpufunc.h>
+
+/* Interrupt vector for clock */
+#define CLOCK_IRQ	0
+
+/* The internal tick rate in ticks per second */
+#define PIT_TICK	1193180L
+
+/* The latch count value for the current HZ setting */
+#define PIT_LATCH	((PIT_TICK + (HZ / 2)) / HZ)
+
+/* I/O port for programmable interval timer */
+#define PIT_CH0		0x40
+#define PIT_CTRL	0x43
+
+/*
+ * Clock interrupt service routine.
+ * No H/W reprogram is required.
+ */
+static int
+clock_isr(void *arg)
+{
+	int s;
+
+	s = splhigh();
+	timer_handler();
+	splx(s);
+
+	return INT_DONE;
+}
+
+/*
+ * Initialize clock H/W chip.
+ * Setup clock tick rate and install clock ISR.
+ */
+void
+clock_init(void)
+{
+	irq_t clock_irq;
+
+	outb_p(PIT_CTRL, 0x34);		/* Command to set generator mode */
+	outb_p(PIT_CH0, (u_char)(PIT_LATCH & 0xff));		/* LSB */
+	outb_p(PIT_CH0, (u_char)((PIT_LATCH >> 8) & 0xff));	/* MSB */
+
+	clock_irq = irq_attach(CLOCK_IRQ, IPL_CLOCK, 0, &clock_isr,
+			       IST_NONE, NULL);
+
+	DPRINTF(("Clock rate: %d ticks/sec\n", CONFIG_HZ));
+}
diff --git a/prex-0.9.0/bsp/hal/x86/pc/diag.c b/prex-0.9.0/bsp/hal/x86/pc/diag.c
new file mode 100755
index 0000000..8ca89ea
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/pc/diag.c
@@ -0,0 +1,203 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * diag.c - diagnostic message support.
+ */
+
+#include <kernel.h>
+#include <sys/bootinfo.h>
+#include <cpufunc.h>
+
+#ifdef CONFIG_DIAG_SCREEN
+
+#define VID_ATTR	0x0F00
+#define VID_PORT	0x03d4
+#define VID_RAM		0xB8000
+
+/* Screen info */
+static short	*vram;
+static int	pos_x;
+static int	pos_y;
+static int	screen_x;
+static int	screen_y;
+
+static void
+screen_scroll_up(void)
+{
+	int i;
+
+	memcpy(vram, vram + screen_x, (size_t)(screen_x * (screen_y - 1) * 2));
+	for (i = 0; i < screen_x; i++)
+		vram[screen_x * (screen_y - 1) + i] = ' ';
+}
+
+static void
+screen_move_cursor(void)
+{
+	int pos = pos_y * screen_x + pos_x;
+
+	outb(VID_PORT, 0x0e);
+	outb(VID_PORT + 1, (u_int)pos >> 8);
+
+	outb(VID_PORT, 0x0f);
+	outb(VID_PORT + 1, (u_int)pos & 0xff);
+}
+
+static void
+screen_newline(void)
+{
+
+	pos_x = 0;
+	pos_y++;
+	if (pos_y >= screen_y) {
+		pos_y = screen_y - 1;
+		screen_scroll_up();
+	}
+}
+
+static void
+screen_putc(char c)
+{
+
+	switch (c) {
+	case '\n':
+		screen_newline();
+		return;
+	case '\r':
+		pos_x = 0;
+		return;
+	case '\b':
+		if (pos_x == 0)
+			return;
+		pos_x--;
+		return;
+	}
+	vram[pos_y * screen_x + pos_x] = c | VID_ATTR;
+	pos_x++;
+	if (pos_x >= screen_x) {
+		pos_x = 0;
+		pos_y++;
+		if (pos_y >= screen_y) {
+			pos_y = screen_y - 1;
+			screen_scroll_up();
+		}
+	}
+}
+
+void
+diag_puts(char *str)
+{
+
+	while (*str)
+		screen_putc(*str++);
+
+	screen_move_cursor();
+}
+
+void
+diag_init(void)
+{
+	struct bootinfo *bi;
+
+	machine_bootinfo(&bi);
+
+	vram = ptokv(VID_RAM);
+	pos_x = 0;
+	pos_y = 0;
+	screen_x = bi->video.text_x;
+	screen_y = bi->video.text_y;
+}
+#endif	/* !CONFIG_DIAG_SCREEN */
+
+
+#ifdef CONFIG_DIAG_BOCHS
+static void
+bochs_putc(char c)
+{
+	/* Write to the bochs debug port. */
+	outb(0xe9, (u_char)c);
+}
+
+void
+diag_puts(char *str)
+{
+
+	/* Skip if Bochs is not running. */
+	if (inb(0xe9) != 0xe9)
+		return;
+
+	while (*str)
+		bochs_putc(*str++);
+}
+
+void
+diag_init(void)
+{
+}
+#endif	/* !CONFIG_DIAG_BOCHS */
+
+
+#ifdef CONFIG_DIAG_SERIAL
+
+#define COM_BASE	CONFIG_NS16550_BASE
+#define COM_THR		(COM_BASE + 0x00)	/* transmit holding register */
+#define COM_LSR		(COM_BASE + 0x05)	/* line status register */
+
+static void
+serial_putc(char c)
+{
+
+	while (!(inb(COM_LSR) & 0x20))
+		;
+	outb(COM_THR, c);
+}
+
+void
+diag_puts(char *str)
+{
+
+	while (*str) {
+		if (*str == '\n')
+			serial_putc('\r');
+		serial_putc(*str++);
+	}
+}
+
+/*
+ * We assume the serial port has already been initialized by
+ * the boot loader.
+ */
+void
+diag_init(void)
+{
+	/* DO NOTHING */
+}
+
+#endif	/* !CONFIG_DIAG_SERIAL */
diff --git a/prex-0.9.0/bsp/hal/x86/pc/interrupt.c b/prex-0.9.0/bsp/hal/x86/pc/interrupt.c
new file mode 100755
index 0000000..2aaa934
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/pc/interrupt.c
@@ -0,0 +1,212 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * interrupt.c - interrupt management routines for intel 8259 chip
+ */
+
+#include <sys/ipl.h>
+#include <kernel.h>
+#include <irq.h>
+#include <cpufunc.h>
+#include <context.h>
+#include <locore.h>
+#include <hal.h>
+
+
+/* Number of IRQ lines */
+#define NIRQS		16
+
+/* I/O address for master/slave programmable interrupt controller */
+#define PIC_M           0x20
+#define PIC_S           0xa0
+
+/* Edge/level control register */
+#define ELCR            0x4d0
+
+/*
+ * Interrupt priority level
+ *
+ * Each interrupt has its logical priority level, with 0 being
+ * the highest priority. While some ISR is running, all lower
+ * priority interrupts are masked off.
+ */
+static volatile int irq_level;
+
+/*
+ * Interrupt mapping table
+ */
+static int	ipl_table[NIRQS];	/* Vector -> level */
+static u_int	mask_table[NIPLS];	/* Level -> mask */
+
+/*
+ * Set mask for current ipl
+ */
+static void
+update_mask(void)
+{
+	u_int mask = mask_table[irq_level];
+
+	outb(PIC_M + 1, mask & 0xff);
+	outb(PIC_S + 1, mask >> 8);
+}
+
+/*
+ * Unmask interrupt in PIC for specified irq.
+ * The interrupt mask table is also updated.
+ * Assumed CPU interrupt is disabled in caller.
+ */
+void
+interrupt_unmask(int vector, int level)
+{
+	u_int unmask = (u_int)~(1 << vector);
+	int i, s;
+
+	s = splhigh();
+	ipl_table[vector] = level;
+	/*
+	 * Unmask target interrupt for all
+	 * lower interrupt levels.
+	 */
+	for (i = 0; i < level; i++)
+		mask_table[i] &= unmask;
+	update_mask();
+	splx(s);
+}
+
+/*
+ * Mask interrupt in PIC for specified irq.
+ * Interrupt must be disabled when this routine is called.
+ */
+void
+interrupt_mask(int vector)
+{
+	u_int mask = (u_int)(1 << vector);
+	int i, level, s;
+
+	s = splhigh();
+	level = ipl_table[vector];
+	for (i = 0; i < level; i++)
+		mask_table[i] |= mask;
+	ipl_table[vector] = IPL_NONE;
+	update_mask();
+	splx(s);
+}
+
+/*
+ * Setup interrupt mode.
+ * Select whether an interrupt trigger is edge or level.
+ */
+void
+interrupt_setup(int vector, int mode)
+{
+	int port, s;
+	u_int bit;
+	u_char val;
+
+	s = splhigh();
+	port = vector < 8 ? ELCR : ELCR + 1;
+	bit = (u_int)(1 << (vector & 7));
+
+	val = inb(port);
+	if (mode == IMODE_LEVEL)
+		val |= bit;
+	else
+		val &= ~bit;
+	outb(port, val);
+	splx(s);
+}
+
+/*
+ * Common interrupt handler.
+ *
+ * This routine is called from the low level interrupt routine
+ * written in assemble code. The interrupt flag is automatically
+ * disabled by h/w in CPU when the interrupt is occurred. The
+ * target interrupt will be masked in ICU while the irq handler
+ * is called.
+ */
+void
+interrupt_handler(struct cpu_regs *regs)
+{
+	int vector = (int)regs->trap_no;
+	int old_ipl, new_ipl;
+
+	/* Adjust interrupt level */
+	old_ipl = irq_level;
+	new_ipl = ipl_table[vector];
+	if (new_ipl > old_ipl)		/* Ignore spurious interrupt */
+		irq_level = new_ipl;
+	update_mask();
+
+	/* Send acknowledge to PIC for specified irq */
+	if (vector & 8)			/* Slave ? */
+		outb(PIC_S, 0x20);	/* Non specific EOI to slave */
+	outb(PIC_M, 0x20);		/* Non specific EOI to master */
+
+	/* Dispatch interrupt */
+	splon();
+	irq_handler(vector);
+	sploff();
+
+	/* Restore interrupt level */
+	irq_level = old_ipl;
+	update_mask();
+}
+
+/*
+ * Initialize 8259 interrupt controllers.
+ * All interrupts will be masked off in ICU.
+ */
+void
+interrupt_init(void)
+{
+	int i;
+
+	irq_level = IPL_NONE;
+
+	for (i = 0; i < NIRQS; i++)
+		ipl_table[i] = IPL_NONE;
+
+	for (i = 0; i < NIPLS; i++)
+		mask_table[i] = 0xfffb;
+
+	outb_p(PIC_M, 0x11);		/* Start initialization edge, master */
+	outb_p(PIC_M + 1, 0x20);	/* Set h/w vector = 0x20 */
+	outb_p(PIC_M + 1, 0x04);	/* Chain to slave (IRQ2) */
+	outb_p(PIC_M + 1, 0x01);	/* 8086 mode */
+
+	outb_p(PIC_S, 0x11);		/* Start initialization edge, master */
+	outb_p(PIC_S + 1, 0x28);	/* Set h/w vector = 0x28 */
+	outb_p(PIC_S + 1, 0x02);	/* Slave (cascade) */
+	outb_p(PIC_S + 1, 0x01);	/* 8086 mode */
+
+	outb(PIC_S + 1, 0xff);		/* Mask all */
+	outb(PIC_M + 1, 0xfb);		/* Mask all except IRQ2 (cascade) */
+}
diff --git a/prex-0.9.0/bsp/hal/x86/pc/machdep.c b/prex-0.9.0/bsp/hal/x86/pc/machdep.c
new file mode 100755
index 0000000..25ba874
--- /dev/null
+++ b/prex-0.9.0/bsp/hal/x86/pc/machdep.c
@@ -0,0 +1,171 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * machdep.c - machine-dependent functions for HAL
+ */
+
+#include <kernel.h>
+#include <page.h>
+#include <machine/syspage.h>
+#include <sys/power.h>
+#include <sys/bootinfo.h>
+#include <mmu.h>
+#include <cpu.h>
+#include <cpufunc.h>
+#include <locore.h>
+
+
+#ifdef CONFIG_MMU
+/*
+ * Virtual and physical address mapping
+ *
+ *      { virtual, physical, size, type }
+ */
+static struct mmumap mmumap_table[] =
+{
+	/*
+	 * RAM
+	 */
+	{ 0x80000000, 0x00000000, AUTOSIZE, VMT_RAM },
+
+	{ 0,0,0,0 }
+};
+#endif
+
+/*
+ * Idle
+ */
+void
+machine_idle(void)
+{
+
+	cpu_idle();
+}
+
+/*
+ * Cause an i386 machine reset.
+ */
+static void
+machine_reset(void)
+{
+	int i;
+
+	/*
+	 * Try to do keyboard reset.
+	 */
+	outb(0x64, 0xfe);
+	for (i = 0; i < 10000; i++)
+		outb(0x80, 0);
+
+	/*
+	 * Do cpu reset.
+	 */
+	cpu_reset();
+
+	/* NOTREACHED */
+}
+
+/*
+ * Power down system.
+ */
+void
+machine_powerdown(int state)
+{
+
+	splhigh();
+
+	DPRINTF(("Power down machine\n\n"));
+
+	switch (state) {
+	case PWR_SUSPEND:
+	case PWR_OFF:
+		for (;;)
+			cpu_idle();
+		/* NOTREACHED */
+		break;
+	case PWR_REBOOT:
+		machine_reset();
+		/* NOTREACHED */
+		break;
+	}
+}
+
+/*
+ * Get pointer to the boot information.
+ */
+void
+machine_bootinfo(struct bootinfo **bip)
+{
+	ASSERT(bip != NULL);
+
+	*bip = (struct bootinfo *)BOOTINFO;
+}
+
+void
+machine_abort(void)
+{
+
+	for (;;) ;
+}
+
+/*
+ * Machine-dependent startup code
+ */
+void
+machine_startup(void)
+{
+#ifdef CONFIG_MMU
+	struct bootinfo *bi = (struct bootinfo *)BOOTINFO;
+#endif
+
+	/*
+	 * Initialize CPU and basic hardware.
+	 */
+	cpu_init();
+	cache_init();
+
+	/*
+	 * Reserve system pages.
+	 */
+	page_reserve(kvtop(SYSPAGE), SYSPAGESZ);
+
+#ifdef CONFIG_MMU
+	/*
+	 * Modify page mapping
+	 * We assume the first block in ram[] for x86 is main memory.
+	 */
+	mmumap_table[0].size = bi->ram[0].size;
+
+	/*
+	 * Initialize MMU
+	 */
+	mmu_init(mmumap_table);
+#endif
+}
diff --git a/prex-0.9.0/conf/arm/gba b/prex-0.9.0/conf/arm/gba
new file mode 100755
index 0000000..1b5f49a
--- /dev/null
+++ b/prex-0.9.0/conf/arm/gba
@@ -0,0 +1,124 @@
+#
+# Prex system configuration file
+#
+
+#
+# Make options
+#
+makeoptions	GCCFLAGS+= -mcpu=arm7tdmi -mtune=arm7tdmi -fno-dwarf2-cfi-asm
+makeoptions	ASFLAGS+= -mfpu=softfpa
+
+#
+# Memory address
+#
+memory		LOADER_TEXT	0x03000000	# Start of boot loader
+memory		KERNEL_TEXT	0x02000000	# Start of kernel
+memory		BOOTIMG_BASE	0x08002000	# Location of boot image
+memory		SYSPAGE_BASE	0x03002000	# Location of system page
+
+#
+# Tunable paramters
+#
+options 	HZ=100		# Ticks/second of the clock
+options 	TIME_SLICE=50	# Context switch ratio (msec)
+options 	OPEN_MAX=8	# Max open files per process
+options 	BUF_CACHE=8	# Blocks for buffer cache
+options 	FS_THREADS=1	# Number of file system threads
+
+#
+# Platform settings
+#
+options		ARM7		# Processor core
+options 	ROMBOOT		# Boot from ROM
+options 	BOOTDISK	# Disk for /boot directory
+
+#
+# General setup
+#
+options 	POSIX		# POSIX support
+options 	CMDBOX		# Core utilities
+options 	TINY		# Optimize for size
+
+#
+# Kernel hacking
+#
+#options 	KD		# Kernel debugger
+#options 	AUDIT		# Security auditing
+
+#
+# Diagnostic options
+#
+#options 	DIAG_SCREEN	# Diagnostic via screen
+options 	DIAG_VBA	# Diagnostic via VBA emulater
+
+#
+# File systems
+#
+#options 	FIFOFS		# FIFO & Pipe
+options 	DEVFS		# Device file system
+options 	RAMFS		# RAM file system
+options 	ARFS		# Archive file system
+
+#
+# Power management
+#
+#options 	PM		# Power management
+#options 	PM_POWERSAVE	# Power policy: Battery optimized
+#options 	PM_PERFORMANCE	# Power policy: Parformance optimized
+
+#
+# Device drivers (initialization order)
+#
+#device		pm		# Power management
+device		cons		# System console
+device		wscons		# Workstation console
+device		lcd		# GBA LCD video (parent:wscons)
+device		swkbd		# Software Keyboard (parent:wscons)
+device		keypad		# GBA keypad (parent:swkbd)
+#device		null		# NULL device
+#device		zero		# Zero device
+device		ramdisk		# RAM disk
+
+#
+# Hardware configuations
+#
+
+#
+# Command box
+#
+#command 	cat
+command 	clear
+command 	cp
+#command 	date
+#command 	dmesg
+#command 	echo
+command 	free
+#command 	head
+#command 	hostname
+#command 	kill
+command 	ls
+#command 	mkdir
+#command 	more
+#command 	mv
+#command 	nice
+#command 	printenv
+command 	ps
+#command 	pwd
+#command 	rm
+#command 	rmdir
+command 	sh
+#command 	sleep
+#command 	sync
+#command 	test
+#command 	touch
+command 	uname
+
+#
+# Adminisrative tools
+#
+#command 	diskutil
+#command 	install
+#command 	pmctrl
+#command 	ktrace
+#command 	lock
+#command 	debug
diff --git a/prex-0.9.0/conf/arm/integrator b/prex-0.9.0/conf/arm/integrator
new file mode 100755
index 0000000..14a233d
--- /dev/null
+++ b/prex-0.9.0/conf/arm/integrator
@@ -0,0 +1,132 @@
+#
+# Prex system configuration file
+#
+
+#
+# Make options
+#
+makeoptions	GCCFLAGS+= -mcpu=arm9tdmi -fno-dwarf2-cfi-asm
+makeoptions	ASFLAGS+= -mfpu=softfpa
+
+#
+# Memory address
+#
+memory		LOADER_TEXT	0x00010000	# Start of boot loader
+memory		KERNEL_TEXT	0x80080000	# Start of kernel
+memory		BOOTIMG_BASE	0x80012000	# Location of boot image
+memory		SYSPAGE_BASE	0x80000000	# Location of system page
+
+#
+# Tunable paramters
+#
+options 	HZ=1000		# Ticks/second of the clock
+options 	TIME_SLICE=50	# Context switch ratio (msec)
+options 	OPEN_MAX=16	# Max open files per process
+options 	BUF_CACHE=32	# Blocks for buffer cache
+options 	FS_THREADS=4	# Number of file system threads
+
+#
+# Platform settings
+#
+options		ARM926EJS	# Processor core
+options 	MMU		# Memory management unit
+options 	CACHE		# Cache memory
+#options 	FPU		# Floating point unit
+#options 	ROMBOOT		# Boot from ROM
+options 	BOOTDISK	# Disk for /boot directory
+
+#
+# General setup
+#
+options 	POSIX		# POSIX support
+options 	CMDBOX		# Core utilities
+#options 	TINY		# Optimize for size
+
+#
+# Kernel hacking
+#
+#options 	KD		# Kernel debugger
+#options 	AUDIT		# Security auditing
+
+#
+# Diagnostic options
+#
+options 	DIAG_SERIAL	# Diagnostic via serial port
+
+#
+# File systems
+#
+options 	FIFOFS		# FIFO & Pipe
+options 	DEVFS		# Device file system
+options 	RAMFS		# RAM file system
+options 	ARFS		# Archive file system
+#options 	FATFS		# FAT file system
+
+#
+# Power management
+#
+options 	PM		# Power management
+#options 	PM_POWERSAVE	# Power policy: Battery optimized
+options 	PM_PERFORMANCE	# Power policy: Parformance optimized
+
+#
+# Device drivers (initialization order)
+#
+device		pm		# Power management
+device		cons		# System console
+device		serial		# Logical serial
+device  	pl011		# ARM PrimeCell PL011 UART (P:serial)
+device		rtc		# Logical RTC
+device 		pl030		# ARM PrimeCell PL030 RTC
+device		null		# NULL device
+device		zero		# Zero device
+device		ramdisk		# RAM disk
+
+#
+# Hardware configuations
+#
+options		ARM_VECTORS=0x00000000
+options		PL011_BASE=0xd6000000
+options		PL011_IRQ=1
+options		PL030_BASE=0xd5000000
+
+
+#
+# Command box
+#
+command 	cat
+command 	clear
+command 	cp
+command 	date
+command 	dmesg
+command 	echo
+command 	free
+command 	head
+command 	hostname
+command 	kill
+command 	ls
+command 	mkdir
+command 	more
+command 	mv
+command 	nice
+command 	printenv
+command 	ps
+command 	pwd
+command 	rm
+command 	rmdir
+command 	sh
+command 	sleep
+command 	sync
+#command 	test
+command 	touch
+command 	uname
+
+#
+# Adminisrative tools
+#
+command 	diskutil
+command 	install
+command 	pmctrl
+command 	ktrace
+command 	lock
+command 	debug
diff --git a/prex-0.9.0/conf/arm/integrator-nommu b/prex-0.9.0/conf/arm/integrator-nommu
new file mode 100755
index 0000000..d5a82fb
--- /dev/null
+++ b/prex-0.9.0/conf/arm/integrator-nommu
@@ -0,0 +1,132 @@
+#
+# Prex system configuration file
+#
+
+#
+# Make options
+#
+makeoptions	GCCFLAGS+= -mcpu=arm9tdmi -fno-dwarf2-cfi-asm
+makeoptions	ASFLAGS+= -mfpu=softfpa
+
+#
+# Memory address
+#
+memory		LOADER_TEXT	0x00010000	# Start of boot loader
+memory		KERNEL_TEXT	0x00080000	# Start of kernel
+memory		BOOTIMG_BASE	0x00012000	# Location of boot image
+memory		SYSPAGE_BASE	0x00000000	# Location of system page
+
+#
+# Tunable paramters
+#
+options 	HZ=1000		# Ticks/second of the clock
+options 	TIME_SLICE=50	# Context switch ratio (msec)
+options 	OPEN_MAX=16	# Max open files per process
+options 	BUF_CACHE=32	# Blocks for buffer cache
+options 	FS_THREADS=4	# Number of file system threads
+
+#
+# Platform settings
+#
+options		ARM926EJS	# Processor core
+#options 	MMU		# Memory management unit
+options 	CACHE		# Cache memory
+#options 	FPU		# Floating point unit
+#options 	ROMBOOT		# Boot from ROM
+options 	BOOTDISK	# Disk for /boot directory
+
+#
+# General setup
+#
+options 	POSIX		# POSIX support
+options 	CMDBOX		# Core utilities
+options 	TINY		# Optimize for size
+
+#
+# Kernel hacking
+#
+#options 	KD		# Kernel debugger
+#options 	AUDIT		# Security auditing
+
+#
+# Diagnostic options
+#
+options 	DIAG_SERIAL	# Diagnostic via serial port
+
+#
+# File systems
+#
+options 	FIFOFS		# FIFO & Pipe
+options 	DEVFS		# Device file system
+options 	RAMFS		# RAM file system
+options 	ARFS		# Archive file system
+#options 	FATFS		# FAT file system
+
+#
+# Power management
+#
+#options 	PM		# Power management
+#options 	PM_POWERSAVE	# Power policy: Battery optimized
+#options 	PM_PERFORMANCE	# Power policy: Parformance optimized
+
+#
+# Device drivers (initialization order)
+#
+#device		pm		# Power management
+device		cons		# System console
+device		serial		# Generic serial
+device  	pl011		# ARM PrimeCell PL011 UART (P:serial)
+device		rtc		# Logical RTC
+device 		pl030		# ARM PrimeCell PL030 RTC
+device		null		# NULL device
+device		zero		# Zero device
+device		ramdisk		# RAM disk
+
+#
+# Hardware configuations
+#
+options		ARM_VECTORS=0x00000000
+options		PL011_BASE=0x16000000
+options		PL011_IRQ=1
+options		PL030_BASE=0x15000000
+
+
+#
+# Command box
+#
+command 	cat
+command 	clear
+command 	cp
+command 	date
+command 	dmesg
+command 	echo
+command 	free
+command 	head
+command 	hostname
+command 	kill
+command 	ls
+command 	mkdir
+command 	more
+command 	mv
+command 	nice
+command 	printenv
+command 	ps
+command 	pwd
+command 	rm
+command 	rmdir
+command 	sh
+command 	sleep
+command 	sync
+#command 	test
+command 	touch
+command 	uname
+
+#
+# Adminisrative tools
+#
+command 	diskutil
+command 	install
+command 	pmctrl
+command 	ktrace
+command 	lock
+command 	debug
diff --git a/prex-0.9.0/conf/etc/files.mk b/prex-0.9.0/conf/etc/files.mk
new file mode 100755
index 0000000..109bb78
--- /dev/null
+++ b/prex-0.9.0/conf/etc/files.mk
@@ -0,0 +1,68 @@
+#
+# Files in /boot
+#
+
+ifeq ($(CONFIG_POSIX),y)
+
+FILES+= 	$(SRCDIR)/usr/sbin/init/init
+FILES+= 	$(SRCDIR)/conf/etc/rc
+FILES+= 	$(SRCDIR)/conf/etc/fstab
+
+ifeq ($(CONFIG_CMDBOX),y)
+FILES+= 	$(SRCDIR)/usr/bin/cmdbox/cmdbox
+endif
+
+ifeq ($(CONFIG_CMD_KTRACE),y)
+FILES+= 	$(SRCDIR)/usr/sbin/ktrace/ktrace
+endif
+
+ifeq ($(CONFIG_CMD_DISKUTIL),y)
+FILES+= 	$(SRCDIR)/usr/sbin/diskutil/diskutil
+endif
+
+ifeq ($(CONFIG_CMD_INSTALL),y)
+FILES+= 	$(SRCDIR)/usr/sbin/install/install
+endif
+
+ifeq ($(CONFIG_CMD_PMCTRL),y)
+FILES+= 	$(SRCDIR)/usr/sbin/pmctrl/pmctrl
+endif
+
+ifeq ($(CONFIG_CMD_LOCK),y)
+FILES+= 	$(SRCDIR)/usr/sbin/lock/lock
+endif
+
+ifeq ($(CONFIG_CMD_DEBUG),y)
+FILES+= 	$(SRCDIR)/usr/sbin/debug/debug
+endif
+
+ifneq ($(_QUICK_),1)
+ifneq ($(CONFIG_TINY),y)
+FILES+=		$(SRCDIR)/usr/sample/hello/hello
+FILES+=		$(SRCDIR)/usr/sample/tetris/tetris
+endif
+endif
+
+#FILES+= 	$(SRCDIR)/usr/test/args/args
+#FILES+= 	$(SRCDIR)/usr/test/attack/attack
+#FILES+= 	$(SRCDIR)/usr/test/conf/conf
+#FILES+= 	$(SRCDIR)/usr/test/creat/creat
+#FILES+= 	$(SRCDIR)/usr/test/debug/debug
+#FILES+= 	$(SRCDIR)/usr/test/dup/dup
+#FILES+= 	$(SRCDIR)/usr/test/environ/environ
+#FILES+= 	$(SRCDIR)/usr/test/fifo/fifo
+#FILES+= 	$(SRCDIR)/usr/test/fork/fork
+#FILES+= 	$(SRCDIR)/usr/test/forkbomb/forkbomb
+#FILES+= 	$(SRCDIR)/usr/test/memleak/memleak
+#FILES+= 	$(SRCDIR)/usr/test/mount/mount
+#FILES+= 	$(SRCDIR)/usr/test/object/object
+#FILES+= 	$(SRCDIR)/usr/test/pipe/pipe
+#FILES+= 	$(SRCDIR)/usr/test/script/hello.sh
+#FILES+= 	$(SRCDIR)/usr/test/signal/signal
+#FILES+= 	$(SRCDIR)/usr/test/stack/stack
+#FILES+= 	$(SRCDIR)/usr/test/stderr/stderr
+#FILES+= 	$(SRCDIR)/usr/test/umount/umount
+
+FILES+=		$(SRCDIR)/doc/LICENSE
+
+endif	# !CONFIG_POSIX
diff --git a/prex-0.9.0/conf/etc/fstab b/prex-0.9.0/conf/etc/fstab
new file mode 100755
index 0000000..91e397d
--- /dev/null
+++ b/prex-0.9.0/conf/etc/fstab
@@ -0,0 +1,14 @@
+# File system table
+
+# Device	Mountpoint	VFSType
+
+none		/		ramfs
+/dev/ram0	/boot		arfs
+none		/dev		devfs
+none		/mnt/fifo	fifofs
+/dev/fd0	/mnt/floppy	fatfs
+
+#/dev/mtd0	/bin		ffs
+#/dev/mtd1	/etc		ffs
+#/dev/cdrom0	/mnt/cdrom	isofs
+#none		/private	cryptfs
diff --git a/prex-0.9.0/conf/etc/rc b/prex-0.9.0/conf/etc/rc
new file mode 100755
index 0000000..39d1fbb
--- /dev/null
+++ b/prex-0.9.0/conf/etc/rc
@@ -0,0 +1,7 @@
+PATH=/boot:/bin
+HOME=/
+export HOME PATH
+uname -msr
+mem
+date
+exec sh
diff --git a/prex-0.9.0/conf/etc/security b/prex-0.9.0/conf/etc/security
new file mode 100755
index 0000000..4ddfdb2
--- /dev/null
+++ b/prex-0.9.0/conf/etc/security
@@ -0,0 +1,42 @@
+#
+# Security configuration
+#
+
+capability	/boot/boot	CAP_DISKADMIN \
+				CAP_PROTSERV \
+			        CAP_SYSFILES
+
+capability	/boot/proc	CAP_RAWIO \
+				CAP_KILL \
+				CAP_TASKCTRL \
+				CAP_EXTMEM \
+				CAP_PROTSERV
+
+capability	/boot/fs	CAP_NICE \
+				CAP_RAWIO \
+				CAP_EXTMEM \
+				CAP_SYSFILES \
+				CAP_PROTSERV
+
+capability	/boot/exec	CAP_NICE \
+				CAP_SETPCAP \
+				CAP_TASKCTRL \
+				CAP_EXTMEM \
+				CAP_PROTSERV \
+				CAP_SYSFILES
+
+capability	/boot/pow	CAP_RAWIO \
+				CAP_KILL \
+				CAP_POWERMGMT \
+				CAP_PROTSERV
+
+capability	/boot/init	CAP_KILL
+
+capability	/boot/cmdbox	CAP_NICE \
+				CAP_KILL
+
+capability	/boot/install	CAP_SYSFILES
+
+capability	/boot/pmctrl	CAP_POWERMGMT
+
+capability	/boot/lock	CAP_USERFILES
diff --git a/prex-0.9.0/conf/etc/tasks.mk b/prex-0.9.0/conf/etc/tasks.mk
new file mode 100755
index 0000000..5b7a067
--- /dev/null
+++ b/prex-0.9.0/conf/etc/tasks.mk
@@ -0,0 +1,49 @@
+#
+# Boot tasks
+#
+
+ifeq ($(CONFIG_POSIX),y)
+TASKS+= 	$(SRCDIR)/usr/server/boot/boot
+TASKS+= 	$(SRCDIR)/usr/server/proc/proc
+TASKS+= 	$(SRCDIR)/usr/server/exec/exec
+ifeq ($(CONFIG_PM),y)
+TASKS+= 	$(SRCDIR)/usr/server/pow/pow
+endif
+TASKS+= 	$(SRCDIR)/usr/server/fs/fs
+endif
+
+#TASKS+= 	$(SRCDIR)/usr/sample/alarm/alarm.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/bench/bench.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/ipc/ipc.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/mutex/mutex.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/sem/sem.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/task/task.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/thread/thread.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/balls/balls.rt
+
+#TASKS+= 	$(SRCDIR)/usr/test/console/console.rt
+#TASKS+= 	$(SRCDIR)/usr/test/deadlock/deadlock.rt
+#TASKS+= 	$(SRCDIR)/usr/test/errno/errno.rt
+#TASKS+= 	$(SRCDIR)/usr/test/exception/exception.rt
+#TASKS+= 	$(SRCDIR)/usr/test/fault/fault.rt
+#TASKS+= 	$(SRCDIR)/usr/test/fdd/fdd.rt
+#TASKS+= 	$(SRCDIR)/usr/test/ipc/ipc.rt
+#TASKS+= 	$(SRCDIR)/usr/test/ipc_mt/ipc_mt.rt
+#TASKS+= 	$(SRCDIR)/usr/test/kbd/kbd.rt
+#TASKS+= 	$(SRCDIR)/usr/test/kmon/kmon.rt
+#TASKS+= 	$(SRCDIR)/usr/test/malloc/malloc.rt
+#TASKS+= 	$(SRCDIR)/usr/test/mutex/mutex.rt
+#TASKS+= 	$(SRCDIR)/usr/test/sem/sem.rt
+#TASKS+= 	$(SRCDIR)/usr/test/task/task.rt
+#TASKS+= 	$(SRCDIR)/usr/test/thread/thread.rt
+#TASKS+= 	$(SRCDIR)/usr/test/time/time.rt
+#TASKS+= 	$(SRCDIR)/usr/test/timer/timer.rt
+#TASKS+= 	$(SRCDIR)/usr/test/ramdisk/ramdisk.rt
+#TASKS+= 	$(SRCDIR)/usr/test/reset/reset.rt
+#TASKS+= 	$(SRCDIR)/usr/test/zero/zero.rt
+
+#TASKS+= 	$(SRCDIR)/usr/test/cpufreq/cpufreq.rt
+#TASKS+= 	$(SRCDIR)/usr/sample/cpumon/cpumon.rt
+
+#TASKS+= 	$(SRCDIR)/usr/server/fs/fs
+#TASKS+= 	$(SRCDIR)/usr/test/fileio/fileio.rt
diff --git a/prex-0.9.0/conf/ppc/prep b/prex-0.9.0/conf/ppc/prep
new file mode 100755
index 0000000..bf17e24
--- /dev/null
+++ b/prex-0.9.0/conf/ppc/prep
@@ -0,0 +1,140 @@
+#
+# Prex system configuration file
+#
+
+#
+# Make options
+#
+makeoptions	GCCFLAGS+= -mcpu=powerpc -m32 -mno-eabi -msoft-float
+makeoptions	GCCFLAGS+= -fno-dwarf2-cfi-asm
+makeoptions	ASFLAGS+= -mregnames
+
+#
+# Memory address
+#
+memory		LOADER_TEXT	0x00100000	# Start of boot loader
+memory		KERNEL_TEXT	0x00080000	# Start of kernel
+memory		BOOTIMG_BASE	0x00102000	# Location of boot image
+memory		SYSPAGE_BASE	0x00000000	# Location of system page
+
+#
+# Tunable paramters
+#
+options 	HZ=1000		# Ticks/second of the clock
+options 	TIME_SLICE=50	# Context switch ratio (msec)
+options 	OPEN_MAX=16	# Max open files per process
+options 	BUF_CACHE=32	# Blocks for buffer cache
+options 	FS_THREADS=4	# Number of file system threads
+
+#
+# Platform settings
+#
+options		MPC750		# Processor type
+#options 	MMU		# Memory management unit
+options 	CACHE		# Cache memory
+#options 	FPU		# Floating point unit
+#options 	ROMBOOT		# Boot from ROM
+options 	BOOTDISK	# Disk for /boot directory
+options		PPC_OEA		# PowerPC OEA
+
+#
+# General setup
+#
+options 	POSIX		# POSIX support
+options 	CMDBOX		# Core utilities
+#options 	TINY		# Optimize for size
+
+#
+# Kernel hacking
+#
+options 	KD		# Kernel debugger
+#options 	AUDIT		# Security auditing
+
+#
+# Diagnostic options
+#
+#options 	DIAG_SCREEN	# Diagnostic via screen
+#options 	DIAG_SERIAL	# Diagnostic via serial port
+options 	DIAG_QEMU	# Diagnostic via qemu emulater
+
+#
+# File systems
+#
+#options 	FIFOFS		# FIFO & Pipe
+options 	DEVFS		# Device file system
+options 	RAMFS		# RAM file system
+options 	ARFS		# Archive file system
+#options 	FATFS		# FAT file system
+
+#
+# Power management
+#
+options 	PM		# Power management
+#options 	PM_POWERSAVE	# Power policy: Battery optimized
+options 	PM_PERFORMANCE	# Power policy: Parformance optimized
+#options 	DVS_EMULATION	# Dynamic voltage scaling emulation
+
+#
+# Device drivers (initialization order)
+#
+device		pm		# Power management
+device		cons		# System console
+#device		wscons		# Workstation console
+#device		pckbd	    	# PC/AT Keyboard (P:wscons)
+#device		vga	    	# VGA video (P:wscons)
+device		serial		# Logical serial
+device		ns16550	    	# NS16550 serial port (P:serial)
+#device		psaux		# PS/2 Mouse
+device		rtc		# Logical RTC
+device		mc146818	# MC146818 Real time clock (P:rtc)
+device		null		# NULL device
+device		zero		# Zero device
+device		ramdisk		# RAM disk
+#device		fdd		# Floppy disk drive
+
+#
+# Hardware configuations
+#
+options		NS16550_BASE=0x3f8
+options		NS16550_IRQ=4
+options		MC146818_BASE=0x70
+
+#
+# Command box
+#
+command 	cat
+command 	clear
+command 	cp
+command 	date
+command 	dmesg
+command 	echo
+command 	free
+command 	head
+command 	hostname
+command 	kill
+command 	ls
+command 	mkdir
+command 	more
+command 	mv
+command 	nice
+command 	printenv
+command 	ps
+command 	pwd
+command 	rm
+command 	rmdir
+command 	sh
+command 	sleep
+command 	sync
+#command 	test
+command 	touch
+command 	uname
+
+#
+# Adminisrative tools
+#
+command 	diskutil
+command 	install
+command 	pmctrl
+command 	ktrace
+command 	lock
+command 	debug
diff --git a/prex-0.9.0/conf/x86/pc b/prex-0.9.0/conf/x86/pc
new file mode 100755
index 0000000..6a1b31d
--- /dev/null
+++ b/prex-0.9.0/conf/x86/pc
@@ -0,0 +1,141 @@
+#
+# Prex system configuration file
+#
+
+#
+# Make options
+#
+makeoptions	GCCFLAGS+= -march=i386
+makeoptions	GCCFLAGS+= -mpreferred-stack-boundary=2
+
+#
+# Memory address
+#
+memory		LOADER_TEXT	0x00004000	# Start of boot loader
+memory		KERNEL_TEXT	0x80010000	# Start of kernel
+memory		BOOTIMG_BASE	0x80100000	# Location of boot image
+memory		SYSPAGE_BASE	0x80000000	# Location of system page
+
+#
+# Tunable paramters
+#
+options 	HZ=1000		# Ticks/second of the clock
+options 	TIME_SLICE=50	# Context switch ratio (msec)
+options 	OPEN_MAX=16	# Max open files per process
+options 	BUF_CACHE=32	# Blocks for buffer cache
+options 	FS_THREADS=4	# Number of file system threads
+
+#
+# Platform settings
+#
+options		I386		# Processor type
+options 	MMU		# Memory management unit
+options 	CACHE		# Cache memory
+#options 	FPU		# Floating point unit
+#options 	ROMBOOT		# Boot from ROM
+options 	BOOTDISK	# Disk for /boot directory
+
+#
+# General setup
+#
+options 	POSIX		# POSIX support
+options 	CMDBOX		# Core utilities
+#options 	TINY		# Optimize for size
+
+#
+# Kernel hacking
+#
+options 	KD		# Kernel debugger
+#options 	AUDIT		# Security auditing
+
+#
+# Diagnostic options
+#
+#options 	DIAG_SCREEN	# Diagnostic via screen
+#options 	DIAG_SERIAL	# Diagnostic via serial port
+options 	DIAG_BOCHS	# Diagnostic via Bochs emulater
+
+#
+# File systems
+#
+options 	FIFOFS		# FIFO & Pipe
+options 	DEVFS		# Device file system
+options 	RAMFS		# RAM file system
+options 	ARFS		# Archive file system
+options 	FATFS		# FAT file system
+
+#
+# Power management
+#
+options 	PM		# Power management
+#options 	PM_POWERSAVE	# Power policy: Battery optimized
+options 	PM_PERFORMANCE	# Power policy: Parformance optimized
+options 	DVS_EMULATION	# Dynamic voltage scaling emulation
+
+#
+# Device drivers (initialization order)
+#
+device		pm		# Power management
+device		i8237		# I8237 DMA controller
+device		cons		# System console
+device		wscons		# Workstation console
+device		pckbd	    	# PC/AT Keyboard (P:wscons)
+device		vga	    	# VGA video (P:wscons)
+#device		serial		# Logical serial
+#device		ns16550	    	# NS16550 serial port (P:serial)
+#device		psaux		# PS/2 Mouse
+device		cpufreq		# CPU frequency controll
+device		est	    	# Intel enhanced speedstep (P:cpufreq)
+device		rtc		# Logical RTC
+device		mc146818	# MC146818 Real time clock (P:rtc)
+device		null		# NULL device
+device		zero		# Zero device
+device		ramdisk		# RAM disk
+device		fdd		# Floppy disk drive
+
+#
+# Hardware configuations
+#
+options		NS16550_BASE=0x3f8
+options		NS16550_IRQ=4
+options		MC146818_BASE=0x70
+
+#
+# Command box
+#
+command 	cat
+command 	clear
+command 	cp
+command 	date
+command 	dmesg
+command 	echo
+command 	free
+command 	head
+command 	hostname
+command 	kill
+command 	ls
+command 	mkdir
+command 	more
+command 	mv
+command 	nice
+command 	printenv
+command 	ps
+command 	pwd
+command 	rm
+command 	rmdir
+command 	sh
+command 	sleep
+command 	sync
+#command 	test
+command 	touch
+command 	uname
+
+#
+# Adminisrative tools
+#
+command 	diskutil
+command 	install
+command 	pmctrl
+command 	ktrace
+command 	lock
+command 	debug
diff --git a/prex-0.9.0/conf/x86/pc-nommu b/prex-0.9.0/conf/x86/pc-nommu
new file mode 100755
index 0000000..c7d2090
--- /dev/null
+++ b/prex-0.9.0/conf/x86/pc-nommu
@@ -0,0 +1,141 @@
+#
+# Prex system configuration file
+#
+
+#
+# Make options
+#
+makeoptions	GCCFLAGS+= -march=i386
+makeoptions	GCCFLAGS+= -mpreferred-stack-boundary=2
+
+#
+# Memory address
+#
+memory		LOADER_TEXT	0x00004000	# Start of boot loader
+memory		KERNEL_TEXT	0x00010000	# Start of kernel
+memory		BOOTIMG_BASE	0x00100000	# Location of boot image
+memory		SYSPAGE_BASE	0x00000000	# Location of system page
+
+#
+# Tunable paramters
+#
+options 	HZ=1000		# Ticks/second of the clock
+options 	TIME_SLICE=50	# Context switch ratio (msec)
+options 	OPEN_MAX=8	# Max open files per process
+options 	BUF_CACHE=16	# Blocks for buffer cache
+options 	FS_THREADS=1	# Number of file system threads
+
+#
+# Platform settings
+#
+options		I386		# Processor type
+#options 	MMU		# Memory management unit
+options 	CACHE		# Cache memory
+#options 	FPU		# Floating point unit
+#options 	ROMBOOT		# Boot from ROM
+options 	BOOTDISK	# Disk for /boot directory
+
+#
+# General setup
+#
+options 	POSIX		# POSIX support
+options 	CMDBOX		# Core utilities
+options 	TINY		# Optimize for size
+
+#
+# Kernel hacking
+#
+options 	KD		# Kernel debugger
+#options 	AUDIT		# Security auditing
+
+#
+# Diagnostic options
+#
+#options 	DIAG_SCREEN	# Diagnostic via screen
+#options 	DIAG_SERIAL	# Diagnostic via serial port
+options 	DIAG_BOCHS	# Diagnostic via Bochs emulater
+
+#
+# File systems
+#
+options 	FIFOFS		# FIFO & Pipe
+options 	DEVFS		# Device file system
+options 	RAMFS		# RAM file system
+options 	ARFS		# Archive file system
+#options 	FATFS		# FAT file system
+
+#
+# Power management
+#
+options 	PM		# Power management
+options 	PM_POWERSAVE	# Power policy: Battery optimized
+#options 	PM_PERFORMANCE	# Power policy: Parformance optimized
+options 	DVS_EMULATION	# Dynamic voltage scaling emulation
+
+#
+# Device drivers (initialization order)
+#
+device		pm		# Power management
+device		i8237		# I8237 DMA controller
+device		cons		# System console
+device		wscons		# Workstation console
+device		pckbd	    	# PC/AT Keyboard (P:wscons)
+device		vga	    	# VGA video (P:wscons)
+#device		serial		# Logical serial
+#device		ns16550	    	# NS16550 serial port (P:serial)
+#device 	psaux		# PS/2 Mouse
+#device		cpufreq		# CPU frequency controll
+#device		est	    	# Intel enhanced speedstep (P:cpufreq)
+device		rtc		# Logical RTC
+device		mc146818	# MC146818 Real time clock
+device		null		# NULL device
+device		zero		# Zero device
+device		ramdisk		# RAM disk
+#device		fdd		# Floppy disk drive
+
+#
+# Hardware configuations
+#
+options		NS16550_BASE=0x3f8
+options		NS16550_IRQ=4
+options		MC146818_BASE=0x70
+
+#
+# Command box
+#
+command 	cat
+command 	clear
+command 	cp
+command 	date
+command 	dmesg
+command 	echo
+command 	free
+command 	head
+command 	hostname
+command 	kill
+command 	ls
+command 	mkdir
+command 	more
+command 	mv
+command 	nice
+command 	printenv
+command 	ps
+command 	pwd
+command 	rm
+command 	rmdir
+command 	sh
+command 	sleep
+command 	sync
+#command 	test
+command 	touch
+command 	uname
+
+#
+# Adminisrative tools
+#
+command 	diskutil
+command 	install
+command 	pmctrl
+command 	ktrace
+command 	lock
+command 	debug
diff --git a/prex-0.9.0/configure b/prex-0.9.0/configure
new file mode 100755
index 0000000..7f24750
--- /dev/null
+++ b/prex-0.9.0/configure
@@ -0,0 +1,400 @@
+#! /bin/sh
+#
+# Prex configure script
+#
+# Required host commands: echo, pwd, expr, uname, tr, cat, cp
+#
+
+usage()
+{
+	if [ -n "$*" ]; then
+		echo "configure: $*"
+	fi
+	echo
+	echo "Usage: configure [options]"
+	echo "Options:"
+	echo "	--help			print this message"
+	echo "	--target=TARGET		use TARGET for target system"
+	echo "	--profile=PROFILE	use PROFILE for target profile"
+	echo "	--cross-prefix=PREFIX	use PREFIX for compile tools"
+	echo "	--cc=CC			use CC as C compiler"
+	echo "	--no-debug		disable all debug features"
+
+	exit 1
+}
+
+quit()
+{
+	echo "Error: $1"
+	exit 1
+}
+
+setdefaults()
+{
+	target=""
+	profile=""
+	prefix=""
+	srcdir=`pwd`
+
+	# Use GNU tools as default toolchain
+	cc="gcc"
+	cpp="cpp"
+	as="as"
+	ld="ld"
+	ar="ar"
+	objcopy="objcopy"
+	objdump="objdump"
+	strip="strip"
+}
+
+checkpath()
+{
+	# Input files
+	CONFIG_IN=$srcdir/conf/$arch/$platform$profile
+	SECURITY_IN=$srcdir/conf/etc/security
+
+	# Output files
+	CONFIG_MK=$srcdir/conf/config.mk
+	CONFIG_H=$srcdir/conf/config.h
+	CONFIG_LD=$srcdir/conf/config.ld
+	DRVTAB_H=$srcdir/conf/drvtab.h
+	DRVTAB_TMP=$srcdir/conf/drvtab.tmp
+	CAPTAB_H=$srcdir/conf/captab.h
+
+	if [ ! -f $CONFIG_IN ]; then
+		quit "Can not find $CONFIG_IN for '$target' target"
+	fi
+}
+
+parseargs()
+{
+	while [ -n "$1" ]; do
+		case $1 in
+		--*=*)
+			option=`expr "x$1" : 'x\([^=]*\)='`
+			optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+			;;
+		--*)
+			option=$1
+			;;
+		*)
+			usage "unrecognized option $1"
+			;;
+		esac
+
+		case $option in
+		--help)
+			usage
+			;;
+		--target)
+			target=$optarg
+			;;
+		--profile)
+			profile="-$optarg"
+			;;
+		--cross-prefix)
+			prefix=$optarg
+			;;
+		--cc)
+			cc=$optarg
+			;;
+		--no-debug)
+			nodebug=1
+			;;
+		*)
+			usage "Unrecognized option $1"
+			;;
+		esac
+		shift
+	done
+}
+
+gettarget()
+{
+	if [ -z "$target" ]; then
+		echo "Warning: '--target' option was not specified"
+		echo "The target system was set to 'x86-pc'"
+		target="x86-pc"
+	fi
+
+	arch=`expr "x$target" : 'x\([^=]*\)-'`
+	platform=`expr "x$target" : 'x[^=]*-\(.*\)'`
+
+	case "$arch" in
+	x86|arm|ppc|sh|mips)
+		;;
+	*)
+		quit "Unkown target architecture: $arch"
+		;;
+	esac
+}
+
+gethost()
+{
+	# 'uname' command may be unavailable under Windows.
+	# So, we check MACHTYPE variable for cygwin/mingw at first.
+	case "$MACHTYPE" in
+	*-cygwin)
+		hostname="CYGWIN"
+		;;
+	*-msys)
+		hostname="MINGW"
+		;;
+	*)
+		hostname=`uname -s`
+		;;
+	esac
+}
+
+# Set the gcc option only when it's supported.
+setgccoption()
+{
+	echo "checking $1"
+	if ${prefix}${cc} $1 -S -xc /dev/null -o /dev/null > /dev/null 2>&1; then
+		echo "GCCFLAGS+= $1" >> $CONFIG_MK
+	fi
+}
+
+checktools()
+{
+	#
+	# Check compiler version
+	#
+	case "$cc" in
+	*gcc*)
+		setgccoption "-fno-stack-protector"
+		;;
+	esac
+}
+
+settools()
+{
+	#
+	# Set host specific tool settings
+	#
+	case "$hostname" in
+	*BSD)
+		;;
+	SunOS)
+		# Solaris
+		as="gas"
+		ld="gld"
+		ar="gar"
+		strip="gstrip"
+		objcopy="gobjcopy"
+		objdump="gobjdump"
+		;;
+	CYGWIN*|MINGW*)
+		case "$arch" in
+		x86)
+			prefix="i386-elf-"
+			;;
+		ppc)
+			prefix="powerpc-elf-"
+			;;
+		*)
+			prefix="$arch-elf-"
+			;;
+		esac
+		;;
+	esac
+
+	#
+	# Set tools
+	#
+	case "$cc" in
+	*gcc*)
+		cc_type="_GNUC_"
+		;;
+	pcc)
+		cc_type="_PCC_"
+		;;
+	suncc)
+		cc_type="_SUNPRO_C_"
+		cc="suncc"
+		;;
+	*)
+		quit "Unkown compiler: $cc"
+		;;
+	esac
+}
+
+options()
+{
+	param=`expr "x$1" : 'x\([^= ]*\)'`
+	value=`expr "x$1" : 'x[^=]*=\([A-Za-z0-9\.]*\)'`
+
+	if [ "x$value" = x ] ; then
+		echo "CONFIG_${param}=y"
+		echo "CONFIG_${param}=y" >> $CONFIG_MK
+		echo "#define CONFIG_${param} y" >> $CONFIG_H
+	else
+		echo "CONFIG_${param}=${value}"
+		echo "CONFIG_${param}=${value}" >> $CONFIG_MK
+		echo "#define CONFIG_${param} ${value}" >> $CONFIG_H
+	fi
+}
+
+device()
+{
+	param=`echo $1 | tr '[a-z]' '[A-Z]'`
+
+	echo "CONFIG_${param}=y"
+	echo "CONFIG_${param}=y" >> $CONFIG_MK
+	echo "#define CONFIG_${param} y" >> $CONFIG_H
+
+	echo "extern struct driver $1_driver;" >> $DRVTAB_H
+	echo "	&$1_driver," >> $DRVTAB_TMP
+}
+
+capability()
+{
+	{
+		echo "{"
+		echo "	\"$1\","
+		shift 1
+		while [ "$1" != "" ] ; do
+			if [ "$2" != "" ] ; then
+				echo "	$1 |"
+			else
+				echo "	$1"
+			fi
+			shift 1
+		done
+		echo "},"
+	} >> $CAPTAB_H
+}
+
+memory()
+{
+	echo "CONFIG_$1=$2"
+	echo "CONFIG_$1=$2" >> $CONFIG_MK
+	echo "CONFIG_$1 = $2 ;" >> $CONFIG_LD
+	echo "#define CONFIG_$1 $2" >> $CONFIG_H
+}
+
+command()
+{
+	param=`echo $1 | tr '[a-z]' '[A-Z]'`
+
+	echo "CONFIG_CMD_${param}=y"
+	echo "CONFIG_CMD_${param}=y" >> $CONFIG_MK
+	echo "#define CONFIG_CMD_${param} y" >> $CONFIG_H
+}
+
+parseconfig()
+{
+	while read line; do
+		read cmd rest <<-END_OF_COMMAND
+			$line
+		END_OF_COMMAND
+
+		case "$cmd" in
+		options)
+			options $rest
+			;;
+		device)
+			device $rest
+			;;
+		capability)
+			capability $rest
+			;;
+		makeoptions)
+			echo "$rest"
+			echo "$rest" >> $CONFIG_MK
+			;;
+		memory)
+			memory $rest
+			;;
+		command)
+			command $rest
+			;;
+		esac
+	done < $1
+}
+
+main()
+{
+	[ -d conf ] ||
+		quit "configure must be run from the top source level"
+
+	#
+	# Process input arguments
+	#
+	setdefaults
+	parseargs "$@"
+	gettarget
+	checkpath
+	gethost
+	settools
+
+	echo "#" > $CONFIG_MK
+	echo "# Automatically generated file. Don't edit" >> $CONFIG_MK
+	echo "#" >> $CONFIG_MK
+	echo "_CONFIG_MK_=1" >> $CONFIG_MK
+
+	echo "/*" > $CONFIG_H
+	echo " * Automatically generated file. Don't edit" >> $CONFIG_H
+	echo " */" >> $CONFIG_H
+
+	cp $CONFIG_H $CONFIG_LD
+	cp $CONFIG_H $DRVTAB_H
+	cp $CONFIG_H $CAPTAB_H
+
+	echo "" > $DRVTAB_TMP
+	echo "struct driver *driver_table[] = {" >> $DRVTAB_TMP
+
+
+	echo "" >> $CAPTAB_H
+	echo "const struct cap_map cap_table[] = {" >> $CAPTAB_H
+
+	#
+	# Setup build settings
+	#
+	{
+		echo "ARCH=${arch}"
+		echo "PLATFORM=${platform}"
+		echo "PROFILE=${platform}${profile}"
+		if [ -n "${nodebug}" ]; then
+			echo "NDEBUG=1"
+		fi
+		echo "${cc_type}=1"
+		echo "CC=${prefix}${cc}"
+		echo "CPP=${prefix}${cpp}"
+		echo "AS=${prefix}${as}"
+		echo "LD=${prefix}${ld}"
+		echo "AR=${prefix}${ar}"
+		echo "OBJCOPY=${prefix}${objcopy}"
+		echo "OBJDUMP=${prefix}${objdump}"
+		echo "STRIP=${prefix}${strip}"
+
+	} >> $CONFIG_MK
+
+	#
+	# Adjust tool options
+	#
+	checktools
+
+	#
+	# Generate configuration parameters
+	#
+	echo "checking configuration files..."
+	echo "#define CONFIG_MACHINE ${target}" >> $CONFIG_H
+	echo "#define CONFIG_PROFILE ${profile}" >> $CONFIG_H
+
+	parseconfig $CONFIG_IN
+	parseconfig $SECURITY_IN
+
+	cat $DRVTAB_TMP >> $DRVTAB_H
+	echo "};" >> $DRVTAB_H
+	rm -f $DRVTAB_TMP
+
+	echo "{	NULL, 0 }" >> $CAPTAB_H
+	echo "};" >> $CAPTAB_H
+
+	echo
+	echo "Prex is now hopefully configured for your setup."
+	echo "Now you must run a make."
+}
+
+main "$@"
diff --git a/prex-0.9.0/doc/ChangeLog b/prex-0.9.0/doc/ChangeLog
new file mode 100755
index 0000000..af0e21b
--- /dev/null
+++ b/prex-0.9.0/doc/ChangeLog
@@ -0,0 +1,332 @@
+
+Version 0.9.0:
+
+ - New: Enable capability based security by default.
+ - New: Support resource limit to prevent DoS attack.
+ - New: Add task_chkcap() kernel call to trace the capability violations.
+ - New: Support pipe and redirection in shell.
+ - New: Support LCD off timer.
+ - New: Add some logical drivers with new driver model.
+ - New: Move HAL in BSP directory.
+ - New: Define compiler options in tool specific makefiles.
+ - New: Add test program for POSIX configuration interface.
+ - New: Handle PATH variable for exec in shell.
+ - New: Add 'spl' interrupt framework derived from BSD.
+ - New: Add 'more' command to verify the pipe feature in shell.
+ - New: Support SUN studio compiler.
+ - New: Change name of real-time task to *.rt to identify it easily.
+ - New: Support path based capability mapping.
+ - New: Support getenv()/putenv().
+ - New: Change irq_attach() to pass data for IST.
+ - New: Add power server - 'pow'.
+ - New: Define power action for each power event.
+ - New: Add test program for POSIX environment variable.
+ - New: Add 'fstab' - file system table.
+ - New: Add configuration file to customize capability table.
+ - New: Run 'rc' script at boot.
+ - New: Add 'set', 'unset' and 'export' command in shell.
+ - New: Add script loader in exec server.
+ - New: Add 'pmctrl' - power management utility.
+ - New: Add _SILENT_ switch for build.
+ - New: Support protected name for system object.
+ - New: Add CAP_PROTSERV capability.
+ - New: Add a shutdown routine in the driver structure.
+ - New: Add an argument for the private data size in device_create().
+ - New: Add device_private() to get the pointer to the private data.
+ - New: Add device_control() service to access another driver.
+ - New: Add the kernel test program for random parameter attack.
+ - New: Add 'diskutil' - disk management utilitiy.
+ - New: Add 'install' - software installer.
+ - New: Add 'ktrace' - system call tracer.
+ - New: Add CAP_USERFILES/CAP_SYSFILES for data caging.
+ - New: Add workstation console multiplexer driver - 'wscons'.
+ - New: Initial PowerPC support.
+ - New: Add _STRICT_ switch for build.
+ - New: Add new device flag (D_PROT) for protected devices.
+ - New: Support Solaris for host.
+ - New: Add audit mode to find defective application.
+ - New: Add test program for stack overflow.
+ - New: Initial version of kernel debugger.
+ - New: Add 'lock' - terminal lock utility.
+ - Fix: Page fault in realloc().
+ - Fix: Remove the internal 'more' command support.
+ - Fix: exception_return() breaks the return value of subsequent syscall.
+ - Fix: 'tty' - the new line is not handled properly.
+ - Fix: Intermittent hang during task_terminate().
+ - Fix: 'lr' register is broken after fork(). (ARM)
+ - Fix: Enable interrupts during system call (ARM).
+ - Fix: Page fault under sub-shell (NOMMU).
+ - Fix: The pipe() system call fails at second call.
+ - Fix: Fix to increment the file reference in dup2().
+ - Fix: The byte count for writing fifo is always 0.
+ - Fix: Memory leak in task_terminate().
+ - Fix: Synchronize server initializations to prevent dead lock.
+ - Fix: Allow priority change if the target thread belongs to the child task.
+ - Fix: Fix to print the file type for device file correctly.
+ - Fix: Reduce #ifdef in the kernel.
+ - Fix: Remove all magic number from the kernel objects.
+ - Fix: Fix the compile error with gcc 2.95. Correct the format of printf.
+ - Fix: Fix to reject changing the capability of the kernel task.
+ - Fix: Fix system hang when kernel is compiled with PCC.
+ - Fix: Remove redundant comments.
+ - Fix: Add signal number in the return code of waitpid().
+ - Fix: Fix to set correct errno when gettimeofday() is failed.
+ - Fix: Change mode_t type to uint32_t.
+ - Fix: Remove workaround for ioctl() buffering issue.
+ - Fix: Move isatty() service to fs server from the library code.
+ - Fix: Remove CAP_IPC capability.
+ - Fix: Remove CAP_SEMAPHORE capability.
+ - Fix: Prevent format string attack with sys_log().
+ - Fix: Fix many codes to prevent buffer overflow caused by strcpy/strcat.
+ - Fix: Add PRIO_REALTIME for the default priority of the real-time threads.
+ - Fix: Page fault in 'nice'. The first item of the envp is lost.
+ - Fix: Add cwd data in exec message to build the full path in exec server.
+ - Fix: setpriority() returns error even if it is success.
+ - Fix: Change 'fifofs' mount point to /mnt/fifo from /fifo.
+ - Fix: Change to generate driver table from configuration file.
+ - Fix: 'proc' - some process data are not initialized for fork().
+ - Fix: Fix alignment of argv pointers.
+ - Fix: 'tty' - fix for big endian.
+ - Fix: Modify libc to reduce the size of executable file.
+
+Version 0.8.1:
+
+ - New: Add MMU support for ARM.
+ - New: Support Integrator/CP platform.
+ - New: Add the function to relocate ARM exception vectors.
+ - New: Add exception handling for ARM architecture.
+ - New: Add machine_setpower() interface in DKI.
+ - New: Define 'syspage' which holds architecture specific data.
+ - New: Change architecture interface to common definition in all platforms.
+ - New: Add physical/virtual address mapping table.
+ - New: Support multiple RAM regions.
+ - New: Add the serial console driver for PC.
+ - New: Add tetris game ported from BSD.
+ - New: Add '--profile' option in the configure script.
+ - New: Support static driver to debug with fixed symbol address.
+ - Fix: Change all external function declarations as BSD style.
+ - Fix: Remove time data from the kernel banner string.
+ - Fix: Improve build and configuration system.
+ - Fix: Add tty_done() to notify the completion of the TTY output interrupt.
+ - Fix: Fix the broken output of 'mem' command in 'kmon'.
+
+
+Version 0.8.0:
+
+ - New: Add 'fatfs' - FAT file system.
+ - New: Add 'fifofs' - FIFO file system.
+ - New: Support pipe().
+ - New: Support compiling with PCC (Portable C Compiler).
+ - New: Add 'head' command.
+ - New: Add 'cal' command.
+ - Fix: Fix object_create() for no object name.
+ - Fix: Remove all variadic macros for C90 compilers.
+ - Fix: The semaphore count is not set properly for re-initialization.
+ - Fix: Change the argument type for timer_callout().
+ - Fix: Fix page fault if an alarm exception is invoked after task termination.
+ - Fix: thread_suspend() returns a success code for error case.
+ - Fix: Fix to return an appropriate error code in thread_load().
+ - Fix: Remove the register data from the argument of an exception handler.
+ - Fix: Change the data types of ioctl() parameters.
+ - Fix: Fix a page fault by waitpid().
+ - Fix: Add wait after enabling gate A20 for some real hardwares.
+ - Fix: Fix vnode lookup routine to prevent a deadlock in a fs server.
+ - Fix: Fix a process server to handle exit() properly.
+ - Fix: Fix the system hang on the actual GBA flash cart.
+
+
+Version 0.7.0:
+
+ - New: Add process server which manages process state and pid.
+ - New: Add exec server which executes an ELF program.
+ - New: Add boot server.
+ - New: Initial release of TTY driver. Minimum set of termios is also added.
+ - New: 'cmdbox' - tiny versions of many UNIX utilities.
+ - New: Add init process.
+ - New: Add stdio to libc, which is optimized for low-footprint systems.
+ - New: Add UNIX emulation for fork(), exec(), pid, file I/O, signal, etc.
+ - New: Support realloc().
+ - New: Change gcc optimization option to -Os from -O2.
+ - New: Enable gcc '-ansi' and '-pedantic' options for portability.
+ - Fix: Fix the scheduler to switch a thread properly for priority change.
+ - Fix: Fix the kernel hang when a thread terminates while it holds a mutex.
+ - Fix: Boot failure when a boot task does not have any data or bss sections.
+ - Fix: The reference count is not incremented after dup().
+ - Fix: Fix to support processing an exception by drivers at interrupt level.
+ - Fix: Fix a file lookup routine in devfs.
+ - Fix: The scheduler is kept locked with some exception conditions.
+ - Fix: kmem_alloc() cause a hang when kernel memory allocation is failed.
+ - Fix: Change the scheduling policy of a timer thread to SCHED_FIFO.
+ - Fix: Page fault during mkdir() when "foo/bar" style path is specified.
+ - Fix: Fix a bug in recursive mutex lock.
+ - Fix: A mutex for buffer cache is not initialized.
+ - Fix: Fix a page fault while writing ramfs.
+ - Fix: Fix a build error with old version (2.95) of gcc.
+ - Fix: Design change of timer_hook().
+ - Fix: Reduce interrupt latency when interrupt occurs in thread switching.
+ - Fix: Rescheduling flag is kept pending in some rare cases.
+ - Fix: Remove a kernel function trace feature that depends on gcc.
+ - Fix: Add checking CAP_NICE for the priority boost.
+ - Fix: Fix a page fault after task termination by an exception.
+ - Fix: Mutex is locked even if cond_wait() fails due to exception.
+ - Fix: Fix memory leak when a periodic thread is terminated.
+
+
+Version 0.5.0:
+
+ - New: Add file system server including VFS framework.
+ - New: Support buffer cache and mount function.
+ - New: Add 'devfs' - device file system.
+ - New: Add 'ramfs' - RAM file system.
+ - New: Add 'arfs' - archive file system.
+ - New: Add file system test tool.
+ - New: Add 'configure' script for build.
+ - New: Support BSD style makefile for POSIX applications.
+ - Fix: Fix crash in irq_detach().
+ - Fix: Fix makefile to optimize build speed with cygwin.
+
+
+Version 0.4.3:
+
+ - New: Support DPC - deferred procedure call.
+ - New: Add 'dmesg' function to dump kernel messages.
+ - New: Reduce the timer jitters of periodic thread.
+ - New: Change the name of sys_stat() to sys_info().
+ - New: Add handling of reference count for the device objects.
+ - New: Add 'force' option to device_broadcast().
+ - New: Make the kernel information as same with POSIX utsname.
+ - New: Remove the quantum adjustment feature.
+ - New: Add IPC test tool for multi-threaded servers.
+ - New: Add timer hooking service to reduce the driver's callout.
+ - New: Improve DVS algorithm of CPUfreq driver.
+ - Fix: System hang when periodic timer is stopped for an invalid timer object.
+ - Fix: Replace a delay driver as generic driver service.
+ - Fix: Fix a system call trap code (ARM).
+ - Fix: Fix a compile error when it built with SSP enabled gcc.
+ - Fix: Fix data corruption in malloc() library.
+ - Fix: A thread could not hold semaphore in some case.
+
+
+Version 0.4.2:
+
+ - New: Support RAM disk driver.
+ - New: Change an argument type of device_read()/device_write().
+ - New: Add kernel release name in the kernel statistics data.
+ - New: Update vm_inherit option of task_create().
+ - New: Change the data type of the message length of IPC related API.
+ - New: The vm_attrib() API is renamed to vm_attribute().
+ - New: Add kernel debugging API.
+ - New: Code size reduction for GBA port.
+ - New: Support recursive locking of mutex.
+ - New: Code clean up and system tuning.
+ - Fix: Fix page fault during kernel memory dump.
+ - Fix: Fix a bug in removing free node for VM region (NOMMU).
+ - Fix: System hang by accessing ARM bank register after STM^ instruction.
+ - Fix: Fix an alignment bug in the page reserve routine.
+ - Fix: Fix memory leak when vm_map() is called two or more times (NOMMU).
+ - Fix: The end address of the page extraction is not correct (i386).
+ - Fix: Interrupt is kept disabled when DMA buffer allocation is failed (i386).
+
+
+Version 0.4.1:
+
+ - New: Add ELF task relocation with NOMMU system.
+ - New: Replace all strncpy() by strlcpy() in kernel for security reason.
+ - Fix: There are some mutex hang conditions that cause system hang.
+ - Fix: Fix a deadlock problem of FDD driver.
+ - Fix: Rewrite the periodic timer routine in kernel.
+ - Fix: The highest priority thread is not selected in sched_wakeone().
+ - Fix: Drop vm_inherit option for task_create() on NOMMU system.
+
+
+Version 0.4.0:
+
+ - New: Add sys_capget()/sys_capset() kernel API for the task capability.
+ - New: Define the standard message header for IPC.
+ - New: Add vm_inherit argument in task_create() to improve exec() emulation.
+ - New: Add /sample directory and sample applications.
+ - New: Remove /img directory.
+ - Fix: Fix the memory leak caused when task_create() is failed.
+ - Fix: Incorrect I/O read size of FDD driver.
+ - Fix: Fix the console driver to lock a scheduler during I/O operations.
+
+
+Version 0.3.1:
+
+ - New: Add null/zero device driver.
+ - New: Support MUTEX_INITIALIZER for the static initialization of mutexes.
+ - New: Merge all configuration files into one single 'config.h'.
+ - New: libc and headers are updated with BSD derived code.
+ - New: Add 'make lint' as make option.
+ - Fix: object_lookup() does not return correct object ID.
+
+
+Version 0.3.0:
+
+ - New: Integrate configuration files and makefiles.
+ - New: Change the name of sync APIs for POSIX compatibility.
+ - New: Support re-initialize of the semaphore.
+ - New: Change the driver ioctl code to BSD style.
+ - New: Add test programs for mutex, semaphore and deadlock detection.
+ - New: Add malloc() in the user mode library.
+ - Fix: Fix the incorrect kernel handling of umem_strnlen().
+ - Fix: Modify the thread test program for long-run test.
+ - Fix: sem_post() can not unblock the waiting thread.
+ - Fix: vm_allocate() does not zero-fill the allocated memory.
+ - Fix: Fix compile error with gcc4.
+
+
+Version 0.2.2:
+
+ - New: Add the kernel function tracer which can dump the run-time call tree.
+ - New: Add a benchmark tool to create/terminate 100000 threads at once.
+ - New: Add code to detect above 64M of RAM. (i386)
+ - Fix: Kernel page fault in accessing the highest physical page. (i386)
+ - Fix: sys_reboot() is replaced by ioctl of the power management driver.
+ - Fix: There is a time window that lost an IST trigger from ISR.
+ - Fix: Change not to restart the system by sys_panic().
+ - Fix: Clean up comments in kernel sources.
+
+
+Version 0.2.1:
+
+ - New: Add ARM processor support. (ATM7TDMI)
+ - New: Add BSP for Game Boy Advance including on-screen keyboard.
+ - Fix: The irq lock count is not 0 after switching to the new thread.
+ - Fix: Improve the kernel callout timer for the small timeout value.
+ - Fix: Remove the error check of max scheduling quantum in sched_setparam().
+
+
+Version 0.2.0:
+
+ - New: Add new VM code for No-MMU platform.
+ - New: Change the structure of the driver I/O table.
+ - New: Add minimum libc.
+ - Fix: Fix panic() if the active condition variable is destroyed.
+ - Fix: Semaphore causes an unconditional wakeup of the blocked threads.
+ - Fix: Update structure of the source tree.
+
+
+Version 0.1.2:
+
+ - New: Add Pentium-M support for i386 processor driver.
+ - New: Add CPU voltage monitoring tool 'cpuvolt'.
+ - New: Add DVS test program which changes the CPU load periodically.
+ - Fix: Improve the build method for cross platform portability.
+
+
+Version 0.1.1:
+
+ - New: Add an initial version of kernel monitor 'kmon'.
+ - New: Add some user mode test programs to check kernel functions.
+ - New: Move time_get()/time_set() functions to the driver layer.
+ - New: Add sys_time() kernel interface to return system ticks.
+ - New: Improve the device I/O dispatcher to verify user buffer automatically.
+ - Fix: Timer overflow issue after 49.7 days of continuous operation.
+ - Fix: Unexpected page fault in the exception handler.
+ - Fix: Page fault after returning from main() routine.
+
+
+Version 0.1:
+
+ - Initial public release.
diff --git a/prex-0.9.0/doc/LICENSE b/prex-0.9.0/doc/LICENSE
new file mode 100755
index 0000000..3f3f721
--- /dev/null
+++ b/prex-0.9.0/doc/LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2005-2009, Kohsuke Ohtani
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of any co-contibutors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/prex-0.9.0/doc/README b/prex-0.9.0/doc/README
new file mode 100755
index 0000000..cc15578
--- /dev/null
+++ b/prex-0.9.0/doc/README
@@ -0,0 +1,133 @@
+
+                       Prex Operating System
+
+
+What is Prex?
+=============
+
+The Prex project is an open source initiative to provide a portable
+real-time operating system for embedded systems. Prex is designed
+specifically for small footprint platforms. It is written in C language
+from scratch based on a traditional micro kernel architecture.
+
+The Prex kernel provides only fundamental features for task, thread, memory,
+ipc, exception, and synchronization. The other basic OS functions such
+like process, file system, application loading, and networking are provided
+by user mode servers on top of the Prex kernel. This design allows systems
+to execute both of native real-time task and generic UNIX process
+simultaneously, without degrading the real-time performance. Futhermore, it
+helps the platform designer to construct OS by choosing appropriate server
+tasks for their target requirements.
+
+
+Licensing
+=========
+
+Prex is royalty-free software released under BSD License.
+
+
+Current Port
+============
+
+Available port (arch-platform):
+
+  - x86-pc
+  - arm-gba
+  - arm-integrator
+  - ppc-prep
+
+
+How to Build?
+=============
+
+Step 1: Prepare Toolchain
+
+  The following packages are required for compiling Prex.
+  - GCC 2.95.3 or later
+  - GNU Binutils 2.15 or later
+  - GNU Make 3.81 or later
+
+  The toolchain should be built appropriately for your target
+  architecture to cross-compile Prex.
+
+Step 2: Prepare Sources
+
+  Unpack the sources and move to the top level directory of the source tree.
+
+  $ cd /usr/src
+  $ tar zxvf prex-X.X.X.tar.gz
+  $ cd prex-X.X.X
+
+Step 3: Configure
+
+  Setup target architecture and platform.
+  The following sample shows for x86-pc target.
+
+  $ ./configure --target=x86-pc
+
+  If you cross compile Prex from a different architecture and/or OS,
+  you have to set --cross-compile option. Please check other options
+  with --help option for 'configure'.
+
+Step 4: Build
+
+  Run make (and pray :)
+
+  $ make
+
+
+Note) If you want to run 'make' at the subdirectory, you have to set the
+      SRCDIR as follow.
+
+  $ export SRCDIR=/usr/src/prex-X.X.X
+
+
+Directory Structure
+===================
+
+Prex source code is divided into the following directories:
+
+ /conf			System configuration files
+
+ /mk			Common Makefiles
+
+ /include		Common include files
+
+ /sys			Prex microkernel
+	/include	Kernel headers
+	/lib		Common kernel library
+	/ipc		Inter process communication support
+	/kern		Kernel main code
+	/mem		Memory management code
+	/sync		Synchronize related code
+
+ /bsp			Board support package
+	/boot		Boot loader
+	/drv		Device driver module
+	/hal		Hardware abstraction layer
+
+ /usr			User mode programs
+	/arch		Architecture dependent code
+	/bin		User command binaries
+	/include	Header files
+	/lib		User libraries
+	/server		System servers
+	/sbin		System utilities
+	/test		Function test programs
+	/sample		Sample programs
+
+
+Project Website
+===============
+
+More information about Prex can be found at:
+
+  http://prex.sourceforge.net
+
+
+Author
+======
+
+  Kohsuke Ohtani <kohtani@users.sourceforge.net>
+
+  Have fun! ;)
diff --git a/prex-0.9.0/include/arm/asm.h b/prex-0.9.0/include/arm/asm.h
new file mode 100755
index 0000000..847a45c
--- /dev/null
+++ b/prex-0.9.0/include/arm/asm.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)asm.h	5.5 (Berkeley) 5/7/91
+ */
+
+#ifndef _ARM_ASM_H
+#define _ARM_ASM_H
+
+#define _ALIGN_TEXT .align 0
+#define _ASM_TYPE_FUNCTION	#function
+#define _ENTRY(x) \
+	.text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
+
+#define _C_LABEL(x)	x
+#define	_ASM_LABEL(x)	x
+
+#define	ENTRY(y)	_ENTRY(_C_LABEL(y));
+#define	NENTRY(y)	_ENTRY(_C_LABEL(y))
+#define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y));
+
+#if defined(PIC)
+#define	PIC_SYM(x,y)	x ## ( ## y ## )
+#else
+#define	PIC_SYM(x,y)	x
+#endif
+
+#endif /* !_ARM_ASM_H */
diff --git a/prex-0.9.0/include/arm/elf.h b/prex-0.9.0/include/arm/elf.h
new file mode 100755
index 0000000..1d46a67
--- /dev/null
+++ b/prex-0.9.0/include/arm/elf.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_ELF_H
+#define _ARM_ELF_H
+
+/*
+ * Relocation type
+ */
+#define	R_ARM_NONE	0
+#define	R_ARM_PC24	1
+#define	R_ARM_ABS32	2
+#define	R_ARM_PLT32	27
+#define	R_ARM_CALL	28
+#define R_ARM_JUMP24	29
+
+#endif /* !_ARM_ELF_H */
diff --git a/prex-0.9.0/include/arm/endian.h b/prex-0.9.0/include/arm/endian.h
new file mode 100755
index 0000000..19c32ee
--- /dev/null
+++ b/prex-0.9.0/include/arm/endian.h
@@ -0,0 +1,2 @@
+
+#define _BYTE_ORDER LITTLE_ENDIAN
diff --git a/prex-0.9.0/include/arm/limits.h b/prex-0.9.0/include/arm/limits.h
new file mode 100755
index 0000000..8ac1fcd
--- /dev/null
+++ b/prex-0.9.0/include/arm/limits.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)limits.h	8.4 (Berkeley) 4/28/95
+ */
+
+#ifndef	_ARM_LIMITS_H
+#define	_ARM_LIMITS_H
+
+#define	CHAR_BIT	8		/* number of bits in a char */
+#define	MB_LEN_MAX	32		/* no multibyte characters */
+
+/*
+ * According to ANSI (section 2.2.4.2), the values below must be usable by
+ * #if preprocessing directives.  Additionally, the expression must have the
+ * same type as would an expression that is an object of the corresponding
+ * type converted according to the integral promotions.  The subtraction for
+ * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
+ * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
+ * These numbers work for pcc as well.  The UINT_MAX and ULONG_MAX values
+ * are written as hex so that GCC will be quiet about large integer constants.
+ */
+#define	SCHAR_MAX	127		/* min value for a signed char */
+#define	SCHAR_MIN	(-128)		/* max value for a signed char */
+
+#define	UCHAR_MAX	255		/* max value for an unsigned char */
+#define	CHAR_MAX	127		/* max value for a char */
+#define	CHAR_MIN	(-128)		/* min value for a char */
+
+#define	USHRT_MAX	65535		/* max value for an unsigned short */
+#define	SHRT_MAX	32767		/* max value for a short */
+#define	SHRT_MIN	(-32768)	/* min value for a short */
+
+#define	UINT_MAX	0xffffffffU	/* max value for an unsigned int */
+#define	INT_MAX		2147483647	/* max value for an int */
+#define	INT_MIN		(-2147483647-1)	/* min value for an int */
+
+#define	ULONG_MAX	0xffffffffUL	/* max value for an unsigned long */
+#define	LONG_MAX	2147483647L	/* max value for a long */
+					/* min value for a long */
+#define	LONG_MIN	(-2147483647L-1L)
+
+#define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
+#define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
+
+#endif	/* _ARM_LIMITS_H */
diff --git a/prex-0.9.0/include/arm/memory.h b/prex-0.9.0/include/arm/memory.h
new file mode 100755
index 0000000..72d980c
--- /dev/null
+++ b/prex-0.9.0/include/arm/memory.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef	_ARM_MEMORY_H
+#define	_ARM_MEMORY_H
+
+#include <conf/config.h>
+
+#ifdef CONFIG_MMU
+#define KERNBASE	0x80000000	/* offset of kernel address space */
+#define PAGE_SIZE	4096		/* bytes per page */
+#define USERLIMIT	0x80000000	/* upper limit on user address space */
+#else
+#define KERNBASE	0		/* offset of kernel address space */
+#define PAGE_SIZE	1024		/* bytes per page */
+#define USERLIMIT	0xffffffff	/* upper limit on user address space */
+#endif
+
+
+#endif	/* _ARM_MEMORY_H */
diff --git a/prex-0.9.0/include/arm/setjmp.h b/prex-0.9.0/include/arm/setjmp.h
new file mode 100755
index 0000000..0a2f9aa
--- /dev/null
+++ b/prex-0.9.0/include/arm/setjmp.h
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)setjmp.h	8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _ARM_SETJMP_H
+#define _ARM_SETJMP_H
+
+#define _JBLEN	(29-13)
+#define _JB_MAGIC__SETJMP	0x4278f500
+#define _JB_MAGIC_SETJMP	0x4278f501
+
+#endif /* !_ARM_SETJMP_H */
diff --git a/prex-0.9.0/include/arm/signal.h b/prex-0.9.0/include/arm/signal.h
new file mode 100755
index 0000000..690c44a
--- /dev/null
+++ b/prex-0.9.0/include/arm/signal.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+typedef int sig_atomic_t;
+
+struct sigcontext {
+	int	sc_onstack;		/* sigstack state to restore */
+	int	sc_mask;		/* signal mask to restore */
+
+	int	sc_r0;
+	int	sc_r1;
+	int	sc_r2;
+	int	sc_r3;
+	int	sc_r4;
+	int	sc_r5;
+	int	sc_r6;
+	int	sc_r7;
+	int	sc_r8;
+	int	sc_r9;
+	int	sc_r10;
+	int	sc_r11;
+	int	sc_r12;
+	int	sc_usr_sp;
+	int	sc_usr_lr;
+	int	sc_svc_sp;
+	int	sc_svc_lr;
+	int	sc_pc;
+	int	sc_cpsr;
+};
diff --git a/prex-0.9.0/include/arm/stdarg.h b/prex-0.9.0/include/arm/stdarg.h
new file mode 100755
index 0000000..0561ceb
--- /dev/null
+++ b/prex-0.9.0/include/arm/stdarg.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	from: @(#)stdarg.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _ARM_STDARG_H
+#define	_ARM_STDARG_H
+
+#include <sys/cdefs.h>
+
+#ifdef __lint__
+typedef void *			va_list;
+#define	va_start(a, l)		(0)
+#define	va_arg(a, t)		(0)
+#define	va_end			/* nothing */
+#define	va_copy(d, s)		((d) = (s))
+
+#elif __GNUC_PREREQ__(2, 96)
+#define va_list			__builtin_va_list
+#define	va_start(ap, last)	__builtin_va_start((ap), (last))
+#define	va_arg			__builtin_va_arg
+#define	va_end			__builtin_va_end
+#define	va_copy(dest, src)	__builtin_va_copy((dest), (src))
+#else
+
+typedef char *			va_list;
+
+#define	__va_size(type) \
+	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+
+#define	va_start(ap, last) \
+	((ap) = (va_list)&(last) + __va_size(last))
+
+#define	va_arg(ap, type) \
+	(*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))
+
+#define	va_end(ap)
+
+#define	va_copy(dest, src)	((dest) = (src))
+#endif
+
+#endif /* !_ARM_STDARG_H */
diff --git a/prex-0.9.0/include/arm/syspage.h b/prex-0.9.0/include/arm/syspage.h
new file mode 100755
index 0000000..56e0b28
--- /dev/null
+++ b/prex-0.9.0/include/arm/syspage.h
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_SYSPAGE_H
+#define _ARM_SYSPAGE_H
+
+#include <conf/config.h>
+
+/**
+ * syspage layout:
+ *
+ * +------------------+ CONFIG_SYSPAGE_BASE
+ * | Vector page      |
+ * |                  |
+ * +------------------+ +0x1000
+ * | Interrupt stack  |
+ * |                  |
+ * +------------------+ +0x2000
+ * | Sys mode stack   |
+ * |                  |
+ * +------------------+ +0x3000
+ * | Boot information |
+ * +------------------+ +0x3400
+ * | Abort mode stack |
+ * +------------------+ +0x3800
+ * | Boot stack       |
+ * +------------------+ +0x4000
+ * | PGD for boot     |
+ * | (MMU only)       |
+ * |                  |
+ * +------------------+ +0x8000
+ * | PTE0 for boot    |
+ * | (MMU only)       |
+ * +------------------+ +0x9000
+ * | PTE1 for UART I/O|
+ * | (MMU only)       |
+ * +------------------+ +0xA000
+
+ *
+ * Note1: Kernel PGD must be stored at 16k aligned address.
+ *
+ * Note2: PTE0 must be stored at 4k aligned address.
+ *
+ * Note2: Interrupt stack should be placed after NULL page
+ * to detect the stack overflow.
+ */
+
+#define SYSPAGE		CONFIG_SYSPAGE_BASE
+#define INTSTK		(SYSPAGE + 0x1000)
+#define SYSSTK		(SYSPAGE + 0x2000)
+#define BOOTINFO	(SYSPAGE + 0x3000)
+#define ABTSTK		(SYSPAGE + 0x3400)
+#define BOOTSTK		(SYSPAGE + 0x3800)
+#define BOOT_PGD	(SYSPAGE + 0x4000)
+#define BOOT_PTE0	(SYSPAGE + 0x8000)
+#define BOOT_PTE1	(SYSPAGE + 0x9000)
+
+#define BOOT_PGD_PHYS	0x4000
+#define BOOT_PTE0_PHYS	0x8000
+#define BOOT_PTE1_PHYS	0x9000
+
+#define INTSTKSZ	0x1000
+#define SYSSTKSZ	0x1000
+#define ABTSTKSZ	0x400
+#define BOOTSTKSZ	0x800
+
+#define INTSTKTOP	(INTSTK + INTSTKSZ)
+#define SYSSTKTOP	(SYSSTK + SYSSTKSZ)
+#define ABTSTKTOP	(ABTSTK + ABTSTKSZ)
+#define BOOTSTKTOP	(BOOTSTK + BOOTSTKSZ)
+
+#ifdef CONFIG_MMU
+#define SYSPAGESZ	0xA000
+#else
+#define SYSPAGESZ	0x4000
+#endif
+
+#endif /* !_ARM_SYSPAGE_H */
diff --git a/prex-0.9.0/include/arm/systrap.h b/prex-0.9.0/include/arm/systrap.h
new file mode 100755
index 0000000..6c4bd40
--- /dev/null
+++ b/prex-0.9.0/include/arm/systrap.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_SYSTRAP_H
+#define _ARM_SYSTRAP_H
+
+#if defined(__gba__)
+
+/*
+ * Note:
+ * GBA BIOS does not allow to an install SWI handler by user. So, the system
+ * calls will jump to the system call entry point (0x200007c) in the kernel
+ * code. Then, the kernel SWI handler will switch the CPU mode to SVC mode.
+ * However, CPU mode can be changed only in privileged CPU mode. By this
+ * reason, all applications run in SYS mode with GBA.
+ *
+ */
+
+#define SYSCALL0(name) \
+	.global name; .align; \
+name##: \
+	stmfd sp!, {r4, r5, lr}; \
+	mov r4, #SYS_##name; \
+	ldr r5, =0x200007c; \
+	add lr, pc, #2; \
+	mov pc, r5; \
+	ldmfd sp!, {r4, r5, pc};
+
+#else
+
+#define SYSCALL0(name) \
+	.global name; .align; \
+name##: swi #SYS_##name; \
+	mov pc, lr
+
+#endif
+
+
+#define SYSCALL1(name) SYSCALL0(name)
+#define SYSCALL2(name) SYSCALL0(name)
+#define SYSCALL3(name) SYSCALL0(name)
+#define SYSCALL4(name) SYSCALL0(name)
+
+#endif /* _ARM_SYSTRAP_H */
diff --git a/prex-0.9.0/include/arm/types.h b/prex-0.9.0/include/arm/types.h
new file mode 100755
index 0000000..9289a2c
--- /dev/null
+++ b/prex-0.9.0/include/arm/types.h
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)types.h	8.3 (Berkeley) 1/5/94
+ */
+
+#ifndef	_ARM_TYPES_H
+#define	_ARM_TYPES_H
+
+#include <sys/cdefs.h>
+
+/*
+ * Basic integral types.  Omit the typedef if
+ * not possible for a machine/compiler combination.
+ */
+typedef	signed char	   int8_t;
+typedef	unsigned char	  uint8_t;
+typedef	short		  int16_t;
+typedef	unsigned short	 uint16_t;
+typedef	int		  int32_t;
+typedef	unsigned int	 uint32_t;
+
+typedef unsigned long	  paddr_t;
+typedef unsigned long	  psize_t;
+typedef unsigned long	  vaddr_t;
+typedef unsigned long	  vsize_t;
+
+typedef int		register_t;
+
+#endif	/* _ARM_TYPES_H */
diff --git a/prex-0.9.0/include/ipc/exec.h b/prex-0.9.0/include/ipc/exec.h
new file mode 100755
index 0000000..3dc2ed6
--- /dev/null
+++ b/prex-0.9.0/include/ipc/exec.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _IPC_EXEC_H
+#define _IPC_EXEC_H
+
+#include <sys/types.h>
+#include <ipc/ipc.h>
+#include <limits.h>
+
+/*
+ * Messages for exec object
+ */
+#define EXEC_EXECVE	0x00000300	/* execve() */
+#define EXEC_BINDCAP	0x00000301	/* bind capability */
+
+/*
+ * Exec message
+ */
+struct exec_msg {
+	struct msg_header hdr;		/* message header */
+	char	path[PATH_MAX];		/* program path */
+	char	cwd[PATH_MAX];		/* current directory */
+	int	argc;			/* number of argment string */
+	int	envc;			/* number of environment string */
+	size_t	bufsz;			/* size of buffer */
+	char	buf[ARG_MAX];		/* string for arg/env */
+};
+
+/*
+ * Capability bind message
+ */
+struct bind_msg {
+	struct msg_header hdr;		/* message header */
+	char	path[PATH_MAX];		/* program path */
+};
+
+
+/* Max size of exec message */
+#define MAX_EXECMSG	sizeof(struct exec_msg)
+
+#endif /* !_IPC_EXEC_H */
diff --git a/prex-0.9.0/include/ipc/fs.h b/prex-0.9.0/include/ipc/fs.h
new file mode 100755
index 0000000..7cacde9
--- /dev/null
+++ b/prex-0.9.0/include/ipc/fs.h
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _IPC_FS_H
+#define _IPC_FS_H
+
+#include <sys/types.h>
+#include <sys/dirent.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+#include <ipc/ipc.h>
+
+#include <limits.h>
+
+/*
+ * Messages for file system object
+ */
+#define FS_MOUNT	0x00000200
+#define FS_UMOUNT	0x00000201
+#define FS_SYNC		0x00000202
+#define FS_OPEN		0x00000203
+#define FS_CLOSE	0x00000204
+#define FS_MKNOD	0x00000205
+#define FS_LSEEK	0x00000206
+#define FS_READ		0x00000207
+#define FS_WRITE	0x00000208
+#define FS_IOCTL	0x00000209
+#define FS_FSYNC	0x0000020A
+#define FS_FSTAT	0x0000020B
+#define FS_OPENDIR	0x0000020C
+#define FS_CLOSEDIR	0x0000020D
+#define FS_READDIR	0x0000020E
+#define FS_REWINDDIR	0x0000020F
+#define FS_SEEKDIR	0x00000210
+#define FS_TELLDIR	0x00000211
+#define FS_MKDIR	0x00000212
+#define FS_RMDIR	0x00000213
+#define FS_RENAME	0x00000214
+#define FS_CHDIR	0x00000215
+#define FS_LINK		0x00000216
+#define FS_UNLINK	0x00000217
+#define FS_STAT		0x00000218
+#define FS_GETCWD	0x00000219
+#define FS_DUP		0x0000021A
+#define FS_DUP2		0x0000021B
+#define FS_FCNTL	0x0000021C
+#define FS_ACCESS	0x0000021D
+#define FS_FORK		0x0000021E
+#define FS_EXEC		0x0000021F
+#define FS_EXIT		0x00000220
+#define FS_REGISTER	0x00000221
+#define FS_PIPE		0x00000222
+#define FS_ISATTY	0x00000223
+#define FS_TRUNCATE	0x00000224
+#define FS_FTRUNCATE	0x00000225
+#define FS_FCHDIR	0x00000226
+
+/*
+ * Mount message
+ */
+struct mount_msg {
+	struct msg_header hdr;		/* message header */
+	char	dev[PATH_MAX];		/* mount device */
+	char	dir[PATH_MAX];		/* mount directory */
+	char	fs[16];			/* file system name */
+	int	flags;			/* mount flags */
+	char	data[64];		/* file system specific data */
+};
+
+/*
+ * File open message
+ */
+struct open_msg {
+	struct msg_header hdr;		/* message header */
+	int	flags;			/* open flag */
+	mode_t	mode;			/* open mode */
+	char	path[PATH_MAX];		/* open file */
+	int	fd;			/* file descriptor */
+};
+
+/*
+ * I/O request message
+ */
+struct io_msg {
+	struct msg_header hdr;		/* message header */
+	int	fd;			/* file descriptor */
+	char	*buf;			/* i/o buffer */
+	size_t	size;			/* read/write size */
+};
+
+/*
+ * File stat message
+ */
+struct stat_msg {
+	struct msg_header hdr;		/* message header */
+	int	fd;			/* file descriptor */
+	char	path[PATH_MAX];		/* open file */
+	struct stat st;
+};
+
+/*
+ * Path management message
+ */
+struct path_msg {
+	struct msg_header hdr;		/* message header */
+	int	fd;			/* file descriptor */
+	char	path[PATH_MAX];
+	char	path2[PATH_MAX];
+	int	data[4];
+};
+
+/*
+ * Directory management message
+ */
+struct dir_msg {
+	struct msg_header hdr;		/* message header */
+	int	fd;			/* file descriptor */
+	struct dirent dirent;		/* directory entry */
+};
+
+/*
+ * IO cotrol message
+ */
+struct ioctl_msg {
+	struct msg_header hdr;		/* message header */
+	int	fd;			/* file descriptor */
+	u_long	request;		/* io control command */
+	char	buf[IOCPARM_MAX];	/* parameter buffer */
+};
+
+/*
+ * File control message
+ */
+struct fcntl_msg {
+	struct msg_header hdr;		/* message header */
+	int	fd;			/* file descriptor */
+	int	cmd;			/* command */
+	int	arg;			/* argument */
+	struct flock lock;		/* file lock data */
+};
+
+
+/* Max size of fs message */
+#define MAX_FSMSG	sizeof(struct mount_msg)
+
+#endif /* !_IPC_FS_H */
diff --git a/prex-0.9.0/include/ipc/ipc.h b/prex-0.9.0/include/ipc/ipc.h
new file mode 100755
index 0000000..4c1f7a8
--- /dev/null
+++ b/prex-0.9.0/include/ipc/ipc.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
+
+#include <sys/types.h>
+
+/*
+ * Message header
+ *
+ * The ID of send task is automatically filled by the kernel
+ * in msg_send() call. So there are no need to set it by the
+ * sender task. The receiver task can always trust the task ID
+ * in all messages.
+ */
+struct msg_header {
+	task_t	task;		/* id of send task */
+	int	code;		/* message code */
+	int	status;		/* return status */
+};
+
+/*
+ * Standard messages
+ */
+#define STD_NULL	0x00000000
+#define STD_VERSION	0x00000001
+#define STD_DEBUG	0x00000002
+#define STD_BOOT	0x00000003
+#define STD_SHUTDOWN	0x00000004
+
+/*
+ * Generic message
+ */
+struct msg {
+	struct msg_header hdr;		/* message header */
+	int	data[4];		/* integer data */
+};
+
+#endif /* !_SYS_IPC_H */
diff --git a/prex-0.9.0/include/ipc/pow.h b/prex-0.9.0/include/ipc/pow.h
new file mode 100755
index 0000000..ff41bb6
--- /dev/null
+++ b/prex-0.9.0/include/ipc/pow.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _IPC_POW_H
+#define _IPC_POW_H
+
+/*
+ * Messages for power object
+ */
+#define	POW_SET_POWER		0x00000400	/* set power state */
+#define	POW_GET_POLICY		0x00000401	/* get current power policy */
+#define	POW_SET_POLICY		0x00000402	/* set power policy */
+#define	POW_GET_SUSTMR		0x00000403	/* get suspend timeout */
+#define	POW_SET_SUSTMR		0x00000404	/* set suspend timeout */
+#define	POW_GET_DIMTMR		0x00000405	/* get dim (lcd off) timeout */
+#define	POW_SET_DIMTMR		0x00000406	/* set dim timeout */
+#define	POW_BATTERY_LVL		0x00000407	/* get current battery level */
+
+#endif /* !_IPC_POW_H */
diff --git a/prex-0.9.0/include/ipc/proc.h b/prex-0.9.0/include/ipc/proc.h
new file mode 100755
index 0000000..e532e65
--- /dev/null
+++ b/prex-0.9.0/include/ipc/proc.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _IPC_PROC_H
+#define _IPC_PROC_H
+
+/*
+ * Messages for process object
+ */
+#define	PS_GETPID	0x00000100
+#define	PS_GETPPID	0x00000101
+#define	PS_GETPGID	0x00000102
+#define	PS_SETPGID	0x00000103
+#define	PS_SETSID	0x00000104
+#define	PS_GETSID	0x00000105
+#define	PS_FORK		0x00000106
+#define	PS_EXIT		0x00000107
+#define	PS_STOP		0x00000108
+#define	PS_WAITPID	0x00000109
+#define	PS_KILL		0x0000010A
+#define	PS_EXEC		0x0000010B
+#define	PS_PSTAT	0x0000010C
+#define	PS_SETINIT	0x0000010D
+#define	PS_REGISTER	0x0000010E
+#define	PS_TRACE	0x0000010F
+
+#endif /* !_IPC_PROC_H */
diff --git a/prex-0.9.0/include/machine/asm.h b/prex-0.9.0/include/machine/asm.h
new file mode 100755
index 0000000..a52ddfb
--- /dev/null
+++ b/prex-0.9.0/include/machine/asm.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/asm.h"
+#elif defined (__x86__)
+#include "x86/asm.h"
+#elif defined (__ppc__)
+#include "ppc/asm.h"
+#elif defined (__mips__)
+#include "mips/asm.h"
+#elif defined (__sh__)
+#include "sh/asm.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/elf.h b/prex-0.9.0/include/machine/elf.h
new file mode 100755
index 0000000..71a0717
--- /dev/null
+++ b/prex-0.9.0/include/machine/elf.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/elf.h"
+#elif defined (__x86__)
+#include "x86/elf.h"
+#elif defined (__ppc__)
+#include "ppc/elf.h"
+#elif defined (__mips__)
+#include "mips/elf.h"
+#elif defined (__sh__)
+#include "sh/elf.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/endian.h b/prex-0.9.0/include/machine/endian.h
new file mode 100755
index 0000000..9d45b03
--- /dev/null
+++ b/prex-0.9.0/include/machine/endian.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/endian.h"
+#elif defined (__x86__)
+#include "x86/endian.h"
+#elif defined (__ppc__)
+#include "ppc/endian.h"
+#elif defined (__mips__)
+#include "mips/endian.h"
+#elif defined (__sh__)
+#include "sh/endian.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/limits.h b/prex-0.9.0/include/machine/limits.h
new file mode 100755
index 0000000..1b30f75
--- /dev/null
+++ b/prex-0.9.0/include/machine/limits.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/limits.h"
+#elif defined (__x86__)
+#include "x86/limits.h"
+#elif defined (__ppc__)
+#include "ppc/limits.h"
+#elif defined (__mips__)
+#include "mips/limits.h"
+#elif defined (__sh__)
+#include "sh/limits.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/lock.h b/prex-0.9.0/include/machine/lock.h
new file mode 100755
index 0000000..1614e58
--- /dev/null
+++ b/prex-0.9.0/include/machine/lock.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/lock.h"
+#elif defined (__x86__)
+#include "x86/lock.h"
+#elif defined (__ppc__)
+#include "ppc/lock.h"
+#elif defined (__mips__)
+#include "mips/lock.h"
+#elif defined (__sh__)
+#include "sh/lock.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/memory.h b/prex-0.9.0/include/machine/memory.h
new file mode 100755
index 0000000..c006e62
--- /dev/null
+++ b/prex-0.9.0/include/machine/memory.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/memory.h"
+#elif defined (__x86__)
+#include "x86/memory.h"
+#elif defined (__ppc__)
+#include "ppc/memory.h"
+#elif defined (__mips__)
+#include "mips/memory.h"
+#elif defined (__sh__)
+#include "sh/memory.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/setjmp.h b/prex-0.9.0/include/machine/setjmp.h
new file mode 100755
index 0000000..5cc7237
--- /dev/null
+++ b/prex-0.9.0/include/machine/setjmp.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/setjmp.h"
+#elif defined (__x86__)
+#include "x86/setjmp.h"
+#elif defined (__ppc__)
+#include "ppc/setjmp.h"
+#elif defined (__mips__)
+#include "mips/setjmp.h"
+#elif defined (__sh__)
+#include "sh/setjmp.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/signal.h b/prex-0.9.0/include/machine/signal.h
new file mode 100755
index 0000000..5c21344
--- /dev/null
+++ b/prex-0.9.0/include/machine/signal.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/signal.h"
+#elif defined (__x86__)
+#include "x86/signal.h"
+#elif defined (__ppc__)
+#include "ppc/signal.h"
+#elif defined (__mips__)
+#include "mips/signal.h"
+#elif defined (__sh__)
+#include "sh/signal.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/stdarg.h b/prex-0.9.0/include/machine/stdarg.h
new file mode 100755
index 0000000..e55ca44
--- /dev/null
+++ b/prex-0.9.0/include/machine/stdarg.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/stdarg.h"
+#elif defined (__x86__)
+#include "x86/stdarg.h"
+#elif defined (__ppc__)
+#include "ppc/stdarg.h"
+#elif defined (__mips__)
+#include "mips/stdarg.h"
+#elif defined (__sh__)
+#include "sh/stdarg.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/syspage.h b/prex-0.9.0/include/machine/syspage.h
new file mode 100755
index 0000000..df8d1c5
--- /dev/null
+++ b/prex-0.9.0/include/machine/syspage.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/syspage.h"
+#elif defined (__x86__)
+#include "x86/syspage.h"
+#elif defined (__ppc__)
+#include "ppc/syspage.h"
+#elif defined (__mips__)
+#include "mips/syspage.h"
+#elif defined (__sh__)
+#include "sh/syspage.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/systrap.h b/prex-0.9.0/include/machine/systrap.h
new file mode 100755
index 0000000..e8100f4
--- /dev/null
+++ b/prex-0.9.0/include/machine/systrap.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/systrap.h"
+#elif defined (__x86__)
+#include "x86/systrap.h"
+#elif defined (__ppc__)
+#include "ppc/systrap.h"
+#elif defined (__mips__)
+#include "mips/systrap.h"
+#elif defined (__sh__)
+#include "sh/systrap.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/machine/types.h b/prex-0.9.0/include/machine/types.h
new file mode 100755
index 0000000..14e29e9
--- /dev/null
+++ b/prex-0.9.0/include/machine/types.h
@@ -0,0 +1,14 @@
+
+#if defined(__arm__)
+#include "arm/types.h"
+#elif defined (__x86__)
+#include "x86/types.h"
+#elif defined (__ppc__)
+#include "ppc/types.h"
+#elif defined (__mips__)
+#include "mips/types.h"
+#elif defined (__sh__)
+#include "sh/types.h"
+#else
+#error architecture not supported
+#endif
diff --git a/prex-0.9.0/include/ppc/asm.h b/prex-0.9.0/include/ppc/asm.h
new file mode 100755
index 0000000..97b0ed3
--- /dev/null
+++ b/prex-0.9.0/include/ppc/asm.h
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)asm.h	5.5 (Berkeley) 5/7/91
+ */
+
+#ifndef _PPC_ASM_H
+#define _PPC_ASM_H
+
+#define _ENTRY(x) \
+	.text; .align 2; .globl x; .type x,@function; x:
+
+#define _C_LABEL(x)	x
+#define	_ASM_LABEL(x)	x
+
+#define	ENTRY(y)	_ENTRY(_C_LABEL(y));
+#define	NENTRY(y)	_ENTRY(_C_LABEL(y))
+#define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y));
+
+#if defined(PIC)
+#define	PIC_SYM(x,y)	x ## ( ## y ## )
+#else
+#define	PIC_SYM(x,y)	x
+#endif
+
+#endif /* !_PPC_ASM_H */
diff --git a/prex-0.9.0/include/ppc/elf.h b/prex-0.9.0/include/ppc/elf.h
new file mode 100755
index 0000000..2e442d9
--- /dev/null
+++ b/prex-0.9.0/include/ppc/elf.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_ELF_H
+#define _PPC_ELF_H
+
+/*
+ * Relocation type
+ */
+#define	R_PPC_NONE 		0
+#define	R_PPC_ADDR32 		1
+#define	R_PPC_ADDR16_LO 	4
+#define	R_PPC_ADDR16_HI 	5
+#define	R_PPC_ADDR16_HA 	6
+#define	R_PPC_REL24 		10
+#define	R_PPC_REL32 		26
+
+#endif /* !_PPC_ELF_H */
diff --git a/prex-0.9.0/include/ppc/endian.h b/prex-0.9.0/include/ppc/endian.h
new file mode 100755
index 0000000..a498f33
--- /dev/null
+++ b/prex-0.9.0/include/ppc/endian.h
@@ -0,0 +1,2 @@
+
+#define _BYTE_ORDER BIG_ENDIAN
diff --git a/prex-0.9.0/include/ppc/limits.h b/prex-0.9.0/include/ppc/limits.h
new file mode 100755
index 0000000..1e427f4
--- /dev/null
+++ b/prex-0.9.0/include/ppc/limits.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)limits.h	8.4 (Berkeley) 4/28/95
+ */
+
+#ifndef	_PPC_LIMITS_H
+#define	_PPC_LIMITS_H
+
+#define	CHAR_BIT	8		/* number of bits in a char */
+#define	MB_LEN_MAX	32		/* no multibyte characters */
+
+/*
+ * According to ANSI (section 2.2.4.2), the values below must be usable by
+ * #if preprocessing directives.  Additionally, the expression must have the
+ * same type as would an expression that is an object of the corresponding
+ * type converted according to the integral promotions.  The subtraction for
+ * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
+ * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
+ * These numbers work for pcc as well.  The UINT_MAX and ULONG_MAX values
+ * are written as hex so that GCC will be quiet about large integer constants.
+ */
+#define	SCHAR_MAX	127		/* min value for a signed char */
+#define	SCHAR_MIN	(-128)		/* max value for a signed char */
+
+#define	UCHAR_MAX	255		/* max value for an unsigned char */
+#define	CHAR_MAX	127		/* max value for a char */
+#define	CHAR_MIN	(-128)		/* min value for a char */
+
+#define	USHRT_MAX	65535		/* max value for an unsigned short */
+#define	SHRT_MAX	32767		/* max value for a short */
+#define	SHRT_MIN	(-32768)	/* min value for a short */
+
+#define	UINT_MAX	0xffffffffU	/* max value for an unsigned int */
+#define	INT_MAX		2147483647	/* max value for an int */
+#define	INT_MIN		(-2147483647-1)	/* min value for an int */
+
+#define	ULONG_MAX	0xffffffffUL	/* max value for an unsigned long */
+#define	LONG_MAX	2147483647L	/* max value for a long */
+					/* min value for a long */
+#define	LONG_MIN	(-2147483647L-1L)
+
+#define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
+#define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
+
+#endif	/* _PPC_LIMITS_H */
diff --git a/prex-0.9.0/include/ppc/memory.h b/prex-0.9.0/include/ppc/memory.h
new file mode 100755
index 0000000..be58448
--- /dev/null
+++ b/prex-0.9.0/include/ppc/memory.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef	_PPC_MEMORY_H
+#define	_PPC_MEMORY_H
+
+#include <conf/config.h>
+
+#ifdef CONFIG_MMU
+#define KERNBASE	0x80000000	/* offset of kernel address space */
+#define PAGE_SIZE	4096		/* bytes per page */
+#define USERLIMIT	0x80000000	/* upper limit on user address space */
+#else
+#define KERNBASE	0		/* offset of kernel address space */
+#define PAGE_SIZE	1024		/* bytes per page */
+#define USERLIMIT	0xffffffff	/* upper limit on user address space */
+#endif
+
+
+#endif	/* _PPC_MEMORY_H */
diff --git a/prex-0.9.0/include/ppc/setjmp.h b/prex-0.9.0/include/ppc/setjmp.h
new file mode 100755
index 0000000..8d643fe
--- /dev/null
+++ b/prex-0.9.0/include/ppc/setjmp.h
@@ -0,0 +1,8 @@
+/*	$NetBSD: setjmp.h,v 1.3 1998/09/16 23:51:27 thorpej Exp $	*/
+
+#ifndef _PPC_SETJMP_H
+#define _PPC_SETJMP_H
+
+#define _JBLEN	100
+
+#endif /* !_PPC_SETJMP_H */
diff --git a/prex-0.9.0/include/ppc/signal.h b/prex-0.9.0/include/ppc/signal.h
new file mode 100755
index 0000000..bb27adf
--- /dev/null
+++ b/prex-0.9.0/include/ppc/signal.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+typedef int sig_atomic_t;
+
+struct sigcontext {
+	int	sc_onstack;		/* sigstack state to restore */
+	int	sc_mask;		/* signal mask to restore */
+
+	/* temporal! */
+	register_t fixreg[32];
+	register_t lr;
+	int cr;
+	int xer;
+	register_t ctr;
+	register_t srr0;
+	register_t srr1;
+	int vrsave;
+	int mq;
+	int spare;
+};
diff --git a/prex-0.9.0/include/ppc/stdarg.h b/prex-0.9.0/include/ppc/stdarg.h
new file mode 100755
index 0000000..ea69d55
--- /dev/null
+++ b/prex-0.9.0/include/ppc/stdarg.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	from: @(#)stdarg.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _PPC_STDARG_H
+#define	_PPC_STDARG_H
+
+#include <sys/cdefs.h>
+
+#ifdef __lint__
+typedef void *			va_list;
+#define	va_start(a, l)		(0)
+#define	va_arg(a, t)		(0)
+#define	va_end			/* nothing */
+#define	va_copy(d, s)		((d) = (s))
+
+#elif __GNUC_PREREQ__(2, 96)
+#define va_list			__builtin_va_list
+#define	va_start(ap, last)	__builtin_va_start((ap), (last))
+#define	va_arg			__builtin_va_arg
+#define	va_end			__builtin_va_end
+#define	va_copy(dest, src)	__builtin_va_copy((dest), (src))
+#else
+
+typedef char *			va_list;
+
+#define	__va_size(type) \
+	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+
+#define	va_start(ap, last) \
+	((ap) = (va_list)&(last) + __va_size(last))
+
+#define	va_arg(ap, type) \
+	(*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))
+
+#define	va_end(ap)
+
+#define	va_copy(dest, src)	((dest) = (src))
+#endif
+
+#endif /* !_PPC_STDARG_H */
diff --git a/prex-0.9.0/include/ppc/syspage.h b/prex-0.9.0/include/ppc/syspage.h
new file mode 100755
index 0000000..e8ffc63
--- /dev/null
+++ b/prex-0.9.0/include/ppc/syspage.h
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_SYSPAGE_H
+#define _PPC_SYSPAGE_H
+
+#include <conf/config.h>
+
+/**
+ * syspage layout:
+ *
+ * +------------------+ CONFIG_SYSPAGE_BASE
+ * | Vector page      |
+ * |                  |
+ * |                  |
+ * |                  |
+ * |                  |
+ * |                  |
+ * +------------------+ +0x3000
+ * | Interrupt stack  |
+ * |                  |
+ * |                  |
+ * +------------------+ +0x4000
+ * | Boot information |
+ * +------------------+ +0x4400
+ * | Boot stack       |
+ * +------------------+ +0x5000
+ * | PGD for boot     |
+ * | (MMU only)       |
+ * |                  |
+ * +------------------+ +0x6000
+ * | PTE0 for boot    |
+ * | (MMU only)       |
+ * |                  |
+ * +------------------+ +0x7000
+ *
+ * Note: Interrupt stack should be placed after NULL page
+ * to detect the stack overflow.
+ */
+
+#define SYSPAGE		CONFIG_SYSPAGE_BASE
+#define INTSTK		(SYSPAGE + 0x3000)
+#define BOOTINFO	(SYSPAGE + 0x4000)
+#define BOOTSTK		(SYSPAGE + 0x4400)
+#define BOOT_PGD	(SYSPAGE + 0x5000)
+#define BOOT_PTE0	(SYSPAGE + 0x6000)
+
+#define BOOT_PGD_PHYS	0x5000
+#define BOOT_PTE0_PHYS	0x6000
+
+#define INTSTKSZ	0x1000		/* size of interrupt stack */
+#define BOOTSTKSZ	0x0c00		/* size of boot stack */
+
+#define INTSTKTOP	(INTSTK + INTSTKSZ)
+#define BOOTSTKTOP	(BOOTSTK + BOOTSTKSZ)
+
+#ifdef CONFIG_MMU
+#define SYSPAGESZ	0x7000
+#else
+#define SYSPAGESZ	0x5000
+#endif
+
+#endif /* !_PPC_SYSPAGE_H */
diff --git a/prex-0.9.0/include/ppc/systrap.h b/prex-0.9.0/include/ppc/systrap.h
new file mode 100755
index 0000000..e4c200d
--- /dev/null
+++ b/prex-0.9.0/include/ppc/systrap.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PPC_SYSTRAP_H
+#define _PPC_SYSTRAP_H
+
+#define SYSCALL0(name) \
+	.global name; .align; \
+name##: ; \
+	li	r0, SYS_##name; \
+	sc; \
+	blr;
+
+
+#define SYSCALL1(name) SYSCALL0(name)
+#define SYSCALL2(name) SYSCALL0(name)
+#define SYSCALL3(name) SYSCALL0(name)
+#define SYSCALL4(name) SYSCALL0(name)
+
+#endif /* _PPC_SYSTRAP_H */
diff --git a/prex-0.9.0/include/ppc/types.h b/prex-0.9.0/include/ppc/types.h
new file mode 100755
index 0000000..8b45d48
--- /dev/null
+++ b/prex-0.9.0/include/ppc/types.h
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)types.h	8.3 (Berkeley) 1/5/94
+ */
+
+#ifndef	_PPC_TYPES_H
+#define	_PPC_TYPES_H
+
+#include <sys/cdefs.h>
+
+/*
+ * Basic integral types.  Omit the typedef if
+ * not possible for a machine/compiler combination.
+ */
+typedef	signed char	   int8_t;
+typedef	unsigned char	  uint8_t;
+typedef	short		  int16_t;
+typedef	unsigned short	 uint16_t;
+typedef	int		  int32_t;
+typedef	unsigned int	 uint32_t;
+
+typedef unsigned long	  paddr_t;
+typedef unsigned long	  psize_t;
+typedef unsigned long	  vaddr_t;
+typedef unsigned long	  vsize_t;
+
+typedef int		register_t;
+
+#endif	/* _PPC_TYPES_H */
diff --git a/prex-0.9.0/include/sys/ar.h b/prex-0.9.0/include/sys/ar.h
new file mode 100755
index 0000000..a018567
--- /dev/null
+++ b/prex-0.9.0/include/sys/ar.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Hugh Smith at The University of Guelph.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)ar.h	8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_AR_H
+#define	_SYS_AR_H
+
+/* Pre-4BSD archives had these magic numbers in them. */
+#define	OARMAG1	0177555
+#define	OARMAG2	0177545
+
+#define	ARMAG		"!<arch>\n"	/* ar "magic number" */
+#define	SARMAG		8		/* strlen(ARMAG); */
+
+#define	AR_EFMT1	"#1/"		/* extended format #1 */
+
+struct ar_hdr {
+	char	ar_name[16];		/* name */
+	char	ar_date[12];		/* modification time */
+	char	ar_uid[6];		/* user id */
+	char	ar_gid[6];		/* group id */
+	char	ar_mode[8];		/* octal file permissions */
+	char	ar_size[10];		/* size in bytes */
+#define	ARFMAG	"`\n"
+	char	ar_fmag[2];		/* consistency check */
+};
+
+#endif /* !_SYS_AR_H */
diff --git a/prex-0.9.0/include/sys/bootinfo.h b/prex-0.9.0/include/sys/bootinfo.h
new file mode 100755
index 0000000..95f024e
--- /dev/null
+++ b/prex-0.9.0/include/sys/bootinfo.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Boot information
+ *
+ * The boot information is stored by an OS loader, and
+ * it is refered by kernel later in boot time.
+ */
+
+#ifndef _SYS_BOOTINFO_H
+#define _SYS_BOOTINFO_H
+
+#include <sys/types.h>
+
+#define MAXIMGNAME	16
+
+/*
+ * Video information
+ */
+struct vidinfo
+{
+	int	pixel_x;	/* screen pixels */
+	int	pixel_y;
+	int	text_x;		/* text size, in characters */
+	int	text_y;
+};
+
+/*
+ * Module information for kernel, driver, and boot tasks.
+ * An OS loader will build this structure regardless of its file format.
+ */
+struct module
+{
+	char		name[MAXIMGNAME]; /* name of image */
+	paddr_t		phys;		/* physical address */
+	size_t		size;		/* size of image */
+	vaddr_t		entry;		/* entry address */
+	vaddr_t		text;		/* text address */
+	vaddr_t		data;		/* data address */
+	size_t		textsz;		/* text size */
+	size_t		datasz;		/* data size */
+	size_t		bsssz;		/* bss size */
+};
+
+/*
+ * Physical memory
+ */
+struct physmem
+{
+	paddr_t		base;		/* start address */
+	psize_t		size;		/* size in bytes */
+	int		type;		/* type */
+};
+
+/* memory types */
+#define MT_USABLE	1
+#define MT_MEMHOLE	2
+#define MT_RESERVED	3
+#define MT_BOOTDISK	4
+
+#define NMEMS		8		/* max number of memory slots */
+
+/*
+ * Boot information
+ */
+struct bootinfo
+{
+	struct vidinfo	video;		/* video information */
+	struct physmem	ram[NMEMS];	/* physical ram table */
+	int		nr_rams;	/* number of ram blocks */
+	struct physmem	bootdisk;	/* boot disk in memory */
+	int		nr_tasks;	/* number of boot tasks */
+	struct module	kernel;		/* kernel image */
+	struct module	driver;		/* driver image */
+	struct module	tasks[1];	/* boot tasks image */
+};
+
+#define BOOTINFOSZ	1024		/* max size of boot information */
+
+#endif /* !_SYS_BOOTINFO_H */
diff --git a/prex-0.9.0/include/sys/buf.h b/prex-0.9.0/include/sys/buf.h
new file mode 100755
index 0000000..4daa0df
--- /dev/null
+++ b/prex-0.9.0/include/sys/buf.h
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_BUF_H_
+#define _SYS_BUF_H_
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/list.h>
+
+/*
+ * Buffer header
+ */
+struct buf {
+	struct list	b_link;		/* link to block list */
+	int		b_flags;	/* see defines below */
+	dev_t		b_dev;		/* device number */
+	int		b_blkno;	/* block # on device */
+	mutex_t		b_lock;		/* lock for access */
+	char		*b_data;	/* pointer to data buffer */
+};
+
+/*
+ * These flags are kept in b_flags.
+ */
+#define	B_BUSY		0x00000001	/* I/O in progress. */
+#define	B_DELWRI	0x00000002	/* delay I/O until buffer reused. */
+#define	B_INVAL		0x00000004	/* does not contain valid info. */
+#define	B_READ		0x00000008	/* read buffer. */
+#define	B_DONE		0x00000010	/* I/O completed. */
+
+__BEGIN_DECLS
+struct buf *getblk(dev_t, int);
+int	bread(dev_t, int, struct buf **);
+int	bwrite(struct buf *);
+void	bdwrite(struct buf *);
+void	binval(dev_t);
+void	brelse(struct buf *);
+void	bflush(struct buf *);
+void	bio_sync(void);
+void	bio_init(void);
+__END_DECLS
+
+#endif /* !_SYS_BUF_H_ */
diff --git a/prex-0.9.0/include/sys/capability.h b/prex-0.9.0/include/sys/capability.h
new file mode 100755
index 0000000..105d36d
--- /dev/null
+++ b/prex-0.9.0/include/sys/capability.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_CAPABILITY_H
+#define _SYS_CAPABILITY_H
+
+/*
+ * Type of capability
+ */
+typedef uint32_t	cap_t;
+
+/*
+ * Task capabilities
+ */
+
+#define CAP_NICE	0x00000001	/* Allow changing scheduling parameters */
+#define CAP_RAWIO	0x00000002	/* Allow raw I/O operations */
+#define CAP_KILL	0x00000004	/* Allow raising exception to another task */
+#define CAP_SETPCAP	0x00000008	/* Allow setting capability */
+#define CAP_TASKCTRL	0x00000010	/* Allow controlling another task's execution */
+#define CAP_EXTMEM	0x00000020	/* Allow touching another task's memory */
+#define CAP_PROTSERV	0x00000040	/* Allow operations as protected server */
+#define CAP_NETWORK	0x00000080	/* Allow accessing network service */
+#define CAP_POWERMGMT	0x00000100	/* Allow power management operation */
+#define CAP_DISKADMIN	0x00000200	/* Allow mount, umount, etc. */
+#define CAP_USERFILES	0x00000400	/* Allow accessing user files */
+#define CAP_SYSFILES	0x00000800	/* Allow accessing system files */
+
+/*
+ * Default capability set
+ */
+#define CAPSET_BOOT	0x00000043	/* capabilities for boot tasks */
+
+#endif /* !_SYS_CAPABILITY_H */
diff --git a/prex-0.9.0/include/sys/cdefs.h b/prex-0.9.0/include/sys/cdefs.h
new file mode 100755
index 0000000..2ef5202
--- /dev/null
+++ b/prex-0.9.0/include/sys/cdefs.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Berkeley Software Design, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
+ */
+
+#ifndef	_SYS_CDEFS_H_
+#define	_SYS_CDEFS_H_
+
+/*
+ * Macro to test if we're using a GNU C compiler of a specific vintage
+ * or later, for e.g. features that appeared in a particular version
+ * of GNU C.  Usage:
+ *
+ *	#if __GNUC_PREREQ__(major, minor)
+ *	...cool feature...
+ *	#else
+ *	...delete feature...
+ *	#endif
+ */
+#ifdef __GNUC__
+#define	__GNUC_PREREQ__(x, y)						\
+	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
+	 (__GNUC__ > (x)))
+#else
+#define	__GNUC_PREREQ__(x, y)	0
+#endif
+
+#if defined(__cplusplus)
+#define	__BEGIN_DECLS	extern "C" {
+#define	__END_DECLS	};
+#else
+#define	__BEGIN_DECLS
+#define	__END_DECLS
+#endif
+
+#define	__CONCAT(x,y)	x ## y
+#define	__STRING(x)	#x
+
+#if defined(__cplusplus) || defined(__PCC__)
+#define	__inline	inline		/* convert to C++/C99 keyword */
+#else
+#ifndef __GNUC__
+#define	__inline			/* delete GCC keyword */
+#endif
+#endif /* !__cplusplus */
+
+#ifdef __GNUC__
+#define	__packed	__attribute__((__packed__))
+#define	__noreturn	__attribute__((__noreturn__))
+#elif defined(__lint__)
+#define	__packed	/* delete */
+#define	__noreturn	/* delete */
+#elif defined(__PCC__)
+#define	__packed	_Pragma("packed")
+#define	__noreturn	/* delete */
+#elif defined(__SUNPRO_C)
+#define	__packed	/* delete */
+#define	__noreturn	/* delete */
+#else
+#define	__packed	error: no __packed for this compiler
+#define	__noreturn	/* delete */
+#endif
+
+#define	__P(protos)	()
+#define	__RCSID(_s)
+#define	__COPYRIGHT(_s)
+
+#endif /* !_SYS_CDEFS_H_ */
diff --git a/prex-0.9.0/include/sys/dbgctl.h b/prex-0.9.0/include/sys/dbgctl.h
new file mode 100755
index 0000000..b8c4bb5
--- /dev/null
+++ b/prex-0.9.0/include/sys/dbgctl.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_DBGCTL_H
+#define _SYS_DBGCTL_H
+
+struct diag_ops {
+	void	(*puts)(char *);
+};
+
+struct abort_ops {
+	void	(*abort)(void);
+};
+
+/*
+ * Debug control code
+ */
+#define DBGC_LOGSIZE		0x0001	/* return log size */
+#define DBGC_GETLOG		0x0002	/* get message log */
+#define DBGC_TRACE		0x0003	/* trace thread */
+
+#ifdef KERNEL
+#define DBGC_DUMPTRAP		0x8001	/* dump trap frame */
+#define DBGC_SETDIAG		0x8002	/* set diag handler */
+#define DBGC_SETABORT		0x8003	/* set abort handler */
+#endif
+#endif /* !_SYS_DBGCTL_H */
diff --git a/prex-0.9.0/include/sys/device.h b/prex-0.9.0/include/sys/device.h
new file mode 100755
index 0000000..21fb8b0
--- /dev/null
+++ b/prex-0.9.0/include/sys/device.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_DEVICE_H
+#define _SYS_DEVICE_H
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+/*
+ * Device flags
+ *
+ * If D_PROT is set, the device can not be opened via devfs.
+ */
+#define D_CHR		0x00000001	/* character device */
+#define D_BLK		0x00000002	/* block device */
+#define D_REM		0x00000004	/* removable device */
+#define D_PROT		0x00000008	/* protected device */
+#define D_TTY		0x00000010	/* tty device */
+
+
+#ifdef KERNEL
+
+/*
+ * Device operations
+ */
+struct devops {
+	int (*open)	(device_t, int);
+	int (*close)	(device_t);
+	int (*read)	(device_t, char *, size_t *, int);
+	int (*write)	(device_t, char *, size_t *, int);
+	int (*ioctl)	(device_t, u_long, void *);
+	int (*devctl)	(device_t, u_long, void *);
+};
+
+typedef int (*devop_open_t)   (device_t, int);
+typedef int (*devop_close_t)  (device_t);
+typedef int (*devop_read_t)   (device_t, char *, size_t *, int);
+typedef int (*devop_write_t)  (device_t, char *, size_t *, int);
+typedef int (*devop_ioctl_t)  (device_t, u_long, void *);
+typedef int (*devop_devctl_t) (device_t, u_long, void *);
+
+#define	no_open		((devop_open_t)nullop)
+#define	no_close	((devop_close_t)nullop)
+#define	no_read		((devop_read_t)enodev)
+#define	no_write	((devop_write_t)enodev)
+#define	no_ioctl	((devop_ioctl_t)enodev)
+#define	no_devctl	((devop_devctl_t)nullop)
+
+/*
+ * Driver object
+ */
+struct driver {
+	const char	*name;		/* name of device driver */
+	struct devops	*devops;	/* device operations */
+	size_t		devsz;		/* size of private data */
+	int		flags;		/* state of driver */
+	int (*probe)	(struct driver *);
+	int (*init)	(struct driver *);
+	int (*unload)	(struct driver *);
+};
+
+/*
+ * flags for the driver.
+ */
+#define	DS_INACTIVE	0x00		/* driver is inactive */
+#define DS_ALIVE	0x01		/* probe succeded */
+#define DS_ACTIVE	0x02		/* intialized */
+#define DS_DEBUG	0x04		/* debug */
+
+#endif /* !KERNEL */
+#endif /* !_SYS_DEVICE_H */
diff --git a/prex-0.9.0/include/sys/dirent.h b/prex-0.9.0/include/sys/dirent.h
new file mode 100755
index 0000000..86f26d8
--- /dev/null
+++ b/prex-0.9.0/include/sys/dirent.h
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)dirent.h	8.3 (Berkeley) 8/10/94
+ */
+
+#ifndef _SYS_DIRENT_H_
+#define _SYS_DIRENT_H_
+
+#include <sys/types.h>
+#include <sys/syslimits.h>
+
+/*
+ * The dirent structure defines the format of directory entries returned by
+ * the getdirentries(2) system call.
+ *
+ * A directory entry has a struct dirent at the front of it, containing its
+ * inode number, the length of the entry, and the length of the name
+ * contained in the entry.  These are followed by the name padded to a 4
+ * byte boundary with null bytes.  All names are guaranteed null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
+ */
+
+struct dirent {
+	uint32_t d_fileno;		/* file number of entry */
+	uint16_t d_reclen;		/* length of this record */
+	uint16_t d_namlen;		/* length of string in d_name */
+	uint8_t  d_type; 		/* file type, see below */
+	char	 d_name[NAME_MAX];	/* name must be no longer than this */
+};
+
+/*
+ * File types
+ */
+#define	DT_UNKNOWN	 0
+#define	DT_FIFO		 1
+#define	DT_CHR		 2
+#define	DT_DIR		 4
+#define	DT_BLK		 6
+#define	DT_REG		 8
+#define	DT_LNK		10
+#define	DT_SOCK		12
+#define	DT_WHT		14
+
+/*
+ * Convert between stat structure types and directory types.
+ */
+#define	IFTODT(mode)	(((mode) & 0170000) >> 12)
+#define	DTTOIF(dirtype)	((dirtype) << 12)
+
+#endif	/* !_SYS_DIRENT_H_ */
diff --git a/prex-0.9.0/include/sys/elf.h b/prex-0.9.0/include/sys/elf.h
new file mode 100755
index 0000000..2bc004a
--- /dev/null
+++ b/prex-0.9.0/include/sys/elf.h
@@ -0,0 +1,466 @@
+/*-
+ * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This is the ELF ABI header file
+ * formerly known as "elf_abi.h".
+ */
+
+#ifndef _SYS_ELF_H_
+#define _SYS_ELF_H_
+
+#include <sys/cdefs.h>
+#include <machine/types.h>
+
+#include <machine/elf.h>
+
+typedef uint8_t	Elf_Byte;
+
+typedef uint32_t	Elf32_Addr;	/* Unsigned program address */
+typedef uint32_t	Elf32_Off;	/* Unsigned file offset */
+typedef int32_t		Elf32_Sword;	/* Signed large integer */
+typedef uint32_t	Elf32_Word;	/* Unsigned large integer */
+typedef uint16_t	Elf32_Half;	/* Unsigned medium integer */
+
+/* e_ident[] identification indexes */
+#define EI_MAG0		0		/* file ID */
+#define EI_MAG1		1		/* file ID */
+#define EI_MAG2		2		/* file ID */
+#define EI_MAG3		3		/* file ID */
+#define EI_CLASS	4		/* file class */
+#define EI_DATA		5		/* data encoding */
+#define EI_VERSION	6		/* ELF header version */
+#define EI_OSABI	7	/* Operating system / ABI identification */
+#define EI_ABIVERSION	8	/* ABI version */
+#define OLD_EI_BRAND	8	/* Start of architecture identification. */
+#define EI_PAD		9	/* Start of padding (per SVR4 ABI). */
+#define EI_NIDENT	16		/* Size of e_ident[] */
+
+/* e_ident[] magic number */
+#define	ELFMAG0		0x7f		/* e_ident[EI_MAG0] */
+#define	ELFMAG1		'E'		/* e_ident[EI_MAG1] */
+#define	ELFMAG2		'L'		/* e_ident[EI_MAG2] */
+#define	ELFMAG3		'F'		/* e_ident[EI_MAG3] */
+#define	ELFMAG		"\177ELF"	/* magic */
+#define	SELFMAG		4		/* size of magic */
+
+/* e_ident[] file class */
+#define	ELFCLASSNONE	0		/* invalid */
+#define	ELFCLASS32	1		/* 32-bit objs */
+#define	ELFCLASS64	2		/* 64-bit objs */
+#define	ELFCLASSNUM	3		/* number of classes */
+
+/* e_ident[] data encoding */
+#define ELFDATANONE	0		/* invalid */
+#define ELFDATA2LSB	1		/* Little-Endian */
+#define ELFDATA2MSB	2		/* Big-Endian */
+#define ELFDATANUM	3		/* number of data encode defines */
+
+/* e_ident[] OS ABI */
+#define ELFOSABI_SYSV		0	/* UNIX System V ABI */
+#define ELFOSABI_NONE		ELFOSABI_SYSV	/* symbol used in old spec */
+#define ELFOSABI_HPUX		1	/* HP-UX operating system */
+#define ELFOSABI_NETBSD		2	/* NetBSD */
+#define ELFOSABI_LINUX		3	/* GNU/Linux */
+#define ELFOSABI_HURD		4	/* GNU/Hurd */
+#define ELFOSABI_86OPEN		5	/* 86Open common IA32 ABI */
+#define ELFOSABI_SOLARIS	6	/* Solaris */
+#define ELFOSABI_MONTEREY	7	/* Monterey */
+#define ELFOSABI_IRIX		8	/* IRIX */
+#define ELFOSABI_FREEBSD	9	/* FreeBSD */
+#define ELFOSABI_TRU64		10	/* TRU64 UNIX */
+#define ELFOSABI_MODESTO	11	/* Novell Modesto */
+#define ELFOSABI_OPENBSD	12	/* OpenBSD */
+#define ELFOSABI_ARM		97	/* ARM */
+#define ELFOSABI_STANDALONE	255	/* Standalone (embedded) application */
+
+/* e_ident */
+#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
+                      (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
+                      (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
+                      (ehdr).e_ident[EI_MAG3] == ELFMAG3)
+
+/* ELF Header */
+typedef struct elfhdr{
+	unsigned char	e_ident[EI_NIDENT]; /* ELF Identification */
+	Elf32_Half	e_type;		/* object file type */
+	Elf32_Half	e_machine;	/* machine */
+	Elf32_Word	e_version;	/* object file version */
+	Elf32_Addr	e_entry;	/* virtual entry point */
+	Elf32_Off	e_phoff;	/* program header table offset */
+	Elf32_Off	e_shoff;	/* section header table offset */
+	Elf32_Word	e_flags;	/* processor-specific flags */
+	Elf32_Half	e_ehsize;	/* ELF header size */
+	Elf32_Half	e_phentsize;	/* program header entry size */
+	Elf32_Half	e_phnum;	/* number of program header entries */
+	Elf32_Half	e_shentsize;	/* section header entry size */
+	Elf32_Half	e_shnum;	/* number of section header entries */
+	Elf32_Half	e_shstrndx;	/* section header table's "section
+					   header string table" entry offset */
+} Elf32_Ehdr;
+
+/* e_type */
+#define ET_NONE		0		/* No file type */
+#define ET_REL		1		/* relocatable file */
+#define ET_EXEC		2		/* executable file */
+#define ET_DYN		3		/* shared object file */
+#define ET_CORE		4		/* core file */
+#define ET_NUM		5		/* number of types */
+#define ET_LOPROC	0xff00		/* reserved range for processor */
+#define ET_HIPROC	0xffff		/*  specific e_type */
+
+/* e_machine */
+#define EM_NONE		0		/* No Machine */
+#define EM_M32		1		/* AT&T WE 32100 */
+#define EM_SPARC	2		/* SPARC */
+#define EM_386		3		/* Intel 80386 */
+#define EM_68K		4		/* Motorola 68000 */
+#define EM_88K		5		/* Motorola 88000 */
+#define EM_486		6		/* Intel 80486 - unused? */
+#define EM_860		7		/* Intel 80860 */
+#define EM_MIPS		8		/* MIPS R3000 Big-Endian only */
+/*
+ * Don't know if EM_MIPS_RS4_BE,
+ * EM_SPARC64, EM_PARISC,
+ * or EM_PPC are ABI compliant
+ */
+#define EM_MIPS_RS4_BE	10		/* MIPS R4000 Big-Endian */
+#define EM_SPARC64	11		/* SPARC v9 64-bit unoffical */
+#define EM_PARISC	15		/* HPPA */
+#define EM_SPARC32PLUS	18		/* Enhanced instruction set SPARC */
+#define EM_PPC		20		/* PowerPC */
+#define EM_ARM		40
+#define EM_ALPHA	41		/* DEC ALPHA */
+#define EM_SPARCV9	43		/* SPARC version 9 */
+#define EM_ALPHA_EXP	0x9026		/* DEC ALPHA */
+#define EM_VAX		75		/* DEC VAX */
+#define EM_NUM		15		/* number of machine types */
+
+/* Version */
+#define EV_NONE		0		/* Invalid */
+#define EV_CURRENT	1		/* Current */
+#define EV_NUM		2		/* number of versions */
+
+/* Section Header */
+typedef struct {
+	Elf32_Word	sh_name;	/* name - index into section header
+					   string table section */
+	Elf32_Word	sh_type;	/* type */
+	Elf32_Word	sh_flags;	/* flags */
+	Elf32_Addr	sh_addr;	/* address */
+	Elf32_Off	sh_offset;	/* file offset */
+	Elf32_Word	sh_size;	/* section size */
+	Elf32_Word	sh_link;	/* section header table index link */
+	Elf32_Word	sh_info;	/* extra information */
+	Elf32_Word	sh_addralign;	/* address alignment */
+	Elf32_Word	sh_entsize;	/* section entry size */
+} Elf32_Shdr;
+
+/* Special Section Indexes */
+#define SHN_UNDEF	0		/* undefined */
+#define SHN_LORESERVE	0xff00		/* lower bounds of reserved indexes */
+#define SHN_LOPROC	0xff00		/* reserved range for processor */
+#define SHN_HIPROC	0xff1f		/*   specific section indexes */
+#define SHN_ABS		0xfff1		/* absolute value */
+#define SHN_COMMON	0xfff2		/* common symbol */
+#define SHN_HIRESERVE	0xffff		/* upper bounds of reserved indexes */
+
+/* sh_type */
+#define SHT_NULL	0		/* inactive */
+#define SHT_PROGBITS	1		/* program defined information */
+#define SHT_SYMTAB	2		/* symbol table section */
+#define SHT_STRTAB	3		/* string table section */
+#define SHT_RELA	4		/* relocation section with addends*/
+#define SHT_HASH	5		/* symbol hash table section */
+#define SHT_DYNAMIC	6		/* dynamic section */
+#define SHT_NOTE	7		/* note section */
+#define SHT_NOBITS	8		/* no space section */
+#define SHT_REL		9		/* relation section without addends */
+#define SHT_SHLIB	10		/* reserved - purpose unknown */
+#define SHT_DYNSYM	11		/* dynamic symbol table section */
+#define SHT_NUM		12		/* number of section types */
+#define SHT_LOPROC	0x70000000	/* reserved range for processor */
+#define SHT_HIPROC	0x7fffffff	/*  specific section header types */
+#define SHT_LOUSER	0x80000000	/* reserved range for application */
+#define SHT_HIUSER	0xffffffff	/*  specific indexes */
+
+/* Section names */
+#define ELF_BSS         ".bss"		/* uninitialized data */
+#define ELF_DATA        ".data"		/* initialized data */
+#define ELF_DEBUG       ".debug"	/* debug */
+#define ELF_DYNAMIC     ".dynamic"	/* dynamic linking information */
+#define ELF_DYNSTR      ".dynstr"	/* dynamic string table */
+#define ELF_DYNSYM      ".dynsym"	/* dynamic symbol table */
+#define ELF_FINI        ".fini"		/* termination code */
+#define ELF_GOT         ".got"		/* global offset table */
+#define ELF_HASH        ".hash"		/* symbol hash table */
+#define ELF_INIT        ".init"		/* initialization code */
+#define ELF_REL_DATA    ".rel.data"	/* relocation data */
+#define ELF_REL_FINI    ".rel.fini"	/* relocation termination code */
+#define ELF_REL_INIT    ".rel.init"	/* relocation initialization code */
+#define ELF_REL_DYN     ".rel.dyn"	/* relocaltion dynamic link info */
+#define ELF_REL_RODATA  ".rel.rodata"	/* relocation read-only data */
+#define ELF_REL_TEXT    ".rel.text"	/* relocation code */
+#define ELF_RODATA      ".rodata"	/* read-only data */
+#define ELF_SHSTRTAB    ".shstrtab"	/* section header string table */
+#define ELF_STRTAB      ".strtab"	/* string table */
+#define ELF_SYMTAB      ".symtab"	/* symbol table */
+#define ELF_TEXT        ".text"		/* code */
+
+
+/* Section Attribute Flags - sh_flags */
+#define SHF_WRITE	0x1		/* Writable */
+#define SHF_ALLOC	0x2		/* occupies memory */
+#define SHF_EXECINSTR	0x4		/* executable */
+#define SHF_MASKPROC	0xf0000000	/* reserved bits for processor */
+					/*  specific section attributes */
+
+/* Symbol Table Entry */
+typedef struct elf32_sym {
+	Elf32_Word	st_name;	/* name - index into string table */
+	Elf32_Addr	st_value;	/* symbol value */
+	Elf32_Word	st_size;	/* symbol size */
+	unsigned char	st_info;	/* type and binding */
+	unsigned char	st_other;	/* 0 - no defined meaning */
+	Elf32_Half	st_shndx;	/* section header index */
+} Elf32_Sym;
+
+/* Symbol table index */
+#define STN_UNDEF	0		/* undefined */
+
+/* Extract symbol info - st_info */
+#define ELF32_ST_BIND(x)	((x) >> 4)
+#define ELF32_ST_TYPE(x)	(((unsigned int) x) & 0xf)
+#define ELF32_ST_INFO(b,t)	(((b) << 4) + ((t) & 0xf))
+
+/* Symbol Binding - ELF32_ST_BIND - st_info */
+#define STB_LOCAL	0		/* Local symbol */
+#define STB_GLOBAL	1		/* Global symbol */
+#define STB_WEAK	2		/* like global - lower precedence */
+#define STB_NUM		3		/* number of symbol bindings */
+#define STB_LOPROC	13		/* reserved range for processor */
+#define STB_HIPROC	15		/*  specific symbol bindings */
+
+/* Symbol type - ELF32_ST_TYPE - st_info */
+#define STT_NOTYPE	0		/* not specified */
+#define STT_OBJECT	1		/* data object */
+#define STT_FUNC	2		/* function */
+#define STT_SECTION	3		/* section */
+#define STT_FILE	4		/* file */
+#define STT_NUM		5		/* number of symbol types */
+#define STT_LOPROC	13		/* reserved range for processor */
+#define STT_HIPROC	15		/*  specific symbol types */
+
+/* Relocation entry with implicit addend */
+typedef struct
+{
+	Elf32_Addr	r_offset;	/* offset of relocation */
+	Elf32_Word	r_info;		/* symbol table index and type */
+} Elf32_Rel;
+
+/* Relocation entry with explicit addend */
+typedef struct
+{
+	Elf32_Addr	r_offset;	/* offset of relocation */
+	Elf32_Word	r_info;		/* symbol table index and type */
+	Elf32_Sword	r_addend;
+} Elf32_Rela;
+
+/* Extract relocation info - r_info */
+#define ELF32_R_SYM(i)		((i) >> 8)
+#define ELF32_R_TYPE(i)		((unsigned char) (i))
+#define ELF32_R_INFO(s,t) 	(((s) << 8) + (unsigned char)(t))
+
+/* Program Header */
+typedef struct {
+	Elf32_Word	p_type;		/* segment type */
+	Elf32_Off	p_offset;	/* segment offset */
+	Elf32_Addr	p_vaddr;	/* virtual address of segment */
+	Elf32_Addr	p_paddr;	/* physical address - ignored? */
+	Elf32_Word	p_filesz;	/* number of bytes in file for seg. */
+	Elf32_Word	p_memsz;	/* number of bytes in mem. for seg. */
+	Elf32_Word	p_flags;	/* flags */
+	Elf32_Word	p_align;	/* memory alignment */
+} Elf32_Phdr;
+
+/* Segment types - p_type */
+#define PT_NULL		0		/* unused */
+#define PT_LOAD		1		/* loadable segment */
+#define PT_DYNAMIC	2		/* dynamic linking section */
+#define PT_INTERP	3		/* the RTLD */
+#define PT_NOTE		4		/* auxiliary information */
+#define PT_SHLIB	5		/* reserved - purpose undefined */
+#define PT_PHDR		6		/* program header */
+#define PT_NUM		7		/* Number of segment types */
+#define PT_LOPROC	0x70000000	/* reserved range for processor */
+#define PT_HIPROC	0x7fffffff	/*  specific segment types */
+
+/* Segment flags - p_flags */
+#define PF_X		0x1		/* Executable */
+#define PF_W		0x2		/* Writable */
+#define PF_R		0x4		/* Readable */
+#define PF_MASKPROC	0xf0000000	/* reserved bits for processor */
+					/*  specific segment flags */
+
+/* Dynamic structure */
+typedef struct {
+	Elf32_Sword	d_tag;		/* controls meaning of d_val */
+	union {
+		Elf32_Word	d_val;	/* Multiple meanings - see d_tag */
+		Elf32_Addr	d_ptr;	/* program virtual address */
+	} d_un;
+} Elf32_Dyn;
+
+/* Dynamic Array Tags - d_tag */
+#define DT_NULL		0		/* marks end of _DYNAMIC array */
+#define DT_NEEDED	1		/* string table offset of needed lib */
+#define DT_PLTRELSZ	2		/* size of relocation entries in PLT */
+#define DT_PLTGOT	3		/* address PLT/GOT */
+#define DT_HASH		4		/* address of symbol hash table */
+#define DT_STRTAB	5		/* address of string table */
+#define DT_SYMTAB	6		/* address of symbol table */
+#define DT_RELA		7		/* address of relocation table */
+#define DT_RELASZ	8		/* size of relocation table */
+#define DT_RELAENT	9		/* size of relocation entry */
+#define DT_STRSZ	10		/* size of string table */
+#define DT_SYMENT	11		/* size of symbol table entry */
+#define DT_INIT		12		/* address of initialization func. */
+#define DT_FINI		13		/* address of termination function */
+#define DT_SONAME	14		/* string table offset of shared obj */
+#define DT_RPATH	15		/* string table offset of library
+					   search path */
+#define DT_SYMBOLIC	16		/* start sym search in shared obj. */
+#define DT_REL		17		/* address of rel. tbl. w addends */
+#define DT_RELSZ	18		/* size of DT_REL relocation table */
+#define DT_RELENT	19		/* size of DT_REL relocation entry */
+#define DT_PLTREL	20		/* PLT referenced relocation entry */
+#define DT_DEBUG	21		/* bugger */
+#define DT_TEXTREL	22		/* Allow rel. mod. to unwritable seg */
+#define DT_JMPREL	23		/* add. of PLT's relocation entries */
+#define DT_BIND_NOW	24		/* Bind now regardless of env setting */
+#define DT_NUM		25		/* Number used. */
+#define DT_LOPROC	0x70000000	/* reserved range for processor */
+#define DT_HIPROC	0x7fffffff	/*  specific dynamic array tags */
+
+/* Standard ELF hashing function */
+unsigned int elf_hash(const unsigned char *name);
+
+/*
+ * Note Definitions
+ */
+typedef struct {
+	Elf32_Word namesz;
+	Elf32_Word descsz;
+	Elf32_Word type;
+} Elf32_Note;
+
+/*
+ * XXX - these _KERNEL items aren't part of the ABI!
+ */
+#if defined(_KERNEL) || defined(_DYN_LOADER)
+
+#define ELF32_NO_ADDR	((u_long) ~0)	/* Indicates addr. not yet filled in */
+#define ELF_AUX_ENTRIES	8		/* Size of aux array passed to loader */
+
+typedef struct {
+	Elf32_Sword	au_id;				/* 32-bit id */
+	Elf32_Word	au_v;				/* 32-bit value */
+} Aux32Info;
+
+enum AuxID {
+	AUX_null = 0,
+	AUX_ignore = 1,
+	AUX_execfd = 2,
+	AUX_phdr = 3,			/* &phdr[0] */
+	AUX_phent = 4,			/* sizeof(phdr[0]) */
+	AUX_phnum = 5,			/* # phdr entries */
+	AUX_pagesz = 6,			/* PAGESIZE */
+	AUX_base = 7,			/* ld.so base addr */
+	AUX_flags = 8,			/* processor flags */
+	AUX_entry = 9,			/* a.out entry */
+	AUX_sun_uid = 2000,		/* euid */
+	AUX_sun_ruid = 2001,		/* ruid */
+	AUX_sun_gid = 2002,		/* egid */
+	AUX_sun_rgid = 2003		/* rgid */
+};
+
+struct elf_args {
+        u_long  arg_entry;		/* program entry point */
+        u_long  arg_interp;		/* Interpreter load address */
+        u_long  arg_phaddr;		/* program header address */
+        u_long  arg_phentsize;		/* Size of program header */
+        u_long  arg_phnum;		/* Number of program headers */
+        u_long  arg_os;			/* OS tag */
+};
+
+#endif
+
+#if !defined(ELFSIZE) && defined(ARCH_ELFSIZE)
+#define ELFSIZE ARCH_ELFSIZE
+#endif
+
+#if defined(ELFSIZE)
+#define CONCAT(x,y)	__CONCAT(x,y)
+#define ELFNAME(x)	CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
+#define ELFNAME2(x,y)	CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
+#define ELFNAMEEND(x)	CONCAT(x,CONCAT(_elf,ELFSIZE))
+#define ELFDEFNNAME(x)	CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
+#endif
+
+#define Elf_Ehdr	Elf32_Ehdr
+#define Elf_Phdr	Elf32_Phdr
+#define Elf_Shdr	Elf32_Shdr
+#define Elf_Sym		Elf32_Sym
+#define Elf_Rel		Elf32_Rel
+#define Elf_RelA	Elf32_Rela
+#define Elf_Dyn		Elf32_Dyn
+#define Elf_Word	Elf32_Word
+#define Elf_Sword	Elf32_Sword
+#define Elf_Addr	Elf32_Addr
+#define Elf_Off		Elf32_Off
+#define Elf_Nhdr	Elf32_Nhdr
+#define Elf_Note	Elf32_Note
+
+#define ELF_R_SYM	ELF32_R_SYM
+#define ELF_R_TYPE	ELF32_R_TYPE
+#define ELF_R_INFO	ELF32_R_INFO
+#define ELFCLASS	ELFCLASS32
+
+#define ELF_ST_BIND	ELF32_ST_BIND
+#define ELF_ST_TYPE	ELF32_ST_TYPE
+#define ELF_ST_INFO	ELF32_ST_INFO
+
+#define AuxInfo		Aux32Info
+
+#define ELF_TARG_VER	1	/* The ver for which this code is intended */
+
+
+__BEGIN_DECLS
+int relocate_rel(Elf32_Rel *, Elf32_Addr, char *);
+int relocate_rela(Elf32_Rela *, Elf32_Addr, char *);
+__END_DECLS
+
+#endif /* _SYS_ELF_H_ */
diff --git a/prex-0.9.0/include/sys/endian.h b/prex-0.9.0/include/sys/endian.h
new file mode 100755
index 0000000..38500b1
--- /dev/null
+++ b/prex-0.9.0/include/sys/endian.h
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 1987, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)endian.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _SYS_ENDIAN_H_
+#define	_SYS_ENDIAN_H_
+
+/*
+ * Define the order of 32-bit words in 64-bit words.
+ */
+#define _QUAD_HIGHWORD 0
+#define _QUAD_LOWWORD 1
+
+/*
+ * Definitions for byte order, according to byte significance from low
+ * address to high.
+ */
+#define	LITTLE_ENDIAN	1234	/* LSB first: i386, vax */
+#define	BIG_ENDIAN	4321	/* MSB first: 68000, ibm, net */
+#define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long */
+
+#include <machine/endian.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#define	BYTE_ORDER	_BYTE_ORDER
+
+
+/*
+ * Macros for network/external number representation conversion.
+ */
+#if BYTE_ORDER == BIG_ENDIAN && !defined(__lint__)
+#define	ntohl(x)	(x)
+#define	ntohs(x)	(x)
+#define	htonl(x)	(x)
+#define	htons(x)	(x)
+
+#else	/* LITTLE_ENDIAN || !defined(__lint__) */
+
+__BEGIN_DECLS
+uint32_t htonl(uint32_t);
+uint16_t htons(uint16_t);
+uint32_t ntohl(uint32_t);
+uint16_t ntohs(uint16_t);
+__END_DECLS
+
+#endif	/* LITTLE_ENDIAN || !defined(__lint__) */
+
+#endif /* !_SYS_ENDIAN_H_ */
diff --git a/prex-0.9.0/include/sys/errno.h b/prex-0.9.0/include/sys/errno.h
new file mode 100755
index 0000000..4d40162
--- /dev/null
+++ b/prex-0.9.0/include/sys/errno.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)errno.h	8.5 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_ERRNO_H_
+#define _SYS_ERRNO_H_
+
+#define	EPERM		1		/* Operation not permitted */
+#define	ENOENT		2		/* No such file or directory */
+#define	ESRCH		3		/* No such process */
+#define	EINTR		4		/* Interrupted system call */
+#define	EIO		5		/* Input/output error */
+#define	ENXIO		6		/* Device not configured */
+#define	E2BIG		7		/* Argument list too long */
+#define	ENOEXEC		8		/* Exec format error */
+#define	EBADF		9		/* Bad file descriptor */
+#define	ECHILD		10		/* No child processes */
+#define	EDEADLK		11		/* Resource deadlock avoided */
+					/* 11 was EAGAIN */
+#define	ENOMEM		12		/* Cannot allocate memory */
+#define	EACCES		13		/* Permission denied */
+#define	EFAULT		14		/* Bad address */
+#define	ENOTBLK		15		/* Block device required */
+#define	EBUSY		16		/* Device busy */
+#define	EEXIST		17		/* File exists */
+#define	EXDEV		18		/* Cross-device link */
+#define	ENODEV		19		/* Operation not supported by device */
+#define	ENOTDIR		20		/* Not a directory */
+#define	EISDIR		21		/* Is a directory */
+#define	EINVAL		22		/* Invalid argument */
+#define	ENFILE		23		/* Too many open files in system */
+#define	EMFILE		24		/* Too many open files */
+#define	ENOTTY		25		/* Inappropriate ioctl for device */
+#define	ETXTBSY		26		/* Text file busy */
+#define	EFBIG		27		/* File too large */
+#define	ENOSPC		28		/* No space left on device */
+#define	ESPIPE		29		/* Illegal seek */
+#define	EROFS		30		/* Read-only file system */
+#define	EMLINK		31		/* Too many links */
+#define	EPIPE		32		/* Broken pipe */
+
+/* math software */
+#define	EDOM		33		/* Numerical argument out of domain */
+#define	ERANGE		34		/* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define	EAGAIN		35		/* Resource temporarily unavailable */
+#define	EWOULDBLOCK	EAGAIN		/* Operation would block */
+
+#define	ETIMEDOUT	36		/* Operation timed out */
+#define	ENAMETOOLONG	37		/* File name too long */
+#define	ENOTEMPTY	38		/* Directory not empty */
+
+/* quotas & mush */
+#define	EPROCLIM	39		/* Too many processes */
+#define	ENOSYS		40		/* Function not implemented */
+
+#endif /* !_SYS_ERRNO_H_ */
diff --git a/prex-0.9.0/include/sys/fcntl.h b/prex-0.9.0/include/sys/fcntl.h
new file mode 100755
index 0000000..971132b
--- /dev/null
+++ b/prex-0.9.0/include/sys/fcntl.h
@@ -0,0 +1,140 @@
+/*-
+ * Copyright (c) 1983, 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)fcntl.h	8.3 (Berkeley) 1/21/94
+ */
+
+#ifndef _SYS_FCNTL_H_
+#define	_SYS_FCNTL_H_
+
+/*
+ * This file includes the definitions for open and fcntl
+ * described by POSIX for <fcntl.h>.
+ */
+
+#include <sys/types.h>
+
+/*
+ * File status flags: these are used by open(2), fcntl(2).
+ * They are also used (indirectly) in the kernel file structure f_flags,
+ * which is a superset of the open/fcntl flags.  Open flags and f_flags
+ * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
+ * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
+ */
+/* open-only flags */
+#define	O_RDONLY	0x00000000	/* open for reading only */
+#define	O_WRONLY	0x00000001	/* open for writing only */
+#define	O_RDWR		0x00000002	/* open for reading and writing */
+#define	O_ACCMODE	0x00000003	/* mask for above modes */
+
+/*
+ * Kernel encoding of open mode; separate read and write bits that are
+ * independently testable: 1 greater than the above.
+ */
+#define	FREAD		0x00000001
+#define	FWRITE		0x00000002
+
+#define	O_NONBLOCK	0x00000004	/* no delay */
+#define	O_APPEND	0x00000008	/* set append mode */
+#define	O_SHLOCK	0x00000010	/* open with shared file lock */
+#define	O_EXLOCK	0x00000020	/* open with exclusive file lock */
+#define	O_ASYNC		0x00000040	/* signal pgrp when data ready */
+#define	O_SYNC		0x00000080	/* synchronous writes */
+#define	O_CREAT		0x00000200	/* create if nonexistent */
+#define	O_TRUNC		0x00000400	/* truncate to zero length */
+#define	O_EXCL		0x00000800	/* error if already exists */
+
+#define	FPIPE		0x00010000	/* pipe */
+
+/* defined by POSIX 1003.1; BSD default, so no bit required */
+#define	O_NOCTTY	0		/* don't assign controlling terminal */
+
+/* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE */
+#define	FFLAGS(oflags)	((oflags) + 1)
+#define	OFLAGS(fflags)	((fflags) - 1)
+
+/*
+ * Constants used for fcntl(2)
+ */
+
+/* command values */
+#define	F_DUPFD		0		/* duplicate file descriptor */
+#define	F_GETFD		1		/* get file descriptor flags */
+#define	F_SETFD		2		/* set file descriptor flags */
+#define	F_GETFL		3		/* get file status flags */
+#define	F_SETFL		4		/* set file status flags */
+#define	F_GETOWN	5		/* get SIGIO/SIGURG proc/pgrp */
+#define F_SETOWN	6		/* set SIGIO/SIGURG proc/pgrp */
+#define	F_GETLK		7		/* get record locking information */
+#define	F_SETLK		8		/* set record locking information */
+#define	F_SETLKW	9		/* F_SETLK; wait if blocked */
+
+/* file descriptor flags (F_GETFD, F_SETFD) */
+#define	FD_CLOEXEC	1		/* close-on-exec flag */
+
+/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
+#define	F_RDLCK		1		/* shared or read lock */
+#define	F_UNLCK		2		/* unlock */
+#define	F_WRLCK		3		/* exclusive or write lock */
+
+/*
+ * Advisory file segment locking data type -
+ * information passed to system by user
+ */
+struct flock {
+	off_t	l_start;	/* starting offset */
+	off_t	l_len;		/* len = 0 means until end of file */
+	pid_t	l_pid;		/* lock owner */
+	short	l_type;		/* lock type: read/write, etc. */
+	short	l_whence;	/* type of l_start */
+};
+
+/* lock operations for flock(2) */
+#define	LOCK_SH		0x01		/* shared file lock */
+#define	LOCK_EX		0x02		/* exclusive file lock */
+#define	LOCK_NB		0x04		/* don't block when locking */
+#define	LOCK_UN		0x08		/* unlock file */
+
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	open(const char *, int, ...);
+int	creat(const char *, mode_t);
+int	fcntl(int, int, ...);
+#if 0
+int	flock(int, int);
+#endif
+__END_DECLS
+
+#endif /* !_SYS_FCNTL_H_ */
diff --git a/prex-0.9.0/include/sys/file.h b/prex-0.9.0/include/sys/file.h
new file mode 100755
index 0000000..c375217
--- /dev/null
+++ b/prex-0.9.0/include/sys/file.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_FILE_H_
+#define _SYS_FILE_H_
+
+#include <sys/types.h>
+#include <sys/vnode.h>
+
+struct vnode;
+
+/*
+ * File structure
+ */
+struct file {
+	int		f_flags;	/* open flag */
+	int		f_count;	/* reference count */
+	off_t		f_offset;	/* current position in file */
+	struct vnode	*f_vnode;	/* vnode */
+};
+typedef struct file *file_t;
+
+#endif /* !_SYS_FILE_H_ */
diff --git a/prex-0.9.0/include/sys/ioctl.h b/prex-0.9.0/include/sys/ioctl.h
new file mode 100755
index 0000000..5a4af95
--- /dev/null
+++ b/prex-0.9.0/include/sys/ioctl.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contibutors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_IOCTL_H_
+#define _SYS_IOCTL_H_
+
+#include <sys/cdefs.h>
+#include <sys/time.h>
+#include <sys/power.h>
+
+/*
+ * Ioctl's have the command encoded in the lower word, and the size of
+ * any in or out parameters in the upper word.  The high 3 bits of the
+ * upper word are used to encode the in/out status of the parameter.
+ */
+#define	IOCPARM_MASK	0xff		/* parameter length, at most 13 bits */
+#define	IOCPARM_LEN(x)	(((x) >> 16) & IOCPARM_MASK)
+#define	IOCBASECMD(x)	((x) & ~(IOCPARM_MASK << 16))
+#define	IOCGROUP(x)	(((x) >> 8) & 0xff)
+
+#define IOCPARM_MAX	256
+
+#define	IOC_VOID	0x20000000	/* no parameters */
+#define	IOC_OUT		0x40000000	/* copy out parameters */
+#define	IOC_IN		0x80000000U	/* copy in parameters */
+#define	IOC_INOUT	(IOC_IN|IOC_OUT)
+#define	IOC_DIRMASK	0xe0000000
+
+/* Prex */
+#define IOC_IVAL	0x10000000	/* input argument is immediate value */
+#define IOC_OVAL	0x08000000	/* return value as output */
+
+#define	_IOC(inout,group,num,len) \
+	(u_long)(inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
+#define	_IO(g,n)	_IOC(IOC_VOID,	(g), (n), 0)
+#define	_IOR(g,n,t)	_IOC(IOC_OUT,	(g), (n), sizeof(t))
+#define	_IOW(g,n,t)	_IOC(IOC_IN,	(g), (n), sizeof(t))
+/* this should be _IORW, but stdio got there first */
+#define	_IOWR(g,n,t)	_IOC(IOC_INOUT,	(g), (n), sizeof(t))
+
+#define	_IORN(g,n,t)	_IOC((IOC_OVAL|IOC_OUT), (g), (n), sizeof(t))
+#define	_IOWN(g,n,t)	_IOC((IOC_IVAL|IOC_IN),  (g), (n), sizeof(t))
+
+
+/*
+ * CPU frequency I/O control code
+ */
+#define CFIOC_GET_INFO		 _IOR('6', 0, struct cpufreqinfo)
+
+/*
+ * CPU frequency information
+ */
+struct cpufreqinfo {
+	int	maxfreq;	/* max speed in MHz */
+	int	maxvolts;	/* max power in mV */
+	int	freq;		/* current speed in MHz */
+	int	volts;		/* current power in mV */
+};
+
+/*
+ * Power management I/O control code
+ */
+#define PMIOC_CONNECT		 _IOW('P', 0, int)
+#define PMIOC_QUERY_EVENT	 _IOW('P', 1, int)
+#define PMIOC_SET_POWER		 _IOW('P', 2, int)
+#define PMIOC_GET_SUSTMR	 _IOR('P', 3, int)
+#define PMIOC_SET_SUSTMR	 _IOW('P', 4, int)
+#define PMIOC_GET_DIMTMR	 _IOR('P', 5, int)
+#define PMIOC_SET_DIMTMR	 _IOW('P', 6, int)
+#define PMIOC_GET_POLICY	 _IOR('P', 7, int)
+#define PMIOC_SET_POLICY	 _IOW('P', 8, int)
+
+/*
+ * RTC I/O control code
+ */
+#define RTCIOC_GET_TIME		 _IOR('R', 0, struct __timeval)
+#define RTCIOC_SET_TIME		 _IOW('R', 1, struct __timeval)
+
+struct __timeval {
+	long	tv_sec;		/* seconds */
+	long	tv_usec;	/* and microseconds */
+};
+
+__BEGIN_DECLS
+int	ioctl(int, unsigned long, ...);
+__END_DECLS
+
+#endif	/* !_SYS_IOCTL_H_ */
diff --git a/prex-0.9.0/include/sys/ipl.h b/prex-0.9.0/include/sys/ipl.h
new file mode 100755
index 0000000..a27d085
--- /dev/null
+++ b/prex-0.9.0/include/sys/ipl.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ipl.h - Interrupt priority level
+ */
+
+#ifndef _SYS_IPL_H
+#define _SYS_IPL_H
+#ifdef KERNEL
+
+/*
+ * Interrupt priority levels
+ */
+#define IPL_NONE	0	/* nothing (lowest) */
+#define IPL_COMM	1	/* serial, parallel */
+#define IPL_BLOCK	2	/* FDD, IDE */
+#define IPL_NET		3	/* network */
+#define IPL_DISPLAY	4	/* screen */
+#define IPL_INPUT	5	/* keyboard, mouse */
+#define IPL_AUDIO	6	/* audio */
+#define IPL_BUS		7	/* USB, PCCARD */
+#define IPL_RTC		8	/* RTC Alarm */
+#define IPL_PROFILE	9	/* profiling timer */
+#define IPL_CLOCK	10	/* system Clock Timer */
+#define IPL_HIGH	11	/* everything */
+
+#define NIPLS		12	/* number of IPLs */
+
+#endif /* !KERNEL */
+#endif /* !_SYS_IPL_H */
diff --git a/prex-0.9.0/include/sys/keycode.h b/prex-0.9.0/include/sys/keycode.h
new file mode 100755
index 0000000..034321c
--- /dev/null
+++ b/prex-0.9.0/include/sys/keycode.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Hardware independent key code for meta keys
+ */
+
+#ifndef _SYS_KEYCODE_H
+#define _SYS_KEYCODE_H
+
+#define K_CTRL		0x80
+#define K_SHFT		0x81
+#define K_ALT		0x82
+#define K_CAPS		0x83
+
+#define K_INS		0x84
+#define K_HOME		0x85
+#define K_END		0x86
+#define K_PGUP		0x87
+#define K_PGDN		0x88
+#define K_UP		0x89
+#define K_DOWN		0x8a
+#define K_LEFT		0x8b
+#define K_RGHT		0x8c
+
+#define K_F1		0x90
+#define K_F2		0x91
+#define K_F3		0x92
+#define K_F4		0x93
+#define K_F5		0x94
+#define K_F6		0x95
+#define K_F7		0x96
+#define K_F8		0x97
+#define K_F9		0x98
+#define K_F10		0x99
+#define K_F11		0x9a
+#define K_F12		0x9b
+
+#endif /* !_SYS_KEYCODE_H */
diff --git a/prex-0.9.0/include/sys/list.h b/prex-0.9.0/include/sys/list.h
new file mode 100755
index 0000000..3aa9104
--- /dev/null
+++ b/prex-0.9.0/include/sys/list.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_LIST_H_
+#define _SYS_LIST_H_
+
+#include <sys/cdefs.h>
+
+struct list {
+	struct list	*next;
+	struct list	*prev;
+};
+
+typedef struct list *list_t;
+
+#define list_init(head)		((head)->next = (head)->prev = (head))
+#define list_next(node)		((node)->next)
+#define list_prev(node)		((node)->prev)
+#define list_empty(head)	((head)->next == (head))
+#define list_first(head)	((head)->next)
+#define list_last(head)		((head)->prev)
+#define list_end(head, node)	((node) == (head))
+
+/*
+ * Get the struct for this entry
+ */
+#define list_entry(p, type, member) \
+    ((type *)((char *)(p) - (unsigned long)(&((type *)0)->member)))
+
+#define LIST_INIT(head) { &(head), &(head) }
+
+
+/*
+ * Insert new node after specified node
+ */
+static __inline void
+list_insert(list_t prev, list_t node)
+{
+	prev->next->prev = node;
+	node->next = prev->next;
+	node->prev = prev;
+	prev->next = node;
+}
+
+/*
+ * Remove specified node from list
+ */
+static __inline void
+list_remove(list_t node)
+{
+	node->prev->next = node->next;
+	node->next->prev = node->prev;
+}
+
+#endif /* !_SYS_LIST_H_ */
diff --git a/prex-0.9.0/include/sys/mount.h b/prex-0.9.0/include/sys/mount.h
new file mode 100755
index 0000000..8933e18
--- /dev/null
+++ b/prex-0.9.0/include/sys/mount.h
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 1989, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)mount.h	8.21 (Berkeley) 5/20/95
+ */
+
+#ifndef _SYS_MOUNT_H_
+#define _SYS_MOUNT_H_
+
+#include <sys/cdefs.h>
+#include <sys/list.h>
+#include <sys/vnode.h>
+#include <sys/syslimits.h>
+
+typedef struct { int32_t val[2]; } fsid_t;	/* file system id type */
+
+
+/*
+ * file system statistics
+ */
+struct statfs {
+	short	f_type;			/* filesystem type number */
+	short	f_flags;		/* copy of mount flags */
+	long	f_bsize;		/* fundamental file system block size */
+	long	f_blocks;		/* total data blocks in file system */
+	long	f_bfree;		/* free blocks in fs */
+	long	f_bavail;		/* free blocks avail to non-superuser */
+	long	f_files;		/* total file nodes in file system */
+	long	f_ffree;		/* free file nodes in fs */
+	fsid_t	f_fsid;			/* file system id */
+	long	f_namelen;		/* maximum filename length */
+};
+
+/*
+ * Mount data
+ */
+struct mount {
+	struct list	m_link;		/* link to next mount point */
+	struct vfsops	*m_op;		/* pointer to vfs operation */
+	int		m_flags;	/* mount flag */
+	int		m_count;	/* reference count */
+	char		m_path[PATH_MAX]; /* mounted path */
+	dev_t		m_dev;		/* mounted device */
+	struct vnode	*m_root;	/* root vnode */
+	struct vnode	*m_covered;	/* vnode covered on parent fs */
+	void		*m_data;	/* private data for fs */
+};
+typedef struct mount *mount_t;
+
+
+/*
+ * Mount flags.
+ *
+ * Unmount uses MNT_FORCE flag.
+ */
+#define	MNT_RDONLY	0x00000001	/* read only filesystem */
+#define	MNT_SYNCHRONOUS	0x00000002	/* file system written synchronously */
+#define	MNT_NOEXEC	0x00000004	/* can't exec from filesystem */
+#define	MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */
+#define	MNT_NODEV	0x00000010	/* don't interpret special files */
+#define	MNT_UNION	0x00000020	/* union with underlying filesystem */
+#define	MNT_ASYNC	0x00000040	/* file system written asynchronously */
+
+/*
+ * exported mount flags.
+ */
+#define	MNT_EXRDONLY	0x00000080	/* exported read only */
+#define	MNT_EXPORTED	0x00000100	/* file system is exported */
+#define	MNT_DEFEXPORTED	0x00000200	/* exported to the world */
+#define	MNT_EXPORTANON	0x00000400	/* use anon uid mapping for everyone */
+#define	MNT_EXKERB	0x00000800	/* exported with Kerberos uid mapping */
+
+/*
+ * Flags set by internal operations.
+ */
+#define	MNT_LOCAL	0x00001000	/* filesystem is stored locally */
+#define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */
+#define	MNT_ROOTFS	0x00004000	/* identifies the root filesystem */
+
+/*
+ * Mask of flags that are visible to statfs()
+ */
+#define	MNT_VISFLAGMASK	0x0000ffff
+
+/*
+ * Filesystem type switch table.
+ */
+struct vfssw {
+	char		*vs_name;	/* name of file system */
+	int		(*vs_init)(void); /* initialize routine */
+	struct vfsops	*vs_op;		/* pointer to vfs operation */
+};
+
+/*
+ * Operations supported on virtual file system.
+ */
+struct vfsops {
+	int (*vfs_mount)	(mount_t, char *, int, void *);
+	int (*vfs_unmount)	(mount_t);
+	int (*vfs_sync)		(mount_t);
+	int (*vfs_vget)		(mount_t, vnode_t);
+	int (*vfs_statfs)	(mount_t, struct statfs *);
+	struct vnops	*vfs_vnops;
+};
+
+typedef int (*vfsop_mount_t)(mount_t, char *, int, void *);
+typedef int (*vfsop_umount_t)(mount_t);
+typedef int (*vfsop_sync_t)(mount_t);
+typedef int (*vfsop_vget_t)(mount_t, vnode_t);
+typedef int (*vfsop_statfs_t)(mount_t, struct statfs *);
+
+/*
+ * VFS interface
+ */
+#define VFS_MOUNT(MP, DEV, FL, DAT) ((MP)->m_op->vfs_mount)(MP, DEV, FL, DAT)
+#define VFS_UNMOUNT(MP)             ((MP)->m_op->vfs_unmount)(MP)
+#define VFS_SYNC(MP)                ((MP)->m_op->vfs_sync)(MP)
+#define VFS_VGET(MP, VP)            ((MP)->m_op->vfs_vget)(MP, VP)
+#define VFS_STATFS(MP, SFP)         ((MP)->m_op->vfs_statfs)(MP, SFP)
+
+#define VFS_NULL		    ((void *)vfs_null)
+
+__BEGIN_DECLS
+int	mount(const char *, const char *, const char *, int, void *);
+int	umount(const char *);
+int	vfs_nullop(void);
+int	vfs_einval(void);
+__END_DECLS
+
+#endif	/* !_SYS_MOUNT_H_ */
diff --git a/prex-0.9.0/include/sys/param.h b/prex-0.9.0/include/sys/param.h
new file mode 100755
index 0000000..c49cd42
--- /dev/null
+++ b/prex-0.9.0/include/sys/param.h
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)param.h	8.3 (Berkeley) 4/4/95
+ */
+
+#ifndef _SYS_PARAM_H_
+#define _SYS_PARAM_H_
+
+#include <conf/config.h>
+
+#ifndef LOCORE
+#include <sys/types.h>
+#endif
+
+/*
+ * Machine-independent constants (some used in following include files).
+ * Redefined constants are from POSIX 1003.1 limits file.
+ */
+#include <sys/syslimits.h>
+
+#define	NCARGS		ARG_MAX		/* max bytes for an exec function */
+#define	NGROUPS		NGROUPS_MAX	/* max number groups */
+#define	NOFILE		OPEN_MAX	/* max open files per process */
+#define	NOGROUP		65535		/* marker for empty group set member */
+#define MAXHOSTNAMELEN	32		/* max hostname size */
+
+#define	MAXTASKS	256		/* max number of tasks in system */
+#define	MAXTHREADS	128		/* max number of threads per task */
+#define	MAXOBJECTS	32		/* max number of objects per task */
+#define	MAXSYNCS	512		/* max number of synch objects per task */
+#define MAXMEM		(4*1024*1024)	/* max core per task - first # is Mb */
+
+/* The following name length include a null-terminate character */
+#define MAXTASKNAME	12		/* max task name */
+#define MAXDEVNAME	12		/* max device name */
+#define MAXOBJNAME	16		/* max object name */
+#define MAXEVTNAME	12		/* max event name */
+
+#define HZ		CONFIG_HZ	/* ticks per second */
+#define MAXIRQS		32		/* max number of irq line */
+#define	PASSWORD_LEN	4		/* fixed length, not counting NULL */
+
+/*
+ * Priorities.
+ * Probably should not be altered too much.
+ */
+#define PRI_TIMER	15	/* priority for timer thread */
+#define PRI_IST	 	16	/* top priority for interrupt threads */
+#define PRI_DPC	 	33	/* priority for Deferred Procedure Call */
+#define PRI_IDLE	255	/* priority for idle thread */
+#define PRI_REALTIME	127	/* default priority for real-time thread */
+#define PRI_DEFAULT	200	/* default user priority */
+
+#define MAXPRI		0
+#define MINPRI		255
+#define NPRI		(MINPRI + 1)	/* number of thread priority */
+
+/* Server priorities */
+#define PRI_PROC	124	/* process server */
+#define PRI_EXEC	125	/* exec server */
+#define PRI_FS		126	/* file system server */
+#define PRI_POW		100	/* power server */
+
+#ifndef	NULL
+#if !defined(__cplusplus)
+#define	NULL	((void *)0)
+#else
+#define	NULL	0
+#endif
+#endif
+
+/* More types and definitions used throughout the kernel. */
+#ifdef KERNEL
+#include <sys/cdefs.h>
+#endif
+
+#ifndef KERNEL
+/* Signals. */
+#include <sys/signal.h>
+#endif
+
+#include <machine/limits.h>
+#include <machine/memory.h>
+
+#define KSTACKSZ	768		/* kernel stack size */
+
+#define USRSTACK	(0 + PAGE_SIZE)	/* base address of user stack */
+#define DFLSTKSZ	4096		/* default size of user stack */
+
+#ifdef CONFIG_MMU
+#define user_area(a)	((vaddr_t)(a) <  (vaddr_t)USERLIMIT)
+#else
+#define user_area(a)	1
+#endif
+
+/* Address translation between physical address and kernel viritul address */
+#define ptokv(pa)	(void *)((paddr_t)(pa) + KERNBASE)
+#define kvtop(va)	((paddr_t)(va) - KERNBASE)
+
+/*
+ * Round p (pointer or byte index) up to a correctly-aligned value for all
+ * data types (int, long, ...).   The result is u_long and must be cast to
+ * any desired pointer type.
+ */
+#define	_ALIGNBYTES	(sizeof(int) - 1)
+#define	ALIGN(p)	(((unsigned)(p) + _ALIGNBYTES) &~ _ALIGNBYTES)
+
+/*
+ * Memory page
+ */
+#define PAGE_MASK	(PAGE_SIZE-1)
+#define trunc_page(x)	((x) & ~PAGE_MASK)
+#define round_page(x)	(((x) + PAGE_MASK) & ~PAGE_MASK)
+
+/*
+ * MAXPATHLEN defines the longest permissable path length after expanding
+ * symbolic links. It is used to allocate a temporary buffer from the buffer
+ * pool in which to do the name expansion, hence should be a power of two,
+ * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
+ * maximum number of symbolic links that may be expanded in a path name.
+ * It should be set high enough to allow all legitimate uses, but halt
+ * infinite loops reasonably quickly.
+ */
+#define	MAXPATHLEN	PATH_MAX
+#define MAXSYMLINKS	8
+
+/* Bit map related macros. */
+#define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/* Macros for counting and rounding. */
+#ifndef howmany
+#define	howmany(x, y)	(((x)+((y)-1))/(y))
+#endif
+#define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
+#define rounddown(x,y)  (((x)/(y))*(y))
+#define powerof2(x)	((((x)-1)&(x))==0)
+
+/* Macros for min/max. */
+#define	MIN(a,b) (((a)<(b))?(a):(b))
+#define	MAX(a,b) (((a)>(b))?(a):(b))
+
+#define	BSIZE	512		/* size of secondary block (bytes) */
+
+/*
+ * Macro to convert milliseconds and tick.
+ */
+#define mstohz(ms)	(((ms) + 0UL) * HZ / 1000)
+
+#define hztoms(tick)	((tick) >= 0x20000 ? \
+			 (((tick) + 0u) / HZ) * 1000u : \
+			 (((tick) + 0u) * 1000u) / HZ)
+
+#endif /* !_SYS_PARAM_H_ */
diff --git a/prex-0.9.0/include/sys/posix.h b/prex-0.9.0/include/sys/posix.h
new file mode 100755
index 0000000..4e32c8f
--- /dev/null
+++ b/prex-0.9.0/include/sys/posix.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_POSIX_H
+#define _SYS_POSIX_H
+#ifndef KERNEL
+
+#include <sys/types.h>
+
+extern object_t __proc_obj;
+extern object_t __fs_obj;
+
+__BEGIN_DECLS
+int __posix_call(object_t, void *, size_t, int);
+__END_DECLS
+
+#endif	/* KERNEL */
+#endif	/* !_SYS_POSIX_H */
diff --git a/prex-0.9.0/include/sys/power.h b/prex-0.9.0/include/sys/power.h
new file mode 100755
index 0000000..439e528
--- /dev/null
+++ b/prex-0.9.0/include/sys/power.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_POWER_H
+#define _SYS_POWER_H
+
+#include <conf/config.h>
+
+/*
+ * Power policy
+ */
+#define PM_PERFORMANCE		0
+#define PM_POWERSAVE		1
+
+/*
+ * Power state
+ */
+#define PWR_ON			0
+#define PWR_SUSPEND		1
+#define PWR_OFF			2
+#define PWR_REBOOT		3
+
+/*
+ * Power management events
+ */
+#define PME_NO_EVENT		0
+#define PME_PWRBTN_PRESS	1
+#define PME_SLPBTN_PRESS	2
+#define PME_LCD_OPEN		3
+#define PME_LCD_CLOSE		4
+#define PME_AC_ATTACH		5
+#define PME_AC_DETACH		6
+#define PME_LOW_BATTERY		7
+#define PME_USER_ACTIVITY	8
+
+/*
+ * Default power policy
+ */
+#ifdef CONFIG_PM_POWERSAVE
+#define DEFAULT_POWER_POLICY	PM_POWERSAVE
+#else
+#define DEFAULT_POWER_POLICY	PM_PERFORMANCE
+#endif
+
+#endif	/* !_SYS_POWER_H */
diff --git a/prex-0.9.0/include/sys/prex.h b/prex-0.9.0/include/sys/prex.h
new file mode 100755
index 0000000..0c66d91
--- /dev/null
+++ b/prex-0.9.0/include/sys/prex.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_H
+#define _SYS_H
+#ifndef KERNEL
+
+#include <conf/config.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/sysinfo.h>
+#include <sys/capability.h>
+#include <sys/dbgctl.h>
+
+/*
+ * vm_option for task_crate()
+ */
+#define VM_NEW		0
+#define VM_SHARE	1
+#define VM_COPY		2
+
+/*
+ * protection flags for vm_attribute()
+ */
+#define	PROT_READ	0x1		/* pages can be read */
+#define	PROT_WRITE	0x2		/* pages can be written */
+#define	PROT_EXEC	0x4		/* pages can be executed */
+
+/*
+ * Device open mode for device_open()
+ */
+#define DO_RDONLY	0x0
+#define DO_WRONLY	0x1
+#define DO_RDWR		0x2
+#define DO_RWMASK	0x3
+
+/*
+ * Scheduling policy
+ */
+#define SCHED_FIFO	0	/* First In First Out */
+#define SCHED_RR	1	/* Round Robin */
+#define SCHED_OTHER	2	/* Other */
+
+/* Default exception handler */
+#define EXC_DFL		((void (*)(int)) -1)
+
+/*
+ * Synch initializer
+ */
+#define MUTEX_INITIALIZER	(mutex_t)0x4d496e69
+#define COND_INITIALIZER	(cond_t)0x43496e69
+
+
+__BEGIN_DECLS
+void	exception_return(void);
+int	exception_setup(void (*handler)(int));
+int	exception_raise(task_t task, int excno);
+int	exception_wait(int *excno);
+
+int	task_create(task_t parent, int vm_option, task_t *childp);
+int	task_terminate(task_t task);
+task_t	task_self(void);
+int	task_suspend(task_t task);
+int	task_resume(task_t task);
+int	task_setname(task_t task, const char *name);
+int	task_setcap(task_t task, cap_t cap);
+int	task_chkcap(task_t task, cap_t cap);
+
+int	thread_create(task_t task, thread_t *tp);
+int	thread_terminate(thread_t t);
+int	thread_load(thread_t t, void (*entry)(void), void *stack);
+thread_t thread_self(void);
+void	thread_yield(void);
+int	thread_suspend(thread_t t);
+int	thread_resume(thread_t t);
+int	thread_getpri(thread_t t, int *pri);
+int	thread_setpri(thread_t t, int	pri);
+int	thread_getpolicy(thread_t t, int *policy);
+int	thread_setpolicy(thread_t t, int policy);
+
+int	vm_allocate(task_t task, void **addr, size_t size, int anywhere);
+int	vm_free(task_t task, void *addr);
+int	vm_attribute(task_t task, void *addr, int prot);
+int	vm_map(task_t target, void  *addr, size_t size, void **alloc);
+
+int	object_create(const char *name, object_t *objp);
+int	object_destroy(object_t obj);
+int	object_lookup(const char *name, object_t *objp);
+
+int	msg_send(object_t obj, void *msg, size_t size);
+int	msg_receive(object_t obj, void *msg, size_t size);
+int	msg_reply(object_t obj, void *msg, size_t size);
+
+int	timer_sleep(u_long msec, u_long *remain);
+int	timer_alarm(u_long msec, u_long *remain);
+int	timer_periodic(thread_t t, u_long start, u_long period);
+int	timer_waitperiod(void);
+
+int	device_open(const char *name, int mode, device_t *dev);
+int	device_close(device_t dev);
+int	device_read(device_t dev, void *buf, size_t *nbyte, int blkno);
+int	device_write(device_t dev, void *buf, size_t *nbyte, int blkno);
+int	device_ioctl(device_t dev, u_long cmd, void *arg);
+
+int	mutex_init(mutex_t *mp);
+int	mutex_destroy(mutex_t *mp);
+int	mutex_trylock(mutex_t *mp);
+int	mutex_lock(mutex_t *mp);
+int	mutex_unlock(mutex_t *mp);
+
+int	cond_init(cond_t *cp);
+int	cond_destroy(cond_t *cp);
+int	cond_wait(cond_t *cp, mutex_t *mp);
+int	cond_signal(cond_t *cp);
+int	cond_broadcast(cond_t *cp);
+
+int	sem_init(sem_t *sp, u_int value);
+int	sem_destroy(sem_t *sp);
+int	sem_wait(sem_t *sp, u_long timeout);
+int	sem_trywait(sem_t *sp);
+int	sem_post(sem_t *sp);
+int	sem_getvalue(sem_t *sp, u_int *value);
+
+int	sys_log(const char *msg);
+void	sys_panic(const char *msg);
+int	sys_info(int type, void *buf);
+int	sys_time(u_long *ticks);
+int	sys_debug(int cmd, void *data);
+
+void	panic(const char *fmt, ...);
+void	dprintf(const char *fmt, ...);
+
+__END_DECLS
+
+#endif /* KERNEL */
+#endif /* !_SYS_H */
diff --git a/prex-0.9.0/include/sys/queue.h b/prex-0.9.0/include/sys/queue.h
new file mode 100755
index 0000000..772e750
--- /dev/null
+++ b/prex-0.9.0/include/sys/queue.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_QUEUE_H
+#define _SYS_QUEUE_H
+
+#include <sys/cdefs.h>
+
+struct queue {
+	struct queue   *next;
+	struct queue   *prev;
+};
+typedef struct queue *queue_t;
+
+#define queue_init(head)	((head)->next = (head)->prev = (head))
+#define queue_empty(head)	((head)->next == (head))
+#define queue_next(q)		((q)->next)
+#define queue_prev(q)		((q)->prev)
+#define queue_first(head)	((head)->next)
+#define queue_last(head)	((head)->prev)
+#define queue_end(head,q)	((q) == (head))
+
+/* Get the struct for this entry */
+#define queue_entry(q, type, member) \
+    ((type *)((char *)(q) - (unsigned long)(&((type *)0)->member)))
+
+__BEGIN_DECLS
+void	enqueue(queue_t, queue_t);
+queue_t	dequeue(queue_t);
+void	queue_insert(queue_t, queue_t);
+void	queue_remove(queue_t);
+__END_DECLS
+
+#endif /* !_SYS_QUEUE_H */
diff --git a/prex-0.9.0/include/sys/resource.h b/prex-0.9.0/include/sys/resource.h
new file mode 100755
index 0000000..9d664b8
--- /dev/null
+++ b/prex-0.9.0/include/sys/resource.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)resource.h	8.4 (Berkeley) 1/9/95
+ */
+
+#ifndef _SYS_RESOURCE_H_
+#define	_SYS_RESOURCE_H_
+
+/*
+ * Process priority specifications to get/setpriority.
+ */
+#define	PRIO_MIN	-20
+#define	PRIO_MAX	20
+
+#define	PRIO_PROCESS	0
+#define	PRIO_PGRP	1
+#define	PRIO_USER	2
+
+/*
+ * Resource limits
+ */
+#define	RLIMIT_CPU	0		/* cpu time in milliseconds */
+#define	RLIMIT_FSIZE	1		/* maximum file size */
+#define	RLIMIT_DATA	2		/* data size */
+#define	RLIMIT_STACK	3		/* stack size */
+#define	RLIMIT_CORE	4		/* core file size */
+#define	RLIMIT_RSS	5		/* resident set size */
+#define	RLIMIT_MEMLOCK	6		/* locked-in-memory address space */
+#define	RLIMIT_NPROC	7		/* number of processes */
+#define	RLIMIT_NOFILE	8		/* number of open files */
+
+#define	RLIM_NLIMITS	9		/* number of resource limits */
+
+#define	RLIM_INFINITY	(((u_long)1 << 31) - 1)
+
+struct rlimit {
+	rlim_t	rlim_cur;		/* current (soft) limit */
+	rlim_t	rlim_max;		/* maximum value for rlim_cur */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	getpriority(int, int);
+int	setpriority(int, int, int);
+int	getrlimit(int, struct rlimit *);
+int	setrlimit(int, const struct rlimit *);
+__END_DECLS
+
+#endif	/* !_SYS_RESOURCE_H_ */
diff --git a/prex-0.9.0/include/sys/signal.h b/prex-0.9.0/include/sys/signal.h
new file mode 100755
index 0000000..36650b2
--- /dev/null
+++ b/prex-0.9.0/include/sys/signal.h
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)signal.h	8.4 (Berkeley) 5/4/95
+ */
+
+#ifndef	_SYS_SIGNAL_H_
+#define	_SYS_SIGNAL_H_
+
+#define NSIG	32		/* counting 0; could be 33 (mask is 1-32) */
+
+#include <machine/signal.h>	/* sigcontext */
+
+#define	SIGHUP	1	/* hangup */
+#define	SIGINT	2	/* interrupt */
+#define	SIGQUIT	3	/* quit */
+#define	SIGILL	4	/* illegal instruction (not reset when caught) */
+#define	SIGTRAP	5	/* trace trap (not reset when caught) */
+#define	SIGABRT	6	/* abort() */
+#define	SIGIOT	SIGABRT	/* compatibility */
+#define	SIGEMT	7	/* EMT instruction */
+#define	SIGFPE	8	/* floating point exception */
+#define	SIGKILL	9	/* kill (cannot be caught or ignored) */
+#define	SIGBUS	10	/* bus error */
+#define	SIGSEGV	11	/* segmentation violation */
+#define	SIGSYS	12	/* bad argument to system call */
+#define	SIGPIPE	13	/* write on a pipe with no one to read it */
+#define	SIGALRM	14	/* alarm clock */
+#define	SIGTERM	15	/* software termination signal from kill */
+#define	SIGURG	16	/* urgent condition on IO channel */
+#define	SIGSTOP	17	/* sendable stop signal not from tty */
+#define	SIGTSTP	18	/* stop signal from tty */
+#define	SIGCONT	19	/* continue a stopped process */
+#define	SIGCHLD	20	/* to parent on child stop or exit */
+#define	SIGTTIN	21	/* to readers pgrp upon background tty read */
+#define	SIGTTOU	22	/* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define	SIGIO	23	/* input/output possible signal */
+#define	SIGXCPU	24	/* exceeded CPU time limit */
+#define	SIGXFSZ	25	/* exceeded file size limit */
+#define	SIGVTALRM 26	/* virtual time alarm */
+#define	SIGPROF	27	/* profiling time alarm */
+#define SIGWINCH 28	/* window size changes */
+#define SIGINFO	29	/* information request */
+#define SIGPWR	SIGINFO
+#define SIGUSR1 30	/* user defined signal 1 */
+#define SIGUSR2 31	/* user defined signal 2 */
+
+#ifndef KERNEL
+
+/*
+ * Language spec sez we must list exactly one parameter, even though we
+ * actually supply three.  Ugh!
+ */
+#define	SIG_DFL		((void (*)(int))  0)
+#define	SIG_IGN		((void (*)(int))  1)
+#define	SIG_ERR		((void (*)(int)) -1)
+
+typedef unsigned int sigset_t;
+
+union sigval {
+	int	sival_int;
+	void	*sival_ptr;
+};
+
+struct siginfo {
+	int	si_signo;	/* redundant signal number */
+	int	si_code;	/* facility that raised this signal */
+	union sigval si_value;	/* value that was queued with signal */
+};
+
+typedef struct siginfo siginfo_t;
+
+/*
+ * Signal vector "template" used in sigaction call.
+ */
+struct sigaction {
+	union {
+		void (*__sa_handler) (int);
+		void (*__sa_sigaction) (int, siginfo_t *, void *);
+	} __sigaction_u;
+	sigset_t sa_mask;
+	int sa_flags;
+};
+
+#define sa_handler      __sigaction_u.__sa_handler
+#define sa_sigaction    __sigaction_u.__sa_sigaction
+
+/* sa_flags bits */
+
+#define SA_ONSTACK	0x0001	/* take signal on signal stack */
+#define SA_RESTART	0x0002	/* restart system on signal return */
+#define	SA_DISABLE	0x0004	/* disable taking signals on alternate stack */
+#define SA_NOCLDSTOP	0x0008	/* do not generate SIGCHLD on child stop */
+#define SA_SIGINFO	0x0040	/* take sa_sigaction handler */
+
+/*
+ * Flags for sigprocmask:
+ */
+#define	SIG_BLOCK	1	/* block specified signal set */
+#define	SIG_UNBLOCK	2	/* unblock specified signal set */
+#define	SIG_SETMASK	3	/* set specified signal set */
+
+#include <sys/cdefs.h>
+
+typedef	void (*sig_t)(int);	/* type of signal function */
+
+/*
+ * Structure used in sigaltstack call.
+ */
+struct	sigaltstack {
+	char	*ss_base;		/* signal stack base */
+	int	ss_size;		/* signal stack length */
+	int	ss_flags;		/* SA_DISABLE and/or SA_ONSTACK */
+};
+#define	MINSIGSTKSZ	8192			/* minimum allowable stack */
+#define	SIGSTKSZ	(MINSIGSTKSZ + 32768)	/* recommended stack size */
+
+/*
+ * 4.3 compatibility:
+ * Signal vector "template" used in sigvec call.
+ */
+struct	sigvec {
+	void	(*sv_handler)(int);	/* signal handler */
+	int	sv_mask;		/* signal mask to apply */
+	int	sv_flags;		/* see signal options below */
+};
+
+#define SV_ONSTACK	SA_ONSTACK
+#define SV_INTERRUPT	SA_RESTART	/* same bit, opposite sense */
+#define sv_onstack sv_flags	/* isn't compatibility wonderful! */
+
+/*
+ * Structure used in sigstack call.
+ */
+struct	sigstack {
+	char	*ss_sp;			/* signal stack pointer */
+	int	ss_onstack;		/* current status */
+};
+
+/*
+ * Macro for converting signal number to a mask suitable for
+ * sigblock().
+ */
+#define sigmask(m)	(1 << ((m)-1))
+
+#define	BADSIG		SIG_ERR
+
+#ifdef _REENTRANT
+extern mutex_t __sig_lock;
+#define SIGNAL_LOCK()	mutex_lock(&__sig_lock)
+#define SIGNAL_UNLOCK()	mutex_unlock(&__sig_lock)
+#else
+#define SIGNAL_LOCK()
+#define SIGNAL_UNLOCK()
+#endif
+
+extern struct sigaction __sig_act[NSIG];
+extern sigset_t __sig_mask;
+extern sigset_t __sig_pending;
+
+/*
+ * For historical reasons; programs expect signal's return value to be
+ * defined by <sys/signal.h>.
+ */
+__BEGIN_DECLS
+void	(*signal(int, void (*)(int)))(int);
+int	__sig_flush(void);
+__END_DECLS
+
+#endif /* !KERNEL */
+#endif	/* !_SYS_SIGNAL_H_ */
diff --git a/prex-0.9.0/include/sys/stat.h b/prex-0.9.0/include/sys/stat.h
new file mode 100755
index 0000000..325f17a
--- /dev/null
+++ b/prex-0.9.0/include/sys/stat.h
@@ -0,0 +1,123 @@
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)stat.h	8.12 (Berkeley) 6/16/95
+ */
+
+#ifndef _SYS_STAT_H_
+#define	_SYS_STAT_H_
+
+#include <sys/time.h>
+
+struct stat {
+	dev_t	  st_dev;		/* inode's device */
+	ino_t	  st_ino;		/* inode's number */
+	mode_t	  st_mode;		/* inode protection mode */
+	nlink_t	  st_nlink;		/* number of hard links */
+	uid_t	  st_uid;		/* user ID of the file's owner */
+	gid_t	  st_gid;		/* group ID of the file's group */
+	dev_t	  st_rdev;		/* device type */
+	off_t	  st_size;		/* file size, in bytes */
+	time_t	  st_atime;		/* time of last access */
+	time_t	  st_mtime;		/* time of last data modification */
+	time_t	  st_ctime;		/* time of last file status change */
+	int32_t	  st_blocks;		/* blocks allocated for file */
+	uint32_t  st_blksize;		/* optimal blocksize for I/O */
+};
+
+#define	S_ISUID	0004000			/* set user id on execution */
+#define	S_ISGID	0002000			/* set group id on execution */
+#define	S_ISTXT	0001000			/* sticky bit */
+
+#define	S_IRWXU	0000700			/* RWX mask for owner */
+#define	S_IRUSR	0000400			/* R for owner */
+#define	S_IWUSR	0000200			/* W for owner */
+#define	S_IXUSR	0000100			/* X for owner */
+
+#define	S_IREAD		S_IRUSR
+#define	S_IWRITE	S_IWUSR
+#define	S_IEXEC		S_IXUSR
+
+#define	S_IRWXG	0000070			/* RWX mask for group */
+#define	S_IRGRP	0000040			/* R for group */
+#define	S_IWGRP	0000020			/* W for group */
+#define	S_IXGRP	0000010			/* X for group */
+
+#define	S_IRWXO	0000007			/* RWX mask for other */
+#define	S_IROTH	0000004			/* R for other */
+#define	S_IWOTH	0000002			/* W for other */
+#define	S_IXOTH	0000001			/* X for other */
+
+#define	S_IFMT	 0170000		/* type of file mask */
+#define	S_IFIFO	 0010000		/* named pipe (fifo) */
+#define	S_IFCHR	 0020000		/* character special */
+#define	S_IFDIR	 0040000		/* directory */
+#define	S_IFBLK	 0060000		/* block special */
+#define	S_IFREG	 0100000		/* regular */
+#define	S_IFLNK	 0120000		/* symbolic link */
+#define	S_IFSOCK 0140000		/* socket */
+#define	S_IFWHT  0160000		/* whiteout */
+#define	S_ISVTX	 0001000		/* save swapped text even after use */
+
+#define	S_ISDIR(m)	((m & 0170000) == 0040000)	/* directory */
+#define	S_ISCHR(m)	((m & 0170000) == 0020000)	/* char special */
+#define	S_ISBLK(m)	((m & 0170000) == 0060000)	/* block special */
+#define	S_ISREG(m)	((m & 0170000) == 0100000)	/* regular file */
+#define	S_ISFIFO(m)	((m & 0170000) == 0010000 || \
+			 (m & 0170000) == 0140000)	/* fifo or socket */
+#define	S_ISLNK(m)	((m & 0170000) == 0120000)	/* symbolic link */
+#define	S_ISSOCK(m)	((m & 0170000) == 0010000 || \
+			 (m & 0170000) == 0140000)	/* fifo or socket */
+#define	S_ISWHT(m)	((m & 0170000) == 0160000)	/* whiteout */
+
+#define	ACCESSPERMS	(S_IRWXU|S_IRWXG|S_IRWXO)	/* 0777 */
+							/* 7777 */
+#define	ALLPERMS	(mode_t)(S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
+							/* 0666 */
+#define	DEFFILEMODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
+
+#define S_BLKSIZE	512		/* block size used in the stat struct */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	chmod(const char *, mode_t);
+int	fstat(int, struct stat *);
+int	mkdir(const char *, mode_t);
+int	mkfifo(const char *, mode_t);
+int	stat(const char *, struct stat *);
+mode_t	umask(mode_t);
+int	lstat(const char *, struct stat *);
+__END_DECLS
+
+#endif /* !_SYS_STAT_H_ */
diff --git a/prex-0.9.0/include/sys/sysinfo.h b/prex-0.9.0/include/sys/sysinfo.h
new file mode 100755
index 0000000..9971b0f
--- /dev/null
+++ b/prex-0.9.0/include/sys/sysinfo.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2007-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H
+
+#include <sys/param.h>
+#include <sys/utsname.h>
+#include <sys/capability.h>
+#include <sys/device.h>
+
+/*
+ * Max size of info buffer.
+ *
+ * Please make sure MAXINFOSZ is still correct if you change
+ * the information structure below.
+ */
+#define MAXINFOSZ	sizeof(struct kerninfo)
+
+/*
+ * Data type for sys_info()
+ */
+#define INFO_KERNEL	1
+#define INFO_MEMORY	2
+#define INFO_TIMER	3
+#define INFO_THREAD	4
+#define INFO_TASK	5
+#define INFO_VM		6
+#define INFO_DEVICE	7
+#define INFO_IRQ	8
+
+/*
+ * Kernel information
+ * Note: must be same with struct utsname.
+ */
+struct kerninfo {
+	char	sysname[_SYS_NMLN];	/* name of this OS. */
+	char	nodename[_SYS_NMLN];	/* name of this network node. */
+	char	release[_SYS_NMLN];	/* release level. */
+	char	version[_SYS_NMLN];	/* version level. */
+	char	machine[_SYS_NMLN];	/* hardware type. */
+};
+
+/*
+ * Memory information
+ */
+struct meminfo {
+	psize_t		total;		/* total memory size in bytes */
+	psize_t		free;		/* current free memory in bytes */
+	psize_t		bootdisk;	/* total size of boot disk */
+};
+
+/*
+ * Thread information
+ */
+struct threadinfo {
+	u_long		cookie;		/* index cookie */
+	thread_t	id;		/* thread id */
+	int		state;		/* thread state */
+	int		policy;		/* scheduling policy */
+	int		priority;	/* current priority */
+	int		basepri;	/* base priority */
+	u_int		time;		/* total running time */
+	int		suscnt;		/* suspend count */
+	task_t		task;		/* task id */
+	int		active;		/* true if active thread */
+	char		taskname[MAXTASKNAME];	/* task name */
+	char		slpevt[MAXEVTNAME];	/* sleep event */
+};
+
+/*
+ * Task information
+ */
+struct taskinfo {
+	u_long		cookie;		/* index cookie */
+	task_t		id;		/* task id */
+	int		flags;		/* task flags */
+	int		suscnt;		/* suspend count */
+	cap_t		capability;	/* security permission flag */
+	size_t		vmsize;		/* used memory size */
+	int		nthreads;	/* number of threads */
+	int		active;		/* true if active task */
+	char		taskname[MAXTASKNAME];	/* task name */
+};
+
+/*
+ * VM information
+ */
+struct vminfo {
+	u_long		cookie;		/* index cookie */
+	task_t		task;		/* task id */
+	vaddr_t		virt;		/* virtual address */
+	size_t		size;		/* size */
+	int		flags;		/* region flag */
+	paddr_t		phys;		/* physical address */
+};
+
+/* Flags for vm */
+#define VF_READ		0x00000001
+#define VF_WRITE	0x00000002
+#define VF_EXEC		0x00000004
+#define VF_SHARED	0x00000008
+#define VF_MAPPED	0x00000010
+#define VF_FREE		0x00000080
+
+/*
+ * Device information
+ */
+struct devinfo {
+	u_long		cookie;		/* index cookie */
+	device_t	id;		/* device id */
+	int	 	flags;		/* device characteristics flags */
+	char	 	name[MAXDEVNAME]; /* device name */
+};
+
+/*
+ * Timer informations
+ */
+struct timerinfo {
+	int		hz;		/* clock frequency */
+	u_long		cputicks;	/* total cpu ticks since boot */
+	u_long		idleticks;	/* total idle ticks */
+};
+
+/*
+ * IRQ information
+ */
+struct irqinfo {
+	int		cookie;		/* index cookie */
+	int		vector;		/* vector number */
+	u_int		count;		/* interrupt count */
+	int		priority;	/* interrupt priority */
+	int		istreq;		/* pending ist request */
+	thread_t	thread;		/* thread id of ist */
+};
+
+#endif /* !_SYS_SYSINFO_H */
diff --git a/prex-0.9.0/include/sys/syslimits.h b/prex-0.9.0/include/sys/syslimits.h
new file mode 100755
index 0000000..bc1e559
--- /dev/null
+++ b/prex-0.9.0/include/sys/syslimits.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)syslimits.h	8.1 (Berkeley) 6/2/93
+ */
+#include <conf/config.h>
+
+#ifndef _SYS_SYSLIMITS_H_
+#define _SYS_SYSLIMITS_H_
+
+#define	ARG_MAX			  255	/* max bytes for an exec function */
+#define	MAX_INPUT		  128	/* max bytes in terminal input */
+#define	NAME_MAX		   64	/* max bytes in a file name */
+#define	NGROUPS_MAX		   16	/* max supplemental group id's */
+#define	OPEN_MAX      CONFIG_OPEN_MAX	/* max open files per process */
+#define	PATH_MAX		  256	/* max bytes in pathname (include null)*/
+#define	PIPE_BUF		 1024	/* max bytes for atomic pipe writes */
+#define	LINE_MAX		  256	/* max bytes in an input line */
+
+#endif
diff --git a/prex-0.9.0/include/sys/syslog.h b/prex-0.9.0/include/sys/syslog.h
new file mode 100755
index 0000000..cb71f76
--- /dev/null
+++ b/prex-0.9.0/include/sys/syslog.h
@@ -0,0 +1,117 @@
+/*-
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)syslog.h	8.1 (Berkeley) 6/2/93
+ */
+
+/*
+ * priorities/facilities are encoded into a single 32-bit quantity, where the
+ * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
+ * (0-big number).  Both the priorities and the facilities map roughly
+ * one-to-one to strings in the syslogd(8) source code.  This mapping is
+ * included in this file.
+ *
+ * priorities (these are ordered)
+ */
+#define	LOG_EMERG	0	/* system is unusable */
+#define	LOG_ALERT	1	/* action must be taken immediately */
+#define	LOG_CRIT	2	/* critical conditions */
+#define	LOG_ERR		3	/* error conditions */
+#define	LOG_WARNING	4	/* warning conditions */
+#define	LOG_NOTICE	5	/* normal but significant condition */
+#define	LOG_INFO	6	/* informational */
+#define	LOG_DEBUG	7	/* debug-level messages */
+
+#define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
+				/* extract priority */
+#define	LOG_PRI(p)	((p) & LOG_PRIMASK)
+#define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
+
+
+/* facility codes */
+#define	LOG_KERN	(0<<3)	/* kernel messages */
+#define	LOG_USER	(1<<3)	/* random user-level messages */
+#define	LOG_MAIL	(2<<3)	/* mail system */
+#define	LOG_DAEMON	(3<<3)	/* system daemons */
+#define	LOG_AUTH	(4<<3)	/* security/authorization messages */
+#define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
+#define	LOG_LPR		(6<<3)	/* line printer subsystem */
+#define	LOG_NEWS	(7<<3)	/* network news subsystem */
+#define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
+#define	LOG_CRON	(9<<3)	/* clock daemon */
+#define	LOG_AUTHPRIV	(10<<3)	/* security/authorization messages (private) */
+#define	LOG_FTP		(11<<3)	/* ftp daemon */
+
+/* other codes through 15 reserved for system use */
+#define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
+#define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
+#define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
+#define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
+#define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
+#define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
+#define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
+#define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
+
+#define	LOG_NFACILITIES	24	/* current number of facilities */
+#define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
+				/* facility of pri */
+#define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
+
+/*
+ * arguments to setlogmask.
+ */
+#define	LOG_MASK(pri)	(1 << (pri))		/* mask for one priority */
+#define	LOG_UPTO(pri)	((1 << ((pri)+1)) - 1)	/* all priorities through pri */
+
+/*
+ * Option flags for openlog.
+ *
+ * LOG_ODELAY no longer does anything.
+ * LOG_NDELAY is the inverse of what it used to be.
+ */
+#define	LOG_PID		0x01	/* log the pid with each message */
+#define	LOG_CONS	0x02	/* log on the console if errors in sending */
+#define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
+#define	LOG_NDELAY	0x08	/* don't delay open */
+#define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
+#define	LOG_PERROR	0x20	/* log to stderr as well */
+
+#ifndef KERNEL
+
+#include <machine/stdarg.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	closelog(void);
+void	openlog(const char *, int, int);
+int	setlogmask(int);
+void	syslog(int, const char *, ...);
+void	vsyslog(int, const char *, va_list);
+__END_DECLS
+
+#endif /* !KERNEL */
diff --git a/prex-0.9.0/include/sys/termios.h b/prex-0.9.0/include/sys/termios.h
new file mode 100755
index 0000000..6f9dc92
--- /dev/null
+++ b/prex-0.9.0/include/sys/termios.h
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 1988, 1989, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)termios.h	8.3 (Berkeley) 3/28/94
+ */
+
+#ifndef _SYS_TERMIOS_H_
+#define _SYS_TERMIOS_H_
+
+#include <sys/ioctl.h>
+
+/*
+ * Special Control Characters
+ *
+ * Index into c_cc[] character array.
+ *
+ *	Name	     Subscript	Enabled by
+ */
+#define	VEOF		0	/* ICANON */
+#define	VEOL		1	/* ICANON */
+#define	VEOL2		2	/* ICANON */
+#define	VERASE		3	/* ICANON */
+#define VWERASE 	4	/* ICANON */
+#define VKILL		5	/* ICANON */
+#define	VREPRINT 	6	/* ICANON */
+/*			7	   spare 1 */
+#define VINTR		8	/* ISIG */
+#define VQUIT		9	/* ISIG */
+#define VSUSP		10	/* ISIG */
+#define VDSUSP		11	/* ISIG */
+#define VSTART		12	/* IXON, IXOFF */
+#define VSTOP		13	/* IXON, IXOFF */
+#define	VLNEXT		14	/* IEXTEN */
+#define	VDISCARD	15	/* IEXTEN */
+#define VMIN		16	/* !ICANON */
+#define VTIME		17	/* !ICANON */
+#define VSTATUS		18	/* ICANON */
+#define VDDB		19	/* Prex: debugger key */
+#define	NCCS		20
+
+#define _POSIX_VDISABLE	((unsigned char)'\377')
+
+#define CCEQ(val, c)	(c == val ? val != _POSIX_VDISABLE : 0)
+
+/*
+ * Input flags - software input processing
+ */
+#define	IGNBRK		0x00000001	/* ignore BREAK condition */
+#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
+#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
+#define	PARMRK		0x00000008	/* mark parity and framing errors */
+#define	INPCK		0x00000010	/* enable checking of parity errors */
+#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
+#define	INLCR		0x00000040	/* map NL into CR */
+#define	IGNCR		0x00000080	/* ignore CR */
+#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
+#define	IXON		0x00000200	/* enable output flow control */
+#define	IXOFF		0x00000400	/* enable input flow control */
+#define	IXANY		0x00000800	/* any char will restart after stop */
+#define IMAXBEL		0x00002000	/* ring bell on input queue full */
+
+/*
+ * Output flags - software output processing
+ */
+#define	OPOST		0x00000001	/* enable following output processing */
+#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
+#define OXTABS		0x00000004	/* expand tabs to spaces */
+#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
+
+/*
+ * Control flags - hardware control of terminal
+ */
+#define	CIGNORE		0x00000001	/* ignore control flags */
+#define CSIZE		0x00000300	/* character size mask */
+#define     CS5		    0x00000000	    /* 5 bits (pseudo) */
+#define     CS6		    0x00000100	    /* 6 bits */
+#define     CS7		    0x00000200	    /* 7 bits */
+#define     CS8		    0x00000300	    /* 8 bits */
+#define CSTOPB		0x00000400	/* send 2 stop bits */
+#define CREAD		0x00000800	/* enable receiver */
+#define PARENB		0x00001000	/* parity enable */
+#define PARODD		0x00002000	/* odd parity, else even */
+#define HUPCL		0x00004000	/* hang up on last close */
+#define CLOCAL		0x00008000	/* ignore modem status lines */
+#define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
+#define CRTSCTS		CCTS_OFLOW	/* ??? */
+#define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
+#define	MDMBUF		0x00100000	/* flow control output via Carrier */
+
+/*
+ * "Local" flags - dumping ground for other state
+ *
+ * Warning: some flags in this structure begin with
+ * the letter "I" and look like they belong in the
+ * input flag.
+ */
+
+#ifndef _POSIX_SOURCE
+#define	ECHOKE		0x00000001	/* visual erase for line kill */
+#endif  /*_POSIX_SOURCE */
+#define	ECHOE		0x00000002	/* visually erase chars */
+#define	ECHOK		0x00000004	/* echo NL after line kill */
+#define ECHO		0x00000008	/* enable echoing */
+#define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
+#ifndef _POSIX_SOURCE
+#define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
+#define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
+#endif  /*_POSIX_SOURCE */
+#define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
+#define	ICANON		0x00000100	/* canonicalize input lines */
+#ifndef _POSIX_SOURCE
+#define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
+#endif  /*_POSIX_SOURCE */
+#define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
+#define EXTPROC         0x00000800      /* external processing */
+#define TOSTOP		0x00400000	/* stop background jobs from output */
+#ifndef _POSIX_SOURCE
+#define FLUSHO		0x00800000	/* output being flushed (state) */
+#define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
+#define PENDIN		0x20000000	/* XXX retype pending input (state) */
+#endif  /*_POSIX_SOURCE */
+#define	NOFLSH		0x80000000	/* don't flush after interrupt */
+
+typedef unsigned long	tcflag_t;
+typedef unsigned char	cc_t;
+typedef long		speed_t;
+
+struct termios {
+	tcflag_t	c_iflag;	/* input flags */
+	tcflag_t	c_oflag;	/* output flags */
+	tcflag_t	c_cflag;	/* control flags */
+	tcflag_t	c_lflag;	/* local flags */
+	cc_t		c_cc[NCCS];	/* control chars */
+	long		c_ispeed;	/* input speed */
+	long		c_ospeed;	/* output speed */
+};
+
+/*
+ * Commands passed to tcsetattr() for setting the termios structure.
+ */
+#define	TCSANOW		0		/* make change immediate */
+#define	TCSADRAIN	1		/* drain output, then change */
+#define	TCSAFLUSH	2		/* drain output, flush input */
+#ifndef _POSIX_SOURCE
+#define TCSASOFT	0x10		/* flag - don't alter h.w. state */
+#endif
+
+/*
+ * Standard speeds
+ */
+#define B0	0
+#define B50	50
+#define B75	75
+#define B110	110
+#define B134	134
+#define B150	150
+#define B200	200
+#define B300	300
+#define B600	600
+#define B1200	1200
+#define	B1800	1800
+#define B2400	2400
+#define B4800	4800
+#define B9600	9600
+#define B19200	19200
+#define B38400	38400
+
+#ifndef KERNEL
+
+#define	TCIFLUSH	1
+#define	TCOFLUSH	2
+#define TCIOFLUSH	3
+#define	TCOOFF		1
+#define	TCOON		2
+#define TCIOFF		3
+#define TCION		4
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+speed_t	cfgetispeed(const struct termios *);
+speed_t	cfgetospeed(const struct termios *);
+int	cfsetispeed(struct termios *, speed_t);
+int	cfsetospeed(struct termios *, speed_t);
+int	tcgetattr(int, struct termios *);
+int	tcsetattr(int, int, const struct termios *);
+int	tcdrain(int);
+int	tcflow(int, int);
+int	tcflush(int, int);
+int	tcsendbreak(int, int);
+
+#ifndef _POSIX_SOURCE
+void	cfmakeraw(struct termios *);
+int	cfsetspeed(struct termios *, speed_t);
+#endif /* !_POSIX_SOURCE */
+__END_DECLS
+
+#endif /* !KERNEL */
+
+
+/*
+ * Tty ioctl's except for those supported only for backwards compatibility
+ * with the old tty driver.
+ */
+
+/*
+ * Window/terminal size structure.  This information is stored by the kernel
+ * in order to provide a consistent interface, but is not used by the kernel.
+ */
+struct winsize {
+	unsigned short	ws_row;		/* rows, in characters */
+	unsigned short	ws_col;		/* columns, in characters */
+	unsigned short	ws_xpixel;	/* horizontal size, pixels */
+	unsigned short	ws_ypixel;	/* vertical size, pixels */
+};
+
+#define	TIOCEXCL	 _IO('t', 13)		/* set exclusive use of tty */
+#define	TIOCNXCL	 _IO('t', 14)		/* reset exclusive use of tty */
+						/* 15 unused */
+#define	TIOCFLUSH	_IOW('t', 16, int)	/* flush buffers */
+						/* 17-18 compat */
+#define	TIOCGETA	_IOR('t', 19, struct termios) /* get termios struct */
+#define	TIOCSETA	_IOW('t', 20, struct termios) /* set termios struct */
+#define	TIOCSETAW	_IOW('t', 21, struct termios) /* drain output, set */
+#define	TIOCSETAF	_IOW('t', 22, struct termios) /* drn out, fls in, set */
+#define	TIOCGETD	_IOR('t', 26, int)	/* get line discipline */
+#define	TIOCSETD	_IOW('t', 27, int)	/* set line discipline */
+						/* 127-124 compat */
+#define	TIOCSBRK	 _IO('t', 123)		/* set break bit */
+#define	TIOCCBRK	 _IO('t', 122)		/* clear break bit */
+#define	TIOCSDTR	 _IO('t', 121)		/* set data terminal ready */
+#define	TIOCCDTR	 _IO('t', 120)		/* clear data terminal ready */
+#define	TIOCGPGRP	_IOR('t', 119, int)	/* get pgrp of tty */
+#define	TIOCSPGRP	_IOW('t', 118, int)	/* set pgrp of tty */
+						/* 117-116 compat */
+#define	TIOCOUTQ	_IOR('t', 115, int)	/* output queue size */
+#define	TIOCSTI		_IOW('t', 114, char)	/* simulate terminal input */
+#define	TIOCNOTTY	 _IO('t', 113)		/* void tty association */
+
+#define	TIOCSTOP	 _IO('t', 111)		/* stop output, like ^S */
+#define	TIOCSTART	 _IO('t', 110)		/* start output, like ^Q */
+#define	TIOCMSET	_IOW('t', 109, int)	/* set all modem bits */
+#define	TIOCMBIS	_IOW('t', 108, int)	/* bis modem bits */
+#define	TIOCMBIC	_IOW('t', 107, int)	/* bic modem bits */
+#define	TIOCMGET	_IOR('t', 106, int)	/* get all modem bits */
+#define	TIOCGWINSZ	_IOR('t', 104, struct winsize)	/* get window size */
+#define	TIOCSWINSZ	_IOW('t', 103, struct winsize)	/* set window size */
+#define		UIOCCMD(n)	_IO('u', n)	/* usr cntl op "n" */
+#define	TIOCCONS	_IOW('t', 98, int)	/* become virtual console */
+#define	TIOCSCTTY	 _IO('t', 97)		/* become controlling tty */
+#define	TIOCDRAIN	 _IO('t', 94)		/* wait till output drained */
+
+#define	TTYDISC		0		/* termios tty line discipline */
+#define	TABLDISC	3		/* tablet discipline */
+#define	SLIPDISC	4		/* serial IP discipline */
+
+/* Prex unique */
+#define	TIOCSETSIGT	_IOW('t', 200, int)	/* set signal task */
+#define TIOCINQ		_IOR('t', 201, int)	/* input queue size */
+
+/*
+ * Defaults on "first" open.
+ */
+#define	TTYDEF_IFLAG	(tcflag_t)(BRKINT | ICRNL | IXON | IXANY)
+#define TTYDEF_OFLAG	(tcflag_t)(OPOST | ONLCR | OXTABS)
+#define TTYDEF_LFLAG	(tcflag_t)(ECHO | ICANON | ISIG | ECHOE|ECHOK|ECHONL)
+#define TTYDEF_CFLAG	(tcflag_t)(CREAD | CS8 | HUPCL)
+#define TTYDEF_SPEED	(B9600)
+
+/*
+ * Control Character Defaults
+ */
+#define CTRL(x)	(cc_t)(x&037)
+#define	CEOF		CTRL('d')
+#define	CEOL		((unsigned char)'\377')	/* XXX avoid _POSIX_VDISABLE */
+#define	CERASE		0177
+#define	CINTR		CTRL('c')
+#define	CSTATUS		((unsigned char)'\377')	/* XXX avoid _POSIX_VDISABLE */
+#define	CKILL		CTRL('u')
+#define	CMIN		1
+#define	CQUIT		034		/* FS, ^\ */
+#define	CSUSP		CTRL('z')
+#define	CTIME		0
+#define	CDSUSP		CTRL('y')
+#define	CSTART		CTRL('q')
+#define	CSTOP		CTRL('s')
+#define	CLNEXT		CTRL('v')
+#define	CDISCARD 	CTRL('o')
+#define	CWERASE 	CTRL('w')
+#define	CREPRINT 	CTRL('r')
+#define	CEOT		CEOF
+/* compat */
+#define	CBRK		CEOL
+#define CRPRNT		CREPRINT
+#define	CFLUSH		CDISCARD
+#define	CKDB		CTRL('k')
+
+#ifdef KERNEL
+/*
+ * #define TTYDEFCHARS to include an array of default control characters.
+ */
+#define TTYDEFCHARS \
+{ \
+	CEOF,	CEOL,	CEOL,	CERASE, CWERASE, CKILL, CREPRINT, \
+	_POSIX_VDISABLE, CINTR,	CQUIT,	CSUSP,	CDSUSP,	CSTART,	CSTOP,	CLNEXT, \
+	CDISCARD, CMIN,	CTIME,  CSTATUS, CKDB \
+}
+#endif /* KERNEL */
+
+/*
+ * END OF PROTECTED INCLUDE.
+ */
+#endif /* !_SYS_TERMIOS_H_ */
diff --git a/prex-0.9.0/include/sys/time.h b/prex-0.9.0/include/sys/time.h
new file mode 100755
index 0000000..c5152c1
--- /dev/null
+++ b/prex-0.9.0/include/sys/time.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.5 (Berkeley) 5/4/95
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#include <sys/types.h>
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+	long	tv_sec;		/* seconds */
+	long	tv_usec;	/* and microseconds */
+};
+
+/*
+ * Structure defined by POSIX.4 to be like a timeval.
+ */
+struct timespec {
+	time_t	ts_sec;		/* seconds */
+	long	ts_nsec;	/* and nanoseconds */
+};
+
+#define	TIMEVAL_TO_TIMESPEC(tv, ts) {					\
+	(ts)->ts_sec = (tv)->tv_sec;					\
+	(ts)->ts_nsec = (tv)->tv_usec * 1000;				\
+}
+#define	TIMESPEC_TO_TIMEVAL(tv, ts) {					\
+	(tv)->tv_sec = (ts)->ts_sec;					\
+	(tv)->tv_usec = (ts)->ts_nsec / 1000;				\
+}
+
+struct timezone {
+	int	tz_minuteswest;	/* minutes west of Greenwich */
+	int	tz_dsttime;	/* type of dst correction */
+};
+
+#define	DST_NONE	0	/* not on dst */
+#define	DST_USA		1	/* USA style dst */
+#define	DST_AUST	2	/* Australian style dst */
+#define	DST_WET		3	/* Western European dst */
+#define	DST_MET		4	/* Middle European dst */
+#define	DST_EET		5	/* Eastern European dst */
+#define	DST_CAN		6	/* Canada */
+
+/* Operations on timevals. */
+#define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
+#define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
+#define	timercmp(tvp, uvp, cmp)						\
+	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
+	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
+	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
+
+/*
+ * Names of the interval timers, and structure
+ * defining a timer setting.
+ */
+#define	ITIMER_REAL	0
+#define	ITIMER_VIRTUAL	1
+#define	ITIMER_PROF	2
+
+struct	itimerval {
+	struct	timeval it_interval;	/* timer interval */
+	struct	timeval it_value;	/* current value */
+};
+
+/*
+ * Getkerninfo clock information structure
+ */
+struct clockinfo {
+	int	hz;		/* clock frequency */
+	int	tick;		/* micro-seconds per hz tick */
+	int	stathz;		/* statistics clock frequency */
+	int	profhz;		/* profiling clock frequency */
+};
+
+#ifndef KERNEL
+#include <time.h>
+
+#ifndef _POSIX_SOURCE
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	gettimeofday(struct timeval *, struct timezone *);
+#if 0
+int	adjtime(const struct timeval *, struct timeval *);
+int	getitimer(int, struct itimerval *);
+int	setitimer(int, const struct itimerval *, struct itimerval *);
+int	settimeofday(const struct timeval *, const struct timezone *);
+int	utimes(const char *, const struct timeval *);
+#endif
+__END_DECLS
+#endif /* !POSIX */
+#endif /* !KERNEL */
+
+
+#endif /* !_SYS_TIME_H_ */
diff --git a/prex-0.9.0/include/sys/types.h b/prex-0.9.0/include/sys/types.h
new file mode 100755
index 0000000..f5e682b
--- /dev/null
+++ b/prex-0.9.0/include/sys/types.h
@@ -0,0 +1,133 @@
+/*-
+ * Copyright (c) 1982, 1986, 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)types.h	8.6 (Berkeley) 2/19/95
+ */
+
+#ifndef _SYS_TYPES_H_
+#define	_SYS_TYPES_H_
+
+/* Machine type dependent parameters. */
+#include <machine/types.h>
+
+typedef	unsigned char	u_char;
+typedef	unsigned short	u_short;
+typedef	unsigned int	u_int;
+typedef	unsigned long	u_long;
+
+typedef	uint32_t	dev_t;		/* device number */
+typedef	uint32_t	gid_t;		/* group id */
+typedef	uint32_t	ino_t;		/* inode number */
+typedef	uint32_t	mode_t;		/* permissions */
+typedef	uint32_t	nlink_t;	/* link count */
+typedef	int32_t		off_t;		/* file offset */
+typedef	int32_t		pid_t;		/* process id */
+typedef	uint32_t	uid_t;		/* user id */
+typedef unsigned long	rlim_t;		/* resource limit */
+
+#ifndef KERNEL
+typedef unsigned long	object_t;
+typedef unsigned long	task_t;
+typedef unsigned long	thread_t;
+typedef unsigned long	mutex_t;
+typedef unsigned long	cond_t;
+typedef unsigned long	sem_t;
+typedef unsigned long	device_t;
+#endif /* KERNEL */
+
+#define OBJECT_NULL	((object_t)0)
+#define TASK_NULL	  ((task_t)0)
+#define THREAD_NULL	((thread_t)0)
+#define MUTEX_NULL	 ((mutex_t)0)
+#define COND_NULL	  ((cond_t)0)
+#define SEM_NULL	   ((sem_t)0)
+#define NODEV		((device_t)0)
+
+#ifdef KERNEL
+typedef void (*dkifn_t)(void);
+#endif
+
+#include <sys/endian.h>
+
+#if !defined(_CLOCK_T)
+#define _CLOCK_T
+typedef	unsigned long	clock_t;	/* relative time in a specified resolution */
+#endif
+
+#if !defined(_SIZE_T)
+#define _SIZE_T
+typedef	unsigned int	size_t;		/* size of something in bytes */
+#endif
+
+#if !defined(_SSIZE_T)
+#define _SSIZE_T
+typedef	int		ssize_t;	/* size of something in bytes */
+#endif
+
+#if !defined(_TIME_T)
+#define _TIME_T
+typedef	long		time_t;		/* time of day in seconds */
+#endif
+
+#define	NBBY	8		/* number of bits in a byte */
+
+#ifndef KERNEL
+/*
+ * Select uses bit masks of file descriptors in longs.  These macros
+ * manipulate such bit fields (the filesystem macros use chars).
+ * FD_SETSIZE may be defined by the user, but the default here should
+ * be enough for most uses.
+ */
+#ifndef	FD_SETSIZE
+#define	FD_SETSIZE	16
+#endif
+
+typedef int32_t	fd_mask;
+#define NFDBITS	(sizeof(fd_mask) * NBBY)	/* bits per mask */
+
+#ifndef howmany
+#define	howmany(x, y)	(((x) + ((y) - 1)) / (y))
+#endif
+
+typedef	struct fd_set {
+	fd_mask	fds_bits[howmany(FD_SETSIZE, NFDBITS)];
+} fd_set;
+
+#define	FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define	FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define	FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define	FD_COPY(f, t)	bcopy(f, t, sizeof(*(f)))
+#define	FD_ZERO(p)	bzero(p, sizeof(*(p)))
+#endif /* !KERNEL */
+
+#endif /* !_SYS_TYPES_H_ */
diff --git a/prex-0.9.0/include/sys/utsname.h b/prex-0.9.0/include/sys/utsname.h
new file mode 100755
index 0000000..4b2d23a
--- /dev/null
+++ b/prex-0.9.0/include/sys/utsname.h
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chuck Karish of Mindcraft, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)utsname.h	8.1 (Berkeley) 1/4/94
+ */
+
+#ifndef	_SYS_UTSNAME_H_
+#define	_SYS_UTSNAME_H_
+
+#define _SYS_NMLN	16
+
+struct utsname {
+	char	sysname[_SYS_NMLN];	/* name of this OS. */
+	char	nodename[_SYS_NMLN];	/* name of this network node. */
+	char	release[_SYS_NMLN];	/* release level. */
+	char	version[_SYS_NMLN];	/* version level. */
+	char	machine[_SYS_NMLN];	/* hardware type. */
+};
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	uname(struct utsname *);
+__END_DECLS
+
+#endif	/* !_SYS_UTSNAME_H_ */
diff --git a/prex-0.9.0/include/sys/vnode.h b/prex-0.9.0/include/sys/vnode.h
new file mode 100755
index 0000000..bc990dc
--- /dev/null
+++ b/prex-0.9.0/include/sys/vnode.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_VNODE_H_
+#define _SYS_VNODE_H_
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <sys/list.h>
+#include <sys/dirent.h>
+#include <sys/syslimits.h>
+
+struct vfsops;
+struct vnops;
+struct vnode;
+struct file;
+
+/*
+ * Vnode types.
+ */
+enum {
+	VNON,	    /* no type */
+	VREG,	    /* regular file  */
+	VDIR,	    /* directory */
+	VBLK,	    /* block device */
+	VCHR,	    /* character device */
+	VLNK,	    /* symbolic link */
+	VSOCK,	    /* socks */
+	VFIFO	    /* FIFO */
+};
+
+/*
+ * Reading or writing any of these items requires holding the
+ * appropriate lock.
+ */
+struct vnode {
+	struct list	v_link;		/* link for hash list */
+	struct mount	*v_mount;	/* mounted vfs pointer */
+	struct vnops	*v_op;		/* vnode operations */
+	int		v_refcnt;	/* reference count */
+	int		v_type;		/* vnode type */
+	int		v_flags;	/* vnode flag */
+	mode_t		v_mode;		/* file mode */
+	size_t		v_size;		/* file size */
+	mutex_t		v_lock;		/* lock for this vnode */
+	int		v_nrlocks;	/* lock count (for debug) */
+	int		v_blkno;	/* block number */
+	char		*v_path;	/* pointer to path in fs */
+	void		*v_data;	/* private data for fs */
+};
+typedef struct vnode *vnode_t;
+
+/* flags for vnode */
+#define VROOT		0x0001		/* root of its file system */
+#define VISTTY		0x0002		/* device is tty */
+#define VPROTDEV	0x0004		/* protected device */
+
+/*
+ * Vnode attribute
+ */
+struct vattr {
+	int		va_type;	/* vnode type */
+	mode_t		va_mode;	/* file access mode */
+};
+
+/*
+ *  Modes.
+ */
+#define	VREAD	00004		/* read, write, execute permissions */
+#define	VWRITE	00002
+#define	VEXEC	00001
+
+/*
+ * vnode operations
+ */
+struct vnops {
+	int (*vop_open)		(vnode_t, int);
+	int (*vop_close)	(vnode_t, file_t);
+	int (*vop_read)		(vnode_t, file_t, void *, size_t, size_t *);
+	int (*vop_write)	(vnode_t, file_t, void *, size_t, size_t *);
+	int (*vop_seek)		(vnode_t, file_t, off_t, off_t);
+	int (*vop_ioctl)	(vnode_t, file_t, u_long, void *);
+	int (*vop_fsync)	(vnode_t, file_t);
+	int (*vop_readdir)	(vnode_t, file_t, struct dirent *);
+	int (*vop_lookup)	(vnode_t, char *, vnode_t);
+	int (*vop_create)	(vnode_t, char *, mode_t);
+	int (*vop_remove)	(vnode_t, vnode_t, char *);
+	int (*vop_rename)	(vnode_t, vnode_t, char *, vnode_t, vnode_t, char *);
+	int (*vop_mkdir)	(vnode_t, char *, mode_t);
+	int (*vop_rmdir)	(vnode_t, vnode_t, char *);
+	int (*vop_getattr)	(vnode_t, struct vattr *);
+	int (*vop_setattr)	(vnode_t, struct vattr *);
+	int (*vop_inactive)	(vnode_t);
+	int (*vop_truncate)	(vnode_t, off_t);
+};
+
+typedef	int (*vnop_open_t)	(vnode_t, int);
+typedef	int (*vnop_close_t)	(vnode_t, file_t);
+typedef	int (*vnop_read_t)	(vnode_t, file_t, void *, size_t, size_t *);
+typedef	int (*vnop_write_t)	(vnode_t, file_t, void *, size_t, size_t *);
+typedef	int (*vnop_seek_t)	(vnode_t, file_t, off_t, off_t);
+typedef	int (*vnop_ioctl_t)	(vnode_t, file_t, u_long, void *);
+typedef	int (*vnop_fsync_t)	(vnode_t, file_t);
+typedef	int (*vnop_readdir_t)	(vnode_t, file_t, struct dirent *);
+typedef	int (*vnop_lookup_t)	(vnode_t, char *, vnode_t);
+typedef	int (*vnop_create_t)	(vnode_t, char *, mode_t);
+typedef	int (*vnop_remove_t)	(vnode_t, vnode_t, char *);
+typedef	int (*vnop_rename_t)	(vnode_t, vnode_t, char *, vnode_t, vnode_t, char *);
+typedef	int (*vnop_mkdir_t)	(vnode_t, char *, mode_t);
+typedef	int (*vnop_rmdir_t)	(vnode_t, vnode_t, char *);
+typedef	int (*vnop_getattr_t)	(vnode_t, struct vattr *);
+typedef	int (*vnop_setattr_t)	(vnode_t, struct vattr *);
+typedef	int (*vnop_inactive_t)	(vnode_t);
+typedef	int (*vnop_truncate_t)	(vnode_t, off_t);
+
+/*
+ * vnode interface
+ */
+#define VOP_OPEN(VP, F)		   ((VP)->v_op->vop_open)(VP, F)
+#define VOP_CLOSE(VP, FP)	   ((VP)->v_op->vop_close)(VP, FP)
+#define VOP_READ(VP, FP, B, S, C)  ((VP)->v_op->vop_read)(VP, FP, B, S, C)
+#define VOP_WRITE(VP, FP, B, S, C) ((VP)->v_op->vop_write)(VP, FP, B, S, C)
+#define VOP_SEEK(VP, FP, OLD, NEW) ((VP)->v_op->vop_seek)(VP, FP, OLD, NEW)
+#define VOP_IOCTL(VP, FP, C, A)	   ((VP)->v_op->vop_ioctl)(VP, FP, C, A)
+#define VOP_FSYNC(VP, FP)	   ((VP)->v_op->vop_fsync)(VP, FP)
+#define VOP_READDIR(VP, FP, DIR)   ((VP)->v_op->vop_readdir)(VP, FP, DIR)
+#define VOP_LOOKUP(DVP, N, VP)	   ((DVP)->v_op->vop_lookup)(DVP, N, VP)
+#define VOP_CREATE(DVP, N, M)	   ((DVP)->v_op->vop_create)(DVP, N, M)
+#define VOP_REMOVE(DVP, VP, N)	   ((DVP)->v_op->vop_remove)(DVP, VP, N)
+#define VOP_RENAME(DVP1, VP1, N1, DVP2, VP2, N2) \
+			   ((DVP1)->v_op->vop_rename)(DVP1, VP1, N1, DVP2, VP2, N2)
+#define VOP_MKDIR(DVP, N, M)	   ((DVP)->v_op->vop_mkdir)(DVP, N, M)
+#define VOP_RMDIR(DVP, VP, N)	   ((DVP)->v_op->vop_rmdir)(DVP, VP, N)
+#define VOP_GETATTR(VP, VAP)	   ((VP)->v_op->vop_getattr)(VP, VAP)
+#define VOP_SETATTR(VP, VAP)	   ((VP)->v_op->vop_setattr)(VP, VAP)
+#define VOP_INACTIVE(VP)	   ((VP)->v_op->vop_inactive)(VP)
+#define VOP_TRUNCATE(VP, N)	   ((VP)->v_op->vop_truncate)(VP, N)
+
+__BEGIN_DECLS
+int	 vop_nullop(void);
+int	 vop_einval(void);
+vnode_t	 vn_lookup(struct mount *, char *);
+void	 vn_lock(vnode_t);
+void	 vn_unlock(vnode_t);
+int	 vn_stat(vnode_t, struct stat *);
+int	 vn_access(vnode_t, int);
+vnode_t	 vget(struct mount *, char *);
+void	 vput(vnode_t);
+void	 vgone(vnode_t);
+void	 vref(vnode_t);
+void	 vrele(vnode_t);
+int	 vcount(vnode_t);
+void	 vflush(struct mount *);
+__END_DECLS
+
+#endif /* !_SYS_VNODE_H_ */
diff --git a/prex-0.9.0/include/sys/wait.h b/prex-0.9.0/include/sys/wait.h
new file mode 100755
index 0000000..a15e237
--- /dev/null
+++ b/prex-0.9.0/include/sys/wait.h
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)wait.h	8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_WAIT_H_
+#define _SYS_WAIT_H_
+
+/*
+ * This file holds definitions relevent to the wait4 system call
+ * and the alternate interfaces that use it (wait, wait3, waitpid).
+ */
+
+/*
+ * Macros to test the exit status returned by wait
+ * and extract the relevant values.
+ */
+#ifdef _POSIX_SOURCE
+#define	_W_INT(i)	(i)
+#else
+#define	_W_INT(w)	(*(int *)&(w))	/* convert union wait to int */
+#define	WCOREFLAG	0200
+#endif
+
+#define	_WSTATUS(x)	(_W_INT(x) & 0177)
+#define	_WSTOPPED	0177		/* _WSTATUS if process is stopped */
+#define WIFSTOPPED(x)	(_WSTATUS(x) == _WSTOPPED)
+#define WSTOPSIG(x)	(_W_INT(x) >> 8)
+#define WIFSIGNALED(x)	(_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
+#define WTERMSIG(x)	(_WSTATUS(x))
+#define WIFEXITED(x)	(_WSTATUS(x) == 0)
+#define WEXITSTATUS(x)	(_W_INT(x) >> 8)
+#ifndef _POSIX_SOURCE
+#define WCOREDUMP(x)	(_W_INT(x) & WCOREFLAG)
+
+#define	W_EXITCODE(ret, sig)	((ret) << 8 | (sig))
+#define	W_STOPCODE(sig)		((sig) << 8 | _WSTOPPED)
+#endif
+
+/*
+ * Option bits for the third argument of wait4.  WNOHANG causes the
+ * wait to not hang if there are no stopped or terminated processes, rather
+ * returning an error indication in this case (pid==0).  WUNTRACED
+ * indicates that the caller should receive status about untraced children
+ * which stop due to signals.  If children are stopped and a wait without
+ * this option is done, it is as though they were still running... nothing
+ * about them is returned.
+ */
+#define WNOHANG		1	/* don't hang in wait */
+#define WUNTRACED	2	/* tell about stopped, untraced children */
+
+#ifndef _POSIX_SOURCE
+/* POSIX extensions and 4.2/4.3 compatability: */
+
+/*
+ * Tokens for special values of the "pid" parameter to wait4.
+ */
+#define	WAIT_ANY	(-1)	/* any process */
+#define	WAIT_MYPGRP	0	/* any process in my process group */
+
+#include <sys/endian.h>
+
+/*
+ * Deprecated:
+ * Structure of the information in the status word returned by wait4.
+ * If w_stopval==WSTOPPED, then the second structure describes
+ * the information returned, else the first.
+ */
+union wait {
+	int	w_status;		/* used in syscall */
+	/*
+	 * Terminated process status.
+	 */
+	struct {
+#if BYTE_ORDER == LITTLE_ENDIAN
+		unsigned int	w_Termsig:7,	/* termination signal */
+				w_Coredump:1,	/* core dump indicator */
+				w_Retcode:8,	/* exit code if w_termsig==0 */
+				w_Filler:16;	/* upper bits filler */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+		unsigned int	w_Filler:16,	/* upper bits filler */
+				w_Retcode:8,	/* exit code if w_termsig==0 */
+				w_Coredump:1,	/* core dump indicator */
+				w_Termsig:7;	/* termination signal */
+#endif
+	} w_T;
+	/*
+	 * Stopped process status.  Returned
+	 * only for traced children unless requested
+	 * with the WUNTRACED option bit.
+	 */
+	struct {
+#if BYTE_ORDER == LITTLE_ENDIAN
+		unsigned int	w_Stopval:8,	/* == W_STOPPED if stopped */
+				w_Stopsig:8,	/* signal that stopped us */
+				w_Filler:16;	/* upper bits filler */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+		unsigned int	w_Filler:16,	/* upper bits filler */
+				w_Stopsig:8,	/* signal that stopped us */
+				w_Stopval:8;	/* == W_STOPPED if stopped */
+#endif
+	} w_S;
+};
+#define	w_termsig	w_T.w_Termsig
+#define w_coredump	w_T.w_Coredump
+#define w_retcode	w_T.w_Retcode
+#define w_stopval	w_S.w_Stopval
+#define w_stopsig	w_S.w_Stopsig
+
+#define	WSTOPPED	_WSTOPPED
+#endif /* _POSIX_SOURCE */
+
+#ifndef KERNEL
+#include <sys/types.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+pid_t	wait(int *);
+pid_t	waitpid(pid_t, int *, int);
+__END_DECLS
+#endif
+
+#endif /* !_SYS_WAIT_H_ */
diff --git a/prex-0.9.0/include/x86/asm.h b/prex-0.9.0/include/x86/asm.h
new file mode 100755
index 0000000..bb48d0d
--- /dev/null
+++ b/prex-0.9.0/include/x86/asm.h
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)asm.h	5.5 (Berkeley) 5/7/91
+ */
+
+#ifndef _X86_ASM_H
+#define _X86_ASM_H
+
+#define _ALIGN_TEXT .align 4
+#define _ENTRY(x) \
+	.text; _ALIGN_TEXT; .globl x; .type x,@function; x:
+
+#define _C_LABEL(x)	x
+#define	_ASM_LABEL(x)	x
+
+#define	ENTRY(y)	_ENTRY(_C_LABEL(y));
+#define	NENTRY(y)	_ENTRY(_C_LABEL(y))
+#define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y));
+
+#if defined(PIC)
+#define	PIC_SYM(x,y)	x ## ( ## y ## )
+#else
+#define	PIC_SYM(x,y)	x
+#endif
+
+#endif /* !_X86_ASM_H */
diff --git a/prex-0.9.0/include/x86/elf.h b/prex-0.9.0/include/x86/elf.h
new file mode 100755
index 0000000..e2904d3
--- /dev/null
+++ b/prex-0.9.0/include/x86/elf.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_ELF_H
+#define _X86_ELF_H
+
+/*
+ * Relocation type for i386
+ */
+#define R_386_NONE	0
+#define R_386_32	1
+#define R_386_PC32	2
+#define R_386_GOT32	3
+#define R_386_PLT32	4
+#define R_386_COPY	5
+#define R_386_GLOB_DAT	6
+#define R_386_JMP_SLOT	7
+#define R_386_RELATIVE	8
+#define R_386_GOTOFF	9
+#define R_386_GOTPC	10
+#define R_386_NUM	11
+
+#endif /* !_X86_ELF_H */
diff --git a/prex-0.9.0/include/x86/endian.h b/prex-0.9.0/include/x86/endian.h
new file mode 100755
index 0000000..19c32ee
--- /dev/null
+++ b/prex-0.9.0/include/x86/endian.h
@@ -0,0 +1,2 @@
+
+#define _BYTE_ORDER LITTLE_ENDIAN
diff --git a/prex-0.9.0/include/x86/limits.h b/prex-0.9.0/include/x86/limits.h
new file mode 100755
index 0000000..6fd273e
--- /dev/null
+++ b/prex-0.9.0/include/x86/limits.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)limits.h	8.4 (Berkeley) 4/28/95
+ */
+#ifndef	_X86_LIMITS_H
+#define	_X86_LIMITS_H
+
+#define	CHAR_BIT	8		/* number of bits in a char */
+#define	MB_LEN_MAX	32		/* no multibyte characters */
+
+
+/*
+ * According to ANSI (section 2.2.4.2), the values below must be usable by
+ * #if preprocessing directives.  Additionally, the expression must have the
+ * same type as would an expression that is an object of the corresponding
+ * type converted according to the integral promotions.  The subtraction for
+ * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
+ * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
+ * These numbers work for pcc as well.  The UINT_MAX and ULONG_MAX values
+ * are written as hex so that GCC will be quiet about large integer constants.
+ */
+#define	SCHAR_MAX	127		/* min value for a signed char */
+#define	SCHAR_MIN	(-128)		/* max value for a signed char */
+
+#define	UCHAR_MAX	255		/* max value for an unsigned char */
+#define	CHAR_MAX	127		/* max value for a char */
+#define	CHAR_MIN	(-128)		/* min value for a char */
+
+#define	USHRT_MAX	65535		/* max value for an unsigned short */
+#define	SHRT_MAX	32767		/* max value for a short */
+#define	SHRT_MIN	(-32768)	/* min value for a short */
+
+#define	UINT_MAX	0xffffffffU	/* max value for an unsigned int */
+#define	INT_MAX		2147483647	/* max value for an int */
+#define	INT_MIN		(-2147483647-1)	/* min value for an int */
+
+#define	ULONG_MAX	0xffffffffUL	/* max value for an unsigned long */
+#define	LONG_MAX	2147483647L	/* max value for a long */
+					/* min value for a long */
+#define	LONG_MIN	(-2147483647L-1L)
+
+#define	SSIZE_MAX	INT_MAX		/* max value for a ssize_t */
+#define	SIZE_T_MAX	UINT_MAX	/* max value for a size_t */
+
+#endif	/* _X86_LIMITS_H */
diff --git a/prex-0.9.0/include/x86/memory.h b/prex-0.9.0/include/x86/memory.h
new file mode 100755
index 0000000..c301432
--- /dev/null
+++ b/prex-0.9.0/include/x86/memory.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef	_X86_MEMORY_H
+#define	_X86_MEMORY_H
+
+#include <conf/config.h>
+
+#ifdef CONFIG_MMU
+#define KERNBASE	0x80000000	/* offset of kernel address space */
+#define PAGE_SIZE	4096		/* bytes per page */
+#define USERLIMIT	0x80000000	/* upper limit on user address space */
+#else
+#define KERNBASE	0		/* offset of kernel address space */
+#define PAGE_SIZE	1024		/* bytes per page */
+#define USERLIMIT	0xffffffff	/* upper limit on user address space */
+#endif
+
+#endif	/* _X86_MEMORY_H */
diff --git a/prex-0.9.0/include/x86/setjmp.h b/prex-0.9.0/include/x86/setjmp.h
new file mode 100755
index 0000000..112332c
--- /dev/null
+++ b/prex-0.9.0/include/x86/setjmp.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)setjmp.h	8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _X86_SETJMP_H
+#define _X86_SETJMP_H
+
+#define _JBLEN	10
+
+#endif /* !_X86_SETJMP_H */
diff --git a/prex-0.9.0/include/x86/signal.h b/prex-0.9.0/include/x86/signal.h
new file mode 100755
index 0000000..f9f348e
--- /dev/null
+++ b/prex-0.9.0/include/x86/signal.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1986, 1989, 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)signal.h	8.2 (Berkeley) 5/3/95
+ */
+
+/*
+ * Machine-dependent signal definitions
+ */
+
+typedef int sig_atomic_t;
+
+/*
+ * Information pushed on stack when a signal is delivered.
+ * This is used by the kernel to restore state following
+ * execution of the signal handler.  It is also made available
+ * to the handler to allow it to restore state properly if
+ * a non-standard exit is performed.
+ */
+struct	sigcontext {
+	int	sc_onstack;	/* sigstack state to restore */
+	int	sc_mask;	/* signal mask to restore */
+
+	int	sc_gs;
+	int	sc_fs;
+	int	sc_es;
+	int	sc_ds;
+	int	sc_edi;
+	int	sc_esi;
+	int	sc_ebp;
+	int	sc_ebx;
+	int	sc_edx;
+	int	sc_ecx;
+	int	sc_eax;
+
+	int	sc_eip;
+	int	sc_cs;
+	int	sc_eflags;
+	int	sc_esp;
+	int	sc_ss;
+};
diff --git a/prex-0.9.0/include/x86/stdarg.h b/prex-0.9.0/include/x86/stdarg.h
new file mode 100755
index 0000000..e4d6094
--- /dev/null
+++ b/prex-0.9.0/include/x86/stdarg.h
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)stdarg.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _X86_STDARG_H
+#define	_X86_STDARG_H
+
+#include <sys/cdefs.h>
+
+#ifdef __lint__
+typedef void *			va_list;
+#define	va_start(a, l)		(0)
+#define	va_arg(a, t)		(0)
+#define	va_end			/* nothing */
+#define	va_copy(d, s)		((d) = (s))
+
+#elif __GNUC_PREREQ__(2, 96)
+#define va_list			__builtin_va_list
+#define	va_start(ap, last)	__builtin_va_start((ap), (last))
+#define	va_arg			__builtin_va_arg
+#define	va_end			__builtin_va_end
+#define	va_copy(dest, src)	__builtin_va_copy((dest), (src))
+#else
+
+typedef char *			va_list;
+
+#define	__va_size(type) \
+	(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+
+#define	va_start(ap, last) \
+	((ap) = (va_list)&(last) + __va_size(last))
+
+#define	va_arg(ap, type) \
+	(*(type *)(void *)((ap) += __va_size(type), (ap) - __va_size(type)))
+
+#define	va_end(ap)
+
+#define	va_copy(dest, src)	((dest) = (src))
+#endif
+
+#endif /* !_X86_STDARG_H */
diff --git a/prex-0.9.0/include/x86/syspage.h b/prex-0.9.0/include/x86/syspage.h
new file mode 100755
index 0000000..a9b0b02
--- /dev/null
+++ b/prex-0.9.0/include/x86/syspage.h
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2008-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _X86_SYSPAGE_H
+#define _X86_SYSPAGE_H
+
+#include <conf/config.h>
+
+/**
+ * syspage layout:
+ *
+ * +------------------+ CONFIG_SYSPAGE_BASE
+ * | NULL pointer     |
+ * | detection page   |
+ * |                  |
+ * +------------------+ +0x1000
+ * | Interrupt stack  |
+ * |                  |
+ * |                  |
+ * +------------------+ +0x2000
+ * | Boot information |
+ * +------------------+ +0x2400
+ * | Boot stack       |
+ * +------------------+ +0x3000
+ * | PGD for boot     |
+ * | (MMU only)       |
+ * |                  |
+ * +------------------+ +0x4000
+ * | PTE0 for boot    |
+ * | (MMU only)       |
+ * |                  |
+ * +------------------+ +0x5000
+ *
+ * Note: Interrupt stack should be placed after NULL page
+ * to detect the stack overflow.
+ */
+
+#define SYSPAGE		CONFIG_SYSPAGE_BASE
+#define INTSTK		(SYSPAGE + 0x1000)
+#define BOOTINFO	(SYSPAGE + 0x2000)
+#define BOOTSTK		(SYSPAGE + 0x2400)
+#define BOOT_PGD	(SYSPAGE + 0x3000)
+#define BOOT_PTE0	(SYSPAGE + 0x4000)
+
+#define BOOT_PGD_PHYS	0x3000
+#define BOOT_PTE0_PHYS	0x4000
+
+#define INTSTKSZ	0x1000		/* size of interrupt stack */
+#define BOOTSTKSZ	0x0c00		/* size of boot stack */
+
+#define INTSTKTOP	(INTSTK + INTSTKSZ)
+#define BOOTSTKTOP	(BOOTSTK + BOOTSTKSZ)
+
+#ifdef CONFIG_MMU
+#define SYSPAGESZ	0x5000
+#else
+#define SYSPAGESZ	0x3000
+#endif
+
+#endif /* !_X86_SYSPAGE_H */
diff --git a/prex-0.9.0/include/x86/systrap.h b/prex-0.9.0/include/x86/systrap.h
new file mode 100755
index 0000000..32365b8
--- /dev/null
+++ b/prex-0.9.0/include/x86/systrap.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef	_X86_SYSTRAP_H
+#define	_X86_SYSTRAP_H
+
+#define SYSCALL0(name) \
+	.global name; .align 2; \
+name##: movl	$(SYS_##name), %eax; \
+	jmp	__systrap
+
+#define SYSCALL1(name) SYSCALL0(name)
+#define SYSCALL2(name) SYSCALL0(name)
+#define SYSCALL3(name) SYSCALL0(name)
+#define SYSCALL4(name) SYSCALL0(name)
+
+#endif	/* _X86_SYSTRAP_H */
diff --git a/prex-0.9.0/include/x86/types.h b/prex-0.9.0/include/x86/types.h
new file mode 100755
index 0000000..42a4196
--- /dev/null
+++ b/prex-0.9.0/include/x86/types.h
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)types.h	8.3 (Berkeley) 1/5/94
+ */
+
+#ifndef	_X86_TYPES_H
+#define	_X86_TYPES_H
+
+#include <sys/cdefs.h>
+
+/*
+ * Basic integral types.  Omit the typedef if
+ * not possible for a machine/compiler combination.
+ */
+typedef	signed char	   int8_t;
+typedef	unsigned char	  uint8_t;
+typedef	short		  int16_t;
+typedef	unsigned short	 uint16_t;
+typedef	int		  int32_t;
+typedef	unsigned int	 uint32_t;
+
+typedef unsigned long	  paddr_t;
+typedef unsigned long	  psize_t;
+typedef unsigned long	  vaddr_t;
+typedef unsigned long	  vsize_t;
+
+typedef int		register_t;
+
+#endif	/* _X86_TYPES_H */
diff --git a/prex-0.9.0/mk/common.mk b/prex-0.9.0/mk/common.mk
new file mode 100755
index 0000000..7b93c91
--- /dev/null
+++ b/prex-0.9.0/mk/common.mk
@@ -0,0 +1,168 @@
+# common.mk - common make rules to build Prex
+
+#
+# This file includes the common rules to make Prex source tree.
+# The files are installed in /mk, and are, by convention,
+# named with the suffix ".mk".
+#
+# Supported environment variables:
+#
+#  SRCDIR          ... Root directory of source tree
+#  NDEBUG          ... Force disable debug switch (default: 0)
+#  LIBGCC_PATH     ... Path for libgcc.a (optional)
+#
+# Variables in local Makefile:
+#
+#  TARGET          ... Target file name
+#  SUBDIR,SUBDIR-y ... List of subdirectories
+#  SRCS,SRCS-y     ... Source files
+#  OBJS,OBJS-y     ... Object files
+#  LIBS            ... Libraries
+#  INCSDIR         ... Include path
+#  LIBSDIR         ... Library path
+#  DEFS            ... Definition to pass to the compiler
+#  MAP             ... Name of map file
+#  DISASM          ... Name of disassemble file
+#  SYMBOL          ... Name of symbol file
+#
+
+ifndef _COMMON_MK_
+_COMMON_MK_:=	1
+
+ifdef _GNUC_
+include $(SRCDIR)/mk/gcc.mk
+endif
+
+ifdef _PCC_
+include $(SRCDIR)/mk/pcc.mk
+endif
+
+ifdef _SUNPRO_C_
+include $(SRCDIR)/mk/suncc.mk
+endif
+
+ifdef DISASM
+ASMGEN=		$(OBJDUMP) $@ --disassemble-all > $(DISASM)
+endif
+
+ifdef SYMBOL
+SYMGEN=		cp $@ $(SYMBOL)
+endif
+
+SUBDIR+=	$(SUBDIR-y)
+OBJS+=		$(OBJS-y)
+SRCS+=		$(SRCS-y)
+ifeq ($(OBJS),)
+OBJS+=		$(addsuffix .o,$(basename $(SRCS)))
+endif
+
+.SUFFIXES:
+.SUFFIXES: .bin .a .o .S .c .cc .cpp .cxx .h
+
+ifeq ($(_SILENT_),1)
+echo-file=	@echo '  $(1) $(subst $(SRCDIR)/,,$(abspath $(2)))'
+
+echo-files=	@(for d in $(2) _ ; do \
+		  if [ "$$d" != "_" ]; then \
+		    echo "  $(1) $(subst $(SRCDIR)/,,$(abspath $$d))" ; fi; \
+		  done);
+endif
+
+#
+# Inference rules
+#
+%.o: %.c
+	$(call echo-file,CC     ,$<)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(OUTPUT_OPTION) $<
+
+%.o: %.S
+	$(call echo-file,AS     ,$<)
+	$(CPP) $(ACPPFLAGS) $(CPPFLAGS) $< $*.tmp
+	$(AS) $(ASFLAGS) $(OUTPUT_OPTION) $*.tmp
+	$(RM) $*.tmp
+
+
+#
+# Target
+#
+all: config $(SUBDIR) $(TARGET)
+
+
+#
+# Check configuration file
+#
+.PHONY: config
+config:
+ifndef ARCH
+	@echo 'Error: You must run `configure` before make.'
+	exit 1
+endif
+
+#
+# Rules to process sub-directory
+#
+ifdef SUBDIR
+.PHONY: $(SUBDIR)
+$(SUBDIR): dummy
+	@$(MAKE) -C $@
+endif
+
+-include Makefile.dep
+
+#
+# Depend
+#
+.PHONY: depend dep
+depend dep:
+ifdef SUBDIR
+	@(for d in $(SUBDIR) _ ; do \
+	  if [ "$$d" != "_" ]; then $(MAKE) -C $$d depend; fi; \
+	done);
+endif
+	$(RM) Makefile.dep
+	@(for d in $(SRCS) _ ; do \
+	  if [ "$$d" != "_" ]; then \
+	  $(CPP) -M $(CPPFLAGS) $$d >> Makefile.dep; fi; \
+	done);
+
+#
+# Lint
+#
+.PHONY: lint
+lint:
+ifdef SUBDIR
+	@(for d in $(SUBDIR) _ ; do \
+	  if [ "$$d" != "_" ]; then $(MAKE) -C $$d lint; fi; \
+	done);
+endif
+	@(for d in $(filter %.c, $(SRCS)) _ ; do \
+	  if [ "$$d" != "_" ]; then \
+	  echo ; \
+	  echo "Checking $$d" ; \
+	  $(LINT) $(CPPFLAGS) $(LINTFLAGS) $$d; fi; \
+	done);
+
+#
+# Clean up
+#
+CLEANS= Makefile.dep $(TARGET) $(OBJS) $(DISASM) $(MAP) $(SYMBOL) $(CLEANFILES)
+
+.PHONY: clean
+clean:
+ifdef SUBDIR
+	@(for d in $(SUBDIR) _ ; do \
+	  if [ "$$d" != "_" ]; then $(MAKE) -C $$d clean; fi; \
+	done);
+endif
+	$(call echo-files,CLEAN  ,$(CLEANS))
+	$(RM) $(CLEANS)
+
+.PHONY: dummy
+
+#
+# Build OS image
+#
+.PHINY: image
+image: config $(TARGET)
+
+endif # !_COMMON_MK_
diff --git a/prex-0.9.0/mk/gcc.mk b/prex-0.9.0/mk/gcc.mk
new file mode 100755
index 0000000..300eec3
--- /dev/null
+++ b/prex-0.9.0/mk/gcc.mk
@@ -0,0 +1,49 @@
+# gcc specifc flags
+
+ifndef _GCC_MK_
+_GCC_MK_:=	1
+
+OUTPUT_OPTION=	-o $@
+
+DEFINES=	$(addprefix -D,$(DEFS))
+
+CFLAGS+=	-c -Os -ansi -pedantic -Wall -Wundef -Wstrict-prototypes \
+		-Wpointer-arith -nostdinc -fno-strict-aliasing $(GCCFLAGS)
+CPPFLAGS+=	$(DEFINES) -I. $(addprefix -I,$(INCSDIR))
+ACPPFLAGS+=	-D__ASSEMBLY__
+LDFLAGS+=	-static -nostdlib $(addprefix -L,$(LIBSDIR))
+
+ifeq ($(_DEBUG_),1)
+CFLAGS+=	-fno-omit-frame-pointer -g
+else
+CFLAGS+=	-fomit-frame-pointer
+endif
+
+ifeq ($(_KERNEL_),1)
+CFLAGS+=	-fno-builtin
+endif
+
+ifeq ($(_STRICT_),1)
+CFLAGS+=	-Werror
+endif
+
+ifdef LDSCRIPT
+LDFLAGS+=	-T $(LDSCRIPT)
+endif
+
+ifdef MAP
+LDFLAGS+=	-Map $(MAP)
+endif
+
+ifeq ($(_RELOC_OBJ_),1)
+LDFLAGS_S:=	$(LDFLAGS) --error-unresolved-symbols
+LDFLAGS+=	-r -d
+endif
+
+ifndef LIBGCC_PATH
+LIBGCC_PATH := $(dir $(shell $(RAWCC) -print-libgcc-file-name))
+export LIBGCC_PATH
+endif
+PLATFORM_LIBS+=	-L$(LIBGCC_PATH) -lgcc
+
+endif # !_GCC_MK_
diff --git a/prex-0.9.0/mk/image.mk b/prex-0.9.0/mk/image.mk
new file mode 100755
index 0000000..66a5156
--- /dev/null
+++ b/prex-0.9.0/mk/image.mk
@@ -0,0 +1,27 @@
+# Rules to create OS image
+
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	$(SRCDIR)/prexos
+LOADER:=	$(SRCDIR)/bsp/boot/bootldr
+DRIVER:=	$(SRCDIR)/bsp/drv/drv.ko
+KERNEL:=	$(SRCDIR)/sys/prex
+
+include $(SRCDIR)/conf/etc/tasks.mk
+include $(SRCDIR)/conf/etc/files.mk
+include $(SRCDIR)/mk/common.mk
+-include $(SRCDIR)/bsp/boot/$(ARCH)/$(PLATFORM)/Makefile.sysgen
+
+$(TARGET): dummy
+	$(call echo-file,PACK   ,$@)
+ifdef FILES
+	$(AR) rcS bootdisk.a $(FILES)
+	$(AR) rcS tmp.a $(KERNEL) $(DRIVER) $(TASKS) bootdisk.a
+	$(RM) bootdisk.a
+else
+	$(AR) rcS tmp.a $(KERNEL) $(DRIVER) $(TASKS)
+endif
+	$(CAT) $(LOADER) tmp.a > $@
+	$(RM) tmp.a
+	$(call sysgen)
+	@echo 'Done.'
diff --git a/prex-0.9.0/mk/lib.mk b/prex-0.9.0/mk/lib.mk
new file mode 100755
index 0000000..cdb1b4d
--- /dev/null
+++ b/prex-0.9.0/mk/lib.mk
@@ -0,0 +1,16 @@
+# Rules to compile library
+
+include $(SRCDIR)/mk/own.mk
+
+_RELOC_OBJ_:=	1
+
+ifndef _KERNEL_
+INCSDIR+=	$(SRCDIR)/usr/include
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(OBJS)
+	$(call echo-file,AR     ,$(TARGET))
+	$(AR) rucs $(TARGET) $?
+	$(STRIP) -x -R .comment -R .note $(TARGET)
diff --git a/prex-0.9.0/mk/obj.mk b/prex-0.9.0/mk/obj.mk
new file mode 100755
index 0000000..646c66b
--- /dev/null
+++ b/prex-0.9.0/mk/obj.mk
@@ -0,0 +1,16 @@
+# Rules to link a set of .o files into one .o file
+
+include $(SRCDIR)/mk/own.mk
+
+_RELOC_OBJ_:=	1
+
+ifndef _KERNEL_
+INCSDIR+=	$(SRCDIR)/usr/include
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(OBJS)
+	$(call echo-file,LD     ,$@)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $^
+
diff --git a/prex-0.9.0/mk/own.mk b/prex-0.9.0/mk/own.mk
new file mode 100755
index 0000000..96feeb2
--- /dev/null
+++ b/prex-0.9.0/mk/own.mk
@@ -0,0 +1,63 @@
+ifndef _OWN_MK_
+_OWN_MK_:=	1
+
+# Build flavor
+#_DEBUG_:=	1
+#_QUICK_:=	1
+#_STRICT_:=	1
+#_SILENT_:=	1
+
+# Clean the slate
+CFLAGS=
+CPPFLAGS=
+LDFLAGS=
+ASFLAGS=
+STRIPFLAG=
+
+ifndef _CONFIG_MK_
+-include $(SRCDIR)/conf/config.mk
+export SRCDIR
+endif
+
+LINT:=		splint
+#LINT:=		lint
+RM:=		rm -f
+CAT:=		cat
+ifdef SHELL_PATH
+SHELL:=		$(SHELL_PATH)
+endif
+
+# We assume GNU make...
+MAKEFLAGS+=	-rR --no-print-directory
+
+ifeq ($(LINT),splint)
+LINTFLAGS:=	-D__lint__ -weak -nolib -retvalother -fcnuse
+else
+LINTFLAGS:=	-D__lint__ -x -u
+endif
+
+INCSDIR:=	$(SRCDIR) $(SRCDIR)/include
+DEFS+=		__$(ARCH)__ __$(PLATFORM)__
+
+ifneq ($(NDEBUG),1)
+ifeq ($(_DEBUG_),1)
+DEFS+=		DEBUG
+DEBUG:=		1
+endif
+endif
+
+RAWCC:=		$(CC)
+ifeq ($(_SILENT_),1)
+CC:=		@$(CC)
+CPP:=		@$(CPP)
+AS:=		@$(AS)
+LD:=		@$(LD)
+AR:=		@$(AR)
+STRIP:=		@$(STRIP)
+OBJCOPY:=	@$(OBJCOPY)
+OBJDUMP:=	@$(OBJDUMP)
+RM:=		@$(RM)
+CAT:=		@$(CAT)
+endif
+
+endif # !_OWN_MK_
diff --git a/prex-0.9.0/mk/pcc.mk b/prex-0.9.0/mk/pcc.mk
new file mode 100755
index 0000000..62ac709
--- /dev/null
+++ b/prex-0.9.0/mk/pcc.mk
@@ -0,0 +1,32 @@
+# pcc specific flags
+
+ifndef _PCC_MK_
+_PCC_MK_:=	1
+
+OUTPUT_OPTION=	-o $@
+
+DEFINES=	$(addprefix -D,$(DEFS))
+
+CFLAGS+=	-c -O -static -nostdinc -nostdlib
+CPPFLAGS+=	$(DEFINES) -I. $(addprefix -I,$(INCSDIR))
+ACPPFLAGS+=	-D__ASSEMBLY__
+LDFLAGS+=	-static -nostdlib $(addprefix -L,$(LIBSDIR))
+
+ifeq ($(_DEBUG_),1)
+CFLAGS+=	-g
+endif
+
+ifdef LDSCRIPT
+LDFLAGS+=	-T $(LDSCRIPT)
+endif
+
+ifdef MAP
+LDFLAGS+=	-Map $(MAP)
+endif
+
+ifeq ($(_RELOC_OBJ_),1)
+LDFLAGS_S=	$(LDFLAGS) --error-unresolved-symbols
+LDFLAGS+=	-r -d
+endif
+
+endif # !_PCC_MK_
diff --git a/prex-0.9.0/mk/prog.mk b/prex-0.9.0/mk/prog.mk
new file mode 100755
index 0000000..2ba9910
--- /dev/null
+++ b/prex-0.9.0/mk/prog.mk
@@ -0,0 +1,33 @@
+# Rules to compile a POSIX executable file
+
+include $(SRCDIR)/mk/own.mk
+
+INCSDIR+=	$(SRCDIR)/usr/include
+LIBSDIR+=	$(SRCDIR)/usr/lib
+CRT0:=		$(SRCDIR)/usr/lib/crt0.o
+LIBC:=		$(SRCDIR)/usr/lib/libc.a
+
+ifeq ($(CONFIG_MMU),y)
+LDSCRIPT:=	$(SRCDIR)/usr/arch/$(ARCH)/user.ld
+STRIPFLAG:=	-s
+else
+LDSCRIPT:=	$(SRCDIR)/usr/arch/$(ARCH)/user-nommu.ld
+STRIPFLAG:=	--strip-debug --strip-unneeded
+_RELOC_OBJ_:=	1
+endif
+
+ifdef PROG
+TARGET?=	$(PROG)
+ifndef SRCS
+SRCS:=		$(basename $(PROG)).c
+endif
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(LIBS) $(OBJS)
+	$(call echo-file,LD     ,$@)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(CRT0) $(OBJS) $(LIBS) $(LIBC) $(PLATFORM_LIBS)
+	$(ASMGEN)
+	$(SYMGEN)
+	$(STRIP) $(STRIPFLAG) $@
diff --git a/prex-0.9.0/mk/subdir.mk b/prex-0.9.0/mk/subdir.mk
new file mode 100755
index 0000000..4ec8acb
--- /dev/null
+++ b/prex-0.9.0/mk/subdir.mk
@@ -0,0 +1,4 @@
+# Rules to process sub directories
+
+include $(SRCDIR)/mk/own.mk
+include $(SRCDIR)/mk/common.mk
diff --git a/prex-0.9.0/mk/suncc.mk b/prex-0.9.0/mk/suncc.mk
new file mode 100755
index 0000000..adfda71
--- /dev/null
+++ b/prex-0.9.0/mk/suncc.mk
@@ -0,0 +1,42 @@
+# sun studio specifc flags
+
+ifndef _SUNCC_MK_
+_SUNCC_MK_:=	1
+
+OUTPUT_OPTION=	-o $@
+
+DEFINES=	$(addprefix -D,$(DEFS))
+
+CFLAGS+=	-c -xspace -features=none -xnolib -xc99=none
+CPPFLAGS+=	$(DEFINES) -I. $(addprefix -I,$(INCSDIR))
+ACPPFLAGS+=	-D__ASSEMBLY__
+LDFLAGS+=	-static -nostdlib $(addprefix -L,$(LIBSDIR))
+
+ifeq ($(_DEBUG_),1)
+CFLAGS+=	-g
+else
+CFLAGS+=
+endif
+
+ifeq ($(_KERNEL_),1)
+CFLAGS+=	-xbuiltin=%none
+endif
+
+ifeq ($(_STRICT_),1)
+CFLAGS+=	-errwarn
+endif
+
+ifdef LDSCRIPT
+LDFLAGS+=	-T $(LDSCRIPT)
+endif
+
+ifdef MAP
+LDFLAGS+=	-Map $(MAP)
+endif
+
+ifeq ($(_RELOC_OBJ_),1)
+LDFLAGS_S=	$(LDFLAGS) --error-unresolved-symbols
+LDFLAGS+=	-r -d
+endif
+
+endif # !_SUNCC_MK_
diff --git a/prex-0.9.0/mk/task.mk b/prex-0.9.0/mk/task.mk
new file mode 100755
index 0000000..e054d39
--- /dev/null
+++ b/prex-0.9.0/mk/task.mk
@@ -0,0 +1,34 @@
+# Rules to compile a real-time task
+
+include $(SRCDIR)/mk/own.mk
+
+DEFS+=		_STANDALONE
+INCSDIR+=	$(SRCDIR)/usr/include
+LIBSDIR+=	$(SRCDIR)/usr/lib
+CRT0:=		$(SRCDIR)/usr/lib/crt0.o
+LIBC:=		$(SRCDIR)/usr/lib/libsa.a
+
+ifeq ($(CONFIG_MMU),y)
+LDSCRIPT:=	$(SRCDIR)/usr/arch/$(ARCH)/user.ld
+STRIPFLAG:=	-s
+else
+LDSCRIPT:=	$(SRCDIR)/usr/arch/$(ARCH)/user-nommu.ld
+STRIPFLAG:=	--strip-debug --strip-unneeded
+_RELOC_OBJ_:=	1
+endif
+
+ifdef TASK
+TARGET?=	$(TASK)
+ifndef SRCS
+SRCS:=		$(basename $(TASK)).c
+endif
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(LIBS) $(OBJS)
+	$(call echo-file,LD     ,$@)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(CRT0) $(OBJS) $(LIBS) $(LIBC) $(PLATFORM_LIBS)
+	$(ASMGEN)
+	$(SYMGEN)
+	$(STRIP) $(STRIPFLAG) $@
diff --git a/prex-0.9.0/sys/Makefile b/prex-0.9.0/sys/Makefile
new file mode 100755
index 0000000..9df9047
--- /dev/null
+++ b/prex-0.9.0/sys/Makefile
@@ -0,0 +1,59 @@
+# Rules to compile kernel
+
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	prex
+
+#MAP:=		prex.map
+#DISASM:= 	prex.lst
+#SYMBOL:= 	prex.sym
+
+_KERNEL_:=	1
+DEFS+=		KERNEL
+
+SRCS+=		kern/main.c \
+		kern/sched.c \
+		kern/task.c \
+		kern/thread.c \
+		kern/timer.c \
+		kern/sysent.c \
+		kern/irq.c \
+		kern/device.c \
+		kern/exception.c \
+		kern/system.c \
+		mem/kmem.c \
+		mem/page.c \
+		ipc/msg.c \
+		ipc/object.c \
+		sync/cond.c \
+		sync/mutex.c \
+		sync/sem.c \
+		lib/queue.c \
+		lib/string.c \
+		lib/vsprintf.c
+
+ifeq ($(CONFIG_MMU),y)
+SRCS+=		mem/vm.c
+else
+SRCS+=		mem/vm_nommu.c
+endif
+
+ifeq ($(DEBUG),1)
+SRCS+=		kern/debug.c
+endif
+
+HAL:=		$(SRCDIR)/bsp/hal/hal.o
+LIBSDIR+=	$(SRCDIR)/conf
+INCSDIR+=	$(CURDIR)/include $(SRCDIR)/bsp/hal/$(ARCH)/include
+ifndef LDSCRIPT
+LDSCRIPT:=	$(SRCDIR)/bsp/hal/$(ARCH)/arch/kern.ld
+endif
+
+include $(SRCDIR)/mk/common.mk
+
+$(TARGET): $(OBJS) $(HAL) $(LDSCRIPT)
+	$(call echo-file,LD     ,$@)
+	$(LD) $(LDFLAGS) $(OUTPUT_OPTION) $(HAL) $(OBJS) $(PLATFORM_LIBS)
+	$(ASMGEN)
+	$(SYMGEN)
+	$(STRIP) -s $@
diff --git a/prex-0.9.0/sys/include/debug.h b/prex-0.9.0/sys/include/debug.h
new file mode 100755
index 0000000..0a171b1
--- /dev/null
+++ b/prex-0.9.0/sys/include/debug.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEBUG_H
+#define _DEBUG_H
+
+#include <sys/cdefs.h>
+#include <hal.h>
+
+#ifdef CONFIG_TINY
+#define LOGBUFSZ	512	/* size of log buffer */
+#else
+#define LOGBUFSZ	2048	/* size of log buffer */
+#endif
+
+#define DBGMSGSZ	128	/* Size of one message */
+
+#ifdef DEBUG
+#define DPRINTF(a)	printf a
+#define ASSERT(exp)	do { if (!(exp)) \
+			     assert(__FILE__, __LINE__, #exp); } while (0)
+#else
+#define DPRINTF(a)	((void)0)
+#define ASSERT(exp)	((void)0)
+#define panic(x)	machine_abort()
+#endif
+
+__BEGIN_DECLS
+#ifdef DEBUG
+void	printf(const char *, ...);
+void	assert(const char *, int, const char *);
+void	panic(const char *);
+int	dbgctl(int, void *);
+#endif
+__END_DECLS
+
+#endif /* !_DEBUG_H */
diff --git a/prex-0.9.0/sys/include/device.h b/prex-0.9.0/sys/include/device.h
new file mode 100755
index 0000000..97396a6
--- /dev/null
+++ b/prex-0.9.0/sys/include/device.h
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEVICE_H
+#define _DEVICE_H
+
+#include <sys/cdefs.h>
+#include <types.h>
+#include <sys/device.h>
+
+/*
+ * Device object
+ */
+struct device {
+	struct device	*next;		/* linkage on list of all devices */
+	struct driver	*driver;	/* pointer to the driver object */
+	char		name[MAXDEVNAME]; /* name of device */
+	int		flags;		/* D_* flags defined above */
+	int		active;		/* device has not been destroyed */
+	int		refcnt;		/* reference count */
+	void		*private;	/* private storage */
+};
+
+__BEGIN_DECLS
+int	 device_open(const char *, int, device_t *);
+int	 device_close(device_t);
+int	 device_read(device_t, void *, size_t *, int);
+int	 device_write(device_t, void *, size_t *, int);
+int	 device_ioctl(device_t, u_long, void *);
+int	 device_info(struct devinfo *);
+void	 device_init(void);
+__BEGIN_DECLS
+
+#endif /* !_DEVICE_H */
diff --git a/prex-0.9.0/sys/include/event.h b/prex-0.9.0/sys/include/event.h
new file mode 100755
index 0000000..06a07a6
--- /dev/null
+++ b/prex-0.9.0/sys/include/event.h
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _EVENT_H
+#define _EVENT_H
+
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+
+/*
+ * Event for sleep/wakeup
+ */
+struct event {
+	struct queue	sleepq;		/* queue for waiting thread */
+	char		*name;		/* pointer to event name string */
+};
+
+/* Macro to initialize event dynamically */
+#define event_init(event, evt_name) \
+    do { queue_init(&(event)->sleepq); (event)->name = evt_name; } while (0)
+
+#define event_waiting(event)   (!queue_empty(&(event)->sleepq))
+
+#endif /* !_EVENT_H */
diff --git a/prex-0.9.0/sys/include/exception.h b/prex-0.9.0/sys/include/exception.h
new file mode 100755
index 0000000..5ed9413
--- /dev/null
+++ b/prex-0.9.0/sys/include/exception.h
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _EXCEPT_H
+#define _EXCEPT_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+
+/* Number of exceptions */
+#define	NEXC		32
+
+/* Default exception handler */
+#define EXC_DFL		((void (*)(int)) -1)
+
+__BEGIN_DECLS
+int	 exception_setup(void (*)(int));
+int	 exception_raise(task_t, int);
+int	 exception_post(task_t, int);
+int	 exception_wait(int *);
+void	 exception_mark(int);
+void	 exception_deliver(void);
+void	 exception_return(void);
+void	 exception_init(void);
+__BEGIN_DECLS
+
+#endif /* !_EXCEPT_H */
diff --git a/prex-0.9.0/sys/include/hal.h b/prex-0.9.0/sys/include/hal.h
new file mode 100755
index 0000000..e8bc151
--- /dev/null
+++ b/prex-0.9.0/sys/include/hal.h
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PREX_HAL_H
+#define _PREX_HAL_H
+
+#include <types.h>
+#include <sys/bootinfo.h>
+#include <context.h>
+#include <mmu.h>
+
+#define NO_PGD		((pgd_t)0)	/* non-existent pgd */
+
+/*
+ * Types for context_set()
+ */
+#define CTX_KSTACK	0	/* set kernel mode stack address */
+#define CTX_KENTRY	1	/* set kernel mode entry address */
+#define CTX_KARG	2	/* set kernel mode argument */
+#define CTX_USTACK	3	/* set user mode stack address */
+#define CTX_UENTRY	4	/* set user mode entry addres */
+#define CTX_UARG	5	/* set user mode argument */
+
+/*
+ * page types for mmu_map()
+ */
+#define PG_UNMAP	0	/* no page */
+#define PG_READ		1	/* user - read only */
+#define PG_WRITE	2	/* user - read/write */
+#define PG_SYSTEM	3	/* system */
+#define PG_IOMEM	4	/* system - no cache */
+
+/*
+ * Virtual/physical address mapping
+ */
+struct mmumap
+{
+	vaddr_t		virt;		/* virtual address */
+	paddr_t		phys;		/* physical address */
+	psize_t		size;		/* size */
+	int		type;		/* mapping type */
+};
+
+#define AUTOSIZE	0
+
+/*
+ * type of virtual memory mappings
+ */
+#define VMT_NULL	0
+#define VMT_RAM		1
+#define VMT_ROM		2
+#define VMT_DMA		3
+#define VMT_IO		4
+
+
+/*
+ * Return value of ISR
+ */
+#define INT_DONE	0	/* done */
+#define INT_ERROR	1	/* error */
+#define INT_CONTINUE	2	/* continue to IST */
+
+/* No IST for irq_attach() */
+#define IST_NONE        ((void (*)(void *)) -1)
+
+/*
+ * Interrupt mode for interrupt_setup()
+ */
+#define IMODE_EDGE	0	/* edge trigger */
+#define IMODE_LEVEL	1	/* level trigger */
+
+
+__BEGIN_DECLS
+void	  context_set(context_t, int, register_t);
+void	  context_switch(context_t, context_t);
+void	  context_save(context_t);
+void	  context_restore(context_t);
+void	  context_dump(context_t);
+
+void	  mmu_init(struct mmumap *);
+void	  mmu_premap(paddr_t, vaddr_t);
+pgd_t	  mmu_newmap(void);
+void	  mmu_terminate(pgd_t);
+int	  mmu_map(pgd_t, paddr_t, vaddr_t, size_t, int);
+void	  mmu_switch(pgd_t);
+paddr_t	  mmu_extract(pgd_t, vaddr_t, size_t);
+
+int	  copyin(const void *, void *, size_t);
+int	  copyout(const void *, void *, size_t);
+int	  copyinstr(const void *, void *, size_t);
+
+int	  splhigh(void);
+int	  spl0(void);
+void	  splx(int);
+
+void	  syscall_ret(void);
+
+void	  interrupt_mask(int);
+void	  interrupt_unmask(int, int);
+void	  interrupt_setup(int, int);
+void	  interrupt_init(void);
+
+void	  machine_startup(void);
+void	  machine_idle(void);
+void	  machine_powerdown(int);
+void	  machine_abort(void);
+void	  machine_bootinfo(struct bootinfo **);
+
+void	  clock_init(void);
+
+#ifdef DEBUG
+void	  diag_init(void);
+void	  diag_puts(char *);
+#else
+#define   diag_init()	((void)0)
+#endif
+__END_DECLS
+
+#endif /* !_PREX_HAL_H */
diff --git a/prex-0.9.0/sys/include/ipc.h b/prex-0.9.0/sys/include/ipc.h
new file mode 100755
index 0000000..a0153dd
--- /dev/null
+++ b/prex-0.9.0/sys/include/ipc.h
@@ -0,0 +1,64 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _IPC_H
+#define _IPC_H
+
+#include <sys/cdefs.h>
+#include <types.h>
+#include <sys/list.h>
+#include <sys/queue.h>
+#include <ipc/ipc.h>
+
+struct object {
+	struct list	link;		/* linkage for all objects in system */
+	char		name[MAXOBJNAME]; /* object name */
+	struct list	task_link;	/* linkage on object list in task */
+	task_t		owner;		/* creator of this object */
+	struct queue	sendq;		/* queue for sender threads */
+	struct queue	recvq;		/* queue for receiver threads */
+};
+
+__BEGIN_DECLS
+int	 object_create(const char *, object_t *);
+int	 object_lookup(const char *, object_t *);
+int	 object_destroy(object_t);
+int	 object_valid(object_t);
+void	 object_cleanup(task_t);
+void	 object_init(void);
+
+int	 msg_send(object_t, void *, size_t);
+int	 msg_receive(object_t, void *, size_t);
+int	 msg_reply(object_t, void *, size_t);
+void	 msg_cancel(thread_t);
+void	 msg_abort(object_t);
+void	 msg_init(void);
+__BEGIN_DECLS
+
+#endif /* !_IPC_H */
diff --git a/prex-0.9.0/sys/include/irq.h b/prex-0.9.0/sys/include/irq.h
new file mode 100755
index 0000000..21d19ea
--- /dev/null
+++ b/prex-0.9.0/sys/include/irq.h
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _IRQ_H
+#define _IRQ_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/sysinfo.h>
+#include <sys/ipl.h>
+#include <event.h>
+
+struct irq {
+	int		vector;		/* vector number */
+	int		(*isr)(void *);	/* pointer to isr */
+	void		(*ist)(void *);	/* pointer to ist */
+	void		*data;		/* data to be passed for isr/ist */
+	int		priority;	/* interrupt priority */
+	u_int		count;		/* interrupt count */
+	int		istreq;		/* number of ist request */
+	thread_t	thread;		/* thread id of ist */
+	struct event	istevt;		/* event for ist */
+};
+
+/*
+ * Return values from ISR.
+ */
+#define INT_DONE	0	/* success */
+#define INT_ERROR	1	/* interrupt not handled */
+#define INT_CONTINUE	2	/* continue processing (Request IST) */
+
+/*
+ * Macro to map an interrupt priority level to IST priority.
+ */
+#define ISTPRI(pri)	(PRI_IST + (IPL_HIGH - pri))
+
+/* No IST for irq_attach() */
+#define IST_NONE	((void (*)(void *)) -1)
+
+__BEGIN_DECLS
+irq_t	 irq_attach(int, int, int, int (*)(void *), void (*)(void *), void *);
+void	 irq_detach(irq_t);
+void	 irq_handler(int);
+int	 irq_info(struct irqinfo *);
+void	 irq_init(void);
+__BEGIN_DECLS
+
+#endif /* !_IRQ_H */
diff --git a/prex-0.9.0/sys/include/kernel.h b/prex-0.9.0/sys/include/kernel.h
new file mode 100755
index 0000000..4b16189
--- /dev/null
+++ b/prex-0.9.0/sys/include/kernel.h
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _KERNEL_H
+#define _KERNEL_H
+
+#include <conf/config.h>
+#include <types.h>
+#include <machine/stdarg.h>
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/errno.h>
+#include <task.h>
+#include <thread.h>
+#include <version.h>
+#include <debug.h>
+#include <libkern.h>
+
+#define __s(x) __STRING(x)
+
+#define HOSTNAME	"Preky"
+#define PROFILE		__s(CONFIG_PROFILE)
+#define MACHINE		__s(CONFIG_MACHINE)
+#define VERSION		__s(MAJORVERSION) "." __s(MINORVERSION) "." __s(PATCHLEVEL)
+
+#define BANNER		"Prex version " VERSION PROFILE " for " MACHINE \
+			" ("__DATE__ ")\n" \
+			"Copyright (c) 2005-2009 Kohsuke Ohtani\n"
+
+/*
+ * Global variables in the kernel.
+ */
+extern struct thread	*curthread;	/* pointer to the current thread */
+extern struct task	kernel_task;	/* kernel task */
+
+#endif /* !_KERNEL_H */
diff --git a/prex-0.9.0/sys/include/kmem.h b/prex-0.9.0/sys/include/kmem.h
new file mode 100755
index 0000000..2a9dd4a
--- /dev/null
+++ b/prex-0.9.0/sys/include/kmem.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _KMEM_H
+#define _KMEM_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	*kmem_alloc(size_t);
+void	 kmem_free(void *);
+void	*kmem_map(void *, size_t);
+void	 kmem_init(void);
+__END_DECLS
+
+#endif /* !_KMEM_H */
diff --git a/prex-0.9.0/sys/include/libkern.h b/prex-0.9.0/sys/include/libkern.h
new file mode 100755
index 0000000..b1c4da2
--- /dev/null
+++ b/prex-0.9.0/sys/include/libkern.h
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LIBKERN_H
+#define _LIBKERN_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <machine/stdarg.h>
+
+__BEGIN_DECLS
+size_t	 strlcpy(char *, const char *, size_t);
+int	 strncmp(const char *, const char *, size_t);
+size_t	 strnlen(const char *, size_t);
+void	*memcpy(void *, const void *, size_t);
+void	*memset(void *, int, size_t);
+int	 vsprintf(char *, const char *, va_list);
+__BEGIN_DECLS
+
+#endif /* !_LIBKERN_H */
diff --git a/prex-0.9.0/sys/include/page.h b/prex-0.9.0/sys/include/page.h
new file mode 100755
index 0000000..e1cdd05
--- /dev/null
+++ b/prex-0.9.0/sys/include/page.h
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PAGE_H
+#define _PAGE_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/sysinfo.h>
+
+__BEGIN_DECLS
+paddr_t	 page_alloc(psize_t);
+void	 page_free(paddr_t, psize_t);
+int	 page_reserve(paddr_t, psize_t);
+void	 page_info(struct meminfo *);
+void	 page_init(void);
+__END_DECLS
+
+#endif /* !_PAGE_H */
diff --git a/prex-0.9.0/sys/include/sched.h b/prex-0.9.0/sys/include/sched.h
new file mode 100755
index 0000000..c99afd6
--- /dev/null
+++ b/prex-0.9.0/sys/include/sched.h
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SCHED_H
+#define _SCHED_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <event.h>
+
+/*
+ * Scheduling policies defined by IEEE Std 1003.1-2001
+ */
+#define SCHED_FIFO	0	/* First in-first out */
+#define SCHED_RR	1	/* Round robin */
+#define	SCHED_OTHER	2	/* Another scheduling policy */
+
+/*
+ * Scheduling quantum (Ticks for context switch)
+ */
+#define QUANTUM		(CONFIG_TIME_SLICE * HZ / 1000)
+
+/*
+ * DPC (Deferred Procedure Call) object
+ */
+struct dpc {
+	struct queue	link;		/* linkage on DPC queue */
+	int		state;
+	void		(*func)(void *); /* callback routine */
+	void		*arg;		/* argument to pass */
+};
+
+/* state for DPC */
+#define DPC_FREE	0x4470463f	/* magic# 'DpF?' */
+#define DPC_PENDING	0x4470503f	/* magic# 'DpP?' */
+
+#define sched_sleep(evt)	sched_tsleep((evt), 0)
+
+__BEGIN_DECLS
+int	 sched_tsleep(struct event *, u_long);
+void	 sched_wakeup(struct event *);
+thread_t sched_wakeone(struct event *);
+void	 sched_unsleep(thread_t, int);
+void	 sched_yield(void);
+void	 sched_suspend(thread_t);
+void	 sched_resume(thread_t);
+void	 sched_tick(void);
+void	 sched_start(thread_t, int, int);
+void	 sched_stop(thread_t);
+void	 sched_lock(void);
+void	 sched_unlock(void);
+int	 sched_getpri(thread_t);
+void	 sched_setpri(thread_t, int, int);
+int	 sched_getpolicy(thread_t);
+int	 sched_setpolicy(thread_t, int);
+void	 sched_dpc(struct dpc *, void (*)(void *), void *);
+void	 sched_init(void);
+__END_DECLS
+
+#endif /* !_SCHED_H */
diff --git a/prex-0.9.0/sys/include/sync.h b/prex-0.9.0/sys/include/sync.h
new file mode 100755
index 0000000..cfa12b2
--- /dev/null
+++ b/prex-0.9.0/sys/include/sync.h
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYNC_H
+#define _SYNC_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/list.h>
+#include <event.h>
+
+struct sem {
+	struct sem	*next;		/* linkage on semaphore list in system */
+	struct list	task_link;	/* linkage on semaphore list in task */
+	task_t		owner;		/* owner task */
+	struct event	event;		/* event */
+	u_int		value;		/* current value */
+	int		refcnt;		/* reference count */
+};
+
+struct mutex {
+	struct list	task_link;	/* linkage on mutex list in task */
+	task_t		owner;		/* owner task */
+	struct event	event;		/* event */
+	struct list	link;		/* linkage on locked mutex list */
+	thread_t	holder;		/* thread that holds the mutex */
+	int		priority;	/* highest priority in waiting threads */
+	int		locks;		/* counter for recursive lock */
+};
+
+struct cond {
+	struct list	task_link;	/* linkage on cv list in task */
+	task_t		owner;		/* owner task */
+	struct event	event;		/* event */
+};
+
+/* maximum value for semaphore. */
+#define MAXSEMVAL		((u_int)((~0u) >> 1))
+
+/* max mutex count to inherit priority */
+#define MAXINHERIT		10
+
+#define MUTEX_INITIALIZER	(mutex_t)0x4d496e69	/* 'MIni' */
+#define COND_INITIALIZER	(cond_t)0x43496e69	/* 'CIni' */
+
+__BEGIN_DECLS
+int	 sem_init(sem_t *, u_int);
+int	 sem_destroy(sem_t *);
+int	 sem_wait(sem_t *, u_long);
+int	 sem_trywait(sem_t *);
+int	 sem_post(sem_t *);
+int	 sem_getvalue(sem_t *, u_int *);
+void	 sem_cleanup(task_t);
+
+int	 mutex_init(mutex_t *);
+int	 mutex_destroy(mutex_t *);
+int	 mutex_lock(mutex_t *);
+int	 mutex_trylock(mutex_t *);
+int	 mutex_unlock(mutex_t *);
+void	 mutex_cancel(thread_t);
+void	 mutex_setpri(thread_t, int);
+void	 mutex_cleanup(task_t);
+
+int	 cond_init(cond_t *);
+int	 cond_destroy(cond_t *);
+int	 cond_wait(cond_t *, mutex_t *);
+int	 cond_signal(cond_t *);
+int	 cond_broadcast(cond_t *);
+void	 cond_cleanup(task_t);
+__END_DECLS
+
+#endif /* !_SYNC_H */
diff --git a/prex-0.9.0/sys/include/system.h b/prex-0.9.0/sys/include/system.h
new file mode 100755
index 0000000..c17f80d
--- /dev/null
+++ b/prex-0.9.0/sys/include/system.h
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYSTEM_H
+#define _SYSTEM_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	 sysinfo(int, void *);
+int	 sys_info(int, void *);
+int	 sys_log(const char *);
+int	 sys_debug(int, void *);
+int	 sys_panic(const char *);
+int	 sys_time(u_long *);
+int	 sys_nosys(void);
+__END_DECLS
+
+#endif /* !_SYSTEM_H */
diff --git a/prex-0.9.0/sys/include/task.h b/prex-0.9.0/sys/include/task.h
new file mode 100755
index 0000000..fd095f8
--- /dev/null
+++ b/prex-0.9.0/sys/include/task.h
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _TASK_H
+#define _TASK_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/list.h>
+#include <sys/capability.h>	/* for cap_t */
+#include <sys/sysinfo.h>
+#include <thread.h>
+#include <timer.h>
+
+/*
+ * Task struct
+ */
+struct task {
+	struct list	link;		/* linkage on task list in system */
+	char		name[MAXTASKNAME]; /* task name */
+	task_t		parent;		/* parent task */
+	vm_map_t	map;		/* address space description */
+	int		suscnt;		/* suspend count */
+	int		flags;		/* flags defined below */
+	cap_t		capability;	/* security permission flag */
+	struct timer	alarm;		/* timer for alarm exception */
+	void		(*handler)(int); /* pointer to exception handler */
+	struct list	threads;	/* list of threads */
+	struct list	objects;	/* IPC objects owned by this task */
+	struct list	mutexes;	/* mutexes owned by this task */
+	struct list	conds;		/* cv owned by this task */
+	struct list	sems;		/* semaphores owned by this task */
+	int		nthreads;	/* number of threads */
+	int		nobjects;	/* number of IPC objects */
+	int		nsyncs;		/* number of syncronizer objects */
+};
+
+#define curtask		(curthread->task)
+
+/* flags */
+#define TF_SYSTEM	0x00000001 /* kernel task (kern_task) */
+#define	TF_TRACE	0x00000002 /* process system call tracing active */
+#define	TF_PROFIL	0x00000004 /* has started profiling */
+#define	TF_AUDIT	0x00000008 /* audit mode */
+
+/* default flags */
+#ifdef CONFIG_AUDIT
+#define TF_DEFAULT	TF_AUDIT
+#else
+#define TF_DEFAULT	0
+#endif
+
+/* vm option for task_create(). */
+#define VM_NEW		0	/* create new memory map */
+#define VM_SHARE	1	/* share parent's memory map */
+#define VM_COPY		2	/* duplicate parent's memory map */
+
+__BEGIN_DECLS
+int	 task_create(task_t, int, task_t *);
+int	 task_terminate(task_t);
+task_t	 task_self(void);
+int	 task_suspend(task_t);
+int	 task_resume(task_t);
+int	 task_setname(task_t, const char *);
+int	 task_setcap(task_t, cap_t);
+int	 task_chkcap(task_t, cap_t);
+int	 task_capable(cap_t);
+int	 task_valid(task_t);
+int	 task_access(task_t);
+int	 task_info(struct taskinfo *);
+void	 task_bootstrap(void);
+void	 task_init(void);
+__END_DECLS
+
+#endif /* !_TASK_H */
diff --git a/prex-0.9.0/sys/include/thread.h b/prex-0.9.0/sys/include/thread.h
new file mode 100755
index 0000000..e509e32
--- /dev/null
+++ b/prex-0.9.0/sys/include/thread.h
@@ -0,0 +1,120 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _THREAD_H
+#define _THREAD_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <sys/list.h>
+#include <sys/sysinfo.h>
+#include <event.h>
+#include <timer.h>
+#include <hal.h>
+
+/*
+ * Description of a thread.
+ */
+struct thread {
+	struct list	link;		/* linkage on all threads */
+	struct list 	task_link;	/* linkage on thread list in task */
+	struct queue	sched_link;	/* linkage on scheduling queue */
+	task_t		task;		/* task to which I belong */
+	int		state;		/* thread state */
+	int		policy;		/* scheduling policy */
+	int		priority;	/* current priority */
+	int		basepri;	/* statical base priority */
+	int		timeleft;	/* remaining ticks to run */
+	u_int		time;		/* total running time */
+	int		resched;	/* true if rescheduling is needed */
+	int		locks;		/* schedule lock counter */
+	int		suscnt;		/* suspend count */
+	struct event	*slpevt;	/* event we are waiting on */
+	int		slpret;		/* return value for sched_tleep */
+	struct timer 	timeout;	/* thread timer */
+	struct timer	*periodic;	/* pointer to periodic timer */
+	uint32_t 	excbits;	/* bitmap of pending exceptions */
+	struct list 	mutexes;	/* mutexes locked by this thread */
+	mutex_t 	mutex_waiting;	/* mutex pointer currently waiting */
+	struct queue 	ipc_link;	/* linkage on IPC queue */
+	void		*msgaddr;	/* kernel address of IPC message */
+	size_t		msgsize;	/* size of IPC message */
+	thread_t	sender;		/* thread that sends IPC message */
+	thread_t	receiver;	/* thread that receives IPC message */
+	object_t 	sendobj;	/* IPC object sending to */
+	object_t 	recvobj;	/* IPC object receiving from */
+	void		*kstack;	/* base address of kernel stack */
+	struct context 	ctx;		/* machine specific context */
+};
+
+/*
+ * Thread state
+ */
+#define TS_RUN		0x00	/* running or ready to run */
+#define TS_SLEEP	0x01	/* awaiting an event */
+#define TS_SUSP		0x02	/* suspend count is not 0 */
+#define TS_EXIT		0x04	/* terminated */
+
+/*
+ * Sleep result
+ */
+#define SLP_SUCCESS	0	/* success */
+#define SLP_BREAK	1	/* break due to some reasons */
+#define SLP_TIMEOUT	2	/* timeout */
+#define SLP_INVAL	3	/* target event becomes invalid */
+#define SLP_INTR	4	/* interrupted by exception */
+
+/*
+ * Scheduling operations for thread_schedparam().
+ */
+#define SOP_GETPRI	0	/* get scheduling priority */
+#define SOP_SETPRI	1	/* set scheduling priority */
+#define SOP_GETPOLICY	2	/* get scheduling policy */
+#define SOP_SETPOLICY	3	/* set scheduling policy */
+
+__BEGIN_DECLS
+int	 thread_create(task_t, thread_t *);
+int	 thread_terminate(thread_t);
+void	 thread_destroy(thread_t);
+int	 thread_load(thread_t, void (*)(void), void *);
+thread_t thread_self(void);
+int	 thread_valid(thread_t);
+void	 thread_yield(void);
+int	 thread_suspend(thread_t);
+int	 thread_resume(thread_t);
+int	 thread_schedparam(thread_t, int, int *);
+void	 thread_idle(void);
+int	 thread_info(struct threadinfo *);
+thread_t kthread_create(void (*)(void *), void *, int);
+void	 kthread_terminate(thread_t);
+void	 thread_init(void);
+__END_DECLS
+
+#endif /* !_THREAD_H */
diff --git a/prex-0.9.0/sys/include/timer.h b/prex-0.9.0/sys/include/timer.h
new file mode 100755
index 0000000..bd5c7cf
--- /dev/null
+++ b/prex-0.9.0/sys/include/timer.h
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _TIMER_H
+#define _TIMER_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/list.h>
+#include <sys/sysinfo.h>
+#include <event.h>
+
+/*
+ * Time-out element.
+ */
+struct timer {
+	struct list	link;		/* linkage on timer chain */
+	int		state;		/* timer state */
+	u_long		expire;		/* expiration time, in ticks */
+	u_long		interval;	/* time interval */
+	void		(*func)(void *); /* function to call */
+	void		*arg;		/* function argument */
+	struct event	event;		/* event for this timer */
+};
+
+/* state for timer */
+#define TM_ACTIVE	0x54616321	/* magic# 'Tac!' */
+#define TM_STOP		0x54737421	/* magic# 'Tst!' */
+
+/*
+ * Macro to compare two timer counts.
+ * time_after() returns true if a is after b.
+ */
+#define time_after(a,b)		(((long)(b) - (long)(a)) < 0)
+#define time_before(a,b)	time_after(b,a)
+
+#define time_after_eq(a,b)	(((long)(a) - (long)(b)) >= 0)
+#define time_before_eq(a,b)	time_after_eq(b,a)
+
+/*
+ * Macro to get the next element on timer list.
+ */
+#define timer_next(head) \
+	(list_entry(list_first(head), struct timer, link))
+
+__BEGIN_DECLS
+void	 timer_callout(struct timer *, u_long, void (*)(void *), void *);
+void	 timer_stop(struct timer *);
+u_long	 timer_delay(u_long);
+int	 timer_sleep(u_long, u_long *);
+int	 timer_alarm(u_long, u_long *);
+int	 timer_periodic(thread_t, u_long, u_long);
+int	 timer_waitperiod(void);
+void	 timer_cancel(thread_t);
+void	 timer_clock(void);
+void	 timer_handler(void);
+u_long	 timer_ticks(void);
+void	 timer_info(struct timerinfo *);
+void	 timer_init(void);
+__END_DECLS
+
+#endif /* !_TIMER_H */
diff --git a/prex-0.9.0/sys/include/types.h b/prex-0.9.0/sys/include/types.h
new file mode 100755
index 0000000..c7c64c7
--- /dev/null
+++ b/prex-0.9.0/sys/include/types.h
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+#include <sys/types.h>
+
+/*
+ * Common kernel type declarations.
+ */
+typedef struct object	*object_t;
+typedef struct task	*task_t;
+typedef struct thread	*thread_t;
+typedef struct device	*device_t;
+typedef struct mutex	*mutex_t;
+typedef struct cond	*cond_t;
+typedef struct sem	*sem_t;
+typedef struct vm_map	*vm_map_t;
+typedef struct irq	*irq_t;
+
+#endif /* !_TYPES_H */
diff --git a/prex-0.9.0/sys/include/version.h b/prex-0.9.0/sys/include/version.h
new file mode 100755
index 0000000..20997e9
--- /dev/null
+++ b/prex-0.9.0/sys/include/version.h
@@ -0,0 +1,4 @@
+
+#define MAJORVERSION	0
+#define MINORVERSION	9
+#define PATCHLEVEL	0
diff --git a/prex-0.9.0/sys/include/vm.h b/prex-0.9.0/sys/include/vm.h
new file mode 100755
index 0000000..3b940c2
--- /dev/null
+++ b/prex-0.9.0/sys/include/vm.h
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _VM_H
+#define _VM_H
+
+#include <types.h>
+#include <sys/cdefs.h>
+#include <sys/sysinfo.h>
+#include <sys/bootinfo.h>
+
+/*
+ * One structure per allocated segment.
+ */
+struct seg {
+	struct seg	*prev;		/* segment list sorted by address */
+	struct seg	*next;
+	struct seg	*sh_prev;	/* link for all shared segments */
+	struct seg	*sh_next;
+	vaddr_t		addr;		/* base address */
+	size_t		size;		/* size */
+	int		flags;		/* SEG_* flag */
+	paddr_t		phys;		/* physical address */
+};
+
+/* Flags for segment */
+#define SEG_READ	0x00000001
+#define SEG_WRITE	0x00000002
+#define SEG_EXEC	0x00000004
+#define SEG_SHARED	0x00000008
+#define SEG_MAPPED	0x00000010
+#define SEG_FREE	0x00000080
+
+/* Attribute for vm_attribute() */
+#define	PROT_NONE	0x0		/* pages cannot be accessed */
+#define	PROT_READ	0x1		/* pages can be read */
+#define	PROT_WRITE	0x2		/* pages can be written */
+#define	PROT_EXEC	0x4		/* pages can be executed */
+
+/*
+ * VM mapping per one task.
+ */
+struct vm_map {
+	struct seg	head;		/* list head of segements */
+	int		refcnt;		/* reference count */
+	pgd_t		pgd;		/* page directory */
+	size_t		total;		/* total used size */
+};
+
+__BEGIN_DECLS
+int	 vm_allocate(task_t, void **, size_t, int);
+int	 vm_free(task_t, void *);
+int	 vm_attribute(task_t, void *, int);
+int	 vm_map(task_t, void *, size_t, void **);
+vm_map_t vm_dup(vm_map_t);
+vm_map_t vm_create(void);
+int	 vm_reference(vm_map_t);
+void	 vm_terminate(vm_map_t);
+void	 vm_switch(vm_map_t);
+int	 vm_load(vm_map_t, struct module *, void **);
+paddr_t	 vm_translate(vaddr_t, size_t);
+int	 vm_info(struct vminfo *);
+void	 vm_init(void);
+__END_DECLS
+
+#endif /* !_VM_H */
diff --git a/prex-0.9.0/sys/ipc/msg.c b/prex-0.9.0/sys/ipc/msg.c
new file mode 100755
index 0000000..0f82427
--- /dev/null
+++ b/prex-0.9.0/sys/ipc/msg.c
@@ -0,0 +1,444 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * msg.c - routines to transmit a message.
+ */
+
+/**
+ * IPC transmission:
+ *
+ * Messages are sent to the specific object by using msg_send.  The
+ * transmission of a message is completely synchronous with this
+ * kernel. This means the thread which sent a message is blocked until
+ * it receives a response from another thread.  msg_receive performs
+ * reception of a message. msg_receive is also blocked when no message
+ * is reached to the target object.  The receiver thread must answer the
+ * message using msg_reply after processing the message.
+ *
+ * The receiver thread can not receive an additional message until it
+ * replies to the sender. In short, a thread can receive only one
+ * message at once. In other hand, once the thread receives a message,
+ * it can send another message to different object. This mechanism
+ * allows threads to redirect the sender's request to another thread.
+ *
+ * A message is copied from thread to thread directly without any kernel
+ * buffering. The message buffer in sender's memory space is automatically
+ * mapped to the receiver's memory by kernel. Since there is no page
+ * out of memory in this system, we can copy the message data via physical
+ * memory at anytime.
+ */
+
+#include <kernel.h>
+#include <sched.h>
+#include <task.h>
+#include <kmem.h>
+#include <thread.h>
+#include <task.h>
+#include <event.h>
+#include <ipc.h>
+
+/* forward declarations */
+static thread_t	msg_dequeue(queue_t);
+static void	msg_enqueue(queue_t, thread_t);
+
+static struct event ipc_event;		/* event for IPC operation */
+
+/*
+ * Send a message.
+ *
+ * The current thread will be blocked until any other thread
+ * receives and reply the message.  A thread can send a
+ * message to any object if it knows the object id.
+ */
+int
+msg_send(object_t obj, void *msg, size_t size)
+{
+	struct msg_header *hdr;
+	thread_t t;
+	void *kmsg;
+	int rc;
+
+	if (!user_area(msg))
+		return EFAULT;
+
+	if (size < sizeof(struct msg_header))
+		return EINVAL;
+
+	sched_lock();
+
+	if (!object_valid(obj)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	/*
+	 * A thread can not send a message when it is
+	 * already receiving from the target object.
+	 * It will obviously cause a deadlock.
+	 */
+	if (obj == curthread->recvobj) {
+		sched_unlock();
+		return EDEADLK;
+	}
+	/*
+	 * Translate message address to the kernel linear
+	 * address.  So that a receiver thread can access
+	 * the message via kernel pointer. We can catch
+	 * the page fault here.
+	 */
+	if ((kmsg = kmem_map(msg, size)) == NULL) {
+		sched_unlock();
+		return EFAULT;
+	}
+	curthread->msgaddr = kmsg;
+	curthread->msgsize = size;
+
+	/*
+	 * The sender ID is filled in the message header
+	 * by the kernel. So, the receiver can trust it.
+	 */
+	hdr = (struct msg_header *)kmsg;
+	hdr->task = curtask;
+
+	/*
+	 * If receiver already exists, wake it up.
+	 * The highest priority thread can get the message.
+	 */
+	if (!queue_empty(&obj->recvq)) {
+		t = msg_dequeue(&obj->recvq);
+		sched_unsleep(t, 0);
+	}
+	/*
+	 * Sleep until we get a reply message.
+	 * Note: Do not touch any data in the object
+	 * structure after we wakeup. This is because the
+	 * target object may be deleted while we are sleeping.
+	 */
+	curthread->sendobj = obj;
+	msg_enqueue(&obj->sendq, curthread);
+	rc = sched_sleep(&ipc_event);
+	if (rc == SLP_INTR)
+		queue_remove(&curthread->ipc_link);
+	curthread->sendobj = NULL;
+
+	sched_unlock();
+
+	/*
+	 * Check sleep result.
+	 */
+	switch (rc) {
+	case SLP_BREAK:
+		return EAGAIN;	/* Receiver has been terminated */
+	case SLP_INVAL:
+		return EINVAL;	/* Object has been deleted */
+	case SLP_INTR:
+		return EINTR;	/* Exception */
+	default:
+		/* DO NOTHING */
+		break;
+	}
+	return 0;
+}
+
+/*
+ * Receive a message.
+ *
+ * A thread can receive a message from the object which was
+ * created by any thread belongs to same task. If the message
+ * has not reached yet, it blocks until any message comes in.
+ *
+ * The size argument specifies the "maximum" size of the message
+ * buffer to receive. If the sent message is larger than this
+ * size, the kernel will automatically clip the message to this
+ * maximum buffer size.
+ *
+ * When a message is received, the sender thread is removed from
+ * object's send queue. So, another thread can receive the
+ * subsequent message from that object. This is important for
+ * the multi-thread server which must receive multiple messages
+ * simultaneously.
+ */
+int
+msg_receive(object_t obj, void *msg, size_t size)
+{
+	thread_t t;
+	size_t len;
+	int rc, error = 0;
+
+	if (!user_area(msg))
+		return EFAULT;
+
+	sched_lock();
+
+	if (!object_valid(obj)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (obj->owner != curtask) {
+		sched_unlock();
+		return EACCES;
+	}
+	/*
+	 * Check if this thread finished previous receive
+	 * operation.  A thread can not receive different
+	 * messages at once.
+	 */
+	if (curthread->recvobj) {
+		sched_unlock();
+		return EBUSY;
+	}
+	curthread->recvobj = obj;
+
+	/*
+	 * If no message exists, wait until message arrives.
+	 */
+	while (queue_empty(&obj->sendq)) {
+		/*
+		 * Block until someone sends a message.
+		 */
+		msg_enqueue(&obj->recvq, curthread);
+		rc = sched_sleep(&ipc_event);
+		if (rc != 0) {
+			/*
+			 * Receive is failed due to some reasons.
+			 */
+			switch (rc) {
+			case SLP_INVAL:
+				error = EINVAL;	/* Object has been deleted */
+				break;
+			case SLP_INTR:
+				queue_remove(&curthread->ipc_link);
+				error = EINTR;	/* Got exception */
+				break;
+			default:
+				panic("msg_receive");
+				break;
+			}
+			curthread->recvobj = NULL;
+			sched_unlock();
+			return error;
+		}
+
+		/*
+		 * Check the existence of the sender thread again.
+		 * Even if this thread is woken by the sender thread,
+		 * the message may be received by another thread.
+		 * This may happen when another high priority thread
+		 * becomes runnable before we receive the message.
+		 */
+	}
+
+	t = msg_dequeue(&obj->sendq);
+
+	/*
+	 * Copy out the message to the user-space.
+	 */
+	len = MIN(size, t->msgsize);
+	if (len > 0) {
+		if (copyout(t->msgaddr, msg, len)) {
+			msg_enqueue(&obj->sendq, t);
+			curthread->recvobj = NULL;
+			sched_unlock();
+			return EFAULT;
+		}
+	}
+	/*
+	 * Detach the message from the target object.
+	 */
+	curthread->sender = t;
+	t->receiver = curthread;
+
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Send a reply message.
+ *
+ * The target object must be the object that we are receiving.
+ * Otherwise, this function will be failed.
+ */
+int
+msg_reply(object_t obj, void *msg, size_t size)
+{
+	thread_t t;
+	size_t len;
+
+	if (!user_area(msg))
+		return EFAULT;
+
+	sched_lock();
+
+	if (!object_valid(obj) || obj != curthread->recvobj) {
+		sched_unlock();
+		return EINVAL;
+	}
+	/*
+	 * Check if sender still exists
+	 */
+	if (curthread->sender == NULL) {
+		/* Clear receive state */
+		curthread->recvobj = NULL;
+		sched_unlock();
+		return EINVAL;
+	}
+	/*
+	 * Copy a message to the sender's buffer.
+	 */
+	t = curthread->sender;
+	len = MIN(size, t->msgsize);
+	if (len > 0) {
+		if (copyin(msg, t->msgaddr, len)) {
+			sched_unlock();
+			return EFAULT;
+		}
+	}
+	/*
+	 * Wakeup sender with no error.
+	 */
+	sched_unsleep(t, 0);
+	t->receiver = NULL;
+
+	/* Clear transmit state */
+	curthread->sender = NULL;
+	curthread->recvobj = NULL;
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Cancel pending message operation of the specified thread.
+ * This is called when the thread is terminated.
+ *
+ * We have to handle the following conditions to prevent deadlock.
+ *
+ * If the terminated thread is sending a message:
+ *  1. A message is already received.
+ *     -> The receiver thread will reply to the invalid thread.
+ *
+ *  2. A message is not received yet.
+ *     -> The thread remains in send queue of the object.
+ *
+ * When the terminated thread is receiving a message.
+ *  3. A message is already sent.
+ *     -> The sender thread will wait for reply forever.
+ *
+ *  4. A message is not sent yet.
+ *     -> The thread remains in receive queue of the object.
+ */
+void
+msg_cancel(thread_t t)
+{
+
+	sched_lock();
+
+	if (t->sendobj != NULL) {
+		if (t->receiver != NULL)
+			t->receiver->sender = NULL;
+		else
+			queue_remove(&t->ipc_link);
+	}
+	if (t->recvobj != NULL) {
+		if (t->sender != NULL) {
+			sched_unsleep(t->sender, SLP_BREAK);
+			t->sender->receiver = NULL;
+		} else
+			queue_remove(&t->ipc_link);
+	}
+	sched_unlock();
+}
+
+/*
+ * Abort all message operations relevant to the specified object.
+ * This is called when the target object is deleted.
+ */
+void
+msg_abort(object_t obj)
+{
+	queue_t q;
+	thread_t t;
+
+	sched_lock();
+
+	/*
+	 * Force wakeup all threads in the send queue.
+	 */
+	while (!queue_empty(&obj->sendq)) {
+		q = dequeue(&obj->sendq);
+		t = queue_entry(q, struct thread, ipc_link);
+		sched_unsleep(t, SLP_INVAL);
+	}
+	/*
+	 * Force wakeup all threads waiting for receive.
+	 */
+	while (!queue_empty(&obj->recvq)) {
+		q = dequeue(&obj->recvq);
+		t = queue_entry(q, struct thread, ipc_link);
+		sched_unsleep(t, SLP_INVAL);
+	}
+	sched_unlock();
+}
+
+/*
+ * Dequeue thread from the IPC queue.
+ * The most highest priority thread will be chosen.
+ */
+static thread_t
+msg_dequeue(queue_t head)
+{
+	queue_t q;
+	thread_t t, top;
+
+	q = queue_first(head);
+	top = queue_entry(q, struct thread, ipc_link);
+
+	while (!queue_end(head, q)) {
+		t = queue_entry(q, struct thread, ipc_link);
+		if (t->priority < top->priority)
+			top = t;
+		q = queue_next(q);
+	}
+	queue_remove(&top->ipc_link);
+	return top;
+}
+
+static void
+msg_enqueue(queue_t head, thread_t t)
+{
+
+	enqueue(head, &t->ipc_link);
+}
+
+void
+msg_init(void)
+{
+
+	event_init(&ipc_event, "ipc");
+}
diff --git a/prex-0.9.0/sys/ipc/object.c b/prex-0.9.0/sys/ipc/object.c
new file mode 100755
index 0000000..607fe70
--- /dev/null
+++ b/prex-0.9.0/sys/ipc/object.c
@@ -0,0 +1,250 @@
+/*-
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * object.c - object service
+ */
+
+/**
+ * IPC object:
+ *
+ * An object represents service, state, or policies etc. To manipulate
+ * objects, kernel provide 3 functions: create, destroy and lookup.
+ * Prex task will create an object to provide its services to other
+ * tasks. The tasks will communicate by sending a message to the
+ * object each other. In typical case, a server task creates an object
+ * and client tasks will send a request message to it.
+ *
+ * A substance of object is stored in kernel space, and so it's protected
+ * from user mode code.  Usually, an object has a unique name within a
+ * system. Before a task sends a message to the specific object, it must
+ * obtain the object ID by looking up the name of the target object.
+ *
+ * A task can create a private object which does not have name. Since
+ * another task can not obtain the ID of such object, the IPC operations
+ * for the private object are limited to the threads in the same task.
+ *
+ * The object name started with '!' means that it is a protected object.
+ * The protected object can be created only by the task which has
+ * CAP_PROTSERV capability. Since this capability is given to the known
+ * system servers, the client task can always trust the object owner.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <sched.h>
+#include <task.h>
+#include <ipc.h>
+
+/* forward declarations */
+static object_t	object_find(const char *);
+
+static struct list	object_list;	/* list of all objects */
+
+/*
+ * Create a new object.
+ *
+ * The ID of the new object is stored in objp on success.
+ * The name of the object must be unique in the system.
+ * Or, the object can be created without name by setting
+ * NULL as name argument. This object can be used as a
+ * private object which can be accessed only by threads in
+ * same task.
+ */
+int
+object_create(const char *name, object_t *objp)
+{
+	struct object *obj = 0;
+	char str[MAXOBJNAME];
+	int error;
+
+	if (name == NULL)
+		str[0] = '\0';
+	else {
+		error = copyinstr(name, str, MAXOBJNAME);
+		if (error)
+			return error;
+
+		/* Check capability if name is protected object. */
+		if (name[0] == '!' && !task_capable(CAP_PROTSERV))
+			return EPERM;
+	}
+	sched_lock();
+
+	if (curtask->nobjects >= MAXOBJECTS) {
+		sched_unlock();
+		return EAGAIN;
+	}
+	/*
+	 * Check user buffer first. This can reduce the error
+	 * recovery for the subsequence resource allocations.
+	 */
+	if (copyout(&obj, objp, sizeof(obj))) {
+		sched_unlock();
+		return EFAULT;
+	}
+	if (object_find(str) != NULL) {
+		sched_unlock();
+		return EEXIST;
+	}
+	if ((obj = kmem_alloc(sizeof(*obj))) == NULL) {
+		sched_unlock();
+		return ENOMEM;
+	}
+	if (name != NULL)
+		strlcpy(obj->name, str, MAXOBJNAME);
+
+	obj->owner = curtask;
+	queue_init(&obj->sendq);
+	queue_init(&obj->recvq);
+	list_insert(&curtask->objects, &obj->task_link);
+	curtask->nobjects++;
+	list_insert(&object_list, &obj->link);
+	copyout(&obj, objp, sizeof(obj));
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Search an object in the object name space. The object
+ * name must be null-terminated string.
+ */
+int
+object_lookup(const char *name, object_t *objp)
+{
+	object_t obj;
+	char str[MAXOBJNAME];
+	int error;
+
+	error = copyinstr(name, str, MAXOBJNAME);
+	if (error)
+		return error;
+
+	sched_lock();
+	obj = object_find(str);
+	sched_unlock();
+
+	if (obj == NULL)
+		return ENOENT;
+
+	if (copyout(&obj, objp, sizeof(obj)))
+		return EFAULT;
+	return 0;
+}
+
+int
+object_valid(object_t obj)
+{
+	object_t tmp;
+	list_t n;
+
+	for (n = list_first(&object_list); n != &object_list;
+	     n = list_next(n)) {
+		tmp = list_entry(n, struct object, link);
+		if (tmp == obj)
+			return 1;
+	}
+	return 0;
+}
+
+static object_t
+object_find(const char *name)
+{
+	object_t obj;
+	list_t n;
+
+	for (n = list_first(&object_list); n != &object_list;
+	     n = list_next(n)) {
+		obj = list_entry(n, struct object, link);
+		if (!strncmp(obj->name, name, MAXOBJNAME))
+			return obj;
+	}
+	return 0;
+}
+
+/*
+ * Deallocate an object-- the internal version of object_destory.
+ */
+static void
+object_deallocate(object_t obj)
+{
+
+	msg_abort(obj);
+	obj->owner->nobjects--;
+	list_remove(&obj->task_link);
+	list_remove(&obj->link);
+	kmem_free(obj);
+}
+
+/*
+ * Destroy an object.
+ *
+ * All pending messages related to the target object are
+ * automatically cancelled.
+ */
+int
+object_destroy(object_t obj)
+{
+
+	sched_lock();
+	if (!object_valid(obj)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (obj->owner != curtask) {
+		sched_unlock();
+		return EACCES;
+	}
+	object_deallocate(obj);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Clean up for task termination.
+ */
+void
+object_cleanup(task_t task)
+{
+	object_t obj;
+
+	while (!list_empty(&task->objects)) {
+		obj = list_entry(list_first(&task->objects),
+				 struct object, task_link);
+		object_deallocate(obj);
+	}
+}
+
+void
+object_init(void)
+{
+
+	list_init(&object_list);
+}
diff --git a/prex-0.9.0/sys/kern/debug.c b/prex-0.9.0/sys/kern/debug.c
new file mode 100755
index 0000000..7043465
--- /dev/null
+++ b/prex-0.9.0/sys/kern/debug.c
@@ -0,0 +1,203 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * debug.c - kernel debug services
+ */
+
+#include <kernel.h>
+#include <task.h>
+#include <thread.h>
+#include <sched.h>
+#include <hal.h>
+#include <sys/dbgctl.h>
+
+typedef void (*diagfn_t)(char *);
+typedef void (*abtfn_t)(void);
+
+static abtfn_t	db_abort = &machine_abort;	/* abort handler */
+static diagfn_t	db_puts = &diag_puts;		/* function to print string */
+static char	db_msg[DBGMSGSZ];		/* debug message string */
+
+static char	log_buf[LOGBUFSZ];		/* log buffer */
+static u_long	log_head;			/* index for log head */
+static u_long	log_tail;			/* iundex for log tail */
+static u_long	log_len;			/* length of log */
+
+#define LOGINDEX(x)	((x) & (LOGBUFSZ - 1))
+
+/*
+ * Scaled down version of C Library printf.
+ * Only %s %u %d %c %x and zero pad flag are recognized.
+ * Printf should not be used for chit-chat.
+ */
+void
+printf(const char *fmt, ...)
+{
+	va_list args;
+	int i, s;
+	char c;
+
+	s = splhigh();
+	va_start(args, fmt);
+	vsprintf(db_msg, fmt, args);
+
+	(*db_puts)(db_msg);
+
+	/*
+	 * Record to log buffer.
+	 */
+	for (i = 0; i < DBGMSGSZ; i++) {
+		c = db_msg[i];
+		if (c == '\0')
+			break;
+		log_buf[LOGINDEX(log_tail)] = c;
+		log_tail++;
+		if (log_len < LOGBUFSZ)
+			log_len++;
+		else
+			log_head = log_tail - LOGBUFSZ;
+	}
+	va_end(args);
+	splx(s);
+}
+
+/*
+ * Kernel assertion.
+ */
+void
+assert(const char *file, int line, const char *exp)
+{
+
+	printf("Assertion failed: %s line:%d '%s'\n", file, line, exp);
+
+	(*db_abort)();
+	/* NOTREACHED */
+}
+
+/*
+ * Kernel panic.
+ */
+void
+panic(const char *msg)
+{
+
+	printf("Kernel panic: %s\n", msg);
+
+	(*db_abort)();
+	/* NOTREACHED */
+}
+
+/*
+ * Copy log to the user's buffer.
+ */
+static int
+getlog(char *buf)
+{
+	u_long cnt, len, i;
+	int s, error = 0;
+	char c;
+
+	s = splhigh();
+	i = log_head;
+	len = log_len;
+	if (len >= LOGBUFSZ) {
+		/*
+		 * Overrun found. Discard broken message.
+		 */
+		while (len > 0 && log_buf[LOGINDEX(i)] != '\n') {
+			i++;
+			len--;
+		}
+	}
+	for (cnt = 0; cnt < LOGBUFSZ; cnt++) {
+		if (cnt < len)
+			c = log_buf[LOGINDEX(i)];
+		else
+			c = '\0';
+		if (copyout(&c, buf, 1)) {
+			error = EFAULT;
+			break;
+		}
+		i++;
+		buf++;
+	}
+	splx(s);
+	return error;
+}
+
+/*
+ * Debug control service.
+ */
+int
+dbgctl(int cmd, void *data)
+{
+	int error = 0;
+	size_t size;
+	task_t task;
+	struct diag_ops *dops;
+	struct abort_ops *aops;
+
+	switch (cmd) {
+	case DBGC_LOGSIZE:
+		size = LOGBUFSZ;
+		error = copyout(&size, data, sizeof(size));
+		break;
+
+	case DBGC_GETLOG:
+		error = getlog(data);
+		break;
+
+	case DBGC_TRACE:
+		task = (task_t)data;
+		if (task_valid(task)) {
+			task->flags ^= TF_TRACE;
+		}
+		break;
+
+	case DBGC_DUMPTRAP:
+		context_dump(&curthread->ctx);
+		break;
+
+	case DBGC_SETDIAG:
+		dops = data;
+		db_puts = dops->puts;
+		break;
+
+	case DBGC_SETABORT:
+		aops = data;
+		db_abort = aops->abort;
+		break;
+
+	default:
+		error = EINVAL;
+		break;
+	}
+	return error;
+}
diff --git a/prex-0.9.0/sys/kern/device.c b/prex-0.9.0/sys/kern/device.c
new file mode 100755
index 0000000..b2b6177
--- /dev/null
+++ b/prex-0.9.0/sys/kern/device.c
@@ -0,0 +1,562 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * device.c - device I/O support routines
+ */
+
+/**
+ * The device_* system calls are interfaces to access the specific
+ * device object which is handled by the related device driver.
+ *
+ * The routines in this moduile have the following role:
+ *  - Manage the name space for device objects.
+ *  - Forward user I/O requests to the drivers with minimum check.
+ *  - Provide the table for the Driver-Kernel Interface.
+ */
+
+#include <kernel.h>
+#include <irq.h>
+#include <kmem.h>
+#include <task.h>
+#include <timer.h>
+#include <page.h>
+#include <sched.h>
+#include <exception.h>
+#include <vm.h>
+#include <device.h>
+#include <system.h>
+#include <hal.h>
+
+/* forward declarations */
+static device_t	device_create(struct driver *, const char *, int);
+static int	device_destroy(device_t);
+static device_t	device_lookup(const char *);
+static int	device_valid(device_t);
+static int	device_reference(device_t);
+static void	device_release(device_t);
+static void	*device_private(device_t);
+static int	device_control(device_t, u_long, void *);
+static int	device_broadcast(u_long, void *, int);
+
+#define DKIENT(func)	(dkifn_t)(func)
+
+/*
+ * Driver-Kernel Interface (DKI)
+ */
+static const dkifn_t dkient[] = {
+	/*  0 */ DKIENT(copyin),
+	/*  1 */ DKIENT(copyout),
+	/*  2 */ DKIENT(copyinstr),
+	/*  3 */ DKIENT(kmem_alloc),
+	/*  4 */ DKIENT(kmem_free),
+	/*  5 */ DKIENT(kmem_map),
+	/*  6 */ DKIENT(page_alloc),
+	/*  7 */ DKIENT(page_free),
+	/*  8 */ DKIENT(page_reserve),
+	/*  9 */ DKIENT(irq_attach),
+	/* 10 */ DKIENT(irq_detach),
+	/* 11 */ DKIENT(spl0),
+	/* 12 */ DKIENT(splhigh),
+	/* 13 */ DKIENT(splx),
+	/* 14 */ DKIENT(timer_callout),
+	/* 15 */ DKIENT(timer_stop),
+	/* 16 */ DKIENT(timer_delay),
+	/* 17 */ DKIENT(timer_ticks),
+	/* 18 */ DKIENT(sched_lock),
+	/* 19 */ DKIENT(sched_unlock),
+	/* 20 */ DKIENT(sched_tsleep),
+	/* 21 */ DKIENT(sched_wakeup),
+	/* 22 */ DKIENT(sched_dpc),
+	/* 23 */ DKIENT(task_capable),
+	/* 24 */ DKIENT(exception_post),
+	/* 25 */ DKIENT(device_create),
+	/* 26 */ DKIENT(device_destroy),
+	/* 27 */ DKIENT(device_lookup),
+	/* 28 */ DKIENT(device_control),
+	/* 29 */ DKIENT(device_broadcast),
+	/* 30 */ DKIENT(device_private),
+	/* 31 */ DKIENT(machine_bootinfo),
+	/* 32 */ DKIENT(machine_powerdown),
+	/* 33 */ DKIENT(sysinfo),
+#ifdef DEBUG
+	/* 34 */ DKIENT(panic),
+	/* 35 */ DKIENT(printf),
+	/* 36 */ DKIENT(dbgctl),
+#else
+	/* 34 */ DKIENT(machine_abort),
+	/* 35 */ DKIENT(sys_nosys),
+	/* 36 */ DKIENT(sys_nosys),
+#endif
+};
+
+/* list head of the devices */
+static struct device *device_list = NULL;
+
+/*
+ * device_create - create new device object.
+ *
+ * A device object is created by the device driver to provide
+ * I/O services to applications.  Returns device ID on
+ * success, or 0 on failure.
+ */
+static device_t
+device_create(struct driver *drv, const char *name, int flags)
+{
+	device_t dev;
+	size_t len;
+	void *private = NULL;
+
+	ASSERT(drv != NULL);
+
+	/* Check the length of name. */
+	len = strnlen(name, MAXDEVNAME);
+	if (len == 0 || len >= MAXDEVNAME)
+		return NULL;
+
+	sched_lock();
+
+	/* Check if specified name is already used. */
+	if (device_lookup(name) != NULL)
+		panic("duplicate device");
+
+	/*
+	 * Allocate a device structure and device private data.
+	 */
+	if ((dev = kmem_alloc(sizeof(*dev))) == NULL)
+		panic("device_create");
+
+	if (drv->devsz != 0) {
+		if ((private = kmem_alloc(drv->devsz)) == NULL)
+			panic("devsz");
+		memset(private, 0, drv->devsz);
+	}
+	strlcpy(dev->name, name, len + 1);
+	dev->driver = drv;
+	dev->flags = flags;
+	dev->active = 1;
+	dev->refcnt = 1;
+	dev->private = private;
+	dev->next = device_list;
+	device_list = dev;
+
+	sched_unlock();
+	return dev;
+}
+
+/*
+ * Destroy a device object. If some other threads still
+ * refer the target device, the destroy operation will be
+ * pending until its reference count becomes 0.
+ */
+static int
+device_destroy(device_t dev)
+{
+
+	sched_lock();
+	if (!device_valid(dev)) {
+		sched_unlock();
+		return ENODEV;
+	}
+	dev->active = 0;
+	device_release(dev);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Look up a device object by device name.
+ */
+static device_t
+device_lookup(const char *name)
+{
+	device_t dev;
+
+	for (dev = device_list; dev != NULL; dev = dev->next) {
+		if (!strncmp(dev->name, name, MAXDEVNAME))
+			return dev;
+	}
+	return NULL;
+}
+
+/*
+ * Return device's private data.
+ */
+static void *
+device_private(device_t dev)
+{
+	ASSERT(dev != NULL);
+	ASSERT(dev->private != NULL);
+
+	return dev->private;
+}
+
+/*
+ * Return true if specified device is valid.
+ */
+static int
+device_valid(device_t dev)
+{
+	device_t tmp;
+	int found = 0;
+
+	for (tmp = device_list; tmp != NULL; tmp = tmp->next) {
+		if (tmp == dev) {
+			found = 1;
+			break;
+		}
+	}
+	if (found && dev->active)
+		return 1;
+	return 0;
+}
+
+/*
+ * Increment the reference count on an active device.
+ */
+static int
+device_reference(device_t dev)
+{
+
+	sched_lock();
+	if (!device_valid(dev)) {
+		sched_unlock();
+		return ENODEV;
+	}
+	if (!task_capable(CAP_RAWIO)) {
+		sched_unlock();
+		return EPERM;
+	}
+	dev->refcnt++;
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Decrement the reference count on a device. If the reference
+ * count becomes zero, we can release the resource for the device.
+ */
+static void
+device_release(device_t dev)
+{
+	device_t *tmp;
+
+	sched_lock();
+	if (--dev->refcnt > 0) {
+		sched_unlock();
+		return;
+	}
+	/*
+	 * No more references - we can remove the device.
+	 */
+	for (tmp = &device_list; *tmp; tmp = &(*tmp)->next) {
+		if (*tmp == dev) {
+			*tmp = dev->next;
+			break;
+		}
+	}
+	kmem_free(dev);
+	sched_unlock();
+}
+
+/*
+ * device_open - open the specified device.
+ *
+ * Even if the target driver does not have an open
+ * routine, this function does not return an error. By
+ * using this mechanism, an application can check whether
+ * the specific device exists or not. The open mode
+ * should be handled by an each device driver if it is
+ * needed.
+ */
+int
+device_open(const char *name, int mode, device_t *devp)
+{
+	struct devops *ops;
+	device_t dev;
+	char str[MAXDEVNAME];
+	int error;
+
+	error = copyinstr(name, str, MAXDEVNAME);
+	if (error)
+		return error;
+
+	sched_lock();
+	if ((dev = device_lookup(str)) == NULL) {
+		sched_unlock();
+		return ENXIO;
+	}
+	error = device_reference(dev);
+	if (error) {
+		sched_unlock();
+		return error;
+	}
+	sched_unlock();
+
+	ops = dev->driver->devops;
+	ASSERT(ops->open != NULL);
+	error = (*ops->open)(dev, mode);
+	if (!error)
+		error = copyout(&dev, devp, sizeof(dev));
+
+	device_release(dev);
+	return error;
+}
+
+/*
+ * device_close - close a device.
+ *
+ * Even if the target driver does not have close routine,
+ * this function does not return any errors.
+ */
+int
+device_close(device_t dev)
+{
+	struct devops *ops;
+	int error;
+
+	if ((error = device_reference(dev)) != 0)
+		return error;
+
+	ops = dev->driver->devops;
+	ASSERT(ops->close != NULL);
+	error = (*ops->close)(dev);
+
+	device_release(dev);
+	return error;
+}
+
+/*
+ * device_read - read from a device.
+ *
+ * Actual read count is set in "nbyte" as return.
+ * Note: The size of one block is device dependent.
+ */
+int
+device_read(device_t dev, void *buf, size_t *nbyte, int blkno)
+{
+	struct devops *ops;
+	size_t count;
+	int error;
+
+	if (!user_area(buf))
+		return EFAULT;
+
+	if ((error = device_reference(dev)) != 0)
+		return error;
+
+	if (copyin(nbyte, &count, sizeof(count))) {
+		device_release(dev);
+		return EFAULT;
+	}
+
+	ops = dev->driver->devops;
+	ASSERT(ops->read != NULL);
+	error = (*ops->read)(dev, buf, &count, blkno);
+	if (!error)
+		error = copyout(&count, nbyte, sizeof(count));
+
+	device_release(dev);
+	return error;
+}
+
+/*
+ * device_write - write to a device.
+ *
+ * Actual write count is set in "nbyte" as return.
+ */
+int
+device_write(device_t dev, void *buf, size_t *nbyte, int blkno)
+{
+	struct devops *ops;
+	size_t count;
+	int error;
+
+	if (!user_area(buf))
+		return EFAULT;
+
+	if ((error = device_reference(dev)) != 0)
+		return error;
+
+	if (copyin(nbyte, &count, sizeof(count))) {
+		device_release(dev);
+		return EFAULT;
+	}
+
+	ops = dev->driver->devops;
+	ASSERT(ops->write != NULL);
+	error = (*ops->write)(dev, buf, &count, blkno);
+	if (!error)
+		error = copyout(&count, nbyte, sizeof(count));
+
+	device_release(dev);
+	return error;
+}
+
+/*
+ * device_ioctl - I/O control request.
+ *
+ * A command and its argument are completely device dependent.
+ * The ioctl routine of each driver must validate the user buffer
+ * pointed by the arg value.
+ */
+int
+device_ioctl(device_t dev, u_long cmd, void *arg)
+{
+	struct devops *ops;
+	int error;
+
+	if ((error = device_reference(dev)) != 0)
+		return error;
+
+	ops = dev->driver->devops;
+	ASSERT(ops->ioctl != NULL);
+	error = (*ops->ioctl)(dev, cmd, arg);
+
+	device_release(dev);
+	return error;
+}
+
+/*
+ * Device control - devctl is similar to ioctl, but is invoked from
+ * other device driver rather than from user application.
+ */
+static int
+device_control(device_t dev, u_long cmd, void *arg)
+{
+	struct devops *ops;
+	int error;
+
+	ASSERT(dev != NULL);
+
+	sched_lock();
+	ops = dev->driver->devops;
+	ASSERT(ops->devctl != NULL);
+	error = (*ops->devctl)(dev, cmd, arg);
+	sched_unlock();
+	return error;
+}
+
+/*
+ * device_broadcast - broadcast devctl command to all device objects.
+ *
+ * If "force" argument is true, we will continue command
+ * notification even if some driver returns an error. In this
+ * case, this routine returns EIO error if at least one driver
+ * returns an error.
+ *
+ * If force argument is false, a kernel stops the command processing
+ * when at least one driver returns an error. In this case,
+ * device_broadcast will return the error code which is returned
+ * by the driver.
+ */
+static int
+device_broadcast(u_long cmd, void *arg, int force)
+{
+	device_t dev;
+	struct devops *ops;
+	int error, retval = 0;
+
+	sched_lock();
+
+	for (dev = device_list; dev != NULL; dev = dev->next) {
+		/*
+		 * Call driver's devctl() routine.
+		 */
+		ops = dev->driver->devops;
+		if (ops == NULL)
+			continue;
+
+		ASSERT(ops->devctl != NULL);
+		error = (*ops->devctl)(dev, cmd, arg);
+		if (error) {
+			DPRINTF(("%s returns error=%d for cmd=%ld\n",
+				 dev->name, error, cmd));
+			if (force)
+				retval = EIO;
+			else {
+				retval = error;
+				break;
+			}
+		}
+	}
+	sched_unlock();
+	return retval;
+}
+
+/*
+ * Return device information.
+ */
+int
+device_info(struct devinfo *info)
+{
+	u_long target = info->cookie;
+	u_long i = 0;
+	device_t dev;
+	int error = ESRCH;
+
+	sched_lock();
+	for (dev = device_list; dev != NULL; dev = dev->next) {
+		if (i++ == target) {
+			info->cookie = i;
+			info->id = dev;
+			info->flags = dev->flags;
+			strlcpy(info->name, dev->name, MAXDEVNAME);
+			error = 0;
+			break;
+		}
+	}
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Initialize device driver module.
+ */
+void
+device_init(void)
+{
+	struct module *mod;
+	struct bootinfo *bi;
+	void (*entry)(const dkifn_t *);
+
+	machine_bootinfo(&bi);
+	mod = &bi->driver;
+	if (mod == NULL) {
+		DPRINTF(("Warning: No driver found\n"));
+		return;
+	}
+	entry = (void (*)(const dkifn_t *))mod->entry;
+	ASSERT(entry != NULL);
+
+	/* Show module location to add the driver symbols for gdb. */
+	DPRINTF(("Entering driver module (at 0x%x)\n", (int)entry));
+
+	(*entry)(dkient);
+}
diff --git a/prex-0.9.0/sys/kern/exception.c b/prex-0.9.0/sys/kern/exception.c
new file mode 100755
index 0000000..9a60319
--- /dev/null
+++ b/prex-0.9.0/sys/kern/exception.c
@@ -0,0 +1,374 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exception.c - exception handling routines
+ */
+
+/**
+ * An user mode task can set its own exception handler with
+ * exception_setup() system call.
+ *
+ * There are two different types of exceptions in a system - H/W and
+ * S/W exception. The kernel determines to which thread it delivers
+ * depending on the exception type.
+ *
+ *  - H/W exception
+ *
+ *   This type of exception is caused by H/W trap & fault. The
+ *   exception will be sent to the thread which caused the trap.
+ *   If no handler is specified by the task, it will be terminated
+ *   by the kernel immediately.
+ *
+ *  - S/W exception
+ *
+ *   The user mode task can send S/W exception to another task by
+ *   exception_raise() system call.
+ *   The exception  will be sent to the thread that is sleeping with
+ *   exception_wait() call. If no thread is waiting for the exception,
+ *   the exception is sent to the first thread in the target task.
+ *
+ * Kernel supports 32 types of exceptions. The following pre-defined
+ * exceptions are raised by kernel itself.
+ *
+ *   Exception Type Reason
+ *   --------- ---- -----------------------
+ *   SIGILL    h/w  illegal instruction
+ *   SIGTRAP   h/w  break point
+ *   SIGFPE    h/w  math error
+ *   SIGSEGV   h/w  invalid memory access
+ *   SIGALRM   s/w  alarm event
+ *
+ * The POSIX emulation library will setup own exception handler to
+ * convert the Prex exceptions into UNIX signals. It will maintain its
+ * own signal mask, and transfer control to the POSIX signal handler.
+ */
+
+#include <kernel.h>
+#include <event.h>
+#include <task.h>
+#include <thread.h>
+#include <sched.h>
+#include <task.h>
+#include <hal.h>
+#include <exception.h>
+
+static struct event	exception_event;
+
+/*
+ * Install an exception handler for the current task.
+ *
+ * EXC_DFL can be specified as handler to remove the current handler.
+ * If handler is removed, all pending exceptions are discarded
+ * immediately. At this time, all threads blocked in exception_wait()
+ * are automatically unblocked.
+ *
+ * We allow only one exception handler per task. If the handler
+ * has already been set in task, exception_setup() just override
+ * the previous handler.
+ */
+int
+exception_setup(void (*handler)(int))
+{
+	task_t self = curtask;
+	list_t head, n;
+	thread_t t;
+	int s;
+
+	if (handler != EXC_DFL && !user_area(handler))
+		return EFAULT;
+	if (handler == NULL)
+		return EINVAL;
+
+	sched_lock();
+	if (self->handler != EXC_DFL && handler == EXC_DFL) {
+		/*
+		 * Remove existing exception handler. Do clean up
+		 * job for all threads in the target task.
+		 */
+		head = &self->threads;
+		for (n = list_first(head); n != head; n = list_next(n)) {
+
+			/*
+			 * Clear pending exceptions.
+			 */
+			s = splhigh();
+			t = list_entry(n, struct thread, task_link);
+			t->excbits = 0;
+			splx(s);
+
+			/*
+			 * If the thread is waiting for an exception,
+			 * cancel it.
+			 */
+			if (t->slpevt == &exception_event) {
+				DPRINTF(("Exception cancelled task=%s\n",
+					 self->name));
+				sched_unsleep(t, SLP_BREAK);
+			}
+		}
+	}
+	self->handler = handler;
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * exception_raise - system call to raise an exception.
+ *
+ * The exception pending flag is marked here, and it is
+ * processed by exception_deliver() later. The task must have
+ * CAP_KILL capability to raise an exception to another task.
+ */
+int
+exception_raise(task_t task, int excno)
+{
+	int error;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		DPRINTF(("Bad exception task=%lx\n", (long)task));
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_KILL)) {
+		sched_unlock();
+		return EPERM;
+	}
+	error = exception_post(task, excno);
+	sched_unlock();
+	return error;
+}
+
+/*
+ * exception_post-- the internal version of exception_raise().
+ */
+int
+exception_post(task_t task, int excno)
+{
+	list_t head, n;
+	thread_t t = NULL;
+	int s, found = 0;
+
+	sched_lock();
+	if (task->flags & TF_SYSTEM) {
+		sched_unlock();
+		return EPERM;
+	}
+
+	if ((task->handler == EXC_DFL) ||
+	    (task->nthreads == 0) ||
+	    (excno < 0) || (excno >= NEXC)) {
+		sched_unlock();
+		return EINVAL;
+	}
+
+	/*
+	 * Determine which thread should we send an exception.
+	 * First, search the thread that is currently waiting
+	 * an exception by calling exception_wait().
+	 */
+	head = &task->threads;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		t = list_entry(n, struct thread, task_link);
+		if (t->slpevt == &exception_event) {
+			found = 1;
+			break;
+		}
+	}
+
+	/*
+	 * If no thread is waiting exceptions, we send it to
+	 * the master thread in the task.
+	 */
+	if (!found) {
+		if (!list_empty(&task->threads)) {
+			n = list_first(&task->threads);
+			t = list_entry(n, struct thread, task_link);
+		}
+	}
+
+	/*
+	 * Mark pending bit for this exception.
+	 */
+	s = splhigh();
+	t->excbits |= (1 << excno);
+	splx(s);
+
+	/*
+	 * Wakeup the target thread regardless of its
+	 * waiting event.
+	 */
+	sched_unsleep(t, SLP_INTR);
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * exception_wait - block a current thread until some
+ * exceptions are raised to the current thread.
+ *
+ * The routine returns EINTR on success.
+ */
+int
+exception_wait(int *excno)
+{
+	int i, rc, s;
+
+	if (curtask->handler == EXC_DFL)
+		return EINVAL;
+
+	/* Check fault before sleeping. */
+	i = 0;
+	if (copyout(&i, excno, sizeof(i)))
+		return EFAULT;
+
+	sched_lock();
+
+	/*
+	 * Sleep until some exceptions occur.
+	 */
+	rc = sched_sleep(&exception_event);
+	if (rc == SLP_BREAK) {
+		sched_unlock();
+		return EINVAL;
+	}
+	s = splhigh();
+	for (i = 0; i < NEXC; i++) {
+		if (curthread->excbits & (1 << i))
+			break;
+	}
+	splx(s);
+	ASSERT(i != NEXC);
+	sched_unlock();
+
+	if (copyout(&i, excno, sizeof(i)))
+		return EFAULT;
+	return EINTR;
+}
+
+/*
+ * Mark an exception flag for the current thread.
+ *
+ * This is called by HAL code when H/W trap is occurred. If a
+ * current task does not have exception handler, then the
+ * current task will be terminated. This routine can be called
+ * at interrupt level.
+ */
+void
+exception_mark(int excno)
+{
+	int s;
+
+	ASSERT(excno > 0 && excno < NEXC);
+
+	/* Mark pending bit */
+	s = splhigh();
+	curthread->excbits |= (1 << excno);
+	splx(s);
+}
+
+/*
+ * exception_deliver - deliver pending exception to the task.
+ *
+ * Check if pending exception exists for the current task, and
+ * deliver it to the exception handler if needed. All
+ * exceptions are delivered at the time when the control goes
+ * back to the user mode.  Some application may use longjmp()
+ * during its signal handler. So, current context must be
+ * saved to the user mode stack.
+ */
+void
+exception_deliver(void)
+{
+	task_t self = curtask;
+	void (*handler)(int);
+	uint32_t bitmap;
+	int s, excno;
+
+	ASSERT(curthread->state != TS_EXIT);
+	sched_lock();
+
+	s = splhigh();
+	bitmap = curthread->excbits;
+	splx(s);
+
+	if (bitmap != 0) {
+		/*
+		 * Find a pending exception.
+		 */
+		for (excno = 0; excno < NEXC; excno++) {
+			if (bitmap & (1 << excno))
+				break;
+		}
+		handler = self->handler;
+		if (handler == EXC_DFL) {
+			DPRINTF(("Exception #%d is not handled by task.\n",
+				excno));
+			DPRINTF(("Terminate task:%s (id:%lx)\n",
+				 self->name, (long)self));
+
+			task_terminate(self);
+			/* NOTREACHED */
+		}
+
+		/*
+		 * Transfer control to an exception handler.
+		 */
+		s = splhigh();
+		context_save(&curthread->ctx);
+		context_set(&curthread->ctx, CTX_UENTRY, (register_t)handler);
+		context_set(&curthread->ctx, CTX_UARG, (register_t)excno);
+		curthread->excbits &= ~(1 << excno);
+		splx(s);
+	}
+	sched_unlock();
+}
+
+/*
+ * exception_return() is called from exception handler to
+ * restore the original context.
+ */
+void
+exception_return(void)
+{
+	int s;
+
+	s = splhigh();
+	context_restore(&curthread->ctx);
+	splx(s);
+}
+
+void
+exception_init(void)
+{
+
+	event_init(&exception_event, "exception");
+}
diff --git a/prex-0.9.0/sys/kern/irq.c b/prex-0.9.0/sys/kern/irq.c
new file mode 100755
index 0000000..a94ff5c
--- /dev/null
+++ b/prex-0.9.0/sys/kern/irq.c
@@ -0,0 +1,262 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * irq.c - interrupt request management routines.
+ */
+
+/**
+ * We define the following two different types of interrupt services
+ * in order to improve real-time performance.
+ *
+ * - Interrupt Service Routine (ISR)
+ *
+ *  ISR is started by an actual hardware interrupt. The associated
+ *  interrupt is disabled in Interrupt Control Unit (ICU), and CPU
+ *  interrupt is enabled while ISR runs.
+ *  If ISR determines that the corresponding device generated the
+ *  interrupt, ISR must program the device to stop that interrupt.
+ *  Then, ISR should do minimum I/O operation and return control as
+ *  quickly as possible. ISR will run within a context of the thread
+ *  running when interrupt occurs. So, only few kernel services are
+ *  available within ISR.
+ *
+ * - Interrupt Service Thread (IST)
+ *
+ *  IST is automatically activated if ISR returns INT_CONTINUE. It
+ *  will be called when the system enters safer condition than ISR.
+ *  A device driver should use IST to do heavy I/O operation as much
+ *  as possible. Since ISR for the same IRQ line may be invoked during
+ *  IST, the shared data, resources, and device registers must be
+ *  synchronized by disabling interrupts. IST does not have to be
+ *  reentrant because it is not interrupted by same IST itself.
+ */
+
+#include <kernel.h>
+#include <event.h>
+#include <kmem.h>
+#include <sched.h>
+#include <thread.h>
+#include <irq.h>
+#include <hal.h>
+
+/* forward declarations */
+static void	irq_thread(void *);
+
+static struct irq	*irq_table[MAXIRQS];	/* IRQ descriptor table */
+
+/*
+ * irq_attach - attach ISR and IST to the specified interrupt.
+ *
+ * Returns irq handle, or panic on failure.  The interrupt of
+ * attached irq will be unmasked (enabled) in this routine.
+ * TODO: Interrupt sharing is not supported, for now.
+ */
+irq_t
+irq_attach(int vector, int pri, int shared,
+	   int (*isr)(void *), void (*ist)(void *), void *data)
+{
+	struct irq *irq;
+	int mode;
+
+	ASSERT(isr != NULL);
+
+	sched_lock();
+	if ((irq = kmem_alloc(sizeof(*irq))) == NULL)
+		panic("irq_attach");
+
+	memset(irq, 0, sizeof(*irq));
+	irq->vector = vector;
+	irq->priority = pri;
+	irq->isr = isr;
+	irq->ist = ist;
+	irq->data = data;
+
+	if (ist != IST_NONE) {
+		/*
+		 * Create a new thread for IST.
+		 */
+		irq->thread = kthread_create(&irq_thread, irq, ISTPRI(pri));
+		if (irq->thread == NULL)
+			panic("irq_attach");
+
+		event_init(&irq->istevt, "interrupt");
+	}
+	irq_table[vector] = irq;
+	mode = shared ? IMODE_LEVEL : IMODE_EDGE;
+	interrupt_setup(vector, mode);
+	interrupt_unmask(vector, pri);
+
+	sched_unlock();
+	DPRINTF(("IRQ%d attached priority=%d\n", vector, pri));
+	return irq;
+}
+
+/*
+ * Detach an interrupt handler from the interrupt chain.
+ * The detached interrupt will be masked off if nobody
+ * attaches to it, anymore.
+ */
+void
+irq_detach(irq_t irq)
+{
+	ASSERT(irq != NULL);
+	ASSERT(irq->vector < MAXIRQS);
+
+	interrupt_mask(irq->vector);
+	irq_table[irq->vector] = NULL;
+	if (irq->thread != NULL)
+		kthread_terminate(irq->thread);
+
+	kmem_free(irq);
+}
+
+/*
+ * Interrupt service thread.
+ * This is a common dispatcher to all interrupt threads.
+ */
+static void
+irq_thread(void *arg)
+{
+	void (*fn)(void *);
+	void *data;
+	struct irq *irq;
+
+	splhigh();
+
+	irq = (struct irq *)arg;
+	fn = irq->ist;
+	data = irq->data;
+
+	for (;;) {
+		if (irq->istreq <= 0) {
+			/*
+			 * Since the interrupt is disabled above,
+			 * an interrupt for this vector keeps
+			 * pending until this thread enters sleep
+			 * state. Thus, we don't lose any IST
+			 * requests even if the interrupt is fired
+			 * here.
+			 */
+			sched_sleep(&irq->istevt);
+		}
+		irq->istreq--;
+		ASSERT(irq->istreq >= 0);
+
+		/*
+		 * Call IST
+		 */
+		spl0();
+		(*fn)(data);
+		splhigh();
+	}
+	/* NOTREACHED */
+}
+
+/*
+ * Interrupt handler.
+ *
+ * This routine will call the corresponding ISR for the
+ * requested interrupt vector. HAL code must call this
+ * routine with scheduler locked.
+ */
+void
+irq_handler(int vector)
+{
+	struct irq *irq;
+	int rc;
+
+	irq = irq_table[vector];
+	if (irq == NULL) {
+		DPRINTF(("Random interrupt ignored\n"));
+		return;
+	}
+	ASSERT(irq->isr != NULL);
+
+	/* Profile */
+	irq->count++;
+
+	/*
+	 * Call ISR
+	 */
+	rc = (*irq->isr)(irq->data);
+
+	if (rc == INT_CONTINUE) {
+		/*
+		 * Kick IST
+		 */
+		ASSERT(irq->ist != IST_NONE);
+		irq->istreq++;
+		sched_wakeup(&irq->istevt);
+		ASSERT(irq->istreq != 0);
+	}
+}
+
+/*
+ * Return irq information.
+ */
+int
+irq_info(struct irqinfo *info)
+{
+	int vec = info->cookie;
+	int found = 0;
+	struct irq *irq;
+
+	while (vec < MAXIRQS) {
+		if (irq_table[vec]) {
+			found = 1;
+			break;
+		}
+		vec++;
+	}
+	if (!found)
+		return ESRCH;
+
+	irq = irq_table[vec];
+	info->vector = irq->vector;
+	info->count = irq->count;
+	info->priority = irq->priority;
+	info->istreq = irq->istreq;
+	info->thread = irq->thread;
+	info->cookie = vec + 1;
+	return 0;
+}
+
+/*
+ * Start interrupt processing.
+ */
+void
+irq_init(void)
+{
+
+	interrupt_init();
+
+	/* Enable interrupts */
+	spl0();
+}
diff --git a/prex-0.9.0/sys/kern/main.c b/prex-0.9.0/sys/kern/main.c
new file mode 100755
index 0000000..2bbb388
--- /dev/null
+++ b/prex-0.9.0/sys/kern/main.c
@@ -0,0 +1,115 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * main.c - kernel main routine
+ */
+
+#include <kernel.h>
+#include <task.h>
+#include <thread.h>
+#include <timer.h>
+#include <page.h>
+#include <kmem.h>
+#include <vm.h>
+#include <sched.h>
+#include <exception.h>
+#include <irq.h>
+#include <ipc.h>
+#include <device.h>
+#include <sync.h>
+#include <hal.h>
+
+/*
+ * Initialization code.
+ *
+ * Called from kernel_start() routine that is
+ * implemented in HAL.
+ * We assume that the following machine state has
+ * been already set before this routine.
+ *	- Kernel BSS section is filled with 0.
+ *	- Kernel stack is configured.
+ *	- All interrupts are disabled.
+ *	- Minimum page table is set. (MMU systems only)
+ */
+int
+main(void)
+{
+
+	sched_lock();
+	diag_init();
+	DPRINTF((BANNER));
+
+	/*
+	 * Initialize memory managers.
+	 */
+	page_init();
+	kmem_init();
+
+	/*
+	 * Do machine-dependent
+	 * initialization.
+	 */
+	machine_startup();
+
+	/*
+	 * Initialize kernel core.
+	 */
+	vm_init();
+	task_init();
+	thread_init();
+	sched_init();
+	exception_init();
+	timer_init();
+	object_init();
+	msg_init();
+
+	/*
+	 * Enable interrupt and
+	 * initialize devices.
+	 */
+	irq_init();
+	clock_init();
+	device_init();
+
+	/*
+	 * Set up boot tasks.
+	 */
+	task_bootstrap();
+
+	/*
+	 * Start scheduler and
+	 * enter idle loop.
+	 */
+	sched_unlock();
+	thread_idle();
+
+	/* NOTREACHED */
+	return 0;
+}
diff --git a/prex-0.9.0/sys/kern/sched.c b/prex-0.9.0/sys/kern/sched.c
new file mode 100755
index 0000000..ac35a59
--- /dev/null
+++ b/prex-0.9.0/sys/kern/sched.c
@@ -0,0 +1,733 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * sched.c - scheduler
+ */
+
+/**
+ * General Design:
+ *
+ * The Prex scheduler is based on the algorithm known as priority
+ * based multi level queue. Each thread has its own priority assigned
+ * between 0 and 255. The lower number means higher priority like BSD
+ * UNIX.  The scheduler maintains 256 level run queues mapped to each
+ * priority.  The lowest priority (=255) is used only for an idle
+ * thread.
+ *
+ * All threads have two different types of priorities:
+ *
+ *  Base priority:
+ *      This is a static priority used for priority computation.
+ *      A user mode program can change this value via system call.
+ *
+ *  Current priority:
+ *      An actual scheduling priority. A kernel may adjust this
+ *      priority dynamically if it's needed.
+ *
+ * Each thread has one of the following state.
+ *
+ *  - TS_RUN     Running or ready to run
+ *  - TS_SLEEP   Sleep for some event
+ *  - TS_SUSP    Suspend count is not 0
+ *  - TS_EXIT    Terminated
+ *
+ * The thread is always preemptive even in the kernel mode.
+ * There are following 4 reasons to switch thread.
+ *
+ * (1) Block
+ *      Thread is blocked for sleep or suspend.
+ *
+ * (2) Preemption
+ *      Higher priority thread becomes runnable.
+ *
+ * (3) Quantum expiration
+ *      The thread consumes its time quantum.
+ *
+ * (4) Yield
+ *      The thread releases CPU by itself.
+ *
+ * There are following three types of scheduling policies.
+ *
+ *  - SCHED_FIFO   First in-first-out
+ *  - SCHED_RR     Round robin (SCHED_FIFO + timeslice)
+ *  - SCHED_OTHER  Not supported now
+ */
+
+#include <kernel.h>
+#include <event.h>
+#include <thread.h>
+#include <timer.h>
+#include <vm.h>
+#include <task.h>
+#include <sched.h>
+#include <hal.h>
+
+static struct queue	runq[NPRI];	/* run queues */
+static struct queue	wakeq;		/* queue for waking threads */
+static struct queue	dpcq;		/* DPC queue */
+static struct event	dpc_event;	/* event for DPC */
+static int		maxpri;		/* highest priority in runq */
+
+/*
+ * Search for highest-priority runnable thread.
+ */
+static int
+runq_getbest(void)
+{
+	int pri;
+
+	for (pri = 0; pri < MINPRI; pri++)
+		if (!queue_empty(&runq[pri]))
+			break;
+	return pri;
+}
+
+/*
+ * Put a thread on the tail of the run queue.
+ * The rescheduling flag is set if the priority is beter
+ * than the currently running thread.
+ */
+static void
+runq_enqueue(thread_t t)
+{
+
+	enqueue(&runq[t->priority], &t->sched_link);
+	if (t->priority < maxpri) {
+		maxpri = t->priority;
+		curthread->resched = 1;
+	}
+}
+
+/*
+ * Insert a thread to the head of the run queue.
+ * We assume this routine is called while thread switching.
+ */
+static void
+runq_insert(thread_t t)
+{
+
+	queue_insert(&runq[t->priority], &t->sched_link);
+	if (t->priority < maxpri)
+		maxpri = t->priority;
+}
+
+/*
+ * Pick up and remove the highest-priority thread
+ * from the run queue.
+ */
+static thread_t
+runq_dequeue(void)
+{
+	queue_t q;
+	thread_t t;
+
+	q = dequeue(&runq[maxpri]);
+	t = queue_entry(q, struct thread, sched_link);
+	if (queue_empty(&runq[maxpri]))
+		maxpri = runq_getbest();
+
+	return t;
+}
+
+/*
+ * Remove the specified thread from the run queue.
+ */
+static void
+runq_remove(thread_t t)
+{
+
+	queue_remove(&t->sched_link);
+	maxpri = runq_getbest();
+}
+
+/*
+ * Wake up all threads in the wake queue.
+ */
+static void
+wakeq_flush(void)
+{
+	queue_t q;
+	thread_t t;
+
+	while (!queue_empty(&wakeq)) {
+		/*
+		 * Set a thread runnable.
+		 */
+		q = dequeue(&wakeq);
+		t = queue_entry(q, struct thread, sched_link);
+		t->slpevt = NULL;
+		t->state &= ~TS_SLEEP;
+		if (t != curthread && t->state == TS_RUN)
+			runq_enqueue(t);
+	}
+}
+
+/*
+ * Set the thread running:
+ * Put a thread on the wake queue. This thread will be moved
+ * to the run queue later in wakeq_flush().
+ */
+static void
+sched_setrun(thread_t t)
+{
+
+	enqueue(&wakeq, &t->sched_link);
+	timer_stop(&t->timeout);
+}
+
+/*
+ * sched_swtch - this is the scheduler proper:
+ *
+ * If the scheduling reason is preemption, the current thread
+ * will remain at the head of the run queue.  So, the thread
+ * still has right to run next again among the same priority
+ * threads. For other scheduling reason, the current thread is
+ * inserted into the tail of the run queue.
+ */
+static void
+sched_swtch(void)
+{
+	thread_t prev, next;
+
+	/*
+	 * Put the current thread on the run queue.
+	 */
+	prev = curthread;
+	if (prev->state == TS_RUN) {
+		if (prev->priority > maxpri)
+			runq_insert(prev);	/* preemption */
+		else
+			runq_enqueue(prev);
+	}
+	prev->resched = 0;
+
+	/*
+	 * Select the thread to run the CPU next.
+	 * If it's same with previous one, return.
+	 */
+	next = runq_dequeue();
+	if (next == prev)
+		return;
+	curthread = next;
+
+	/*
+	 * Switch to the new thread.
+	 * You are expected to understand this..
+	 */
+	if (prev->task != next->task)
+		vm_switch(next->task->map);
+	context_switch(&prev->ctx, &next->ctx);
+}
+
+/*
+ * sleep_timeout - sleep timer is expired:
+ *
+ * Wake up the thread which is sleeping in sched_tsleep().
+ */
+static void
+sleep_timeout(void *arg)
+{
+	thread_t t = (thread_t)arg;
+
+	sched_unsleep(t, SLP_TIMEOUT);
+}
+
+/*
+ * sched_tsleep - sleep the current thread until a wakeup
+ * is performed on the specified event.
+ * This routine returns a sleep result.
+ */
+int
+sched_tsleep(struct event *evt, u_long msec)
+{
+	int s;
+
+	ASSERT(evt != NULL);
+
+	sched_lock();
+	s = splhigh();
+
+	/*
+	 * Put the current thread on the sleep queue.
+	 */
+	curthread->slpevt = evt;
+	curthread->state |= TS_SLEEP;
+	enqueue(&evt->sleepq, &curthread->sched_link);
+
+	/*
+	 * Program timer to wake us up at timeout.
+	 */
+	if (msec != 0) {
+		timer_callout(&curthread->timeout, msec,
+			      &sleep_timeout, curthread);
+	}
+
+	wakeq_flush();
+	sched_swtch();		/* Sleep here. Zzzz.. */
+
+	splx(s);
+	sched_unlock();
+	return curthread->slpret;
+}
+
+/*
+ * sched_wakeup - wake up all threads sleeping on event.
+ *
+ * A thread can have sleep and suspend state simultaneously.
+ * So, the thread may keep suspending even if it woke up.
+ */
+void
+sched_wakeup(struct event *evt)
+{
+	queue_t q;
+	thread_t t;
+	int s;
+
+	ASSERT(evt != NULL);
+
+	sched_lock();
+	s = splhigh();
+	while (!queue_empty(&evt->sleepq)) {
+		q = dequeue(&evt->sleepq);
+		t = queue_entry(q, struct thread, sched_link);
+		t->slpret = 0;
+		sched_setrun(t);
+	}
+	splx(s);
+	sched_unlock();
+}
+
+/*
+ * sched_wakeone - wake up one thread sleeping on event.
+ *
+ * The highest priority thread is woken among sleeping
+ * threads. This routine returns the thread ID of the
+ * woken thread, or NULL if no threads are sleeping.
+ */
+thread_t
+sched_wakeone(struct event *evt)
+{
+	queue_t head, q;
+	thread_t top, t = NULL;
+	int s;
+
+	sched_lock();
+	s = splhigh();
+	head = &evt->sleepq;
+	if (!queue_empty(head)) {
+		/*
+		 * Select the highet priority thread in
+		 * the sleep queue, and wake it up.
+		 */
+		q = queue_first(head);
+		top = queue_entry(q, struct thread, sched_link);
+		while (!queue_end(head, q)) {
+			t = queue_entry(q, struct thread, sched_link);
+			if (t->priority < top->priority)
+				top = t;
+			q = queue_next(q);
+		}
+		queue_remove(&top->sched_link);
+		top->slpret = 0;
+		sched_setrun(top);
+	}
+	splx(s);
+	sched_unlock();
+	return t;
+}
+
+/*
+ * sched_unsleep - cancel sleep.
+ *
+ * sched_unsleep() removes the specified thread from its
+ * sleep queue. The specified sleep result will be passed
+ * to the sleeping thread as a return value of sched_tsleep().
+ */
+void
+sched_unsleep(thread_t t, int result)
+{
+	int s;
+
+	sched_lock();
+	if (t->state & TS_SLEEP) {
+		s = splhigh();
+		queue_remove(&t->sched_link);
+		t->slpret = result;
+		sched_setrun(t);
+		splx(s);
+	}
+	sched_unlock();
+}
+
+/*
+ * Yield the current processor to another thread.
+ *
+ * Note that the current thread may run immediately again,
+ * if no other thread exists in the same priority queue.
+ */
+void
+sched_yield(void)
+{
+
+	sched_lock();
+
+	if (!queue_empty(&runq[curthread->priority]))
+		curthread->resched = 1;
+
+	sched_unlock();		/* Switch a current thread here */
+}
+
+/*
+ * Suspend the specified thread.
+ * Called with scheduler locked.
+ */
+void
+sched_suspend(thread_t t)
+{
+
+	if (t->state == TS_RUN) {
+		if (t == curthread)
+			curthread->resched = 1;
+		else
+			runq_remove(t);
+	}
+	t->state |= TS_SUSP;
+}
+
+/*
+ * Resume the specified thread.
+ * Called with scheduler locked.
+ */
+void
+sched_resume(thread_t t)
+{
+
+	if (t->state & TS_SUSP) {
+		t->state &= ~TS_SUSP;
+		if (t->state == TS_RUN)
+			runq_enqueue(t);
+	}
+}
+
+/*
+ * sched_tick() is called from timer_clock() once every tick.
+ * Check quantum expiration, and mark a rescheduling flag.
+ * We don't need locking in here.
+ */
+void
+sched_tick(void)
+{
+
+	if (curthread->state != TS_EXIT) {
+		/*
+		 * Bill time to current thread.
+		 */
+		curthread->time++;
+
+		if (curthread->policy == SCHED_RR) {
+			if (--curthread->timeleft <= 0) {
+				/*
+				 * The quantum is up.
+				 * Give the thread another.
+				 */
+				curthread->timeleft += QUANTUM;
+				curthread->resched = 1;
+			}
+		}
+	}
+}
+
+/*
+ * Setup the thread structure to start scheduling.
+ */
+void
+sched_start(thread_t t, int pri, int policy)
+{
+
+	t->state = TS_RUN | TS_SUSP;
+	t->policy = policy;
+	t->priority = pri;
+	t->basepri = pri;
+	if (t->policy == SCHED_RR)
+		t->timeleft = QUANTUM;
+}
+
+/*
+ * Stop scheduling of the specified thread.
+ */
+void
+sched_stop(thread_t t)
+{
+
+	if (t == curthread) {
+		/*
+		 * If specified thread is a current thread,
+		 * the scheduling lock count is force set
+		 * to 1 to ensure the thread switching in
+		 * the next sched_unlock().
+		 */
+		curthread->locks = 1;
+		curthread->resched = 1;
+	} else {
+		if (t->state == TS_RUN)
+			runq_remove(t);
+		else if (t->state & TS_SLEEP)
+			queue_remove(&t->sched_link);
+	}
+	timer_stop(&t->timeout);
+	t->state = TS_EXIT;
+}
+
+/*
+ * sched_lock - lock the scheduler.
+ *
+ * The thread switch is disabled during scheduler locked.
+ * Since the scheduling lock can be nested any number of
+ * times, the caller has the responsible to unlock the same
+ * number of locks.
+ */
+void
+sched_lock(void)
+{
+
+	curthread->locks++;
+}
+
+/*
+ * sched_unlock - unlock scheduler.
+ *
+ * If nobody locks the scheduler anymore, it checks the
+ * rescheduling flag and kick the scheduler if it's required.
+ * This routine will be always called at the end of each
+ * interrupt handler.
+ */
+void
+sched_unlock(void)
+{
+	int s;
+
+	ASSERT(curthread->locks > 0);
+
+	s = splhigh();
+	if (curthread->locks == 1) {
+		wakeq_flush();
+		while (curthread->resched) {
+			/*
+			 * Kick scheduler.
+			 */
+			sched_swtch();
+
+			/*
+			 * Now we run pending interrupts which fired
+			 * during the thread switch. So, we can catch
+			 * the rescheduling request from such ISRs.
+			 * Otherwise, the reschedule may be deferred
+			 * until _next_ sched_unlock() call.
+			 */
+			splx(s);
+			s = splhigh();
+			wakeq_flush();
+		}
+	}
+	curthread->locks--;
+	splx(s);
+}
+
+/*
+ * Return the priority of the specified thread.
+ */
+int
+sched_getpri(thread_t t)
+{
+
+	return t->priority;
+}
+
+/*
+ * sched_setpri - set priority of thread.
+ *
+ * Arrange to reschedule if the resulting priority is
+ * better than that of the current thread.
+ * Called with scheduler locked.
+ */
+void
+sched_setpri(thread_t t, int basepri, int pri)
+{
+
+	t->basepri = basepri;
+
+	if (t == curthread) {
+		/*
+		 * If we change the current thread's priority,
+		 * rescheduling may be happened.
+		 */
+		t->priority = pri;
+		maxpri = runq_getbest();
+		if (pri != maxpri)
+			curthread->resched = 1;
+	} else {
+		if (t->state == TS_RUN) {
+			/*
+			 * Update the thread priority and adjust
+			 * the run queue position for new priority.
+			 * The rescheduling flag may be set.
+			 */
+			runq_remove(t);
+			t->priority = pri;
+			runq_enqueue(t);
+		} else
+			t->priority = pri;
+	}
+}
+
+/*
+ * Get the scheduling policy.
+ */
+int
+sched_getpolicy(thread_t t)
+{
+
+	return t->policy;
+}
+
+/*
+ * Set the scheduling policy.
+ */
+int
+sched_setpolicy(thread_t t, int policy)
+{
+	int error = 0;
+
+	switch (policy) {
+	case SCHED_RR:
+	case SCHED_FIFO:
+		t->timeleft = QUANTUM;
+		t->policy = policy;
+		break;
+	default:
+		error = EINVAL;
+		break;
+	}
+	return error;
+}
+
+/*
+ * Schedule DPC callback.
+ *
+ * DPC (Deferred Procedure Call) is used to call the specific
+ * function at some later time with a DPC priority.
+ * This routine can be called from ISR.
+ */
+void
+sched_dpc(struct dpc *dpc, void (*fn)(void *), void *arg)
+{
+	int s;
+
+	ASSERT(dpc != NULL);
+	ASSERT(fn != NULL);
+
+	sched_lock();
+
+	s = splhigh();
+	dpc->func = fn;
+	dpc->arg = arg;
+	if (dpc->state != DPC_PENDING)
+		enqueue(&dpcq, &dpc->link);
+	dpc->state = DPC_PENDING;
+	splx(s);
+
+	sched_wakeup(&dpc_event);
+	sched_unlock();
+}
+
+/*
+ * DPC thread.
+ *
+ * This is a kernel thread to process the pending call back
+ * request in DPC queue. Each DPC routine is called with
+ * the following conditions.
+ *  - Interrupt is enabled.
+ *  - Scheduler is unlocked.
+ *  - The scheduling priority is PRI_DPC.
+ */
+static void
+dpc_thread(void *dummy)
+{
+	queue_t q;
+	struct dpc *dpc;
+
+	splhigh();
+
+	for (;;) {
+		/*
+		 * Wait until next DPC request.
+		 */
+		sched_sleep(&dpc_event);
+
+		while (!queue_empty(&dpcq)) {
+			q = dequeue(&dpcq);
+			dpc = queue_entry(q, struct dpc, link);
+			dpc->state = DPC_FREE;
+
+			/*
+			 * Call DPC routine.
+			 */
+			spl0();
+			(*dpc->func)(dpc->arg);
+			splhigh();
+		}
+	}
+	/* NOTREACHED */
+}
+
+/*
+ * Initialize the global scheduler state.
+ */
+void
+sched_init(void)
+{
+	thread_t t;
+	int i;
+
+	for (i = 0; i < NPRI; i++)
+		queue_init(&runq[i]);
+
+	queue_init(&wakeq);
+	queue_init(&dpcq);
+	event_init(&dpc_event, "dpc");
+	maxpri = PRI_IDLE;
+	curthread->resched = 1;
+
+	t = kthread_create(dpc_thread, NULL, PRI_DPC);
+	if (t == NULL)
+		panic("sched_init");
+
+	DPRINTF(("Time slice is %d msec\n", CONFIG_TIME_SLICE));
+}
diff --git a/prex-0.9.0/sys/kern/sysent.c b/prex-0.9.0/sys/kern/sysent.c
new file mode 100755
index 0000000..4058e23
--- /dev/null
+++ b/prex-0.9.0/sys/kern/sysent.c
@@ -0,0 +1,236 @@
+/*-
+ * Copyright (c) 2005-2009 Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * sysent.c - system call switch table.
+ */
+
+#include <kernel.h>
+#include <thread.h>
+#include <timer.h>
+#include <vm.h>
+#include <task.h>
+#include <exception.h>
+#include <ipc.h>
+#include <device.h>
+#include <sync.h>
+#include <system.h>
+
+typedef register_t (*sysfn_t)(register_t, register_t, register_t, register_t);
+
+#ifdef DEBUG
+static void strace_entry(register_t, register_t, register_t, register_t,
+			 register_t);
+static void strace_return(register_t, register_t);
+#endif
+
+struct sysent {
+#ifdef DEBUG
+	int	sy_narg;	/* number of arguments */
+	char	*sy_name;	/* name string */
+#endif
+	sysfn_t	sy_call;	/* handler */
+};
+
+/*
+ * Sysent initialization macros.
+ *
+ * Initialization macro for system calls which take their args
+ * in the C style. In order to reduce the memory space, we
+ * store the syscall name and its argument count only when
+ * DEBUG is defined.
+ *
+ */
+#ifdef DEBUG
+#define SYSENT(n, fn)	{n, __STRING(fn), (sysfn_t)(fn)}
+#else
+#define SYSENT(n, fn)	{(sysfn_t)(fn)}
+#endif
+
+/*
+ * This table is the switch used to transfer to the
+ * appropriate routine for processing a system call.
+ * The first element must be exception_return because
+ * it requires special handling in HAL code.
+ */
+static const struct sysent sysent[] = {
+	/*  0 */ SYSENT(0, exception_return),
+	/*  1 */ SYSENT(1, exception_setup),
+	/*  2 */ SYSENT(2, exception_raise),
+	/*  3 */ SYSENT(1, exception_wait),
+	/*  4 */ SYSENT(3, task_create),
+	/*  5 */ SYSENT(1, task_terminate),
+	/*  6 */ SYSENT(0, task_self),
+	/*  7 */ SYSENT(1, task_suspend),
+	/*  8 */ SYSENT(1, task_resume),
+	/*  9 */ SYSENT(2, task_setname),
+	/* 10 */ SYSENT(2, task_setcap),
+	/* 11 */ SYSENT(2, task_chkcap),
+	/* 12 */ SYSENT(2, thread_create),
+	/* 13 */ SYSENT(1, thread_terminate),
+	/* 14 */ SYSENT(3, thread_load),
+	/* 15 */ SYSENT(0, thread_self),
+	/* 16 */ SYSENT(0, thread_yield),
+	/* 17 */ SYSENT(1, thread_suspend),
+	/* 18 */ SYSENT(1, thread_resume),
+	/* 19 */ SYSENT(3, thread_schedparam),
+	/* 20 */ SYSENT(4, vm_allocate),
+	/* 21 */ SYSENT(2, vm_free),
+	/* 22 */ SYSENT(3, vm_attribute),
+	/* 23 */ SYSENT(4, vm_map),
+	/* 24 */ SYSENT(2, object_create),
+	/* 25 */ SYSENT(1, object_destroy),
+	/* 26 */ SYSENT(2, object_lookup),
+	/* 27 */ SYSENT(3, msg_send),
+	/* 28 */ SYSENT(3, msg_receive),
+	/* 29 */ SYSENT(3, msg_reply),
+	/* 30 */ SYSENT(2, timer_sleep),
+	/* 31 */ SYSENT(2, timer_alarm),
+	/* 32 */ SYSENT(3, timer_periodic),
+	/* 33 */ SYSENT(0, timer_waitperiod),
+	/* 34 */ SYSENT(3, device_open),
+	/* 35 */ SYSENT(1, device_close),
+	/* 36 */ SYSENT(4, device_read),
+	/* 37 */ SYSENT(4, device_write),
+	/* 38 */ SYSENT(3, device_ioctl),
+	/* 39 */ SYSENT(1, mutex_init),
+	/* 40 */ SYSENT(1, mutex_destroy),
+	/* 41 */ SYSENT(1, mutex_lock),
+	/* 42 */ SYSENT(1, mutex_trylock),
+	/* 43 */ SYSENT(1, mutex_unlock),
+	/* 44 */ SYSENT(1, cond_init),
+	/* 45 */ SYSENT(1, cond_destroy),
+	/* 46 */ SYSENT(2, cond_wait),
+	/* 47 */ SYSENT(1, cond_signal),
+	/* 48 */ SYSENT(1, cond_broadcast),
+	/* 49 */ SYSENT(2, sem_init),
+	/* 50 */ SYSENT(1, sem_destroy),
+	/* 51 */ SYSENT(2, sem_wait),
+	/* 52 */ SYSENT(1, sem_trywait),
+	/* 53 */ SYSENT(1, sem_post),
+	/* 54 */ SYSENT(2, sem_getvalue),
+	/* 55 */ SYSENT(1, sys_log),
+	/* 56 */ SYSENT(1, sys_panic),
+	/* 57 */ SYSENT(2, sys_info),
+	/* 58 */ SYSENT(1, sys_time),
+	/* 59 */ SYSENT(2, sys_debug),
+};
+
+#define NSYSCALL	(int)(sizeof(sysent) / sizeof(sysent[0]))
+
+
+/*
+ * System call dispatcher.
+ */
+register_t
+syscall_handler(register_t a1, register_t a2, register_t a3, register_t a4,
+		register_t id)
+{
+	register_t retval = EINVAL;
+	const struct sysent *callp;
+
+#ifdef DEBUG
+	strace_entry(a1, a2, a3, a4, id);
+#endif
+
+	if (id < NSYSCALL) {
+		callp = &sysent[id];
+		retval = (*callp->sy_call)(a1, a2, a3, a4);
+	}
+
+#ifdef DEBUG
+	strace_return(retval, id);
+#endif
+	return retval;
+}
+
+#ifdef DEBUG
+/*
+ * Show syscall info if the task is being traced.
+ */
+static void
+strace_entry(register_t a1, register_t a2, register_t a3, register_t a4,
+	     register_t id)
+{
+	const struct sysent *callp;
+
+	if (curtask->flags & TF_TRACE) {
+		if (id >= NSYSCALL) {
+			printf("%s: OUT OF RANGE (%d)\n",
+			       curtask->name, id);
+			return;
+		}
+
+		callp = &sysent[id];
+
+		printf("%s: %s(", curtask->name, callp->sy_name);
+		switch (callp->sy_narg) {
+		case 0:
+			printf(")\n");
+			break;
+		case 1:
+			printf("0x%08x)\n", a1);
+			break;
+		case 2:
+			printf("0x%08x, 0x%08x)\n", a1, a2);
+			break;
+		case 3:
+			printf("0x%08x, 0x%08x, 0x%08x)\n",
+			       a1, a2, a3);
+			break;
+		case 4:
+			printf("0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
+			       a1, a2, a3, a4);
+			break;
+		}
+	}
+}
+
+/*
+ * Show status if syscall is failed.
+ *
+ * We ignore the return code for the function which does
+ * not have any arguments, although timer_waitperiod()
+ * has valid return code...
+ */
+static void
+strace_return(register_t retval, register_t id)
+{
+	const struct sysent *callp;
+
+	if (curtask->flags & TF_TRACE) {
+		if (id >= NSYSCALL)
+			return;
+		callp = &sysent[id];
+		if (callp->sy_narg != 0 && retval != 0)
+			printf("%s: !!! %s() = 0x%08x\n",
+				curtask->name, callp->sy_name, retval);
+	}
+}
+#endif /* !DEBUG */
diff --git a/prex-0.9.0/sys/kern/system.c b/prex-0.9.0/sys/kern/system.c
new file mode 100755
index 0000000..0c48144
--- /dev/null
+++ b/prex-0.9.0/sys/kern/system.c
@@ -0,0 +1,245 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * system.c - system services
+ */
+
+#include <kernel.h>
+#include <thread.h>
+#include <sched.h>
+#include <task.h>
+#include <vm.h>
+#include <irq.h>
+#include <page.h>
+#include <device.h>
+#include <system.h>
+#include <hal.h>
+#include <sys/dbgctl.h>
+
+static char	infobuf[MAXINFOSZ];	/* common information buffer */
+
+static const struct kerninfo kerninfo = {
+	"Prex",	HOSTNAME, VERSION, __DATE__, MACHINE
+};
+
+/*
+ * Get system information.
+ */
+int
+sysinfo(int type, void *buf)
+{
+	int error = 0;
+
+	sched_lock();
+
+	switch (type) {
+	case INFO_KERNEL:
+		memcpy(buf, &kerninfo, sizeof(kerninfo));
+		break;
+	case INFO_MEMORY:
+		page_info(buf);
+		break;
+	case INFO_TIMER:
+		timer_info(buf);
+		break;
+	case INFO_THREAD:
+		error = thread_info(buf);
+		break;
+	case INFO_DEVICE:
+		error = device_info(buf);
+		break;
+	case INFO_TASK:
+		error = task_info(buf);
+		break;
+	case INFO_VM:
+		error = vm_info(buf);
+		break;
+	case INFO_IRQ:
+		error = irq_info(buf);
+		break;
+	default:
+		error = EINVAL;
+		break;
+	}
+	sched_unlock();
+	return error;
+}
+
+/*
+ * System call to get system information.
+ */
+int
+sys_info(int type, void *buf)
+{
+	int error;
+	size_t bufsz = 0;
+
+	if (buf == NULL || !user_area(buf))
+		return EFAULT;
+
+	sched_lock();
+
+	switch (type) {
+	case INFO_KERNEL:
+		bufsz = sizeof(struct kerninfo);
+		break;
+	case INFO_MEMORY:
+		bufsz = sizeof(struct meminfo);
+		break;
+	case INFO_TIMER:
+		bufsz = sizeof(struct timerinfo);
+		break;
+	case INFO_THREAD:
+		bufsz = sizeof(struct threadinfo);
+		break;
+	case INFO_DEVICE:
+		bufsz = sizeof(struct devinfo);
+		break;
+	case INFO_TASK:
+		bufsz = sizeof(struct taskinfo);
+		break;
+	case INFO_VM:
+		bufsz = sizeof(struct vminfo);
+		break;
+	case INFO_IRQ:
+		bufsz = sizeof(struct irqinfo);
+		break;
+	default:
+		sched_unlock();
+		return EINVAL;
+	}
+
+	error = copyin(buf, &infobuf, bufsz);
+	if (!error) {
+		error = sysinfo(type, &infobuf);
+		if (!error) {
+			error = copyout(&infobuf, buf, bufsz);
+		}
+	}
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Logging system call.
+ *
+ * Write a message to the logging device.  The log
+ * function is available only when kernel is built
+ * with debug option.
+ */
+int
+sys_log(const char *str)
+{
+#ifdef DEBUG
+	char buf[DBGMSGSZ];
+
+	if (copyinstr(str, buf, DBGMSGSZ))
+		return EINVAL;
+
+	printf("%s", buf);
+	return 0;
+#else
+	return ENOSYS;
+#endif
+}
+
+/*
+ * Kernel debug service.
+ */
+int
+sys_debug(int cmd, void *data)
+{
+#ifdef DEBUG
+	int error = EINVAL;
+	task_t task = 0;
+
+	switch (cmd) {
+	case DBGC_LOGSIZE:
+	case DBGC_GETLOG:
+		error = dbgctl(cmd, data);
+		break;
+	case DBGC_TRACE:
+		task = (task_t)data;
+		if (!task_valid(task)) {
+			error = ESRCH;
+			break;
+		}
+		dbgctl(cmd, (void *)task);
+		error = 0;
+		break;
+	}
+	return error;
+#else
+	return ENOSYS;
+#endif
+}
+
+/*
+ * Panic system call.
+ */
+int
+sys_panic(const char *str)
+{
+#ifdef DEBUG
+	char buf[DBGMSGSZ];
+
+	sched_lock();
+	copyinstr(str, buf, DBGMSGSZ - 20);
+	printf("User panic: %s\n", str);
+	printf(" task=%s thread=%lx\n", curtask->name, (long)curthread);
+
+	machine_abort();
+	/* NOTREACHED */
+#else
+	task_terminate(curtask);
+#endif
+	return 0;
+}
+
+/*
+ * Get system time - return ticks since OS boot.
+ */
+int
+sys_time(u_long *ticks)
+{
+	u_long t;
+
+	t = timer_ticks();
+	return copyout(&t, ticks, sizeof(t));
+}
+
+/*
+ * nonexistent system call.
+ */
+int
+sys_nosys(void)
+{
+	return EINVAL;
+}
diff --git a/prex-0.9.0/sys/kern/task.c b/prex-0.9.0/sys/kern/task.c
new file mode 100755
index 0000000..97e14bb
--- /dev/null
+++ b/prex-0.9.0/sys/kern/task.c
@@ -0,0 +1,547 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * task.c - task management routines.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <sched.h>
+#include <thread.h>
+#include <ipc.h>
+#include <sync.h>
+#include <vm.h>
+#include <exception.h>
+#include <task.h>
+#include <hal.h>
+#include <sys/bootinfo.h>
+
+struct task		kernel_task;	/* kernel task */
+static struct list	task_list;	/* list for all tasks */
+static int		ntasks;		/* number of tasks in system */
+
+/**
+ * task_create - create a new task.
+ *
+ * vm_option:
+ *   VM_NEW:   The child task will have fresh memory image.
+ *   VM_SHARE: The child task will share whole memory image with parent.
+ *   VM_COPY:  The parent's memory image is copied to the child's one.
+ *             VM_COPY is supported only with MMU system.
+ *
+ * Note: The child task initially contains no threads.
+ */
+int
+task_create(task_t parent, int vm_option, task_t *childp)
+{
+	struct task *task;
+	vm_map_t map = NULL;
+
+	ASSERT(parent != NULL);
+
+	switch (vm_option) {
+	case VM_NEW:
+	case VM_SHARE:
+#ifdef CONFIG_MMU
+	case VM_COPY:
+#endif
+		break;
+	default:
+		return EINVAL;
+	}
+	if (ntasks >= MAXTASKS)
+		return EAGAIN;
+
+	sched_lock();
+	if (!task_valid(parent)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if ((curtask->flags & TF_SYSTEM) == 0) {
+		if (!task_access(parent)) {
+			sched_unlock();
+			return EPERM;
+		}
+		/*
+		 * It's important to set zero as task id before
+		 * copying parent's memory space. Otherwise, we
+		 * have to switch VM space to copy it.
+		 */
+		task = 0;
+		if (copyout(&task, childp, sizeof(task))) {
+			sched_unlock();
+			return EFAULT;
+		}
+	}
+
+	if ((task = kmem_alloc(sizeof(*task))) == NULL) {
+		sched_unlock();
+		return ENOMEM;
+	}
+	memset(task, 0, sizeof(*task));
+
+	/*
+	 * Setup VM mapping.
+	 */
+	switch (vm_option) {
+	case VM_NEW:
+		map = vm_create();
+		break;
+	case VM_SHARE:
+		vm_reference(parent->map);
+		map = parent->map;
+		break;
+	case VM_COPY:
+		map = vm_dup(parent->map);
+		break;
+	}
+	if (map == NULL) {
+		kmem_free(task);
+		sched_unlock();
+		return ENOMEM;
+	}
+
+	/*
+	 * Fill initial task data.
+	 */
+	task->map = map;
+	task->handler = parent->handler;
+	task->capability = parent->capability;
+	task->parent = parent;
+	task->flags = TF_DEFAULT;
+	strlcpy(task->name, "*noname", MAXTASKNAME);
+	list_init(&task->threads);
+	list_init(&task->objects);
+	list_init(&task->mutexes);
+	list_init(&task->conds);
+	list_init(&task->sems);
+	list_insert(&task_list, &task->link);
+	ntasks++;
+
+	if (curtask->flags & TF_SYSTEM)
+		*childp = task;
+	else {
+		/*
+		 * No page fault here because we have already
+		 * checked it.
+		 */
+		copyout(&task, childp, sizeof(task));
+	}
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Terminate the specified task.
+ */
+int
+task_terminate(task_t task)
+{
+	list_t head, n;
+	thread_t t;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(task)) {
+		sched_unlock();
+		return EPERM;
+	}
+
+	list_remove(&task->link);
+	task->handler = EXC_DFL;
+
+	/*
+	 * Clean up all resources owned by the target task.
+	 */
+	timer_stop(&task->alarm);
+	object_cleanup(task);
+	mutex_cleanup(task);
+	cond_cleanup(task);
+	sem_cleanup(task);
+
+	/*
+	 * Terminate each thread in the task.
+	 */
+	head = &task->threads;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		t = list_entry(n, struct thread, task_link);
+		if (t != curthread)
+			thread_destroy(t);
+	}
+	if (task == curtask)
+		thread_destroy(curthread);
+
+	vm_terminate(task->map);
+	task->map = NULL;
+	kmem_free(task);
+	ntasks--;
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Return the current task.
+ */
+task_t
+task_self(void)
+{
+
+	return curthread->task;
+}
+
+/*
+ * Suspend a task.
+ */
+int
+task_suspend(task_t task)
+{
+	list_t head, n;
+	thread_t t;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(task)) {
+		sched_unlock();
+		return EPERM;
+	}
+
+	if (++task->suscnt == 1) {
+		/*
+		 * Suspend all threads within the task.
+		 */
+		head = &task->threads;
+		for (n = list_first(head); n != head; n = list_next(n)) {
+			t = list_entry(n, struct thread, task_link);
+			thread_suspend(t);
+		}
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Resume a task.
+ *
+ * A thread in the task will begin to run only when both
+ * thread suspend count and task suspend count become 0.
+ */
+int
+task_resume(task_t task)
+{
+	list_t head, n;
+	thread_t t;
+
+	ASSERT(task != curtask);
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (task->suscnt == 0) {
+		sched_unlock();
+		return EINVAL;
+	}
+
+	if (--task->suscnt == 0) {
+		/*
+		 * Resume all threads in the target task.
+		 */
+		head = &task->threads;
+		for (n = list_first(head); n != head; n = list_next(n)) {
+			t = list_entry(n, struct thread, task_link);
+			thread_resume(t);
+		}
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Set task name.
+ *
+ * The naming service is separated from task_create() because
+ * the task name can be changed at anytime by exec().
+ */
+int
+task_setname(task_t task, const char *name)
+{
+	char str[MAXTASKNAME];
+	int error;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(task)) {
+		sched_unlock();
+		return EPERM;
+	}
+
+	if (curtask->flags & TF_SYSTEM)
+		strlcpy(task->name, name, MAXTASKNAME);
+	else {
+		error = copyinstr(name, str, MAXTASKNAME);
+		if (error) {
+			sched_unlock();
+			return error;
+		}
+		strlcpy(task->name, str, MAXTASKNAME);
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Set the capability of the specified task.
+ */
+int
+task_setcap(task_t task, cap_t cap)
+{
+
+	if (!task_capable(CAP_SETPCAP))
+		return EPERM;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	task->capability = cap;
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * task_chkcap - system call to check task capability.
+ */
+int
+task_chkcap(task_t task, cap_t cap)
+{
+	int error = 0;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if ((task->capability & cap) == 0) {
+		DPRINTF(("Denying capability by %s: task=%s cap=%08x\n",
+			 curtask->name, task->name, cap));
+		if (task->flags & TF_AUDIT)
+			panic("audit failed");
+		error = EPERM;
+	}
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Check if the current task has specified capability.
+ * Returns true on success, or false on error.
+ */
+int
+task_capable(cap_t cap)
+{
+	int capable = 1;
+
+	if ((curtask->capability & cap) == 0) {
+		DPRINTF(("Denying capability by kernel: task=%s cap=%08x\n",
+			 curtask->name, cap));
+		if (curtask->flags & TF_AUDIT)
+			panic("audit failed");
+		capable = 0;
+	}
+	return capable;
+}
+
+/*
+ * Return true if the specified task is valid.
+ */
+int
+task_valid(task_t task)
+{
+	task_t tmp;
+	list_t n;
+
+	for (n = list_first(&task_list); n != &task_list; n = list_next(n)) {
+		tmp = list_entry(n, struct task, link);
+		if (tmp == task)
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * Check if the current task can access the specified task.
+ * Return true on success, or false on error.
+ */
+int
+task_access(task_t task)
+{
+
+	if (task->flags & TF_SYSTEM) {
+		/* Do not access the kernel task. */
+		return 0;
+	} else {
+		if (task == curtask || task->parent == curtask ||
+		    task == curtask->parent ||	/* XXX: fork on nommu */
+		    task_capable(CAP_TASKCTRL))
+			return 1;
+	}
+	return 0;
+}
+
+int
+task_info(struct taskinfo *info)
+{
+	u_long target = info->cookie;
+	u_long i = 0;
+	task_t task;
+	list_t n;
+
+	sched_lock();
+	n = list_first(&task_list);
+	do {
+		if (i++ == target) {
+			task = list_entry(n, struct task, link);
+			info->cookie = i;
+			info->id = task;
+			info->flags = task->flags;
+			info->suscnt = task->suscnt;
+			info->capability = task->capability;
+			info->vmsize = task->map->total;
+			info->nthreads = task->nthreads;
+			info->active = (task == curtask) ? 1 : 0;
+			strlcpy(info->taskname, task->name, MAXTASKNAME);
+			sched_unlock();
+			return 0;
+		}
+		n = list_next(n);
+	} while (n != &task_list);
+	sched_unlock();
+	return ESRCH;
+}
+
+/*
+ * Create and setup boot tasks.
+ */
+void
+task_bootstrap(void)
+{
+	struct module *mod;
+	struct bootinfo *bi;
+	task_t task;
+	thread_t t;
+	void *stack, *sp;
+	int i, error = 0;
+
+	machine_bootinfo(&bi);
+	mod = &bi->tasks[0];
+
+	for (i = 0; i < bi->nr_tasks; i++) {
+		/*
+		 * Create a new task.
+		 */
+		if ((error = task_create(&kernel_task, VM_NEW, &task)) != 0)
+			break;
+		if ((error = vm_load(task->map, mod, &stack)) != 0)
+			break;
+		task_setname(task, mod->name);
+
+		/*
+		 * Set the default capability.
+		 * We give CAP_SETPCAP to the exec server.
+		 */
+		task->capability = CAPSET_BOOT;
+		if (!strncmp(task->name, "exec", MAXTASKNAME))
+			task->capability |= CAP_SETPCAP;
+
+		/*
+		 * Create and start a new thread.
+		 */
+		if ((error = thread_create(task, &t)) != 0)
+			break;
+		sp = (char *)stack + DFLSTKSZ - (sizeof(int) * 3);
+		error = thread_load(t, (void (*)(void))mod->entry, sp);
+		if (error)
+			break;
+		t->priority = PRI_REALTIME;
+		t->basepri = PRI_REALTIME;
+		thread_resume(t);
+
+		mod++;
+	}
+	if (error) {
+		DPRINTF(("task_bootstrap: error=%d\n", error));
+		panic("unable to load boot task");
+	}
+}
+
+/*
+ * Initialize task.
+ */
+void
+task_init(void)
+{
+
+	list_init(&task_list);
+
+	/*
+	 * Create a kernel task as first task.
+	 */
+	strlcpy(kernel_task.name, "kernel", MAXTASKNAME);
+	kernel_task.flags = TF_SYSTEM;
+	kernel_task.nthreads = 0;
+	list_init(&kernel_task.threads);
+	list_init(&kernel_task.objects);
+	list_init(&kernel_task.mutexes);
+	list_init(&kernel_task.conds);
+	list_init(&kernel_task.sems);
+
+	list_insert(&task_list, &kernel_task.link);
+	ntasks = 1;
+}
diff --git a/prex-0.9.0/sys/kern/thread.c b/prex-0.9.0/sys/kern/thread.c
new file mode 100755
index 0000000..6e327d1
--- /dev/null
+++ b/prex-0.9.0/sys/kern/thread.c
@@ -0,0 +1,599 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * thread.c - thread management routines.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <task.h>
+#include <thread.h>
+#include <ipc.h>
+#include <sched.h>
+#include <sync.h>
+#include <hal.h>
+
+/* forward declarations */
+static thread_t thread_allocate(task_t);
+static void	thread_deallocate(thread_t);
+
+static struct thread	idle_thread;	/* idle thread */
+static thread_t		zombie;		/* zombie thread */
+static struct list	thread_list;	/* list of all threads */
+
+/* global variable */
+thread_t curthread = &idle_thread;	/* current thread */
+
+/*
+ * Create a new thread.
+ *
+ * The new thread will start from the return address of
+ * thread_create() in user mode.  Since a new thread shares
+ * the user mode stack of the caller thread, the caller is
+ * responsible to allocate and set new stack for it. The new
+ * thread is initially set to suspend state, and so,
+ * thread_resume() must be called to start it.
+ */
+int
+thread_create(task_t task, thread_t *tp)
+{
+	thread_t t;
+	vaddr_t sp;
+
+	sched_lock();
+
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (task->nthreads >= MAXTHREADS) {
+		sched_unlock();
+		return EAGAIN;
+	}
+	/*
+	 * We check the pointer to the return value here.
+	 * This will simplify the error recoveries of the
+	 * subsequent code.
+	 */
+	if ((curtask->flags & TF_SYSTEM) == 0) {
+		t = NULL;
+		if (copyout(&t, tp, sizeof(t))) {
+			sched_unlock();
+			return EFAULT;
+		}
+	}
+	/*
+	 * Make thread entry for new thread.
+	 */
+	if ((t = thread_allocate(task)) == NULL) {
+		DPRINTF(("Out of text\n"));
+		sched_unlock();
+		return ENOMEM;
+	}
+	memcpy(t->kstack, curthread->kstack, KSTACKSZ);
+	sp = (vaddr_t)t->kstack + KSTACKSZ;
+	context_set(&t->ctx, CTX_KSTACK, (register_t)sp);
+	context_set(&t->ctx, CTX_KENTRY, (register_t)&syscall_ret);
+	sched_start(t, curthread->basepri, SCHED_RR);
+	t->suscnt = task->suscnt + 1;
+
+	/*
+	 * No page fault here:
+	 */
+	if (curtask->flags & TF_SYSTEM)
+		*tp = t;
+	else
+		copyout(&t, tp, sizeof(t));
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Permanently stop execution of the specified thread.
+ * If given thread is a current thread, this routine
+ * never returns.
+ */
+int
+thread_terminate(thread_t t)
+{
+
+	sched_lock();
+	if (!thread_valid(t)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(t->task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	thread_destroy(t);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * thread_destroy-- the internal version of thread_terminate.
+ */
+void
+thread_destroy(thread_t th)
+{
+
+	msg_cancel(th);
+	mutex_cancel(th);
+	timer_cancel(th);
+	sched_stop(th);
+	thread_deallocate(th);
+}
+
+/*
+ * Load entry/stack address of the user mode context.
+ *
+ * If the entry or stack address is NULL, we keep the
+ * old value for it.
+ */
+int
+thread_load(thread_t t, void (*entry)(void), void *stack)
+{
+	int s;
+
+	if (entry != NULL && !user_area(entry))
+		return EINVAL;
+	if (stack != NULL && !user_area(stack))
+		return EINVAL;
+
+	sched_lock();
+
+	if (!thread_valid(t)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(t->task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	s = splhigh();
+	if (entry != NULL)
+		context_set(&t->ctx, CTX_UENTRY, (register_t)entry);
+	if (stack != NULL)
+		context_set(&t->ctx, CTX_USTACK, (register_t)stack);
+	splx(s);
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Return the current thread.
+ */
+thread_t
+thread_self(void)
+{
+
+	return curthread;
+}
+
+/*
+ * Return true if specified thread is valid.
+ */
+int
+thread_valid(thread_t t)
+{
+	list_t head, n;
+	thread_t tmp;
+
+	head = &thread_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		tmp = list_entry(n, struct thread, link);
+		if (tmp == t)
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * Release a current thread for other thread.
+ */
+void
+thread_yield(void)
+{
+
+	sched_yield();
+}
+
+/*
+ * Suspend thread.
+ *
+ * A thread can be suspended any number of times.
+ * And, it does not start to run again unless the thread
+ * is resumed by the same count of suspend request.
+ */
+int
+thread_suspend(thread_t t)
+{
+
+	sched_lock();
+	if (!thread_valid(t)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(t->task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (++t->suscnt == 1)
+		sched_suspend(t);
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Resume thread.
+ *
+ * A thread does not begin to run, unless both thread
+ * suspend count and task suspend count are set to 0.
+ */
+int
+thread_resume(thread_t t)
+{
+
+	ASSERT(t != curthread);
+
+	sched_lock();
+	if (!thread_valid(t)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (!task_access(t->task)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (t->suscnt == 0) {
+		sched_unlock();
+		return EINVAL;
+	}
+	t->suscnt--;
+	if (t->suscnt == 0 && t->task->suscnt == 0)
+		sched_resume(t);
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * thread_schedparam - get/set scheduling parameter.
+ */
+int
+thread_schedparam(thread_t t, int op, int *param)
+{
+	int pri, policy;
+	int error = 0;
+
+	sched_lock();
+	if (!thread_valid(t)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (t->task->flags & TF_SYSTEM) {
+		sched_unlock();
+		return EINVAL;
+	}
+	/*
+	 * A thread can change the scheduling parameters of the
+	 * threads in the same task or threads in the child task.
+	 */
+	if (!(t->task == curtask || t->task->parent == curtask) &&
+	    !task_capable(CAP_NICE)) {
+		sched_unlock();
+		return EPERM;
+	}
+
+	switch (op) {
+	case SOP_GETPRI:
+		pri = sched_getpri(t);
+		if (copyout(&pri, param, sizeof(pri)))
+			error = EINVAL;
+		break;
+
+	case SOP_SETPRI:
+		if (copyin(param, &pri, sizeof(pri))) {
+			error = EINVAL;
+			break;
+		}
+		/*
+		 * Validate the priority range.
+		 */
+		if (pri < 0)
+			pri = 0;
+		else if (pri >= PRI_IDLE)
+			pri = PRI_IDLE - 1;
+
+		/*
+		 * If the caller has CAP_NICE capability, it can
+		 * change the thread priority to any level.
+		 * Otherwise, the caller can not set the priority
+		 * to higher above realtime priority.
+		 */
+		if (pri <= PRI_REALTIME && !task_capable(CAP_NICE)) {
+			error = EPERM;
+			break;
+		}
+		/*
+		 * If a current priority is inherited for mutex,
+		 * we can not change the priority to lower value.
+		 * In this case, only the base priority is changed,
+		 * and a current priority will be adjusted to
+		 * correct value, later.
+		 */
+		if (t->priority != t->basepri && pri > t->priority)
+			pri = t->priority;
+
+		mutex_setpri(t, pri);
+		sched_setpri(t, pri, pri);
+		break;
+
+	case SOP_GETPOLICY:
+		policy = sched_getpolicy(t);
+		if (copyout(&policy, param, sizeof(policy)))
+			error = EINVAL;
+		break;
+
+	case SOP_SETPOLICY:
+		if (copyin(param, &policy, sizeof(policy))) {
+			error = EINVAL;
+			break;
+		}
+		error = sched_setpolicy(t, policy);
+		break;
+
+	default:
+		error = EINVAL;
+		break;
+	}
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Idle thread.
+ *
+ * Put the system into low power mode until we get an
+ * interrupt.  Then, we try to release the current thread to
+ * run the thread who was woken by ISR.  This routine is
+ * called only once after kernel initialization is completed.
+ */
+void
+thread_idle(void)
+{
+
+	for (;;) {
+		machine_idle();
+		sched_yield();
+	}
+}
+
+/*
+ * Allocate a thread.
+ */
+static thread_t
+thread_allocate(task_t task)
+{
+	struct thread *t;
+	void *stack;
+
+	if ((t = kmem_alloc(sizeof(*t))) == NULL)
+		return NULL;
+
+	if ((stack = kmem_alloc(KSTACKSZ)) == NULL) {
+		kmem_free(t);
+		return NULL;
+	}
+	memset(t, 0, sizeof(*t));
+
+	t->kstack = stack;
+	t->task = task;
+	list_init(&t->mutexes);
+	list_insert(&thread_list, &t->link);
+	list_insert(&task->threads, &t->task_link);
+	task->nthreads++;
+
+	return t;
+}
+
+/*
+ * Deallocate a thread.
+ *
+ * We can not release the context of the "current" thread
+ * because our thread switching always requires the current
+ * context. So, the resource deallocation is deferred until
+ * another thread calls thread_deallocate() later.
+ */
+static void
+thread_deallocate(thread_t t)
+{
+
+	list_remove(&t->task_link);
+	list_remove(&t->link);
+	t->excbits = 0;
+	t->task->nthreads--;
+
+	if (zombie != NULL) {
+		/*
+		 * Deallocate a zombie thread which
+		 * was killed in previous request.
+		 */
+		ASSERT(zombie != curthread);
+		kmem_free(zombie->kstack);
+		zombie->kstack = NULL;
+		kmem_free(zombie);
+		zombie = NULL;
+	}
+	if (t == curthread) {
+		/*
+		 * Enter zombie state and wait for
+		 * somebody to be killed us.
+		 */
+		zombie = t;
+		return;
+	}
+
+	kmem_free(t->kstack);
+	t->kstack = NULL;
+	kmem_free(t);
+}
+
+/*
+ * Return thread information.
+ */
+int
+thread_info(struct threadinfo *info)
+{
+	u_long target = info->cookie;
+	u_long i = 0;
+	thread_t t;
+	list_t n;
+
+	sched_lock();
+	n = list_last(&thread_list);
+	do {
+		if (i++ == target) {
+			t = list_entry(n, struct thread, link);
+			info->cookie = i;
+			info->id = t;
+			info->state = t->state;
+			info->policy = t->policy;
+			info->priority = t->priority;
+			info->basepri = t->basepri;
+			info->time = t->time;
+			info->suscnt = t->suscnt;
+			info->task = t->task;
+			info->active = (t == curthread) ? 1 : 0;
+			strlcpy(info->taskname, t->task->name, MAXTASKNAME);
+			strlcpy(info->slpevt, t->slpevt ?
+				t->slpevt->name : "-", MAXEVTNAME);
+			sched_unlock();
+			return 0;
+		}
+		n = list_prev(n);
+	} while (n != &thread_list);
+	sched_unlock();
+	return ESRCH;
+}
+
+/*
+ * Create a thread running in the kernel address space.
+ *
+ * Since we disable an interrupt during thread switching, the
+ * interrupt is still disabled at the entry of the kernel
+ * thread.  So, the kernel thread must enable interrupts
+ * immediately when it gets control.
+ * This routine assumes the scheduler is already locked.
+ */
+thread_t
+kthread_create(void (*entry)(void *), void *arg, int pri)
+{
+	thread_t t;
+	vaddr_t sp;
+
+	ASSERT(curthread->locks > 0);
+
+	/*
+	 * If there is not enough core for the new thread,
+	 * the caller should just drop to panic().
+	 */
+	if ((t = thread_allocate(&kernel_task)) == NULL)
+		return NULL;
+
+	memset(t->kstack, 0, KSTACKSZ);
+	sp = (vaddr_t)t->kstack + KSTACKSZ;
+	context_set(&t->ctx, CTX_KSTACK, (register_t)sp);
+	context_set(&t->ctx, CTX_KENTRY, (register_t)entry);
+	context_set(&t->ctx, CTX_KARG, (register_t)arg);
+	sched_start(t, pri, SCHED_FIFO);
+	t->suscnt = 1;
+	sched_resume(t);
+
+	return t;
+}
+
+/*
+ * Terminate a kernel thread.
+ */
+void
+kthread_terminate(thread_t t)
+{
+	ASSERT(t != NULL);
+	ASSERT(t->task->flags & TF_SYSTEM);
+
+	sched_lock();
+
+	mutex_cancel(t);
+	timer_cancel(t);
+	sched_stop(t);
+	thread_deallocate(t);
+
+	sched_unlock();
+}
+
+/*
+ * The first thread in the system is created here by hand.
+ * This thread will become an idle thread when thread_idle()
+ * is called later in main().
+ */
+void
+thread_init(void)
+{
+	void *stack;
+	vaddr_t sp;
+
+	list_init(&thread_list);
+
+	if ((stack = kmem_alloc(KSTACKSZ)) == NULL)
+		panic("thread_init");
+
+	memset(stack, 0, KSTACKSZ);
+	sp = (vaddr_t)stack + KSTACKSZ;
+	context_set(&idle_thread.ctx, CTX_KSTACK, (register_t)sp);
+	sched_start(&idle_thread, PRI_IDLE, SCHED_FIFO);
+	idle_thread.kstack = stack;
+	idle_thread.task = &kernel_task;
+	idle_thread.state = TS_RUN;
+	idle_thread.locks = 1;
+	list_init(&idle_thread.mutexes);
+
+	list_insert(&thread_list, &idle_thread.link);
+	list_insert(&kernel_task.threads, &idle_thread.task_link);
+	kernel_task.nthreads = 1;
+}
diff --git a/prex-0.9.0/sys/kern/timer.c b/prex-0.9.0/sys/kern/timer.c
new file mode 100755
index 0000000..71e6b91
--- /dev/null
+++ b/prex-0.9.0/sys/kern/timer.c
@@ -0,0 +1,469 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * timer.c - kernel timer services.
+ */
+
+#include <kernel.h>
+#include <task.h>
+#include <event.h>
+#include <sched.h>
+#include <thread.h>
+#include <kmem.h>
+#include <exception.h>
+#include <timer.h>
+#include <sys/signal.h>
+
+static volatile u_long	lbolt;		/* ticks elapsed since bootup */
+static volatile u_long	idle_ticks;	/* total ticks for idle */
+
+static struct event	timer_event;	/* event to wakeup a timer thread */
+static struct event	delay_event;	/* event for the thread delay */
+static struct list	timer_list;	/* list of active timers */
+static struct list	expire_list;	/* list of expired timers */
+
+/*
+ * Get remaining ticks to the expiration time.
+ * Return 0 if timer has been expired.
+ */
+static u_long
+time_remain(u_long expire)
+{
+
+	if (time_before(lbolt, expire))
+		return expire - lbolt;
+	return 0;
+}
+
+/*
+ * Activate a timer.
+ */
+static void
+timer_add(struct timer *tmr, u_long ticks)
+{
+	list_t head, n;
+	struct timer *t;
+
+	if (ticks == 0)
+		ticks++;
+
+	tmr->expire = lbolt + ticks;
+	tmr->state = TM_ACTIVE;
+
+	/*
+	 * Insert a timer element into the timer list which
+	 * is sorted by expiration time.
+	 */
+	head = &timer_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		t = list_entry(n, struct timer, link);
+		if (time_before(tmr->expire, t->expire))
+			break;
+	}
+	list_insert(list_prev(n), &tmr->link);
+}
+
+/*
+ * Stop an active timer.
+ */
+void
+timer_stop(struct timer *tmr)
+{
+	int s;
+
+	ASSERT(tmr != NULL);
+
+	s = splhigh();
+	if (tmr->state == TM_ACTIVE) {
+		list_remove(&tmr->link);
+		tmr->state = TM_STOP;
+	}
+	splx(s);
+}
+
+/*
+ * Schedule a callout function to run after a specified
+ * length of time.
+ *
+ * Note: A device driver can call timer_callout() or
+ * timer_stop() from ISR at interrupt level.
+ */
+void
+timer_callout(struct timer *tmr, u_long msec, void (*fn)(void *), void *arg)
+{
+	int s;
+
+	ASSERT(tmr != NULL);
+	ASSERT(fn != NULL);
+
+	s = splhigh();
+
+	if (tmr->state == TM_ACTIVE)
+		list_remove(&tmr->link);
+
+	tmr->func = fn;
+	tmr->arg = arg;
+	tmr->interval = 0;
+	timer_add(tmr, mstohz(msec));
+
+	splx(s);
+}
+
+/*
+ * timer_delay - delay thread execution.
+ *
+ * The caller thread is blocked for the specified time.
+ * Returns 0 on success, or the remaining time (msec) on
+ * failure.
+ */
+u_long
+timer_delay(u_long msec)
+{
+	struct timer *tmr;
+	u_long remain = 0;
+	int rc;
+
+	rc = sched_tsleep(&delay_event, msec);
+	if (rc != SLP_TIMEOUT) {
+		tmr = &curthread->timeout;
+		remain = hztoms(time_remain(tmr->expire));
+	}
+	return remain;
+}
+
+/*
+ * timer_sleep - sleep system call.
+ *
+ * Stop execution of the current thread for the indicated amount
+ * of time.  If the sleep is interrupted, the remaining time is
+ * set in "remain".
+ */
+int
+timer_sleep(u_long msec, u_long *remain)
+{
+	u_long left;
+
+	left = timer_delay(msec);
+
+	if (remain != NULL) {
+		if (copyout(&left, remain, sizeof(left)))
+			return EFAULT;
+	}
+	if (left > 0)
+		return EINTR;
+	return 0;
+}
+
+/*
+ * Alarm timer expired:
+ * Send an alarm exception to the target task.
+ */
+static void
+alarm_expire(void *arg)
+{
+	task_t task = (task_t)arg;
+
+	exception_post(task, SIGALRM);
+}
+
+/*
+ * timer_alarm - alarm system call.
+ *
+ * SIGALRM exception is sent to the caller task when specified
+ * delay time is passed. If "msec" argument is 0, stop the
+ * current running timer.
+ */
+int
+timer_alarm(u_long msec, u_long *remain)
+{
+	struct timer *tmr;
+	u_long left = 0;
+	int s;
+
+	s = splhigh();
+	tmr = &curtask->alarm;
+
+	/*
+	 * If the timer is active, save the remaining time
+	 * before we update the timer setting.
+	 */
+	if (tmr->state == TM_ACTIVE)
+		left = hztoms(time_remain(tmr->expire));
+
+	if (msec == 0)
+		timer_stop(tmr);
+	else
+		timer_callout(tmr, msec, &alarm_expire, curtask);
+
+	splx(s);
+	if (remain != NULL) {
+		if (copyout(&left, remain, sizeof(left)))
+			return EFAULT;
+	}
+	return 0;
+}
+
+/*
+ * timer_periodic - set periodic timer for the specified thread.
+ *
+ * The periodic thread can wait the timer period by calling
+ * timer_waitperiod(). The unit of start/period is milli-seconds.
+ */
+int
+timer_periodic(thread_t t, u_long start, u_long period)
+{
+	struct timer *tmr;
+	int s;
+
+	if (start != 0 && period == 0)
+		return EINVAL;
+
+	sched_lock();
+	if (!thread_valid(t)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (t->task != curtask) {
+		sched_unlock();
+		return EPERM;
+	}
+
+	tmr = t->periodic;
+	if (start == 0) {
+		/*
+		 * Cancel periodic timer.
+		 */
+		if (tmr == NULL || tmr->state != TM_ACTIVE) {
+			sched_unlock();
+			return EINVAL;
+		}
+		timer_stop(tmr);
+	} else {
+		if (tmr == NULL) {
+			/*
+			 * Allocate a timer element at first call.
+			 * This is to save the data area in the thread
+			 * structure.
+			 */
+			if ((tmr = kmem_alloc(sizeof(tmr))) == NULL) {
+				sched_unlock();
+				return ENOMEM;
+			}
+			memset(tmr, 0, sizeof(*tmr));
+			event_init(&tmr->event, "periodic");
+			t->periodic = tmr;
+		}
+		/*
+		 * Program an interval timer.
+		 */
+		s = splhigh();
+		tmr->interval = mstohz(period);
+		if (tmr->interval == 0)
+			tmr->interval = 1;
+		timer_add(tmr, mstohz(start));
+		splx(s);
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * timer_waitperiod - wait next period of the periodic timer.
+ *
+ * If the caller task receives any exception, this system call
+ * will return before target time. So, the caller must retry
+ * immediately if the error status is EINTR. This will be
+ * automatically done by the library stub routine.
+ */
+int
+timer_waitperiod(void)
+{
+	struct timer *tmr;
+	int rc;
+
+	tmr = curthread->periodic;
+	if (tmr == NULL || tmr->state != TM_ACTIVE)
+		return EINVAL;
+
+	if (time_before(lbolt, tmr->expire)) {
+		/*
+		 * Sleep until timer_handler() routine wakes us up.
+		 */
+		rc = sched_sleep(&tmr->event);
+		if (rc != SLP_SUCCESS)
+			return EINTR;
+	}
+	return 0;
+}
+
+/*
+ * Untimeout the timers for the thread termination.
+ */
+void
+timer_cancel(thread_t t)
+{
+
+	if (t->periodic != NULL) {
+		timer_stop(t->periodic);
+		kmem_free(t->periodic);
+		t->periodic = NULL;
+	}
+}
+
+/*
+ * Timer thread.
+ *
+ * Handle all expired timers. Each callout routine is
+ * called with scheduler locked and interrupts enabled.
+ */
+static void
+timer_thread(void *dummy)
+{
+	struct timer *tmr;
+
+	splhigh();
+
+	for (;;) {
+		/*
+		 * Wait until next timer expiration.
+		 */
+		sched_sleep(&timer_event);
+
+		while (!list_empty(&expire_list)) {
+			/*
+			 * callout
+			 */
+			tmr = timer_next(&expire_list);
+			list_remove(&tmr->link);
+			tmr->state = TM_STOP;
+			sched_lock();
+			spl0();
+			(*tmr->func)(tmr->arg);
+
+			/*
+			 * Unlock scheduler here in order to give
+			 * chance to higher priority threads to run.
+			 */
+			sched_unlock();
+			splhigh();
+		}
+	}
+	/* NOTREACHED */
+}
+
+/*
+ * Handle clock interrupts.
+ *
+ * timer_handler() is called directly from the real time clock
+ * interrupt.  All interrupts are still disabled at the entry
+ * of this routine.
+ */
+void
+timer_handler(void)
+{
+	struct timer *tmr;
+	u_long ticks;
+	int wakeup = 0;
+
+	/*
+	 * Bump time in ticks.
+	 * Note that it is allowed to wrap.
+	 */
+	lbolt++;
+	if (curthread->priority == PRI_IDLE)
+		idle_ticks++;
+
+	while (!list_empty(&timer_list)) {
+		/*
+		 * Check timer expiration.
+		 */
+		tmr = timer_next(&timer_list);
+		if (time_before(lbolt, tmr->expire))
+			break;
+
+		list_remove(&tmr->link);
+		if (tmr->interval != 0) {
+			/*
+			 * Periodic timer - reprogram timer again.
+			 */
+			ticks = time_remain(tmr->expire + tmr->interval);
+			timer_add(tmr, ticks);
+			sched_wakeup(&tmr->event);
+		} else {
+			/*
+			 * One-shot timer
+			 */
+			list_insert(&expire_list, &tmr->link);
+			wakeup = 1;
+		}
+	}
+	if (wakeup)
+		sched_wakeup(&timer_event);
+
+	sched_tick();
+}
+
+/*
+ * Return ticks since boot.
+ */
+u_long
+timer_ticks(void)
+{
+
+	return lbolt;
+}
+
+/*
+ * Return timer information.
+ */
+void
+timer_info(struct timerinfo *info)
+{
+
+	info->hz = HZ;
+	info->cputicks = lbolt;
+	info->idleticks = idle_ticks;
+}
+
+/*
+ * Initialize the timer facility, called at system startup time.
+ */
+void
+timer_init(void)
+{
+
+	event_init(&timer_event, "timer");
+	event_init(&delay_event, "delay");
+	list_init(&timer_list);
+	list_init(&expire_list);
+
+	if (kthread_create(&timer_thread, NULL, PRI_TIMER) == NULL)
+		panic("timer_init");
+}
diff --git a/prex-0.9.0/sys/lib/queue.c b/prex-0.9.0/sys/lib/queue.c
new file mode 100755
index 0000000..96de44c
--- /dev/null
+++ b/prex-0.9.0/sys/lib/queue.c
@@ -0,0 +1,87 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * queue.c - generic queue management library
+ */
+
+#include <kernel.h>
+
+/*
+ * Insert element at tail of queue
+ */
+void
+enqueue(queue_t head, queue_t item)
+{
+
+	item->next = head;
+	item->prev = head->prev;
+	item->prev->next = item;
+	head->prev = item;
+}
+
+/*
+ * Remove and return element of head of queue
+ */
+queue_t
+dequeue(queue_t head)
+{
+	queue_t item;
+
+	if (head->next == head)
+		return ((queue_t)0);
+	item = head->next;
+	item->next->prev = head;
+	head->next = item->next;
+	return item;
+}
+
+/*
+ * Insert element after specified element
+ */
+void
+queue_insert(queue_t prev, queue_t item)
+{
+
+	item->prev = prev;
+	item->next = prev->next;
+	prev->next->prev = item;
+	prev->next = item;
+}
+
+/*
+ * Remove specified element from queue
+ */
+void
+queue_remove(queue_t item)
+{
+
+	item->prev->next = item->next;
+	item->next->prev = item->prev;
+}
diff --git a/prex-0.9.0/sys/lib/string.c b/prex-0.9.0/sys/lib/string.c
new file mode 100755
index 0000000..103e0f1
--- /dev/null
+++ b/prex-0.9.0/sys/lib/string.c
@@ -0,0 +1,113 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * string.c - Minimum string library for kernel
+ */
+
+#include <kernel.h>
+
+/*
+ * Safer version of strncpy
+ * The destination string is always terminated with NULL character.
+ */
+size_t
+strlcpy(char *dest, const char *src, size_t count)
+{
+	char *d = dest;
+	const char *s = src;
+	size_t n = count;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0 && --n != 0) {
+		do {
+			if ((*d++ = *s++) == 0)
+				break;
+		} while (--n != 0);
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (count != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return (size_t)(s - src - 1);	/* count does not include NUL */
+}
+
+int
+strncmp(const char *src, const char *tgt, size_t count)
+{
+	signed char res = 0;
+
+	while (count) {
+		if ((res = *src - *tgt++) != 0 || !*src++)
+			break;
+		count--;
+	}
+	return res;
+}
+
+/* The returned size does not include the last NULL char */
+size_t
+strnlen(const char *str, size_t count)
+{
+	const char *tmp;
+
+	for (tmp = str; count-- && *tmp != '\0'; ++tmp);
+	return (size_t)(tmp - str);
+}
+
+void *
+memcpy(void *dest, const void *src, size_t count)
+{
+	char *tmp = (char *)dest, *s = (char *)src;
+
+	ASSERT(count != 0);
+
+	while (count--)
+		*tmp++ = *s++;
+
+	return dest;
+}
+
+void *
+memset(void *dest, int ch, size_t count)
+{
+	char *p = (char *)dest;
+
+	ASSERT(count != 0);
+
+	while (count--)
+		*p++ = (char)ch;
+
+	return dest;
+}
diff --git a/prex-0.9.0/sys/lib/vsprintf.c b/prex-0.9.0/sys/lib/vsprintf.c
new file mode 100755
index 0000000..d48ea4a
--- /dev/null
+++ b/prex-0.9.0/sys/lib/vsprintf.c
@@ -0,0 +1,147 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vsprintf.c - Format and output data to buffer
+ */
+
+#include <kernel.h>
+
+#define isdigit(c)  ((u_int)((c) - '0') < 10)
+
+static u_long
+divide(long *n, int base)
+{
+	u_long res;
+
+	res = ((u_long)*n) % base;
+	*n = (long)(((u_long)*n) / base);
+	return res;
+}
+
+static int
+atoi(const char **s)
+{
+	int i = 0;
+	while (isdigit((int)**s))
+		i = i * 10 + *((*s)++) - '0';
+	return i;
+}
+
+/*
+ * Print formatted output - scaled down version
+ *
+ * Identifiers:
+ *  %d - Decimal signed int
+ *  %x - Hex integer
+ *  %u - Unsigned integer
+ *  %c - Character
+ *  %s - String
+ *
+ * Flags:
+ *   0 - Zero pad
+ */
+int
+vsprintf(char *buf, const char *fmt, va_list args)
+{
+	char *p, *str;
+	const char *digits = "0123456789abcdef";
+	char pad, tmp[16];
+	int width, base, sign, i;
+	long num;
+
+	for (p = buf; *fmt; fmt++) {
+		if (*fmt != '%') {
+			*p++ = *fmt;
+			continue;
+		}
+		/* get flags */
+		++fmt;
+		pad = ' ';
+		if (*fmt == '0') {
+			pad = '0';
+			fmt++;
+		}
+		/* get width */
+		width = -1;
+		if (isdigit(*fmt)) {
+			width = atoi(&fmt);
+		}
+		/* ignore long */
+		if (*fmt == 'l')
+			fmt++;
+		base = 10;
+		sign = 0;
+		switch (*fmt) {
+		case 'c':
+			*p++ = (char)va_arg(args, int);
+			continue;
+		case 's':
+			str = va_arg(args, char *);
+			if (str == NULL)
+				str = "<NULL>";
+			for (; *str && width != 0; str++, width--) {
+				*p++ = *str;
+			}
+			while (width-- > 0)
+				*p++ = pad;
+			continue;
+		case 'X':
+		case 'x':
+			base = 16;
+			break;
+		case 'd':
+			sign = 1;
+			break;
+		case 'u':
+			break;
+		default:
+			continue;
+		}
+		num = va_arg(args, long);
+		if (sign && num < 0) {
+			num = -num;
+			*p++ = '-';
+			width--;
+		}
+		i = 0;
+		if (num == 0)
+			tmp[i++] = '0';
+		else
+			while (num != 0)
+				tmp[i++] = digits[divide(&num, base)];
+		width -= i;
+		while (width-- > 0)
+			*p++ = pad;
+		while (i-- > 0)
+			*p++ = tmp[i];
+	}
+	*p = '\0';
+	return 0;
+}
diff --git a/prex-0.9.0/sys/mem/kmem.c b/prex-0.9.0/sys/mem/kmem.c
new file mode 100755
index 0000000..c332eea
--- /dev/null
+++ b/prex-0.9.0/sys/mem/kmem.c
@@ -0,0 +1,331 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * kmem.c - kernel memory allocator
+ */
+
+/*
+ * This is a memory allocator optimized for the low foot print
+ * kernel. It works on top of the underlying page allocator, and
+ * manages more smaller memory than page size. It will divide one page
+ * into two or more blocks, and each page is linked as a kernel page.
+ *
+ * There are following 3 linked lists to manage used/free blocks.
+ *  1) All pages allocated for the kernel memory are linked.
+ *  2) All blocks divided in the same page are linked.
+ *  3) All free blocks of the same size are linked.
+ *
+ * Currently, it can not handle the memory size exceeding one page.
+ * Instead, a driver can use page_alloc() to allocate larger memory.
+ *
+ * The kmem functions are used by not only the kernel core but also by
+ * the buggy drivers. If such kernel code illegally writes data in
+ * exceeding the allocated area, the system will crash easily. In
+ * order to detect the memory over run, each free block has a magic
+ * ID.
+ */
+
+#include <kernel.h>
+#include <page.h>
+#include <sched.h>
+#include <vm.h>
+#include <kmem.h>
+
+/*
+ * Block header
+ *
+ * All free blocks that have same size are linked each other.
+ * In addition, all free blocks within same page are also linked.
+ */
+struct block_hdr {
+	u_short		 magic;		/* magic number */
+	u_short		 size;		/* size of this block */
+	struct list	 link;		/* link to the free list */
+	struct block_hdr *pg_next;	/* next block in same page */
+};
+
+/*
+ * Page header
+ *
+ * The page header is placed at the top of each page. This
+ * header is used in order to free the page when there are no
+ * used block left in the page. If 'nallocs' value becomes zero,
+ * that page can be removed from kernel page.
+ */
+struct page_hdr {
+	u_short		 magic;		/* magic number */
+	u_short		 nallocs;	/* number of allocated blocks */
+	struct block_hdr first_blk;	/* first block in this page */
+};
+
+#define ALIGN_SIZE	16
+#define ALIGN_MASK	(ALIGN_SIZE - 1)
+#define ALLOC_SIZE(n)	(size_t) \
+			(((vaddr_t)(n) + ALIGN_MASK) & (vaddr_t)~ALIGN_MASK)
+
+/* number of free block list */
+#define NR_BLOCK_LIST	(PAGE_SIZE / ALIGN_SIZE)
+
+#define BLOCK_MAGIC	0xdead
+#define PAGE_MAGIC	0xbeef
+
+#define BLKHDR_SIZE	(sizeof(struct block_hdr))
+#define PGHDR_SIZE	(sizeof(struct page_hdr))
+#define MAX_ALLOC_SIZE	(size_t)(PAGE_SIZE - PGHDR_SIZE)
+
+#define MIN_BLOCK_SIZE	(BLKHDR_SIZE + 16)
+#define MAX_BLOCK_SIZE	(u_short)(PAGE_SIZE - (PGHDR_SIZE - BLKHDR_SIZE))
+
+/* macro to point the page header from specific address. */
+#define PAGETOP(n)	(struct page_hdr *) \
+			    ((vaddr_t)(n) & (vaddr_t)~(PAGE_SIZE - 1))
+
+/* macro to get the index of free block list. */
+#define BLKNDX(b)	((u_int)((b)->size) >> 4)
+
+/**
+ * Array of the head block of free block list.
+ *
+ * The index of array is decided by the size of each block.
+ * All block has the size of the multiple of 16.
+ *
+ * ie. free_blocks[0] = list for 16 byte block
+ *     free_blocks[1] = list for 32 byte block
+ *     free_blocks[2] = list for 48 byte block
+ *         .
+ *         .
+ *     free_blocks[255] = list for 4096 byte block
+ *
+ * Generally, only one list is used to search the free block with
+ * a first fit algorithm. Basically, this allocator also uses a
+ * first fit method. However it uses multiple lists corresponding
+ * to each block size. A search is started from the list of the
+ * requested size. So, it is not necessary to search smaller
+ * block's list wastefully.
+ *
+ * Most of kernel memory allocator is using 2^n as block size.
+ * But, these implementation will throw away much memory that
+ * the block size is not fit. This is not suitable for the
+ * embedded system with low foot print.
+ */
+static struct list free_blocks[NR_BLOCK_LIST];
+
+/*
+ * Find the free block for the specified size.
+ * Returns pointer to free block, or NULL on failure.
+ *
+ * First, it searches from the list of same size. If it does not
+ * exists, then it will search the list of larger one.
+ * It will use the block of smallest size that satisfies the
+ * specified size.
+ */
+static struct block_hdr *
+block_find(size_t size)
+{
+	int i;
+	list_t n;
+
+	for (i = (int)((u_int)size >> 4); i < NR_BLOCK_LIST; i++) {
+		if (!list_empty(&free_blocks[i]))
+			break;
+	}
+	if (i >= NR_BLOCK_LIST)
+		return NULL;
+
+	n = list_first(&free_blocks[i]);
+	return list_entry(n, struct block_hdr, link);
+}
+
+/*
+ * Allocate memory block for kernel
+ *
+ * This function does not fill the allocated block by 0 for performance.
+ * kmem_alloc() returns NULL on failure.
+ *
+ * => must not be called from interrupt context.
+ */
+void *
+kmem_alloc(size_t size)
+{
+	struct block_hdr *blk, *newblk;
+	struct page_hdr *pg;
+	paddr_t pa;
+	void *p;
+
+	ASSERT(size != 0);
+
+	sched_lock();		/* Lock scheduler */
+
+	/*
+	 * First, the free block of enough size is searched
+	 * from the page already used. If it does not exist,
+	 * new page is allocated for free block.
+	 */
+	size = ALLOC_SIZE(size + BLKHDR_SIZE);
+	if (size > MAX_ALLOC_SIZE)
+		panic("kmem_alloc: too large allocation");
+
+	blk = block_find(size);
+	if (blk) {
+		/*
+		 * Block found.
+		 */
+		list_remove(&blk->link); /* Remove from free list */
+		pg = PAGETOP(blk);	 /* Get the page address */
+	} else {
+		/*
+		 * No block found. Allocate new page.
+		 */
+		if ((pa = page_alloc(PAGE_SIZE)) == 0) {
+			sched_unlock();
+			return NULL;
+		}
+		pg = ptokv(pa);
+		pg->nallocs = 0;
+		pg->magic = PAGE_MAGIC;
+
+		/*
+		 * Setup first block.
+		 */
+		blk = &pg->first_blk;
+		blk->magic = BLOCK_MAGIC;
+		blk->size = MAX_BLOCK_SIZE;
+		blk->pg_next = NULL;
+	}
+
+	/*
+	 * Sanity check
+	 */
+	if (pg->magic != PAGE_MAGIC || blk->magic != BLOCK_MAGIC)
+		panic("kmem_alloc: overrun");
+
+	/*
+	 * If the found block is large enough, split it.
+	 */
+	if (blk->size - size >= MIN_BLOCK_SIZE) {
+		/*
+		 * Make new block.
+		 */
+		newblk = (struct block_hdr *)((vaddr_t)blk + size);
+		newblk->magic = BLOCK_MAGIC;
+		newblk->size = (u_short)(blk->size - size);
+		list_insert(&free_blocks[BLKNDX(newblk)], &newblk->link);
+
+		/*
+		 * Update page list.
+		 */
+		newblk->pg_next = blk->pg_next;
+		blk->pg_next = newblk;
+		blk->size = (u_short)size;
+	}
+	/*
+	 * Increment allocation count of this page.
+	 */
+	pg->nallocs++;
+	p = (void *)((vaddr_t)blk + BLKHDR_SIZE);
+
+	sched_unlock();
+	return p;
+}
+
+/*
+ * Free allocated memory block.
+ *
+ * Some kernel does not release the free page for the kernel memory
+ * because it is needed to allocate immediately later. For example,
+ * it is efficient here if the free page is just linked to the list
+ * of the biggest size. However, consider the case where a driver
+ * requires many small memories temporarily. After these pages are
+ * freed, they can not be reused for an application.
+ */
+void
+kmem_free(void *ptr)
+{
+	struct block_hdr *blk;
+	struct page_hdr *pg;
+
+	ASSERT(ptr != NULL);
+
+	/* Lock scheduler */
+	sched_lock();
+
+	/* Get the block header */
+	blk = (struct block_hdr *)((vaddr_t)ptr - BLKHDR_SIZE);
+	if (blk->magic != BLOCK_MAGIC)
+		panic("kmem_free: invalid address");
+
+	/*
+	 * Return the block to free list. Since kernel code will
+	 * request fixed size of memory block, we don't merge the
+	 * blocks to use it as cache.
+	 */
+	list_insert(&free_blocks[BLKNDX(blk)], &blk->link);
+
+	/*
+	 * Decrement allocation count of this page.
+	 */
+	pg = PAGETOP(blk);
+	if (--pg->nallocs == 0) {
+		/*
+		 * No allocated block in this page.
+		 * Remove all blocks and deallocate this page.
+		 */
+		for (blk = &pg->first_blk; blk != NULL; blk = blk->pg_next) {
+			list_remove(&blk->link); /* Remove from free list */
+		}
+		pg->magic = 0;
+		page_free(kvtop(pg), PAGE_SIZE);
+	}
+	sched_unlock();
+}
+
+/*
+ * Map specified virtual address to the kernel address
+ * Returns kernel address on success, or NULL if no mapped memory.
+ */
+void *
+kmem_map(void *addr, size_t size)
+{
+	paddr_t pa;
+
+	pa = vm_translate((vaddr_t)addr, size);
+	if (pa == 0)
+		return NULL;
+	return ptokv(pa);
+}
+
+void
+kmem_init(void)
+{
+	int i;
+
+	for (i = 0; i < NR_BLOCK_LIST; i++)
+		list_init(&free_blocks[i]);
+}
diff --git a/prex-0.9.0/sys/mem/page.c b/prex-0.9.0/sys/mem/page.c
new file mode 100755
index 0000000..ea876ac
--- /dev/null
+++ b/prex-0.9.0/sys/mem/page.c
@@ -0,0 +1,302 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * page.c - physical page allocator
+ */
+
+/*
+ * Simple list-based page allocator:
+ *
+ * When the remaining page is exhausted, what should we do ?
+ * If the system can stop with panic() here, the error check of
+ * many portions in kernel is not necessary, and kernel code can
+ * become more simple. But, in general, even if a page is
+ * exhausted, a kernel can not be stopped but it should return an
+ * error and continue processing.  If the memory becomes short
+ * during boot time, kernel and drivers can use panic() in that
+ * case.
+ */
+
+#include <kernel.h>
+#include <page.h>
+#include <sched.h>
+#include <hal.h>
+
+/*
+ * The page structure is put on the head of the first page of
+ * each free block.
+ */
+struct page {
+	struct page	*next;
+	struct page	*prev;
+	vsize_t		size;		/* number of bytes of this block */
+};
+
+static struct page	page_head;	/* first free block */
+static psize_t		total_size;	/* size of memory in the system */
+static psize_t		used_size;	/* current used size */
+static psize_t		bootdisk_size;	/* size of the boot disk */
+
+/*
+ * page_alloc - allocate continuous pages of the specified size.
+ *
+ * This routine returns the physical address of a new free page
+ * block, or returns NULL on failure. The requested size is
+ * automatically round up to the page boundary.  The allocated
+ * memory is _not_ filled with 0.
+ */
+paddr_t
+page_alloc(psize_t psize)
+{
+	struct page *blk, *tmp;
+	vsize_t size;
+
+	ASSERT(psize != 0);
+
+	sched_lock();
+
+	/*
+	 * Find the free block that has enough size.
+	 */
+	size = round_page(psize);
+	blk = &page_head;
+	do {
+		blk = blk->next;
+		if (blk == &page_head) {
+			sched_unlock();
+			DPRINTF(("page_alloc: out of memory\n"));
+			return 0;	/* Not found. */
+		}
+	} while (blk->size < size);
+
+	/*
+	 * If found block size is exactly same with requested,
+	 * just remove it from a free list. Otherwise, the
+	 * found block is divided into two and first half is
+	 * used for allocation.
+	 */
+	if (blk->size == size) {
+		blk->prev->next = blk->next;
+		blk->next->prev = blk->prev;
+	} else {
+		tmp = (struct page *)((vaddr_t)blk + size);
+		tmp->size = blk->size - size;
+		tmp->prev = blk->prev;
+		tmp->next = blk->next;
+		blk->prev->next = tmp;
+		blk->next->prev = tmp;
+	}
+	used_size += (psize_t)size;
+	sched_unlock();
+	return kvtop(blk);
+}
+
+/*
+ * Free page block.
+ *
+ * This allocator does not maintain the size of allocated page
+ * block. The caller must provide the size information of the
+ * block.
+ */
+void
+page_free(paddr_t paddr, psize_t psize)
+{
+	struct page *blk, *prev;
+	vsize_t size;
+
+	ASSERT(psize != 0);
+
+	sched_lock();
+
+	size = round_page(psize);
+	blk = ptokv(paddr);
+
+	/*
+	 * Find the target position in list.
+	 */
+	for (prev = &page_head; prev->next < blk; prev = prev->next) {
+		if (prev->next == &page_head)
+			break;
+	}
+
+	/*
+	 * Insert new block into list.
+	 */
+	blk->size = size;
+	blk->prev = prev;
+	blk->next = prev->next;
+	prev->next->prev = blk;
+	prev->next = blk;
+
+	/*
+	 * If the adjoining block is free, it combines and
+	 * is made on block.
+	 */
+	if (blk->next != &page_head &&
+	    ((vaddr_t)blk + blk->size) == (vaddr_t)blk->next) {
+		blk->size += blk->next->size;
+		blk->next = blk->next->next;
+		blk->next->prev = blk;
+	}
+	if (blk->prev != &page_head &&
+	    (vaddr_t)blk->prev + blk->prev->size == (vaddr_t)blk) {
+		blk->prev->size += blk->size;
+		blk->prev->next = blk->next;
+		blk->next->prev = blk->prev;
+	}
+	used_size -= (psize_t)size;
+	sched_unlock();
+}
+
+/*
+ * The function to reserve pages in specific address.
+ */
+int
+page_reserve(paddr_t paddr, psize_t psize)
+{
+	struct page *blk, *tmp;
+	vaddr_t start, end;
+	vsize_t size;
+
+	if (psize == 0)
+		return 0;
+
+	start = trunc_page((vaddr_t)ptokv(paddr));
+	end = round_page((vaddr_t)ptokv(paddr + psize));
+	size = end - start;
+
+	/*
+	 * Find the block which includes specified block.
+	 */
+	blk = page_head.next;
+	for (;;) {
+		if (blk == &page_head)
+			return ENOMEM;
+
+		if ((vaddr_t)blk <= start
+		    && end <= (vaddr_t)blk + blk->size)
+			break;
+		blk = blk->next;
+	}
+	if ((vaddr_t)blk == start && blk->size == size) {
+		/*
+		 * Unlink the block from free list.
+		 */
+		blk->prev->next = blk->next;
+		blk->next->prev = blk->prev;
+	} else {
+		/*
+		 * Split this block.
+		 */
+		if ((vaddr_t)blk + blk->size != end) {
+			tmp = (struct page *)end;
+			tmp->size = (vaddr_t)blk + blk->size - end;
+			tmp->next = blk->next;
+			tmp->prev = blk;
+
+			blk->size -= tmp->size;
+			blk->next->prev = tmp;
+			blk->next = tmp;
+		}
+		if ((vaddr_t)blk == start) {
+			blk->prev->next = blk->next;
+			blk->next->prev = blk->prev;
+		} else
+			blk->size = start - (vaddr_t)blk;
+	}
+	used_size += (psize_t)size;
+	return 0;
+}
+
+void
+page_info(struct meminfo *info)
+{
+
+	info->total = total_size;
+	info->free = total_size - used_size;
+	info->bootdisk = bootdisk_size;
+
+#ifndef CONFIG_ROMBOOT
+	/*
+	 * The boot disk is placed at RAM.
+	 */
+	info->free -= bootdisk_size;
+#endif
+}
+
+/*
+ * Initialize page allocator.
+ * page_init() must be called prior to other memory manager's
+ * initializations.
+ */
+void
+page_init(void)
+{
+	struct physmem *ram;
+	struct bootinfo *bi;
+	int i;
+
+	machine_bootinfo(&bi);
+
+	total_size = 0;
+	bootdisk_size = 0;
+	page_head.next = page_head.prev = &page_head;
+
+	/*
+	 * First, create a free list from the boot information.
+	 */
+	for (i = 0; i < bi->nr_rams; i++) {
+		ram = &bi->ram[i];
+		if (ram->type == MT_USABLE) {
+			page_free(ram->base, ram->size);
+			total_size += ram->size;
+		}
+	}
+	/*
+	 * Then, reserve un-usable memory.
+	 */
+	for (i = 0; i < bi->nr_rams; i++) {
+		ram = &bi->ram[i];
+		switch (ram->type) {
+		case MT_BOOTDISK:
+			bootdisk_size += ram->size;
+			/* FALLTHROUGH */
+		case MT_MEMHOLE:
+			total_size -= ram->size;
+			/* FALLTHROUGH */
+		case MT_RESERVED:
+			if (page_reserve(ram->base, ram->size))
+				panic("page_init");
+			break;
+		}
+	}
+	used_size = 0;
+	DPRINTF(("Memory size=%ld\n", total_size));
+}
diff --git a/prex-0.9.0/sys/mem/vm.c b/prex-0.9.0/sys/mem/vm.c
new file mode 100755
index 0000000..7ed5cbe
--- /dev/null
+++ b/prex-0.9.0/sys/mem/vm.c
@@ -0,0 +1,985 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vm.c - virtual memory allocator
+ */
+
+/*
+ * A task owns its private virtual address space. All threads in
+ * a task share one same memory space.
+ * When new task is made, the address mapping of the parent task
+ * is copied to child task's. In this time, the read-only space
+ * is shared with old map.
+ *
+ * Since this kernel does not do page out to the physical storage,
+ * it is guaranteed that the allocated memory is always continuing
+ * and existing. Thereby, a kernel and drivers can be constructed
+ * very simply.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <thread.h>
+#include <page.h>
+#include <task.h>
+#include <sched.h>
+#include <hal.h>
+#include <vm.h>
+
+/* forward declarations */
+static void	   seg_init(struct seg *);
+static struct seg *seg_create(struct seg *, vaddr_t, size_t);
+static void	   seg_delete(struct seg *, struct seg *);
+static struct seg *seg_lookup(struct seg *, vaddr_t, size_t);
+static struct seg *seg_alloc(struct seg *, size_t);
+static void	   seg_free(struct seg *, struct seg *);
+static struct seg *seg_reserve(struct seg *, vaddr_t, size_t);
+static int	   do_allocate(vm_map_t, void **, size_t, int);
+static int	   do_free(vm_map_t, void *);
+static int	   do_attribute(vm_map_t, void *, int);
+static int	   do_map(vm_map_t, void *, size_t, void **);
+static vm_map_t	   do_dup(vm_map_t);
+
+
+static struct vm_map	kernel_map;	/* vm mapping for kernel */
+
+/**
+ * vm_allocate - allocate zero-filled memory for specified address
+ *
+ * If "anywhere" argument is true, the "addr" argument will be
+ * ignored.  In this case, the address of free space will be
+ * found automatically.
+ *
+ * The allocated area has writable, user-access attribute by
+ * default.  The "addr" and "size" argument will be adjusted
+ * to page boundary.
+ */
+int
+vm_allocate(task_t task, void **addr, size_t size, int anywhere)
+{
+	int error;
+	void *uaddr;
+
+	sched_lock();
+
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (copyin(addr, &uaddr, sizeof(uaddr))) {
+		sched_unlock();
+		return EFAULT;
+	}
+	if (anywhere == 0 && !user_area(*addr)) {
+		sched_unlock();
+		return EACCES;
+	}
+
+	error = do_allocate(task->map, &uaddr, size, anywhere);
+	if (!error) {
+		if (copyout(&uaddr, addr, sizeof(uaddr)))
+			error = EFAULT;
+	}
+	sched_unlock();
+	return error;
+}
+
+static int
+do_allocate(vm_map_t map, void **addr, size_t size, int anywhere)
+{
+	struct seg *seg;
+	vaddr_t start, end;
+	paddr_t pa;
+
+	if (size == 0)
+		return EINVAL;
+	if (map->total + size >= MAXMEM)
+		return ENOMEM;
+
+	/*
+	 * Allocate segment
+	 */
+	if (anywhere) {
+		size = round_page(size);
+		if ((seg = seg_alloc(&map->head, size)) == NULL)
+			return ENOMEM;
+	} else {
+		start = trunc_page((vaddr_t)*addr);
+		end = round_page(start + size);
+		size = (size_t)(end - start);
+
+		if ((seg = seg_reserve(&map->head, start, size)) == NULL)
+			return ENOMEM;
+	}
+	seg->flags = SEG_READ | SEG_WRITE;
+
+	/*
+	 * Allocate physical pages, and map them into virtual address
+	 */
+	if ((pa = page_alloc(size)) == 0)
+		goto err1;
+
+	if (mmu_map(map->pgd, pa, seg->addr, size, PG_WRITE))
+		goto err2;
+
+	seg->phys = pa;
+
+	/* Zero fill */
+	memset(ptokv(pa), 0, seg->size);
+	*addr = (void *)seg->addr;
+	map->total += size;
+	return 0;
+
+ err2:
+	page_free(pa, size);
+ err1:
+	seg_free(&map->head, seg);
+	return ENOMEM;
+}
+
+/*
+ * Deallocate memory segment for specified address.
+ *
+ * The "addr" argument points to a memory segment previously
+ * allocated through a call to vm_allocate() or vm_map(). The
+ * number of bytes freed is the number of bytes of the
+ * allocated segment. If one of the segment of previous and next
+ * are free, it combines with them, and larger free segment is
+ * created.
+ */
+int
+vm_free(task_t task, void *addr)
+{
+	int error;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (!user_area(addr)) {
+		sched_unlock();
+		return EFAULT;
+	}
+
+	error = do_free(task->map, addr);
+
+	sched_unlock();
+	return error;
+}
+
+static int
+do_free(vm_map_t map, void *addr)
+{
+	struct seg *seg;
+	vaddr_t va;
+
+	va = trunc_page((vaddr_t)addr);
+
+	/*
+	 * Find the target segment.
+	 */
+	seg = seg_lookup(&map->head, va, 1);
+	if (seg == NULL || seg->addr != va || (seg->flags & SEG_FREE))
+		return EINVAL;
+
+	/*
+	 * Unmap pages of the segment.
+	 */
+	mmu_map(map->pgd, seg->phys, seg->addr,	seg->size, PG_UNMAP);
+
+	/*
+	 * Relinquish use of the page if it is not shared and mapped.
+	 */
+	if (!(seg->flags & SEG_SHARED) && !(seg->flags & SEG_MAPPED))
+		page_free(seg->phys, seg->size);
+
+	map->total -= seg->size;
+	seg_free(&map->head, seg);
+
+	return 0;
+}
+
+/*
+ * Change attribute of specified virtual address.
+ *
+ * The "addr" argument points to a memory segment previously
+ * allocated through a call to vm_allocate(). The attribute
+ * type can be chosen a combination of PROT_READ, PROT_WRITE.
+ * Note: PROT_EXEC is not supported, yet.
+ */
+int
+vm_attribute(task_t task, void *addr, int attr)
+{
+	int error;
+
+	sched_lock();
+	if (attr == 0 || attr & ~(PROT_READ | PROT_WRITE)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (!user_area(addr)) {
+		sched_unlock();
+		return EFAULT;
+	}
+
+	error = do_attribute(task->map, addr, attr);
+
+	sched_unlock();
+	return error;
+}
+
+static int
+do_attribute(vm_map_t map, void *addr, int attr)
+{
+	struct seg *seg;
+	int new_flags, map_type;
+	paddr_t old_pa, new_pa;
+	vaddr_t va;
+
+	va = trunc_page((vaddr_t)addr);
+
+	/*
+	 * Find the target segment.
+	 */
+	seg = seg_lookup(&map->head, va, 1);
+	if (seg == NULL || seg->addr != va || (seg->flags & SEG_FREE)) {
+		return EINVAL;	/* not allocated */
+	}
+	/*
+	 * The attribute of the mapped segment can not be changed.
+	 */
+	if (seg->flags & SEG_MAPPED)
+		return EINVAL;
+
+	/*
+	 * Check new and old flag.
+	 */
+	new_flags = 0;
+	if (seg->flags & SEG_WRITE) {
+		if (!(attr & PROT_WRITE))
+			new_flags = SEG_READ;
+	} else {
+		if (attr & PROT_WRITE)
+			new_flags = SEG_READ | SEG_WRITE;
+	}
+	if (new_flags == 0)
+		return 0;	/* same attribute */
+
+	map_type = (new_flags & SEG_WRITE) ? PG_WRITE : PG_READ;
+
+	/*
+	 * If it is shared segment, duplicate it.
+	 */
+	if (seg->flags & SEG_SHARED) {
+
+		old_pa = seg->phys;
+
+		/* Allocate new physical page. */
+		if ((new_pa = page_alloc(seg->size)) == 0)
+			return ENOMEM;
+
+		/* Copy source page */
+		memcpy(ptokv(new_pa), ptokv(old_pa), seg->size);
+
+		/* Map new segment */
+		if (mmu_map(map->pgd, new_pa, seg->addr, seg->size,
+			    map_type)) {
+			page_free(new_pa, seg->size);
+			return ENOMEM;
+		}
+		seg->phys = new_pa;
+
+		/* Unlink from shared list */
+		seg->sh_prev->sh_next = seg->sh_next;
+		seg->sh_next->sh_prev = seg->sh_prev;
+		if (seg->sh_prev == seg->sh_next)
+			seg->sh_prev->flags &= ~SEG_SHARED;
+		seg->sh_next = seg->sh_prev = seg;
+	} else {
+		if (mmu_map(map->pgd, seg->phys, seg->addr, seg->size,
+			    map_type))
+			return ENOMEM;
+	}
+	seg->flags = new_flags;
+	return 0;
+}
+
+/**
+ * vm_map - map another task's memory to current task.
+ *
+ * Note: This routine does not support mapping to the specific address.
+ */
+int
+vm_map(task_t target, void *addr, size_t size, void **alloc)
+{
+	int error;
+
+	sched_lock();
+	if (!task_valid(target)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (target == curtask) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (!task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (!user_area(addr)) {
+		sched_unlock();
+		return EFAULT;
+	}
+
+	error = do_map(target->map, addr, size, alloc);
+
+	sched_unlock();
+	return error;
+}
+
+static int
+do_map(vm_map_t map, void *addr, size_t size, void **alloc)
+{
+	struct seg *seg, *cur, *tgt;
+	vm_map_t curmap;
+	vaddr_t start, end;
+	paddr_t pa;
+	size_t offset;
+	int map_type;
+	void *tmp;
+
+	if (size == 0)
+		return EINVAL;
+	if (map->total + size >= MAXMEM)
+		return ENOMEM;
+
+	/* check fault */
+	tmp = NULL;
+	if (copyout(&tmp, alloc, sizeof(tmp)))
+		return EFAULT;
+
+	start = trunc_page((vaddr_t)addr);
+	end = round_page((vaddr_t)addr + size);
+	size = (size_t)(end - start);
+	offset = (size_t)((vaddr_t)addr - start);
+
+	/*
+	 * Find the segment that includes target address
+	 */
+	seg = seg_lookup(&map->head, start, size);
+	if (seg == NULL || (seg->flags & SEG_FREE))
+		return EINVAL;	/* not allocated */
+	tgt = seg;
+
+	/*
+	 * Find the free segment in current task
+	 */
+	curmap = curtask->map;
+	if ((seg = seg_alloc(&curmap->head, size)) == NULL)
+		return ENOMEM;
+	cur = seg;
+
+	/*
+	 * Try to map into current memory
+	 */
+	if (tgt->flags & SEG_WRITE)
+		map_type = PG_WRITE;
+	else
+		map_type = PG_READ;
+
+	pa = tgt->phys + (paddr_t)(start - tgt->addr);
+	if (mmu_map(curmap->pgd, pa, cur->addr, size, map_type)) {
+		seg_free(&curmap->head, seg);
+		return ENOMEM;
+	}
+
+	cur->flags = tgt->flags | SEG_MAPPED;
+	cur->phys = pa;
+
+	tmp = (void *)(cur->addr + offset);
+	copyout(&tmp, alloc, sizeof(tmp));
+
+	curmap->total += size;
+	return 0;
+}
+
+/*
+ * Create new virtual memory space.
+ * No memory is inherited.
+ *
+ * Must be called with scheduler locked.
+ */
+vm_map_t
+vm_create(void)
+{
+	struct vm_map *map;
+
+	/* Allocate new map structure */
+	if ((map = kmem_alloc(sizeof(*map))) == NULL)
+		return NULL;
+
+	map->refcnt = 1;
+	map->total = 0;
+
+	/* Allocate new page directory */
+	if ((map->pgd = mmu_newmap()) == NO_PGD) {
+		kmem_free(map);
+		return NULL;
+	}
+	seg_init(&map->head);
+	return map;
+}
+
+/*
+ * Terminate specified virtual memory space.
+ * This is called when task is terminated.
+ */
+void
+vm_terminate(vm_map_t map)
+{
+	struct seg *seg, *tmp;
+
+	if (--map->refcnt > 0)
+		return;
+
+	sched_lock();
+	seg = &map->head;
+	do {
+		if (seg->flags != SEG_FREE) {
+			/* Unmap segment */
+			mmu_map(map->pgd, seg->phys, seg->addr,
+				seg->size, PG_UNMAP);
+
+			/* Free segment if it is not shared and mapped */
+			if (!(seg->flags & SEG_SHARED) &&
+			    !(seg->flags & SEG_MAPPED)) {
+				page_free(seg->phys, seg->size);
+			}
+		}
+		tmp = seg;
+		seg = seg->next;
+		seg_delete(&map->head, tmp);
+	} while (seg != &map->head);
+
+	if (map == curtask->map) {
+		/*
+		 * Switch to the kernel page directory before
+		 * deleting current page directory.
+		 */
+		mmu_switch(kernel_map.pgd);
+	}
+
+	mmu_terminate(map->pgd);
+	kmem_free(map);
+	sched_unlock();
+}
+
+/*
+ * Duplicate specified virtual memory space.
+ * This is called when new task is created.
+ *
+ * Returns new map id, NULL if it fails.
+ *
+ * All segments of original memory map are copied to new memory map.
+ * If the segment is read-only, executable, or shared segment, it is
+ * no need to copy. These segments are physically shared with the
+ * original map.
+ */
+vm_map_t
+vm_dup(vm_map_t org_map)
+{
+	vm_map_t new_map;
+
+	sched_lock();
+	new_map = do_dup(org_map);
+	sched_unlock();
+	return new_map;
+}
+
+static vm_map_t
+do_dup(vm_map_t org_map)
+{
+	vm_map_t new_map;
+	struct seg *tmp, *src, *dest;
+	int map_type;
+
+	if ((new_map = vm_create()) == NULL)
+		return NULL;
+
+	new_map->total = org_map->total;
+	/*
+	 * Copy all segments
+	 */
+	tmp = &new_map->head;
+	src = &org_map->head;
+
+	/*
+	 * Copy top segment
+	 */
+	*tmp = *src;
+	tmp->next = tmp->prev = tmp;
+
+	if (src == src->next)	/* Blank memory ? */
+		return new_map;
+
+	do {
+		ASSERT(src != NULL);
+		ASSERT(src->next != NULL);
+
+		if (src == &org_map->head) {
+			dest = tmp;
+		} else {
+			/* Create new segment struct */
+			dest = kmem_alloc(sizeof(*dest));
+			if (dest == NULL)
+				return NULL;
+
+			*dest = *src;	/* memcpy */
+
+			dest->prev = tmp;
+			dest->next = tmp->next;
+			tmp->next->prev = dest;
+			tmp->next = dest;
+			tmp = dest;
+		}
+		if (src->flags == SEG_FREE) {
+			/*
+			 * Skip free segment
+			 */
+		} else {
+			/* Check if the segment can be shared */
+			if (!(src->flags & SEG_WRITE) &&
+			    !(src->flags & SEG_MAPPED)) {
+				dest->flags |= SEG_SHARED;
+			}
+
+			if (!(dest->flags & SEG_SHARED)) {
+				/* Allocate new physical page. */
+				dest->phys = page_alloc(src->size);
+				if (dest->phys == 0)
+					return NULL;
+
+				/* Copy source page */
+				memcpy(ptokv(dest->phys), ptokv(src->phys),
+				       src->size);
+			}
+			/* Map the segment to virtual address */
+			if (dest->flags & SEG_WRITE)
+				map_type = PG_WRITE;
+			else
+				map_type = PG_READ;
+
+			if (mmu_map(new_map->pgd, dest->phys, dest->addr,
+				    dest->size, map_type))
+				return NULL;
+		}
+		src = src->next;
+	} while (src != &org_map->head);
+
+	/*
+	 * No error. Now, link all shared segments
+	 */
+	dest = &new_map->head;
+	src = &org_map->head;
+	do {
+		if (dest->flags & SEG_SHARED) {
+			src->flags |= SEG_SHARED;
+			dest->sh_prev = src;
+			dest->sh_next = src->sh_next;
+			src->sh_next->sh_prev = dest;
+			src->sh_next = dest;
+		}
+		dest = dest->next;
+		src = src->next;
+	} while (src != &org_map->head);
+	return new_map;
+}
+
+/*
+ * Switch VM mapping.
+ *
+ * Since a kernel task does not have user mode memory image, we
+ * don't have to setup the page directory for it. Thus, an idle
+ * thread and interrupt threads can be switched quickly.
+ */
+void
+vm_switch(vm_map_t map)
+{
+
+	if (map != &kernel_map)
+		mmu_switch(map->pgd);
+}
+
+/*
+ * Increment reference count of VM mapping.
+ */
+int
+vm_reference(vm_map_t map)
+{
+
+	map->refcnt++;
+	return 0;
+}
+
+/*
+ * Load task image for boot task.
+ * Return 0 on success, or errno on failure.
+ */
+int
+vm_load(vm_map_t map, struct module *mod, void **stack)
+{
+	char *src;
+	void *text, *data;
+	int error;
+
+	DPRINTF(("Loading task: %s\n", mod->name));
+
+	/*
+	 * We have to switch VM mapping to touch the virtual
+	 * memory space of a target task without page fault.
+	 */
+	vm_switch(map);
+
+	src = ptokv(mod->phys);
+	text = (void *)mod->text;
+	data = (void *)mod->data;
+
+	/*
+	 * Create text segment
+	 */
+	error = do_allocate(map, &text, mod->textsz, 0);
+	if (error)
+		return error;
+	memcpy(text, src, mod->textsz);
+	error = do_attribute(map, text, PROT_READ);
+	if (error)
+		return error;
+
+	/*
+	 * Create data & BSS segment
+	 */
+	if (mod->datasz + mod->bsssz != 0) {
+		error = do_allocate(map, &data, mod->datasz + mod->bsssz, 0);
+		if (error)
+			return error;
+		if (mod->datasz > 0) {
+			src = src + (mod->data - mod->text);
+			memcpy(data, src, mod->datasz);
+		}
+	}
+	/*
+	 * Create stack
+	 */
+	*stack = (void *)USRSTACK;
+	error = do_allocate(map, stack, DFLSTKSZ, 0);
+	if (error)
+		return error;
+
+	/* Free original pages */
+	page_free(mod->phys, mod->size);
+	return 0;
+}
+
+/*
+ * Translate virtual address of current task to physical address.
+ * Returns physical address on success, or NULL if no mapped memory.
+ */
+paddr_t
+vm_translate(vaddr_t addr, size_t size)
+{
+
+	return mmu_extract(curtask->map->pgd, addr, size);
+}
+
+int
+vm_info(struct vminfo *info)
+{
+	u_long target = info->cookie;
+	task_t task = info->task;
+	u_long i;
+	vm_map_t map;
+	struct seg *seg;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	map = task->map;
+	seg = &map->head;
+	i = 0;
+	do {
+		if (i++ == target) {
+			info->cookie = i;
+			info->virt = seg->addr;
+			info->size = seg->size;
+			info->flags = seg->flags;
+			info->phys = seg->phys;
+			sched_unlock();
+			return 0;
+		}
+		seg = seg->next;
+	} while (seg != &map->head);
+	sched_unlock();
+	return ESRCH;
+}
+
+void
+vm_init(void)
+{
+	pgd_t pgd;
+
+	/*
+	 * Setup vm mapping for kernel task.
+	 */
+	if ((pgd = mmu_newmap()) == NO_PGD)
+		panic("vm_init");
+	kernel_map.pgd = pgd;
+	mmu_switch(pgd);
+
+	seg_init(&kernel_map.head);
+	kernel_task.map = &kernel_map;
+}
+
+
+/*
+ * Initialize segment.
+ */
+static void
+seg_init(struct seg *seg)
+{
+
+	seg->next = seg->prev = seg;
+	seg->sh_next = seg->sh_prev = seg;
+	seg->addr = PAGE_SIZE;
+	seg->phys = 0;
+	seg->size = USERLIMIT - PAGE_SIZE;
+	seg->flags = SEG_FREE;
+}
+
+/*
+ * Create new free segment after the specified segment.
+ * Returns segment on success, or NULL on failure.
+ */
+static struct seg *
+seg_create(struct seg *prev, vaddr_t addr, size_t size)
+{
+	struct seg *seg;
+
+	if ((seg = kmem_alloc(sizeof(*seg))) == NULL)
+		return NULL;
+
+	seg->addr = addr;
+	seg->size = size;
+	seg->phys = 0;
+	seg->flags = SEG_FREE;
+	seg->sh_next = seg->sh_prev = seg;
+
+	seg->next = prev->next;
+	seg->prev = prev;
+	prev->next->prev = seg;
+	prev->next = seg;
+
+	return seg;
+}
+
+/*
+ * Delete specified segment.
+ */
+static void
+seg_delete(struct seg *head, struct seg *seg)
+{
+
+	/*
+	 * If it is shared segment, unlink from shared list.
+	 */
+	if (seg->flags & SEG_SHARED) {
+		seg->sh_prev->sh_next = seg->sh_next;
+		seg->sh_next->sh_prev = seg->sh_prev;
+		if (seg->sh_prev == seg->sh_next)
+			seg->sh_prev->flags &= ~SEG_SHARED;
+	}
+	if (head != seg)
+		kmem_free(seg);
+}
+
+/*
+ * Find the segment at the specified address.
+ */
+static struct seg *
+seg_lookup(struct seg *head, vaddr_t addr, size_t size)
+{
+	struct seg *seg;
+
+	seg = head;
+	do {
+		if (seg->addr <= addr &&
+		    seg->addr + seg->size >= addr + size) {
+			return seg;
+		}
+		seg = seg->next;
+	} while (seg != head);
+	return NULL;
+}
+
+/*
+ * Allocate free segment for specified size.
+ */
+static struct seg *
+seg_alloc(struct seg *head, size_t size)
+{
+	struct seg *seg;
+
+	seg = head;
+	do {
+		if ((seg->flags & SEG_FREE) && seg->size >= size) {
+			if (seg->size != size) {
+				/*
+				 * Split this segment and return its head.
+				 */
+				if (seg_create(seg,
+					       seg->addr + size,
+					       seg->size - size) == NULL)
+					return NULL;
+			}
+			seg->size = size;
+			return seg;
+		}
+		seg = seg->next;
+	} while (seg != head);
+	return NULL;
+}
+
+/*
+ * Delete specified free segment.
+ */
+static void
+seg_free(struct seg *head, struct seg *seg)
+{
+	struct seg *prev, *next;
+
+	ASSERT(seg->flags != SEG_FREE);
+
+	seg->flags = SEG_FREE;
+
+	/*
+	 * If it is shared segment, unlink from shared list.
+	 */
+	if (seg->flags & SEG_SHARED) {
+		seg->sh_prev->sh_next = seg->sh_next;
+		seg->sh_next->sh_prev = seg->sh_prev;
+		if (seg->sh_prev == seg->sh_next)
+			seg->sh_prev->flags &= ~SEG_SHARED;
+	}
+	/*
+	 * If next segment is free, merge with it.
+	 */
+	next = seg->next;
+	if (next != head && (next->flags & SEG_FREE)) {
+		seg->next = next->next;
+		next->next->prev = seg;
+		seg->size += next->size;
+		kmem_free(next);
+	}
+	/*
+	 * If previous segment is free, merge with it.
+	 */
+	prev = seg->prev;
+	if (seg != head && (prev->flags & SEG_FREE)) {
+		prev->next = seg->next;
+		seg->next->prev = prev;
+		prev->size += seg->size;
+		kmem_free(seg);
+	}
+}
+
+/*
+ * Reserve the segment at the specified address/size.
+ */
+static struct seg *
+seg_reserve(struct seg *head, vaddr_t addr, size_t size)
+{
+	struct seg *seg, *prev, *next;
+	size_t diff;
+
+	/*
+	 * Find the block which includes specified block.
+	 */
+	seg = seg_lookup(head, addr, size);
+	if (seg == NULL || !(seg->flags & SEG_FREE))
+		return NULL;
+
+	/*
+	 * Check previous segment to split segment.
+	 */
+	prev = NULL;
+	if (seg->addr != addr) {
+		prev = seg;
+		diff = (size_t)(addr - seg->addr);
+		seg = seg_create(prev, addr, prev->size - diff);
+		if (seg == NULL)
+			return NULL;
+		prev->size = diff;
+	}
+	/*
+	 * Check next segment to split segment.
+	 */
+	if (seg->size != size) {
+		next = seg_create(seg, seg->addr + size, seg->size - size);
+		if (next == NULL) {
+			if (prev) {
+				/* Undo previous seg_create() operation */
+				seg_free(head, seg);
+			}
+			return NULL;
+		}
+		seg->size = size;
+	}
+	seg->flags = 0;
+	return seg;
+}
diff --git a/prex-0.9.0/sys/mem/vm_nommu.c b/prex-0.9.0/sys/mem/vm_nommu.c
new file mode 100755
index 0000000..6ce1c5a
--- /dev/null
+++ b/prex-0.9.0/sys/mem/vm_nommu.c
@@ -0,0 +1,681 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vm_nommu.c - virtual memory alloctor for no MMU systems
+ */
+
+/*
+ * When the platform does not support memory management unit (MMU)
+ * all virtual memories are mapped to the physical memory. So, the
+ * memory space is shared among all tasks and kernel.
+ *
+ * Important: The lists of segments are not sorted by address.
+ */
+
+#include <kernel.h>
+#include <kmem.h>
+#include <thread.h>
+#include <page.h>
+#include <task.h>
+#include <sched.h>
+#include <vm.h>
+
+/* forward declarations */
+static void	   seg_init(struct seg *);
+static struct seg *seg_create(struct seg *, vaddr_t, size_t);
+static void	   seg_delete(struct seg *, struct seg *);
+static struct seg *seg_lookup(struct seg *, vaddr_t, size_t);
+static struct seg *seg_alloc(struct seg *, size_t);
+static void	   seg_free(struct seg *, struct seg *);
+static struct seg *seg_reserve(struct seg *, vaddr_t, size_t);
+static int	   do_allocate(vm_map_t, void **, size_t, int);
+static int	   do_free(vm_map_t, void *);
+static int	   do_attribute(vm_map_t, void *, int);
+static int	   do_map(vm_map_t, void *, size_t, void **);
+
+
+static struct vm_map	kernel_map;	/* vm mapping for kernel */
+
+/**
+ * vm_allocate - allocate zero-filled memory for specified address
+ *
+ * If "anywhere" argument is true, the "addr" argument will be
+ * ignored.  In this case, the address of free space will be
+ * found automatically.
+ *
+ * The allocated area has writable, user-access attribute by
+ * default.  The "addr" and "size" argument will be adjusted
+ * to page boundary.
+ */
+int
+vm_allocate(task_t task, void **addr, size_t size, int anywhere)
+{
+	int error;
+	void *uaddr;
+
+	sched_lock();
+
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (copyin(addr, &uaddr, sizeof(*addr))) {
+		sched_unlock();
+		return EFAULT;
+	}
+	if (anywhere == 0 && !user_area(*addr)) {
+		sched_unlock();
+		return EACCES;
+	}
+
+	error = do_allocate(task->map, &uaddr, size, anywhere);
+	if (!error) {
+		if (copyout(&uaddr, addr, sizeof(uaddr)))
+			error = EFAULT;
+	}
+	sched_unlock();
+	return error;
+}
+
+static int
+do_allocate(vm_map_t map, void **addr, size_t size, int anywhere)
+{
+	struct seg *seg;
+	vaddr_t start, end;
+
+	if (size == 0)
+		return EINVAL;
+	if (map->total + size >= MAXMEM)
+		return ENOMEM;
+
+	/*
+	 * Allocate segment, and reserve pages for it.
+	 */
+	if (anywhere) {
+		size = round_page(size);
+		if ((seg = seg_alloc(&map->head, size)) == NULL)
+			return ENOMEM;
+		start = seg->addr;
+	} else {
+		start = trunc_page((vaddr_t)*addr);
+		end = round_page(start + size);
+		size = (size_t)(end - start);
+
+		if ((seg = seg_reserve(&map->head, start, size)) == NULL)
+			return ENOMEM;
+	}
+	seg->flags = SEG_READ | SEG_WRITE;
+
+	/* Zero fill */
+	memset((void *)start, 0, size);
+	*addr = (void *)seg->addr;
+	map->total += size;
+	return 0;
+}
+
+/*
+ * Deallocate memory segment for specified address.
+ *
+ * The "addr" argument points to a memory segment previously
+ * allocated through a call to vm_allocate() or vm_map(). The
+ * number of bytes freed is the number of bytes of the
+ * allocated segment.  If one of the segment of previous and
+ * next are free, it combines with them, and larger free
+ * segment is created.
+ */
+int
+vm_free(task_t task, void *addr)
+{
+	int error;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (!user_area(addr)) {
+		sched_unlock();
+		return EFAULT;
+	}
+
+	error = do_free(task->map, addr);
+
+	sched_unlock();
+	return error;
+}
+
+static int
+do_free(vm_map_t map, void *addr)
+{
+	struct seg *seg;
+	vaddr_t va;
+
+	va = trunc_page((vaddr_t)addr);
+
+	/*
+	 * Find the target segment.
+	 */
+	seg = seg_lookup(&map->head, va, 1);
+	if (seg == NULL || seg->addr != va || (seg->flags & SEG_FREE))
+		return EINVAL;	/* not allocated */
+
+	/*
+	 * Relinquish use of the page if it is not shared and mapped.
+	 */
+	if (!(seg->flags & SEG_SHARED) && !(seg->flags & SEG_MAPPED))
+		page_free(seg->phys, seg->size);
+
+	map->total -= seg->size;
+	seg_free(&map->head, seg);
+
+	return 0;
+}
+
+/*
+ * Change attribute of specified virtual address.
+ *
+ * The "addr" argument points to a memory segment previously
+ * allocated through a call to vm_allocate(). The attribute
+ * type can be chosen a combination of PROT_READ, PROT_WRITE.
+ * Note: PROT_EXEC is not supported, yet.
+ */
+int
+vm_attribute(task_t task, void *addr, int attr)
+{
+	int error;
+
+	sched_lock();
+	if (attr == 0 || attr & ~(PROT_READ | PROT_WRITE)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (task != curtask && !task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (!user_area(addr)) {
+		sched_unlock();
+		return EFAULT;
+	}
+
+	error = do_attribute(task->map, addr, attr);
+
+	sched_unlock();
+	return error;
+}
+
+static int
+do_attribute(vm_map_t map, void *addr, int attr)
+{
+	struct seg *seg;
+	int new_flags = 0;
+	vaddr_t va;
+
+	va = trunc_page((vaddr_t)addr);
+
+	/*
+	 * Find the target segment.
+	 */
+	seg = seg_lookup(&map->head, va, 1);
+	if (seg == NULL || seg->addr != va || (seg->flags & SEG_FREE)) {
+		return EINVAL;	/* not allocated */
+	}
+	/*
+	 * The attribute of the mapped or shared segment can not be changed.
+	 */
+	if ((seg->flags & SEG_MAPPED) || (seg->flags & SEG_SHARED))
+		return EINVAL;
+
+	/*
+	 * Check new and old flag.
+	 */
+	if (seg->flags & SEG_WRITE) {
+		if (!(attr & PROT_WRITE))
+			new_flags = SEG_READ;
+	} else {
+		if (attr & PROT_WRITE)
+			new_flags = SEG_READ | SEG_WRITE;
+	}
+	if (new_flags == 0)
+		return 0;	/* same attribute */
+	seg->flags = new_flags;
+	return 0;
+}
+
+/**
+ * vm_map - map another task's memory to current task.
+ *
+ * Note: This routine does not support mapping to the specific
+ * address.
+ */
+int
+vm_map(task_t target, void *addr, size_t size, void **alloc)
+{
+	int error;
+
+	sched_lock();
+	if (!task_valid(target)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	if (target == curtask) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (!task_capable(CAP_EXTMEM)) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (!user_area(addr)) {
+		sched_unlock();
+		return EFAULT;
+	}
+
+	error = do_map(target->map, addr, size, alloc);
+
+	sched_unlock();
+	return error;
+}
+
+static int
+do_map(vm_map_t map, void *addr, size_t size, void **alloc)
+{
+	struct seg *seg, *tgt;
+	vm_map_t curmap;
+	vaddr_t start, end;
+	void *tmp;
+
+	if (size == 0)
+		return EINVAL;
+	if (map->total + size >= MAXMEM)
+		return ENOMEM;
+
+	/* check fault */
+	tmp = NULL;
+	if (copyout(&tmp, alloc, sizeof(tmp)))
+		return EFAULT;
+
+	start = trunc_page((vaddr_t)addr);
+	end = round_page((vaddr_t)addr + size);
+	size = (size_t)(end - start);
+
+	/*
+	 * Find the segment that includes target address
+	 */
+	seg = seg_lookup(&map->head, start, size);
+	if (seg == NULL || (seg->flags & SEG_FREE))
+		return EINVAL;	/* not allocated */
+	tgt = seg;
+
+	/*
+	 * Create new segment to map
+	 */
+	curmap = curtask->map;
+	if ((seg = seg_create(&curmap->head, start, size)) == NULL)
+		return ENOMEM;
+	seg->flags = tgt->flags | SEG_MAPPED;
+
+	copyout(&addr, alloc, sizeof(addr));
+
+	curmap->total += size;
+	return 0;
+}
+
+/*
+ * Create new virtual memory space.
+ * No memory is inherited.
+ * Must be called with scheduler locked.
+ */
+vm_map_t
+vm_create(void)
+{
+	struct vm_map *map;
+
+	/* Allocate new map structure */
+	if ((map = kmem_alloc(sizeof(*map))) == NULL)
+		return NULL;
+
+	map->refcnt = 1;
+	map->total = 0;
+
+	seg_init(&map->head);
+	return map;
+}
+
+/*
+ * Terminate specified virtual memory space.
+ * This is called when task is terminated.
+ */
+void
+vm_terminate(vm_map_t map)
+{
+	struct seg *seg, *tmp;
+
+	if (--map->refcnt > 0)
+		return;
+
+	sched_lock();
+	seg = &map->head;
+	do {
+		if (seg->flags != SEG_FREE) {
+			/* Free segment if it is not shared and mapped */
+			if (!(seg->flags & SEG_SHARED) &&
+			    !(seg->flags & SEG_MAPPED)) {
+				page_free(seg->phys, seg->size);
+			}
+		}
+		tmp = seg;
+		seg = seg->next;
+		seg_delete(&map->head, tmp);
+	} while (seg != &map->head);
+
+	kmem_free(map);
+	sched_unlock();
+}
+
+/*
+ * Duplicate specified virtual memory space.
+ */
+vm_map_t
+vm_dup(vm_map_t org_map)
+{
+	/*
+	 * This function is not supported with no MMU system.
+	 */
+	return NULL;
+}
+
+/*
+ * Switch VM mapping.
+ */
+void
+vm_switch(vm_map_t map)
+{
+}
+
+/*
+ * Increment reference count of VM mapping.
+ */
+int
+vm_reference(vm_map_t map)
+{
+
+	map->refcnt++;
+	return 0;
+}
+
+/*
+ * Setup task image for boot task. (NOMMU version)
+ * Return 0 on success, errno on failure.
+ *
+ * Note: We assume that the task images are already copied to
+ * the proper address by a boot loader.
+ */
+int
+vm_load(vm_map_t map, struct module *mod, void **stack)
+{
+	struct seg *seg;
+	vaddr_t base, start, end;
+	size_t size;
+
+	DPRINTF(("Loading task:\'%s\'\n", mod->name));
+
+	/*
+	 * Reserve text & data area
+	 */
+	base = mod->text;
+	size = mod->textsz + mod->datasz + mod->bsssz;
+	if (size == 0)
+		return EINVAL;
+
+	start = trunc_page(base);
+	end = round_page(start + size);
+	size = (size_t)(end - start);
+
+	if ((seg = seg_create(&map->head, start, size)) == NULL)
+		return ENOMEM;
+
+	seg->flags = SEG_READ | SEG_WRITE;
+
+	if (mod->bsssz != 0)
+		memset((void *)(mod->data + mod->datasz), 0, mod->bsssz);
+
+	/*
+	 * Create stack
+	 */
+	return do_allocate(map, stack, DFLSTKSZ, 1);
+}
+
+/*
+ * Translate virtual address of current task to physical address.
+ * Returns physical address on success, or NULL if no mapped memory.
+ */
+paddr_t
+vm_translate(vaddr_t addr, size_t size)
+{
+
+	return (paddr_t)addr;
+}
+
+int
+vm_info(struct vminfo *info)
+{
+	u_long target = info->cookie;
+	task_t task = info->task;
+	u_long i;
+	vm_map_t map;
+	struct seg *seg;
+
+	sched_lock();
+	if (!task_valid(task)) {
+		sched_unlock();
+		return ESRCH;
+	}
+	map = task->map;
+	seg = &map->head;
+	i = 0;
+	do {
+		if (i++ == target) {
+			info->cookie = i;
+			info->virt = seg->addr;
+			info->size = seg->size;
+			info->flags = seg->flags;
+			info->phys = seg->phys;
+			sched_unlock();
+			return 0;
+		}
+		seg = seg->next;
+	} while (seg != &map->head);
+	sched_unlock();
+	return ESRCH;
+}
+
+void
+vm_init(void)
+{
+
+	seg_init(&kernel_map.head);
+	kernel_task.map = &kernel_map;
+}
+
+/*
+ * Initialize segment.
+ */
+static void
+seg_init(struct seg *seg)
+{
+
+	seg->next = seg->prev = seg;
+	seg->sh_next = seg->sh_prev = seg;
+	seg->addr = 0;
+	seg->phys = 0;
+	seg->size = 0;
+	seg->flags = SEG_FREE;
+}
+
+/*
+ * Create new free segment after the specified segment.
+ * Returns segment on success, or NULL on failure.
+ */
+static struct seg *
+seg_create(struct seg *prev, vaddr_t addr, size_t size)
+{
+	struct seg *seg;
+
+	if ((seg = kmem_alloc(sizeof(*seg))) == NULL)
+		return NULL;
+
+	seg->addr = addr;
+	seg->size = size;
+	seg->phys = (paddr_t)addr;
+	seg->flags = SEG_FREE;
+	seg->sh_next = seg->sh_prev = seg;
+
+	seg->next = prev->next;
+	seg->prev = prev;
+	prev->next->prev = seg;
+	prev->next = seg;
+
+	return seg;
+}
+
+/*
+ * Delete specified segment.
+ */
+static void
+seg_delete(struct seg *head, struct seg *seg)
+{
+
+	/*
+	 * If it is shared segment, unlink from shared list.
+	 */
+	if (seg->flags & SEG_SHARED) {
+		seg->sh_prev->sh_next = seg->sh_next;
+		seg->sh_next->sh_prev = seg->sh_prev;
+		if (seg->sh_prev == seg->sh_next)
+			seg->sh_prev->flags &= ~SEG_SHARED;
+	}
+	if (head != seg)
+		kmem_free(seg);
+}
+
+/*
+ * Find the segment at the specified address.
+ */
+static struct seg *
+seg_lookup(struct seg *head, vaddr_t addr, size_t size)
+{
+	struct seg *seg;
+
+	seg = head;
+	do {
+		if (seg->addr <= addr &&
+		    seg->addr + seg->size >= addr + size) {
+			return seg;
+		}
+		seg = seg->next;
+	} while (seg != head);
+	return NULL;
+}
+
+/*
+ * Allocate free segment for specified size.
+ */
+static struct seg *
+seg_alloc(struct seg *head, size_t size)
+{
+	struct seg *seg;
+	paddr_t pa;
+
+	if ((pa = page_alloc(size)) == 0)
+		return NULL;
+
+	if ((seg = seg_create(head, (vaddr_t)pa, size)) == NULL) {
+     		page_free(pa, size);
+		return NULL;
+	}
+	return seg;
+}
+
+/*
+ * Delete specified free segment.
+ */
+static void
+seg_free(struct seg *head, struct seg *seg)
+{
+	ASSERT(seg->flags != SEG_FREE);
+
+	/*
+	 * If it is shared segment, unlink from shared list.
+	 */
+	if (seg->flags & SEG_SHARED) {
+		seg->sh_prev->sh_next = seg->sh_next;
+		seg->sh_next->sh_prev = seg->sh_prev;
+		if (seg->sh_prev == seg->sh_next)
+			seg->sh_prev->flags &= ~SEG_SHARED;
+	}
+	seg->prev->next = seg->next;
+	seg->next->prev = seg->prev;
+
+	kmem_free(seg);
+}
+
+/*
+ * Reserve the segment at the specified address/size.
+ */
+static struct seg *
+seg_reserve(struct seg *head, vaddr_t addr, size_t size)
+{
+	struct seg *seg;
+	paddr_t pa;
+
+	pa = (paddr_t)addr;
+
+	if (page_reserve(pa, size) != 0)
+		return NULL;
+
+	if ((seg = seg_create(head, (vaddr_t)pa, size)) == NULL) {
+     		page_free(pa, size);
+		return NULL;
+	}
+	return seg;
+}
diff --git a/prex-0.9.0/sys/sync/cond.c b/prex-0.9.0/sys/sync/cond.c
new file mode 100755
index 0000000..89efa44
--- /dev/null
+++ b/prex-0.9.0/sys/sync/cond.c
@@ -0,0 +1,245 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cond.c - condition variable object
+ */
+
+#include <kernel.h>
+#include <sched.h>
+#include <event.h>
+#include <kmem.h>
+#include <task.h>
+#include <sync.h>
+
+/* forward declarations */
+static int	cond_valid(cond_t);
+static int	cond_copyin(cond_t *, cond_t *);
+
+/*
+ * Create and initialize a condition variable (CV).
+ *
+ * If an initialized condition variable is reinitialized,
+ * undefined behavior results.
+ */
+int
+cond_init(cond_t *cp)
+{
+	task_t self = curtask;
+	cond_t c;
+
+	if (self->nsyncs >= MAXSYNCS)
+		return EAGAIN;
+
+	if ((c = kmem_alloc(sizeof(struct cond))) == NULL)
+		return ENOMEM;
+
+	event_init(&c->event, "condvar");
+	c->owner = self;
+
+	if (copyout(&c, cp, sizeof(c))) {
+		kmem_free(c);
+		return EFAULT;
+	}
+	sched_lock();
+	list_insert(&self->conds, &c->task_link);
+	self->nsyncs++;
+	sched_unlock();
+	return 0;
+}
+
+static void
+cond_deallocate(cond_t c)
+{
+
+	c->owner->nsyncs--;
+	list_remove(&c->task_link);
+	kmem_free(c);
+}
+
+/*
+ * Tear down a condition variable.
+ *
+ * If there are any blocked thread waiting for the specified
+ * CV, it returns EBUSY.
+ */
+int
+cond_destroy(cond_t *cp)
+{
+	cond_t c;
+
+	sched_lock();
+	if (cond_copyin(cp, &c)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (event_waiting(&c->event)) {
+		sched_unlock();
+		return EBUSY;
+	}
+	cond_deallocate(c);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Clean up for task termination.
+ */
+void
+cond_cleanup(task_t task)
+{
+	cond_t c;
+
+	while (!list_empty(&task->conds)) {
+		c = list_entry(list_first(&task->conds),
+			       struct cond, task_link);
+		cond_deallocate(c);
+	}
+}
+
+/*
+ * Wait on a condition.
+ *
+ * If the thread receives any exception while waiting CV, this
+ * routine returns immediately with EINTR in order to invoke
+ * exception handler. However, an application assumes this call
+ * does NOT return with an error. So, the stub routine in a
+ * system call library must call cond_wait() again if it gets
+ * EINTR as error.
+ */
+int
+cond_wait(cond_t *cp, mutex_t *mp)
+{
+	cond_t c;
+	int error, rc;
+
+	if (copyin(cp, &c, sizeof(cp)))
+		return EINVAL;
+
+	sched_lock();
+	if (c == COND_INITIALIZER) {
+		if ((error = cond_init(cp)) != 0) {
+			sched_unlock();
+			return error;
+		}
+		copyin(cp, &c, sizeof(cp));
+	} else {
+		if (!cond_valid(c)) {
+			sched_unlock();
+			return EINVAL;
+		}
+	}
+        /* unlock mutex */
+	if ((error = mutex_unlock(mp)) != 0) {
+		sched_unlock();
+		return error;
+	}
+
+	/* and block */
+	rc = sched_sleep(&c->event);
+	if (rc == SLP_INTR)
+		error = EINTR;
+	sched_unlock();
+
+        /* grab mutex before returning */
+	if (error == 0)
+		error = mutex_lock(mp);
+
+	return error;
+}
+
+/*
+ * Unblock one thread that is blocked on the specified CV.
+ * The thread which has highest priority will be unblocked.
+ */
+int
+cond_signal(cond_t *cp)
+{
+	cond_t c;
+
+	sched_lock();
+	if (cond_copyin(cp, &c)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	sched_wakeone(&c->event);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Unblock all threads that are blocked on the specified CV.
+ */
+int
+cond_broadcast(cond_t *cp)
+{
+	cond_t c;
+
+	sched_lock();
+	if (cond_copyin(cp, &c)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	sched_wakeup(&c->event);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Check if the specified cv is valid.
+ */
+static int
+cond_valid(cond_t c)
+{
+	cond_t tmp;
+	list_t head, n;
+
+	head = &curtask->conds;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		tmp = list_entry(n, struct cond, task_link);
+		if (tmp == c)
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * cond_copyin - copy a condition variable from user space.
+ * It also checks if the passed CV is valid.
+ */
+static int
+cond_copyin(cond_t *ucp, cond_t *kcp)
+{
+	cond_t c;
+
+	if (copyin(ucp, &c, sizeof(ucp)) || !cond_valid(c))
+		return EINVAL;
+	*kcp = c;
+	return 0;
+}
diff --git a/prex-0.9.0/sys/sync/mutex.c b/prex-0.9.0/sys/sync/mutex.c
new file mode 100755
index 0000000..d3f303f
--- /dev/null
+++ b/prex-0.9.0/sys/sync/mutex.c
@@ -0,0 +1,494 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mutex.c - mutual exclusion service.
+ */
+
+/*
+ * A mutex is used to protect un-sharable resources. A thread can use
+ * mutex_lock() to ensure that global resource is not accessed by
+ * other thread. The mutex is effective only the threads belonging to
+ * the same task.
+ *
+ * Prex will change the thread priority to prevent priority inversion.
+ *
+ * <Priority inheritance>
+ *   The priority is changed at the following conditions.
+ *
+ *   1. When the current thread can not lock the mutex and its
+ *      mutex holder has lower priority than current thread, the
+ *      priority of mutex holder is boosted to same priority with
+ *      current thread.  If this mutex holder is waiting for another
+ *      mutex, such related mutexes are also processed.
+ *
+ *   2. When the current thread unlocks the mutex and its priority
+ *      has already been inherited, the current priority is reset.
+ *      In this time, the current priority is changed to the highest
+ *      priority among the threads waiting for the mutexes locked by
+ *      current thread.
+ *
+ *   3. When the thread priority is changed by user request, the
+ *      inherited thread's priority is changed.
+ *
+ * <Limitation>
+ *
+ *   1. If the priority is changed by user request, the priority
+ *      recomputation is done only when the new priority is higher
+ *      than old priority. The inherited priority is reset to base
+ *      priority when the mutex is unlocked.
+ *
+ *   2. Even if thread is killed with mutex waiting, the related
+ *      priority is not adjusted.
+ */
+
+#include <kernel.h>
+#include <event.h>
+#include <sched.h>
+#include <kmem.h>
+#include <thread.h>
+#include <task.h>
+#include <sync.h>
+
+/* forward declarations */
+static int	mutex_valid(mutex_t);
+static int	mutex_copyin(mutex_t *, mutex_t *);
+static int	prio_inherit(thread_t);
+static void	prio_uninherit(thread_t);
+
+/*
+ * Initialize a mutex.
+ *
+ * If an initialized mutex is reinitialized, undefined
+ * behavior results. Technically, we can not detect such
+ * error condition here because we can not touch the passed
+ * object in kernel.
+ */
+int
+mutex_init(mutex_t *mp)
+{
+	task_t self = curtask;
+	mutex_t m;
+
+	if (self->nsyncs >= MAXSYNCS)
+		return EAGAIN;
+
+	if ((m = kmem_alloc(sizeof(struct mutex))) == NULL)
+		return ENOMEM;
+
+	event_init(&m->event, "mutex");
+	m->owner = self;
+	m->holder = NULL;
+	m->priority = MINPRI;
+
+	if (copyout(&m, mp, sizeof(m))) {
+		kmem_free(m);
+		return EFAULT;
+	}
+
+	sched_lock();
+	list_insert(&self->mutexes, &m->task_link);
+	self->nsyncs++;
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Internal version of mutex_destroy.
+ */
+static void
+mutex_deallocate(mutex_t m)
+{
+
+	m->owner->nsyncs--;
+	list_remove(&m->task_link);
+	kmem_free(m);
+}
+
+/*
+ * Destroy the specified mutex.
+ * The mutex must be unlock state, otherwise it fails with EBUSY.
+ */
+int
+mutex_destroy(mutex_t *mp)
+{
+	mutex_t m;
+
+	sched_lock();
+	if (copyin(mp, &m, sizeof(mp))) {
+		sched_unlock();
+		return EFAULT;
+	}
+	if (!mutex_valid(m)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (m->holder || event_waiting(&m->event)) {
+		sched_unlock();
+		return EBUSY;
+	}
+	mutex_deallocate(m);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Clean up for task termination.
+ */
+void
+mutex_cleanup(task_t task)
+{
+	mutex_t m;
+
+	while (!list_empty(&task->mutexes)) {
+		m = list_entry(list_first(&task->mutexes),
+			       struct mutex, task_link);
+		mutex_deallocate(m);
+	}
+}
+
+/*
+ * Lock a mutex.
+ *
+ * A current thread is blocked if the mutex has already been
+ * locked. If current thread receives any exception while
+ * waiting mutex, this routine returns with EINTR in order to
+ * invoke exception handler. But, POSIX thread assumes this
+ * function does NOT return with EINTR.  So, system call stub
+ * routine in library must call this again if it gets EINTR.
+ */
+int
+mutex_lock(mutex_t *mp)
+{
+	mutex_t m;
+	int error, rc;
+
+	sched_lock();
+	if ((error = mutex_copyin(mp, &m)) != 0) {
+		sched_unlock();
+		return error;
+	}
+
+	if (m->holder == curthread) {
+		/*
+		 * Recursive lock
+		 */
+		m->locks++;
+		ASSERT(m->locks != 0);
+	} else {
+		/*
+		 * Check whether a target mutex is locked.
+		 * If the mutex is not locked, this routine
+		 * returns immediately.
+		 */
+		if (m->holder == NULL)
+			m->priority = curthread->priority;
+		else {
+			/*
+			 * Wait for a mutex.
+			 */
+			curthread->mutex_waiting = m;
+			if ((error = prio_inherit(curthread)) != 0) {
+				curthread->mutex_waiting = NULL;
+				sched_unlock();
+				return error;
+			}
+			rc = sched_sleep(&m->event);
+			curthread->mutex_waiting = NULL;
+			if (rc == SLP_INTR) {
+				sched_unlock();
+				return EINTR;
+			}
+		}
+		m->locks = 1;
+		m->holder = curthread;
+		list_insert(&curthread->mutexes, &m->link);
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Try to lock a mutex without blocking.
+ */
+int
+mutex_trylock(mutex_t *mp)
+{
+	mutex_t m;
+	int error;
+
+	sched_lock();
+	if ((error = mutex_copyin(mp, &m)) != 0) {
+		sched_unlock();
+		return error;
+	}
+
+	if (m->holder == curthread) {
+		m->locks++;
+		ASSERT(m->locks != 0);
+	} else {
+		if (m->holder != NULL)
+			error = EBUSY;
+		else {
+			m->locks = 1;
+			m->holder = curthread;
+			list_insert(&curthread->mutexes, &m->link);
+		}
+	}
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Unlock a mutex.
+ * Caller must be a current mutex holder.
+ */
+int
+mutex_unlock(mutex_t *mp)
+{
+	mutex_t m;
+	int error;
+
+	sched_lock();
+	if ((error = mutex_copyin(mp, &m)) != 0) {
+		sched_unlock();
+		return error;
+	}
+
+	if (m->holder != curthread || m->locks <= 0) {
+		sched_unlock();
+		return EPERM;
+	}
+	if (--m->locks == 0) {
+		list_remove(&m->link);
+		prio_uninherit(curthread);
+		/*
+		 * Change the mutex holder, and make the next
+		 * holder runnable if it exists.
+		 */
+		m->holder = sched_wakeone(&m->event);
+		if (m->holder)
+			m->holder->mutex_waiting = NULL;
+
+		m->priority = m->holder ? m->holder->priority : MINPRI;
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Cancel mutex operations.
+ *
+ * This is called with scheduling locked when thread is
+ * terminated. If a thread is terminated with mutex hold, all
+ * waiting threads keeps waiting forever. So, all mutex locked by
+ * terminated thread must be unlocked. Even if the terminated
+ * thread is waiting some mutex, the inherited priority of other
+ * mutex holder is not adjusted.
+ */
+void
+mutex_cancel(thread_t t)
+{
+	list_t head;
+	mutex_t m;
+	thread_t holder;
+
+	/*
+	 * Purge all mutexes held by the thread.
+	 */
+	head = &t->mutexes;
+	while (!list_empty(head)) {
+		/*
+		 * Release locked mutex.
+		 */
+		m = list_entry(list_first(head), struct mutex, link);
+		m->locks = 0;
+		list_remove(&m->link);
+
+		/*
+		 * Change the mutex holder if other thread
+		 * is waiting for it.
+		 */
+		holder = sched_wakeone(&m->event);
+		if (holder) {
+			holder->mutex_waiting = NULL;
+			m->locks = 1;
+			list_insert(&holder->mutexes, &m->link);
+		}
+		m->holder = holder;
+	}
+}
+
+/*
+ * This is called with scheduling locked before thread priority
+ * is changed.
+ */
+void
+mutex_setpri(thread_t t, int pri)
+{
+
+	if (t->mutex_waiting && pri < t->priority)
+		prio_inherit(t);
+}
+
+/*
+ * Check if the specified mutex is valid.
+ */
+static int
+mutex_valid(mutex_t m)
+{
+	mutex_t tmp;
+	list_t head, n;
+
+	head = &curtask->mutexes;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		tmp = list_entry(n, struct mutex, task_link);
+		if (tmp == m)
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * Copy mutex from user space.
+ * If it is not initialized, create new mutex.
+ */
+static int
+mutex_copyin(mutex_t *ump, mutex_t *kmp)
+{
+	mutex_t m;
+	int error;
+
+	if (copyin(ump, &m, sizeof(ump)))
+		return EFAULT;
+
+	if (m == MUTEX_INITIALIZER) {
+		/*
+		 * Allocate new mutex, and retreive its id
+		 * from the user space.
+		 */
+		if ((error = mutex_init(ump)) != 0)
+			return error;
+		copyin(ump, &m, sizeof(ump));
+	} else {
+		if (!mutex_valid(m))
+			return EINVAL;
+	}
+	*kmp = m;
+	return 0;
+}
+
+/*
+ * Inherit priority.
+ *
+ * To prevent priority inversion, we must ensure the higher
+ * priority thread does not wait other lower priority thread. So,
+ * raise the priority of mutex holder which blocks the "waiter"
+ * thread. If such mutex holder is also waiting for other mutex,
+ * that mutex is also processed. Returns EDEALK if it finds
+ * deadlock condition.
+ */
+static int
+prio_inherit(thread_t waiter)
+{
+	mutex_t m = waiter->mutex_waiting;
+	thread_t holder;
+	int count = 0;
+
+	do {
+		holder = m->holder;
+		/*
+		 * If the holder of relative mutex has already
+		 * been waiting for the "waiter" thread, it
+		 * causes a deadlock.
+		 */
+		if (holder == waiter) {
+			DPRINTF(("Deadlock! mutex=%lx holder=%lx waiter=%lx\n",
+				 (long)m, (long)holder, (long)waiter));
+			return EDEADLK;
+		}
+		/*
+		 * If the priority of the mutex holder is lower
+		 * than "waiter" thread's, we rise the mutex
+		 * holder's priority.
+		 */
+		if (holder->priority > waiter->priority) {
+			sched_setpri(holder, holder->basepri, waiter->priority);
+			m->priority = waiter->priority;
+		}
+		/*
+		 * If the mutex holder is waiting for another
+		 * mutex, that mutex is also processed.
+		 */
+		m = (mutex_t)holder->mutex_waiting;
+
+		/* Fail safe... */
+		ASSERT(count < MAXINHERIT);
+		if (count >= MAXINHERIT)
+			break;
+
+	} while (m != NULL);
+	return 0;
+}
+
+/*
+ * Un-inherit priority
+ *
+ * The priority of specified thread is reset to the base
+ * priority.  If specified thread locks other mutex and higher
+ * priority thread is waiting for it, the priority is kept to
+ * that level.
+ */
+static void
+prio_uninherit(thread_t t)
+{
+	int maxpri;
+	list_t head, n;
+	mutex_t m;
+
+	/* Check if the priority is inherited. */
+	if (t->priority == t->basepri)
+		return;
+
+	maxpri = t->basepri;
+
+	/*
+	 * Find the highest priority thread that is waiting
+	 * for the thread. This is done by checking all mutexes
+	 * that the thread locks.
+	 */
+	head = &t->mutexes;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		m = list_entry(n, struct mutex, link);
+		if (m->priority < maxpri)
+			maxpri = m->priority;
+	}
+
+	sched_setpri(t, t->basepri, maxpri);
+}
diff --git a/prex-0.9.0/sys/sync/sem.c b/prex-0.9.0/sys/sync/sem.c
new file mode 100755
index 0000000..ad06e5e
--- /dev/null
+++ b/prex-0.9.0/sys/sync/sem.c
@@ -0,0 +1,345 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * sem.c - semaphore support
+ */
+
+#include <kernel.h>
+#include <event.h>
+#include <sched.h>
+#include <kmem.h>
+#include <task.h>
+#include <sync.h>
+
+/* forward declarations */
+static int	sem_valid(sem_t);
+static void	sem_release(sem_t);
+static void	sem_reference(sem_t);
+static int	sem_copyin(sem_t *, sem_t *);
+
+static struct sem *sem_list = NULL;	/* list head of semaphore list */
+
+/*
+ * sem_init - initialize a semaphore; required before use.
+ *
+ * sem_init() creates a new semaphore if the specified
+ * semaphore does not exist yet. If the semaphore already
+ * exists, it is re-initialized only if nobody is waiting for
+ * it. The initial semaphore value is set to the requested
+ * value. A semaphore can be shared among different tasks.
+ */
+int
+sem_init(sem_t *sp, u_int value)
+{
+	task_t self = curtask;
+	sem_t s;
+
+	/*
+	 * A couple of quick sanity checks.
+	 */
+	if (self->nsyncs >= MAXSYNCS)
+		return EAGAIN;
+	if (value > MAXSEMVAL)
+		return EINVAL;
+	if (copyin(sp, &s, sizeof(sp)))
+		return EFAULT;
+
+	/*
+	 * An application can call sem_init() to reset the
+	 * value of existing semaphore. So, we have to check
+	 * whether the semaphore is already allocated.
+	 */
+	sched_lock();
+	if (sem_valid(s)) {
+		/*
+		 * Semaphore already exists.
+		 */
+		if (s->owner != self) {
+			sched_unlock();
+			return EINVAL;
+		}
+		if (event_waiting(&s->event)) {
+			sched_unlock();
+			return EBUSY;
+		}
+		s->value = value;
+
+	} else {
+		/*
+		 * Create new semaphore.
+		 */
+		if ((s = kmem_alloc(sizeof(struct sem))) == NULL) {
+			sched_unlock();
+			return ENOSPC;
+		}
+		if (copyout(&s, sp, sizeof(s))) {
+			kmem_free(s);
+			sched_unlock();
+			return EFAULT;
+		}
+		event_init(&s->event, "semaphore");
+		s->owner = self;
+		s->refcnt = 1;
+		s->value = value;
+
+		list_insert(&self->sems, &s->task_link);
+		self->nsyncs++;
+		s->next = sem_list;
+		sem_list = s;
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Destroy a semaphore.
+ * If some thread is waiting for the specified semaphore,
+ * this routine fails with EBUSY.
+ */
+int
+sem_destroy(sem_t *sp)
+{
+	sem_t s;
+
+	sched_lock();
+	if (sem_copyin(sp, &s) || s->owner != curtask) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (event_waiting(&s->event) || s->value == 0) {
+		sched_unlock();
+		return EBUSY;
+	}
+	sem_release(s);
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * sem_wait - lock a semaphore.
+ *
+ * The value of timeout is msec unit. 0 for no timeout.
+ *
+ * sem_wait() locks the semaphore referred by sem only if the
+ * semaphore value is currently positive. The thread will
+ * sleep while the semaphore value is zero. It decrements the
+ * semaphore value in return.
+ *
+ * If waiting thread receives any exception, this routine
+ * returns with EINTR in order to invoke exception
+ * handler. But, an application assumes this call does NOT
+ * return with an error. So, the system call stub routine will
+ * automatically call sem_wait again if it gets EINTR.
+ */
+int
+sem_wait(sem_t *sp, u_long timeout)
+{
+	sem_t s;
+	int rc, error = 0;
+
+	sched_lock();
+	if (sem_copyin(sp, &s)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	sem_reference(s);
+
+	while (s->value == 0) {
+		rc = sched_tsleep(&s->event, timeout);
+		if (rc == SLP_TIMEOUT) {
+			error = ETIMEDOUT;
+			break;
+		}
+		if (rc == SLP_INTR) {
+			error = EINTR;
+			break;
+		}
+		/*
+		 * We have to check the semaphore value again
+		 * because another thread may run and acquire
+		 * the semaphore before us.
+		 */
+	}
+	if (!error)
+		s->value--;
+
+	sem_release(s);
+	sched_unlock();
+	return error;
+}
+
+/*
+ * Try to lock a semaphore.
+ * If the semaphore is already locked, it just returns EAGAIN.
+ */
+int
+sem_trywait(sem_t *sp)
+{
+	sem_t s;
+
+	sched_lock();
+	if (sem_copyin(sp, &s)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (s->value == 0) {
+		sched_unlock();
+		return EAGAIN;
+	}
+	s->value--;
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Unlock a semaphore.
+ *
+ * If the semaphore value becomes non zero, then one of
+ * the threads blocked waiting for the semaphore will be
+ * unblocked.  This is non-blocking operation.
+ */
+int
+sem_post(sem_t *sp)
+{
+	sem_t s;
+
+	sched_lock();
+	if (sem_copyin(sp, &s)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (s->value >= MAXSEMVAL) {
+		sched_unlock();
+		return ERANGE;
+	}
+	s->value++;
+	if (s->value > 0)
+		sched_wakeone(&s->event);
+
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Get the semaphore value.
+ */
+int
+sem_getvalue(sem_t *sp, u_int *value)
+{
+	sem_t s;
+
+	sched_lock();
+	if (sem_copyin(sp, &s)) {
+		sched_unlock();
+		return EINVAL;
+	}
+	if (copyout(&s->value, value, sizeof(s->value))) {
+		sched_unlock();
+		return EFAULT;
+	}
+	sched_unlock();
+	return 0;
+}
+
+/*
+ * Take out a reference on a semaphore.
+ */
+static void
+sem_reference(sem_t s)
+{
+
+	s->refcnt++;
+}
+
+/*
+ * Release a reference on a semaphore.  If this is the last
+ * reference, the semaphore data structure is deallocated.
+ */
+static void
+sem_release(sem_t s)
+{
+	sem_t *sp;
+
+	if (--s->refcnt > 0)
+		return;
+
+	list_remove(&s->task_link);
+	s->owner->nsyncs--;
+
+	for (sp = &sem_list; *sp; sp = &(*sp)->next) {
+		if (*sp == s) {
+			*sp = s->next;
+			break;
+		}
+	}
+	kmem_free(s);
+}
+
+void
+sem_cleanup(task_t task)
+{
+	list_t head, n;
+	sem_t s;
+
+	head = &task->sems;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		s = list_entry(n, struct sem, task_link);
+		sem_release(s);
+	}
+}
+
+static int
+sem_valid(sem_t s)
+{
+	sem_t tmp;
+
+	for (tmp = sem_list; tmp; tmp = tmp->next) {
+		if (tmp == s)
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * sem_copyin - copy a semaphore from user space.
+ *
+ * It also checks whether the passed semaphore is valid.
+ */
+static int
+sem_copyin(sem_t *usp, sem_t *ksp)
+{
+	sem_t s;
+
+	if (copyin(usp, &s, sizeof(usp)) || !sem_valid(s))
+		return EINVAL;
+
+	*ksp = s;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/Makefile b/prex-0.9.0/usr/Makefile
new file mode 100755
index 0000000..d032f5f
--- /dev/null
+++ b/prex-0.9.0/usr/Makefile
@@ -0,0 +1,9 @@
+include $(SRCDIR)/mk/own.mk
+
+SUBDIR:=	lib server bin sbin
+
+ifneq ($(_QUICK_),1)
+SUBDIR+=	sample test
+endif
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/usr/arch/arm/_crt0.S b/prex-0.9.0/usr/arch/arm/_crt0.S
new file mode 100755
index 0000000..0a478f8
--- /dev/null
+++ b/prex-0.9.0/usr/arch/arm/_crt0.S
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * crt0.S - C startup routine
+ */
+
+/**
+ * Stack layout:
+ *      argc            argument counter (integer)
+ *      argv[0]         program name (pointer)
+ *      argv[1...N]     program args (pointers)
+ *      argv[argc-1]    end of args (integer)
+ *      NULL
+ *      env[0...N]      environment variables (pointers)
+ *      NULL
+ */
+
+/*
+ * Entry point called by kernel first
+ */
+	.text
+	.global _start
+_start:
+	ldr	r0, [sp], #4		/* Get argc */
+	mov	r1, sp			/* Get argv */
+	add	r2, r1, r0, lsl #2	/* Get envp */ 
+	mov	fp, #0			/* Clear frame pointer */
+	bl	__prex_main
+
diff --git a/prex-0.9.0/usr/arch/arm/_systrap.S b/prex-0.9.0/usr/arch/arm/_systrap.S
new file mode 100755
index 0000000..c3eac0c
--- /dev/null
+++ b/prex-0.9.0/usr/arch/arm/_systrap.S
@@ -0,0 +1 @@
+/* trap code is described in systrap.h */
diff --git a/prex-0.9.0/usr/arch/arm/elf_reloc.c b/prex-0.9.0/usr/arch/arm/elf_reloc.c
new file mode 100755
index 0000000..02be8d8
--- /dev/null
+++ b/prex-0.9.0/usr/arch/arm/elf_reloc.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <sys/elf.h>
+#include <sys/syslog.h>
+
+int
+relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sect)
+{
+	Elf32_Addr *where, tmp;
+	Elf32_Sword addend;
+
+	where = (Elf32_Addr *)(target_sect + rel->r_offset);
+
+	switch (ELF32_R_TYPE(rel->r_info)) {
+	case R_ARM_NONE:
+		break;
+	case R_ARM_ABS32:
+		*where += (Elf32_Addr)sym_val;
+		/* printf("R_ARM_ABS32: %x -> %x\n", where, *where); */
+		break;
+	case R_ARM_PC24:
+	case R_ARM_PLT32:
+	case R_ARM_CALL:
+	case R_ARM_JUMP24:
+		addend = *where & 0x00ffffff;
+		if (addend & 0x00800000)
+			addend |= 0xff000000;
+		tmp = sym_val - (Elf32_Addr)where + (addend << 2);
+		tmp >>= 2;
+		*where = (*where & 0xff000000) | (tmp & 0x00ffffff);
+		/* printf("R_ARM_PC24: %x -> %x\n", where, *where); */
+		break;
+	default:
+#ifdef DEBUG
+		syslog(LOG_ERR, "relocation fail type=%d\n", ELF32_R_TYPE(rel->r_info));
+#endif
+		return -1;
+	}
+	return 0;
+}
+
+int
+relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sec)
+{
+	/* printf("Invalid relocation type\n"); */
+	return -1;
+}
diff --git a/prex-0.9.0/usr/arch/arm/setjmp.S b/prex-0.9.0/usr/arch/arm/setjmp.S
new file mode 100755
index 0000000..7484371
--- /dev/null
+++ b/prex-0.9.0/usr/arch/arm/setjmp.S
@@ -0,0 +1,140 @@
+/*	$NetBSD: setjmp.S,v 1.5 2003/04/05 23:08:51 bjh21 Exp $	*/
+
+/*
+ * Copyright (c) 1997 Mark Brinicombe
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Mark Brinicombe
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+#include <machine/setjmp.h>
+
+/*
+ * C library -- setjmp, longjmp
+ *
+ *	longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ *	setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is restored.
+ */
+
+ENTRY(setjmp)
+	/* Block all signals and retrieve the old signal mask */
+	stmfd	sp!, {r0, r14}
+	mov	r0, #0x00000000
+
+	bl	PIC_SYM(_C_LABEL(sigblock), PLT)
+	mov	r1, r0
+
+	ldmfd	sp!, {r0, r14}
+
+	/* Store signal mask */
+	str	r1, [r0, #((25-13) * 4)]
+
+	ldr	r1, .Lsetjmp_magic
+	str	r1, [r0], #4
+
+#if 0 /* PREX */
+#ifdef SOFTFLOAT
+	add	r0, r0, #52
+#else
+	/* Store fp registers */
+	sfm	f4, 4, [r0], #48
+	/* Store fpsr */
+	rfs	r1
+	str	r1, [r0], #0x0004
+#endif	/*SOFTFLOAT*/
+#endif
+	/* Store integer registers */
+        stmia	r0, {r4-r14}
+        mov	r0, #0x00000000
+        mov	r15, r14
+
+.Lsetjmp_magic:
+	.word	_JB_MAGIC_SETJMP
+
+
+ENTRY(longjmp)
+	ldr	r2, .Lsetjmp_magic
+	ldr	r3, [r0]
+	teq	r2, r3
+	bne	botch
+
+	/* Fetch signal mask */
+	ldr	r2, [r0, #((25-13) * 4)]
+
+	/* Set signal mask */
+	stmfd	sp!, {r0, r1, r14}
+	sub	sp, sp, #4	/* align the stack */
+
+	mov	r0, r2
+	bl	PIC_SYM(_C_LABEL(sigsetmask), PLT)
+
+	add	sp, sp, #4	/* unalign the stack */
+	ldmfd	sp!, {r0, r1, r14}
+
+	add	r0, r0, #4
+#if 0 /* PREX */
+#ifdef SOFTFLOAT
+	add	r0, r0, #52
+#else
+	/* Restore fp registers */
+	lfm	f4, 4, [r0], #48
+	/* Restore FPSR */
+	ldr	r4, [r0], #0x0004
+	wfs	r4
+#endif	/* SOFTFLOAT */
+#endif
+	/* Restore integer registers */
+        ldmia	r0, {r4-r14}
+
+	/* Validate sp and r14 */
+	teq	sp, #0
+	teqne	r14, #0
+	beq	botch
+
+	/* Set return value */
+
+	mov	r0, r1
+	teq	r0, #0x00000000
+	moveq	r0, #0x00000001
+#ifdef __ARM_26__
+	mov	r15, r14
+#else
+	mov	r15, r14
+#endif
+
+	/* validation failed, die die die. */
+botch:
+#if 0 /* PREX */
+	bl	PIC_SYM(_C_LABEL(longjmperror), PLT)
+#endif
+	bl	PIC_SYM(_C_LABEL(abort), PLT)
+	b	. - 8		/* Cannot get here */
diff --git a/prex-0.9.0/usr/arch/arm/user-nommu.ld b/prex-0.9.0/usr/arch/arm/user-nommu.ld
new file mode 100755
index 0000000..af8d6e4
--- /dev/null
+++ b/prex-0.9.0/usr/arch/arm/user-nommu.ld
@@ -0,0 +1,37 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = SIZEOF_HEADERS;
+
+	.text : {
+		*(.text)
+		*(.glue_7)
+		*(.glue_7t)
+	} : text = 0xff
+
+	. = ALIGN(4);
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	} : text
+
+	. = ALIGN(4);
+	.data : {
+		*(.data)
+	} : data
+
+	. = ALIGN(4);
+	.bss .  : {
+		*(.bss)
+		*(COMMON)
+	}
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/usr/arch/arm/user.ld b/prex-0.9.0/usr/arch/arm/user.ld
new file mode 100755
index 0000000..0a52127
--- /dev/null
+++ b/prex-0.9.0/usr/arch/arm/user.ld
@@ -0,0 +1,37 @@
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS
+{
+	. = 0x10000 + SIZEOF_HEADERS;
+
+	.text : {
+		*(.text)
+		*(.glue_7)
+		*(.glue_7t)
+	} : text = 0xff
+
+	. = ALIGN(4);
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	} : text
+
+	. = ALIGN(0x1000);
+	.data : {
+		*(.data)
+	} : data
+
+	. = ALIGN(4);
+	.bss .  : {
+		*(.bss)
+		*(COMMON)
+	}
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/usr/arch/ppc/_crt0.S b/prex-0.9.0/usr/arch/ppc/_crt0.S
new file mode 100755
index 0000000..bd96831
--- /dev/null
+++ b/prex-0.9.0/usr/arch/ppc/_crt0.S
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * crt0.S - C startup routine
+ */
+
+/**
+ * Stack layout:
+ *      argc            argument counter (integer)
+ *      argv[0]         program name (pointer)
+ *      argv[1...N]     program args (pointers)
+ *      argv[argc-1]    end of args (integer)
+ *      NULL
+ *      env[0...N]      environment variables (pointers)
+ *      NULL
+ */
+
+/*
+ * Entry point called by kernel first
+ */
+	.text
+	.global _start
+_start:
+	lwz	r3, 0(r1)
+	addi	r4, r1, 4
+	slwi	r5, r3, 2
+	add	r5, r5, r4
+	subi	r1, r1, 8	/* adjust stack to call C function */
+	b	__prex_main
+
diff --git a/prex-0.9.0/usr/arch/ppc/_systrap.S b/prex-0.9.0/usr/arch/ppc/_systrap.S
new file mode 100755
index 0000000..c3eac0c
--- /dev/null
+++ b/prex-0.9.0/usr/arch/ppc/_systrap.S
@@ -0,0 +1 @@
+/* trap code is described in systrap.h */
diff --git a/prex-0.9.0/usr/arch/ppc/elf_reloc.c b/prex-0.9.0/usr/arch/ppc/elf_reloc.c
new file mode 100755
index 0000000..9da7d1b
--- /dev/null
+++ b/prex-0.9.0/usr/arch/ppc/elf_reloc.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <sys/elf.h>
+#include <sys/syslog.h>
+
+int
+relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sect)
+{
+
+	/* printf("Invalid relocation type\n"); */
+	return -1;
+}
+
+int
+relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sect)
+{
+	Elf32_Addr *where;
+	uint32_t val;
+
+	where = (Elf32_Addr *)(target_sect + rela->r_offset);
+	val = sym_val + rela->r_addend;
+
+	switch (ELF32_R_TYPE(rela->r_info)) {
+	case R_PPC_NONE:
+		break;
+	case R_PPC_ADDR32:
+		/* printf("R_PPC_ADDR32\n"); */
+		*(uint32_t *)where = val;
+		break;
+	case R_PPC_ADDR16_LO:
+		/* printf("R_PPC_ADDR16_LO\n"); */
+		*(uint16_t *)where = val;
+		break;
+	case R_PPC_ADDR16_HI:
+		/* printf("R_PPC_ADDR16_HI\n"); */
+		*(uint16_t *)where = (val >> 16);
+		break;
+	case R_PPC_ADDR16_HA:
+		/* printf("R_PPC_ADDR16_HA\n"); */
+		*(uint16_t *)where = (val + 0x8000) >> 16;
+		break;
+	case R_PPC_REL24:
+		/* printf("R_PPC_REL24\n"); */
+		*(uint32_t *)where =
+			(*(uint32_t *)where & ~0x03fffffc)
+			| ((val - (uint32_t)where)
+			   & 0x03fffffc);
+		break;
+	case R_PPC_REL32:
+		/* printf("R_PPC_REL32\n"); */
+		*(uint32_t *)where = val - (uint32_t)where;
+		break;
+	default:
+		/* printf("Unkown relocation type=%d\n",
+			ELF32_R_TYPE(rela->r_info)); */
+#ifdef DEBUG
+		syslog(LOG_ERR, "relocation fail type=%d\n", ELF32_R_TYPE(rela->r_info));
+#endif
+		return -1;
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/arch/ppc/setjmp.S b/prex-0.9.0/usr/arch/ppc/setjmp.S
new file mode 100755
index 0000000..eb28c24
--- /dev/null
+++ b/prex-0.9.0/usr/arch/ppc/setjmp.S
@@ -0,0 +1,34 @@
+/*	$NetBSD: _setjmp.S,v 1.2 2002/07/30 06:07:57 matt Exp $	*/
+
+#include <machine/asm.h>
+#include <machine/setjmp.h>
+
+/*
+ * C library -- setjmp, longjmp
+ *
+ *	longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ *	setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is restored.
+ */
+
+ENTRY(setjmp)
+	mflr	%r11			/* save return address */
+	mfcr	%r12			/* save condition register */
+	mr	%r10,%r1		/* save stack pointer */
+	mr	%r9,%r2			/* save GPR2 (not needed) */
+	stmw	%r9,8(%r3)		/* save r9..r31 */
+	li	%r3,0			/* indicate success */
+	blr				/* return */
+
+ENTRY(longjmp)
+	lmw	%r9,8(%r3)		/* save r9..r31 */
+	mtlr	%r11			/* restore LR */
+	mtcr	%r12			/* restore CR */
+	mr	%r2,%r9			/* restore GPR2 (not needed) */
+	mr	%r1,%r10		/* restore stack */
+	or.	%r3,%r4,%r4		/* get return value */
+	bnelr				/* return if not 0 */
+	li	%r3,1			/* what's the point? */
+	blr				/* return */
diff --git a/prex-0.9.0/usr/arch/ppc/user-nommu.ld b/prex-0.9.0/usr/arch/ppc/user-nommu.ld
new file mode 100755
index 0000000..fad5741
--- /dev/null
+++ b/prex-0.9.0/usr/arch/ppc/user-nommu.ld
@@ -0,0 +1,29 @@
+OUTPUT_FORMAT("elf32-powerpc")
+OUTPUT_ARCH(powerpc)
+ENTRY(_start)
+
+SECTIONS {
+	. = SIZEOF_HEADERS;
+
+	.text . : {
+		*(.text)
+	}
+	. = ALIGN(4);
+	.rodata . : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+	. = ALIGN(4);
+	.data . : {
+		*(.data)
+		*(.sdata)
+		*(.sdata2)
+	}
+	. = ALIGN(4);
+	.bss . : {
+		*(.sbss)
+		*(.bss)
+		*(COMMON)
+	}
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/usr/arch/ppc/user.ld b/prex-0.9.0/usr/arch/ppc/user.ld
new file mode 100755
index 0000000..1c812c9
--- /dev/null
+++ b/prex-0.9.0/usr/arch/ppc/user.ld
@@ -0,0 +1,37 @@
+OUTPUT_FORMAT("elf32-powerpc")
+OUTPUT_ARCH(powerpc)
+ENTRY(_start)
+PHDRS
+{
+	text PT_LOAD FILEHDR PHDRS;
+	data PT_LOAD;
+}
+SECTIONS {
+	. = 0x10000 + SIZEOF_HEADERS;
+
+	.text . : {
+		*(.text)
+	}
+
+	. = ALIGN(4);
+	.rodata . : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+
+	. = ALIGN(0x1000);
+	.data . : {
+		*(.data)
+		*(.sdata)
+		*(.sdata2)
+	}
+
+	. = ALIGN(4);
+	.bss . : {
+		*(.sbss)
+		*(.bss)
+		*(COMMON)
+	}
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/usr/arch/x86/_crt0.S b/prex-0.9.0/usr/arch/x86/_crt0.S
new file mode 100755
index 0000000..c64c038
--- /dev/null
+++ b/prex-0.9.0/usr/arch/x86/_crt0.S
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * crt0.S - C startup routine
+ */
+
+/**
+ * Stack layout:
+ *      argc            argument counter (integer)
+ *      argv[0]         program name (pointer)
+ *      argv[1...N]     program args (pointers)
+ *      argv[argc-1]    end of args (integer)
+ *      NULL
+ *      env[0...N]      environment variables (pointers)
+ *      NULL
+ */
+
+/*
+ * Entry point called by kernel first
+ */
+	.text
+	.global _start
+_start:
+	popl	%ecx			/* Get argc */
+	movl	%esp, %ebx		/* Get argv */
+	movl	%esp, %eax
+	movl	%ecx, %edx
+	leal	(%eax,%edx,4), %eax	/* Get envp */
+
+	xorl	%ebp, %ebp		/* NULL */
+	pushl	%ebp			/* Set return address */
+	pushl	%ebp
+
+	pushl	%eax			/* Set envp */
+	pushl	%ebx			/* Set argv */
+	pushl	%ecx			/* Set argc */
+	call	__prex_main
+
diff --git a/prex-0.9.0/usr/arch/x86/_systrap.S b/prex-0.9.0/usr/arch/x86/_systrap.S
new file mode 100755
index 0000000..102401d
--- /dev/null
+++ b/prex-0.9.0/usr/arch/x86/_systrap.S
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * Assumes eax register holds system call number
+ */
+ENTRY(__systrap)
+	pushl	%esi
+	pushl	%ebx
+	movl	12(%esp), %ebx
+	movl	16(%esp), %ecx
+	movl	20(%esp), %edx
+	movl	24(%esp), %esi
+	int	$0x40
+	popl	%ebx
+	popl	%esi
+	ret
diff --git a/prex-0.9.0/usr/arch/x86/elf_reloc.c b/prex-0.9.0/usr/arch/x86/elf_reloc.c
new file mode 100755
index 0000000..8d0854f
--- /dev/null
+++ b/prex-0.9.0/usr/arch/x86/elf_reloc.c
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/elf.h>
+
+int
+relocate_rel(Elf32_Rel *rel, Elf32_Addr sym_val, char *target_sect)
+{
+	Elf32_Addr *where;
+
+	where = (Elf32_Addr *)(target_sect + rel->r_offset);
+
+	/* printf("R_TYPE=%x\n", ELF32_R_TYPE(rel->r_info)); */
+	switch (ELF32_R_TYPE(rel->r_info)) {
+	case R_386_NONE:
+		break;
+	case R_386_32:
+		*where += (Elf32_Addr)sym_val;
+		/* printf("R_386_32: %x -> %x\n", where, *where); */
+		break;
+	case R_386_PC32:
+		*where += sym_val - (Elf32_Addr)where;
+		/* printf("R_386_PC32: %x -> %x\n", where, *where); */
+		break;
+	default:
+		return -1;
+	}
+	return 0;
+}
+
+int
+relocate_rela(Elf32_Rela *rela, Elf32_Addr sym_val, char *target_sec)
+{
+	return -1;
+}
diff --git a/prex-0.9.0/usr/arch/x86/setjmp.S b/prex-0.9.0/usr/arch/x86/setjmp.S
new file mode 100755
index 0000000..8410204
--- /dev/null
+++ b/prex-0.9.0/usr/arch/x86/setjmp.S
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * C library -- _setjmp, _longjmp
+ *
+ *	longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ *	setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is restored.
+ */
+
+/* #include "DEFS.h" */
+#include <machine/asm.h>
+
+ENTRY(setjmp)
+	pushl	$0
+	call	sigblock
+	popl	%edx
+	movl	4(%esp),%ecx
+	movl	0(%esp),%edx
+	movl	%edx, 0(%ecx)
+	movl	%ebx, 4(%ecx)
+	movl	%esp, 8(%ecx)
+	movl	%ebp,12(%ecx)
+	movl	%esi,16(%ecx)
+	movl	%edi,20(%ecx)
+	movl	%eax,24(%ecx)
+	movl	$0,%eax
+	ret
+
+ENTRY(longjmp)
+	movl	4(%esp),%edx
+	pushl	24(%edx)
+	call	sigsetmask
+	popl	%eax
+	movl	4(%esp),%edx
+	movl	8(%esp),%eax
+	movl	0(%edx),%ecx
+	movl	4(%edx),%ebx
+	movl	8(%edx),%esp
+	movl	12(%edx),%ebp
+	movl	16(%edx),%esi
+	movl	20(%edx),%edi
+	cmpl	$0,%eax
+	jne	1f
+	movl	$1,%eax
+1:	movl	%ecx,0(%esp)
+	ret
diff --git a/prex-0.9.0/usr/arch/x86/user-nommu.ld b/prex-0.9.0/usr/arch/x86/user-nommu.ld
new file mode 100755
index 0000000..bde4039
--- /dev/null
+++ b/prex-0.9.0/usr/arch/x86/user-nommu.ld
@@ -0,0 +1,31 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SECTIONS
+{
+	. = SIZEOF_HEADERS ;
+
+	.text : {
+		*(.text)
+	} = 0x9090
+
+	. = ALIGN(32);
+	.rodata : {
+		*(.rodata*)
+		*(.rodata.*)
+	}
+
+	. = ALIGN(32);
+	.data : {
+		*(.data*)
+	}
+
+	.bss . : {
+		*(.bss*)
+		*(COMMON)
+	}
+
+	/DISCARD/ : {
+		*(.comment .note .eh_frame)
+	}
+}
diff --git a/prex-0.9.0/usr/arch/x86/user.ld b/prex-0.9.0/usr/arch/x86/user.ld
new file mode 100755
index 0000000..4e98ffa
--- /dev/null
+++ b/prex-0.9.0/usr/arch/x86/user.ld
@@ -0,0 +1,30 @@
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SECTIONS
+{
+	. = 0x10000 + SIZEOF_HEADERS ;
+
+	.text : {
+		*(.text)
+	} = 0x9090
+
+	. = ALIGN(32);
+
+	.rodata : {
+		*(.rodata)
+		*(.rodata.*)
+	}
+
+	. = ALIGN (0x1000);
+	.data : {
+		*(.data)
+	}
+
+	.bss . : {
+		*(.bss)
+		*(COMMON)
+	}
+
+	/DISCARD/ : { *(.comment .note) }
+}
diff --git a/prex-0.9.0/usr/bin/Makefile b/prex-0.9.0/usr/bin/Makefile
new file mode 100755
index 0000000..9199a96
--- /dev/null
+++ b/prex-0.9.0/usr/bin/Makefile
@@ -0,0 +1,32 @@
+include $(SRCDIR)/mk/own.mk
+
+include $(CURDIR)/cmdbox/Makefile.inc
+
+include $(CURDIR)/cat/Makefile.inc
+include $(CURDIR)/clear/Makefile.inc
+include $(CURDIR)/cp/Makefile.inc
+include $(CURDIR)/date/Makefile.inc
+include $(CURDIR)/dmesg/Makefile.inc
+include $(CURDIR)/echo/Makefile.inc
+include $(CURDIR)/free/Makefile.inc
+include $(CURDIR)/head/Makefile.inc
+include $(CURDIR)/hostname/Makefile.inc
+include $(CURDIR)/kill/Makefile.inc
+include $(CURDIR)/ls/Makefile.inc
+include $(CURDIR)/mkdir/Makefile.inc
+include $(CURDIR)/more/Makefile.inc
+include $(CURDIR)/mv/Makefile.inc
+include $(CURDIR)/nice/Makefile.inc
+include $(CURDIR)/printenv/Makefile.inc
+include $(CURDIR)/ps/Makefile.inc
+include $(CURDIR)/pwd/Makefile.inc
+include $(CURDIR)/rm/Makefile.inc
+include $(CURDIR)/rmdir/Makefile.inc
+include $(CURDIR)/sh/Makefile.inc
+include $(CURDIR)/sleep/Makefile.inc
+include $(CURDIR)/sync/Makefile.inc
+include $(CURDIR)/test/Makefile.inc
+include $(CURDIR)/touch/Makefile.inc
+include $(CURDIR)/uname/Makefile.inc
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/bin/cat/Makefile.inc b/prex-0.9.0/usr/bin/cat/Makefile.inc
new file mode 100755
index 0000000..cd60ac5
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cat/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_CAT)+=	cat/cat.c
diff --git a/prex-0.9.0/usr/bin/cat/cat.c b/prex-0.9.0/usr/bin/cat/cat.c
new file mode 100755
index 0000000..6c81895
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cat/cat.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Kevin Fall.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* modified by Kohsuke Ohtani for Prex. */
+
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+#include <err.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	cat_main(argc, argv)
+#endif
+
+static void do_cat(int rfd);
+
+static char *stdbuf;
+static char *filename;
+static int rval;
+
+int
+main(int argc, char *argv[])
+{
+	int ch, fd;
+
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case '?':
+		default:
+			fprintf(stderr, "usage: cat [-] [file ...]\n");
+			exit(1);
+			/* NOTREACHED */
+		}
+	argv += optind;
+
+	if ((stdbuf = malloc(BUFSIZ)) == NULL)
+		err(1, NULL);
+
+	fd = fileno(stdin);
+	filename = "stdin";
+	do {
+		if (*argv) {
+			if (!strcmp(*argv, "-"))
+				fd = fileno(stdin);
+			else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
+				warn("%s", *argv);
+				++argv;
+				rval = 1;
+				continue;
+			}
+			filename = *argv++;
+		}
+		do_cat(fd);
+		if (fd != fileno(stdin))
+			(void)close(fd);
+	} while (*argv);
+	free(stdbuf);
+	exit(rval);
+}
+
+static void
+do_cat(int rfd)
+{
+	int nr, nw, off, wfd;
+	struct stat sbuf;
+
+	wfd = fileno(stdout);
+	if (fstat(wfd, &sbuf))
+		err(1, "%s", filename);
+	while ((nr = read(rfd, stdbuf, BUFSIZ)) > 0)
+		for (off = 0; nr; nr -= nw, off += nw)
+			if ((nw = write(wfd, stdbuf + off, (size_t)nr)) < 0)
+				err(1, "stdout");
+	if (nr < 0) {
+		warn("%s @%d", filename, errno);
+		rval = 1;
+	}
+}
diff --git a/prex-0.9.0/usr/bin/clear/Makefile.inc b/prex-0.9.0/usr/bin/clear/Makefile.inc
new file mode 100755
index 0000000..f11f422
--- /dev/null
+++ b/prex-0.9.0/usr/bin/clear/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_CLEAR)+=	clear/clear.c
diff --git a/prex-0.9.0/usr/bin/clear/clear.c b/prex-0.9.0/usr/bin/clear/clear.c
new file mode 100755
index 0000000..0902b9f
--- /dev/null
+++ b/prex-0.9.0/usr/bin/clear/clear.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	clear_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+
+	printf("\33[2J");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/cmdbox/Makefile.inc b/prex-0.9.0/usr/bin/cmdbox/Makefile.inc
new file mode 100755
index 0000000..f9af17d
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cmdbox/Makefile.inc
@@ -0,0 +1,10 @@
+
+PROG:=		cmdbox/cmdbox
+
+DEFS+=		CMDBOX
+
+#MAP:= 		cmdbox.map
+#DISASM:= 	cmdbox.lst
+#SYMBOL:= 	cmdbox.sym
+
+SRCS=		cmdbox/main.c cmdbox/cmd_conf.c
diff --git a/prex-0.9.0/usr/bin/cmdbox/cmd_conf.c b/prex-0.9.0/usr/bin/cmdbox/cmd_conf.c
new file mode 100755
index 0000000..d3efd89
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cmdbox/cmd_conf.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include "cmdbox.h"
+
+extern int help_main(int argc, char *argv[]);
+extern int cat_main(int argc, char *argv[]);
+extern int clear_main(int argc, char *argv[]);
+extern int cp_main(int argc, char *argv[]);
+extern int date_main(int argc, char *argv[]);
+extern int dmesg_main(int argc, char *argv[]);
+extern int echo_main(int argc, char *argv[]);
+extern int free_main(int argc, char *argv[]);
+extern int head_main(int argc, char *argv[]);
+extern int hostname_main(int argc, char *argv[]);
+extern int kill_main(int argc, char *argv[]);
+extern int ls_main(int argc, char *argv[]);
+extern int mkdir_main(int argc, char *argv[]);
+extern int more_main(int argc, char *argv[]);
+extern int mv_main(int argc, char *argv[]);
+extern int nice_main(int argc, char *argv[]);
+extern int printenv_main(int argc, char *argv[]);
+extern int ps_main(int argc, char *argv[]);
+extern int pwd_main(int argc, char *argv[]);
+extern int rm_main(int argc, char *argv[]);
+extern int rmdir_main(int argc, char *argv[]);
+extern int sleep_main(int argc, char *argv[]);
+extern int sync_main(int argc, char *argv[]);
+extern int test_main(int argc, char *argv[]);
+extern int touch_main(int argc, char *argv[]);
+extern int uname_main(int argc, char *argv[]);
+extern int null_main(int argc, char *argv[]);
+
+/*
+ * Bultin commands
+ */
+const struct cmdentry builtin_cmds[] = {
+#ifdef CONFIG_CMD_CAT
+	{ "cat"      ,cat_main        },
+#endif
+#ifdef CONFIG_CMD_CLEAR
+	{ "clear"    ,clear_main      },
+#endif
+#ifdef CONFIG_CMD_CP
+	{ "cp"       ,cp_main         },
+#endif
+#ifdef CONFIG_CMD_DATE
+	{ "date"     ,date_main       },
+#endif
+#ifdef CONFIG_CMD_DMESG
+	{ "dmesg"    ,dmesg_main      },
+#endif
+#ifdef CONFIG_CMD_ECHO
+	{ "echo"     ,echo_main       },
+#endif
+#ifdef CONFIG_CMD_FREE
+	{ "free"     ,free_main       },
+#endif
+#ifdef CONFIG_CMD_HEAD
+	{ "head"     ,head_main   },
+#endif
+	{ "help"     ,help_main       },
+#ifdef CONFIG_CMD_HOSTNAME
+	{ "hostname" ,hostname_main   },
+#endif
+#ifdef CONFIG_CMD_KILL
+	{ "kill"     ,kill_main       },
+#endif
+#ifdef CONFIG_CMD_LS
+	{ "ls"       ,ls_main         },
+#endif
+#ifdef CONFIG_CMD_MKDIR
+	{ "mkdir"    ,mkdir_main      },
+#endif
+#ifdef CONFIG_CMD_MORE
+	{ "more"     ,more_main       },
+#endif
+#ifdef CONFIG_CMD_MV
+	{ "mv"       ,mv_main         },
+#endif
+#ifdef CONFIG_CMD_NICE
+	{ "nice"     ,nice_main       },
+#endif
+#ifdef CONFIG_CMD_PRINTENV
+	{ "printenv" ,printenv_main   },
+#endif
+#ifdef CONFIG_CMD_PS
+	{ "ps"       ,ps_main         },
+#endif
+#ifdef CONFIG_CMD_PWD
+	{ "pwd"      ,pwd_main        },
+#endif
+#ifdef CONFIG_CMD_RM
+	{ "rm"       ,rm_main         },
+#endif
+#ifdef CONFIG_CMD_RMDIR
+	{ "rmdir"    ,rmdir_main      },
+#endif
+#ifdef CONFIG_CMD_SLEEP
+	{ "sleep"    ,sleep_main      },
+#endif
+#ifdef CONFIG_CMD_SYNC
+	{ "sync"     ,sync_main       },
+#endif
+#ifdef CONFIG_CMD_TEST
+	{ "test"     ,test_main       },
+#endif
+#ifdef CONFIG_CMD_TOUCH
+	{ "touch"    ,touch_main      },
+#endif
+#ifdef CONFIG_CMD_UNAME
+	{ "uname"    ,uname_main      },
+#endif
+	{ NULL       ,null_main       },
+};
diff --git a/prex-0.9.0/usr/bin/cmdbox/cmdbox.h b/prex-0.9.0/usr/bin/cmdbox/cmdbox.h
new file mode 100755
index 0000000..031cbf2
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cmdbox/cmdbox.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Command description
+ */
+struct cmdentry {
+	char *cmd;
+	int (*func) (int, char **);
+};
+
+extern const struct cmdentry builtin_cmds[];
+extern const struct cmdentry shell_cmds[];
diff --git a/prex-0.9.0/usr/bin/cmdbox/main.c b/prex-0.9.0/usr/bin/cmdbox/main.c
new file mode 100755
index 0000000..b7b8cbe
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cmdbox/main.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <limits.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <libgen.h>
+#include <termios.h>
+
+#include "cmdbox.h"
+
+#ifdef CONFIG_CMD_SH
+extern int sh_main(int argc, char *argv[]);
+#endif
+
+int
+null_main(int argc, char *argv[])
+{
+	return -1;
+}
+
+int
+help_main(int argc, char *argv[])
+{
+	struct cmdentry const *entry;
+	struct winsize ws;
+	int maxcol, col = 0;
+
+	/* Get screen size */
+	maxcol = 80;
+	if (ioctl(fileno(stderr), TIOCGWINSZ, &ws) == 0)
+		maxcol = (int)ws.ws_col;
+	if (maxcol < 80)
+		maxcol -= 15;
+	else
+		maxcol -= 25;
+
+	fprintf(stderr, "usage: cmdbox [command] [arguments]...\n");
+	fprintf(stderr, "builtin commands:\n");
+
+	/*
+	 * Show help for builtin commands.
+	 */
+	entry = builtin_cmds;
+	while (entry->cmd != NULL) {
+		col += fprintf(stderr, "%s%s", ((col == 0) ? "    " : ", "),
+			       entry->cmd);
+		entry++;
+		if (col > maxcol && entry->cmd != NULL) {
+			fprintf(stderr, ",\n");
+			col = 0;
+		}
+	}
+
+#ifdef CONFIG_CMD_SH
+	/*
+	 * Show help for shell commands.
+	 */
+	entry = shell_cmds;
+	while (entry->cmd != NULL) {
+		col += fprintf(stderr, "%s%s", ((col == 0) ? "    " : ", "),
+			       entry->cmd);
+		entry++;
+		if (col > maxcol && entry->cmd != NULL) {
+			fprintf(stderr, ",\n");
+			col = 0;
+		}
+	}
+#endif
+	fprintf(stderr, "\nuse `-?` to find out more about each command.\n");
+	return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+	char *prog, *cmd;
+	struct cmdentry const *entry;
+	int shcmd = 0;
+
+	prog = basename(argv[0]);
+	cmd = prog;
+
+	/*
+	 * Alias:
+	 * 'sh'            => sh
+	 * 'cmdbox'        => sh
+	 * 'cmdbox sh'     => sh
+	 * 'cmdbox cmd'    => cmd
+	 * 'cmd' (symlink) => cmd
+	 */
+	if (!strcmp(prog, "sh"))
+		shcmd = 1;
+	else if (!strcmp(prog, "cmdbox")) {
+		if (argc == 1)
+			shcmd = 1;
+		else {
+			if (!strcmp(argv[1], "sh"))
+				shcmd = 1;
+			else
+				cmd = argv[1];
+			argv++;
+			argc--;
+		}
+	}
+
+	if (shcmd) {
+		task_setname(task_self(), "sh");
+		exit(sh_main(argc, argv));
+	}
+
+	entry = builtin_cmds;
+	while (entry->cmd != NULL) {
+		if (!strcmp(cmd, entry->cmd)) {
+			task_setname(task_self(), cmd);
+			exit(entry->func(argc, argv));
+		}
+		entry++;
+	}
+	fprintf(stderr, "No such command: %s\n", cmd);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/cp/Makefile.inc b/prex-0.9.0/usr/bin/cp/Makefile.inc
new file mode 100755
index 0000000..83d8ea7
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cp/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_CP)+=		cp/cp.c
diff --git a/prex-0.9.0/usr/bin/cp/cp.c b/prex-0.9.0/usr/bin/cp/cp.c
new file mode 100755
index 0000000..cfaccd9
--- /dev/null
+++ b/prex-0.9.0/usr/bin/cp/cp.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * David Hitz of Auspex Systems Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* modified by Kohsuke Ohtani for Prex. */
+
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+#include <unistd.h>
+#include <err.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	cp_main(argc, argv)
+#endif
+
+static void usage(void);
+static int copy(char *from, char *to, int dirflag);
+
+
+static char *iobuf;
+
+int
+main(int argc, char *argv[])
+{
+	int r, ch, checkch, i, iflag = 0;
+	char *target;
+	struct stat to_stat, tmp_stat;
+
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc < 2)
+		usage();
+
+	if ((iobuf = malloc(BUFSIZ)) == NULL)
+		err(1, NULL);
+
+	target = argv[--argc];
+
+	r = stat(target, &to_stat);
+	if (r == -1 && errno != ENOENT)
+		err(1, "%s", target);
+	if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
+		/*
+		 * File to file
+		 */
+		if (argc > 1)
+			usage();
+
+		if (stat(argv[0], &tmp_stat) == -1) {
+			warn("%s", argv[0]);
+			exit(1);
+		}
+		if (!S_ISREG(tmp_stat.st_mode))
+			usage();
+
+		/* interactive mode */
+		if (r != -1 && iflag) {
+			(void)fprintf(stderr, "overwrite %s? ", target);
+			checkch = ch = getchar();
+			while (ch != '\n' && ch != EOF)
+				ch = getchar();
+			if (checkch != 'y')
+				exit(0);
+		}
+		r = copy(argv[0], target, 0);
+	} else {
+		/*
+		 * File(s) to directory
+		 */
+		r = 0;
+		for (i = 0; i < argc; i++)
+			r = copy(argv[i], target, 1);
+	}
+	free(iobuf);
+	exit(r);
+}
+
+static void
+usage(void)
+{
+	fprintf(stderr, "usage: cp src target\n"
+		"       cp src1 ... srcN directory\n");
+	exit(1);
+	/* NOTREACHED */
+}
+
+static int
+copy(char *from, char *to, int dirflag)
+{
+	char path[PATH_MAX];
+	int fold, fnew, n;
+	struct stat stbuf;
+	mode_t mode;
+	char *p;
+
+	if (dirflag) {
+		p = strrchr(from, '/');
+		p = p ? p + 1 : from;
+		strlcpy(path, to, sizeof(path));
+		if (strcmp(to, "/"))
+			strlcat(path, "/", sizeof(path));
+		strlcat(path, p, sizeof(path));
+		to = path;
+	}
+
+	if ((fold = open(from, O_RDONLY)) == -1) {
+		warn("%s", from);
+		return 1;
+	}
+	fstat(fold, &stbuf);
+	mode = stbuf.st_mode;
+
+	if ((fnew = creat(to, mode)) == -1) {
+		warn("%s", to);
+		close(fold);
+		return 1;
+	}
+	while ((n = read(fold, iobuf, BUFSIZ)) > 0) {
+		if (write(fnew, iobuf, (size_t)n) != n) {
+			warn("%s", to);
+			close(fold);
+			close(fnew);
+			return 1;
+		}
+	}
+	close(fold);
+	close(fnew);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/date/Makefile.inc b/prex-0.9.0/usr/bin/date/Makefile.inc
new file mode 100755
index 0000000..472f5ed
--- /dev/null
+++ b/prex-0.9.0/usr/bin/date/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_DATE)+=	date/date.c
diff --git a/prex-0.9.0/usr/bin/date/date.c b/prex-0.9.0/usr/bin/date/date.c
new file mode 100755
index 0000000..a0a5c78
--- /dev/null
+++ b/prex-0.9.0/usr/bin/date/date.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <time.h>
+#include <err.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	date_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+	time_t tval;
+	char buf[201];
+	char format[] = "%a %b %e %H:%M:%S %Y";
+
+	if (time(&tval) == -1) {
+		warn("time");
+		exit(1);
+	}
+	strftime(buf, sizeof(buf), format, localtime(&tval));
+	printf("%s\n", buf);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/dmesg/Makefile.inc b/prex-0.9.0/usr/bin/dmesg/Makefile.inc
new file mode 100755
index 0000000..2e3e0c9
--- /dev/null
+++ b/prex-0.9.0/usr/bin/dmesg/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_DMESG)+=	dmesg/dmesg.c
diff --git a/prex-0.9.0/usr/bin/dmesg/dmesg.c b/prex-0.9.0/usr/bin/dmesg/dmesg.c
new file mode 100755
index 0000000..b3f2d66
--- /dev/null
+++ b/prex-0.9.0/usr/bin/dmesg/dmesg.c
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	dmesg_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+	size_t size;
+	char *buf;
+	int i;
+
+	if (sys_debug(DBGC_LOGSIZE, &size) != 0) {
+		fprintf(stderr, "dmesg: not supported\n");
+		exit(1);
+	}
+	if (size == 0)
+		exit(1);
+	if ((buf = malloc(size)) == NULL)
+		exit(1);
+
+	if (sys_debug(DBGC_GETLOG, buf) != 0) {
+		free(buf);
+		exit(1);
+	}
+	for (i = 0; i < (int)size; i++) {
+		if (*buf == '\0')
+			break;
+		putc(*buf, stdout);
+		buf++;
+	}
+	free(buf);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/echo/Makefile.inc b/prex-0.9.0/usr/bin/echo/Makefile.inc
new file mode 100755
index 0000000..5f65fdb
--- /dev/null
+++ b/prex-0.9.0/usr/bin/echo/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_ECHO)+=	echo/echo.c
diff --git a/prex-0.9.0/usr/bin/echo/echo.c b/prex-0.9.0/usr/bin/echo/echo.c
new file mode 100755
index 0000000..0e9fa3c
--- /dev/null
+++ b/prex-0.9.0/usr/bin/echo/echo.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	echo_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+	int nflag;
+
+	/* This utility may NOT do getopt(3) option parsing. */
+	if (*++argv && !strcmp(*argv, "-n")) {
+		++argv;
+		nflag = 1;
+	}
+	else
+		nflag = 0;
+
+	while (*argv) {
+		(void)printf("%s", *argv);
+		if (*++argv)
+			putchar(' ');
+	}
+	if (!nflag)
+		putchar('\n');
+	exit(0);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/bin/free/Makefile.inc b/prex-0.9.0/usr/bin/free/Makefile.inc
new file mode 100755
index 0000000..032912c
--- /dev/null
+++ b/prex-0.9.0/usr/bin/free/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_FREE)+=	free/free.c
diff --git a/prex-0.9.0/usr/bin/free/free.c b/prex-0.9.0/usr/bin/free/free.c
new file mode 100755
index 0000000..5e45644
--- /dev/null
+++ b/prex-0.9.0/usr/bin/free/free.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	free_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+	struct meminfo info;
+
+	sys_info(INFO_MEMORY, &info);
+
+	printf("          total       used       free   bootdisk\n");
+	printf("Mem: %10d %10d %10d %10d\n", (u_int)info.total,
+	       (u_int)(info.total - info.free), (u_int)info.free,
+	       (u_int)info.bootdisk);
+	exit(0);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/bin/head/Makefile.inc b/prex-0.9.0/usr/bin/head/Makefile.inc
new file mode 100755
index 0000000..a180e64
--- /dev/null
+++ b/prex-0.9.0/usr/bin/head/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_HEAD)+=	head/head.c
diff --git a/prex-0.9.0/usr/bin/head/head.c b/prex-0.9.0/usr/bin/head/head.c
new file mode 100755
index 0000000..6ae80a0
--- /dev/null
+++ b/prex-0.9.0/usr/bin/head/head.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 1980, 1987, 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * head - give the first few lines of a stream or of each of a set of files
+ *
+ * Bill Joy UCB August 24, 1977
+ */
+
+#ifdef CMDBOX
+#define main(argc, argv)	head_main(argc, argv)
+#endif
+
+void head(FILE *, int);
+static void usage(void);
+
+int eval;
+
+int
+main(int argc, char *argv[])
+{
+	int ch;
+	FILE *fp;
+	int first, linecnt;
+	char *ep;
+
+	linecnt = 10;
+	while ((ch = getopt(argc, argv, "n:")) != EOF)
+		switch(ch) {
+		case 'n':
+			linecnt = strtol(optarg, &ep, 10);
+			if (*ep || linecnt <= 0)
+				err(1, "illegal line count -- %s", optarg);
+			break;
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (*argv)
+		for (first = 1; *argv; ++argv) {
+			if ((fp = fopen(*argv, "r")) == NULL) {
+				err(0, "%s: %s", *argv, strerror(errno));
+				continue;
+			}
+			if (argc > 1) {
+				(void)printf("%s==> %s <==\n",
+				    first ? "" : "\n", *argv);
+				first = 0;
+			}
+			head(fp, linecnt);
+			(void)fclose(fp);
+		}
+	else
+		head(stdin, linecnt);
+	exit(eval);
+}
+
+void
+head(FILE *fp, int cnt)
+{
+	int ch;
+
+	while (cnt--)
+		while ((ch = getc(fp)) != EOF) {
+			if (putchar(ch) == EOF)
+				err(1, "stdout: %s", strerror(errno));
+			if (ch == '\n')
+				break;
+		}
+}
+
+static void
+usage()
+{
+	(void)fprintf(stderr, "usage: head [-n lines] [file ...]\n");
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/bin/hostname/Makefile.inc b/prex-0.9.0/usr/bin/hostname/Makefile.inc
new file mode 100755
index 0000000..535b12f
--- /dev/null
+++ b/prex-0.9.0/usr/bin/hostname/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_HOSTNAME)+=	hostname/hostname.c
diff --git a/prex-0.9.0/usr/bin/hostname/hostname.c b/prex-0.9.0/usr/bin/hostname/hostname.c
new file mode 100755
index 0000000..40a9f82
--- /dev/null
+++ b/prex-0.9.0/usr/bin/hostname/hostname.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	hostname_main(argc, argv)
+#endif
+
+/*
+ * TODO: we should get the hostname from net server.
+ */
+
+int
+main(int argc, char *argv[])
+{
+	char hostname[MAXHOSTNAMELEN];
+
+	if (!gethostname(hostname, sizeof(hostname)))
+		printf("%s\n", hostname);
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/bin/kill/Makefile.inc b/prex-0.9.0/usr/bin/kill/Makefile.inc
new file mode 100755
index 0000000..556af10
--- /dev/null
+++ b/prex-0.9.0/usr/bin/kill/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_KILL)+=	kill/kill.c
diff --git a/prex-0.9.0/usr/bin/kill/kill.c b/prex-0.9.0/usr/bin/kill/kill.c
new file mode 100755
index 0000000..601afe2
--- /dev/null
+++ b/prex-0.9.0/usr/bin/kill/kill.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	kill_main(argc, argv)
+#endif
+
+static void nosig(char *);
+static void printsignals(FILE *);
+static int signame_to_signum(char *);
+static void usage(void);
+
+int
+main(int argc, char *argv[])
+{
+	int errors, numsig, pid;
+	char *ep;
+
+	if (argc < 2)
+		usage();
+
+	numsig = SIGTERM;
+
+	argc--;
+	argv++;
+	if (!strcmp(*argv, "-l")) {
+		argc--, argv++;
+		if (argc > 1)
+			usage();
+		if (argc == 1) {
+			if (isdigit((unsigned char)**argv) == 0)
+				usage();
+			numsig = strtol(*argv, &ep, 10);
+			if (!*argv || *ep)
+				errx(1, "illegal signal number: %s", *argv);
+			if (numsig >= 128)
+				numsig -= 128;
+			if (numsig <= 0 || numsig >= NSIG)
+				nosig(*argv);
+			printf("%s\n", sys_signame[numsig]);
+			exit(0);
+		}
+		printsignals(stdout);
+		exit(0);
+	}
+
+	if (!strcmp(*argv, "-s")) {
+		argc--, argv++;
+		if (argc < 1) {
+			warnx("option requires an argument -- s");
+			usage();
+		}
+		if (strcmp(*argv, "0")) {
+			if ((numsig = signame_to_signum(*argv)) < 0)
+				nosig(*argv);
+		} else
+			numsig = 0;
+		argc--, argv++;
+	} else if (**argv == '-') {
+		++*argv;
+		if (isalpha(**argv)) {
+			if ((numsig = signame_to_signum(*argv)) < 0)
+				nosig(*argv);
+		} else if (isdigit(**argv)) {
+			numsig = strtol(*argv, &ep, 10);
+			if (!*argv || *ep)
+				errx(1, "illegal signal number: %s", *argv);
+			if (numsig <= 0 || numsig >= NSIG)
+				nosig(*argv);
+		} else
+			nosig(*argv);
+		argc--, argv++;
+	}
+
+	if (argc == 0)
+		usage();
+
+	for (errors = 0; argc; argc--, argv++) {
+		pid = strtol(*argv, &ep, 10);
+		if (!*argv || *ep) {
+			warnx("illegal process id: %s", *argv);
+			errors = 1;
+		} else if (kill(pid, numsig) == -1) {
+			warn("%s", *argv);
+			errors = 1;
+		}
+	}
+
+	exit(errors);
+}
+
+static int
+signame_to_signum(sig)
+	char *sig;
+{
+	int n;
+
+	if (!strncasecmp(sig, "sig", 3))
+		sig += 3;
+	for (n = 1; n < NSIG; n++) {
+		if (!strcasecmp(sys_signame[n], sig))
+			return n;
+	}
+	return -1;
+}
+
+static void
+nosig(name)
+	char *name;
+{
+
+	warnx("unknown signal %s; valid signals:", name);
+	printsignals(stderr);
+	exit(1);
+	/* NOTREACHED */
+}
+
+static void
+printsignals(fp)
+	FILE *fp;
+{
+	int n;
+	const char *name;
+
+	for (n = 1; n < NSIG; n++) {
+		name = sys_signame[n];
+		if (n == (NSIG / 2) || n == (NSIG - 1))
+			(void)fprintf(fp, "%s\n", name);
+		else
+			(void)fprintf(fp, "%s ", name);
+	}
+}
+
+static void
+usage(void)
+{
+
+	fprintf(stderr, "usage: kill [-s signal_name] pid ...\n"
+		"       kill -l [exit_status]\n"
+		"       kill -signal_name pid ...\n"
+		"       kill -signal_number pid ...\n");
+	exit(1);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/bin/ls/Makefile.inc b/prex-0.9.0/usr/bin/ls/Makefile.inc
new file mode 100755
index 0000000..463f6cf
--- /dev/null
+++ b/prex-0.9.0/usr/bin/ls/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_LS)+=		ls/ls.c
diff --git a/prex-0.9.0/usr/bin/ls/ls.c b/prex-0.9.0/usr/bin/ls/ls.c
new file mode 100755
index 0000000..71a500d
--- /dev/null
+++ b/prex-0.9.0/usr/bin/ls/ls.c
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+
+#include <unistd.h>
+#include <termios.h>
+#include <err.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	ls_main(argc, argv)
+#endif
+
+static void printentry(char *name, struct stat *sp);
+static int do_ls(char *path);
+
+/* Flags */
+#define LSF_DOT		0x01	/* List files begining with . */
+#define LSF_LONG	0x02	/* Long format */
+#define LSF_SINGLE	0x04	/* Single column */
+#define LSF_TYPE	0x08	/* Add /(dir) and @(symlink) with file name */
+#define LSF_ALL		0x10	/* List hidden files */
+
+#define LSF_RECURSIVE	0x20	/* List Subdirectory */
+#define LSF_TIMESORT	0x40	/* Sort by time */
+
+#define DEFAULT_WIDTH	80
+
+static unsigned int ls_flags;
+static int termwidth;
+static int cols;
+
+int
+main(int argc, char *argv[])
+{
+	struct winsize ws;
+	int ch, rc;
+
+	ls_flags = 0;
+
+	while ((ch = getopt(argc, argv, "1ClFaA")) != -1) {
+		switch(ch) {
+		case '1':
+			ls_flags |= LSF_SINGLE;
+			ls_flags &= ~LSF_LONG;
+			break;
+		case 'C':
+			ls_flags &= ~LSF_SINGLE;
+			ls_flags &= ~LSF_LONG;
+			break;
+		case 'l':
+			ls_flags |= LSF_LONG;
+			ls_flags &= ~LSF_SINGLE;
+			break;
+		case 'F':
+			ls_flags |= LSF_TYPE;
+			break;
+		case 'a':
+			ls_flags |= LSF_DOT;
+			/* FALLTHROUGH */
+		case 'A':
+			ls_flags |= LSF_ALL;
+			break;
+		default:
+		case '?':
+			fprintf(stderr, "usage: ls [-1CFAal] [file ...]\n");
+			exit(1);
+		}
+	}
+	argc -= optind;
+	argv += optind;
+
+	if (isatty(STDOUT_FILENO)) {
+		if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == 0 &&
+		    ws.ws_col != 0) {
+			termwidth = ws.ws_col;
+		} else {
+			termwidth = DEFAULT_WIDTH;
+		}
+	}
+
+	if (argc == 0)
+		rc = do_ls(".");
+	else {
+		do {
+			rc = do_ls(*argv);
+			++argv;
+		} while (*argv);
+	}
+	if (rc)
+		err(1, NULL);
+	return 0;
+}
+
+static void
+printtype(u_int mode)
+{
+	char type;
+
+	switch (mode & S_IFMT) {
+	case S_IFIFO:
+		type = 'p';
+		break;
+	case S_IFCHR:
+		type = 'c';
+			break;
+	case S_IFDIR:
+		type = 'd';
+		break;
+	case S_IFBLK:
+		type = 'b';
+		break;
+	case S_IFLNK:
+		type = 'l';
+		break;
+	case S_IFSOCK:
+		type = 's';
+		break;
+	case S_IFREG:
+	default:
+		type = '-';
+		break;
+	}
+	putchar(type);
+}
+
+/* We don't use strmode() to save code. */
+static void
+printmode(u_int mode)
+{
+
+	if (mode & S_IRUSR)
+		putchar('r');
+	else
+		putchar('-');
+	if (mode & S_IWUSR)
+		putchar('w');
+	else
+		putchar('-');
+	if (mode & S_IXUSR)
+		putchar('x');
+	else
+		putchar('-');
+}
+
+static void
+printentry(char *name, struct stat *sp)
+{
+	int color;
+	int dot = 0;
+	int len;
+
+	if (name[0] == '.') {
+		if ((ls_flags & LSF_DOT) == 0)
+			return;
+		dot = 1;
+	}
+
+	/* set color */
+	color = 0;
+	if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
+		color = 35;  /* magenta */
+	else if (S_ISDIR(sp->st_mode))
+		color = 36;  /* cyan */
+	else if (S_ISFIFO(sp->st_mode))
+		color = 34;
+	else if (S_ISLNK(sp->st_mode))
+		color = 33;  /* yellow */
+
+	if (ls_flags & LSF_LONG) {
+		printtype(sp->st_mode);
+		printmode(sp->st_mode);
+
+		printf("------");
+
+		/* print link */
+		printf("  1 ");
+
+		/* print owner */
+		printf("prex   ");
+
+		/* print date/time */
+		printf("%s 12:00 ", __DATE__);
+
+		/* print size */
+		printf("%7d ", (int)sp->st_size);
+	}
+
+	/* print name */
+	printf("\033[%dm", color);
+	printf("%s", name);
+
+	/* print type */
+	if (!dot && (ls_flags & LSF_TYPE)) {
+		printtype(sp->st_mode);
+		if (sp->st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
+			putchar('*');
+	}
+	printf("\033[0m");
+	if (ls_flags & LSF_LONG || ls_flags & LSF_SINGLE) {
+		putchar('\n');
+	} else {
+		len = strlen(name);
+		cols += len;
+		if (cols > termwidth / 2 + 8) {
+			printf("\n");
+			cols = 0;
+		} else {
+			if (len > 8) {
+				putchar(' ');
+				cols++;
+			} else {
+				for (; len <= 9; len++) {
+					putchar(' ');
+					cols++;
+				}
+			}
+		}
+	}
+}
+
+static int
+do_ls(char *path)
+{
+	struct stat st;
+	int nr_file = 0;
+	char buf[PATH_MAX];
+	DIR *dir;
+	struct dirent *entry;
+
+	if (stat(path, &st) == -1)
+		return ENOTDIR;
+
+	if (S_ISDIR(st.st_mode)) {
+
+		dir = opendir(path);
+		if (dir == NULL)
+			return ENOTDIR;
+
+		cols = 0;
+		for (;;) {
+
+			entry = readdir(dir);
+			if (entry == NULL)
+				break;
+
+			buf[0] = 0;
+			strlcpy(buf, path, sizeof(buf));
+			buf[sizeof(buf) - 1] = '\0';
+			if (!strcmp(entry->d_name, "."))
+				;	/* Do nothing */
+			else if (!strcmp(entry->d_name, ".."))
+				;	/* Do nothing */
+			else {
+				strlcat(buf, "/", sizeof(buf));
+				strlcat(buf, entry->d_name, sizeof(buf));
+			}
+			if (stat(buf, &st) == -1 && errno != EACCES)
+				break;
+			printentry(entry->d_name, &st);
+			nr_file++;
+		}
+		closedir(dir);
+		if (ls_flags & LSF_LONG)
+			printf("total %d\n", nr_file);
+		else
+			putchar('\n');
+	} else {
+
+		printentry(path, &st);
+		putchar('\n');
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/mkdir/Makefile.inc b/prex-0.9.0/usr/bin/mkdir/Makefile.inc
new file mode 100755
index 0000000..36bee61
--- /dev/null
+++ b/prex-0.9.0/usr/bin/mkdir/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_MKDIR)+=	mkdir/mkdir.c
diff --git a/prex-0.9.0/usr/bin/mkdir/mkdir.c b/prex-0.9.0/usr/bin/mkdir/mkdir.c
new file mode 100755
index 0000000..7062180
--- /dev/null
+++ b/prex-0.9.0/usr/bin/mkdir/mkdir.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1983, 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/mount.h>
+
+#include <unistd.h>
+#include <err.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	mkdir_main(argc, argv)
+#endif
+
+static int	build(char *);
+static void	usage(void);
+
+int
+main(int argc, char *argv[])
+{
+	int ch, exitval, pflag;
+
+	pflag = 0;
+	while ((ch = getopt(argc, argv, "p")) != EOF)
+		switch(ch) {
+		case 'p':
+			pflag = 1;
+			break;
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argv[0] == NULL)
+		usage();
+
+	for (exitval = 0; *argv != NULL; ++argv) {
+		if (pflag && build(*argv)) {
+			exitval = 1;
+			continue;
+		}
+		if (mkdir(*argv,
+			  (mode_t)(S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+			warn("%s", *argv);
+			exitval = 1;
+		}
+	}
+	exit(exitval);
+	/* NOTREACHED */
+}
+
+static int
+build(path)
+	char *path;
+{
+	struct stat sb;
+	char *p;
+
+	p = path;
+	if (p[0] == '/')		/* Skip leading '/'. */
+		++p;
+	for (;; ++p) {
+		if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
+			break;
+		if (p[0] != '/')
+			continue;
+		*p = '\0';
+		if (stat(path, &sb)) {
+			if (errno != ENOENT ||
+			    mkdir(path, (mode_t)(S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+				warn("%s", path);
+				return 1;
+			}
+		}
+		*p = '/';
+	}
+	return 0;
+}
+
+static void
+usage()
+{
+	(void)fprintf(stderr, "usage: mkdir [-p] directory ...\n");
+	exit (1);
+}
diff --git a/prex-0.9.0/usr/bin/more/Makefile.inc b/prex-0.9.0/usr/bin/more/Makefile.inc
new file mode 100755
index 0000000..fb6a371
--- /dev/null
+++ b/prex-0.9.0/usr/bin/more/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_MORE)+=	more/more.c
diff --git a/prex-0.9.0/usr/bin/more/more.c b/prex-0.9.0/usr/bin/more/more.c
new file mode 100755
index 0000000..3e25ba1
--- /dev/null
+++ b/prex-0.9.0/usr/bin/more/more.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/termios.h>
+#include <sys/ioctl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <err.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	more_main(argc, argv)
+#endif
+
+static void do_more(FILE *, int);
+
+int
+main(int argc, char *argv[])
+{
+	struct winsize ws;
+	int ch;
+	FILE *fp = NULL;
+	int height = 25;
+	int rval = 0;
+
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case '?':
+		default:
+			fprintf(stderr, "usage: more [file ...]\n");
+			exit(1);
+			/* NOTREACHED */
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (ioctl(0, TIOCGWINSZ, &ws) == 0)
+		height = (int)ws.ws_row;
+
+	if (*argv) {
+		for (; *argv; ++argv) {
+			if ((fp = fopen(*argv, "r")) == NULL) {
+				warn("%s", *argv);
+				++argv;
+				rval = 1;
+				continue;
+			}
+			do_more(fp, height);
+			(void)fclose(fp);
+		}
+	} else
+		do_more(stdin, height);
+
+	exit(rval);
+}
+
+static void
+do_more(FILE *fp, int maxlines)
+{
+	int c, len, lines = 0;
+
+	while ((c = getc(fp)) != EOF) {
+		if (c == '\n' && ++lines >= maxlines) {
+			len = printf("\n--More-- ");
+			fflush(stdout);
+			read(2, &c, 1);
+
+			printf("\033[1A"); /* up cursor */
+			putc('\r', stdout);
+			while (--len >= 0)
+				putc(' ', stdout);
+			putc('\r', stdout);
+			len = 0;
+			lines = 0;
+		} else
+			putchar(c);
+	}
+	putchar('\n');
+}
diff --git a/prex-0.9.0/usr/bin/mv/Makefile.inc b/prex-0.9.0/usr/bin/mv/Makefile.inc
new file mode 100755
index 0000000..3a6b22d
--- /dev/null
+++ b/prex-0.9.0/usr/bin/mv/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_MV)+=		mv/mv.c
diff --git a/prex-0.9.0/usr/bin/mv/mv.c b/prex-0.9.0/usr/bin/mv/mv.c
new file mode 100755
index 0000000..36483ab
--- /dev/null
+++ b/prex-0.9.0/usr/bin/mv/mv.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <err.h>
+#include <string.h>
+#include <stdio.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	mv_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+	char path[PATH_MAX];
+	char *src, *dest, *p;
+	struct stat st1, st2;
+	int rc;
+
+	if (argc != 3) {
+		fprintf(stderr, "usage: mv src dest\n");
+		exit(1);
+	}
+	src = argv[1];
+	dest = argv[2];
+
+	/* Check if source exists and it's regular file. */
+	if (stat(src, &st1) < 0)
+		err(1,"mv");
+	if (!S_ISREG(st1.st_mode)) {
+		fprintf(stderr, "mv: invalid file type\n");
+		exit(1);
+	}
+
+	/* Check if target is a directory. */
+	rc = stat(dest, &st2);
+	if (!rc && S_ISDIR(st2.st_mode)) {
+		p = strrchr(src, '/');
+		p = p ? p + 1 : src;
+		strlcpy(path, dest, sizeof(path));
+		if (strcmp(dest, "/"))
+			strlcat(path, "/", sizeof(path));
+		strlcat(path, p, sizeof(path));
+		dest = path;
+	}
+	if (rename(src, dest) < 0)
+		err(1,"rename");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/nice/Makefile.inc b/prex-0.9.0/usr/bin/nice/Makefile.inc
new file mode 100755
index 0000000..0204d8d
--- /dev/null
+++ b/prex-0.9.0/usr/bin/nice/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_NICE)+=	nice/nice.c
diff --git a/prex-0.9.0/usr/bin/nice/nice.c b/prex-0.9.0/usr/bin/nice/nice.c
new file mode 100755
index 0000000..d2da937
--- /dev/null
+++ b/prex-0.9.0/usr/bin/nice/nice.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <err.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	nice_main(argc, argv)
+#endif
+
+#define	DEFNICE	10
+
+static void usage(void);
+
+int
+main(int argc, char *argv[])
+{
+	int niceness = DEFNICE;
+	int c;
+
+        /* handle obsolete -number syntax */
+        if (argc > 1 && argv[1][0] == '-' &&
+	    isdigit((unsigned char)argv[1][1])) {
+		niceness = atoi (argv[1] + 1);
+                argc--; argv++;
+        }
+
+	while ((c = getopt (argc, argv, "n:")) != -1) {
+		switch (c) {
+		case 'n':
+			niceness = atoi (optarg);
+			break;
+
+		case '?':
+		default:
+			usage();
+			break;
+		}
+	}
+	argc -= optind; argv += optind;
+
+	if (argc == 0)
+		usage();
+
+	errno = 0;
+	niceness += getpriority(PRIO_PROCESS, 0);
+	if (errno) {
+		err (1, "getpriority");
+		/* NOTREACHED */
+	}
+	if (setpriority(PRIO_PROCESS, 0, niceness) == -1) {
+		warn ("setpriority");
+	}
+	execvp(argv[0], &argv[1]);
+	err ((errno == ENOENT) ? 127 : 126, "%s", argv[0]);
+	/* NOTREACHED */
+	return 0;
+}
+
+static void
+usage()
+{
+	(void)fprintf(stderr,
+	    "usage: nice [ -n increment ] utility [ argument ...]\n");
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/bin/printenv/Makefile.inc b/prex-0.9.0/usr/bin/printenv/Makefile.inc
new file mode 100755
index 0000000..cb08c39
--- /dev/null
+++ b/prex-0.9.0/usr/bin/printenv/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_PRINTENV)+=	printenv/printenv.c
diff --git a/prex-0.9.0/usr/bin/printenv/printenv.c b/prex-0.9.0/usr/bin/printenv/printenv.c
new file mode 100755
index 0000000..8da06c1
--- /dev/null
+++ b/prex-0.9.0/usr/bin/printenv/printenv.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1987, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern char	**environ;
+
+static void usage(void);
+
+
+#ifdef CMDBOX
+#define main(argc, argv)	printenv_main(argc, argv)
+#endif
+
+/*
+ * printenv
+ *
+ * Bill Joy, UCB
+ * February, 1979
+ */
+int
+main(int argc, char *argv[])
+{
+	char *cp, **ep;
+	size_t len;
+	int ch;
+
+	while ((ch = getopt(argc, argv, "")) != EOF)
+		switch(ch) {
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc == 0) {
+		for (ep = environ; *ep; ep++)
+			(void)printf("%s\n", *ep);
+		exit(0);
+	}
+	len = strlen(*argv);
+	for (ep = environ; *ep; ep++)
+		if (!memcmp(*ep, *argv, len)) {
+			cp = *ep + len;
+			if (!*cp || *cp == '=') {
+				(void)printf("%s\n", *cp ? cp + 1 : cp);
+				exit(0);
+			}
+		}
+	exit(1);
+}
+
+static void
+usage(void)
+{
+	(void)fprintf(stderr, "usage: printenv [name]\n");
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/bin/ps/Makefile.inc b/prex-0.9.0/usr/bin/ps/Makefile.inc
new file mode 100755
index 0000000..c1edd02
--- /dev/null
+++ b/prex-0.9.0/usr/bin/ps/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_PS)+=		ps/ps.c
diff --git a/prex-0.9.0/usr/bin/ps/ps.c b/prex-0.9.0/usr/bin/ps/ps.c
new file mode 100755
index 0000000..7b93e82
--- /dev/null
+++ b/prex-0.9.0/usr/bin/ps/ps.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+x *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+#include <ipc/proc.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	ps_main(argc, argv)
+#endif
+
+#define PSFX	0x01
+#define PSFL	0x02
+
+struct procinfo {
+	pid_t	pid;
+	pid_t	ppid;
+	int	stat;
+};
+
+static object_t procobj;
+
+static int
+pstat(task_t task, struct procinfo *pi)
+{
+	static struct msg m;
+	int rc;
+
+	do {
+		m.hdr.code = PS_PSTAT;
+		m.data[0] = (int)task;
+		rc = msg_send(procobj, &m, sizeof(m));
+	} while (rc == EINTR);
+
+	if (rc || m.hdr.status) {
+		pi->pid = -1;
+		pi->ppid = -1;
+		pi->stat = 1;
+		return -1;
+	}
+
+	pi->pid = m.data[0];
+	pi->ppid = m.data[1];
+	pi->stat = m.data[2];
+	return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+	static const char stat[][2] = { "R", "Z", "S" };
+	static const char pol[][5] = { "FIFO", "RR  " };
+	static struct threadinfo ti;
+	static struct procinfo pi;
+	int ch, rc, ps_flag = 0;
+	pid_t last_pid = -2;
+
+	while ((ch = getopt(argc, argv, "lx")) != -1)
+		switch(ch) {
+		case 'x':
+			ps_flag |= PSFX;
+			break;
+		case 'l':
+			ps_flag |= PSFL;
+			break;
+
+		case '?':
+		default:
+			fprintf(stderr, "usage: ps [-lx]\n");
+			exit(1);
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (object_lookup("!proc", &procobj))
+		exit(1);
+
+	if (ps_flag & PSFL)
+		printf("  PID  PPID PRI STAT POL      TIME WCHAN       CMD\n");
+	else
+		printf("  PID     TIME CMD\n");
+
+	rc = 0;
+	ti.cookie = 0;
+	do {
+		/*
+		 * Get thread info from kernel.
+		 */
+		rc = sys_info(INFO_THREAD, &ti);
+		if (!rc) {
+			/*
+			 * Get process info from server.
+			 */
+			if (pstat(ti.task, &pi) && !(ps_flag & PSFX))
+				continue;
+
+			if (ps_flag & PSFL) {
+				if (pi.pid == -1)
+					printf("    -     -"); /* kernel */
+				else
+					printf("%5d %5d", pi.pid, pi.ppid);
+
+				printf(" %3d %s    %s %8d "
+				       "%-11s %-11s\n",
+				       ti.priority, stat[pi.stat-1],
+				       pol[ti.policy],
+				       ti.time, ti.slpevt, ti.taskname);
+			} else {
+				if (!(ps_flag & PSFX) && (pi.pid == last_pid))
+					continue;
+				if (pi.pid == -1)
+					printf("    -"); /* kernel */
+				else
+					printf("%5d", pi.pid);
+
+				printf(" %8d %-11s\n", ti.time, ti.taskname);
+				last_pid = pi.pid;
+			}
+		}
+	} while (rc == 0);
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/bin/pwd/Makefile.inc b/prex-0.9.0/usr/bin/pwd/Makefile.inc
new file mode 100755
index 0000000..cf80516
--- /dev/null
+++ b/prex-0.9.0/usr/bin/pwd/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_PWD)+=	pwd/pwd.c
diff --git a/prex-0.9.0/usr/bin/pwd/pwd.c b/prex-0.9.0/usr/bin/pwd/pwd.c
new file mode 100755
index 0000000..635a0fa
--- /dev/null
+++ b/prex-0.9.0/usr/bin/pwd/pwd.c
@@ -0,0 +1,57 @@
+/*rr
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	pwd_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+	char cwd[PATH_MAX];
+	char *p;
+
+	if (argc > 1) {
+		fprintf(stderr, "usage: pwd\n");
+		exit(1);
+	}
+	if ((p = getcwd(cwd, PATH_MAX)) == NULL) {
+		err(1, NULL);
+		exit(1);
+	}
+	puts(p);
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/bin/rm/Makefile.inc b/prex-0.9.0/usr/bin/rm/Makefile.inc
new file mode 100755
index 0000000..6a305dd
--- /dev/null
+++ b/prex-0.9.0/usr/bin/rm/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_RM)+=		rm/rm.c
diff --git a/prex-0.9.0/usr/bin/rm/rm.c b/prex-0.9.0/usr/bin/rm/rm.c
new file mode 100755
index 0000000..042d58b
--- /dev/null
+++ b/prex-0.9.0/usr/bin/rm/rm.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	rm_main(argc, argv)
+#endif
+
+static void
+usage(void)
+{
+
+	fprintf(stderr, "usage: rm file...\n");
+	exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+	int ch, rc;
+
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc == 0) {
+		usage();
+		return 0;
+	}
+	rc = 0;
+	do {
+		if ((rc = unlink(*argv)) < 0)
+			break;
+		++argv;
+	} while (*argv);
+
+	if (rc < 0)
+		err(1, "%s", *argv);
+
+	exit(rc);
+}
diff --git a/prex-0.9.0/usr/bin/rmdir/Makefile.inc b/prex-0.9.0/usr/bin/rmdir/Makefile.inc
new file mode 100755
index 0000000..1aeb183
--- /dev/null
+++ b/prex-0.9.0/usr/bin/rmdir/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_RMDIR)+=	rmdir/rmdir.c
diff --git a/prex-0.9.0/usr/bin/rmdir/rmdir.c b/prex-0.9.0/usr/bin/rmdir/rmdir.c
new file mode 100755
index 0000000..6f62e54
--- /dev/null
+++ b/prex-0.9.0/usr/bin/rmdir/rmdir.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	rmdir_main(argc, argv)
+#endif
+
+static void
+usage(void)
+{
+	fprintf(stderr, "usage: rmdir dirname...\n");
+	exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+	int ch, rc;
+
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc == 0)
+		usage();
+
+	rc = 0;
+	do {
+		if ((rc = rmdir(*argv)) < 0)
+			break;
+		++argv;
+	} while (*argv);
+
+	if (rc < 0)
+		err(1, "%s", *argv);
+	exit(rc);
+}
diff --git a/prex-0.9.0/usr/bin/sh/Makefile.inc b/prex-0.9.0/usr/bin/sh/Makefile.inc
new file mode 100755
index 0000000..4b39e30
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sh/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_SH)+=		sh/sh.c sh/cmds.c sh/var.c
diff --git a/prex-0.9.0/usr/bin/sh/cmds.c b/prex-0.9.0/usr/bin/sh/cmds.c
new file mode 100755
index 0000000..d90cfa2
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sh/cmds.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/fcntl.h>
+#include <sys/prex.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <setjmp.h>
+
+#include "sh.h"
+
+extern char **environ;
+
+static int cmd_null(int argc, char *argv[]);
+static int cmd_cd(int argc, char *argv[]);
+static int cmd_mem(int argc, char *argv[]);
+static int cmd_exec(int argc, char *argv[]);
+static int cmd_exit(int argc, char *argv[]);
+
+/*
+ * Internal shell commands
+ */
+const struct cmdentry shell_cmds[] = {
+    { "cd"         ,cmd_cd           },
+    { "exec"       ,cmd_exec         },
+    { "exit"       ,cmd_exit         },
+    { "export"     ,cmd_export       },
+    { "mem"        ,cmd_mem          },
+    { "set"        ,cmd_showvars     },
+    { "unset"      ,cmd_unsetvar     },
+    { NULL         ,cmd_null         },
+};
+
+
+static int
+cmd_null(int argc, char *argv[])
+{
+	return 0;
+}
+
+static int
+cmd_cd(int argc, char *argv[])
+{
+	char *p;
+
+	if (argc > 2) {
+		fprintf(stderr, "usage: cd [dir]\n");
+		return 0;
+	}
+	if (argc == 1) {
+		p = getenv("HOME");
+		if (p == NULL)
+			p = "/";
+	} else
+		p = argv[1];
+
+	if (chdir(p) < 0)
+		return errno;
+	return 0;
+}
+
+static int
+cmd_exec(int argc, char *argv[])
+{
+	char **envp = environ;
+
+	if (argc < 2) {
+		fprintf(stderr, "usage: exec command\n");
+		return 0;
+	}
+
+	close(0);
+	open("/dev/tty", O_RDONLY);
+
+	/*
+	 * Memory size optimization for 'exec sh'.
+	 */
+	if (!strcmp(argv[1], "sh")) {
+		longjmp(jmpbuf, 1);
+		/* NOTREACHED */
+	}
+	return execve(argv[1], &argv[2], envp);
+}
+
+static int
+cmd_mem(int argc, char *argv[])
+{
+	struct meminfo info;
+
+	sys_info(INFO_MEMORY, &info);
+
+	/* UNIX v7 style... */
+	printf("mem = %d\n", (u_int)info.total);
+	return 0;
+}
+
+static int
+cmd_exit(int argc, char *argv[])
+{
+
+	exit(0);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/bin/sh/sh.c b/prex-0.9.0/usr/bin/sh/sh.c
new file mode 100755
index 0000000..a318f76
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sh/sh.c
@@ -0,0 +1,489 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/keycode.h>
+#include <sys/syslog.h>
+#include <sys/wait.h>
+#include <sys/fcntl.h>
+
+#include <limits.h>
+#include <dirent.h>
+#include <termios.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <setjmp.h>
+#include <libgen.h>	/* for basename() */
+
+#include "sh.h"
+
+#define ARGMAX		32
+
+#define	CMD_PIPE	1
+#define	CMD_BACKGND	2
+#define	CMD_BUILTIN	4
+
+extern const struct cmdentry shell_cmds[];
+#ifdef CMDBOX
+extern const struct cmdentry builtin_cmds[];
+#define main(argc, argv)	sh_main(argc, argv)
+#endif
+
+static pid_t	shpid = 0;	/* pid of shell */
+char		retval;		/* return value for shell */
+unsigned	interact;	/* if shell reads from stdin */
+
+jmp_buf	jmpbuf;
+
+static void
+error(const char *msg, ...)
+{
+	va_list ap;
+
+	va_start(ap, msg);
+	if (msg != NULL) {
+		vfprintf(stderr, msg, ap);
+		fprintf(stderr, "\n");
+	}
+	va_end(ap);
+	if (getpid() != shpid)
+		_exit(1);
+
+	if (!interact)
+		_exit(1);
+	retval = 1;
+}
+
+static void
+showsignal(int pid, int s)
+{
+	int signo = WTERMSIG(s);
+
+	signo &= 0x7f;
+	if (signo < NSIG && sys_siglist[signo])
+		error(" %d: %s", pid, sys_siglist[signo]);
+	else
+		error(" %d: Signal %d", pid, signo);
+
+	retval = signo + 0200;
+}
+
+static void
+showprompt(void)
+{
+	static char cwd[PATH_MAX];
+	static char prompt[PATH_MAX+20];
+
+	getcwd(cwd, PATH_MAX);
+	sprintf(prompt, "\033[32m[prex:%s]\033[0m# ", cwd);
+	write(1, prompt, strlen(prompt));
+}
+
+static void
+execute(int argc, char *argv[], int *redir, int flags, cmdfn_t cmdfn)
+{
+	int pid, i;
+	int status;
+	static char **arg;
+	char *file;
+	char spid[20];
+
+	arg = argc > 1 ? &argv[1] : NULL;
+	file = argv[0];
+	pid = vfork();
+	if (pid == -1) {
+		for (i = 0; i < 2; i++)
+			if (redir[i] != -1)
+				close(redir[i]);
+		error("Cannot fork");
+		return;
+	}
+	if (pid == 0) {
+		/* Child only */
+		setpgid(0, 0);
+		tcsetpgrp(2, getpgrp());
+
+		for (i = 0; i < 2; i++) {
+			if (redir[i] != -1) {
+				if (dup2(redir[i], i) == -1)
+					error("Cannot redirect %d", i);
+				close(redir[i]);
+			}
+		}
+		signal(SIGINT, SIG_DFL);
+		signal(SIGQUIT, SIG_DFL);
+		signal(SIGTERM, SIG_DFL);
+
+		if (flags & CMD_BACKGND) {
+			signal(SIGINT, SIG_IGN);
+			signal(SIGQUIT, SIG_IGN);
+			if (redir[0] == -1) {
+				close(0);
+				open("/dev/null", O_RDWR);
+			}
+		}
+		errno = 0;
+		if (cmdfn) {
+			task_setname(task_self(), basename(file));
+			if (cmdfn(argc, argv) != 0)
+				fprintf(stderr, "%s: %s\n", argv[0],
+					strerror(errno));
+		} else {
+			execv(file, arg);
+			/* Try $PATH */
+			if (errno == ENOENT)
+				execvp(file, arg);
+			if (errno == ENOENT || errno == ENOTDIR)
+				error("%s: command not found", argv[0]);
+			else if (errno == EACCES)
+				error("Permission denied");
+			else
+				error("%s cannot execute", argv[0]);
+		}
+		exit(1);
+		/* NOTREACHED */
+	}
+	/* Parent */
+	for (i = 0; i < 2; i++) {
+		if (redir[i] != -1)
+			close(redir[i]);
+	}
+	if (flags & CMD_PIPE)
+		return;
+	if (flags & CMD_BACKGND) {
+		sprintf(spid, "%u\n", pid);
+		write(1, spid, strlen(spid));
+		return;
+	}
+
+	while (wait(&status) != pid);
+	if (status) {
+		if (WIFSIGNALED(status))
+			showsignal(pid, status);
+		else if (WIFEXITED(status))
+			retval = WEXITSTATUS(status);
+	} else
+		retval = 0;
+	return;
+}
+
+static int
+redirect(char **args, int *redir)
+{
+	unsigned int i, io, append = 0;
+	int fd, argc;
+	char *p, *file;
+
+	for (i = 0; args[i] != NULL; i++) {
+		p = args[i];
+		switch (*p) {
+		case '<':
+			io = 0;
+ 			break;
+		case '>':
+			io = 1;
+			if (*(p + 1) == '>') {
+				append = 1;
+				p++;
+			}
+ 			break;
+		default:
+			continue;
+		}
+
+		/* get file name */
+		args[i] = (char *)-1;
+		if (*(p + 1) == '\0') {
+			file = args[++i];
+			args[i] = (char *)-1;
+		} else
+			file = p + 1;
+
+		/* if redirected from pipe, ignore */
+		if (redir[io] == -1) {
+			if (io == 1) {
+				if (append)
+					fd = open(file, O_WRONLY | O_APPEND);
+				else
+					fd = creat(file, 0666);
+			} else
+				fd = open(file, O_RDONLY);
+
+			if (fd == -1) {
+				error("%s: cannot open", file);
+				return -1;
+			}
+			redir[io] = fd;
+		}
+	}
+
+	/* strip redirection info */
+	argc = 0;
+	for (i = 0; args[i]; i++) {
+		if (args[i] != (char *)-1)
+			args[argc++] = args[i];
+	}
+	args[argc] = NULL;
+	return argc;
+}
+
+static cmdfn_t
+findcmd(const struct cmdentry cmds[], char *cmd)
+{
+	int i = 0;
+
+	while (cmds[i].cmd != NULL) {
+		if (!strcmp(cmd, cmds[i].cmd))
+			return cmds[i].func;
+		i++;
+	}
+	return 0;
+}
+
+static void
+parsecmd(char *cmds, int *redir, int flags)
+{
+	static char cmdbox[] = "cmdbox";
+	static char *args[ARGMAX];
+	char *p, *word = NULL;
+	cmdfn_t fn;
+	int i, argc = 0;
+
+	optind = 1;	/* for nommu */
+
+	if (cmds[0] != ' ' && cmds[0] != '\t')
+		word = cmds;
+
+	p = cmds;
+	while (*p) {
+		if (word == NULL) {
+			/* Skip white space. */
+			if (*p != ' ' && *p != '\t')
+				word = p;
+		} else {
+			if (*p == ' ' || *p == '\t') {
+				*p = '\0';
+				args[argc++] = word;
+				word = NULL;
+				if (argc >= ARGMAX - 1) {
+					error("Too many args");
+					return;
+				}
+			}
+		}
+		p++;
+	}
+	if (argc == 0 && word == NULL)
+		return;
+
+	if (word)
+		args[argc++] = word;
+	args[argc] = NULL;
+
+	/* Handle variable */
+	if ((p = strchr(args[0], '=')) != NULL) {
+		*p++ = '\0';
+		if (*p == '\0')
+			unsetvar(args[0]);
+		else
+			setvar(args[0], p);
+		return;
+	}
+
+	fn = findcmd(shell_cmds, args[0]);
+	if (fn) {
+		/* Run as shell internal command */
+		if ((*fn)(argc, args) != 0)
+			error("%s: %s", args[0], strerror(errno));
+		return;
+	}
+	argc = redirect(args, redir);
+	if (argc == -1)
+		return;
+
+	fn = findcmd(builtin_cmds, args[0]);
+
+	/*
+	 * Alias: 'sh' => 'cmdbox sh'
+	 */
+	if (fn == NULL && !strcmp(args[0], "sh")) {
+		for (i = argc; i >= 0; i--)
+			args[i + 1] = args[i];
+		args[0] = cmdbox;
+		argc++;
+	}
+	execute(argc, args, redir, flags, fn);
+}
+
+static void
+parsepipe(char *str, int flags)
+{
+	int pip[2] = { -1, -1 };
+	int redir[2] = { -1, -1 };
+	char *p, *cmds;
+
+	p = cmds = str;
+	while (*cmds) {
+		switch (*p) {
+		case '|':
+			*p = '\0';
+			redir[0] = pip[0];
+			if (pipe(pip) == -1) {
+				error("Cannot pipe");
+				return;
+			}
+			redir[1] = pip[1];
+			parsecmd(cmds, redir, flags | CMD_PIPE);
+			cmds = p + 1;
+			break;
+		case '\0':
+			redir[0] = pip[0];
+			redir[1] = -1;
+			parsecmd(cmds, redir, flags);
+			return;
+		}
+		p++;
+	}
+}
+
+static void
+parseline(char *line)
+{
+	char *p, *cmds;
+
+	p = cmds = line;
+	while (*cmds) {
+		switch (*p) {
+		case ';':
+			*p = '\0';
+			parsepipe(cmds, 0);
+			cmds = p + 1;
+			break;
+		case '&':
+			*p = '\0';
+			parsepipe(cmds, CMD_BACKGND);
+			cmds = p + 1;
+			break;
+		case '\0':
+		case '\n':
+		case '#':
+			*p = '\0';
+			parsepipe(cmds, 0);
+			return;
+		}
+		p++;
+	}
+}
+
+static char *
+readline(int fd, char *line, int len)
+{
+	char *p = line;
+	int nleft = len;
+	int cnt;
+
+	while (--nleft > 0) {
+		cnt = read(fd, p, 1);
+		if (cnt == -1)
+			return (char *)-1;	/* error */
+		if (cnt == 0) {
+			if (p == line)
+				return NULL;	/* EOF */
+			break;
+		}
+		if (*p == '\n')
+			break;
+		p++;
+	}
+	*p = '\0';
+	return line;
+}
+
+static void
+cmdloop(int fd)
+{
+	static char line[LINE_MAX];
+	char *p;
+
+	for (;;) {
+		if (interact)
+			showprompt();
+
+		line[0] = '\0';
+		p = readline(fd, line, sizeof(line));
+		if (p == (char *)-1)
+			continue;
+		if (p == NULL)
+			break;
+		parseline(line);
+		tcsetpgrp(2, shpid);
+	}
+}
+
+int
+main(int argc, char **argv)
+{
+	int input;
+
+	if (shpid == 0)
+		shpid = getpid();
+
+	if (setjmp(jmpbuf)) {
+		argv = (char **)0;
+		argc = 1;
+	}
+	interact = 1;
+	initvar();
+
+	if (argc == 1) {
+		input = 0;
+		if (isatty(0) && isatty(1)) {
+			interact = 1;
+			signal(SIGINT, SIG_IGN);
+			signal(SIGQUIT, SIG_IGN);
+			signal(SIGTERM, SIG_IGN);
+		}
+	} else {
+		interact = 0;
+		close(0);
+		input = open(argv[1], O_RDONLY);
+		if (input < 0) {
+			fprintf(stderr, "%s: cannot open\n", argv[1]);
+			interact = 1;
+			exit(1);
+		}
+	}
+	cmdloop(input);
+	exit(retval);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/sh/sh.h b/prex-0.9.0/usr/bin/sh/sh.h
new file mode 100755
index 0000000..831b310
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sh/sh.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+typedef int (*cmdfn_t)(int, char **);
+
+/*
+ * Command description
+ */
+struct cmdentry {
+	char	*cmd;
+	cmdfn_t func;
+};
+
+/*
+ * Command alias
+ */
+struct alias {
+	char	*name;
+	char	*value;
+};
+
+extern jmp_buf jmpbuf;
+
+extern void	initvar(void);
+extern void	setvar(char *name, char *val);
+extern void	unsetvar(char *name);
+
+extern int	null_cmd(int argc, char *argv[]);
+extern int	cmd_showvars(int argc, char *argv[]);
+extern int	cmd_unsetvar(int argc, char *argv[]);
+extern int	cmd_export(int argc, char *argv[]);
diff --git a/prex-0.9.0/usr/bin/sh/var.c b/prex-0.9.0/usr/bin/sh/var.c
new file mode 100755
index 0000000..013cb8c
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sh/var.c
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+extern char **environ;
+
+/*
+ * Shell variables.
+ */
+
+#define VTABSIZE	20
+#define MAXVARNAME	32
+
+struct var {
+	char	*name;
+	char	*val;
+};
+
+static struct var vartab[VTABSIZE];
+
+static int
+is_name(char c)
+{
+
+	if ((c >= 'a' && c <= 'z') ||
+	    (c >= 'A' && c <= 'Z') || c == '_')
+		return 1;
+	return 0;
+}
+
+static int
+is_validname(char *name)
+{
+	char *p;
+
+	for (p = name; *p != '\0'; p++) {
+		if (!is_name(*p))
+			return 0;
+	}
+	return 1;
+}
+
+static struct var *
+lookupvar(char *name)
+{
+	struct var *var;
+	int i;
+
+	var = &vartab[0];
+	for (i = 0; i < VTABSIZE; i++) {
+		if (var->name != NULL && !strcmp(var->name, name))
+			return var;
+		var++;
+	}
+	return NULL;
+}
+
+void
+setvar(char *name, char *val)
+{
+	struct var *var, *free;
+	int i;
+
+	/*
+	 * Lookup existing name in variable table.
+	 */
+	var = lookupvar(name);
+
+	if (var == NULL) {
+		/*
+		 * Not found. Find empty slot.
+		 */
+		free = NULL;
+		var = &vartab[0];
+		for (i = 0; i < VTABSIZE; i++) {
+			if (var->name == NULL) {
+				free = var;
+				break;
+			}
+			var++;
+		}
+		if (free == NULL) {
+			fprintf(stderr, "too many variables\n");
+			return;
+		}
+		var = free;
+	}
+
+	if (!is_validname(name)) {
+		fprintf(stderr, "%s: bad vairable name\n", name);
+		return;
+	}
+	if ((var->name = strdup(name)) == NULL) {
+		fprintf(stderr, "out of memory\n");
+		return;
+	}
+	var->val = strdup(val);
+}
+
+void
+unsetvar(char *name)
+{
+	struct var *var;
+
+	/* Find target slot in variable table */
+	var = lookupvar(name);
+	if (var == NULL)
+		return;
+
+	free(var->name);
+	free(var->val);
+	var->name = NULL;
+	var->val = NULL;
+}
+
+void
+setvareq(char *str)
+{
+	char name[MAXVARNAME];
+	char *p, *s;
+	int i;
+
+	s = str;
+	p = name;
+	for (i = 0; i < MAXVARNAME - 1; i++) {
+		*p++ = *s++;
+		if (*s == '=')
+			break;
+	}
+	*p = '\0';
+	p = strchr(str, '=');
+	setvar(name, p + 1);
+}
+
+int
+cmd_showvars(int argc, char *argv[])
+{
+	struct var *var;
+	int i;
+
+	var = &vartab[0];
+	for (i = 0; i < VTABSIZE; i++) {
+		if (var->name != NULL)
+			printf("%s=%s\n", var->name, var->val);
+		var++;
+	}
+	return 0;
+}
+
+int
+cmd_unsetvar(int argc, char *argv[])
+{
+
+	if (argc != 2) {
+		fprintf(stderr, "usage: unset name\n");
+		return 0;
+	}
+
+	unsetvar(argv[1]);
+	return 0;
+}
+
+int
+cmd_export(int argc, char *argv[])
+{
+	struct var *var;
+	int i;
+
+	if (argc == 1) {
+		fprintf(stderr, "usage: export name\n");
+		return 0;
+	}
+	for (i = 1; i < argc; i++) {
+		var = lookupvar(argv[i]);
+		if (var != NULL)
+			setenv(var->name, var->val, 1);
+	}
+	return 0;
+}
+
+void
+initvar(void)
+{
+	char **envp;
+	int i;
+
+	for (i = 0; i < VTABSIZE; i++)
+		vartab[i].name = NULL;
+
+	for (envp = environ; *envp; envp++) {
+		if (strchr(*envp, '='))
+			setvareq(*envp);
+	}
+}
diff --git a/prex-0.9.0/usr/bin/sleep/Makefile.inc b/prex-0.9.0/usr/bin/sleep/Makefile.inc
new file mode 100755
index 0000000..fc5441b
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sleep/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_SLEEP)+=	sleep/sleep.c
diff --git a/prex-0.9.0/usr/bin/sleep/sleep.c b/prex-0.9.0/usr/bin/sleep/sleep.c
new file mode 100755
index 0000000..3668b7e
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sleep/sleep.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	sleep_main(argc, argv)
+#endif
+
+static void usage(void);
+
+int
+main(int argc, char *argv[])
+{
+	int ch, secs;
+
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc != 1)
+		usage();
+
+	if ((secs = atoi(*argv)) > 0)
+		(void)sleep((u_int)secs);
+	exit(0);
+}
+
+static void
+usage(void)
+{
+
+	fprintf(stderr, "usage: sleep seconds\n");
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/bin/sync/Makefile.inc b/prex-0.9.0/usr/bin/sync/Makefile.inc
new file mode 100755
index 0000000..c0a86ed
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sync/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_SYNC)+=	sync/sync.c
diff --git a/prex-0.9.0/usr/bin/sync/sync.c b/prex-0.9.0/usr/bin/sync/sync.c
new file mode 100755
index 0000000..2f284f7
--- /dev/null
+++ b/prex-0.9.0/usr/bin/sync/sync.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	sync_main(argc, argv)
+#endif
+
+int
+main(int argc, char *argv[])
+{
+
+	sync();
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/bin/test/Makefile.inc b/prex-0.9.0/usr/bin/test/Makefile.inc
new file mode 100755
index 0000000..0ca1447
--- /dev/null
+++ b/prex-0.9.0/usr/bin/test/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_TEST)+=	test/test.c
diff --git a/prex-0.9.0/usr/bin/test/test.c b/prex-0.9.0/usr/bin/test/test.c
new file mode 100755
index 0000000..f9b9c86
--- /dev/null
+++ b/prex-0.9.0/usr/bin/test/test.c
@@ -0,0 +1,469 @@
+/* $NetBSD: test.c,v 1.26 2005/02/10 06:56:55 simonb Exp $ */
+
+/*
+ * test(1); version 7-like  --  author Erik Baalbergen
+ * modified by Eric Gisin to be used as built-in.
+ * modified by Arnold Robbins to add SVR3 compatibility
+ * (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
+ * modified by J.T. Conklin for NetBSD.
+ *
+ * This program is in the Public Domain.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	test_main(argc, argv)
+#endif
+
+/* test(1) accepts the following grammar:
+	oexpr	::= aexpr | aexpr "-o" oexpr ;
+	aexpr	::= nexpr | nexpr "-a" aexpr ;
+	nexpr	::= primary | "!" primary
+	primary	::= unary-operator operand
+		| operand binary-operator operand
+		| operand
+		| "(" oexpr ")"
+		;
+	unary-operator ::= "-r"|"-w"|"-x"|"-f"|"-d"|"-c"|"-b"|"-p"|
+		"-u"|"-g"|"-k"|"-s"|"-t"|"-z"|"-n"|"-o"|"-O"|"-G"|"-L"|"-S";
+
+	binary-operator ::= "="|"!="|"-eq"|"-ne"|"-ge"|"-gt"|"-le"|"-lt"|
+			"-nt"|"-ot"|"-ef";
+	operand ::= <any legal UNIX file name>
+*/
+
+enum token {
+	EOI,
+	FILRD,
+	FILWR,
+	FILEX,
+	FILEXIST,
+	FILREG,
+	FILDIR,
+	FILCDEV,
+	FILBDEV,
+	FILFIFO,
+	FILSOCK,
+	FILSYM,
+	FILGZ,
+	FILTT,
+	FILSUID,
+	FILSGID,
+	FILSTCK,
+	FILNT,
+	FILOT,
+	FILEQ,
+	FILUID,
+	FILGID,
+	STREZ,
+	STRNZ,
+	STREQ,
+	STRNE,
+	STRLT,
+	STRGT,
+	INTEQ,
+	INTNE,
+	INTGE,
+	INTGT,
+	INTLE,
+	INTLT,
+	UNOT,
+	BAND,
+	BOR,
+	LPAREN,
+	RPAREN,
+	OPERAND
+};
+
+enum token_types {
+	UNOP,
+	BINOP,
+	BUNOP,
+	BBINOP,
+	PAREN
+};
+
+static struct t_op {
+	const char *op_text;
+	short op_num, op_type;
+} const ops [] = {
+	{"-r",	FILRD,	UNOP},
+	{"-w",	FILWR,	UNOP},
+	{"-x",	FILEX,	UNOP},
+	{"-e",	FILEXIST,UNOP},
+	{"-f",	FILREG,	UNOP},
+	{"-d",	FILDIR,	UNOP},
+	{"-c",	FILCDEV,UNOP},
+	{"-b",	FILBDEV,UNOP},
+	{"-p",	FILFIFO,UNOP},
+	{"-u",	FILSUID,UNOP},
+	{"-g",	FILSGID,UNOP},
+	{"-k",	FILSTCK,UNOP},
+	{"-s",	FILGZ,	UNOP},
+	{"-t",	FILTT,	UNOP},
+	{"-z",	STREZ,	UNOP},
+	{"-n",	STRNZ,	UNOP},
+	{"-h",	FILSYM,	UNOP},		/* for backwards compat */
+	{"-O",	FILUID,	UNOP},
+	{"-G",	FILGID,	UNOP},
+	{"-L",	FILSYM,	UNOP},
+	{"-S",	FILSOCK,UNOP},
+	{"=",	STREQ,	BINOP},
+	{"!=",	STRNE,	BINOP},
+	{"<",	STRLT,	BINOP},
+	{">",	STRGT,	BINOP},
+	{"-eq",	INTEQ,	BINOP},
+	{"-ne",	INTNE,	BINOP},
+	{"-ge",	INTGE,	BINOP},
+	{"-gt",	INTGT,	BINOP},
+	{"-le",	INTLE,	BINOP},
+	{"-lt",	INTLT,	BINOP},
+	{"-nt",	FILNT,	BINOP},
+	{"-ot",	FILOT,	BINOP},
+	{"-ef",	FILEQ,	BINOP},
+	{"!",	UNOT,	BUNOP},
+	{"-a",	BAND,	BBINOP},
+	{"-o",	BOR,	BBINOP},
+	{"(",	LPAREN,	PAREN},
+	{")",	RPAREN,	PAREN},
+	{0,	0,	0}
+};
+
+static char **t_wp;
+static struct t_op const *t_wp_op;
+
+static void syntax(const char *, const char *);
+static int oexpr(enum token);
+static int aexpr(enum token);
+static int nexpr(enum token);
+static int primary(enum token);
+static int binop(void);
+static int filstat(char *, enum token);
+static enum token t_lex(char *);
+static int isoperand(void);
+static int getn(const char *);
+static int newerf(const char *, const char *);
+static int olderf(const char *, const char *);
+static int equalf(const char *, const char *);
+
+static void error(const char *, ...);
+
+static void
+error(const char *msg, ...)
+{
+	va_list ap;
+
+	va_start(ap, msg);
+	verrx(2, msg, ap);
+	va_end(ap);
+	/*NOTREACHED*/
+}
+
+int
+main(int argc, char *argv[])
+{
+	int res;
+
+	if (strcmp(argv[0], "[") == 0) {
+		if (strcmp(argv[--argc], "]"))
+			error("missing ]");
+		argv[argc] = NULL;
+	}
+
+	if (argc < 2)
+		return 1;
+
+	t_wp = &argv[1];
+	res = !oexpr(t_lex(*t_wp));
+
+	if (*t_wp != NULL && *++t_wp != NULL)
+		syntax(*t_wp, "unexpected operator");
+
+	return res;
+}
+
+static void
+syntax(const char *op, const char *msg)
+{
+
+	if (op && *op)
+		error("%s: %s", op, msg);
+	else
+		error("%s", msg);
+}
+
+static int
+oexpr(enum token n)
+{
+	int res;
+
+	res = aexpr(n);
+	if (t_lex(*++t_wp) == BOR)
+		return oexpr(t_lex(*++t_wp)) || res;
+	t_wp--;
+	return res;
+}
+
+static int
+aexpr(enum token n)
+{
+	int res;
+
+	res = nexpr(n);
+	if (t_lex(*++t_wp) == BAND)
+		return aexpr(t_lex(*++t_wp)) && res;
+	t_wp--;
+	return res;
+}
+
+static int
+nexpr(enum token n)
+{
+
+	if (n == UNOT)
+		return !nexpr(t_lex(*++t_wp));
+	return primary(n);
+}
+
+static int
+primary(enum token n)
+{
+	enum token nn;
+	int res;
+
+	if (n == EOI)
+		return 0;		/* missing expression */
+	if (n == LPAREN) {
+		if ((nn = t_lex(*++t_wp)) == RPAREN)
+			return 0;	/* missing expression */
+		res = oexpr(nn);
+		if (t_lex(*++t_wp) != RPAREN)
+			syntax(NULL, "closing paren expected");
+		return res;
+	}
+	if (t_wp_op && t_wp_op->op_type == UNOP) {
+		/* unary expression */
+		if (*++t_wp == NULL)
+			syntax(t_wp_op->op_text, "argument expected");
+		switch (n) {
+		case STREZ:
+			return strlen(*t_wp) == 0;
+		case STRNZ:
+			return strlen(*t_wp) != 0;
+		case FILTT:
+			return isatty(getn(*t_wp));
+		default:
+			return filstat(*t_wp, n);
+		}
+	}
+
+	if (t_lex(t_wp[1]), t_wp_op && t_wp_op->op_type == BINOP) {
+		return binop();
+	}
+
+	return strlen(*t_wp) > 0;
+}
+
+static int
+binop(void)
+{
+	const char *opnd1, *opnd2;
+	struct t_op const *op;
+
+	opnd1 = *t_wp;
+	(void) t_lex(*++t_wp);
+	op = t_wp_op;
+
+	if ((opnd2 = *++t_wp) == NULL)
+		syntax(op->op_text, "argument expected");
+
+	switch (op->op_num) {
+	case STREQ:
+		return strcmp(opnd1, opnd2) == 0;
+	case STRNE:
+		return strcmp(opnd1, opnd2) != 0;
+	case STRLT:
+		return strcmp(opnd1, opnd2) < 0;
+	case STRGT:
+		return strcmp(opnd1, opnd2) > 0;
+	case INTEQ:
+		return getn(opnd1) == getn(opnd2);
+	case INTNE:
+		return getn(opnd1) != getn(opnd2);
+	case INTGE:
+		return getn(opnd1) >= getn(opnd2);
+	case INTGT:
+		return getn(opnd1) > getn(opnd2);
+	case INTLE:
+		return getn(opnd1) <= getn(opnd2);
+	case INTLT:
+		return getn(opnd1) < getn(opnd2);
+	case FILNT:
+		return newerf(opnd1, opnd2);
+	case FILOT:
+		return olderf(opnd1, opnd2);
+	case FILEQ:
+		return equalf(opnd1, opnd2);
+	default:
+		abort();
+		/* NOTREACHED */
+	}
+}
+
+static int
+filstat(char *nm, enum token mode)
+{
+	struct stat s;
+
+	if (mode == FILSYM ? lstat(nm, &s) : stat(nm, &s))
+		return 0;
+
+	switch (mode) {
+	case FILRD:
+		return access(nm, R_OK) == 0;
+	case FILWR:
+		return access(nm, W_OK) == 0;
+	case FILEX:
+		return access(nm, X_OK) == 0;
+	case FILEXIST:
+		return access(nm, F_OK) == 0;
+	case FILREG:
+		return S_ISREG(s.st_mode);
+	case FILDIR:
+		return S_ISDIR(s.st_mode);
+	case FILCDEV:
+		return S_ISCHR(s.st_mode);
+	case FILBDEV:
+		return S_ISBLK(s.st_mode);
+	case FILFIFO:
+		return S_ISFIFO(s.st_mode);
+	case FILSOCK:
+		return S_ISSOCK(s.st_mode);
+	case FILSYM:
+		return S_ISLNK(s.st_mode);
+	case FILSUID:
+		return (s.st_mode & S_ISUID) != 0;
+	case FILSGID:
+		return (s.st_mode & S_ISGID) != 0;
+	case FILSTCK:
+		return (s.st_mode & S_ISVTX) != 0;
+	case FILGZ:
+		return s.st_size > (off_t)0;
+	case FILUID:
+		return s.st_uid == geteuid();
+	case FILGID:
+		return s.st_gid == getegid();
+	default:
+		return 1;
+	}
+}
+
+static enum token
+t_lex(char *s)
+{
+	struct t_op const *op;
+
+	op = ops;
+
+	if (s == 0) {
+		t_wp_op = NULL;
+		return EOI;
+	}
+	while (op->op_text) {
+		if (strcmp(s, op->op_text) == 0) {
+			if ((op->op_type == UNOP && isoperand()) ||
+			    (op->op_num == LPAREN && *(t_wp+1) == 0))
+				break;
+			t_wp_op = op;
+			return op->op_num;
+		}
+		op++;
+	}
+	t_wp_op = NULL;
+	return OPERAND;
+}
+
+static int
+isoperand(void)
+{
+	struct t_op const *op;
+	char *s, *t;
+
+	op = ops;
+	if ((s  = *(t_wp+1)) == 0)
+		return 1;
+	if ((t = *(t_wp+2)) == 0)
+		return 0;
+	while (op->op_text) {
+		if (strcmp(s, op->op_text) == 0)
+	    		return op->op_type == BINOP &&
+	    		    (t[0] != ')' || t[1] != '\0');
+		op++;
+	}
+	return 0;
+}
+
+/* atoi with error detection */
+static int
+getn(const char *s)
+{
+	char *p;
+	long r;
+
+	errno = 0;
+	r = strtol(s, &p, 10);
+
+	if (errno != 0)
+	      error("%s: out of range", s);
+
+	while (isspace((unsigned char)*p))
+	      p++;
+
+	if (*p)
+	      error("%s: bad number", s);
+
+	return (int) r;
+}
+
+static int
+newerf(const char *f1, const char *f2)
+{
+	struct stat b1, b2;
+
+	return (stat(f1, &b1) == 0 &&
+		stat(f2, &b2) == 0 &&
+		b1.st_mtime > b2.st_mtime);
+}
+
+static int
+olderf(const char *f1, const char *f2)
+{
+	struct stat b1, b2;
+
+	return (stat(f1, &b1) == 0 &&
+		stat(f2, &b2) == 0 &&
+		b1.st_mtime < b2.st_mtime);
+}
+
+static int
+equalf(const char *f1, const char *f2)
+{
+	struct stat b1, b2;
+
+	return (stat(f1, &b1) == 0 &&
+		stat(f2, &b2) == 0 &&
+		b1.st_dev == b2.st_dev &&
+		b1.st_ino == b2.st_ino);
+}
diff --git a/prex-0.9.0/usr/bin/touch/Makefile.inc b/prex-0.9.0/usr/bin/touch/Makefile.inc
new file mode 100755
index 0000000..6dc8001
--- /dev/null
+++ b/prex-0.9.0/usr/bin/touch/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_TOUCH)+=	touch/touch.c
diff --git a/prex-0.9.0/usr/bin/touch/touch.c b/prex-0.9.0/usr/bin/touch/touch.c
new file mode 100755
index 0000000..ab2ea21
--- /dev/null
+++ b/prex-0.9.0/usr/bin/touch/touch.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	touch_main(argc, argv)
+#endif
+
+/* Flags */
+#define TF_NOCREAT	0x01	/* Do not create file */
+
+static void usage(void);
+static int do_touch(char *, unsigned int);
+
+int
+main(int argc, char *argv[])
+{
+	unsigned int flags;
+	int ch;
+
+	flags = 0;
+	while ((ch = getopt(argc, argv, "")) != -1)
+		switch(ch) {
+		case 'c':
+			flags |= TF_NOCREAT;
+			break;
+		case '?':
+		default:
+			usage();
+		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc == 0)
+		usage();
+
+	do {
+		if (do_touch(*argv, flags))
+			err(1, NULL);
+		++argv;
+	} while (*argv);
+	exit(1);
+}
+
+static void
+usage(void)
+{
+	fprintf(stderr, "usage: touch [-c] file...\n");
+	exit(1);
+}
+
+static int
+do_touch(char *file, unsigned int flags)
+{
+	struct stat st;
+	int fd;
+
+	if (stat(file, &st) < 0) {
+		if (!(flags & TF_NOCREAT)) {
+			if ((fd = creat(file, 0666)) < 0)
+				return -1;
+			close(fd);
+		}
+		return 0;
+	}
+	if ((fd = open(file, 2)) < 0)
+		return -1;
+	/* utime(file, NULL) */
+	close(fd);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/bin/uname/Makefile.inc b/prex-0.9.0/usr/bin/uname/Makefile.inc
new file mode 100755
index 0000000..06ecbed
--- /dev/null
+++ b/prex-0.9.0/usr/bin/uname/Makefile.inc
@@ -0,0 +1,2 @@
+
+SRCS-$(CONFIG_CMD_UNAME)+=	uname/uname.c
diff --git a/prex-0.9.0/usr/bin/uname/uname.c b/prex-0.9.0/usr/bin/uname/uname.c
new file mode 100755
index 0000000..bdb44e8
--- /dev/null
+++ b/prex-0.9.0/usr/bin/uname/uname.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/utsname.h>
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+
+#ifdef CMDBOX
+#define main(argc, argv)	uname_main(argc, argv)
+#endif
+
+#define	MFLAG	0x01
+#define	NFLAG	0x02
+#define	RFLAG	0x04
+#define	SFLAG	0x08
+#define	VFLAG	0x10
+
+static void
+usage(void)
+{
+	fprintf(stderr, "usage: uname [-amnsrv]\n");
+	exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+	u_int flags;
+	int ch;
+	struct utsname uts;
+
+	flags = 0;
+	while ((ch = getopt(argc, argv, "amnrsv")) != EOF) {
+		switch(ch) {
+		case 'a':
+			flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
+			break;
+		case 'm':
+			flags |= MFLAG;
+			break;
+		case 'n':
+			flags |= NFLAG;
+			break;
+		case 'r':
+			flags |= RFLAG;
+			break;
+		case 's':
+			flags |= SFLAG;
+			break;
+		case 'v':
+			flags |= VFLAG;
+			break;
+		case '?':
+		default:
+			usage();
+		}
+	}
+	argc -= optind;
+	argv += optind;
+
+	if (argc)
+		usage();
+
+	if (!flags)
+		flags |= SFLAG;
+
+	uname(&uts);
+
+	if (flags & SFLAG)
+		printf("%s ", uts.sysname);
+
+	if (flags & RFLAG)
+		printf("%s ", uts.release);
+
+	if (flags & VFLAG)
+		printf("%s ", uts.version);
+
+	if (flags & MFLAG)
+		printf("%s ", uts.machine);
+
+	if (flags & NFLAG)
+		printf("%s", uts.nodename);
+
+	putchar('\n');
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/include/ar.h b/prex-0.9.0/usr/include/ar.h
new file mode 100755
index 0000000..7fa4c1b
--- /dev/null
+++ b/prex-0.9.0/usr/include/ar.h
@@ -0,0 +1 @@
+#include <sys/ar.h>
diff --git a/prex-0.9.0/usr/include/assert.h b/prex-0.9.0/usr/include/assert.h
new file mode 100755
index 0000000..a9aa602
--- /dev/null
+++ b/prex-0.9.0/usr/include/assert.h
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)assert.h	8.2 (Berkeley) 1/21/94
+ */
+
+/*
+ * Unlike other ANSI header files, <assert.h> may usefully be included
+ * multiple times, with and without DEBUG defined.
+ */
+
+#undef assert
+#undef _assert
+
+#ifdef DEBUG
+#define	_assert(e)	assert(e)
+#ifdef __STDC__
+#define	assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
+#define	dassert(e)	((e) ? (void)0 : __dassert(__FILE__, __LINE__, #e))
+#else	/* PCC */
+#define	assert(e)	((e) ? (void)0 : __assert(__FILE__, __LINE__, "e"))
+#define	dassert(e)	((e) ? (void)0 : __dassert(__FILE__, __LINE__, "e"))
+#endif
+
+#else
+#define	assert(e)	((void)0)
+#define	_assert(e)	((void)0)
+#define	dassert(e)	((void)0)
+#endif
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void __assert(const char *, int, const char *);
+void __dassert(const char *, int, const char *);
+__END_DECLS
diff --git a/prex-0.9.0/usr/include/ctype.h b/prex-0.9.0/usr/include/ctype.h
new file mode 100755
index 0000000..028c8f5
--- /dev/null
+++ b/prex-0.9.0/usr/include/ctype.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int	isalnum(int c);
+int	isalpha(int c);
+int	isblank(int c);
+int	iscntrl(int c);
+int	isdigit(int c);
+int	isgraph(int c);
+int	islower(int c);
+int	isprint(int c);
+int	ispunct(int c);
+int	isspace(int c);
+int	isupper(int c);
+int	isxdigit(int c);
+int	isascii(int c);
+int	toascii(int c);
+
+int	tolower(int c);
+int	toupper(int c);
+__END_DECLS
+
+#endif /* !_CTYPE_H */
diff --git a/prex-0.9.0/usr/include/dirent.h b/prex-0.9.0/usr/include/dirent.h
new file mode 100755
index 0000000..f704cdf
--- /dev/null
+++ b/prex-0.9.0/usr/include/dirent.h
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)dirent.h	8.2 (Berkeley) 7/28/94
+ */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+
+/*
+ * The kernel defines the format of directory entries returned by
+ * the getdirentries(2) system call.
+ */
+#include <sys/dirent.h>
+
+#ifdef _POSIX_SOURCE
+typedef void *	DIR;
+#else
+
+#define	d_ino		d_fileno	/* backward compatibility */
+
+struct _dirdesc {
+	int	dd_fd;		/* file descriptor associated with directory */
+	struct dirent dd_ent;
+};
+typedef struct _dirdesc DIR;
+
+#define	dirfd(dirp)	((dirp)->dd_fd)
+
+#ifndef NULL
+#define	NULL	0
+#endif
+
+#endif /* _POSIX_SOURCE */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+DIR *opendir(const char *);
+struct dirent *readdir(DIR *);
+void rewinddir(DIR *);
+int closedir(DIR *);
+
+#ifndef _POSIX_SOURCE
+long telldir(const DIR *);
+void seekdir(DIR *, long);
+#endif /* not POSIX */
+__END_DECLS
+
+#endif /* !_DIRENT_H */
diff --git a/prex-0.9.0/usr/include/err.h b/prex-0.9.0/usr/include/err.h
new file mode 100755
index 0000000..86b3652
--- /dev/null
+++ b/prex-0.9.0/usr/include/err.h
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)err.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _ERR_H_
+#define	_ERR_H_
+
+#include <machine/stdarg.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	err(int, const char *, ...) __noreturn;
+void	verr(int, const char *, va_list) __noreturn;
+void	errx(int, const char *, ...) __noreturn;
+void	verrx(int, const char *, va_list) __noreturn;
+void	warn(const char *, ...);
+void	vwarn(const char *, va_list);
+void	warnx(const char *, ...);
+void	vwarnx(const char *, va_list);
+__END_DECLS
+
+#endif /* !_ERR_H_ */
diff --git a/prex-0.9.0/usr/include/errno.h b/prex-0.9.0/usr/include/errno.h
new file mode 100755
index 0000000..7142f41
--- /dev/null
+++ b/prex-0.9.0/usr/include/errno.h
@@ -0,0 +1,8 @@
+#ifndef _ERRNO_H_
+#define _ERRNO_H_
+
+#include <sys/errno.h>
+
+extern int errno;			/* global error number */
+
+#endif /* !_ERRNO_H_ */
diff --git a/prex-0.9.0/usr/include/fcntl.h b/prex-0.9.0/usr/include/fcntl.h
new file mode 100755
index 0000000..58d4fac
--- /dev/null
+++ b/prex-0.9.0/usr/include/fcntl.h
@@ -0,0 +1,2 @@
+
+#include <sys/fcntl.h>
diff --git a/prex-0.9.0/usr/include/fts.h b/prex-0.9.0/usr/include/fts.h
new file mode 100755
index 0000000..90469b3
--- /dev/null
+++ b/prex-0.9.0/usr/include/fts.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)fts.h	8.3 (Berkeley) 8/14/94
+ */
+
+#ifndef	_FTS_H_
+#define	_FTS_H_
+
+typedef struct {
+	struct _ftsent *fts_cur;	/* current node */
+	struct _ftsent *fts_child;	/* linked list of children */
+	struct _ftsent **fts_array;	/* sort array */
+	dev_t fts_dev;			/* starting device # */
+	char *fts_path;			/* path for this descent */
+	int fts_rfd;			/* fd for root */
+	int fts_pathlen;		/* sizeof(path) */
+	int fts_nitems;			/* elements in the sort array */
+	int (*fts_compar)		/* compare function */
+		(const struct _ftsent **, const struct _ftsent **);
+
+#define	FTS_COMFOLLOW	0x001		/* follow command line symlinks */
+#define	FTS_LOGICAL	0x002		/* logical walk */
+#define	FTS_NOCHDIR	0x004		/* don't change directories */
+#define	FTS_NOSTAT	0x008		/* don't get stat info */
+#define	FTS_PHYSICAL	0x010		/* physical walk */
+#define	FTS_SEEDOT	0x020		/* return dot and dot-dot */
+#define	FTS_XDEV	0x040		/* don't cross devices */
+#if 0
+#define	FTS_WHITEOUT	0x080		/* return whiteout information */
+#endif
+#define	FTS_OPTIONMASK	0x0ff		/* valid user option mask */
+
+#define	FTS_NAMEONLY	0x100		/* (private) child names only */
+#define	FTS_STOP	0x200		/* (private) unrecoverable error */
+	int fts_options;		/* fts_open options, global flags */
+} FTS;
+
+typedef struct _ftsent {
+	struct _ftsent *fts_cycle;	/* cycle node */
+	struct _ftsent *fts_parent;	/* parent directory */
+	struct _ftsent *fts_link;	/* next file in directory */
+	long fts_number;	        /* local numeric value */
+	void *fts_pointer;	        /* local address value */
+	char *fts_accpath;		/* access path */
+	char *fts_path;			/* root path */
+	int fts_errno;			/* errno for this node */
+	int fts_symfd;			/* fd for symlink */
+	u_short fts_pathlen;		/* strlen(fts_path) */
+	u_short fts_namelen;		/* strlen(fts_name) */
+
+	ino_t fts_ino;			/* inode */
+	dev_t fts_dev;			/* device */
+	nlink_t fts_nlink;		/* link count */
+
+#define	FTS_ROOTPARENTLEVEL	-1
+#define	FTS_ROOTLEVEL		 0
+	short fts_level;		/* depth (-1 to N) */
+
+#define	FTS_D		 1		/* preorder directory */
+#define	FTS_DC		 2		/* directory that causes cycles */
+#define	FTS_DEFAULT	 3		/* none of the above */
+#define	FTS_DNR		 4		/* unreadable directory */
+#define	FTS_DOT		 5		/* dot or dot-dot */
+#define	FTS_DP		 6		/* postorder directory */
+#define	FTS_ERR		 7		/* error; errno is set */
+#define	FTS_F		 8		/* regular file */
+#define	FTS_INIT	 9		/* initialized only */
+#define	FTS_NS		10		/* stat(2) failed */
+#define	FTS_NSOK	11		/* no stat(2) requested */
+#define	FTS_SL		12		/* symbolic link */
+#define	FTS_SLNONE	13		/* symbolic link without target */
+#define	FTS_W		14		/* whiteout object */
+	u_short fts_info;		/* user flags for FTSENT structure */
+
+#define	FTS_DONTCHDIR	 0x01		/* don't chdir .. to the parent */
+#define	FTS_SYMFOLLOW	 0x02		/* followed a symlink to get here */
+#define	FTS_ISW		 0x04		/* this is a whiteout object */
+	u_short fts_flags;		/* private flags for FTSENT structure */
+
+#define	FTS_AGAIN	 1		/* read node again */
+#define	FTS_FOLLOW	 2		/* follow symbolic link */
+#define	FTS_NOINSTR	 3		/* no instructions */
+#define	FTS_SKIP	 4		/* discard node */
+	u_short fts_instr;		/* fts_set() instructions */
+
+	struct stat *fts_statp;		/* stat(2) information */
+	char fts_name[1];		/* file name */
+} FTSENT;
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+FTSENT	*fts_children(FTS *, int);
+int	 fts_close(FTS *);
+FTS	*fts_open(char * const *, int,
+	    int (*)(const FTSENT **, const FTSENT **));
+FTSENT	*fts_read(FTS *);
+int	 fts_set(FTS *, FTSENT *, int);
+__END_DECLS
+
+#endif /* !_FTS_H_ */
diff --git a/prex-0.9.0/usr/include/libgen.h b/prex-0.9.0/usr/include/libgen.h
new file mode 100755
index 0000000..44a03c0
--- /dev/null
+++ b/prex-0.9.0/usr/include/libgen.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBGEN_H_
+#define _LIBGEN_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char    *basename(const char *);
+char    *dirname(const char *);
+__END_DECLS
+
+#endif /* _LIBGEN_H_ */
diff --git a/prex-0.9.0/usr/include/limits.h b/prex-0.9.0/usr/include/limits.h
new file mode 100755
index 0000000..0b56f60
--- /dev/null
+++ b/prex-0.9.0/usr/include/limits.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)limits.h	8.2 (Berkeley) 1/4/94
+ */
+
+#ifndef _LIMITS_H_
+#define	_LIMITS_H_
+
+#include <machine/limits.h>
+#include <sys/syslimits.h>
+
+#endif /* !_LIMITS_H_ */
diff --git a/prex-0.9.0/usr/include/paths.h b/prex-0.9.0/usr/include/paths.h
new file mode 100755
index 0000000..e14f451
--- /dev/null
+++ b/prex-0.9.0/usr/include/paths.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)paths.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _PATHS_H_
+#define	_PATHS_H_
+
+/* Default search path. */
+#define	_PATH_DEFPATH	"/boot:/bin"
+/* All standard utilities path. */
+#define	_PATH_STDPATH	"/boot:/bin"
+
+#define	_PATH_BSHELL	"/bin/sh"
+#define	_PATH_CONSOLE	"/dev/console"
+#define	_PATH_DEVNULL	"/dev/null"
+#define	_PATH_TTY	"/dev/tty"
+#define	_PATH_DEV	"/dev/"
+#define	_PATH_TMP	"/tmp/"
+#define _PATH_PASSWD	"/private/passwd"
+
+#endif /* !_PATHS_H_ */
diff --git a/prex-0.9.0/usr/include/setjmp.h b/prex-0.9.0/usr/include/setjmp.h
new file mode 100755
index 0000000..0473e07
--- /dev/null
+++ b/prex-0.9.0/usr/include/setjmp.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)setjmp.h	8.2 (Berkeley) 1/21/94
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_
+
+#include <sys/cdefs.h>
+#include <machine/setjmp.h>
+
+/*
+ * WARNING: sigsetjmp() isn't supported yet, this is a placeholder.
+ */
+typedef int sigjmp_buf[_JBLEN + 1];
+typedef long jmp_buf[_JBLEN];
+
+__BEGIN_DECLS
+int	setjmp(jmp_buf);
+void	longjmp(jmp_buf, int);
+int	sigsetjmp(sigjmp_buf, int);
+void	siglongjmp(sigjmp_buf, int);
+__END_DECLS
+
+#endif /* !_SETJMP_H_ */
diff --git a/prex-0.9.0/usr/include/signal.h b/prex-0.9.0/usr/include/signal.h
new file mode 100755
index 0000000..919b909
--- /dev/null
+++ b/prex-0.9.0/usr/include/signal.h
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)signal.h	8.3 (Berkeley) 3/30/94
+ */
+
+#ifndef _USER_SIGNAL_H
+#define _USER_SIGNAL_H
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <sys/signal.h>
+
+extern const char *const sys_signame[NSIG];
+extern const char *const sys_siglist[NSIG];
+
+__BEGIN_DECLS
+int	raise(int);
+int	kill(pid_t, int);
+int	sigaction(int, const struct sigaction *, struct sigaction *);
+int	sigaddset(sigset_t *, int);
+int	sigdelset(sigset_t *, int);
+int	sigemptyset(sigset_t *);
+int	sigfillset(sigset_t *);
+int	sigismember(const sigset_t *, int);
+int	sigpending(sigset_t *);
+int	sigprocmask(int, const sigset_t *, sigset_t *);
+int	sigsuspend(const sigset_t *);
+int	killpg(pid_t, int);
+int	sigblock(int);
+int	siginterrupt(int, int);
+int	sigpause(int);
+int	sigreturn(struct sigcontext *);
+int	sigsetmask(int);
+int	sigstack(const struct sigstack *, struct sigstack *);
+int	sigvec(int, struct sigvec *, struct sigvec *);
+void	psignal(unsigned int, const char *);
+__END_DECLS
+
+/* List definitions after function declarations, or Reiser cpp gets upset. */
+#define	sigaddset(set, signo)	(*(set) |= 1 << ((signo) - 1), 0)
+#define	sigdelset(set, signo)	(*(set) &= ~(1 << ((signo) - 1)), 0)
+#define	sigemptyset(set)	(*(set) = 0, 0)
+#define	sigfillset(set)		(*(set) = ~(sigset_t)0, 0)
+#define	sigismember(set, signo)	((*(set) & (1 << ((signo) - 1))) != 0)
+
+#endif	/* !_USER_SIGNAL_H */
diff --git a/prex-0.9.0/usr/include/stdarg.h b/prex-0.9.0/usr/include/stdarg.h
new file mode 100755
index 0000000..7b1665d
--- /dev/null
+++ b/prex-0.9.0/usr/include/stdarg.h
@@ -0,0 +1,2 @@
+#include <machine/stdarg.h>
+
diff --git a/prex-0.9.0/usr/include/stddef.h b/prex-0.9.0/usr/include/stddef.h
new file mode 100755
index 0000000..1ec5118
--- /dev/null
+++ b/prex-0.9.0/usr/include/stddef.h
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)stddef.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _STDDEF_H_
+#define _STDDEF_H_
+
+#if !defined(_SIZE_T)
+#define _SIZE_T
+typedef	unsigned int	size_t;		/* size of something in bytes */
+#endif
+
+#if !defined(_WCHAR_T)
+#define _WCHAR_T
+typedef int		wchar_t;
+#endif
+
+#ifndef	NULL
+#if !defined(__cplusplus)
+#define	NULL	((void *)0)
+#else
+#define	NULL	0
+#endif
+#endif
+
+#define	offsetof(type, member)	((size_t)(&((type *)0)->member))
+
+#endif /* _STDDEF_H_ */
diff --git a/prex-0.9.0/usr/include/stdio.h b/prex-0.9.0/usr/include/stdio.h
new file mode 100755
index 0000000..2c8a545
--- /dev/null
+++ b/prex-0.9.0/usr/include/stdio.h
@@ -0,0 +1,301 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)stdio.h	8.5 (Berkeley) 4/29/95
+ */
+
+#ifndef	_STDIO_H_
+#define	_STDIO_H_
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+
+#if !defined(_SIZE_T)
+#define _SIZE_T
+typedef	unsigned int	size_t;		/* size of something in bytes */
+#endif
+
+#include <machine/stdarg.h>
+
+#ifndef	NULL
+#if !defined(__cplusplus)
+#define	NULL	((void *)0)
+#else
+#define	NULL	0
+#endif
+#endif
+
+typedef off_t fpos_t;
+
+#define	_FSTDIO			/* Define for new stdio with functions. */
+
+/*
+ * NB: to fit things in six character monocase externals, the stdio
+ * code uses the prefix `__s' for stdio objects, typically followed
+ * by a three-character attempt at a mnemonic.
+ */
+
+/* stdio buffers */
+struct __sbuf {
+	unsigned char *_base;
+	int	_size;
+};
+
+/*
+ * stdio state variables.
+ *
+ * The following always hold:
+ *
+ *	if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
+ *		_lbfsize is -_bf._size, else _lbfsize is 0
+ *	if _flags&__SRD, _w is 0
+ *	if _flags&__SWR, _r is 0
+ *
+ * This ensures that the getc and putc macros (or inline functions) never
+ * try to write or read from a file that is in `read' or `write' mode.
+ * (Moreover, they can, and do, automatically switch from read mode to
+ * write mode, and back, on "r+" and "w+" files.)
+ *
+ * _lbfsize is used only to make the inline line-buffered output stream
+ * code as compact as possible.
+ *
+ * _ub, _up, and _ur are used when ungetc() pushes back more characters
+ * than fit in the current _bf, or when ungetc() pushes back a character
+ * that does not match the previous one in _bf.  When this happens,
+ * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
+ * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
+ *
+ * NB: see WARNING above before changing the layout of this structure!
+ */
+typedef	struct __sFILE {
+	struct __sFILE *next;	/* file chain */
+	unsigned char *_p;	/* current position in (some) buffer */
+	int	_r;		/* read space left for getc() */
+	int	_w;		/* write space left for putc() */
+	short	_flags;		/* flags, below; this FILE is free if 0 */
+	short	_file;		/* fileno, if Unix descriptor, else -1 */
+	struct	__sbuf _bf;	/* the buffer (at least 1 byte, if !NULL) */
+
+	/* separate buffer for long sequences of ungetc() */
+	struct	__sbuf _ub;	/* ungetc buffer */
+	unsigned char *_up;	/* saved _p when _p is doing ungetc data */
+	int	_ur;		/* saved _r when _r is counting ungetc data */
+
+	/* tricks to meet minimum requirements even when malloc() fails */
+	unsigned char _ubuf[3];	/* guarantee an ungetc() buffer */
+	unsigned char _nbuf[1];	/* guarantee a getc() buffer */
+} FILE;
+
+__BEGIN_DECLS
+extern FILE __sF[];
+__END_DECLS
+
+#define	__SLBF	0x0001		/* line buffered */
+#define	__SNBF	0x0002		/* unbuffered */
+#define	__SRD	0x0004		/* OK to read */
+#define	__SWR	0x0008		/* OK to write */
+	/* RD and WR are never simultaneously asserted */
+#define	__SRW	0x0010		/* open for reading & writing */
+#define	__SEOF	0x0020		/* found EOF */
+#define	__SERR	0x0040		/* found error */
+#define	__SMBF	0x0080		/* _buf is from malloc */
+#define	__SAPP	0x0100		/* fdopen()ed in append mode */
+#define	__SSTR	0x0200		/* this is an sprintf/snprintf string */
+
+/*
+ * The following three definitions are for ANSI C, which took them
+ * from System V, which brilliantly took internal interface macros and
+ * made them official arguments to setvbuf(), without renaming them.
+ * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
+ *
+ * Although numbered as their counterparts above, the implementation
+ * does not rely on this.
+ */
+#define	_IOFBF	0		/* setvbuf should set fully buffered */
+#define	_IOLBF	1		/* setvbuf should set line buffered */
+#define	_IONBF	2		/* setvbuf should set unbuffered */
+
+#define	BUFSIZ	512		/* size of buffer used by setbuf */
+#define	EOF	(-1)
+
+/*
+ * FOPEN_MAX is a minimum maximum, and is the number of streams that
+ * stdio can provide without attempting to allocate further resources
+ * (which could fail).  Do not use this for anything.
+ */
+				/* must be == _POSIX_STREAM_MAX <limits.h> */
+#define	FOPEN_MAX	16	/* must be <= OPEN_MAX <sys/syslimits.h> */
+#define	FILENAME_MAX	256	/* must be <= PATH_MAX <sys/syslimits.h> */
+
+/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
+#ifndef _ANSI_SOURCE
+#define	P_tmpdir	"/var/tmp/"
+#endif
+#define	L_tmpnam	255	/* XXX must be == PATH_MAX */
+#define	TMP_MAX		308915776
+
+/* access function */
+#define	F_OK		0	/* test for existence of file */
+#define	X_OK		0x01	/* test for execute or search permission */
+#define	W_OK		0x02	/* test for write permission */
+#define	R_OK		0x04	/* test for read permission */
+
+/* whence values for lseek(2) */
+#define	SEEK_SET	0	/* set file offset to offset */
+#define	SEEK_CUR	1	/* set file offset to current plus offset */
+#define	SEEK_END	2	/* set file offset to EOF plus offset */
+
+#define	stdin	(&__sF[0])
+#define	stdout	(&__sF[1])
+#define	stderr	(&__sF[2])
+
+/*
+ * Functions defined in ANSI C standard.
+ */
+__BEGIN_DECLS
+void	 clearerr(FILE *);
+int	 fclose(FILE *);
+int	 feof(FILE *);
+int	 ferror(FILE *);
+int	 fflush(FILE *);
+int	 fgetc(FILE *);
+int	 fgetpos(FILE *, fpos_t *);
+char	*fgets(char *, size_t, FILE *);
+FILE	*fopen(const char *, const char *);
+int	 fprintf(FILE *, const char *, ...);
+int	 fputc(int, FILE *);
+int	 fputs(const char *, FILE *);
+size_t	 fread(void *, size_t, size_t, FILE *);
+FILE	*freopen(const char *, const char *, FILE *);
+int	 fscanf(FILE *, const char *, ...);
+int	 fseek(FILE *, long, int);
+int	 fsetpos(FILE *, const fpos_t *);
+long	 ftell(FILE *);
+size_t	 fwrite(const void *, size_t, size_t, FILE *);
+int	 getc(FILE *);
+int	 getchar(void);
+char	*gets(char *);
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+extern const int _sys_nerr;			/* perror(3) external variables */
+extern const char *const _sys_errlist[];
+#endif
+void	 perror(const char *);
+int	 printf(const char *, ...);
+int	 putc(int, FILE *);
+int	 putchar(int);
+int	 puts(const char *);
+int	 remove(const char *);
+int	 rename (const char *, const char *);
+void	 rewind(FILE *);
+int	 scanf(const char *, ...);
+void	 setbuf(FILE *, char *);
+int	 setvbuf(FILE *, char *, int, size_t);
+int	 sprintf(char *, const char *, ...);
+int	 sscanf(const char *, const char *, ...);
+FILE	*tmpfile(void);
+char	*tmpnam(char *);
+int	 ungetc(int, FILE *);
+int	 vfprintf(FILE *, const char *, va_list);
+int	 vprintf(const char *, va_list);
+int	 vsprintf(char *, const char *, va_list);
+__END_DECLS
+
+/*
+ * Functions defined in POSIX 1003.1.
+ */
+#ifndef _ANSI_SOURCE
+#define	L_cuserid	9	/* size for cuserid(); UT_NAMESIZE + 1 */
+#define	L_ctermid	1024	/* size for ctermid(); PATH_MAX */
+
+__BEGIN_DECLS
+char	*ctermid(char *);
+FILE	*fdopen(int, const char *);
+int	 fileno(FILE *);
+__END_DECLS
+#endif /* not ANSI */
+
+/*
+ * Routines that are purely local.
+ */
+#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+__BEGIN_DECLS
+int	 fpurge(FILE *);
+int	 getw(FILE *);
+int	 pclose(FILE *);
+FILE	*popen(const char *, const char *);
+int	 putw(int, FILE *);
+void	 setbuffer(FILE *, char *, int);
+int	 setlinebuf(FILE *);
+char	*tempnam(const char *, const char *);
+int	 snprintf(char *, size_t, const char *, ...);
+int	 vsnprintf(char *, size_t, const char *, va_list);
+int	 vscanf(const char *, va_list);
+int	 vsscanf(const char *, const char *, va_list);
+FILE	*zopen(const char *, const char *, int);
+__END_DECLS
+
+/*
+ * This is a #define because the function is used internally and
+ * (unlike vfscanf) the name __svfscanf is guaranteed not to collide
+ * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined.
+ */
+#define	 vfscanf	__svfscanf
+
+#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
+
+/*
+ * Functions internal to the implementation.
+ */
+__BEGIN_DECLS
+int	__srget(FILE *);
+int	__svfscanf(FILE *, const char *, va_list);
+int	__swbuf(int, FILE *);
+__END_DECLS
+
+/*
+ * The __sfoo macros are here so that we can
+ * define function versions in the C library.
+ */
+
+#define	__sfeof(p)	(((p)->_flags & __SEOF) != 0)
+#define	__sferror(p)	(((p)->_flags & __SERR) != 0)
+#define	__sclearerr(p)	((void)((p)->_flags &= ~(__SERR|__SEOF)))
+#define	__sfileno(p)	((p)->_file)
+
+#define	feof(p)		__sfeof(p)
+#define	ferror(p)	__sferror(p)
+#define	clearerr(p)	__sclearerr(p)
+
+#ifndef _ANSI_SOURCE
+#define	fileno(p)	__sfileno(p)
+#endif
+
+#endif /* _STDIO_H_ */
diff --git a/prex-0.9.0/usr/include/stdlib.h b/prex-0.9.0/usr/include/stdlib.h
new file mode 100755
index 0000000..d06235a
--- /dev/null
+++ b/prex-0.9.0/usr/include/stdlib.h
@@ -0,0 +1,161 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95
+ */
+
+#ifndef _STDLIB_H_
+#define _STDLIB_H_
+
+#if !defined(_SIZE_T)
+#define _SIZE_T
+typedef	unsigned int	size_t;		/* size of something in bytes */
+#endif
+
+#if !defined(_WCHAR_T)
+#define _WCHAR_T
+typedef int		wchar_t;
+#endif
+
+typedef struct {
+	int quot;		/* quotient */
+	int rem;		/* remainder */
+} div_t;
+
+typedef struct {
+	long quot;		/* quotient */
+	long rem;		/* remainder */
+} ldiv_t;
+
+#ifndef NULL
+#define	NULL	0
+#endif
+
+#define	EXIT_FAILURE	1
+#define	EXIT_SUCCESS	0
+
+#define	RAND_MAX	0x7fffffff
+
+extern int __mb_cur_max;
+#define	MB_CUR_MAX	__mb_cur_max
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	 abort(void) __noreturn;
+int	 abs(int);
+int	 atexit(void (*)(void));
+double	 atof(const char *);
+int	 atoi(const char *);
+long	 atol(const char *);
+void	*bsearch(const void *, const void *, size_t,
+	    size_t, int (*)(const void *, const void *));
+void	*calloc(size_t, size_t);
+div_t	 div(int, int);
+void	 exit(int) __noreturn;
+void	 free(void *);
+char	*getenv(const char *);
+long	 labs(long);
+ldiv_t	 ldiv(long, long);
+void	 mstat(void);
+void	*malloc(size_t);
+void	 qsort(void *, size_t, size_t,
+	    int (*)(const void *, const void *));
+int	 rand(void);
+void	*realloc(void *, size_t);
+void	 srand(unsigned);
+double	 strtod(const char *, char **);
+long	 strtol(const char *, char **, int);
+unsigned long
+	 strtoul(const char *, char **, int);
+int	 system(const char *);
+
+/* These are currently just stubs. */
+int	 mblen(const char *, size_t);
+size_t	 mbstowcs(wchar_t *, const char *, size_t);
+int	 wctomb(char *, wchar_t);
+int	 mbtowc(wchar_t *, const char *, size_t);
+size_t	 wcstombs(char *, const wchar_t *, size_t);
+
+#ifndef _ANSI_SOURCE
+int	 putenv(const char *);
+int	 setenv(const char *, const char *, int);
+#endif
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+#define alloca(x) __builtin_alloca(x)	/* built-in for gcc */
+
+					/* getcap(3) functions */
+char	*getbsize(int *, long *);
+char	*cgetcap(char *, char *, int);
+int	 cgetclose(void);
+int	 cgetent(char **, char **, char *);
+int	 cgetfirst(char **, char **);
+int	 cgetmatch(char *, char *);
+int	 cgetnext(char **, char **);
+int	 cgetnum(char *, char *, long *);
+int	 cgetset(char *);
+int	 cgetstr(char *, char *, char **);
+int	 cgetustr(char *, char *, char **);
+
+int	 daemon(int, int);
+char	*devname(int, int);
+int	 getloadavg(double [], int);
+
+char	*group_from_gid(unsigned long, int);
+int	 heapsort(void *, size_t, size_t,
+	    int (*)(const void *, const void *));
+char	*initstate(unsigned long, char *, long);
+int	 mergesort(void *, size_t, size_t,
+	    int (*)(const void *, const void *));
+int	 radixsort(const unsigned char **, int, const unsigned char *,
+	    unsigned);
+int	 sradixsort(const unsigned char **, int, const unsigned char *,
+	    unsigned);
+long	 random(void);
+char	*realpath(const char *, char resolved_path[]);
+char	*setstate(char *);
+void	 srandom(unsigned long);
+char	*user_from_uid(unsigned long, int);
+#ifndef __STRICT_ANSI__
+long long
+	 strtoq(const char *, char **, int);
+unsigned long long
+	 strtouq(const char *, char **, int);
+#endif
+void	 unsetenv(const char *);
+#endif
+
+void	*malloc_r(size_t);
+void	 free_r(void *);
+
+const char *getprogname(void);
+
+__END_DECLS
+
+#endif /* _STDLIB_H_ */
diff --git a/prex-0.9.0/usr/include/string.h b/prex-0.9.0/usr/include/string.h
new file mode 100755
index 0000000..53bd5f8
--- /dev/null
+++ b/prex-0.9.0/usr/include/string.h
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)string.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _STRING_H_
+#define	_STRING_H_
+
+#if !defined(_SIZE_T)
+#define _SIZE_T
+typedef	unsigned int	size_t;		/* size of something in bytes */
+#endif
+
+#ifndef	NULL
+#define	NULL	0
+#endif
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void	*memchr(const void *, int, size_t);
+int	 memcmp(const void *, const void *, size_t);
+void	*memcpy(void *, const void *, size_t);
+void	*memmove(void *, const void *, size_t);
+void	*memset(void *, int, size_t);
+char	*strcat(char *, const char *);
+char	*strchr(const char *, int);
+int	 strcmp(const char *, const char *);
+int	 strcoll(const char *, const char *);
+char	*strcpy(char *, const char *);
+size_t	 strcspn(const char *, const char *);
+char	*strerror(int);
+size_t	 strlen(const char *);
+char	*strncat(char *, const char *, size_t);
+int	 strncmp(const char *, const char *, size_t);
+char	*strncpy(char *, const char *, size_t);
+char	*strpbrk(const char *, const char *);
+char	*strrchr(const char *, int);
+size_t	 strspn(const char *, const char *);
+char	*strstr(const char *, const char *);
+char	*strtok(char *, const char *);
+char	*strtok_r(char *, const char *, char **);
+size_t	 strxfrm(char *, const char *, size_t);
+
+/* Nonstandard routines */
+#ifndef _ANSI_SOURCE
+int	 bcmp(const void *, const void *, size_t);
+void	 bcopy(const void *, void *, size_t);
+void	 bzero(void *, size_t);
+int	 ffs(int);
+char	*index(const char *, int);
+void	*memccpy(void *, const void *, int, size_t);
+char	*rindex(const char *, int);
+int	 strcasecmp(const char *, const char *);
+char	*strdup(const char *);
+int	 strncasecmp(const char *, const char *, size_t);
+char	*strsep(char **, const char *);
+void	 swab(const void *, void *, size_t);
+#endif
+
+size_t	 strlcat(char *, const char *, size_t);
+size_t	 strlcpy(char *, const char *, size_t);
+__END_DECLS
+
+#endif /* _STRING_H_ */
diff --git a/prex-0.9.0/usr/include/termios.h b/prex-0.9.0/usr/include/termios.h
new file mode 100755
index 0000000..1da76d5
--- /dev/null
+++ b/prex-0.9.0/usr/include/termios.h
@@ -0,0 +1 @@
+#include <sys/termios.h>
diff --git a/prex-0.9.0/usr/include/time.h b/prex-0.9.0/usr/include/time.h
new file mode 100755
index 0000000..532142f
--- /dev/null
+++ b/prex-0.9.0/usr/include/time.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.3 (Berkeley) 1/21/94
+ */
+
+#ifndef _TIME_H_
+#define	_TIME_H_
+
+#include <sys/param.h>
+
+#ifndef	NULL
+#define	NULL	0
+#endif
+
+#if !defined(_CLOCK_T)
+#define _CLOCK_T
+typedef	unsigned long	clock_t;	/* relative time in a specified resolution */
+#endif
+
+#if !defined(_SIZE_T)
+#define _SIZE_T
+typedef	unsigned int	size_t;		/* size of something in bytes */
+#endif
+
+#if !defined(_TIME_T)
+#define _TIME_T
+typedef	long		time_t;		/* time of day in seconds */
+#endif
+
+struct tm {
+	int	tm_sec;		/* seconds after the minute [0-60] */
+	int	tm_min;		/* minutes after the hour [0-59] */
+	int	tm_hour;	/* hours since midnight [0-23] */
+	int	tm_mday;	/* day of the month [1-31] */
+	int	tm_mon;		/* months since January [0-11] */
+	int	tm_year;	/* years since 1900 */
+	int	tm_wday;	/* days since Sunday [0-6] */
+	int	tm_yday;	/* days since January 1 [0-365] */
+	int	tm_isdst;	/* Daylight Savings Time flag */
+};
+
+#define	CLK_TCK		HZ 	/* ticks per second */
+#define CLOCKS_PER_SEC	HZ	/* same with CLK_TCK */
+
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+char	*asctime(const struct tm *);
+clock_t	 clock(void);
+char	*ctime(const time_t *);
+double	 difftime(time_t, time_t);
+struct tm *gmtime(const time_t *);
+struct tm *localtime(const time_t *);
+time_t	 mktime(struct tm *);
+size_t	 strftime(char *, size_t, const char *, const struct tm *);
+time_t	 time(time_t *);
+
+char	 *asctime_r(const struct tm *, char *);
+struct tm *gmtime_r(const time_t *, struct tm *);
+struct tm *localtime_r(const time_t *, struct tm *);
+
+#ifndef _ANSI_SOURCE
+void	 tzset(void);
+#endif /* not ANSI */
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+char	*timezone(int, int);
+void	 tzsetwall(void);
+#endif /* neither ANSI nor POSIX */
+__END_DECLS
+
+#endif /* !_TIME_H_ */
diff --git a/prex-0.9.0/usr/include/tzfile.h b/prex-0.9.0/usr/include/tzfile.h
new file mode 100755
index 0000000..5600950
--- /dev/null
+++ b/prex-0.9.0/usr/include/tzfile.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Arthur David Olson of the National Cancer Institute.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)tzfile.h	8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _TZFILE_H_
+#define	_TZFILE_H_
+
+#define SECSPERMIN	60
+#define MINSPERHOUR	60
+#define HOURSPERDAY	24
+#define DAYSPERWEEK	7
+#define DAYSPERNYEAR	365
+#define DAYSPERLYEAR	366
+#define SECSPERHOUR	(SECSPERMIN * MINSPERHOUR)
+#define SECSPERDAY	((long) SECSPERHOUR * HOURSPERDAY)
+#define MONSPERYEAR	12
+
+#define TM_SUNDAY	0
+#define TM_MONDAY	1
+#define TM_TUESDAY	2
+#define TM_WEDNESDAY	3
+#define TM_THURSDAY	4
+#define TM_FRIDAY	5
+#define TM_SATURDAY	6
+
+#define TM_JANUARY	0
+#define TM_FEBRUARY	1
+#define TM_MARCH	2
+#define TM_APRIL	3
+#define TM_MAY		4
+#define TM_JUNE		5
+#define TM_JULY		6
+#define TM_AUGUST	7
+#define TM_SEPTEMBER	8
+#define TM_OCTOBER	9
+#define TM_NOVEMBER	10
+#define TM_DECEMBER	11
+
+#define TM_YEAR_BASE	1900
+
+#define EPOCH_YEAR	1970
+#define EPOCH_WDAY	TM_THURSDAY
+
+/*
+** Accurate only for the past couple of centuries;
+** that will probably do.
+*/
+
+#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
+
+#endif /* !_TZFILE_H_ */
diff --git a/prex-0.9.0/usr/include/unistd.h b/prex-0.9.0/usr/include/unistd.h
new file mode 100755
index 0000000..d350d5a
--- /dev/null
+++ b/prex-0.9.0/usr/include/unistd.h
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (c) 1991, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)unistd.h	8.12 (Berkeley) 4/27/95
+ */
+
+#ifndef _UNISTD_H_
+#define	_UNISTD_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#define	 STDIN_FILENO	0	/* standard input file descriptor */
+#define	STDOUT_FILENO	1	/* standard output file descriptor */
+#define	STDERR_FILENO	2	/* standard error file descriptor */
+
+#ifndef NULL
+#define	NULL		0	/* null pointer constant */
+#endif
+
+__BEGIN_DECLS
+int	 access(const char *, int);
+unsigned int	 alarm(unsigned int);
+int	 chdir(const char *);
+int	 chown(const char *, uid_t, gid_t);
+int	 close(int);
+size_t	 confstr(int, char *, size_t);
+int	 dup(int);
+int	 dup2(int, int);
+int	 execl(const char *, const char *, ...);
+int	 execle(const char *, const char *, ...);
+int	 execlp(const char *, const char *, ...);
+int	 execv(const char *, char * const *);
+int	 execve(const char *, char * const *, char * const *);
+int	 execvp(const char *, char * const *);
+void	_exit(int) __noreturn;
+/* pid_t	 fork(void); */
+pid_t	 vfork(void);
+/* long	 fpathconf(int, int); */
+char	*getcwd(char *, size_t);
+gid_t	 getegid(void);
+uid_t	 geteuid(void);
+gid_t	 getgid(void);
+/* int	 getgroups(int, gid_t []); */
+/* char	*getlogin(void); */
+pid_t	 getpgrp(void);
+pid_t	 getpid(void);
+pid_t	 getppid(void);
+uid_t	 getuid(void);
+int	 isatty(int);
+int	 link(const char *, const char *);
+off_t	 lseek(int, off_t, int);
+/* long	 pathconf(const char *, int); */
+int	 pause(void);
+int	 pipe(int *);
+ssize_t	 read(int, void *, size_t);
+int	 rmdir(const char *);
+int	 setgid(gid_t);
+int	 setpgid(pid_t, pid_t);
+pid_t	 setsid(void);
+int	 setuid(uid_t);
+unsigned int	 sleep(unsigned int);
+/* long	 sysconf(int); */
+pid_t	 tcgetpgrp(int);
+int	 tcsetpgrp(int, pid_t);
+/* char	*ttyname(int); */
+int	 unlink(const char *);
+ssize_t	 write(int, const void *, size_t);
+
+int	 getopt(int, char * const [], const char *);
+
+extern	 char *optarg;			/* getopt(3) external variables */
+extern	 int opterr;
+extern	 int optind;
+extern	 int optopt;
+
+#ifndef	_POSIX_SOURCE
+#ifdef	__STDC__
+struct timeval;				/* select(2) */
+#endif
+/* char	*brk(const char *); */
+/* int	 chroot(const char *); */
+int	 fchdir(int);
+/* int	 fchown(int, int, int); */
+int	 fsync(int);
+int	 ftruncate(int, off_t);
+/* int	 getdtablesize(void); */
+/* long	 gethostid(void); */
+int	 gethostname(char *, size_t);
+/* mode_t	 getmode(const void *, mode_t); */
+int	 getpagesize(void);
+char	*getpass(const char *);
+pid_t	 getpgid(pid_t);
+/* char	*getusershell(void); */
+char	*getwd(char *);			/* obsoleted by getcwd() */
+/* int	 initgroups(const char *, int); */
+/* int	 iruserok(unsigned long, int, const char *, const char *); */
+int	 mknod(const char *, mode_t, dev_t);
+int	 mkstemp(char *);
+char	*mktemp(char *);
+/* int	 nfssvc(int, void *); */
+int	 nice(int);
+void	 psignal(unsigned int, const char *);
+extern const char *const sys_siglist[];
+/* int	 readlink(const char *, char *, int); */
+/* int	 reboot(int); */
+/* int	 rresvport(int *); */
+/* int	 ruserok(const char *, int, const char *, const char *); */
+/* char	*sbrk(int); */
+/* int	 select(int, fd_set *, fd_set *, fd_set *, struct timeval *); */
+int	 setegid(gid_t);
+int	 seteuid(uid_t);
+/* int	 setgroups(int, const gid_t *); */
+/* void	 sethostid(long); */
+int	 sethostname(const char *, size_t);
+int	 setpgrp(pid_t, pid_t);	/* obsoleted by setpgid() */
+/* int	 setregid(gid_t, gid_t); */
+/* int	 setreuid(uid_t, uid_t); */
+/* int	 setrgid(gid_t); */
+/* int	 setruid(uid_t); */
+/* void	 setusershell(void); */
+/* int	 symlink(const char *, const char *); */
+void	 sync(void);
+int	 truncate(const char *, off_t);
+/* unsigned int	 ualarm(unsigned int, unsigned int); */
+void	 usleep(unsigned int);
+pid_t	 getsid(pid_t);
+void	 strmode(mode_t, char *);
+
+extern char *suboptarg;			/* getsubopt(3) external variable */
+int	 getsubopt(char **, char * const *, char **);
+#endif /* !_POSIX_SOURCE */
+
+void	 fslib_init(void);	/* used by Prex native task */
+void	 fslib_exit(void);	/* used by Prex native task */
+__END_DECLS
+
+/* configurable system strings */
+#define	_CS_PATH		 1
+
+#endif /* !_UNISTD_H_ */
diff --git a/prex-0.9.0/usr/lib/Makefile b/prex-0.9.0/usr/lib/Makefile
new file mode 100755
index 0000000..35f133e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/Makefile
@@ -0,0 +1,3 @@
+SUBDIR=	crt libsa libc
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/usr/lib/crt/Makefile b/prex-0.9.0/usr/lib/crt/Makefile
new file mode 100755
index 0000000..7ed9e82
--- /dev/null
+++ b/prex-0.9.0/usr/lib/crt/Makefile
@@ -0,0 +1,6 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	$(SRCDIR)/usr/lib/crt0.o
+SRCS:=		$(SRCDIR)/usr/arch/$(ARCH)/_crt0.S crt1.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/lib/crt/crt1.c b/prex-0.9.0/usr/lib/crt/crt1.c
new file mode 100755
index 0000000..d1e4992
--- /dev/null
+++ b/prex-0.9.0/usr/lib/crt/crt1.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * C start up routine.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern void __libc_init(void);
+extern int main(int argc, char *argv[], char *envp[]);
+
+void	 __prex_main(int, char **, char **);
+static char *_strrchr(char *, int);
+
+char	**environ;
+char	*__progname;
+
+void
+__prex_main(int argc, char *argv[], char *envp[])
+{
+	char *ap;
+
+	environ = envp;
+
+	if ((ap = argv[0])) {
+		if ((__progname = _strrchr(ap, '/')) == NULL)
+			__progname = ap;
+		else
+			++__progname;
+	}
+
+	__libc_init();
+
+	exit(main(argc, argv, envp));
+	/* NOTREACHED */
+}
+
+static char *
+_strrchr(char *p, int ch)
+{
+	char *save;
+
+	for (save = NULL;; ++p) {
+		if (*p == ch)
+			save = (char *)p;
+		if (!*p)
+			return(save);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/Makefile b/prex-0.9.0/usr/lib/libc/Makefile
new file mode 100755
index 0000000..0516254
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/Makefile
@@ -0,0 +1,16 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	$(SRCDIR)/usr/lib/libc.a
+
+include $(SRCDIR)/usr/lib/prex/Makefile.inc
+include $(SRCDIR)/usr/lib/posix/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/ctype/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/errno/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/gen/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/stdio/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/stdlib/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/string/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/termios/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/time/Makefile.inc
+
+include $(SRCDIR)/mk/lib.mk
diff --git a/prex-0.9.0/usr/lib/libc/ctype/Makefile.inc b/prex-0.9.0/usr/lib/libc/ctype/Makefile.inc
new file mode 100755
index 0000000..cd9ad78
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/Makefile.inc
@@ -0,0 +1,5 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/ctype:$(VPATH)
+
+SRCS+=	isalnum.c isalpha.c iscntrl.c isdigit.c isgraph.c islower.c \
+	isprint.c ispunct.c isspace.c isupper.c isxdigit.c isblank.c \
+	tolower.c toupper.c
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isalnum.c b/prex-0.9.0/usr/lib/libc/ctype/isalnum.c
new file mode 100755
index 0000000..656f21e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isalnum.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isalnum(int c)
+{
+	return (isalpha(c) || isdigit(c));
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isalpha.c b/prex-0.9.0/usr/lib/libc/ctype/isalpha.c
new file mode 100755
index 0000000..6379b2e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isalpha.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isalpha(int c)
+{
+	return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isblank.c b/prex-0.9.0/usr/lib/libc/ctype/isblank.c
new file mode 100755
index 0000000..2f018c6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isblank.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isblank(int c)
+{
+	return (c == ' ' || c == '\t');
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/iscntrl.c b/prex-0.9.0/usr/lib/libc/ctype/iscntrl.c
new file mode 100755
index 0000000..4a5b1c4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/iscntrl.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+iscntrl(int c)
+{
+	return (c == 127 || (c >= 0 && c <= 31));
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isdigit.c b/prex-0.9.0/usr/lib/libc/ctype/isdigit.c
new file mode 100755
index 0000000..58f00b2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isdigit.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isdigit(int c)
+{
+	return (c >= '0' && c <= '9');
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isgraph.c b/prex-0.9.0/usr/lib/libc/ctype/isgraph.c
new file mode 100755
index 0000000..f90e4af
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isgraph.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isgraph(int c)
+{
+	return (isprint(c) && c != ' ');
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/islower.c b/prex-0.9.0/usr/lib/libc/ctype/islower.c
new file mode 100755
index 0000000..91dfea2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/islower.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+islower(int c)
+{
+	return (c >= 'a' && c <= 'z');
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isprint.c b/prex-0.9.0/usr/lib/libc/ctype/isprint.c
new file mode 100755
index 0000000..b3bfaf5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isprint.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isprint(int c)
+{
+	return (c >= 0x20 && c <= 0x7E);
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/ispunct.c b/prex-0.9.0/usr/lib/libc/ctype/ispunct.c
new file mode 100755
index 0000000..e675dfc
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/ispunct.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+ispunct(int c)
+{
+	return (isprint(c) && !isspace(c) && !isalnum(c));
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isspace.c b/prex-0.9.0/usr/lib/libc/ctype/isspace.c
new file mode 100755
index 0000000..8bf310a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isspace.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isspace(int c)
+{
+	return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isupper.c b/prex-0.9.0/usr/lib/libc/ctype/isupper.c
new file mode 100755
index 0000000..a154406
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isupper.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isupper(int c)
+{
+	return (c >= 'A' && c <= 'Z');
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/isxdigit.c b/prex-0.9.0/usr/lib/libc/ctype/isxdigit.c
new file mode 100755
index 0000000..d7b1c75
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/isxdigit.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+isxdigit(int c)
+{
+	return (isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'));
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/tolower.c b/prex-0.9.0/usr/lib/libc/ctype/tolower.c
new file mode 100755
index 0000000..db04d9f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/tolower.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+tolower(int c)
+{
+
+	if (isupper(c))
+		return 'a' - 'A' + c;
+	return c;
+}
diff --git a/prex-0.9.0/usr/lib/libc/ctype/toupper.c b/prex-0.9.0/usr/lib/libc/ctype/toupper.c
new file mode 100755
index 0000000..9b22d7e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/ctype/toupper.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+
+int
+toupper(int c)
+{
+
+	if (islower(c))
+		return 'A' - 'a' + c;
+	return c;
+}
diff --git a/prex-0.9.0/usr/lib/libc/errno/Makefile.inc b/prex-0.9.0/usr/lib/libc/errno/Makefile.inc
new file mode 100755
index 0000000..390a587
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/errno/Makefile.inc
@@ -0,0 +1,3 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/errno:$(VPATH)
+
+SRCS+=	errno.c errlst.c
diff --git a/prex-0.9.0/usr/lib/libc/errno/errlst.c b/prex-0.9.0/usr/lib/libc/errno/errlst.c
new file mode 100755
index 0000000..1099510
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/errno/errlst.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1982, 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+const char *const sys_errlist[] = {
+	"Undefined error: 0",			/*  0 - ENOERROR */
+	"Operation not permitted",		/*  1 - EPERM */
+	"No such file or directory",		/*  2 - ENOENT */
+	"No such process",			/*  3 - ESRCH */
+	"Interrupted system call",		/*  4 - EINTR */
+	"Input/output error",			/*  5 - EIO */
+	"Device not configured",		/*  6 - ENXIO */
+	"Argument list too long",		/*  7 - E2BIG */
+	"Exec format error",			/*  8 - ENOEXEC */
+	"Bad file descriptor",			/*  9 - EBADF */
+	"No child processes",			/* 10 - ECHILD */
+	"Resource deadlock avoided",		/* 11 - EDEADLK */
+	"Cannot allocate memory",		/* 12 - ENOMEM */
+	"Permission denied",			/* 13 - EACCES */
+	"Bad address",				/* 14 - EFAULT */
+	"Block device required",		/* 15 - ENOTBLK */
+	"Device busy",				/* 16 - EBUSY */
+	"File exists",				/* 17 - EEXIST */
+	"Cross-device link",			/* 18 - EXDEV */
+	"Operation not supported by device",	/* 19 - ENODEV */
+	"Not a directory",			/* 20 - ENOTDIR */
+	"Is a directory",			/* 21 - EISDIR */
+	"Invalid argument",			/* 22 - EINVAL */
+	"Too many open files in system",	/* 23 - ENFILE */
+	"Too many open files",			/* 24 - EMFILE */
+	"Inappropriate ioctl for device",	/* 25 - ENOTTY */
+	"Text file busy",			/* 26 - ETXTBSY */
+	"File too large",			/* 27 - EFBIG */
+	"No space left on device",		/* 28 - ENOSPC */
+	"Illegal seek",				/* 29 - ESPIPE */
+	"Read-only file system",		/* 30 - EROFS */
+	"Too many links",			/* 31 - EMLINK */
+	"Broken pipe",				/* 32 - EPIPE */
+
+/* math software */
+	"Numerical argument out of domain",	/* 33 - EDOM */
+	"Result too large",			/* 34 - ERANGE */
+
+/* non-blocking and interrupt i/o */
+	"Resource temporarily unavailable",	/* 35 - EAGAIN */
+
+	"Operation timed out",			/* 36 - ETIMEDOUT */
+	"File name too long",			/* 37 - ENAMETOOLONG */
+	"Directory not empty",			/* 38 - ENOTEMPTY */
+
+/* quotas & mush */
+	"Too many processes",			/* 39 - EPROCLIM */
+	"Function not implemented",		/* 40 - ENOSYS */
+};
+const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]);
diff --git a/prex-0.9.0/usr/lib/libc/errno/errno.c b/prex-0.9.0/usr/lib/libc/errno/errno.c
new file mode 100755
index 0000000..9eaed24
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/errno/errno.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+int errno;
diff --git a/prex-0.9.0/usr/lib/libc/gen/Makefile.inc b/prex-0.9.0/usr/lib/libc/gen/Makefile.inc
new file mode 100755
index 0000000..3fab2f5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/Makefile.inc
@@ -0,0 +1,11 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/gen:$(VPATH)
+
+SRCS+=	__libc_init.c assert.c \
+	$(SRCDIR)/usr/arch/$(ARCH)/setjmp.c \
+	execl.c execlp.c execle.c execv.c execvp.c \
+	time.c basename.c dirname.c \
+	gethostname.c sethostname.c \
+	err.c errx.c verr.c verrx.c \
+	warn.c warnx.c vwarn.c vwarnx.c \
+	getpagesize.c confstr.c getpass.c \
+	getprogname.c setprogname.c fts.c
diff --git a/prex-0.9.0/usr/lib/libc/gen/__libc_init.c b/prex-0.9.0/usr/lib/libc/gen/__libc_init.c
new file mode 100755
index 0000000..8fd0dab
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/__libc_init.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+extern void __posix_init(void);
+
+void	 __libc_init(void);
+
+void
+__libc_init(void)
+{
+	__posix_init();
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/assert.c b/prex-0.9.0/usr/lib/libc/gen/assert.c
new file mode 100755
index 0000000..55ad093
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/assert.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void
+__assert(file, line, failedexpr)
+	const char *file, *failedexpr;
+	int line;
+{
+	(void)fprintf(stderr,
+	    "assertion \"%s\" failed: file \"%s\", line %d\n",
+	    failedexpr, file, line);
+	abort();
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/basename.c b/prex-0.9.0/usr/lib/libc/gen/basename.c
new file mode 100755
index 0000000..f1756c6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/basename.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <libgen.h>
+#include <string.h>
+#include <sys/param.h>
+
+char *
+basename(const char *path)
+{
+        static char bname[MAXPATHLEN];
+        size_t len;
+        const char *endp, *startp;
+
+        /* Empty or NULL string gets treated as "." */
+        if (path == NULL || *path == '\0') {
+                bname[0] = '.';
+                bname[1] = '\0';
+                return (bname);
+        }
+
+        /* Strip any trailing slashes */
+        endp = path + strlen(path) - 1;
+        while (endp > path && *endp == '/')
+                endp--;
+
+        /* All slashes becomes "/" */
+        if (endp == path && *endp == '/') {
+                bname[0] = '/';
+                bname[1] = '\0';
+                return (bname);
+        }
+
+        /* Find the start of the base */
+        startp = endp;
+        while (startp > path && *(startp - 1) != '/')
+                startp--;
+
+        len = endp - startp + 1;
+        if (len >= sizeof(bname)) {
+                errno = ENAMETOOLONG;
+                return (NULL);
+        }
+        memcpy(bname, startp, len);
+        bname[len] = '\0';
+        return (bname);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/confstr.c b/prex-0.9.0/usr/lib/libc/gen/confstr.c
new file mode 100755
index 0000000..e094041
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/confstr.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <string.h>
+#include <paths.h>
+#include <unistd.h>
+#include <errno.h>
+
+size_t
+confstr(name, buf, len)
+	int name;
+	char *buf;
+	size_t len;
+{
+	switch (name) {
+	case _CS_PATH:
+		if (len != 0 && buf != NULL) {
+			strncpy(buf, _PATH_DEFPATH, sizeof(_PATH_DEFPATH));
+		}
+		return sizeof(_PATH_DEFPATH);
+	default:
+		errno = EINVAL;
+		return (0);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/dirname.c b/prex-0.9.0/usr/lib/libc/gen/dirname.c
new file mode 100755
index 0000000..247da84
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/dirname.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <libgen.h>
+#include <string.h>
+#include <sys/param.h>
+
+char *
+dirname(const char *path)
+{
+        static char dname[MAXPATHLEN];
+        size_t len;
+        const char *endp;
+
+        /* Empty or NULL string gets treated as "." */
+        if (path == NULL || *path == '\0') {
+                dname[0] = '.';
+                dname[1] = '\0';
+                return (dname);
+        }
+
+        /* Strip any trailing slashes */
+        endp = path + strlen(path) - 1;
+        while (endp > path && *endp == '/')
+                endp--;
+
+        /* Find the start of the dir */
+        while (endp > path && *endp != '/')
+                endp--;
+
+        /* Either the dir is "/" or there are no slashes */
+        if (endp == path) {
+                dname[0] = *endp == '/' ? '/' : '.';
+                dname[1] = '\0';
+                return (dname);
+        } else {
+                /* Move forward past the separating slashes */
+                do {
+                        endp--;
+                } while (endp > path && *endp == '/');
+        }
+
+        len = endp - path + 1;
+        if (len >= sizeof(dname)) {
+                errno = ENAMETOOLONG;
+                return (NULL);
+        }
+        memcpy(dname, path, len);
+        dname[len] = '\0';
+        return (dname);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/err.c b/prex-0.9.0/usr/lib/libc/gen/err.c
new file mode 100755
index 0000000..2096763
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/err.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <err.h>
+#include <stdarg.h>
+
+void
+err(int eval, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	verr(eval, fmt, ap);
+	va_end(ap);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/errx.c b/prex-0.9.0/usr/lib/libc/gen/errx.c
new file mode 100755
index 0000000..3a316a9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/errx.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <err.h>
+#include <stdarg.h>
+
+void
+errx(int eval, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	verrx(eval, fmt, ap);
+	va_end(ap);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/execl.c b/prex-0.9.0/usr/lib/libc/gen/execl.c
new file mode 100755
index 0000000..b3a0f15
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/execl.c
@@ -0,0 +1,67 @@
+/*	$NetBSD: execl.c,v 1.11 2003/08/07 16:42:47 agc Exp $	*/
+
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern char **environ;
+
+int
+execl(const char *name, const char *arg, ...)
+{
+	int r;
+#if defined(__x86__)
+	r = execve(name, (char **) &arg, environ);
+	return (r);
+#else
+	va_list ap;
+	char **argv;
+	int i;
+
+	va_start(ap, arg);
+	for (i = 2; va_arg(ap, char *) != NULL; i++)
+		;
+	va_end(ap);
+
+	argv = alloca (i * sizeof (char *));
+
+	va_start(ap, arg);
+	argv[0] = (char *) arg;
+	for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
+		;
+	va_end(ap);
+
+	r = execve(name, argv, environ);
+	return (r);
+#endif
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/execle.c b/prex-0.9.0/usr/lib/libc/gen/execle.c
new file mode 100755
index 0000000..4d78669
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/execle.c
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+execle(const char *name, const char *arg, ...)
+{
+#if defined(__x86__)
+	va_list ap;
+	char **envp;
+
+	va_start(ap, arg);
+	while ((va_arg(ap, char *)) != NULL)
+		continue;
+	envp = va_arg(ap, char **);
+	va_end(ap);
+
+	return execve(name, (char **) &arg, envp);
+#else
+	va_list ap;
+	char **argv, **envp;
+	int i;
+
+	va_start(ap, arg);
+	for (i = 2; va_arg(ap, char *) != NULL; i++)
+		continue;
+	va_end(ap);
+
+	argv = alloca (i * sizeof (char *));
+
+	va_start(ap, arg);
+	argv[0] = (char *) arg;
+	for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
+		;
+	envp = (char **) va_arg(ap, char **);
+	va_end(ap);
+
+	return execve(name, argv, envp);
+#endif
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/execlp.c b/prex-0.9.0/usr/lib/libc/gen/execlp.c
new file mode 100755
index 0000000..c576184
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/execlp.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+execlp(const char *name, const char *arg, ...)
+{
+#if defined(__x86__)
+	return execvp(name, (char **) &arg);
+#else
+	va_list ap;
+	char **argv;
+	int i;
+
+	va_start(ap, arg);
+	for (i = 2; va_arg(ap, char *) != NULL; i++)
+		;
+	va_end(ap);
+
+	argv = alloca (i * sizeof (char *));
+
+	va_start(ap, arg);
+	argv[0] = (char *) arg;
+	for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++)
+		;
+	va_end(ap);
+
+	return execvp(name, argv);
+#endif
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/execv.c b/prex-0.9.0/usr/lib/libc/gen/execv.c
new file mode 100755
index 0000000..10f9735
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/execv.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <unistd.h>
+
+extern char **environ;
+
+int
+execv(name, argv)
+	const char *name;
+	char * const *argv;
+{
+	int r;
+
+	r = execve(name, argv, environ);
+	return (r);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/execvp.c b/prex-0.9.0/usr/lib/libc/gen/execvp.c
new file mode 100755
index 0000000..29bc52d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/execvp.c
@@ -0,0 +1,130 @@
+/*-
+ * Copyright (c) 1991, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <paths.h>
+#include <unistd.h>
+
+extern char **environ;
+
+int
+execvp(const char *name, char * const *argv)
+{
+	const char **memp;
+	int cnt;
+	size_t lp, ln = 0;
+	int eacces = 0;
+	unsigned int etxtbsy = 0;
+	char buf[PATH_MAX];
+	const char *bp, *path, *p;
+
+	/* "" is not a valid filename; check this before traversing PATH. */
+	if (name[0] == '\0') {
+		errno = ENOENT;
+		goto done;
+	}
+	/* If it's an absolute or relative path name, it's easy. */
+	if (strchr(name, '/')) {
+		bp = name;
+		path = "";
+		goto retry;
+	}
+	bp = buf;
+
+	/* Get the path we're searching. */
+	if (!(path = getenv("PATH")))
+		path = _PATH_DEFPATH;
+
+	ln = strlen(name);
+	do {
+		/* Find the end of this path element. */
+		for (p = path; *path != 0 && *path != ':'; path++)
+			continue;
+		/*
+		 * It's a SHELL path -- double, leading and trailing colons
+		 * mean the current directory.
+		 */
+		if (p == path) {
+			p = ".";
+			lp = 1;
+		} else
+			lp = path - p;
+
+		/*
+		 * If the path is too long complain.  This is a possible
+		 * security issue; given a way to make the path too long
+		 * the user may execute the wrong program.
+		 */
+		if (lp + ln + 2 > sizeof(buf))
+			continue;
+		memcpy(buf, p, lp);
+		buf[lp] = '/';
+		memcpy(buf + lp + 1, name, ln);
+		buf[lp + ln + 1] = '\0';
+
+retry:		(void)execve(bp, argv, environ);
+		switch (errno) {
+		case EACCES:
+			eacces = 1;
+			break;
+		case ENOTDIR:
+		case ENOENT:
+			break;
+		case ENOEXEC:
+			for (cnt = 0; argv[cnt] != NULL; ++cnt)
+				continue;
+			if ((memp = (const char **)(alloca((cnt + 2) * sizeof(*memp)))) == NULL)
+				goto done;
+			memp[0] = _PATH_BSHELL;
+			memp[1] = bp;
+			(void)memcpy(&memp[2], &argv[1], cnt * sizeof(*memp));
+			(void)execve(_PATH_BSHELL, (char * const *)memp,
+			    environ);
+			goto done;
+		case ETXTBSY:
+			if (etxtbsy < 3)
+				(void)sleep(++etxtbsy);
+			goto retry;
+		default:
+			goto done;
+		}
+	} while (*path++ == ':');	/* Otherwise, *path was NUL */
+	if (eacces)
+		errno = EACCES;
+	else if (!errno)
+		errno = ENOENT;
+done:
+	return (-1);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/fts.c b/prex-0.9.0/usr/lib/libc/gen/fts.c
new file mode 100755
index 0000000..36d6c99
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/fts.c
@@ -0,0 +1,971 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <fts.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static FTSENT	*fts_alloc(FTS *, char *, int);
+static FTSENT	*fts_build(FTS *, int);
+static void	 fts_lfree(FTSENT *);
+static void	 fts_load(FTS *, FTSENT *);
+static size_t	 fts_maxarglen(char * const *);
+static void	 fts_padjust(FTS *, void *);
+static int	 fts_palloc(FTS *, size_t);
+static FTSENT	*fts_sort(FTS *, FTSENT *, int);
+static u_short	 fts_stat(FTS *, FTSENT *, int);
+
+
+#define ALIGNBYTES 7
+
+
+#define	ISDOT(a)	(a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
+
+#define	ISSET(opt)	(sp->fts_options & (opt))
+#define	SET(opt)	(sp->fts_options |= (opt))
+
+#define	CHDIR(sp, path)	(!ISSET(FTS_NOCHDIR) && chdir(path))
+#define	FCHDIR(sp, fd)	(!ISSET(FTS_NOCHDIR) && fchdir(fd))
+
+/* fts_build flags */
+#define	BCHILD		1		/* fts_children */
+#define	BNAMES		2		/* fts_children, names only */
+#define	BREAD		3		/* fts_read */
+
+FTS *
+fts_open(char * const *argv, int options,
+    int (*compar)(const FTSENT **, const FTSENT **))
+{
+	FTS *sp;
+	FTSENT *p, *root;
+	int nitems;
+	FTSENT *parent, *tmp = NULL;
+	int len;
+
+	/* Options check. */
+	if (options & ~FTS_OPTIONMASK) {
+		errno = EINVAL;
+		return (NULL);
+	}
+
+	/* Allocate/initialize the stream */
+	if ((sp = malloc((u_int)sizeof(FTS))) == NULL)
+		return (NULL);
+	memset(sp, 0, sizeof(FTS));
+	sp->fts_compar = compar;
+	sp->fts_options = options;
+
+	/* Logical walks turn on NOCHDIR; symbolic links are too hard. */
+	if (ISSET(FTS_LOGICAL))
+		SET(FTS_NOCHDIR);
+
+	/*
+	 * Start out with 1K of path space, and enough, in any case,
+	 * to hold the user's paths.
+	 */
+	if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN)))
+		goto mem1;
+
+	/* Allocate/initialize root's parent. */
+	if ((parent = fts_alloc(sp, "", 0)) == NULL)
+		goto mem2;
+	parent->fts_level = FTS_ROOTPARENTLEVEL;
+
+	/* Allocate/initialize root(s). */
+	for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) {
+		/* Don't allow zero-length paths. */
+		if ((len = strlen(*argv)) == 0) {
+			errno = ENOENT;
+			goto mem3;
+		}
+
+		p = fts_alloc(sp, *argv, len);
+		p->fts_level = FTS_ROOTLEVEL;
+		p->fts_parent = parent;
+		p->fts_accpath = p->fts_name;
+		p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW));
+
+		/* Command-line "." and ".." are real directories. */
+		if (p->fts_info == FTS_DOT)
+			p->fts_info = FTS_D;
+
+		/*
+		 * If comparison routine supplied, traverse in sorted
+		 * order; otherwise traverse in the order specified.
+		 */
+		if (compar) {
+			p->fts_link = root;
+			root = p;
+		} else {
+			p->fts_link = NULL;
+			if (root == NULL)
+				tmp = root = p;
+			else {
+				tmp->fts_link = p;
+				tmp = p;
+			}
+		}
+	}
+	if (compar && nitems > 1)
+		root = fts_sort(sp, root, nitems);
+
+	/*
+	 * Allocate a dummy pointer and make fts_read think that we've just
+	 * finished the node before the root(s); set p->fts_info to FTS_INIT
+	 * so that everything about the "current" node is ignored.
+	 */
+	if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL)
+		goto mem3;
+	sp->fts_cur->fts_link = root;
+	sp->fts_cur->fts_info = FTS_INIT;
+
+	/*
+	 * If using chdir(2), grab a file descriptor pointing to dot to insure
+	 * that we can get back here; this could be avoided for some paths,
+	 * but almost certainly not worth the effort.  Slashes, symbolic links,
+	 * and ".." are all fairly nasty problems.  Note, if we can't get the
+	 * descriptor we run anyway, just more slowly.
+	 */
+	if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0)
+		SET(FTS_NOCHDIR);
+
+	return (sp);
+
+mem3:	fts_lfree(root);
+	free(parent);
+mem2:	free(sp->fts_path);
+mem1:	free(sp);
+	return (NULL);
+}
+
+static void
+fts_load(FTS *sp, FTSENT *p)
+{
+	int len;
+	char *cp;
+
+	/*
+	 * Load the stream structure for the next traversal.  Since we don't
+	 * actually enter the directory until after the preorder visit, set
+	 * the fts_accpath field specially so the chdir gets done to the right
+	 * place and the user can access the first node.  From fts_open it's
+	 * known that the path will fit.
+	 */
+	len = p->fts_pathlen = p->fts_namelen;
+	memmove(sp->fts_path, p->fts_name, len + 1);
+	if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
+		len = strlen(++cp);
+		memmove(p->fts_name, cp, len + 1);
+		p->fts_namelen = len;
+	}
+	p->fts_accpath = p->fts_path = sp->fts_path;
+	sp->fts_dev = p->fts_dev;
+}
+
+int
+fts_close(FTS *sp)
+{
+	FTSENT *freep, *p;
+	int saved_errno = 0;
+
+	/*
+	 * This still works if we haven't read anything -- the dummy structure
+	 * points to the root list, so we step through to the end of the root
+	 * list which has a valid parent pointer.
+	 */
+	if (sp->fts_cur) {
+		for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
+			freep = p;
+			p = p->fts_link ? p->fts_link : p->fts_parent;
+			free(freep);
+		}
+		free(p);
+	}
+
+	/* Free up child linked list, sort array, path buffer. */
+	if (sp->fts_child)
+		fts_lfree(sp->fts_child);
+	if (sp->fts_array)
+		free(sp->fts_array);
+	free(sp->fts_path);
+
+	/* Return to original directory, save errno if necessary. */
+	if (!ISSET(FTS_NOCHDIR)) {
+		saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
+		(void)close(sp->fts_rfd);
+	}
+
+	/* Free up the stream pointer. */
+	free(sp);
+
+	/* Set errno and return. */
+	if (!ISSET(FTS_NOCHDIR) && saved_errno) {
+		errno = saved_errno;
+		return (-1);
+	}
+	return (0);
+}
+
+/*
+ * Special case a root of "/" so that slashes aren't appended which would
+ * cause paths to be written as "//foo".
+ */
+#define	NAPPEND(p)							\
+	(p->fts_level == FTS_ROOTLEVEL && p->fts_pathlen == 1 &&	\
+	    p->fts_path[0] == '/' ? 0 : p->fts_pathlen)
+
+FTSENT *
+fts_read(FTS *sp)
+{
+	FTSENT *p, *tmp;
+	int instr;
+	char *t;
+	int saved_errno;
+
+	/* If finished or unrecoverable error, return NULL. */
+	if (sp->fts_cur == NULL || ISSET(FTS_STOP))
+		return (NULL);
+
+	/* Set current node pointer. */
+	p = sp->fts_cur;
+
+	/* Save and zero out user instructions. */
+	instr = p->fts_instr;
+	p->fts_instr = FTS_NOINSTR;
+
+	/* Any type of file may be re-visited; re-stat and re-turn. */
+	if (instr == FTS_AGAIN) {
+		p->fts_info = fts_stat(sp, p, 0);
+		return (p);
+	}
+
+	/*
+	 * Following a symlink -- SLNONE test allows application to see
+	 * SLNONE and recover.  If indirecting through a symlink, have
+	 * keep a pointer to current location.  If unable to get that
+	 * pointer, follow fails.
+	 */
+	if (instr == FTS_FOLLOW &&
+	    (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
+		p->fts_info = fts_stat(sp, p, 1);
+		if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
+			if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) {
+				p->fts_errno = errno;
+				p->fts_info = FTS_ERR;
+			} else
+				p->fts_flags |= FTS_SYMFOLLOW;
+		}
+		return (p);
+	}
+
+	/* Directory in pre-order. */
+	if (p->fts_info == FTS_D) {
+		/* If skipped or crossed mount point, do post-order visit. */
+		if (instr == FTS_SKIP ||
+		    (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) {
+			if (p->fts_flags & FTS_SYMFOLLOW)
+				(void)close(p->fts_symfd);
+			if (sp->fts_child) {
+				fts_lfree(sp->fts_child);
+				sp->fts_child = NULL;
+			}
+			p->fts_info = FTS_DP;
+			return (p);
+		} 
+
+		/* Rebuild if only read the names and now traversing. */
+		if (sp->fts_child && sp->fts_options & FTS_NAMEONLY) {
+			sp->fts_options &= ~FTS_NAMEONLY;
+			fts_lfree(sp->fts_child);
+			sp->fts_child = NULL;
+		}
+
+		/*
+		 * Cd to the subdirectory.
+		 *
+		 * If have already read and now fail to chdir, whack the list
+		 * to make the names come out right, and set the parent errno
+		 * so the application will eventually get an error condition.
+		 * Set the FTS_DONTCHDIR flag so that when we logically change
+		 * directories back to the parent we don't do a chdir.
+		 *
+		 * If haven't read do so.  If the read fails, fts_build sets
+		 * FTS_STOP or the fts_info field of the node.
+		 */
+		if (sp->fts_child) {
+			if (CHDIR(sp, p->fts_accpath)) {
+				p->fts_errno = errno;
+				p->fts_flags |= FTS_DONTCHDIR;
+				for (p = sp->fts_child; p; p = p->fts_link)
+					p->fts_accpath =
+					    p->fts_parent->fts_accpath;
+			}
+		} else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) {
+			if (ISSET(FTS_STOP))
+				return (NULL);
+			return (p);
+		}
+		p = sp->fts_child;
+		sp->fts_child = NULL;
+		goto name;
+	}
+
+	/* Move to the next node on this level. */
+next:	tmp = p;
+	if ((p = p->fts_link) != NULL) {
+		free(tmp);
+
+		/*
+		 * If reached the top, return to the original directory, and
+		 * load the paths for the next root.
+		 */
+		if (p->fts_level == FTS_ROOTLEVEL) {
+			if (!ISSET(FTS_NOCHDIR) && FCHDIR(sp, sp->fts_rfd)) {
+				SET(FTS_STOP);
+				return (NULL);
+			}
+			fts_load(sp, p);
+			return (sp->fts_cur = p);
+		}
+
+		/*
+		 * User may have called fts_set on the node.  If skipped,
+		 * ignore.  If followed, get a file descriptor so we can
+		 * get back if necessary.
+		 */
+		if (p->fts_instr == FTS_SKIP)
+			goto next;
+		if (p->fts_instr == FTS_FOLLOW) {
+			p->fts_info = fts_stat(sp, p, 1);
+			if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
+				if ((p->fts_symfd =
+				    open(".", O_RDONLY, 0)) < 0) {
+					p->fts_errno = errno;
+					p->fts_info = FTS_ERR;
+				} else
+					p->fts_flags |= FTS_SYMFOLLOW;
+			}
+			p->fts_instr = FTS_NOINSTR;
+		}
+
+name:		t = sp->fts_path + NAPPEND(p->fts_parent);
+		*t++ = '/';
+		memmove(t, p->fts_name, p->fts_namelen + 1);
+		return (sp->fts_cur = p);
+	}
+
+	/* Move up to the parent node. */
+	p = tmp->fts_parent;
+	free(tmp);
+
+	if (p->fts_level == FTS_ROOTPARENTLEVEL) {
+		/*
+		 * Done; free everything up and set errno to 0 so the user
+		 * can distinguish between error and EOF.
+		 */
+		free(p);
+		errno = 0;
+		return (sp->fts_cur = NULL);
+	}
+
+	/* Nul terminate the pathname. */
+	sp->fts_path[p->fts_pathlen] = '\0';
+
+	/*
+	 * Return to the parent directory.  If at a root node or came through
+	 * a symlink, go back through the file descriptor.  Otherwise, cd up
+	 * one directory.
+	 */
+	if (p->fts_level == FTS_ROOTLEVEL) {
+		if (!ISSET(FTS_NOCHDIR) && FCHDIR(sp, sp->fts_rfd)) {
+			SET(FTS_STOP);
+			return (NULL);
+		}
+	} else if (p->fts_flags & FTS_SYMFOLLOW) {
+		if (FCHDIR(sp, p->fts_symfd)) {
+			saved_errno = errno;
+			(void)close(p->fts_symfd);
+			errno = saved_errno;
+			SET(FTS_STOP);
+			return (NULL);
+		}
+		(void)close(p->fts_symfd);
+	} else if (!(p->fts_flags & FTS_DONTCHDIR)) {
+		if (CHDIR(sp, "..")) {
+			SET(FTS_STOP);
+			return (NULL);
+		}
+	}
+	p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
+	return (sp->fts_cur = p);
+}
+
+/*
+ * Fts_set takes the stream as an argument although it's not used in this
+ * implementation; it would be necessary if anyone wanted to add global
+ * semantics to fts using fts_set.  An error return is allowed for similar
+ * reasons.
+ */
+/* ARGSUSED */
+int
+fts_set(FTS *sp, FTSENT *p, int instr)
+{
+	if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
+	    instr != FTS_NOINSTR && instr != FTS_SKIP) {
+		errno = EINVAL;
+		return (1);
+	}
+	p->fts_instr = instr;
+	return (0);
+}
+
+FTSENT *
+fts_children(FTS *sp, int instr)
+{
+	FTSENT *p;
+	int fd;
+
+	if (instr && instr != FTS_NAMEONLY) {
+		errno = EINVAL;
+		return (NULL);
+	}
+
+	/* Set current node pointer. */
+	p = sp->fts_cur;
+
+	/*
+	 * Errno set to 0 so user can distinguish empty directory from
+	 * an error.
+	 */
+	errno = 0;
+
+	/* Fatal errors stop here. */
+	if (ISSET(FTS_STOP))
+		return (NULL);
+
+	/* Return logical hierarchy of user's arguments. */
+	if (p->fts_info == FTS_INIT)
+		return (p->fts_link);
+
+	/*
+	 * If not a directory being visited in pre-order, stop here.  Could
+	 * allow FTS_DNR, assuming the user has fixed the problem, but the
+	 * same effect is available with FTS_AGAIN.
+	 */
+	if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */)
+		return (NULL);
+
+	/* Free up any previous child list. */
+	if (sp->fts_child)
+		fts_lfree(sp->fts_child);
+
+	if (instr == FTS_NAMEONLY) {
+		sp->fts_options |= FTS_NAMEONLY;
+		instr = BNAMES;
+	} else 
+		instr = BCHILD;
+
+	/*
+	 * If using chdir on a relative path and called BEFORE fts_read does
+	 * its chdir to the root of a traversal, we can lose -- we need to
+	 * chdir into the subdirectory, and we don't know where the current
+	 * directory is, so we can't get back so that the upcoming chdir by
+	 * fts_read will work.
+	 */
+	if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' ||
+	    ISSET(FTS_NOCHDIR))
+		return (sp->fts_child = fts_build(sp, instr));
+
+	if ((fd = open(".", O_RDONLY, 0)) < 0)
+		return (NULL);
+	sp->fts_child = fts_build(sp, instr);
+	if (fchdir(fd))
+		return (NULL);
+	(void)close(fd);
+	return (sp->fts_child);
+}
+
+/*
+ * This is the tricky part -- do not casually change *anything* in here.  The
+ * idea is to build the linked list of entries that are used by fts_children
+ * and fts_read.  There are lots of special cases.
+ *
+ * The real slowdown in walking the tree is the stat calls.  If FTS_NOSTAT is
+ * set and it's a physical walk (so that symbolic links can't be directories),
+ * we can do things quickly.  First, if it's a 4.4BSD file system, the type
+ * of the file is in the directory entry.  Otherwise, we assume that the number
+ * of subdirectories in a node is equal to the number of links to the parent.
+ * The former skips all stat calls.  The latter skips stat calls in any leaf
+ * directories and for any files after the subdirectories in the directory have
+ * been found, cutting the stat calls by about 2/3.
+ */
+static FTSENT *
+fts_build(FTS *sp, int type)
+{
+	struct dirent *dp;
+	FTSENT *p, *head;
+	int nitems;
+	FTSENT *cur, *tail;
+	DIR *dirp;
+	void *adjaddr;
+	int cderrno, descend, len, level, maxlen, nlinks, saved_errno;
+#ifdef FTS_WHITEOUT
+	int oflag;
+#endif
+	char *cp = NULL;	/* pacify gcc */
+
+	/* Set current node pointer. */
+	cur = sp->fts_cur;
+
+	/*
+	 * Open the directory for reading.  If this fails, we're done.
+	 * If being called from fts_read, set the fts_info field.
+	 */
+#ifdef FTS_WHITEOUT
+	if (ISSET(FTS_WHITEOUT))
+		oflag = DTF_NODUP|DTF_REWIND;
+	else
+		oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND;
+#else
+#define __opendir2(path, flag) opendir(path)
+#endif
+	if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) {
+		if (type == BREAD) {
+			cur->fts_info = FTS_DNR;
+			cur->fts_errno = errno;
+		}
+		return (NULL);
+	}
+
+	/*
+	 * Nlinks is the number of possible entries of type directory in the
+	 * directory if we're cheating on stat calls, 0 if we're not doing
+	 * any stat calls at all, -1 if we're doing stats on everything.
+	 */
+	if (type == BNAMES)
+		nlinks = 0;
+	else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL))
+		nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2);
+	else
+		nlinks = -1;
+
+#ifdef notdef
+	(void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink);
+	(void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n",
+	    ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT));
+#endif
+	/*
+	 * If we're going to need to stat anything or we want to descend
+	 * and stay in the directory, chdir.  If this fails we keep going,
+	 * but set a flag so we don't chdir after the post-order visit.
+	 * We won't be able to stat anything, but we can still return the
+	 * names themselves.  Note, that since fts_read won't be able to
+	 * chdir into the directory, it will have to return different path
+	 * names than before, i.e. "a/b" instead of "b".  Since the node
+	 * has already been visited in pre-order, have to wait until the
+	 * post-order visit to return the error.  There is a special case
+	 * here, if there was nothing to stat then it's not an error to
+	 * not be able to stat.  This is all fairly nasty.  If a program
+	 * needed sorted entries or stat information, they had better be
+	 * checking FTS_NS on the returned nodes.
+	 */
+	cderrno = 0;
+	if (nlinks || type == BREAD)
+		if (FCHDIR(sp, dirfd(dirp))) {
+			if (nlinks && type == BREAD)
+				cur->fts_errno = errno;
+			cur->fts_flags |= FTS_DONTCHDIR;
+			descend = 0;
+			cderrno = errno;
+		} else
+			descend = 1;
+	else
+		descend = 0;
+
+	/*
+	 * Figure out the max file name length that can be stored in the
+	 * current path -- the inner loop allocates more path as necessary.
+	 * We really wouldn't have to do the maxlen calculations here, we
+	 * could do them in fts_read before returning the path, but it's a
+	 * lot easier here since the length is part of the dirent structure.
+	 *
+	 * If not changing directories set a pointer so that can just append
+	 * each new name into the path.
+	 */
+	maxlen = sp->fts_pathlen - cur->fts_pathlen - 1;
+	len = NAPPEND(cur);
+	if (ISSET(FTS_NOCHDIR)) {
+		cp = sp->fts_path + len;
+		*cp++ = '/';
+	}
+
+	level = cur->fts_level + 1;
+
+	/* Read the directory, attaching each entry to the `link' pointer. */
+	adjaddr = NULL;
+	for (head = tail = NULL, nitems = 0; (dp = readdir(dirp)) != NULL;) {
+
+		if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
+			continue;
+
+		if ((p = fts_alloc(sp, dp->d_name, (int)dp->d_namlen)) == NULL)
+			goto mem1;
+		if (dp->d_namlen > maxlen) {
+			if (fts_palloc(sp, (size_t)dp->d_namlen)) {
+				/*
+				 * No more memory for path or structures.  Save
+				 * errno, free up the current structure and the
+				 * structures already allocated.
+				 */
+mem1:				saved_errno = errno;
+				if (p)
+					free(p);
+				fts_lfree(head);
+				(void)closedir(dirp);
+				errno = saved_errno;
+				cur->fts_info = FTS_ERR;
+				SET(FTS_STOP);
+				return (NULL);
+			}
+			adjaddr = sp->fts_path;
+			maxlen = sp->fts_pathlen - sp->fts_cur->fts_pathlen - 1;
+		}
+
+		p->fts_pathlen = len + dp->d_namlen + 1;
+		p->fts_parent = sp->fts_cur;
+		p->fts_level = level;
+
+#ifdef FTS_WHITEOUT
+		if (dp->d_type == DT_WHT)
+			p->fts_flags |= FTS_ISW;
+#endif
+
+		if (cderrno) {
+			if (nlinks) {
+				p->fts_info = FTS_NS;
+				p->fts_errno = cderrno;
+			} else
+				p->fts_info = FTS_NSOK;
+			p->fts_accpath = cur->fts_accpath;
+		} else if (nlinks == 0
+#ifdef DT_DIR
+		    || (nlinks > 0 && 
+			dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)
+#endif
+		    ) {
+			p->fts_accpath =
+			    ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name;
+			p->fts_info = FTS_NSOK;
+		} else {
+			/* Build a file name for fts_stat to stat. */
+			if (ISSET(FTS_NOCHDIR)) {
+				p->fts_accpath = p->fts_path;
+				memmove(cp, p->fts_name, p->fts_namelen + 1);
+			} else
+				p->fts_accpath = p->fts_name;
+			/* Stat it. */
+			p->fts_info = fts_stat(sp, p, 0);
+
+			/* Decrement link count if applicable. */
+			if (nlinks > 0 && (p->fts_info == FTS_D ||
+			    p->fts_info == FTS_DC || p->fts_info == FTS_DOT))
+				--nlinks;
+		}
+
+		/* We walk in directory order so "ls -f" doesn't get upset. */
+		p->fts_link = NULL;
+		if (head == NULL)
+			head = tail = p;
+		else {
+			tail->fts_link = p;
+			tail = p;
+		}
+		++nitems;
+	}
+	(void)closedir(dirp);
+
+	/*
+	 * If had to realloc the path, adjust the addresses for the rest
+	 * of the tree.
+	 */
+	if (adjaddr)
+		fts_padjust(sp, adjaddr);
+
+	/*
+	 * If not changing directories, reset the path back to original
+	 * state.
+	 */
+	if (ISSET(FTS_NOCHDIR)) {
+		if (cp - 1 > sp->fts_path)
+			--cp;
+		*cp = '\0';
+	}
+
+	/*
+	 * If descended after called from fts_children or after called from
+	 * fts_read and nothing found, get back.  At the root level we use
+	 * the saved fd; if one of fts_open()'s arguments is a relative path
+	 * to an empty directory, we wind up here with no other way back.  If
+	 * can't get back, we're done.
+	 */
+	if (descend && (type == BCHILD || !nitems) &&
+	    (cur->fts_level == FTS_ROOTLEVEL ?
+	    FCHDIR(sp, sp->fts_rfd) : CHDIR(sp, ".."))) {
+		cur->fts_info = FTS_ERR;
+		SET(FTS_STOP);
+		return (NULL);
+	}
+
+	/* If didn't find anything, return NULL. */
+	if (!nitems) {
+		if (type == BREAD)
+			cur->fts_info = FTS_DP;
+		return (NULL);
+	}
+
+	/* Sort the entries. */
+	if (sp->fts_compar && nitems > 1)
+		head = fts_sort(sp, head, nitems);
+	return (head);
+}
+
+static u_short
+fts_stat(FTS *sp, FTSENT *p, int follow)
+{
+	FTSENT *t;
+	dev_t dev;
+	ino_t ino;
+	struct stat *sbp, sb;
+	int saved_errno;
+
+	/* If user needs stat info, stat buffer already allocated. */
+	sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
+
+#ifdef FTS_WHITEOUT
+	/* check for whiteout */
+	if (p->fts_flags & FTS_ISW) {
+		if (sbp != &sb) {
+			memset(sbp, '\0', sizeof (*sbp));
+			sbp->st_mode = S_IFWHT;
+		}
+		return (FTS_W);
+	}
+#endif
+	
+	/*
+	 * If doing a logical walk, or application requested FTS_FOLLOW, do
+	 * a stat(2).  If that fails, check for a non-existent symlink.  If
+	 * fail, set the errno from the stat call.
+	 */
+	if (ISSET(FTS_LOGICAL) || follow) {
+		if (stat(p->fts_accpath, sbp)) {
+			saved_errno = errno;
+			if (!lstat(p->fts_accpath, sbp)) {
+				errno = 0;
+				return (FTS_SLNONE);
+			} 
+			p->fts_errno = saved_errno;
+			goto err;
+		}
+	} else if (lstat(p->fts_accpath, sbp)) {
+		p->fts_errno = errno;
+err:		memset(sbp, 0, sizeof(struct stat));
+		return (FTS_NS);
+	}
+
+	if (S_ISDIR(sbp->st_mode)) {
+		/*
+		 * Set the device/inode.  Used to find cycles and check for
+		 * crossing mount points.  Also remember the link count, used
+		 * in fts_build to limit the number of stat calls.  It is
+		 * understood that these fields are only referenced if fts_info
+		 * is set to FTS_D.
+		 */
+		dev = p->fts_dev = sbp->st_dev;
+		ino = p->fts_ino = sbp->st_ino;
+		p->fts_nlink = sbp->st_nlink;
+
+		if (ISDOT(p->fts_name))
+			return (FTS_DOT);
+
+		/*
+		 * Cycle detection is done by brute force when the directory
+		 * is first encountered.  If the tree gets deep enough or the
+		 * number of symbolic links to directories is high enough,
+		 * something faster might be worthwhile.
+		 */
+		for (t = p->fts_parent;
+		    t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent)
+			if (ino == t->fts_ino && dev == t->fts_dev) {
+				p->fts_cycle = t;
+				return (FTS_DC);
+			}
+		return (FTS_D);
+	}
+	if (S_ISLNK(sbp->st_mode))
+		return (FTS_SL);
+	if (S_ISREG(sbp->st_mode))
+		return (FTS_F);
+	return (FTS_DEFAULT);
+}
+
+static FTSENT *
+fts_sort(FTS *sp, FTSENT *head, int nitems)
+{
+	FTSENT **ap, *p;
+
+	/*
+	 * Construct an array of pointers to the structures and call qsort(3).
+	 * Reassemble the array in the order returned by qsort.  If unable to
+	 * sort for memory reasons, return the directory entries in their
+	 * current order.  Allocate enough space for the current needs plus
+	 * 40 so don't realloc one entry at a time.
+	 */
+	if (nitems > sp->fts_nitems) {
+		sp->fts_nitems = nitems + 40;
+		if ((sp->fts_array = realloc(sp->fts_array,
+		    (size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {
+			sp->fts_nitems = 0;
+			return (head);
+		}
+	}
+	for (ap = sp->fts_array, p = head; p; p = p->fts_link)
+		*ap++ = p;
+	qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *),
+		(int (*)(const void *, const void *))sp->fts_compar);
+
+	for (head = *(ap = sp->fts_array); --nitems; ++ap)
+		ap[0]->fts_link = ap[1];
+	ap[0]->fts_link = NULL;
+	return (head);
+}
+
+static FTSENT *
+fts_alloc(FTS *sp, char *name, int namelen)
+{
+	FTSENT *p;
+	size_t len;
+
+	/*
+	 * The file name is a variable length array and no stat structure is
+	 * necessary if the user has set the nostat bit.  Allocate the FTSENT
+	 * structure, the file name and the stat structure in one chunk, but
+	 * be careful that the stat structure is reasonably aligned.  Since the
+	 * fts_name field is declared to be of size 1, the fts_name pointer is
+	 * namelen + 2 before the first possible address of the stat structure.
+	 */
+	len = sizeof(FTSENT) + namelen;
+	if (!ISSET(FTS_NOSTAT))
+		len += sizeof(struct stat) + ALIGNBYTES;
+	if ((p = malloc(len)) == NULL)
+		return (NULL);
+
+	/* Copy the name plus the trailing NULL. */
+	memmove(p->fts_name, name, namelen + 1);
+
+	if (!ISSET(FTS_NOSTAT))
+		p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
+	p->fts_namelen = namelen;
+	p->fts_path = sp->fts_path;
+	p->fts_errno = 0;
+	p->fts_flags = 0;
+	p->fts_instr = FTS_NOINSTR;
+	p->fts_number = 0;
+	p->fts_pointer = NULL;
+	return (p);
+}
+
+static void
+fts_lfree(FTSENT *head)
+{
+	FTSENT *p;
+
+	/* Free a linked list of structures. */
+	while ((p = head) != NULL) {
+		head = head->fts_link;
+		free(p);
+	}
+}
+
+/*
+ * Allow essentially unlimited paths; find, rm, ls should all work on any tree.
+ * Most systems will allow creation of paths much longer than MAXPATHLEN, even
+ * though the kernel won't resolve them.  Add the size (not just what's needed)
+ * plus 256 bytes so don't realloc the path 2 bytes at a time. 
+ */
+static int
+fts_palloc(FTS *sp, size_t more)
+{
+	sp->fts_pathlen += more + 256;
+	sp->fts_path = realloc(sp->fts_path, (size_t)sp->fts_pathlen);
+	return (sp->fts_path == NULL);
+}
+
+/*
+ * When the path is realloc'd, have to fix all of the pointers in structures
+ * already returned.
+ */
+static void
+fts_padjust(FTS *sp, void *addr)
+{
+	FTSENT *p;
+
+#define	ADJUST(p) {							\
+	(p)->fts_accpath =						\
+	    (char *)addr + ((p)->fts_accpath - (p)->fts_path);		\
+	(p)->fts_path = addr;						\
+}
+	/* Adjust the current set of children. */
+	for (p = sp->fts_child; p; p = p->fts_link)
+		ADJUST(p);
+
+	/* Adjust the rest of the tree. */
+	for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
+		ADJUST(p);
+		p = p->fts_link ? p->fts_link : p->fts_parent;
+	}
+}
+
+static size_t
+fts_maxarglen(char * const *argv)
+{
+	size_t len, max;
+
+	for (max = 0; *argv; ++argv)
+		if ((len = strlen(*argv)) > max)
+			max = len;
+	return (max);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/gethostname.c b/prex-0.9.0/usr/lib/libc/gen/gethostname.c
new file mode 100755
index 0000000..c189fc8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/gethostname.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/utsname.h>
+#include <string.h>
+#include <errno.h>
+
+int
+gethostname(char *name, size_t namelen)
+{
+	struct utsname uts;
+
+	uname(&uts);
+	strcpy(name, uts.nodename);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/getpagesize.c b/prex-0.9.0/usr/lib/libc/gen/getpagesize.c
new file mode 100755
index 0000000..aff0417
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/getpagesize.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+
+int
+getpagesize(void)
+{
+	return PAGE_SIZE;
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/getpass.c b/prex-0.9.0/usr/lib/libc/gen/getpass.c
new file mode 100755
index 0000000..eecdb58
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/getpass.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* modified for Prex by Kohsuke Ohtani. */
+
+#include <sys/termios.h>
+#include <signal.h>
+#include <paths.h>
+#include <stdio.h>
+#include <unistd.h>
+
+char *
+getpass(const char *prompt)
+{
+	struct termios term;
+	register int ch;
+	register char *p;
+	FILE *fp, *outfp;
+	long omask;
+	int echo;
+	static char buf[PASSWORD_LEN + 2];
+
+	/*
+	 * read and write to /dev/tty if possible; else read from
+	 * stdin and write to stderr.
+	 */
+	if ((outfp = fp = fopen(_PATH_TTY, "w+")) == NULL) {
+		outfp = stderr;
+		fp = stdin;
+	}
+	/*
+	 * note - blocking signals isn't necessarily the
+	 * right thing, but we leave it for now.
+	 */
+	omask = sigblock(sigmask(SIGINT)|sigmask(SIGTSTP));
+	(void)tcgetattr(fileno(fp), &term);
+	if ((echo = (term.c_lflag & ECHO)) != 0) {
+		term.c_lflag &= ~ECHO;
+		(void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &term);
+	}
+	(void)fputs(prompt, outfp);
+	rewind(outfp);			/* implied flush */
+	for (p = buf; (ch = getc(fp)) != EOF && ch != '\n';) {
+		if (p < buf + PASSWORD_LEN + 1)
+			*p++ = ch;
+	}
+	*p = '\0';
+	(void)write(fileno(outfp), "\n", 1);
+	if (echo) {
+		term.c_lflag |= ECHO;
+		(void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &term);
+	}
+	(void)sigsetmask(omask);
+	if (fp != stdin)
+		(void)fclose(fp);
+	return(buf);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/getprogname.c b/prex-0.9.0/usr/lib/libc/gen/getprogname.c
new file mode 100755
index 0000000..b9e46e5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/getprogname.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+extern const char *__progname;
+
+const char *
+getprogname(void)
+{
+
+	return (__progname);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/sethostname.c b/prex-0.9.0/usr/lib/libc/gen/sethostname.c
new file mode 100755
index 0000000..05daf47
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/sethostname.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <sys/param.h>
+#include <sys/types.h>
+
+int
+sethostname(const char *name, size_t namelen)
+{
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/setprogname.c b/prex-0.9.0/usr/lib/libc/gen/setprogname.c
new file mode 100755
index 0000000..b78f150
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/setprogname.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+void
+setprogname(const char *progname)
+{
+
+	/* DO NOTHING */
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/time.c b/prex-0.9.0/usr/lib/libc/gen/time.c
new file mode 100755
index 0000000..064e858
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/time.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <time.h>
+
+time_t
+time(t)
+	time_t *t;
+{
+	struct timeval tt;
+
+	if (gettimeofday(&tt, (struct timezone *)0) < 0)
+		return ((time_t)-1);
+	if (t != NULL)
+		*t = tt.tv_sec;
+	return (tt.tv_sec);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/verr.c b/prex-0.9.0/usr/lib/libc/gen/verr.c
new file mode 100755
index 0000000..6b08adb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/verr.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+void
+verr(eval, fmt, ap)
+	int eval;
+	const char *fmt;
+	va_list ap;
+
+{
+	int sverrno;
+
+	sverrno = errno;
+	if (fmt != NULL) {
+		vfprintf(stderr, fmt, ap);
+		fprintf(stderr, ": ");
+	}
+	fprintf(stderr, "%s\n", strerror(sverrno));
+	exit(eval);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/verrx.c b/prex-0.9.0/usr/lib/libc/gen/verrx.c
new file mode 100755
index 0000000..ad8a8bb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/verrx.c
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+void
+verrx(eval, fmt, ap)
+	int eval;
+	const char *fmt;
+	va_list ap;
+{
+	if (fmt != NULL)
+		vfprintf(stderr, fmt, ap);
+	fprintf(stderr, "\n");
+	exit(eval);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/vwarn.c b/prex-0.9.0/usr/lib/libc/gen/vwarn.c
new file mode 100755
index 0000000..ac67e0f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/vwarn.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+void
+vwarn(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+	int sverrno;
+
+	sverrno = errno;
+	if (fmt != NULL) {
+		vfprintf(stderr, fmt, ap);
+		fprintf(stderr, ": ");
+	}
+	fprintf(stderr, "%s\n", strerror(sverrno));
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/vwarnx.c b/prex-0.9.0/usr/lib/libc/gen/vwarnx.c
new file mode 100755
index 0000000..ec2050d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/vwarnx.c
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+void
+vwarnx(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+	if (fmt != NULL)
+		vfprintf(stderr, fmt, ap);
+	fprintf(stderr, "\n");
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/warn.c b/prex-0.9.0/usr/lib/libc/gen/warn.c
new file mode 100755
index 0000000..59e8ccb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/warn.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdarg.h>
+
+void
+warn(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vwarn(fmt, ap);
+	va_end(ap);
+}
diff --git a/prex-0.9.0/usr/lib/libc/gen/warnx.c b/prex-0.9.0/usr/lib/libc/gen/warnx.c
new file mode 100755
index 0000000..fb1241c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/gen/warnx.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <err.h>
+#include <stdarg.h>
+
+void
+warnx(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vwarnx(fmt, ap);
+	va_end(ap);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/Makefile.inc b/prex-0.9.0/usr/lib/libc/stdio/Makefile.inc
new file mode 100755
index 0000000..65630a5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/Makefile.inc
@@ -0,0 +1,13 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/stdio:$(VPATH)
+
+SRCS+=	clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \
+	fgetpos.c fgets.c fileno.c findfp.c flags.c fopen.c \
+	fprintf.c fpurge.c fputc.c fputs.c fread.c freopen.c fscanf.c \
+	fseek.c fsetpos.c ftell.c fvwrite.c fwalk.c fwrite.c \
+	getc.c getchar.c gets.c getw.c makebuf.c mktemp.c \
+	printf.c putc.c putchar.c puts.c putw.c refill.c remove.c rewind.c \
+	scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c \
+	sscanf.c stdio.c ungetc.c vfprintf.c \
+	vfscanf.c vprintf.c vscanf.c vsnprintf.c vsprintf.c vsscanf.c \
+	wsetup.c \
+	perror.c tmpfile.c tmpnam.c tempnam.c
diff --git a/prex-0.9.0/usr/lib/libc/stdio/clrerr.c b/prex-0.9.0/usr/lib/libc/stdio/clrerr.c
new file mode 100755
index 0000000..632b660
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/clrerr.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#undef	clearerr
+
+void
+clearerr(fp)
+	FILE *fp;
+{
+	__sclearerr(fp);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fclose.c b/prex-0.9.0/usr/lib/libc/stdio/fclose.c
new file mode 100755
index 0000000..9ef2ebf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fclose.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+int
+fclose(fp)
+	FILE *fp;
+{
+	int r;
+
+	if (fp->_flags == 0) {	/* not open! */
+		errno = EBADF;
+		return (EOF);
+	}
+	r = fp->_flags & __SWR ? __sflush(fp) : 0;
+	if (__sclose(fp) < 0)
+		r = EOF;
+	if (fp->_flags & __SMBF)
+		free((char *)fp->_bf._base);
+	if (HASUB(fp))
+		FREEUB(fp);
+	fp->_flags = 0;		/* Release this FILE for reuse. */
+	fp->_r = fp->_w = 0;	/* Mess up if reaccessed. */
+	return (r);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fdopen.c b/prex-0.9.0/usr/lib/libc/stdio/fdopen.c
new file mode 100755
index 0000000..d9954b2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fdopen.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include "local.h"
+
+FILE *
+fdopen(fd, mode)
+	int fd;
+	const char *mode;
+{
+	FILE *fp;
+	int flags, oflags, fdflags, tmp;
+
+	if ((flags = __sflags(mode, &oflags)) == 0)
+		return (NULL);
+
+	/* Make sure the mode the user wants is a subset of the actual mode. */
+	if ((fdflags = fcntl(fd, F_GETFL, 0)) < 0)
+		return (NULL);
+	tmp = fdflags & O_ACCMODE;
+	if (tmp != O_RDWR && (tmp != (oflags & O_ACCMODE))) {
+		errno = EINVAL;
+		return (NULL);
+	}
+
+	if ((fp = __sfp()) == NULL)
+		return (NULL);
+	fp->_flags = flags;
+	/*
+	 * If opened for appending, but underlying descriptor does not have
+	 * O_APPEND bit set, assert __SAPP so that __swrite() will lseek to
+	 * end before each write.
+	 */
+	if ((oflags & O_APPEND) && !(fdflags & O_APPEND))
+		fp->_flags |= __SAPP;
+	fp->_file = fd;
+	return (fp);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/feof.c b/prex-0.9.0/usr/lib/libc/stdio/feof.c
new file mode 100755
index 0000000..7da3c43
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/feof.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include "local.h"
+
+/*
+ * A subroutine version of the macro feof.
+ */
+#undef feof
+
+int
+feof(fp)
+	FILE *fp;
+{
+	return (__sfeof(fp));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/ferror.c b/prex-0.9.0/usr/lib/libc/stdio/ferror.c
new file mode 100755
index 0000000..36319d0
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/ferror.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+/*
+ * A subroutine version of the macro ferror.
+ */
+#undef ferror
+
+int
+ferror(fp)
+	FILE *fp;
+{
+	return (__sferror(fp));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fflush.c b/prex-0.9.0/usr/lib/libc/stdio/fflush.c
new file mode 100755
index 0000000..ef7f978
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fflush.c
@@ -0,0 +1,83 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include "local.h"
+
+/* Flush a single file, or (if fp is NULL) all files.  */
+int
+fflush(fp)
+	FILE *fp;
+{
+
+	if (fp == NULL)
+		return (_fwalk(__sflush));
+	if ((fp->_flags & (__SWR | __SRW)) == 0) {
+		errno = EBADF;
+		return (EOF);
+	}
+	return (__sflush(fp));
+}
+
+int
+__sflush(fp)
+	FILE *fp;
+{
+	unsigned char *p;
+	int n, t;
+
+	t = fp->_flags;
+	if ((t & __SWR) == 0)
+		return (0);
+
+	if ((p = fp->_bf._base) == NULL)
+		return (0);
+
+	n = fp->_p - p;		/* write this much */
+
+	/*
+	 * Set these immediately to avoid problems with longjmp and to allow
+	 * exchange buffering (via setvbuf) in user write function.
+	 */
+	fp->_p = p;
+	fp->_w = t & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
+
+	for (; n > 0; n -= t, p += t) {
+		t = __swrite(fp, (char *)p, n);
+		if (t <= 0) {
+			fp->_flags |= __SERR;
+			return (EOF);
+		}
+	}
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fgetc.c b/prex-0.9.0/usr/lib/libc/stdio/fgetc.c
new file mode 100755
index 0000000..6d1b790
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fgetc.c
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+fgetc(fp)
+	FILE *fp;
+{
+	return (getc(fp));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fgetpos.c b/prex-0.9.0/usr/lib/libc/stdio/fgetpos.c
new file mode 100755
index 0000000..44a785d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fgetpos.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+fgetpos(fp, pos)
+	FILE *fp;
+	fpos_t *pos;
+{
+	return((*pos = (fpos_t)ftell(fp)) == (fpos_t)-1);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fgets.c b/prex-0.9.0/usr/lib/libc/stdio/fgets.c
new file mode 100755
index 0000000..be5797b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fgets.c
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "local.h"
+
+/*
+ * Read at most n-1 characters from the given file.
+ * Stop when a newline has been read, or the count runs out.
+ * Return first argument, or NULL if no characters were read.
+ */
+char *
+fgets(buf, n, fp)
+	char *buf;
+	size_t n;
+	FILE *fp;
+{
+	int c = -1;
+	char *s;
+
+	s = buf;
+	while (--n > 0 && (c = getc(fp)) >= 0) {
+		*s++ = c;
+		if (c == '\n')
+			break;
+	}
+	if (c < 0 && s == buf)
+		return (NULL);
+	*s++ = 0;
+	return (buf);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fileno.c b/prex-0.9.0/usr/lib/libc/stdio/fileno.c
new file mode 100755
index 0000000..59d8c50
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fileno.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+/*
+ * A subroutine version of the macro fileno.
+ */
+#undef fileno
+
+int
+fileno(fp)
+	FILE *fp;
+{
+	return (__sfileno(fp));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/findfp.c b/prex-0.9.0/usr/lib/libc/stdio/findfp.c
new file mode 100755
index 0000000..27a53d3
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/findfp.c
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include "local.h"
+
+int	__sdidinit;
+FILE __sF[3];
+
+static void
+std(FILE *fp, FILE *next, short flags, short fileno)
+{
+
+	memset(fp, 0, sizeof(FILE));
+	fp->next = next;
+	fp->_flags = flags;
+	fp->_file = fileno;
+}
+
+/*
+ * Find a free FILE for fopen et al.
+ */
+FILE *
+__sfp()
+{
+	FILE *fp, *tmp;
+
+	if (!__sdidinit)
+		__sinit();
+	for (fp = &__sF[0];; fp = fp->next) {
+		if (fp->_flags == 0)
+			goto found;
+		if (fp->next == NULL) {
+			if ((tmp = malloc(sizeof(FILE))) == NULL)
+				break;
+			fp->next = tmp;
+			fp = tmp;
+			goto found;
+		}
+	}
+	return (NULL);
+found:
+	std(fp, NULL, 1, -1);
+	return (fp);
+}
+
+/*
+ * exit() calls _cleanup() through *__cleanup, set whenever we
+ * open or buffer a file.  This chicanery is done so that programs
+ * that do not use stdio need not link it all in.
+ *
+ * The name `_cleanup' is, alas, fairly well known outside stdio.
+b */
+void
+_cleanup()
+{
+	/* (void) _fwalk(fclose); */
+	(void) _fwalk(__sflush);		/* `cheating' */
+}
+
+/*
+ * __sinit() is called whenever stdio's internal variables must be set up.
+ */
+void
+__sinit()
+{
+
+	std(&__sF[0], &__sF[1], __SRD, STDIN_FILENO);
+	std(&__sF[1], &__sF[2], __SWR, STDOUT_FILENO);
+	std(&__sF[2], NULL, __SWR|__SNBF, STDERR_FILENO);
+
+	/* make sure we clean up on exit */
+	__cleanup = _cleanup;		/* conservative */
+	__sdidinit = 1;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/flags.c b/prex-0.9.0/usr/lib/libc/stdio/flags.c
new file mode 100755
index 0000000..95c4cab
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/flags.c
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+
+/*
+ * Return the (stdio) flags for a given mode.  Store the flags
+ * to be passed to an open() syscall through *optr.
+ * Return 0 on error.
+ */
+int
+__sflags(char *mode, int *optr)
+{
+	int ret, m, o;
+
+	switch (*mode++) {
+
+	case 'r':	/* open for reading */
+		ret = __SRD;
+		m = O_RDONLY;
+		o = 0;
+		break;
+
+	case 'w':	/* open for writing */
+		ret = __SWR;
+		m = O_WRONLY;
+		o = O_CREAT | O_TRUNC;
+		break;
+
+	case 'a':	/* open for appending */
+		ret = __SWR;
+		m = O_WRONLY;
+		o = O_CREAT | O_APPEND;
+		break;
+
+	default:	/* illegal mode */
+		errno = EINVAL;
+		return (0);
+	}
+
+	/* [rwa]\+ or [rwa]b\+ means read and write */
+	if (*mode == '+' || (*mode == 'b' && mode[1] == '+')) {
+		ret = __SRW;
+		m = O_RDWR;
+	}
+	*optr = m | o;
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fopen.c b/prex-0.9.0/usr/lib/libc/stdio/fopen.c
new file mode 100755
index 0000000..ec9c0c5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fopen.c
@@ -0,0 +1,71 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include "local.h"
+
+FILE *
+fopen(file, mode)
+	const char *file;
+	const char *mode;
+{
+	FILE *fp;
+	int f;
+	int flags, oflags;
+
+	if ((flags = __sflags(mode, &oflags)) == 0)
+		return (NULL);
+	if ((fp = __sfp()) == NULL)
+		return (NULL);
+	if ((f = open(file, oflags, DEFFILEMODE)) < 0) {
+		fp->_flags = 0;			/* release */
+		return (NULL);
+	}
+	fp->_file = f;
+	fp->_flags = flags;
+
+	/*
+	 * When opening in append mode, even though we use O_APPEND,
+	 * we need to seek to the end so that ftell() gets the right
+	 * answer.  If the user then alters the seek pointer, or
+	 * the file extends, this will fail, but there is not much
+	 * we can do about this.  (We could set __SAPP and check in
+	 * fseek and ftell.)
+	 */
+	if (oflags & O_APPEND)
+		(void) __sseek((void *)fp, (fpos_t)0, SEEK_END);
+	return (fp);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fprintf.c b/prex-0.9.0/usr/lib/libc/stdio/fprintf.c
new file mode 100755
index 0000000..6e226c0
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fprintf.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+fprintf(FILE *fp, const char *fmt, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, fmt);
+	ret = vfprintf(fp, fmt, ap);
+	va_end(ap);
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fpurge.c b/prex-0.9.0/usr/lib/libc/stdio/fpurge.c
new file mode 100755
index 0000000..3c64d9f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fpurge.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+/*
+ * fpurge: like fflush, but without writing anything: leave the
+ * given FILE's buffer empty.
+ */
+int
+fpurge(fp)
+	FILE *fp;
+{
+	if (!fp->_flags) {
+		errno = EBADF;
+		return(EOF);
+	}
+
+	if (HASUB(fp))
+		FREEUB(fp);
+	fp->_p = fp->_bf._base;
+	fp->_r = 0;
+	fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fputc.c b/prex-0.9.0/usr/lib/libc/stdio/fputc.c
new file mode 100755
index 0000000..0f54acf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fputc.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+fputc(c, fp)
+	int c;
+	FILE *fp;
+{
+	return (putc(c, fp));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fputs.c b/prex-0.9.0/usr/lib/libc/stdio/fputs.c
new file mode 100755
index 0000000..9807c4e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fputs.c
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+/*
+ * Write the given string to the given file.
+ */
+int
+fputs(s, fp)
+	const char *s;
+	FILE *fp;
+{
+	int c, r = 0;
+
+	while ((c = *s++) != '\0')
+		r = putc(c, fp);
+	return(r);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fread.c b/prex-0.9.0/usr/lib/libc/stdio/fread.c
new file mode 100755
index 0000000..6284037
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fread.c
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "local.h"
+
+size_t
+fread(buf, size, count, fp)
+	void *buf;
+	size_t size, count;
+	FILE *fp;
+{
+	size_t resid;
+	char *p;
+	int r;
+	size_t total;
+
+	/*
+	 * The ANSI standard requires a return value of 0 for a count
+	 * or a size of 0.  Peculiarily, it imposes no such requirements
+	 * on fwrite; it only requires fread to be broken.
+	 */
+	if ((resid = count * size) == 0)
+		return (0);
+	if (fp->_r < 0)
+		fp->_r = 0;
+	total = resid;
+	p = buf;
+	while (resid > (size_t)(r = fp->_r)) {
+		(void)memcpy((void *)p, (void *)fp->_p, (size_t)r);
+		fp->_p += r;
+		/* fp->_r = 0 ... done in __srefill */
+		p += r;
+		resid -= r;
+		if (__srefill(fp)) {
+			/* no more input: return partial result */
+			return ((total - resid) / size);
+		}
+	}
+	(void)memcpy((void *)p, (void *)fp->_p, resid);
+	fp->_r -= resid;
+	fp->_p += resid;
+	return (count);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/freopen.c b/prex-0.9.0/usr/lib/libc/stdio/freopen.c
new file mode 100755
index 0000000..9ef6017
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/freopen.c
@@ -0,0 +1,138 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+/*
+ * Re-direct an existing, open (probably) file to some other file.
+ * ANSI is written such that the original file gets closed if at
+ * all possible, no matter what.
+ */
+FILE *
+freopen(file, mode, fp)
+	const char *file, *mode;
+	FILE *fp;
+{
+	int f;
+	int flags, isopen, oflags, sverrno, wantfd;
+
+	if ((flags = __sflags(mode, &oflags)) == 0) {
+		(void) fclose(fp);
+		return (NULL);
+	}
+
+	if (!__sdidinit)
+		__sinit();
+
+	/*
+	 * There are actually programs that depend on being able to "freopen"
+	 * descriptors that weren't originally open.  Keep this from breaking.
+	 * Remember whether the stream was open to begin with, and which file
+	 * descriptor (if any) was associated with it.  If it was attached to
+	 * a descriptor, defer closing it; freopen("/dev/stdin", "r", stdin)
+	 * should work.  This is unnecessary if it was not a Unix file.
+	 */
+	if (fp->_flags == 0) {
+		fp->_flags = __SEOF;	/* hold on to it */
+		isopen = 0;
+		wantfd = -1;
+	} else {
+		/* flush the stream; ANSI doesn't require this. */
+		if (fp->_flags & __SWR)
+			(void) __sflush(fp);
+		/* if close is NULL, closing is a no-op, hence pointless */
+		isopen = 1;
+		if ((wantfd = fp->_file) < 0 && isopen) {
+			(void) __sclose(fp);
+			isopen = 0;
+		}
+	}
+
+	/* Get a new descriptor to refer to the new file. */
+	f = open(file, oflags, DEFFILEMODE);
+	if (f < 0 && isopen) {
+		/* If out of fd's close the old one and try again. */
+		if (errno == ENFILE || errno == EMFILE) {
+			(void) __sclose(fp);
+			isopen = 0;
+			f = open(file, oflags, DEFFILEMODE);
+		}
+	}
+	sverrno = errno;
+
+	/*
+	 * Finish closing fp.  Even if the open succeeded above, we cannot
+	 * keep fp->_base: it may be the wrong size.  This loses the effect
+	 * of any setbuffer calls, but stdio has always done this before.
+	 */
+	if (isopen)
+		(void) __sclose(fp);
+	if (fp->_flags & __SMBF)
+		free((char *)fp->_bf._base);
+	fp->_w = 0;
+	fp->_r = 0;
+	fp->_p = NULL;
+	fp->_bf._base = NULL;
+	fp->_bf._size = 0;
+	if (HASUB(fp))
+		FREEUB(fp);
+	fp->_ub._size = 0;
+
+	if (f < 0) {			/* did not get it after all */
+		fp->_flags = 0;		/* set it free */
+		errno = sverrno;	/* restore in case _close clobbered */
+		return (NULL);
+	}
+
+	/*
+	 * If reopening something that was open before on a real file, try
+	 * to maintain the descriptor.  Various C library routines (perror)
+	 * assume stderr is always fd STDERR_FILENO, even if being freopen'd.
+	 */
+	if (wantfd >= 0 && f != wantfd) {
+		if (dup2(f, wantfd) >= 0) {
+			(void) close(f);
+			f = wantfd;
+		}
+	}
+
+	fp->_flags = flags;
+	fp->_file = f;
+	return (fp);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fscanf.c b/prex-0.9.0/usr/lib/libc/stdio/fscanf.c
new file mode 100755
index 0000000..c791a41
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fscanf.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+fscanf(FILE *fp, char const *fmt, ...) {
+	int ret;
+	va_list ap;
+
+	va_start(ap, fmt);
+	ret = __svfscanf(fp, fmt, ap);
+	va_end(ap);
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fseek.c b/prex-0.9.0/usr/lib/libc/stdio/fseek.c
new file mode 100755
index 0000000..8172406
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fseek.c
@@ -0,0 +1,113 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "local.h"
+
+#define	POS_ERR	(-(fpos_t)1)
+
+/*
+ * Seek the given file to the given offset.
+ * `Whence' must be one of the three SEEK_* macros.
+ */
+int
+fseek(fp, offset, whence)
+	FILE *fp;
+	long offset;
+	int whence;
+{
+	fpos_t curoff;
+	int havepos;
+
+	/* make sure stdio is set up */
+	if (!__sdidinit)
+		__sinit();
+
+	/*
+	 * Change any SEEK_CUR to SEEK_SET, and check `whence' argument.
+	 * After this, whence is either SEEK_SET or SEEK_END.
+	 */
+	switch (whence) {
+
+	case SEEK_CUR:
+		/*
+		 * In order to seek relative to the current stream offset,
+		 * we have to first find the current stream offset a la
+		 * ftell (see ftell for details).
+		 */
+		curoff = __sseek(fp, (fpos_t)0, SEEK_CUR);
+		if (curoff == POS_ERR)
+			return (EOF);
+		if (fp->_flags & __SRD) {
+			curoff -= fp->_r;
+			if (HASUB(fp))
+				curoff -= fp->_ur;
+		} else if (fp->_flags & __SWR && fp->_p != NULL)
+			curoff += fp->_p - fp->_bf._base;
+
+		offset += curoff;
+		whence = SEEK_SET;
+		havepos = 1;
+		break;
+
+	case SEEK_SET:
+	case SEEK_END:
+		curoff = 0;		/* XXX just to keep gcc quiet */
+		havepos = 0;
+		break;
+
+	default:
+		errno = EINVAL;
+		return (EOF);
+	}
+
+	if (fp->_bf._base == NULL)
+		__smakebuf(fp);
+
+	if (__sflush(fp) ||
+	    __sseek(fp, (fpos_t)offset, whence) == POS_ERR) {
+		return (EOF);
+	}
+	/* success: clear EOF indicator and discard ungetc() data */
+	if (HASUB(fp))
+		FREEUB(fp);
+	fp->_p = fp->_bf._base;
+	fp->_r = 0;
+	/* fp->_w = 0; */	/* unnecessary (I think...) */
+	fp->_flags &= ~__SEOF;
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fsetpos.c b/prex-0.9.0/usr/lib/libc/stdio/fsetpos.c
new file mode 100755
index 0000000..fc7ac10
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fsetpos.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+/*
+ * fsetpos: like fseek.
+ */
+int
+fsetpos(iop, pos)
+	FILE *iop;
+	const fpos_t *pos;
+{
+	return (fseek(iop, (long)*pos, SEEK_SET));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/ftell.c b/prex-0.9.0/usr/lib/libc/stdio/ftell.c
new file mode 100755
index 0000000..2bda63f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/ftell.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include "local.h"
+
+/*
+ * ftell: return current offset.
+ */
+long
+ftell(fp)
+	FILE *fp;
+{
+	fpos_t pos;
+
+	/*
+	 * Find offset of underlying I/O object, then
+	 * adjust for buffered bytes.
+	 */
+	pos = __sseek(fp, (fpos_t)0, SEEK_CUR);
+	if (pos == -(fpos_t)1)
+		return (pos);
+
+	if (fp->_flags & __SRD) {
+		/*
+		 * Reading.  Any unread characters (including
+		 * those from ungetc) cause the position to be
+		 * smaller than that in the underlying object.
+		 */
+		pos -= fp->_r;
+		if (HASUB(fp))
+			pos -= fp->_ur;
+	} else if (fp->_flags & __SWR && fp->_p != NULL) {
+		/*
+		 * Writing.  Any buffered characters cause the
+		 * position to be greater than that in the
+		 * underlying object.
+		 */
+		pos += fp->_p - fp->_bf._base;
+	}
+	return (pos);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fvwrite.c b/prex-0.9.0/usr/lib/libc/stdio/fvwrite.c
new file mode 100755
index 0000000..a6c21b7
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fvwrite.c
@@ -0,0 +1,182 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include "local.h"
+#include "fvwrite.h"
+
+/*
+ * Write some memory regions.  Return zero on success, EOF on error.
+ *
+ * This routine is large and unsightly, but most of the ugliness due
+ * to the three different kinds of output buffering is handled here.
+ */
+int
+__sfvwrite(fp, uio)
+	FILE *fp;
+	struct __suio *uio;
+{
+	size_t len;
+	char *p;
+	struct __siov *iov;
+	int w, s;
+	char *nl;
+	int nlknown, nldist;
+
+	if ((len = uio->uio_resid) == 0)
+		return (0);
+	/* make sure we can write */
+	if (cantwrite(fp))
+		return (EOF);
+
+#define	MIN(a, b) ((a) < (b) ? (a) : (b))
+#define	COPY(n)	  (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
+
+	iov = uio->uio_iov;
+	p = iov->iov_base;
+	len = iov->iov_len;
+	iov++;
+#define GETIOV(extra_work) \
+	while (len == 0) { \
+		extra_work; \
+		p = iov->iov_base; \
+		len = iov->iov_len; \
+		iov++; \
+	}
+	if (fp->_flags & __SNBF) {
+		/*
+		 * Unbuffered: write up to BUFSIZ bytes at a time.
+		 */
+		do {
+			GETIOV(;);
+			w = __swrite(fp, p, MIN(len, BUFSIZ));
+			if (w <= 0)
+				goto err;
+			p += w;
+			len -= w;
+		} while ((uio->uio_resid -= w) != 0);
+	} else if ((fp->_flags & __SLBF) == 0) {
+		/*
+		 * Fully buffered: fill partially full buffer, if any,
+		 * and then flush.  If there is no partial buffer, write
+		 * one _bf._size byte chunk directly (without copying).
+		 *
+		 * String output is a special case: write as many bytes
+		 * as fit, but pretend we wrote everything.  This makes
+		 * snprintf() return the number of bytes needed, rather
+		 * than the number used, and avoids its write function
+		 * (so that the write function can be invalid).
+		 */
+		do {
+			GETIOV(;);
+			w = fp->_w;
+			if (fp->_flags & __SSTR) {
+				if (len < w)
+					w = len;
+				COPY(w);	/* copy MIN(fp->_w,len), */
+				fp->_w -= w;
+				fp->_p += w;
+				w = len;	/* but pretend copied all */
+			} else if (fp->_p > fp->_bf._base && len > w) {
+				/* fill and flush */
+				COPY(w);
+				/* fp->_w -= w; */ /* unneeded */
+				fp->_p += w;
+				if (fflush(fp))
+					goto err;
+			} else if (len >= (w = fp->_bf._size)) {
+				/* write directly */
+				w = __swrite(fp, p, w);
+				if (w <= 0)
+					goto err;
+			} else {
+				/* fill and done */
+				w = len;
+				COPY(w);
+				fp->_w -= w;
+				fp->_p += w;
+			}
+			p += w;
+			len -= w;
+		} while ((uio->uio_resid -= w) != 0);
+	} else {
+		/*
+		 * Line buffered: like fully buffered, but we
+		 * must check for newlines.  Compute the distance
+		 * to the first newline (including the newline),
+		 * or `infinity' if there is none, then pretend
+		 * that the amount to write is MIN(len,nldist).
+		 */
+		nlknown = 0;
+		nldist = 0;	/* XXX just to keep gcc happy */
+		do {
+			GETIOV(nlknown = 0);
+			if (!nlknown) {
+				nl = memchr((void *)p, '\n', len);
+				nldist = nl ? nl + 1 - p : len + 1;
+				nlknown = 1;
+			}
+			s = MIN(len, nldist);
+			w = fp->_w + fp->_bf._size;
+			if (fp->_p > fp->_bf._base && s > w) {
+				COPY(w);
+				/* fp->_w -= w; */
+				fp->_p += w;
+				if (fflush(fp))
+					goto err;
+			} else if (s >= (w = fp->_bf._size)) {
+				w = __swrite(fp, p, w);
+				if (w <= 0)
+				 	goto err;
+			} else {
+				w = s;
+				COPY(w);
+				fp->_w -= w;
+				fp->_p += w;
+			}
+			if ((nldist -= w) == 0) {
+				/* copied the newline: flush and forget */
+				if (fflush(fp))
+					goto err;
+				nlknown = 0;
+			}
+			p += w;
+			len -= w;
+		} while ((uio->uio_resid -= w) != 0);
+	}
+	return (0);
+
+err:
+	fp->_flags |= __SERR;
+	return (EOF);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fvwrite.h b/prex-0.9.0/usr/lib/libc/stdio/fvwrite.h
new file mode 100755
index 0000000..79087e4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fvwrite.h
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)fvwrite.h	8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * I/O descriptors for __sfvwrite().
+ */
+struct __siov {
+	void	*iov_base;
+	size_t	iov_len;
+};
+struct __suio {
+	struct	__siov *uio_iov;
+	int	uio_iovcnt;
+	int	uio_resid;
+};
+
+#if __STDC__ || c_plusplus
+extern int __sfvwrite(FILE *, struct __suio *);
+#else
+extern int __sfvwrite();
+#endif
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fwalk.c b/prex-0.9.0/usr/lib/libc/stdio/fwalk.c
new file mode 100755
index 0000000..1e2a60e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fwalk.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include "local.h"
+
+int
+_fwalk(function)
+	int (*function)(FILE *);
+{
+	FILE *fp;
+	int ret;
+
+	ret = 0;
+	for (fp = &__sF[0]; fp != NULL; fp = fp->next) {
+		if (fp->_flags != 0)
+			ret |= (*function)(fp);
+	}
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/fwrite.c b/prex-0.9.0/usr/lib/libc/stdio/fwrite.c
new file mode 100755
index 0000000..cead288
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/fwrite.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include "local.h"
+
+/*
+ * Write `count' objects (each size `size') from memory to the given file.
+ * Return the number of whole objects written.
+ */
+size_t
+fwrite(buf, size, count, fp)
+	const void *buf;
+	size_t size, count;
+	FILE *fp;
+{
+	unsigned char *p = (unsigned char *)buf;
+	size_t len = count * size;
+	size_t n = 0;
+
+	while (n < len) {
+		if (putc((int)*p, fp) == EOF)
+			return n;
+		p++;
+		n++;
+	}
+	return n;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/getc.c b/prex-0.9.0/usr/lib/libc/stdio/getc.c
new file mode 100755
index 0000000..da568a5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/getc.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include "local.h"
+
+int
+getc(fp)
+	FILE *fp;
+{
+	if (--(fp->_r) < 0) {
+		if (__srefill(fp) == 0) {
+			fp->_r--;
+			return (*fp->_p++);
+		}
+		return (EOF);
+	}
+	return (int)(*fp->_p++);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/getchar.c b/prex-0.9.0/usr/lib/libc/stdio/getchar.c
new file mode 100755
index 0000000..b665520
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/getchar.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+#undef getchar
+
+int
+getchar()
+{
+	return (getc(stdin));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/gets.c b/prex-0.9.0/usr/lib/libc/stdio/gets.c
new file mode 100755
index 0000000..461524e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/gets.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+
+char *
+gets(buf)
+	char *buf;
+{
+	int c;
+	char *s;
+
+	for (s = buf; (c = getchar()) != '\n';)
+		if (c == EOF)
+			if (s == buf)
+				return (NULL);
+			else
+				break;
+		else
+			*s++ = c;
+	*s = '\0';
+	return (buf);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/getw.c b/prex-0.9.0/usr/lib/libc/stdio/getw.c
new file mode 100755
index 0000000..7cecd77
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/getw.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+getw(fp)
+	FILE *fp;
+{
+	int w;
+	int size = sizeof(int);
+	char *p = (char *) &w;
+
+	while (size--)
+		*p++ = getc(fp);
+	if (fp->_flags & (__SERR|__SEOF))
+		return EOF;
+	return w;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/local.h b/prex-0.9.0/usr/lib/libc/stdio/local.h
new file mode 100755
index 0000000..d4251d5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/local.h
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)local.h	8.3 (Berkeley) 7/3/94
+ */
+
+#include <sys/cdefs.h>
+
+/*
+ * Information local to this implementation of stdio,
+ * in particular, macros and private variables.
+ */
+
+__BEGIN_DECLS
+int	__sflush(FILE *);
+FILE	*__sfp(void);
+int	__srefill(FILE *);
+int	__sread(FILE *, char *, int);
+int	__swrite(FILE *, char const *, int);
+fpos_t	__sseek(FILE *, fpos_t, int);
+int	__sclose(FILE *);
+void	__sinit(void);
+void	_cleanup(void);
+void	(*__cleanup)(void);
+void	__smakebuf(FILE *);
+int	_fwalk(int (*)(FILE *));
+int	__swsetup(FILE *);
+int	__sflags(const char *, int *);
+int	__sdidinit;
+__END_DECLS
+
+/*
+ * Return true iff the given FILE cannot be written now.
+ */
+#define	cantwrite(fp) \
+	((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
+	 __swsetup(fp))
+
+/*
+ * Test whether the given stdio file has an active ungetc buffer;
+ * release such a buffer, without restoring ordinary unread data.
+ */
+#define	HASUB(fp) ((fp)->_ub._base != NULL)
+#define	FREEUB(fp) { \
+	(fp)->_ub._base = NULL; \
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/makebuf.c b/prex-0.9.0/usr/lib/libc/stdio/makebuf.c
new file mode 100755
index 0000000..070a0cb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/makebuf.c
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+/*
+ * Internal routine to determine `proper' buffering for a file.
+ */
+static int
+__swhatbuf(FILE *fp, size_t *bufsize, int *couldbetty)
+{
+	struct stat st;
+
+	*bufsize = BUFSIZ;
+	*couldbetty = 0;
+	if (fp->_file < 0 || fstat(fp->_file, &st) < 0)
+		return 0;
+
+	/* could be a tty iff it is a character device */
+	*couldbetty = S_ISCHR(st.st_mode);
+	return 0;
+}
+
+/*
+ * Allocate a file buffer, or switch to unbuffered I/O.
+ * Per the ANSI C standard, ALL tty devices default to line buffered.
+ *
+ * As a side effect, we set __SOPT or __SNPT (en/dis-able fseek
+ * optimisation) right after the fstat() that finds the buffer size.
+ */
+void
+__smakebuf(fp)
+	FILE *fp;
+{
+	void *p;
+	int flags;
+	size_t size;
+	int couldbetty;
+
+	if (fp->_flags & __SNBF) {
+		fp->_bf._base = fp->_p = fp->_nbuf;
+		fp->_bf._size = 1;
+		return;
+	}
+	flags = __swhatbuf(fp, &size, &couldbetty);
+	if ((p = malloc(size)) == NULL) {
+		fp->_flags |= __SNBF;
+		fp->_bf._base = fp->_p = fp->_nbuf;
+		fp->_bf._size = 1;
+		return;
+	}
+	__cleanup = _cleanup;
+	flags |= __SMBF;
+	fp->_bf._base = fp->_p = p;
+	fp->_bf._size = size;
+	if (couldbetty && isatty(fp->_file))
+		flags |= __SLBF;
+
+	fp->_flags |= flags;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/mktemp.c b/prex-0.9.0/usr/lib/libc/stdio/mktemp.c
new file mode 100755
index 0000000..77bb6ac
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/mktemp.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 1987, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <unistd.h>
+
+static int _gettemp(char *, int *);
+
+int
+mkstemp(path)
+	char *path;
+{
+	int fd;
+
+	return (_gettemp(path, &fd) ? fd : -1);
+}
+
+char *
+mktemp(path)
+	char *path;
+{
+	return(_gettemp(path, (int *)NULL) ? path : (char *)NULL);
+}
+
+static int
+_gettemp(path, doopen)
+	char *path;
+	int *doopen;
+{
+	extern int errno;
+	char *start, *trv;
+	struct stat sbuf;
+	u_int pid;
+
+	pid = getpid();
+	for (trv = path; *trv; ++trv);		/* extra X's get set to 0's */
+	while (*--trv == 'X') {
+		*trv = (pid % 10) + '0';
+		pid /= 10;
+	}
+
+	/*
+	 * check the target directory; if you have six X's and it
+	 * doesn't exist this runs for a *very* long time.
+	 */
+	for (start = trv + 1;; --trv) {
+		if (trv <= path)
+			break;
+		if (*trv == '/') {
+			*trv = '\0';
+			if (stat(path, &sbuf))
+				return(0);
+			if (!S_ISDIR(sbuf.st_mode)) {
+				errno = ENOTDIR;
+				return(0);
+			}
+			*trv = '/';
+			break;
+		}
+	}
+
+	for (;;) {
+		if (doopen) {
+			if ((*doopen =
+			    open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
+				return(1);
+			if (errno != EEXIST)
+				return(0);
+		}
+		else if (stat(path, &sbuf))
+			return(errno == ENOENT ? 1 : 0);
+
+		/* tricky little algorithm for backward compatibility */
+		for (trv = start;;) {
+			if (!*trv)
+				return(0);
+			if (*trv == 'z')
+				*trv++ = 'a';
+			else {
+				if (isdigit((unsigned char)*trv))
+					*trv = 'a';
+				else
+					++*trv;
+				break;
+			}
+		}
+	}
+	/*NOTREACHED*/
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/perror.c b/prex-0.9.0/usr/lib/libc/stdio/perror.c
new file mode 100755
index 0000000..2106a6f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/perror.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+void
+perror(s)
+	const char *s;
+{
+	if (s != NULL && *s != '\0') {
+		fputs(s, stderr);
+		fputs(": ", stderr);
+	}
+	fputs(strerror(errno), stderr);
+	fputs("\n", stderr);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/printf.c b/prex-0.9.0/usr/lib/libc/stdio/printf.c
new file mode 100755
index 0000000..2f20ed4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/printf.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+printf(char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, fmt);
+	ret = vfprintf(stdout, fmt, ap);
+	va_end(ap);
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/putc.c b/prex-0.9.0/usr/lib/libc/stdio/putc.c
new file mode 100755
index 0000000..f8097dd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/putc.c
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include "local.h"
+
+/*
+ * Write the given character into the (probably full) buffer for
+ * the given file.  Flush the buffer out if it is or becomes full,
+ * or if c=='\n' and the file is line buffered.
+ */
+int
+__swbuf(c, fp)
+	int c;
+	FILE *fp;
+{
+	int n;
+
+	if (cantwrite(fp))
+		return (EOF);
+	c = (unsigned char)c;
+
+	/*
+	 * If it is completely full, flush it out.  Then, in any case,
+	 * stuff c into the buffer.  If this causes the buffer to fill
+	 * completely, or if c is '\n' and the file is line buffered,
+	 * flush it (perhaps a second time).  The second flush will always
+	 * happen on unbuffered streams, where _bf._size==1; fflush()
+	 * guarantees that putc() will always call wbuf() by setting _w
+	 * to 0, so we need not do anything else.
+	 */
+	n = fp->_p - fp->_bf._base;
+	if (n >= fp->_bf._size) {
+		if (fflush(fp))
+			return (EOF);
+		n = 0;
+	}
+	fp->_w--;
+	*fp->_p++ = c;
+	if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n'))
+		if (fflush(fp))
+			return (EOF);
+	return (c);
+}
+
+int
+putc(c, fp)
+	int c;
+	FILE *fp;
+{
+	if (--fp->_w >= 0)
+		return (*fp->_p++ = c);
+	else
+		return (__swbuf(c, fp));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/putchar.c b/prex-0.9.0/usr/lib/libc/stdio/putchar.c
new file mode 100755
index 0000000..0160596
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/putchar.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+#undef putchar
+
+int
+putchar(c)
+	int c;
+{
+	return (putc(c, stdout));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/puts.c b/prex-0.9.0/usr/lib/libc/stdio/puts.c
new file mode 100755
index 0000000..5d97917
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/puts.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+/*
+ * Write the given string to stdout, appending a newline.
+ */
+int
+puts(s)
+	char const *s;
+{
+	char c;
+
+	while ((c = *s++) != '\0')
+		putchar(c);
+	return(putchar('\n'));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/putw.c b/prex-0.9.0/usr/lib/libc/stdio/putw.c
new file mode 100755
index 0000000..c17be84
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/putw.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+putw(w, fp)
+	int w;
+	FILE *fp;
+{
+	int size = sizeof(int);
+	char *p = (char *) &w;
+
+	while (size--)
+		putc(*p++, fp);
+	if (fp->_flags & __SERR)
+		return EOF;
+	return w;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/refill.c b/prex-0.9.0/usr/lib/libc/stdio/refill.c
new file mode 100755
index 0000000..8255b8b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/refill.c
@@ -0,0 +1,118 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+static int
+lflush(FILE *fp)
+{
+
+	if ((fp->_flags & (__SLBF|__SWR)) == (__SLBF|__SWR))
+		return (__sflush(fp));
+	return (0);
+}
+
+/*
+ * Refill a stdio buffer.
+ * Return EOF on eof or error, 0 otherwise.
+ */
+int
+__srefill(fp)
+	FILE *fp;
+{
+
+	/* make sure stdio is set up */
+	if (!__sdidinit)
+		__sinit();
+
+	fp->_r = 0;		/* largely a convenience for callers */
+
+	/* SysV does not make this test; take it out for compatibility */
+	if (fp->_flags & __SEOF)
+		return (EOF);
+
+	/* if not already reading, have to be reading and writing */
+	if ((fp->_flags & __SRD) == 0) {
+		if ((fp->_flags & __SRW) == 0) {
+			errno = EBADF;
+			return (EOF);
+		}
+		/* switch to reading */
+		if (fp->_flags & __SWR) {
+			if (__sflush(fp))
+				return (EOF);
+			fp->_flags &= ~__SWR;
+			fp->_w = 0;
+		}
+		fp->_flags |= __SRD;
+	} else {
+		/*
+		 * We were reading.  If there is an ungetc buffer,
+		 * we must have been reading from that.  Drop it,
+		 * restoring the previous buffer (if any).  If there
+		 * is anything in that buffer, return.
+		 */
+		if (HASUB(fp)) {
+			FREEUB(fp);
+			if ((fp->_r = fp->_ur) != 0) {
+				fp->_p = fp->_up;
+				return (0);
+			}
+		}
+	}
+
+	if (fp->_bf._base == NULL)
+		__smakebuf(fp);
+
+	/*
+	 * Before reading from a line buffered or unbuffered file,
+	 * flush all line buffered output files, per the ANSI C
+	 * standard.
+	 */
+	if (fp->_flags & (__SLBF|__SNBF))
+		(void) _fwalk(lflush);
+	fp->_p = fp->_bf._base;
+	fp->_r = __sread(fp, (char *)fp->_p, fp->_bf._size);
+	if (fp->_r <= 0) {
+		if (fp->_r == 0)
+			fp->_flags |= __SEOF;
+		else {
+			fp->_r = 0;
+			fp->_flags |= __SERR;
+		}
+		return (EOF);
+	}
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/remove.c b/prex-0.9.0/usr/lib/libc/stdio/remove.c
new file mode 100755
index 0000000..7fb3fb2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/remove.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int
+remove(file)
+	const char *file;
+{
+	struct stat sb;
+
+	if (lstat(file, &sb) < 0)
+		return (-1);
+
+	/*
+	 * The file system may prohibit using unlink(2) on directories,
+	 * so always use rmdir(2) in that case.
+	 */
+	if (S_ISDIR(sb.st_mode))
+		return (rmdir(file));
+	else
+		return (unlink(file));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/rewind.c b/prex-0.9.0/usr/lib/libc/stdio/rewind.c
new file mode 100755
index 0000000..f4a2a20
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/rewind.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+
+void
+rewind(fp)
+	FILE *fp;
+{
+	(void) fseek(fp, 0L, SEEK_SET);
+	clearerr(fp);
+	errno = 0;      /* not required, but seems reasonable */
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/scanf.c b/prex-0.9.0/usr/lib/libc/stdio/scanf.c
new file mode 100755
index 0000000..ee0aedb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/scanf.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+scanf(char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, fmt);
+	ret = __svfscanf(stdin, fmt, ap);
+	va_end(ap);
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/setbuf.c b/prex-0.9.0/usr/lib/libc/stdio/setbuf.c
new file mode 100755
index 0000000..e97f016
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/setbuf.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include "local.h"
+
+void
+setbuf(fp, buf)
+	FILE *fp;
+	char *buf;
+{
+	(void) setvbuf(fp, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/setbuffer.c b/prex-0.9.0/usr/lib/libc/stdio/setbuffer.c
new file mode 100755
index 0000000..88441d9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/setbuffer.c
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+void
+setbuffer(fp, buf, size)
+	FILE *fp;
+	char *buf;
+	int size;
+{
+
+	(void)setvbuf(fp, buf, buf ? _IOFBF : _IONBF, size);
+}
+
+/*
+ * set line buffering
+ */
+int
+setlinebuf(fp)
+	FILE *fp;
+{
+
+	return (setvbuf(fp, (char *)NULL, _IOLBF, (size_t)0));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/setvbuf.c b/prex-0.9.0/usr/lib/libc/stdio/setvbuf.c
new file mode 100755
index 0000000..eced230
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/setvbuf.c
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+/*
+ * Set one of the three kinds of buffering, optionally including
+ * a buffer.
+ */
+int
+setvbuf(fp, buf, mode, size)
+	FILE *fp;
+	char *buf;
+	int mode;
+	size_t size;
+{
+	int ret, flags;
+	/*	int ttyflag; */
+
+	/*
+	 * Verify arguments.  The `int' limit on `size' is due to this
+	 * particular implementation.  Note, buf and size are ignored
+	 * when setting _IONBF.
+	 */
+	if (mode != _IONBF)
+		if ((mode != _IOFBF && mode != _IOLBF) || (int)size < 0)
+			return (EOF);
+
+	/*
+	 * Write current buffer, if any.  Discard unread input (including
+	 * ungetc data), cancel line buffering, and free old buffer if
+	 * malloc()ed.  We also clear any eof condition, as if this were
+	 * a seek.
+	 */
+	ret = 0;
+	(void)__sflush(fp);
+	if (HASUB(fp))
+		FREEUB(fp);
+	fp->_r = 0;
+	flags = fp->_flags;
+	if (buf != NULL && (flags & __SMBF))
+		free((void *)fp->_bf._base);
+	flags &= ~(__SLBF | __SNBF | __SMBF | __SEOF);
+
+	/*
+	 * Fix up the FILE fields, and set __cleanup for output flush on
+	 * exit (since we are buffered in some way).
+	 */
+	if (mode == _IOLBF)
+		flags |= __SLBF;
+	fp->_flags = flags;
+
+	/*
+	 * If buffer is NULL, we change only buffering mode.
+	 */
+	if (buf == NULL)
+		return 0;
+
+	fp->_bf._base = fp->_p = (unsigned char *)buf;
+	fp->_bf._size = size;
+	fp->_w = 0;
+	__cleanup = _cleanup;
+
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/snprintf.c b/prex-0.9.0/usr/lib/libc/stdio/snprintf.c
new file mode 100755
index 0000000..395873b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/snprintf.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int
+snprintf(char *str, size_t n, char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	FILE f;
+
+	if ((int)n < 1)
+		return (EOF);
+	va_start(ap, fmt);
+	f._flags = __SWR | __SSTR;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._w = n - 1;
+	ret = vfprintf(&f, fmt, ap);
+	*f._p = 0;
+	va_end(ap);
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/sprintf.c b/prex-0.9.0/usr/lib/libc/stdio/sprintf.c
new file mode 100755
index 0000000..46ed0b4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/sprintf.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <limits.h>
+#include "local.h"
+
+int
+sprintf(char *str, char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	FILE f;
+
+	f._flags = __SWR | __SSTR;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._w = INT_MAX;
+	va_start(ap, fmt);
+	ret = vfprintf(&f, fmt, ap);
+	va_end(ap);
+	*f._p = 0;
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/sscanf.c b/prex-0.9.0/usr/lib/libc/stdio/sscanf.c
new file mode 100755
index 0000000..cd4d927
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/sscanf.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include "local.h"
+
+int
+sscanf(const char *str, char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	FILE f;
+
+	f._flags = __SRD;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._r = strlen(str);
+	f._ub._base = NULL;
+	va_start(ap, fmt);
+	ret = __svfscanf(&f, fmt, ap);
+	va_end(ap);
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/stdio.c b/prex-0.9.0/usr/lib/libc/stdio/stdio.c
new file mode 100755
index 0000000..a455a40
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/stdio.c
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "local.h"
+
+/*
+ * Small standard I/O/seek/close functions.
+ * These maintain the `known seek offset' for seek optimisation.
+ */
+int
+__sread(fp, buf, n)
+	FILE *fp;
+	char *buf;
+	int n;
+{
+	return (read(fp->_file, buf, n));
+}
+
+int
+__swrite(fp, buf, n)
+	FILE *fp;
+	char const *buf;
+	int n;
+{
+	if (fp->_flags & __SAPP)
+		(void) lseek(fp->_file, (off_t)0, SEEK_END);
+	return (write(fp->_file, buf, n));
+}
+
+fpos_t
+__sseek(fp, offset, whence)
+	FILE *fp;
+	fpos_t offset;
+	int whence;
+{
+	return (lseek(fp->_file, (off_t)offset, whence));
+}
+
+int
+__sclose(fp)
+	FILE *fp;
+{
+	return (close(fp->_file));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/tempnam.c b/prex-0.9.0/usr/lib/libc/stdio/tempnam.c
new file mode 100755
index 0000000..7162c18
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/tempnam.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <paths.h>
+
+char *
+tempnam(dir, pfx)
+	const char *dir, *pfx;
+{
+	int sverrno;
+	char *f, *name;
+
+	if (!(name = malloc((size_t)MAXPATHLEN)))
+		return(NULL);
+
+	if (!pfx)
+		pfx = "tmp.";
+
+	if ((f = getenv("TMPDIR")) != NULL) {
+		(void)snprintf(name, (size_t)MAXPATHLEN, "%s%s%sXXXXXXXXXX", f,
+		    *(f + strlen(f) - 1) == '/'? "": "/", pfx);
+		if ((f = mktemp(name)) != NULL)
+			return(f);
+	}
+
+	if ((/* LINTED */f = (char *)dir) != NULL) {
+		(void)snprintf(name, (size_t)MAXPATHLEN, "%s%s%sXXXXXXXXXX", f,
+		    *(f + strlen(f) - 1) == '/'? "": "/", pfx);
+		if ((f = mktemp(name)) != NULL)
+			return(f);
+	}
+
+	f = P_tmpdir;
+	(void)snprintf(name, (size_t)MAXPATHLEN, "%s%sXXXXXXXXXX", f, pfx);
+	if ((f = mktemp(name)) != NULL)
+		return(f);
+
+	f = _PATH_TMP;
+	(void)snprintf(name, (size_t)MAXPATHLEN, "%s%sXXXXXXXXXX", f, pfx);
+	if ((f = mktemp(name)) != NULL)
+		return(f);
+
+	sverrno = errno;
+	free(name);
+	errno = sverrno;
+	return(NULL);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/tmpfile.c b/prex-0.9.0/usr/lib/libc/stdio/tmpfile.c
new file mode 100755
index 0000000..b0ad1b7
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/tmpfile.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <signal.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <paths.h>
+
+FILE *
+tmpfile()
+{
+	sigset_t set, oset;
+	FILE *fp;
+	int fd, sverrno;
+#define	TRAILER	"tmp.XXXXXX"
+	char buf[sizeof(_PATH_TMP) + sizeof(TRAILER)];
+
+	(void)memcpy(buf, _PATH_TMP, sizeof(_PATH_TMP) - 1);
+	(void)memcpy(buf + sizeof(_PATH_TMP) - 1, TRAILER, sizeof(TRAILER));
+
+	sigfillset(&set);
+	(void)sigprocmask(SIG_BLOCK, &set, &oset);
+
+	fd = mkstemp(buf);
+	if (fd != -1)
+		(void)unlink(buf);
+
+	(void)sigprocmask(SIG_SETMASK, &oset, NULL);
+
+	if (fd == -1)
+		return (NULL);
+
+	if ((fp = fdopen(fd, "w+")) == NULL) {
+		sverrno = errno;
+		(void)close(fd);
+		errno = sverrno;
+		return (NULL);
+	}
+	return (fp);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/tmpnam.c b/prex-0.9.0/usr/lib/libc/stdio/tmpnam.c
new file mode 100755
index 0000000..80401ae
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/tmpnam.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <unistd.h>
+
+char *
+tmpnam(s)
+	char *s;
+{
+	static u_long tmpcount;
+	static char buf[L_tmpnam];
+
+	if (s == NULL)
+		s = buf;
+	(void)snprintf(s, L_tmpnam, "%stmp.%lu.XXXXXX", P_tmpdir, tmpcount);
+	++tmpcount;
+	return (mktemp(s));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/ungetc.c b/prex-0.9.0/usr/lib/libc/stdio/ungetc.c
new file mode 100755
index 0000000..44baa6e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/ungetc.c
@@ -0,0 +1,100 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "local.h"
+
+int
+ungetc(c, fp)
+	int c;
+	FILE *fp;
+{
+	if (c == EOF)
+		return (EOF);
+	if (!__sdidinit)
+		__sinit();
+	if ((fp->_flags & __SRD) == 0) {
+		/*
+		 * Not already reading: no good unless reading-and-writing.
+		 * Otherwise, flush any current write stuff.
+		 */
+		if ((fp->_flags & __SRW) == 0)
+			return (EOF);
+		if (fp->_flags & __SWR) {
+			if (__sflush(fp))
+				return (EOF);
+			fp->_flags &= ~__SWR;
+			fp->_w = 0;
+		}
+		fp->_flags |= __SRD;
+	}
+	c = (unsigned char)c;
+
+	/*
+	 * If we are in the middle of ungetc'ing, just continue.
+	 */
+	if (HASUB(fp)) {
+		if (fp->_r >= fp->_ub._size)
+			return (EOF);
+		*--fp->_p = c;
+		fp->_r++;
+		return (c);
+	}
+	fp->_flags &= ~__SEOF;
+
+	/*
+	 * If we can handle this by simply backing up, do so,
+	 * but never replace the original character.
+	 * (This makes sscanf() work when scanning `const' data.)
+	 */
+	if (fp->_bf._base != NULL && fp->_p > fp->_bf._base &&
+	    fp->_p[-1] == c) {
+		fp->_p--;
+		fp->_r++;
+		return (c);
+	}
+
+	/*
+	 * Create an ungetc buffer.
+	 * we will use the `reserve' buffer.
+	 */
+	fp->_ur = fp->_r;
+	fp->_up = fp->_p;
+	fp->_ub._base = fp->_ubuf;
+	fp->_ub._size = sizeof(fp->_ubuf);
+	fp->_ubuf[sizeof(fp->_ubuf) - 1] = c;
+	fp->_p = &fp->_ubuf[sizeof(fp->_ubuf) - 1];
+	fp->_r = 1;
+	return (c);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vfprintf.c b/prex-0.9.0/usr/lib/libc/stdio/vfprintf.c
new file mode 100755
index 0000000..167b44a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vfprintf.c
@@ -0,0 +1,541 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Actual printf innards.
+ *
+ * This code is large and complicated...
+ */
+
+#include <sys/types.h>
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "local.h"
+#include "fvwrite.h"
+
+/*
+ * Flush out all the vectors defined by the given uio,
+ * then reset it so that it can be reused.
+ */
+static int
+__sprint(FILE *fp, struct __suio *uio)
+{
+	int error;
+
+	if (uio->uio_resid == 0) {
+		uio->uio_iovcnt = 0;
+		return (0);
+	}
+	error = __sfvwrite(fp, uio);
+	uio->uio_resid = 0;
+	uio->uio_iovcnt = 0;
+	return (error);
+}
+
+/*
+ * Helper function for `fprintf to unbuffered unix file': creates a
+ * temporary buffer.  We only work on write-only files; this avoids
+ * worries about ungetc buffers and so forth.
+ */
+static int
+__sbprintf(FILE *fp, const char *fmt, va_list ap)
+{
+	int ret;
+	FILE fake;
+	unsigned char buf[BUFSIZ];
+
+	/* copy the important variables */
+	fake._flags = fp->_flags & ~__SNBF;
+	fake._file = fp->_file;
+
+	/* set up the buffer */
+	fake._bf._base = fake._p = buf;
+	fake._bf._size = fake._w = sizeof(buf);
+
+	/* do the work, then copy any error status */
+	ret = vfprintf(&fake, fmt, ap);
+	if (ret >= 0 && fflush(&fake))
+		ret = EOF;
+	if (fake._flags & __SERR)
+		fp->_flags |= __SERR;
+	return (ret);
+}
+
+/*
+ * Macros for converting digits to letters and vice versa
+ */
+#define	to_digit(c)	((c) - '0')
+#define is_digit(c)	((unsigned)to_digit(c) <= 9)
+#define	to_char(n)	((n) + '0')
+
+/*
+ * Convert an unsigned long to ASCII for printf purposes, returning
+ * a pointer to the first character of the string representation.
+ * Octal numbers can be forced to have a leading zero; hex numbers
+ * use the given digits.
+ */
+static char *
+__ultoa(u_long val, char *endp, int base, int octzero, char *xdigs)
+{
+	char *cp = endp;
+	long sval;
+
+	/*
+	 * Handle the three cases separately, in the hope of getting
+	 * better/faster code.
+	 */
+	switch (base) {
+	case 10:
+		if (val < 10) {	/* many numbers are 1 digit */
+			*--cp = to_char(val);
+			return (cp);
+		}
+		/*
+		 * On many machines, unsigned arithmetic is harder than
+		 * signed arithmetic, so we do at most one unsigned mod and
+		 * divide; this is sufficient to reduce the range of
+		 * the incoming value to where signed arithmetic works.
+		 */
+		if (val > LONG_MAX) {
+			*--cp = to_char(val % 10);
+			sval = val / 10;
+		} else
+			sval = val;
+		do {
+			*--cp = to_char(sval % 10);
+			sval /= 10;
+		} while (sval != 0);
+		break;
+
+	case 8:
+		do {
+			*--cp = to_char(val & 7);
+			val >>= 3;
+		} while (val);
+		if (octzero && *cp != '0')
+			*--cp = '0';
+		break;
+
+	case 16:
+		do {
+			*--cp = xdigs[val & 15];
+			val >>= 4;
+		} while (val);
+		break;
+
+	default:			/* oops */
+		exit(1);
+	}
+	return (cp);
+}
+
+
+#define	BUF		32
+
+
+/*
+ * Flags used during conversion.
+ */
+#define	ALT		0x001		/* alternate form */
+#define	HEXPREFIX	0x002		/* add 0x or 0X prefix */
+#define	LADJUST		0x004		/* left adjustment */
+#define	LONGDBL		0x008		/* long double; unimplemented */
+#define	LONGINT		0x010		/* long integer */
+#define	SHORTINT	0x040		/* short integer */
+#define	ZEROPAD		0x080		/* zero (as opposed to blank) pad */
+int
+vfprintf(fp, fmt0, ap)
+	FILE *fp;
+	const char *fmt0;
+	va_list ap;
+{
+	char *fmt;		/* format string */
+	int ch;			/* character from fmt */
+	int n;			/* handy integer (short term usage) */
+	char *cp;		/* handy char pointer (short term usage) */
+	struct __siov *iovp;	/* for PRINT macro */
+	int flags;		/* flags as above */
+	int ret;		/* return value accumulator */
+	int width;		/* width from format (%8d), or 0 */
+	int prec;		/* precision from format (%.3d), or -1 */
+	char sign;		/* sign prefix (' ', '+', '-', or \0) */
+	u_long	ulval;		/* integer arguments %[diouxX] */
+	int base;		/* base for [diouxX] conversion */
+	int dprec;		/* a copy of prec if [diouxX], 0 otherwise */
+	int fieldsz;		/* field size expanded by sign, etc */
+	int realsz;		/* field size expanded by dprec */
+	int size;		/* size of converted field or string */
+	char *xdigs = NULL;	/* digits for [xX] conversion */
+#define NIOV 8
+	struct __suio uio;	/* output information: summary */
+	struct __siov iov[NIOV];/* ... and individual io vectors */
+	char buf[BUF];		/* space for %c, %[diouxX], %[eEfgG] */
+	char ox[2];		/* space for 0x hex-prefix */
+
+	/*
+	 * Choose PADSIZE to trade efficiency vs. size.  If larger printf
+	 * fields occur frequently, increase PADSIZE and make the initialisers
+	 * below longer.
+	 */
+#define	PADSIZE	16		/* pad chunk size */
+	static char blanks[PADSIZE] =
+	 {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};
+	static char zeroes[PADSIZE] =
+	 {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'};
+
+	/*
+	 * BEWARE, these `goto error' on error, and PAD uses `n'.
+	 */
+#define	PRINT(ptr, len) { \
+	iovp->iov_base = (ptr); \
+	iovp->iov_len = (len); \
+	uio.uio_resid += (len); \
+	iovp++; \
+	if (++uio.uio_iovcnt >= NIOV) { \
+		if (__sprint(fp, &uio)) \
+			goto error; \
+		iovp = iov; \
+	} \
+}
+#define	PAD(howmany, with) { \
+	if ((n = (howmany)) > 0) { \
+		while (n > PADSIZE) { \
+			PRINT(with, PADSIZE); \
+			n -= PADSIZE; \
+		} \
+		PRINT(with, n); \
+	} \
+}
+#define	FLUSH() { \
+	if (uio.uio_resid && __sprint(fp, &uio)) \
+		goto error; \
+	uio.uio_iovcnt = 0; \
+	iovp = iov; \
+}
+
+	/*
+	 * To extend shorts properly, we need both signed and unsigned
+	 * argument extraction methods.
+	 */
+#define	SARG() \
+	(flags&LONGINT ? va_arg(ap, long) : \
+	    flags&SHORTINT ? (long)(short)va_arg(ap, int) : \
+	    (long)va_arg(ap, int))
+#define	UARG() \
+	(flags&LONGINT ? va_arg(ap, u_long) : \
+	    flags&SHORTINT ? (u_long)(u_short)va_arg(ap, int) : \
+	    (u_long)va_arg(ap, u_int))
+
+	/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
+	if (cantwrite(fp))
+		return (EOF);
+
+	/* optimise fprintf(stderr) (and other unbuffered Unix files) */
+	if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
+	    fp->_file >= 0)
+		return (__sbprintf(fp, fmt0, ap));
+
+	fmt = (char *)fmt0;
+	uio.uio_iov = iovp = iov;
+	uio.uio_resid = 0;
+	uio.uio_iovcnt = 0;
+	ret = 0;
+
+	/*
+	 * Scan the format for conversions (`%' character).
+	 */
+	for (;;) {
+		for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++)
+			/* void */;
+		if ((n = fmt - cp) != 0) {
+			PRINT(cp, n);
+			ret += n;
+		}
+		if (ch == '\0')
+			goto done;
+		fmt++;		/* skip over '%' */
+
+		flags = 0;
+		dprec = 0;
+		width = 0;
+		prec = -1;
+		sign = '\0';
+
+rflag:		ch = *fmt++;
+reswitch:	switch (ch) {
+		case ' ':
+			/*
+			 * ``If the space and + flags both appear, the space
+			 * flag will be ignored.''
+			 *	-- ANSI X3J11
+			 */
+			if (!sign)
+				sign = ' ';
+			goto rflag;
+		case '#':
+			flags |= ALT;
+			goto rflag;
+		case '*':
+			/*
+			 * ``A negative field width argument is taken as a
+			 * - flag followed by a positive field width.''
+			 *	-- ANSI X3J11
+			 * They don't exclude field widths read from args.
+			 */
+			if ((width = va_arg(ap, int)) >= 0)
+				goto rflag;
+			width = -width;
+			/* FALLTHROUGH */
+		case '-':
+			flags |= LADJUST;
+			goto rflag;
+		case '+':
+			sign = '+';
+			goto rflag;
+		case '.':
+			if ((ch = *fmt++) == '*') {
+				n = va_arg(ap, int);
+				prec = n < 0 ? -1 : n;
+				goto rflag;
+			}
+			n = 0;
+			while (is_digit(ch)) {
+				n = 10 * n + to_digit(ch);
+				ch = *fmt++;
+			}
+			prec = n < 0 ? -1 : n;
+			goto reswitch;
+		case '0':
+			/*
+			 * ``Note that 0 is taken as a flag, not as the
+			 * beginning of a field width.''
+			 *	-- ANSI X3J11
+			 */
+			flags |= ZEROPAD;
+			goto rflag;
+		case '1': case '2': case '3': case '4':
+		case '5': case '6': case '7': case '8': case '9':
+			n = 0;
+			do {
+				n = 10 * n + to_digit(ch);
+				ch = *fmt++;
+			} while (is_digit(ch));
+			width = n;
+			goto reswitch;
+		case 'h':
+			flags |= SHORTINT;
+			goto rflag;
+		case 'l':
+			flags |= LONGINT;
+			goto rflag;
+		case 'c':
+			*(cp = buf) = va_arg(ap, int);
+			size = 1;
+			sign = '\0';
+			break;
+		case 'D':
+			flags |= LONGINT;
+			/*FALLTHROUGH*/
+		case 'd':
+		case 'i':
+			ulval = SARG();
+			if ((long)ulval < 0) {
+				ulval = -ulval;
+				sign = '-';
+			}
+			base = 10;
+			goto number;
+		case 'n':
+			if (flags & LONGINT)
+				*va_arg(ap, long *) = ret;
+			else if (flags & SHORTINT)
+				*va_arg(ap, short *) = ret;
+			else
+				*va_arg(ap, int *) = ret;
+			continue;	/* no output */
+		case 'O':
+			flags |= LONGINT;
+			/*FALLTHROUGH*/
+		case 'o':
+			ulval = UARG();
+			base = 8;
+			goto nosign;
+		case 'p':
+			/*
+			 * ``The argument shall be a pointer to void.  The
+			 * value of the pointer is converted to a sequence
+			 * of printable characters, in an implementation-
+			 * defined manner.''
+			 *	-- ANSI X3J11
+			 */
+			ulval = (u_long)va_arg(ap, void *);
+			base = 16;
+			xdigs = "0123456789abcdef";
+			flags |= HEXPREFIX;
+			ch = 'x';
+			goto nosign;
+		case 's':
+			if ((cp = va_arg(ap, char *)) == NULL)
+				cp = "(null)";
+			if (prec >= 0) {
+				/*
+				 * can't use strlen; can only look for the
+				 * NUL in the first `prec' characters, and
+				 * strlen() will go further.
+				 */
+				char *p = memchr(cp, 0, prec);
+
+				if (p != NULL) {
+					size = p - cp;
+					if (size > prec)
+						size = prec;
+				} else
+					size = prec;
+			} else
+				size = strlen(cp);
+			sign = '\0';
+			break;
+		case 'U':
+			flags |= LONGINT;
+			/*FALLTHROUGH*/
+		case 'u':
+			ulval = UARG();
+			base = 10;
+			goto nosign;
+		case 'X':
+			xdigs = "0123456789ABCDEF";
+			goto hex;
+		case 'x':
+			xdigs = "0123456789abcdef";
+hex:
+			ulval = UARG();
+			base = 16;
+			/* leading 0x/X only if non-zero */
+			if (flags & ALT && ulval != 0)
+				flags |= HEXPREFIX;
+
+			/* unsigned conversions */
+nosign:			sign = '\0';
+			/*
+			 * ``... diouXx conversions ... if a precision is
+			 * specified, the 0 flag will be ignored.''
+			 *	-- ANSI X3J11
+			 */
+number:			if ((dprec = prec) >= 0)
+				flags &= ~ZEROPAD;
+
+			/*
+			 * ``The result of converting a zero value with an
+			 * explicit precision of zero is no characters.''
+			 *	-- ANSI X3J11
+			 */
+			cp = buf + BUF;
+			if (ulval != 0 || prec != 0)
+				cp = __ultoa(ulval, cp, base,
+					     flags & ALT, xdigs);
+			size = buf + BUF - cp;
+			break;
+		default:	/* "%?" prints ?, unless ? is NUL */
+			if (ch == '\0')
+				goto done;
+			/* pretend it was %c with argument ch */
+			cp = buf;
+			*cp = ch;
+			size = 1;
+			sign = '\0';
+			break;
+		}
+
+		/*
+		 * All reasonable formats wind up here.  At this point, `cp'
+		 * points to a string which (if not flags&LADJUST) should be
+		 * padded out to `width' places.  If flags&ZEROPAD, it should
+		 * first be prefixed by any sign or other prefix; otherwise,
+		 * it should be blank padded before the prefix is emitted.
+		 * After any left-hand padding and prefixing, emit zeroes
+		 * required by a decimal [diouxX] precision, then print the
+		 * string proper, then emit zeroes required by any leftover
+		 * floating precision; finally, if LADJUST, pad with blanks.
+		 *
+		 * Compute actual size, so we know how much to pad.
+		 * fieldsz excludes decimal prec; realsz includes it.
+		 */
+		fieldsz = size;
+		if (sign)
+			fieldsz++;
+		else if (flags & HEXPREFIX)
+			fieldsz += 2;
+		realsz = dprec > fieldsz ? dprec : fieldsz;
+
+		/* right-adjusting blank padding */
+		if ((flags & (LADJUST|ZEROPAD)) == 0)
+			PAD(width - realsz, blanks);
+
+		/* prefix */
+		if (sign) {
+			PRINT(&sign, 1);
+		} else if (flags & HEXPREFIX) {
+			ox[0] = '0';
+			ox[1] = ch;
+			PRINT(ox, 2);
+		}
+
+		/* right-adjusting zero padding */
+		if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
+			PAD(width - realsz, zeroes);
+
+		/* leading zeroes from decimal precision */
+		PAD(dprec - fieldsz, zeroes);
+
+		/* the string or number proper */
+		PRINT(cp, size);
+
+		/* left-adjusting padding (always blank) */
+		if (flags & LADJUST)
+			PAD(width - realsz, blanks);
+
+		/* finally, adjust ret */
+		ret += width > realsz ? width : realsz;
+
+		FLUSH();	/* copy out the I/O vectors */
+	}
+done:
+	FLUSH();
+error:
+	return (__sferror(fp) ? EOF : ret);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vfscanf.c b/prex-0.9.0/usr/lib/libc/stdio/vfscanf.c
new file mode 100755
index 0000000..a63e367
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vfscanf.c
@@ -0,0 +1,634 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include "local.h"
+
+#define	BUF		513	/* Maximum length of numeric string. */
+
+/*
+ * Flags used during conversion.
+ */
+#define	LONG		0x01	/* l: long or double */
+#define	LONGDBL		0x02	/* L: long double; unimplemented */
+#define	SHORT		0x04	/* h: short */
+#define	SUPPRESS	0x08	/* suppress assignment */
+#define	POINTER		0x10	/* weird %p pointer (`fake hex') */
+#define	NOSKIP		0x20	/* do not skip blanks */
+
+/*
+ * The following are used in numeric conversions only:
+ * SIGNOK, NDIGITS, DPTOK, and EXPOK are for floating point;
+ * SIGNOK, NDIGITS, PFXOK, and NZDIGITS are for integral.
+ */
+#define	SIGNOK		0x40	/* +/- is (still) legal */
+#define	NDIGITS		0x80	/* no digits detected */
+
+#define	DPTOK		0x100	/* (float) decimal point is still legal */
+#define	EXPOK		0x200	/* (float) exponent (e+3, etc) still legal */
+
+#define	PFXOK		0x100	/* 0x prefix is (still) legal */
+#define	NZDIGITS	0x200	/* no zero digits detected */
+
+/*
+ * Conversion types.
+ */
+#define	CT_CHAR		0	/* %c conversion */
+#define	CT_CCL		1	/* %[...] conversion */
+#define	CT_STRING	2	/* %s conversion */
+#define	CT_INT		3	/* integer, i.e., strtol or strtoul */
+#define	CT_FLOAT	4	/* floating, i.e., strtod */
+
+#define u_char unsigned char
+#define u_long unsigned long
+
+static u_char *__sccl(char *, u_char *);
+
+/*
+ * vfscanf
+ */
+int
+__svfscanf(fp, fmt0, ap)
+	FILE *fp;
+	char const *fmt0;
+	va_list ap;
+{
+	u_char *fmt = (u_char *)fmt0;
+	int c;		/* character from format, or conversion */
+	size_t width;	/* field width, or 0 */
+	char *p;	/* points into all kinds of strings */
+	int n;		/* handy integer */
+	int flags;	/* flags as defined above */
+	char *p0;	/* saves original value of p when necessary */
+	int nassigned;		/* number of fields assigned */
+	int nread;		/* number of characters consumed from fp */
+	int base;		/* base argument to strtol/strtoul */
+	u_long (*ccfn)(const char *, char **, int);
+				/* conversion function (strtol/strtoul) */
+	char ccltab[256];	/* character class table for %[...] */
+	char buf[BUF];		/* buffer for numeric conversions */
+
+	/* `basefix' is used to avoid `if' tests in the integer scanner */
+	static short basefix[17] =
+		{ 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+
+	nassigned = 0;
+	nread = 0;
+	base = 0;		/* XXX just to keep gcc happy */
+	ccfn = 0;		/* XXX just to keep gcc happy */
+	for (;;) {
+		c = *fmt++;
+		if (c == 0)
+			return (nassigned);
+		if (isspace(c)) {
+			for (;;) {
+				if (fp->_r <= 0 && __srefill(fp))
+					return (nassigned);
+				if (!isspace(*fp->_p))
+					break;
+				nread++, fp->_r--, fp->_p++;
+			}
+			continue;
+		}
+		if (c != '%')
+			goto literal;
+		width = 0;
+		flags = 0;
+		/*
+		 * switch on the format.  continue if done;
+		 * break once format type is derived.
+		 */
+again:		c = *fmt++;
+		switch (c) {
+		case '%':
+literal:
+			if (fp->_r <= 0 && __srefill(fp))
+				goto input_failure;
+			if (*fp->_p != c)
+				goto match_failure;
+			fp->_r--, fp->_p++;
+			nread++;
+			continue;
+
+		case '*':
+			flags |= SUPPRESS;
+			goto again;
+		case 'l':
+			flags |= LONG;
+			goto again;
+		case 'L':
+			flags |= LONGDBL;
+			goto again;
+		case 'h':
+			flags |= SHORT;
+			goto again;
+
+		case '0': case '1': case '2': case '3': case '4':
+		case '5': case '6': case '7': case '8': case '9':
+			width = width * 10 + c - '0';
+			goto again;
+
+		/*
+		 * Conversions.
+		 * Those marked `compat' are for 4.[123]BSD compatibility.
+		 *
+		 * (According to ANSI, E and X formats are supposed
+		 * to the same as e and x.  Sorry about that.)
+		 */
+		case 'D':	/* compat */
+			flags |= LONG;
+			/* FALLTHROUGH */
+		case 'd':
+			c = CT_INT;
+			ccfn = (u_long (*)(const char *, char **, int))strtol;
+			base = 10;
+			break;
+
+		case 'i':
+			c = CT_INT;
+			ccfn = (u_long (*)(const char *, char **, int))strtol;
+			base = 0;
+			break;
+
+		case 'O':	/* compat */
+			flags |= LONG;
+			/* FALLTHROUGH */
+		case 'o':
+			c = CT_INT;
+			ccfn = strtoul;
+			base = 8;
+			break;
+
+		case 'u':
+			c = CT_INT;
+			ccfn = strtoul;
+			base = 10;
+			break;
+
+		case 'X':	/* compat   XXX */
+			flags |= LONG;
+			/* FALLTHROUGH */
+		case 'x':
+			flags |= PFXOK;	/* enable 0x prefixing */
+			c = CT_INT;
+			ccfn = strtoul;
+			base = 16;
+			break;
+
+		case 's':
+			c = CT_STRING;
+			break;
+
+		case '[':
+			fmt = __sccl(ccltab, fmt);
+			flags |= NOSKIP;
+			c = CT_CCL;
+			break;
+
+		case 'c':
+			flags |= NOSKIP;
+			c = CT_CHAR;
+			break;
+
+		case 'p':	/* pointer format is like hex */
+			flags |= POINTER | PFXOK;
+			c = CT_INT;
+			ccfn = strtoul;
+			base = 16;
+			break;
+
+		case 'n':
+			if (flags & SUPPRESS)	/* ??? */
+				continue;
+			if (flags & SHORT)
+				*va_arg(ap, short *) = nread;
+			else if (flags & LONG)
+				*va_arg(ap, long *) = nread;
+			else
+				*va_arg(ap, int *) = nread;
+			continue;
+
+		/*
+		 * Disgusting backwards compatibility hacks.	XXX
+		 */
+		case '\0':	/* compat */
+			return (EOF);
+
+		default:	/* compat */
+			if (isupper(c))
+				flags |= LONG;
+			c = CT_INT;
+			ccfn = (u_long (*)(const char *, char **, int))strtol;
+			base = 10;
+			break;
+		}
+
+		/*
+		 * We have a conversion that requires input.
+		 */
+		if (fp->_r <= 0 && __srefill(fp))
+			goto input_failure;
+
+		/*
+		 * Consume leading white space, except for formats
+		 * that suppress this.
+		 */
+		if ((flags & NOSKIP) == 0) {
+			while (isspace(*fp->_p)) {
+				nread++;
+				if (--fp->_r > 0)
+					fp->_p++;
+				else if (__srefill(fp))
+					goto input_failure;
+			}
+			/*
+			 * Note that there is at least one character in
+			 * the buffer, so conversions that do not set NOSKIP
+			 * ca no longer result in an input failure.
+			 */
+		}
+
+		/*
+		 * Do the conversion.
+		 */
+		switch (c) {
+
+		case CT_CHAR:
+			/* scan arbitrary characters (sets NOSKIP) */
+			if (width == 0)
+				width = 1;
+			if (flags & SUPPRESS) {
+				size_t sum = 0;
+				for (;;) {
+					if ((size_t)(n = fp->_r) < width) {
+						sum += n;
+						width -= n;
+						fp->_p += n;
+						if (__srefill(fp)) {
+							if (sum == 0)
+							    goto input_failure;
+							break;
+						}
+					} else {
+						sum += width;
+						fp->_r -= width;
+						fp->_p += width;
+						break;
+					}
+				}
+				nread += sum;
+			} else {
+				size_t r = fread((void *)va_arg(ap, char *), 1,
+				    width, fp);
+
+				if (r == 0)
+					goto input_failure;
+				nread += r;
+				nassigned++;
+			}
+			break;
+
+		case CT_CCL:
+			/* scan a (nonempty) character class (sets NOSKIP) */
+			if (width == 0)
+				width = ~0;	/* `infinity' */
+			/* take only those things in the class */
+			if (flags & SUPPRESS) {
+				n = 0;
+				while (ccltab[*fp->_p]) {
+					n++, fp->_r--, fp->_p++;
+					if (--width == 0)
+						break;
+					if (fp->_r <= 0 && __srefill(fp)) {
+						if (n == 0)
+							goto input_failure;
+						break;
+					}
+				}
+				if (n == 0)
+					goto match_failure;
+			} else {
+				p0 = p = va_arg(ap, char *);
+				while (ccltab[*fp->_p]) {
+					fp->_r--;
+					*p++ = *fp->_p++;
+					if (--width == 0)
+						break;
+					if (fp->_r <= 0 && __srefill(fp)) {
+						if (p == p0)
+							goto input_failure;
+						break;
+					}
+				}
+				n = p - p0;
+				if (n == 0)
+					goto match_failure;
+				*p = 0;
+				nassigned++;
+			}
+			nread += n;
+			break;
+
+		case CT_STRING:
+			/* like CCL, but zero-length string OK, & no NOSKIP */
+			if (width == 0)
+				width = ~0;
+			if (flags & SUPPRESS) {
+				n = 0;
+				while (!isspace(*fp->_p)) {
+					n++, fp->_r--, fp->_p++;
+					if (--width == 0)
+						break;
+					if (fp->_r <= 0 && __srefill(fp))
+						break;
+				}
+				nread += n;
+			} else {
+				p0 = p = va_arg(ap, char *);
+				while (!isspace(*fp->_p)) {
+					fp->_r--;
+					*p++ = *fp->_p++;
+					if (--width == 0)
+						break;
+					if (fp->_r <= 0 && __srefill(fp))
+						break;
+				}
+				*p = 0;
+				nread += p - p0;
+				nassigned++;
+			}
+			continue;
+
+		case CT_INT:
+			/* scan an integer as if by strtol/strtoul */
+#ifdef hardway
+			if (width == 0 || width > sizeof(buf) - 1)
+				width = sizeof(buf) - 1;
+#else
+			/* size_t is unsigned, hence this optimisation */
+			if (--width > sizeof(buf) - 2)
+				width = sizeof(buf) - 2;
+			width++;
+#endif
+			flags |= SIGNOK | NDIGITS | NZDIGITS;
+			for (p = buf; width; width--) {
+				c = *fp->_p;
+				/*
+				 * Switch on the character; `goto ok'
+				 * if we accept it as a part of number.
+				 */
+				switch (c) {
+
+				/*
+				 * The digit 0 is always legal, but is
+				 * special.  For %i conversions, if no
+				 * digits (zero or nonzero) have been
+				 * scanned (only signs), we will have
+				 * base==0.  In that case, we should set
+				 * it to 8 and enable 0x prefixing.
+				 * Also, if we have not scanned zero digits
+				 * before this, do not turn off prefixing
+				 * (someone else will turn it off if we
+				 * have scanned any nonzero digits).
+				 */
+				case '0':
+					if (base == 0) {
+						base = 8;
+						flags |= PFXOK;
+					}
+					if (flags & NZDIGITS)
+					    flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
+					else
+					    flags &= ~(SIGNOK|PFXOK|NDIGITS);
+					goto ok;
+
+				/* 1 through 7 always legal */
+				case '1': case '2': case '3':
+				case '4': case '5': case '6': case '7':
+					base = basefix[base];
+					flags &= ~(SIGNOK | PFXOK | NDIGITS);
+					goto ok;
+
+				/* digits 8 and 9 ok iff decimal or hex */
+				case '8': case '9':
+					base = basefix[base];
+					if (base <= 8)
+						break;	/* not legal here */
+					flags &= ~(SIGNOK | PFXOK | NDIGITS);
+					goto ok;
+
+				/* letters ok iff hex */
+				case 'A': case 'B': case 'C':
+				case 'D': case 'E': case 'F':
+				case 'a': case 'b': case 'c':
+				case 'd': case 'e': case 'f':
+					/* no need to fix base here */
+					if (base <= 10)
+						break;	/* not legal here */
+					flags &= ~(SIGNOK | PFXOK | NDIGITS);
+					goto ok;
+
+				/* sign ok only as first character */
+				case '+': case '-':
+					if (flags & SIGNOK) {
+						flags &= ~SIGNOK;
+						goto ok;
+					}
+					break;
+
+				/* x ok iff flag still set & 2nd char */
+				case 'x': case 'X':
+					if (flags & PFXOK && p == buf + 1) {
+						base = 16;	/* if %i */
+						flags &= ~PFXOK;
+						goto ok;
+					}
+					break;
+				}
+
+				/*
+				 * If we got here, c is not a legal character
+				 * for a number.  Stop accumulating digits.
+				 */
+				break;
+		ok:
+				/*
+				 * c is legal: store it and look at the next.
+				 */
+				*p++ = c;
+				if (--fp->_r > 0)
+					fp->_p++;
+				else if (__srefill(fp))
+					break;		/* EOF */
+			}
+			/*
+			 * If we had only a sign, it is no good; push
+			 * back the sign.  If the number ends in `x',
+			 * it was [sign] '0' 'x', so push back the x
+			 * and treat it as [sign] '0'.
+			 */
+			if (flags & NDIGITS) {
+				if (p > buf)
+					(void) ungetc(*(u_char *)--p, fp);
+				goto match_failure;
+			}
+			c = ((u_char *)p)[-1];
+			if (c == 'x' || c == 'X') {
+				--p;
+				(void) ungetc(c, fp);
+			}
+			if ((flags & SUPPRESS) == 0) {
+				u_long res;
+
+				*p = 0;
+				res = (*ccfn)(buf, (char **)NULL, base);
+				if (flags & POINTER)
+					*va_arg(ap, void **) = (void *)res;
+				else if (flags & SHORT)
+					*va_arg(ap, short *) = res;
+				else if (flags & LONG)
+					*va_arg(ap, long *) = res;
+				else
+					*va_arg(ap, int *) = res;
+				nassigned++;
+			}
+			nread += p - buf;
+			break;
+
+		}
+	}
+input_failure:
+	return (nassigned ? nassigned : -1);
+match_failure:
+	return (nassigned);
+}
+
+/*
+ * Fill in the given table from the scanset at the given format
+ * (just after `[').  Return a pointer to the character past the
+ * closing `]'.  The table has a 1 wherever characters should be
+ * considered part of the scanset.
+ */
+static u_char *
+__sccl(tab, fmt)
+	char *tab;
+	u_char *fmt;
+{
+	int c, n, v;
+
+	/* first `clear' the whole table */
+	c = *fmt++;		/* first char hat => negated scanset */
+	if (c == '^') {
+		v = 1;		/* default => accept */
+		c = *fmt++;	/* get new first char */
+	} else
+		v = 0;		/* default => reject */
+	/* should probably use memset here */
+	for (n = 0; n < 256; n++)
+		tab[n] = v;
+	if (c == 0)
+		return (fmt - 1);/* format ended before closing ] */
+
+	/*
+	 * Now set the entries corresponding to the actual scanset
+	 * to the opposite of the above.
+	 *
+	 * The first character may be ']' (or '-') without being special;
+	 * the last character may be '-'.
+	 */
+	v = 1 - v;
+	for (;;) {
+		tab[c] = v;		/* take character c */
+doswitch:
+		n = *fmt++;		/* and examine the next */
+		switch (n) {
+
+		case 0:			/* format ended too soon */
+			return (fmt - 1);
+
+		case '-':
+			/*
+			 * A scanset of the form
+			 *	[01+-]
+			 * is defined as `the digit 0, the digit 1,
+			 * the character +, the character -', but
+			 * the effect of a scanset such as
+			 *	[a-zA-Z0-9]
+			 * is implementation defined.  The V7 Unix
+			 * scanf treats `a-z' as `the letters a through
+			 * z', but treats `a-a' as `the letter a, the
+			 * character -, and the letter a'.
+			 *
+			 * For compatibility, the `-' is not considerd
+			 * to define a range if the character following
+			 * it is either a close bracket (required by ANSI)
+			 * or is not numerically greater than the character
+			 * we just stored in the table (c).
+			 */
+			n = *fmt;
+			if (n == ']' || n < c) {
+				c = '-';
+				break;	/* resume the for(;;) */
+			}
+			fmt++;
+			do {		/* fill in the range */
+				tab[++c] = v;
+			} while (c < n);
+#if 1	/* XXX another disgusting compatibility hack */
+			/*
+			 * Alas, the V7 Unix scanf also treats formats
+			 * such as [a-c-e] as `the letters a through e'.
+			 * This too is permitted by the standard....
+			 */
+			goto doswitch;
+#else
+			c = *fmt++;
+			if (c == 0)
+				return (fmt - 1);
+			if (c == ']')
+				return (fmt);
+#endif
+			break;
+
+		case ']':		/* end of scanset */
+			return (fmt);
+
+		default:		/* just another character */
+			c = n;
+			break;
+		}
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vprintf.c b/prex-0.9.0/usr/lib/libc/stdio/vprintf.c
new file mode 100755
index 0000000..8574569
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vprintf.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+vprintf(fmt, ap)
+	char const *fmt;
+	va_list ap;
+{
+	return (vfprintf(stdout, fmt, ap));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vscanf.c b/prex-0.9.0/usr/lib/libc/stdio/vscanf.c
new file mode 100755
index 0000000..78f1475
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vscanf.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Donn Seeley at UUNET Technologies, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+vscanf(fmt, ap)
+	const char *fmt;
+	va_list ap;
+{
+
+	return (__svfscanf(stdin, fmt, ap));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vsnprintf.c b/prex-0.9.0/usr/lib/libc/stdio/vsnprintf.c
new file mode 100755
index 0000000..43ddee9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vsnprintf.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+
+int
+vsnprintf(str, n, fmt, ap)
+	char *str;
+	size_t n;
+	const char *fmt;
+	va_list ap;
+{
+	int ret;
+	FILE f;
+
+	if ((int)n < 1)
+		return (EOF);
+	f._flags = __SWR | __SSTR;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._w = n - 1;
+	ret = vfprintf(&f, fmt, ap);
+	*f._p = 0;
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vsprintf.c b/prex-0.9.0/usr/lib/libc/stdio/vsprintf.c
new file mode 100755
index 0000000..e08c88d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vsprintf.c
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <limits.h>
+
+int
+vsprintf(str, fmt, ap)
+	char *str;
+	const char *fmt;
+	va_list ap;
+{
+	int ret;
+	FILE f;
+
+	f._flags = __SWR | __SSTR;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._w = INT_MAX;
+	ret = vfprintf(&f, fmt, ap);
+	*f._p = 0;
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/vsscanf.c b/prex-0.9.0/usr/lib/libc/stdio/vsscanf.c
new file mode 100755
index 0000000..b547143
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/vsscanf.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Donn Seeley at UUNET Technologies, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+int
+vsscanf(str, fmt, ap)
+	const char *str;
+	const char *fmt;
+	va_list ap;
+{
+	FILE f;
+
+	f._flags = __SRD;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._r = strlen(str);
+	return (__svfscanf(&f, fmt, ap));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdio/wsetup.c b/prex-0.9.0/usr/lib/libc/stdio/wsetup.c
new file mode 100755
index 0000000..1b4b8c4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdio/wsetup.c
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "local.h"
+
+
+/*
+ * Various output routines call wsetup to be sure it is safe to write,
+ * because either _flags does not include __SWR, or _buf is NULL.
+ * _wsetup returns 0 if OK to write, nonzero otherwise.
+ */
+int
+__swsetup(fp)
+	FILE *fp;
+{
+	/* make sure stdio is set up */
+	if (!__sdidinit)
+		__sinit();
+
+	/*
+	 * If we are not writing, we had better be reading and writing.
+	 */
+	if ((fp->_flags & __SWR) == 0) {
+		if ((fp->_flags & __SRW) == 0)
+			return (EOF);
+		if (fp->_flags & __SRD) {
+			/* clobber any ungetc data */
+			if (HASUB(fp))
+				FREEUB(fp);
+			fp->_flags &= ~(__SRD|__SEOF);
+			fp->_r = 0;
+			fp->_p = fp->_bf._base;
+		}
+		fp->_flags |= __SWR;
+	}
+
+	/*
+	 * Make a buffer if necessary, then set _w.
+	 */
+	if (fp->_bf._base == NULL)
+		__smakebuf(fp);
+
+	fp->_w = fp->_flags & (__SNBF|__SLBF) ? 0 : fp->_bf._size;
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/Makefile.inc b/prex-0.9.0/usr/lib/libc/stdlib/Makefile.inc
new file mode 100755
index 0000000..8440de2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/Makefile.inc
@@ -0,0 +1,5 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/stdlib:$(VPATH)
+
+SRCS+=	abort.c abs.c atexit.c atof.c atoi.c atol.c div.c exit.c \
+	getopt.c getsubopt.c strtol.c strtoul.c rand.c random.c \
+	getenv.c setenv.c calloc.c putenv.c qsort.c
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/abort.c b/prex-0.9.0/usr/lib/libc/stdlib/abort.c
new file mode 100755
index 0000000..438a198
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/abort.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <unistd.h>
+
+void
+abort()
+{
+#ifdef _STANDALONE
+	exit(1);
+#else
+	sigset_t mask;
+
+	sigfillset(&mask);
+	/*
+	 * don't block SIGABRT to give any handler a chance; we ignore
+	 * any errors -- X311J doesn't allow abort to return anyway.
+	 */
+	sigdelset(&mask, SIGABRT);
+	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+	(void)kill(getpid(), SIGABRT);
+
+	/*
+	 * if SIGABRT ignored, or caught and the handler returns, do
+	 * it again, only harder.
+	 */
+	(void)signal(SIGABRT, SIG_DFL);
+	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+	(void)kill(getpid(), SIGABRT);
+	exit(1);
+#endif
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/abs.c b/prex-0.9.0/usr/lib/libc/stdlib/abs.c
new file mode 100755
index 0000000..afe39fa
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/abs.c
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+int
+abs(j)
+	int j;
+{
+	return(j < 0 ? -j : j);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/atexit.c b/prex-0.9.0/usr/lib/libc/stdlib/atexit.c
new file mode 100755
index 0000000..eaae7fb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/atexit.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include "atexit.h"
+
+exit_fnc __atexit_list[ATEXIT_SIZE];
+int __atexit_index = 0;
+
+/*
+ * Register a function to be performed at exit.
+ */
+int
+atexit(fn)
+	void (*fn)(void);
+{
+	if (__atexit_index >= ATEXIT_SIZE)
+		return -1;
+	__atexit_list[__atexit_index] = fn;
+	__atexit_index++;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/atexit.h b/prex-0.9.0/usr/lib/libc/stdlib/atexit.h
new file mode 100755
index 0000000..f99ff12
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/atexit.h
@@ -0,0 +1,39 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)atexit.h	8.2 (Berkeley) 7/3/94
+ */
+
+/* must be at least 32 to guarantee ANSI conformance */
+/* PREX: #define	ATEXIT_SIZE	32 */
+#define	ATEXIT_SIZE	8
+
+typedef void (*exit_fnc)(void);
+
+extern exit_fnc __atexit_list[ATEXIT_SIZE];
+extern int __atexit_index;
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/atof.c b/prex-0.9.0/usr/lib/libc/stdlib/atof.c
new file mode 100755
index 0000000..77b76ce
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/atof.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+
+double
+atof(ascii)
+	const char *ascii;
+{
+	return (strtod(ascii, NULL));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/atoi.c b/prex-0.9.0/usr/lib/libc/stdlib/atoi.c
new file mode 100755
index 0000000..2fb6bb8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/atoi.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+
+int
+atoi(str)
+	const char *str;
+{
+	return((int)strtol(str, (char **)NULL, 10));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/atol.c b/prex-0.9.0/usr/lib/libc/stdlib/atol.c
new file mode 100755
index 0000000..5da619d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/atol.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+
+long
+atol(str)
+	const char *str;
+{
+	return(strtol(str, (char **)NULL, 10));
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/calloc.c b/prex-0.9.0/usr/lib/libc/stdlib/calloc.c
new file mode 100755
index 0000000..0f3679c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/calloc.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+void *
+calloc(num, size)
+	size_t num;
+	size_t size;
+{
+	void *p;
+
+	size *= num;
+	if ((p = malloc(size)) != NULL)
+		bzero(p, size);
+	return(p);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/div.c b/prex-0.9.0/usr/lib/libc/stdlib/div.c
new file mode 100755
index 0000000..aa98100
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/div.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>		/* div_t */
+
+div_t
+div(num, denom)
+	int num, denom;
+{
+	div_t r;
+
+	r.quot = num / denom;
+	r.rem = num % denom;
+	/*
+	 * The ANSI standard says that |r.quot| <= |n/d|, where
+	 * n/d is to be computed in infinite precision.  In other
+	 * words, we should always truncate the quotient towards
+	 * 0, never -infinity.
+	 *
+	 * Machine division and remainer may work either way when
+	 * one or both of n or d is negative.  If only one is
+	 * negative and r.quot has been truncated towards -inf,
+	 * r.rem will have the same sign as denom and the opposite
+	 * sign of num; if both are negative and r.quot has been
+	 * truncated towards -inf, r.rem will be positive (will
+	 * have the opposite sign of num).  These are considered
+	 * `wrong'.
+	 *
+	 * If both are num and denom are positive, r will always
+	 * be positive.
+	 *
+	 * This all boils down to:
+	 *	if num >= 0, but r.rem < 0, we got the wrong answer.
+	 * In that case, to get the right answer, add 1 to r.quot and
+	 * subtract denom from r.rem.
+	 */
+	if (num >= 0 && r.rem < 0) {
+		r.quot++;
+		r.rem -= denom;
+	}
+	return (r);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/exit.c b/prex-0.9.0/usr/lib/libc/stdlib/exit.c
new file mode 100755
index 0000000..d1710e1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/exit.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include "atexit.h"
+
+void (*__cleanup)(void);
+
+/*
+ * Exit, flushing stdio buffers if necessary.
+ */
+void
+exit(int status)
+{
+	int i = __atexit_index;
+
+	while (i) {
+		__atexit_list[i]();
+		i--;
+	}
+	if (__cleanup)
+		(*__cleanup)();
+
+	_exit(status);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/getenv.c b/prex-0.9.0/usr/lib/libc/stdlib/getenv.c
new file mode 100755
index 0000000..d97fe07
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/getenv.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 1987, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+extern char **environ;
+
+char *__findenv(const char *, int *);
+
+/*
+ * getenv --
+ *	Returns ptr to value associated with name, if any, else NULL.
+ */
+char *
+getenv(name)
+	const char *name;
+{
+	int offset;
+
+	return (__findenv(name, &offset));
+}
+
+/*
+ * __findenv --
+ *	Returns pointer to value associated with name, if any, else NULL.
+ *	Sets offset to be the offset of the name/value combination in the
+ *	environmental array, for use by setenv(3) and unsetenv(3).
+ *	Explicitly removes '=' in argument name.
+ *
+ *	This routine *should* be a static; don't use it.
+ */
+char *
+__findenv(name, offset)
+	const char *name;
+	int *offset;
+{
+	size_t len;
+	const char *np;
+	char **p, *c;
+
+	if (name == NULL || environ == NULL)
+		return (NULL);
+	for (np = name; *np && *np != '='; ++np)
+		continue;
+	len = np - name;
+	for (p = environ; (c = *p) != NULL; ++p)
+		if (strncmp(c, name, len) == 0 && c[len] == '=') {
+			*offset = p - environ;
+			return (c + len + 1);
+		}
+	return (NULL);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/getopt.c b/prex-0.9.0/usr/lib/libc/stdlib/getopt.c
new file mode 100755
index 0000000..ec355bf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/getopt.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 1987, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int	opterr = 1,		/* if error message should be printed */
+	optind = 1,		/* index into parent argv vector */
+	optopt,			/* character checked for validity */
+	optreset;		/* reset getopt */
+char	*optarg;		/* argument associated with option */
+
+#define	BADCH	(int)'?'
+#define	BADARG	(int)':'
+#define	EMSG	""
+
+/*
+ * getopt --
+ *	Parse argc/argv argument vector.
+ */
+int
+getopt(int nargc, char * const nargv[], const char *ostr)
+{
+#if 0
+	extern char *__progname;
+#endif
+	static char *place = EMSG;		/* option letter processing */
+	char *oli;				/* option letter list index */
+
+	if (optreset || !*place) {		/* update scanning pointer */
+		optreset = 0;
+		if (optind >= nargc || *(place = nargv[optind]) != '-') {
+			place = EMSG;
+			return (-1);
+		}
+		if (place[1] && *++place == '-') {	/* found "--" */
+			++optind;
+			place = EMSG;
+			return (-1);
+		}
+	}					/* option letter okay? */
+	if ((optopt = (int)*place++) == (int)':' ||
+	    !(oli = strchr(ostr, optopt))) {
+		/*
+		 * if the user didn't specify '-' as an option,
+		 * assume it means -1.
+		 */
+		if (optopt == (int)'-')
+			return (-1);
+		if (!*place)
+			++optind;
+#if 0
+		if (opterr && *ostr != ':')
+			(void)fprintf(stderr,
+			    "%s: illegal option -- %c\n", __progname, optopt);
+#endif
+		return (BADCH);
+	}
+	if (*++oli != ':') {			/* don't need argument */
+		optarg = NULL;
+		if (!*place)
+			++optind;
+	}
+	else {					/* need an argument */
+		if (*place)			/* no white space */
+			optarg = place;
+		else if (nargc <= ++optind) {	/* no arg */
+			place = EMSG;
+			if (*ostr == ':')
+				return (BADARG);
+#if 0
+			if (opterr)
+				(void)fprintf(stderr,
+				    "%s: option requires an argument -- %c\n",
+				    __progname, optopt);
+#endif
+			return (BADCH);
+		}
+	 	else				/* white space */
+			optarg = nargv[optind];
+		place = EMSG;
+		++optind;
+	}
+	return (optopt);			/* dump back option letter */
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/getsubopt.c b/prex-0.9.0/usr/lib/libc/stdlib/getsubopt.c
new file mode 100755
index 0000000..c14b42a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/getsubopt.c
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * The SVID interface to getsubopt provides no way of figuring out which
+ * part of the suboptions list wasn't matched.  This makes error messages
+ * tricky...  The extern variable suboptarg is a pointer to the token
+ * which didn't match.
+ */
+char *suboptarg;
+
+int
+getsubopt(optionp, tokens, valuep)
+	char **optionp, **valuep;
+	char * const *tokens;
+{
+	int cnt;
+	char *p;
+
+	suboptarg = *valuep = NULL;
+
+	if (!optionp || !*optionp)
+		return(-1);
+
+	/* skip leading white-space, commas */
+	for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+
+	if (!*p) {
+		*optionp = p;
+		return(-1);
+	}
+
+	/* save the start of the token, and skip the rest of the token. */
+	for (suboptarg = p;
+	    *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
+
+	if (*p) {
+		/*
+		 * If there's an equals sign, set the value pointer, and
+		 * skip over the value part of the token.  Terminate the
+		 * token.
+		 */
+		if (*p == '=') {
+			*p = '\0';
+			for (*valuep = ++p;
+			    *p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
+			if (*p)
+				*p++ = '\0';
+		} else
+			*p++ = '\0';
+		/* Skip any whitespace or commas after this token. */
+		for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+	}
+
+	/* set optionp for next round. */
+	*optionp = p;
+
+	for (cnt = 0; *tokens; ++tokens, ++cnt)
+		if (!strcmp(suboptarg, *tokens))
+			return(cnt);
+	return(-1);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/putenv.c b/prex-0.9.0/usr/lib/libc/stdlib/putenv.c
new file mode 100755
index 0000000..05d1a65
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/putenv.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+int
+putenv(str)
+	const char *str;
+{
+	char *p, *equal;
+	int rval;
+
+	if ((p = strdup(str)) == NULL)
+		return (-1);
+	if ((equal = index(p, '=')) == NULL) {
+		(void)free(p);
+		return (-1);
+	}
+	*equal = '\0';
+	rval = setenv(p, equal + 1, 1);
+	(void)free(p);
+	return (rval);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/qsort.c b/prex-0.9.0/usr/lib/libc/stdlib/qsort.c
new file mode 100755
index 0000000..6b31da8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/qsort.c
@@ -0,0 +1,171 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+
+static __inline char	*med3(char *, char *, char *,
+    int (*)(const void *, const void *));
+static __inline void	 swapfunc(char *, char *, size_t, int);
+
+#define min(a, b)	(a) < (b) ? a : b
+
+/*
+ * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
+ */
+#define swapcode(TYPE, parmi, parmj, n) { 		\
+	size_t i = (n) / sizeof (TYPE); 		\
+	TYPE *pi = (TYPE *)(void *)(parmi); 		\
+	TYPE *pj = (TYPE *)(void *)(parmj); 		\
+	do { 						\
+		TYPE	t = *pi;			\
+		*pi++ = *pj;				\
+		*pj++ = t;				\
+        } while (--i > 0);				\
+}
+
+#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
+	es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
+
+static __inline void
+swapfunc(a, b, n, swaptype)
+	char *a, *b;
+	size_t n;
+	int swaptype;
+{
+	if (swaptype <= 1)
+		swapcode(long, a, b, n)
+	else
+		swapcode(char, a, b, n)
+}
+
+#define swap(a, b)						\
+	if (swaptype == 0) {					\
+		long t = *(long *)(void *)(a);			\
+		*(long *)(void *)(a) = *(long *)(void *)(b);	\
+		*(long *)(void *)(b) = t;			\
+	} else							\
+		swapfunc(a, b, es, swaptype)
+
+#define vecswap(a, b, n) if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
+
+static __inline char *
+med3(a, b, c, cmp)
+	char *a, *b, *c;
+	int (*cmp)(const void *, const void *);
+{
+	return cmp(a, b) < 0 ?
+	       (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
+              :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
+}
+
+void
+qsort(a, n, es, cmp)
+	void *a;
+	size_t n, es;
+	int (*cmp)(const void *, const void *);
+{
+	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
+	int d, r, swaptype, swap_cnt;
+
+loop:	SWAPINIT(a, es);
+	swap_cnt = 0;
+	if (n < 7) {
+		for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
+			for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+	pm = (char *) a + (n / 2) * es;
+	if (n > 7) {
+		pl = (char *) a;
+		pn = (char *) a + (n - 1) * es;
+		if (n > 40) {
+			d = (n / 8) * es;
+			pl = med3(pl, pl + d, pl + 2 * d, cmp);
+			pm = med3(pm - d, pm, pm + d, cmp);
+			pn = med3(pn - 2 * d, pn - d, pn, cmp);
+		}
+		pm = med3(pl, pm, pn, cmp);
+	}
+	swap(a, pm);
+	pa = pb = (char *) a + es;
+
+	pc = pd = (char *) a + (n - 1) * es;
+	for (;;) {
+		while (pb <= pc && (r = cmp(pb, a)) <= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pa, pb);
+				pa += es;
+			}
+			pb += es;
+		}
+		while (pb <= pc && (r = cmp(pc, a)) >= 0) {
+			if (r == 0) {
+				swap_cnt = 1;
+				swap(pc, pd);
+				pd -= es;
+			}
+			pc -= es;
+		}
+		if (pb > pc)
+			break;
+		swap(pb, pc);
+		swap_cnt = 1;
+		pb += es;
+		pc -= es;
+	}
+	if (swap_cnt == 0) {  /* Switch to insertion sort */
+		for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
+			for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
+			     pl -= es)
+				swap(pl, pl - es);
+		return;
+	}
+	pn = (char *) a + n * es;
+	r = min(pa - (char *) a, pb - pa);
+	vecswap(a, pb - r, r);
+	r = min(pd - pc, pn - pd - es);
+	vecswap(pb, pn - r, r);
+	if ((r = pb - pa) > es)
+		qsort(a, r / es, es, cmp);
+	if ((r = pd - pc) > es) {
+		/* Iterate rather than recurse to save stack space */
+		a = pn - r;
+		n = r / es;
+		goto loop;
+	}
+/*		qsort(pn - r, r / es, es, cmp);*/
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/rand.c b/prex-0.9.0/usr/lib/libc/stdlib/rand.c
new file mode 100755
index 0000000..99cb73b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/rand.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+
+static u_long next = 1;
+
+int
+rand()
+{
+	return ((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
+}
+
+void
+srand(seed)
+u_int seed;
+{
+	next = seed;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/random.c b/prex-0.9.0/usr/lib/libc/stdlib/random.c
new file mode 100755
index 0000000..6f395fd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/random.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)random.c	8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+#define NSHUFF 50       /* to drop some "seed -> 1st value" linearity */
+
+static u_long randseed = 937186357; /* after srandom(1), NSHUFF counted */
+
+void
+srandom(seed)
+	u_long seed;
+{
+	int i;
+
+	randseed = seed;
+	for (i = 0; i < NSHUFF; i++)
+		(void)random();
+}
+
+/*
+ * Pseudo-random number generator for randomizing the profiling clock,
+ * and whatever else we might use it for.  The result is uniform on
+ * [0, 2^31 - 1].
+ */
+long
+random()
+{
+	long x, hi, lo, t;
+
+	/*
+	 * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
+	 * From "Random number generators: good ones are hard to find",
+	 * Park and Miller, Communications of the ACM, vol. 31, no. 10,
+	 * October 1988, p. 1195.
+	 */
+	/* Can't be initialized with 0, so use another value. */
+	if ((x = randseed) == 0)
+		x = 123459876;
+	hi = x / 127773;
+	lo = x % 127773;
+	t = 16807 * lo - 2836 * hi;
+	if (t < 0)
+		t += 0x7fffffff;
+	randseed = t;
+	return (t);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/setenv.c b/prex-0.9.0/usr/lib/libc/stdlib/setenv.c
new file mode 100755
index 0000000..aa9051e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/setenv.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 1987, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+extern char **environ;
+
+char *__findenv(const char *, int *);
+
+/*
+ * setenv --
+ *	Set the value of the environmental variable "name" to be
+ *	"value".  If rewrite is set, replace any current value.
+ */
+int
+setenv(name, value, rewrite)
+	const char *name;
+	const char *value;
+	int rewrite;
+{
+	static int alloced;			/* if allocated space before */
+	char *c;
+	int l_value, offset;
+
+	if (*value == '=')			/* no `=' in value */
+		++value;
+	l_value = strlen(value);
+	if ((c = __findenv(name, &offset))) {	/* find if already exists */
+		if (!rewrite)
+			return (0);
+		if ((int)strlen(c) >= l_value) {	/* old larger; copy over */
+			while ( (*c++ = *value++) );
+			return (0);
+		}
+	} else {					/* create new slot */
+		int cnt;
+		char **p;
+
+		for (p = environ, cnt = 0; *p; ++p, ++cnt);
+		if (alloced) {			/* just increase size */
+			environ = (char **)realloc((char *)environ,
+			    (size_t)(sizeof(char *) * (cnt + 2)));
+			if (!environ)
+				return (-1);
+		}
+		else {				/* get new space */
+			alloced = 1;		/* copy old entries into it */
+			p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
+			if (!p)
+				return (-1);
+			bcopy(environ, p, cnt * sizeof(char *));
+			environ = p;
+		}
+		environ[cnt + 1] = NULL;
+		offset = cnt;
+	}
+	for (c = (char *)name; *c && *c != '='; ++c);	/* no `=' in name */
+	if (!(environ[offset] =			/* name + `=' + value */
+	    malloc((size_t)((int)(c - name) + l_value + 2))))
+		return (-1);
+	for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
+	for (*c++ = '='; (*c++ = *value++) != 0;);
+	return (0);
+}
+
+/*
+ * unsetenv(name) --
+ *	Delete environmental variable "name".
+ */
+void
+unsetenv(name)
+	const char *name;
+{
+	char **p;
+	int offset;
+
+	while (__findenv(name, &offset))	/* if set multiple times */
+		for (p = &environ[offset];; ++p)
+			if (!(*p = *(p + 1)))
+				break;
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/strtol.c b/prex-0.9.0/usr/lib/libc/stdlib/strtol.c
new file mode 100755
index 0000000..51dc992
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/strtol.c
@@ -0,0 +1,143 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+
+
+/*
+ * Convert a string to a long integer.
+ *
+ * Ignores `locale' stuff.  Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long
+strtol(nptr, endptr, base)
+	const char *nptr;
+	char **endptr;
+	int base;
+{
+	const char *s;
+	long acc, cutoff;
+	int c;
+	int neg, any, cutlim;
+
+	/*
+	 * Skip white space and pick up leading +/- sign if any.
+	 * If base is 0, allow 0x for hex and 0 for octal, else
+	 * assume decimal; if base is already 16, allow 0x.
+	 */
+	s = nptr;
+	do {
+		c = (unsigned char) *s++;
+	} while (isspace(c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == '+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == '0' && (*s == 'x' || *s == 'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == '0' ? 8 : 10;
+
+	/*
+	 * Compute the cutoff value between legal numbers and illegal
+	 * numbers.  That is the largest legal value, divided by the
+	 * base.  An input number that is greater than this value, if
+	 * followed by a legal input character, is too big.  One that
+	 * is equal to this value may be valid or not; the limit
+	 * between valid and invalid numbers is then based on the last
+	 * digit.  For instance, if the range for longs is
+	 * [-2147483648..2147483647] and the input base is 10,
+	 * cutoff will be set to 214748364 and cutlim to either
+	 * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+	 * a value > 214748364, or equal but the next digit is > 7 (or 8),
+	 * the number is too big, and we will return a range error.
+	 *
+	 * Set any if any `digits' consumed; make it negative to indicate
+	 * overflow.
+	 */
+	cutoff = neg ? LONG_MIN : LONG_MAX;
+	cutlim = (int)(cutoff % base);
+	cutoff /= base;
+	if (neg) {
+		if (cutlim > 0) {
+			cutlim -= base;
+			cutoff += 1;
+		}
+		cutlim = -cutlim;
+	}
+	for (acc = 0, any = 0;; c = (unsigned char) *s++) {
+		if (isdigit(c))
+			c -= '0';
+		else if (isalpha(c))
+			c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0)
+			continue;
+		if (neg) {
+			if (acc < cutoff || (acc == cutoff && c > cutlim)) {
+				any = -1;
+				acc = LONG_MIN;
+				errno = ERANGE;
+			} else {
+				any = 1;
+				acc *= base;
+				acc -= c;
+			}
+		} else {
+			if (acc > cutoff || (acc == cutoff && c > cutlim)) {
+				any = -1;
+				acc = LONG_MAX;
+				errno = ERANGE;
+			} else {
+				any = 1;
+				acc *= base;
+				acc += c;
+			}
+		}
+	}
+	if (endptr != 0)
+		/* LINTED interface specification */
+		*endptr = (char *)(any ? s - 1 : nptr);
+	return (acc);
+}
diff --git a/prex-0.9.0/usr/lib/libc/stdlib/strtoul.c b/prex-0.9.0/usr/lib/libc/stdlib/strtoul.c
new file mode 100755
index 0000000..acc63e2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/stdlib/strtoul.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/*
+ * Convert a string to an unsigned long integer.
+ *
+ * Ignores `locale' stuff.  Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long
+strtoul(nptr, endptr, base)
+	const char *nptr;
+	char **endptr;
+	register int base;
+{
+	const char *s;
+	unsigned long acc, cutoff;
+	int c;
+	int neg, any, cutlim;
+
+	/*
+	 * See strtol for comments as to the logic used.
+	 */
+	s = nptr;
+	do {
+		c = (unsigned char) *s++;
+	} while (isspace(c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else {
+		neg = 0;
+		if (c == '+')
+			c = *s++;
+	}
+	if ((base == 0 || base == 16) &&
+	    c == '0' && (*s == 'x' || *s == 'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+	if (base == 0)
+		base = c == '0' ? 8 : 10;
+
+	cutoff = ULONG_MAX / (unsigned long)base;
+	cutlim = (int)(ULONG_MAX % (unsigned long)base);
+	for (acc = 0, any = 0;; c = (unsigned char) *s++) {
+		if (isdigit(c))
+			c -= '0';
+		else if (isalpha(c))
+			c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+		else
+			break;
+		if (c >= base)
+			break;
+		if (any < 0)
+			continue;
+		if (acc > cutoff || (acc == cutoff && c > cutlim)) {
+			any = -1;
+			acc = ULONG_MAX;
+			errno = ERANGE;
+		} else {
+			any = 1;
+			acc *= (unsigned long)base;
+			acc += c;
+		}
+	}
+	if (neg && any > 0)
+		acc = -acc;
+	if (endptr != 0)
+		/* LINTED interface specification */
+		*endptr = (char *)(any ? s - 1 : nptr);
+	return (acc);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/Makefile.inc b/prex-0.9.0/usr/lib/libc/string/Makefile.inc
new file mode 100755
index 0000000..6d963f2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/Makefile.inc
@@ -0,0 +1,8 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/string:$(VPATH)
+
+SRCS+=	bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c \
+	memcmp.c memcpy.c memmove.c memset.c rindex.c strcasecmp.c strcat.c \
+	strchr.c strcmp.c strcoll.c strcpy.c strncpy.c strncat.c strcspn.c \
+	strlen.c strmode.c strdup.c strncmp.c strerror.c \
+	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c strtok_r.c \
+	strxfrm.c swab.c strlcpy.c strlcat.c
diff --git a/prex-0.9.0/usr/lib/libc/string/bcmp.c b/prex-0.9.0/usr/lib/libc/string/bcmp.c
new file mode 100755
index 0000000..6618c46
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/bcmp.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1987, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+/*
+ * bcmp -- vax cmpc3 instruction
+ */
+int
+bcmp(b1, b2, length)
+	const void *b1, *b2;
+	size_t length;
+{
+	char *p1, *p2;
+
+	if (length == 0)
+		return(0);
+	p1 = (char *)b1;
+	p2 = (char *)b2;
+	do
+		if (*p1++ != *p2++)
+			break;
+	while (--length);
+	return((int)length);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/bcopy.c b/prex-0.9.0/usr/lib/libc/string/bcopy.c
new file mode 100755
index 0000000..bd0d1cf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/bcopy.c
@@ -0,0 +1,82 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Copy a block of memory, handling overlap.
+ * This is the routine that actually implements
+ * (the portable versions of) bcopy, memcpy, and memmove.
+ */
+#ifdef MEMCOPY
+void *
+memcpy(dst0, src0, length)
+#else
+#ifdef MEMMOVE
+void *
+memmove(dst0, src0, length)
+#else
+void
+bcopy(src0, dst0, length)
+#endif
+#endif
+	void *dst0;
+	const void *src0;
+	size_t length;
+{
+	char *dst = dst0;
+	const char *src = src0;
+
+	if (length == 0 || dst == src)		/* nothing to do */
+		goto done;
+
+	if (((unsigned long)dst < (unsigned long)src) &&
+	    ((unsigned long)dst < (unsigned long)src + length)) {
+		/* Copy backwards. */
+		src += length;
+		dst += length;
+		while (length--) {
+			*--dst = *--src;
+		}
+	} else {
+		while (length--) {
+			*dst++ = *src++;
+		}
+	}
+done:
+#if defined(MEMCOPY) || defined(MEMMOVE)
+	return (dst0);
+#else
+	return;
+#endif
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/bzero.c b/prex-0.9.0/usr/lib/libc/string/bzero.c
new file mode 100755
index 0000000..a329af6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/bzero.c
@@ -0,0 +1,4 @@
+/*	$NetBSD: bzero.c,v 1.8 1998/08/04 06:25:10 perry Exp $	*/
+
+#define BZERO
+#include "memset.c"
diff --git a/prex-0.9.0/usr/lib/libc/string/ffs.c b/prex-0.9.0/usr/lib/libc/string/ffs.c
new file mode 100755
index 0000000..1f9566d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/ffs.c
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+/*
+ * ffs -- vax ffs instruction
+ */
+int
+ffs(mask)
+	int mask;
+{
+	int bit;
+
+	if (mask == 0)
+		return(0);
+	for (bit = 1; !(mask & 1); bit++)
+		mask >>= 1;
+	return(bit);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/index.c b/prex-0.9.0/usr/lib/libc/string/index.c
new file mode 100755
index 0000000..22d96fd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/index.c
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+#include <stddef.h>
+
+char *
+#ifdef STRCHR
+strchr(p, ch)
+#else
+index(p, ch)
+#endif
+	const char *p, ch;
+{
+	for (;; ++p) {
+		if (*p == ch)
+			return((char *)p);
+		if (!*p)
+			return((char *)NULL);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/memccpy.c b/prex-0.9.0/usr/lib/libc/string/memccpy.c
new file mode 100755
index 0000000..e698f69
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/memccpy.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+void *
+memccpy(t, f, c, n)
+	void *t;
+	const void *f;
+	int c;
+	size_t n;
+{
+
+	if (n) {
+		unsigned char *tp = t;
+		const unsigned char *fp = f;
+		do {
+			if ((*tp++ = *fp++) == c)
+				return (t);
+		} while (--n != 0);
+	}
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/memchr.c b/prex-0.9.0/usr/lib/libc/string/memchr.c
new file mode 100755
index 0000000..5a9a1e4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/memchr.c
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+void *
+memchr(s, c, n)
+	const void *s;
+	unsigned char c;
+	size_t n;
+{
+	if (n != 0) {
+		const unsigned char *p = s;
+
+		do {
+			if (*p++ == c)
+				return ((void *)(p - 1));
+		} while (--n != 0);
+	}
+	return (NULL);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/memcmp.c b/prex-0.9.0/usr/lib/libc/string/memcmp.c
new file mode 100755
index 0000000..11fc8ce
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/memcmp.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Compare memory regions.
+ */
+int
+memcmp(s1, s2, n)
+	const void *s1, *s2;
+	size_t n;
+{
+	if (n != 0) {
+		const unsigned char *p1 = s1, *p2 = s2;
+
+		do {
+			if (*p1++ != *p2++)
+				return (*--p1 - *--p2);
+		} while (--n != 0);
+	}
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/memcpy.c b/prex-0.9.0/usr/lib/libc/string/memcpy.c
new file mode 100755
index 0000000..9a95942
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/memcpy.c
@@ -0,0 +1,4 @@
+/*	$NetBSD: memcpy.c,v 1.1 1998/08/04 04:48:17 perry Exp $	*/
+
+#define MEMCOPY
+#include "bcopy.c"
diff --git a/prex-0.9.0/usr/lib/libc/string/memmove.c b/prex-0.9.0/usr/lib/libc/string/memmove.c
new file mode 100755
index 0000000..3c2658f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/memmove.c
@@ -0,0 +1,4 @@
+/*	$NetBSD: memmove.c,v 1.1 1998/08/04 04:48:17 perry Exp $	*/
+
+#define MEMMOVE
+#include "bcopy.c"
diff --git a/prex-0.9.0/usr/lib/libc/string/memset.c b/prex-0.9.0/usr/lib/libc/string/memset.c
new file mode 100755
index 0000000..68e5625
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/memset.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Hibler and Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <limits.h>
+#include <string.h>
+
+#ifdef BZERO
+#define	RETURN	return
+#define	VAL	0
+
+void
+bzero(dst0, length)
+	void *dst0;
+	size_t length;
+#else
+#define	RETURN	return (dst0)
+#define	VAL	c0
+
+void *
+memset(dst0, c0, length)
+	void *dst0;
+	int c0;
+	size_t length;
+#endif
+{
+	char *dst = dst0;
+
+	while (length--) {
+		*dst++ = (char)VAL;
+	}
+	RETURN;
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/rindex.c b/prex-0.9.0/usr/lib/libc/string/rindex.c
new file mode 100755
index 0000000..8e5aa30
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/rindex.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+char *
+#ifdef STRRCHR
+strrchr(p, ch)
+#else
+rindex(p, ch)
+#endif
+	const char *p;
+	int ch;
+{
+	char *save;
+
+	for (save = NULL;; ++p) {
+		if (*p == ch)
+			save = (char *)p;
+		if (!*p)
+			return(save);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strcasecmp.c b/prex-0.9.0/usr/lib/libc/string/strcasecmp.c
new file mode 100755
index 0000000..07803a0
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strcasecmp.c
@@ -0,0 +1,69 @@
+/*	$NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc Exp $	*/
+
+/*
+ * Copyright (c) 1987, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <ctype.h>
+#include <string.h>
+
+int
+strcasecmp(s1, s2)
+	const char *s1, *s2;
+{
+	const unsigned char *us1 = (const unsigned char *)s1,
+			*us2 = (const unsigned char *)s2;
+
+	while (tolower(*us1) == tolower(*us2++))
+		if (*us1++ == '\0')
+			return (0);
+	return (tolower(*us1) - tolower(*--us2));
+}
+
+int
+strncasecmp(s1, s2, n)
+	const char *s1, *s2;
+	size_t n;
+{
+	if (s1 == NULL || s2 == NULL)
+		return (0);
+
+	if (n != 0) {
+		const unsigned char *us1 = (const unsigned char *)s1,
+				*us2 = (const unsigned char *)s2;
+
+		do {
+			if (tolower(*us1) != tolower(*us2++))
+				return (tolower(*us1) - tolower(*--us2));
+			if (*us1++ == '\0')
+				break;
+		} while (--n != 0);
+	}
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strcat.c b/prex-0.9.0/usr/lib/libc/string/strcat.c
new file mode 100755
index 0000000..d88d718
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strcat.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+char *
+strcat(s, append)
+	char *s;
+	const char *append;
+{
+	char *save = s;
+
+	for (; *s; ++s)
+		;
+	while ((*s++ = *append++) != '\0')
+		;
+	return(save);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strchr.c b/prex-0.9.0/usr/lib/libc/string/strchr.c
new file mode 100755
index 0000000..e2e38a6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strchr.c
@@ -0,0 +1,4 @@
+/*	$NetBSD: strchr.c,v 1.1 1998/08/04 04:48:17 perry Exp $	*/
+
+#define STRCHR
+#include "index.c"
diff --git a/prex-0.9.0/usr/lib/libc/string/strcmp.c b/prex-0.9.0/usr/lib/libc/string/strcmp.c
new file mode 100755
index 0000000..70fde91
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strcmp.c
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Compare strings.
+ */
+int
+strcmp(s1, s2)
+	const char *s1, *s2;
+{
+	while (*s1 == *s2++)
+		if (*s1++ == 0)
+			return (0);
+	return (*(const unsigned char *)s1 - *(const unsigned char *)--s2);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strcoll.c b/prex-0.9.0/usr/lib/libc/string/strcoll.c
new file mode 100755
index 0000000..2dbd27e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strcoll.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Compare strings according to LC_COLLATE category of current locale.
+ */
+int
+strcoll(s1, s2)
+	const char *s1, *s2;
+{
+	/* LC_COLLATE is unimplemented, hence always "C" */
+	return (strcmp(s1, s2));
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strcpy.c b/prex-0.9.0/usr/lib/libc/string/strcpy.c
new file mode 100755
index 0000000..822b146
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strcpy.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+char *
+strcpy(to, from)
+	char *to;
+	const char *from;
+{
+	char *save = to;
+
+	for (; (*to = *from) != '\0'; ++from, ++to);
+	return(save);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strcspn.c b/prex-0.9.0/usr/lib/libc/string/strcspn.c
new file mode 100755
index 0000000..47507fd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strcspn.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Span the complement of string s2.
+ */
+size_t
+strcspn(s1, s2)
+	const char *s1;
+	const char *s2;
+{
+	const char *p, *spanp;
+	char c, sc;
+
+	/*
+	 * Stop as soon as we find any character from s2.  Note that there
+	 * must be a NUL in s2; it suffices to stop when we find that, too.
+	 */
+	for (p = s1;;) {
+		c = *p++;
+		spanp = s2;
+		do {
+			if ((sc = *spanp++) == c)
+				return (p - 1 - s1);
+		} while (sc != 0);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strdup.c b/prex-0.9.0/usr/lib/libc/string/strdup.c
new file mode 100755
index 0000000..44e649f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strdup.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *
+strdup(str)
+	const char *str;
+{
+	size_t len;
+	char *copy;
+
+	len = strlen(str) + 1;
+	if (!(copy = malloc((u_int)len)))
+		return (NULL);
+	bcopy(str, copy, len);
+	return (copy);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strerror.c b/prex-0.9.0/usr/lib/libc/string/strerror.c
new file mode 100755
index 0000000..5617445
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strerror.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+char *
+strerror(num)
+	int num;
+{
+	extern const int sys_nerr;
+	extern const char *sys_errlist[];
+#define	UPREFIX	"Unknown error"
+	static const char ebuf[] = UPREFIX;
+	unsigned int errnum;
+
+	errnum = num;				/* convert to unsigned */
+	if (errnum < (unsigned int)sys_nerr)
+		return((char *)sys_errlist[errnum]);
+
+	return((char *)ebuf);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strlcat.c b/prex-0.9.0/usr/lib/libc/string/strlcat.c
new file mode 100755
index 0000000..ceab094
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strlcat.c
@@ -0,0 +1,55 @@
+/*	$OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end */
+	while (n-- != 0 && *d != '\0')
+		d++;
+	dlen = d - dst;
+	n = siz - dlen;
+
+	if (n == 0)
+		return(dlen + strlen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(dlen + (s - src));	/* count does not include NUL */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strlcpy.c b/prex-0.9.0/usr/lib/libc/string/strlcpy.c
new file mode 100755
index 0000000..110155f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strlcpy.c
@@ -0,0 +1,51 @@
+/*	$OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $	*/
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0 && --n != 0) {
+		do {
+			if ((*d++ = *s++) == 0)
+				break;
+		} while (--n != 0);
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (siz != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return(s - src - 1);	/* count does not include NUL */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strlen.c b/prex-0.9.0/usr/lib/libc/string/strlen.c
new file mode 100755
index 0000000..0eeafd5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strlen.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+size_t
+strlen(str)
+	const char *str;
+{
+	const char *s;
+
+	for (s = str; *s; ++s);
+	return(s - str);
+}
+
diff --git a/prex-0.9.0/usr/lib/libc/string/strmode.c b/prex-0.9.0/usr/lib/libc/string/strmode.c
new file mode 100755
index 0000000..78ece2d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strmode.c
@@ -0,0 +1,145 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+void
+strmode(mode, p)
+	mode_t mode;
+	char *p;
+{
+	 /* print type */
+	switch (mode & S_IFMT) {
+	case S_IFDIR:			/* directory */
+		*p++ = 'd';
+		break;
+	case S_IFCHR:			/* character special */
+		*p++ = 'c';
+		break;
+	case S_IFBLK:			/* block special */
+		*p++ = 'b';
+		break;
+	case S_IFREG:			/* regular */
+		*p++ = '-';
+		break;
+	case S_IFLNK:			/* symbolic link */
+		*p++ = 'l';
+		break;
+	case S_IFSOCK:			/* socket */
+		*p++ = 's';
+		break;
+#ifdef S_IFIFO
+	case S_IFIFO:			/* fifo */
+		*p++ = 'p';
+		break;
+#endif
+#ifdef S_IFWHT
+	case S_IFWHT:			/* whiteout */
+		*p++ = 'w';
+		break;
+#endif
+	default:			/* unknown */
+		*p++ = '?';
+		break;
+	}
+	/* usr */
+	if (mode & S_IRUSR)
+		*p++ = 'r';
+	else
+		*p++ = '-';
+	if (mode & S_IWUSR)
+		*p++ = 'w';
+	else
+		*p++ = '-';
+	switch (mode & (S_IXUSR | S_ISUID)) {
+	case 0:
+		*p++ = '-';
+		break;
+	case S_IXUSR:
+		*p++ = 'x';
+		break;
+	case S_ISUID:
+		*p++ = 'S';
+		break;
+	case S_IXUSR | S_ISUID:
+		*p++ = 's';
+		break;
+	}
+	/* group */
+	if (mode & S_IRGRP)
+		*p++ = 'r';
+	else
+		*p++ = '-';
+	if (mode & S_IWGRP)
+		*p++ = 'w';
+	else
+		*p++ = '-';
+	switch (mode & (S_IXGRP | S_ISGID)) {
+	case 0:
+		*p++ = '-';
+		break;
+	case S_IXGRP:
+		*p++ = 'x';
+		break;
+	case S_ISGID:
+		*p++ = 'S';
+		break;
+	case S_IXGRP | S_ISGID:
+		*p++ = 's';
+		break;
+	}
+	/* other */
+	if (mode & S_IROTH)
+		*p++ = 'r';
+	else
+		*p++ = '-';
+	if (mode & S_IWOTH)
+		*p++ = 'w';
+	else
+		*p++ = '-';
+	switch (mode & (S_IXOTH | S_ISVTX)) {
+	case 0:
+		*p++ = '-';
+		break;
+	case S_IXOTH:
+		*p++ = 'x';
+		break;
+	case S_ISVTX:
+		*p++ = 'T';
+		break;
+	case S_IXOTH | S_ISVTX:
+		*p++ = 't';
+		break;
+	}
+	*p++ = ' ';		/* will be a '+' if ACL's implemented */
+	*p = '\0';
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strncat.c b/prex-0.9.0/usr/lib/libc/string/strncat.c
new file mode 100755
index 0000000..4c7514c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strncat.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Concatenate src on the end of dst.  At most strlen(dst)+n+1 bytes
+ * are written at dst (at most n+1 bytes being appended).  Return dst.
+ */
+char *
+strncat(dst, src, n)
+	char *dst;
+	const char *src;
+	size_t n;
+{
+	if (n != 0) {
+		char *d = dst;
+		const char *s = src;
+
+		while (*d != 0)
+			d++;
+		do {
+			if ((*d = *s++) == 0)
+				break;
+			d++;
+		} while (--n != 0);
+		*d = 0;
+	}
+	return (dst);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strncmp.c b/prex-0.9.0/usr/lib/libc/string/strncmp.c
new file mode 100755
index 0000000..6281ace
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strncmp.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+int
+strncmp(s1, s2, n)
+	const char *s1, *s2;
+	size_t n;
+{
+
+	if (n == 0)
+		return (0);
+	do {
+		if (*s1 != *s2++)
+			return (*(unsigned char *)s1 - *(unsigned char *)--s2);
+		if (*s1++ == 0)
+			break;
+	} while (--n != 0);
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strncpy.c b/prex-0.9.0/usr/lib/libc/string/strncpy.c
new file mode 100755
index 0000000..4372585
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strncpy.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Copy src to dst, truncating or null-padding to always copy n bytes.
+ * Return dst.
+ */
+char *
+strncpy(dst, src, n)
+	char *dst;
+	const char *src;
+	size_t n;
+{
+	if (n != 0) {
+		char *d = dst;
+		const char *s = src;
+
+		do {
+			if ((*d++ = *s++) == 0) {
+				/* NUL pad the remaining n-1 bytes */
+				while (--n != 0)
+					*d++ = 0;
+				break;
+			}
+		} while (--n != 0);
+	}
+	return (dst);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strpbrk.c b/prex-0.9.0/usr/lib/libc/string/strpbrk.c
new file mode 100755
index 0000000..a682e8b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strpbrk.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1985, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Find the first occurrence in s1 of a character in s2 (excluding NUL).
+ */
+char *
+strpbrk(s1, s2)
+	const char *s1, *s2;
+{
+	const char *scanp;
+	int c, sc;
+
+	while ((c = *s1++) != 0) {
+		for (scanp = s2; (sc = *scanp++) != 0;)
+			if (sc == c)
+				return ((char *)(s1 - 1));
+	}
+	return (NULL);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strrchr.c b/prex-0.9.0/usr/lib/libc/string/strrchr.c
new file mode 100755
index 0000000..6c94485
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strrchr.c
@@ -0,0 +1,4 @@
+/*	$NetBSD: strrchr.c,v 1.1 1998/08/04 04:48:17 perry Exp $	*/
+
+#define STRRCHR
+#include "rindex.c"
diff --git a/prex-0.9.0/usr/lib/libc/string/strsep.c b/prex-0.9.0/usr/lib/libc/string/strsep.c
new file mode 100755
index 0000000..846859f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strsep.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * Get next token from string *stringp, where tokens are possibly-empty
+ * strings separated by characters from delim.
+ *
+ * Writes NULs into the string at *stringp to end tokens.
+ * delim need not remain constant from call to call.
+ * On return, *stringp points past the last NUL written (if there might
+ * be further tokens), or is NULL (if there are definitely no more tokens).
+ *
+ * If *stringp is NULL, strsep returns NULL.
+ */
+char *
+strsep(stringp, delim)
+	char **stringp;
+	const char *delim;
+{
+	char *s;
+	const char *spanp;
+	int c, sc;
+	char *tok;
+
+	if ((s = *stringp) == NULL)
+		return (NULL);
+	for (tok = s;;) {
+		c = *s++;
+		spanp = delim;
+		do {
+			if ((sc = *spanp++) == c) {
+				if (c == 0)
+					s = NULL;
+				else
+					s[-1] = 0;
+				*stringp = s;
+				return (tok);
+			}
+		} while (sc != 0);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strspn.c b/prex-0.9.0/usr/lib/libc/string/strspn.c
new file mode 100755
index 0000000..1362b96
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strspn.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Span the string s2 (skip characters that are in s2).
+ */
+size_t
+strspn(s1, s2)
+	const char *s1;
+	const char *s2;
+{
+	const char *p = s1, *spanp;
+	char c, sc;
+
+	/*
+	 * Skip any characters in s2, excluding the terminating \0.
+	 */
+cont:
+	c = *p++;
+	for (spanp = s2; (sc = *spanp++) != 0;)
+		if (sc == c)
+			goto cont;
+	return (p - 1 - s1);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strstr.c b/prex-0.9.0/usr/lib/libc/string/strstr.c
new file mode 100755
index 0000000..73ac791
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strstr.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Find the first occurrence of find in s.
+ */
+char *
+strstr(s, find)
+	const char *s, *find;
+{
+	char c, sc;
+	size_t len;
+
+	if ((c = *find++) != 0) {
+		len = strlen(find);
+		do {
+			do {
+				if ((sc = *s++) == 0)
+					return (NULL);
+			} while (sc != c);
+		} while (strncmp(s, find, len) != 0);
+		s--;
+	}
+	return ((char *)s);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strtok.c b/prex-0.9.0/usr/lib/libc/string/strtok.c
new file mode 100755
index 0000000..bd72c5b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strtok.c
@@ -0,0 +1,41 @@
+/*	$NetBSD: strtok.c,v 1.12 2004/10/27 19:12:31 dsl Exp $	*/
+
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+char *
+strtok(char *s, const char *delim)
+{
+	static char *lasts;
+
+	return strtok_r(s, delim, &lasts);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strtok_r.c b/prex-0.9.0/usr/lib/libc/string/strtok_r.c
new file mode 100755
index 0000000..d68014c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strtok_r.c
@@ -0,0 +1,83 @@
+/*	$NetBSD: strtok_r.c,v 1.9 2003/08/07 16:43:53 agc Exp $	*/
+
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+char *
+strtok_r(s, delim, lasts)
+	char *s;
+	const char *delim;
+	char **lasts;
+{
+	const char *spanp;
+	int c, sc;
+	char *tok;
+
+	if (s == NULL && (s = *lasts) == NULL)
+		return (NULL);
+
+	/*
+	 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
+	 */
+cont:
+	c = *s++;
+	for (spanp = delim; (sc = *spanp++) != 0;) {
+		if (c == sc)
+			goto cont;
+	}
+
+	if (c == 0) {		/* no non-delimiter characters */
+		*lasts = NULL;
+		return (NULL);
+	}
+	tok = s - 1;
+
+	/*
+	 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
+	 * Note that delim must have one NUL; we stop if we see that, too.
+	 */
+	for (;;) {
+		c = *s++;
+		spanp = delim;
+		do {
+			if ((sc = *spanp++) == c) {
+				if (c == 0)
+					s = NULL;
+				else
+					s[-1] = 0;
+				*lasts = s;
+				return (tok);
+			}
+		} while (sc != 0);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/strxfrm.c b/prex-0.9.0/usr/lib/libc/string/strxfrm.c
new file mode 100755
index 0000000..92ed185
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/strxfrm.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+/*
+ * Transform src, storing the result in dst, such that
+ * strcmp() on transformed strings returns what strcoll()
+ * on the original untransformed strings would return.
+ */
+size_t
+strxfrm(dst, src, n)
+	char *dst;
+	const char *src;
+	size_t n;
+{
+	size_t srclen, copysize;
+
+	/*
+	 * Since locales are unimplemented, this is just a copy.
+	 */
+	srclen = strlen(src);
+	if (n != 0) {
+		copysize = srclen < n ? srclen : n - 1;
+		(void)memcpy(dst, src, copysize);
+		dst[copysize] = 0;
+	}
+	return (srclen);
+}
diff --git a/prex-0.9.0/usr/lib/libc/string/swab.c b/prex-0.9.0/usr/lib/libc/string/swab.c
new file mode 100755
index 0000000..8e1bbb0
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/string/swab.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jeffrey Mogul.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+void
+swab(const void *from, void *to, size_t len)
+{
+	char temp;
+	const char *fp;
+	char *tp;
+
+	len = (len / 2) + 1;
+	fp = (const char *)from;
+	tp = (char *)to;
+#define	STEP	temp = *fp++,*tp++ = *fp++,*tp++ = temp
+	while (len-- != 0) {
+		STEP;
+	}
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/Makefile.inc b/prex-0.9.0/usr/lib/libc/termios/Makefile.inc
new file mode 100755
index 0000000..a570ab1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/Makefile.inc
@@ -0,0 +1,5 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/termios:$(VPATH)
+
+SRCS+=	tcgetattr.c tcsetattr.c tcgetpgrp.c tcsetpgrp.c \
+	cfgetospeed.c cfsetospeed.c cfgetispeed.c cfsetispeed.c cfsetspeed.c \
+	cfmakeraw.c tcsendbreak.c tcdrain.c tcflush.c tcflow.c
diff --git a/prex-0.9.0/usr/lib/libc/termios/cfgetispeed.c b/prex-0.9.0/usr/lib/libc/termios/cfgetispeed.c
new file mode 100755
index 0000000..acbdb29
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/cfgetispeed.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+speed_t
+cfgetispeed(t)
+	const struct termios *t;
+{
+
+	return (t->c_ispeed);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/cfgetospeed.c b/prex-0.9.0/usr/lib/libc/termios/cfgetospeed.c
new file mode 100755
index 0000000..8dced7f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/cfgetospeed.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+speed_t
+cfgetospeed(t)
+	const struct termios *t;
+{
+
+	return (t->c_ospeed);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/cfmakeraw.c b/prex-0.9.0/usr/lib/libc/termios/cfmakeraw.c
new file mode 100755
index 0000000..772cf52
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/cfmakeraw.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <unistd.h>
+
+/*
+ * Make a pre-existing termios structure into "raw" mode: character-at-a-time
+ * mode with no characters interpreted, 8-bit data path.
+ */
+void
+cfmakeraw(t)
+	struct termios *t;
+{
+
+	t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+	t->c_oflag &= ~OPOST;
+	t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+	t->c_cflag &= ~(CSIZE|PARENB);
+	t->c_cflag |= CS8;
+	/* XXX set MIN/TIME */
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/cfsetispeed.c b/prex-0.9.0/usr/lib/libc/termios/cfsetispeed.c
new file mode 100755
index 0000000..0ddf57c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/cfsetispeed.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+cfsetispeed(t, speed)
+	struct termios *t;
+	speed_t speed;
+{
+
+	t->c_ispeed = speed;
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/cfsetospeed.c b/prex-0.9.0/usr/lib/libc/termios/cfsetospeed.c
new file mode 100755
index 0000000..41d44e1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/cfsetospeed.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+cfsetospeed(t, speed)
+	struct termios *t;
+	speed_t speed;
+{
+
+	t->c_ospeed = speed;
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/cfsetspeed.c b/prex-0.9.0/usr/lib/libc/termios/cfsetspeed.c
new file mode 100755
index 0000000..e44f44f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/cfsetspeed.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+cfsetspeed(t, speed)
+	struct termios *t;
+	speed_t speed;
+{
+
+	t->c_ispeed = t->c_ospeed = speed;
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcdrain.c b/prex-0.9.0/usr/lib/libc/termios/tcdrain.c
new file mode 100755
index 0000000..a6bf636
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcdrain.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+tcdrain(fd)
+	int fd;
+{
+
+	return (ioctl(fd, TIOCDRAIN, 0));
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcflow.c b/prex-0.9.0/usr/lib/libc/termios/tcflow.c
new file mode 100755
index 0000000..3f83f00
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcflow.c
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+tcflow(fd, action)
+	int fd, action;
+{
+	struct termios term;
+	u_char c;
+
+	switch (action) {
+	case TCOOFF:
+		return (ioctl(fd, TIOCSTOP, 0));
+	case TCOON:
+		return (ioctl(fd, TIOCSTART, 0));
+	case TCION:
+	case TCIOFF:
+		if (tcgetattr(fd, &term) == -1)
+			return (-1);
+		c = term.c_cc[action == TCIOFF ? VSTOP : VSTART];
+		if (c != _POSIX_VDISABLE && write(fd, &c, sizeof(c)) == -1)
+			return (-1);
+		return (0);
+	default:
+		errno = EINVAL;
+		return (-1);
+	}
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcflush.c b/prex-0.9.0/usr/lib/libc/termios/tcflush.c
new file mode 100755
index 0000000..01d6446
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcflush.c
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#define KERNEL			/* XXX - FREAD and FWRITE ifdef'd KERNEL*/
+#include <sys/fcntl.h>
+#undef KERNEL
+#include <errno.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+tcflush(fd, which)
+	int fd, which;
+{
+	int com;
+
+	switch (which) {
+	case TCIFLUSH:
+		com = FREAD;
+		break;
+	case TCOFLUSH:
+		com = FWRITE;
+		break;
+	case TCIOFLUSH:
+		com = FREAD | FWRITE;
+		break;
+	default:
+		errno = EINVAL;
+		return (-1);
+	}
+	return (ioctl(fd, TIOCFLUSH, &com));
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcgetattr.c b/prex-0.9.0/usr/lib/libc/termios/tcgetattr.c
new file mode 100755
index 0000000..91aa743
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcgetattr.c
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+tcgetattr(fd, t)
+	int fd;
+	struct termios *t;
+{
+
+	return (ioctl(fd, TIOCGETA, t));
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcgetpgrp.c b/prex-0.9.0/usr/lib/libc/termios/tcgetpgrp.c
new file mode 100755
index 0000000..c27e75d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcgetpgrp.c
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+pid_t
+tcgetpgrp(int fd)
+{
+	int s;
+
+	if (ioctl(fd, TIOCGPGRP, &s) < 0)
+		return ((pid_t)-1);
+	return ((pid_t)s);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcsendbreak.c b/prex-0.9.0/usr/lib/libc/termios/tcsendbreak.c
new file mode 100755
index 0000000..9ec226e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcsendbreak.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+tcsendbreak(fd, len)
+	int fd, len;
+{
+#if 0 /* PREX */
+	struct timeval sleepytime;
+
+	sleepytime.tv_sec = 0;
+	sleepytime.tv_usec = 400000;
+	if (ioctl(fd, TIOCSBRK, 0) == -1)
+		return (-1);
+	(void)select(0, 0, 0, 0, &sleepytime);
+	if (ioctl(fd, TIOCCBRK, 0) == -1)
+		return (-1);
+#endif
+	return (0);
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcsetattr.c b/prex-0.9.0/usr/lib/libc/termios/tcsetattr.c
new file mode 100755
index 0000000..9340626
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcsetattr.c
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+
+int
+tcsetattr(fd, opt, t)
+	int fd, opt;
+	const struct termios *t;
+{
+	struct termios localterm;
+
+	if (opt & TCSASOFT) {
+		localterm = *t;
+		localterm.c_cflag |= CIGNORE;
+		t = &localterm;
+	}
+	switch (opt & ~TCSASOFT) {
+	case TCSANOW:
+		return (ioctl(fd, TIOCSETA, t));
+	case TCSADRAIN:
+		return (ioctl(fd, TIOCSETAW, t));
+	case TCSAFLUSH:
+		return (ioctl(fd, TIOCSETAF, t));
+	default:
+		errno = EINVAL;
+		return (-1);
+	}
+}
diff --git a/prex-0.9.0/usr/lib/libc/termios/tcsetpgrp.c b/prex-0.9.0/usr/lib/libc/termios/tcsetpgrp.c
new file mode 100755
index 0000000..015a800
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/termios/tcsetpgrp.c
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+
+int
+tcsetpgrp(int fd, pid_t pgrp)
+{
+	int s;
+
+	s = pgrp;
+	return (ioctl(fd, TIOCSPGRP, &s));
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/Makefile.inc b/prex-0.9.0/usr/lib/libc/time/Makefile.inc
new file mode 100755
index 0000000..12517b0
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/Makefile.inc
@@ -0,0 +1,4 @@
+VPATH:=	$(SRCDIR)/usr/lib/libc/time:$(VPATH)
+
+SRCS+=	strftime.c gmtime.c gmtime_r.c localtime.c localtime_r.c \
+	asctime.c asctime_r.c mktime.c
diff --git a/prex-0.9.0/usr/lib/libc/time/asctime.c b/prex-0.9.0/usr/lib/libc/time/asctime.c
new file mode 100755
index 0000000..bb99ce6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/asctime.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <time.h>
+
+
+#ifndef TYPE_BIT
+#define TYPE_BIT(type)	(sizeof (type) * CHAR_BIT)
+#endif /* !defined TYPE_BIT */
+
+#ifndef TYPE_SIGNED
+#define TYPE_SIGNED(type) (((type) -1) < 0)
+#endif /* !defined TYPE_SIGNED */
+
+#ifndef INT_STRLEN_MAXIMUM
+/*
+** 302 / 1000 is log10(2.0) rounded up.
+** Subtract one for the sign bit if the type is signed;
+** add one for integer division truncation;
+** add one more for a minus sign if the type is signed.
+*/
+#define INT_STRLEN_MAXIMUM(type) \
+    ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
+#endif /* !defined INT_STRLEN_MAXIMUM */
+
+#define	ASCTIME_BUFLEN	(3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + 3 + 2 + 1 + 1)
+
+char *
+asctime(timeptr)
+register const struct tm *	timeptr;
+{
+	static char result[ASCTIME_BUFLEN];
+
+	return asctime_r(timeptr, result);
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/asctime_r.c b/prex-0.9.0/usr/lib/libc/time/asctime_r.c
new file mode 100755
index 0000000..eaf6db2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/asctime_r.c
@@ -0,0 +1,43 @@
+/*
+** This file is in the public domain, so clarified as of
+** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+*/
+
+#include <sys/time.h>
+#include <stdio.h>
+#include <time.h>
+
+/*
+** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
+*/
+
+char *
+asctime_r(timeptr, buf)
+register const struct tm *	timeptr;
+char *				buf;
+{
+	static const char	wday_name[][3] = {
+		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+	};
+	static const char	mon_name[][3] = {
+		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+	};
+	const char *wn;
+	const char *mn;
+
+	wn = wday_name[timeptr->tm_wday];
+	mn = mon_name[timeptr->tm_mon];
+	/*
+	** The X3J11-suggested format is
+	**	"%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
+	** Since the .2 in 02.2d is ignored, we drop it.
+	*/
+	(void)sprintf(buf,
+		"%.3s %.3s%3d %02d:%02d:%02d %d\n",
+		wn, mn,
+		timeptr->tm_mday, timeptr->tm_hour,
+		timeptr->tm_min, timeptr->tm_sec,
+		1900 + timeptr->tm_year);
+	return buf;
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/gmtime.c b/prex-0.9.0/usr/lib/libc/time/gmtime.c
new file mode 100755
index 0000000..092d072
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/gmtime.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <time.h>
+
+struct tm *
+gmtime(const time_t *timep)
+{
+	static struct tm tm;
+
+	return gmtime_r(timep, &tm);
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/gmtime_r.c b/prex-0.9.0/usr/lib/libc/time/gmtime_r.c
new file mode 100755
index 0000000..2d85f00
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/gmtime_r.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/time.h>
+#include <tzfile.h>
+
+static const int daysinmonth[] =
+    { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+static int
+is_leap(int year)
+{
+	return (isleap(year) ? 1 : 0);
+}
+
+struct tm *
+gmtime_r(const time_t *timep, struct tm *tmp)
+{
+	time_t t;
+	int days, year, mon;
+	int i;
+
+	t = *timep;
+	days = t / 60 / 60 / 24;
+
+	for (year = 1970, i = DAYSPERNYEAR + is_leap(year);
+	     days >= i;
+	     year++, i = DAYSPERNYEAR + is_leap(year))
+		days -= i;
+
+	tmp->tm_year = year - 1900;
+	tmp->tm_yday = days;
+
+	for (mon = 0; ; mon++) {
+		i = daysinmonth[mon];
+		if (mon == 1 && is_leap(year))
+			i++;
+		if (days < i)
+			break;
+		days -= i;
+	}
+	tmp->tm_mon = mon;
+	tmp->tm_mday = days + 1;
+	tmp->tm_wday = (int) ((1970 + days) % DAYSPERWEEK);
+
+	tmp->tm_sec = t % 60;
+	tmp->tm_min = (t / 60) % 60;
+	tmp->tm_hour = (t / 60 / 60) % 24;
+	tmp->tm_isdst = 0;
+	return tmp;
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/localtime.c b/prex-0.9.0/usr/lib/libc/time/localtime.c
new file mode 100755
index 0000000..36774ce
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/localtime.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <time.h>
+
+struct tm *
+localtime(const time_t *timep)
+{
+	static struct tm tm;
+
+	return localtime_r(timep, &tm);
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/localtime_r.c b/prex-0.9.0/usr/lib/libc/time/localtime_r.c
new file mode 100755
index 0000000..da33f76
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/localtime_r.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/time.h>
+#include <time.h>
+
+struct tm *
+localtime_r(const time_t* timep, struct tm* tmp)
+{
+	/* XXX: handle timezone */
+	return gmtime_r(timep, tmp);
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/mktime.c b/prex-0.9.0/usr/lib/libc/time/mktime.c
new file mode 100755
index 0000000..7c17271
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/mktime.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <time.h>
+#include <tzfile.h>
+
+time_t
+mktime(struct tm *tmp)
+{
+	unsigned int days, year;
+	time_t time;
+
+	days = 0;
+	for (year = 1970; year < (unsigned int)(1900 + tmp->tm_year); year++)
+		days += DAYSPERNYEAR + (isleap(year) ? 1 : 0);
+
+	days += tmp->tm_yday;
+
+	time = (((days * 24 + tmp->tm_hour) * 60) + tmp->tm_min) * 60
+		+ tmp->tm_sec;
+	return time;
+}
diff --git a/prex-0.9.0/usr/lib/libc/time/strftime.c b/prex-0.9.0/usr/lib/libc/time/strftime.c
new file mode 100755
index 0000000..d10070e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libc/time/strftime.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <tzfile.h>
+#include <string.h>
+
+static const char *afmt[] = {
+	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
+};
+static const char *Afmt[] = {
+	"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
+	"Saturday",
+};
+static const char *bfmt[] = {
+	"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
+	"Oct", "Nov", "Dec",
+};
+static const char *Bfmt[] = {
+	"January", "February", "March", "April", "May", "June", "July",
+	"August", "September", "October", "November", "December",
+};
+
+static size_t gsize;
+static char *pt;
+static int _add(const char *);
+static int _conv(int, int, int);
+static int _secs(const struct tm *);
+static size_t _fmt(const char *, const struct tm *);
+
+size_t
+strftime(s, maxsize, format, t)
+	char *s;
+	size_t maxsize;
+	const char *format;
+	const struct tm *t;
+{
+
+	pt = s;
+	if ((gsize = maxsize) < 1)
+		return(0);
+	if (_fmt(format, t)) {
+		*pt = '\0';
+		return(maxsize - gsize);
+	}
+	return(0);
+}
+
+static size_t
+_fmt(format, t)
+	const char *format;
+	const struct tm *t;
+{
+	for (; *format; ++format) {
+		if (*format == '%')
+			switch(*++format) {
+			case '\0':
+				--format;
+				break;
+			case 'A':
+				if (t->tm_wday < 0 || t->tm_wday > 6)
+					return(0);
+				if (!_add(Afmt[t->tm_wday]))
+					return(0);
+				continue;
+			case 'a':
+				if (t->tm_wday < 0 || t->tm_wday > 6)
+					return(0);
+				if (!_add(afmt[t->tm_wday]))
+					return(0);
+				continue;
+			case 'B':
+				if (t->tm_mon < 0 || t->tm_mon > 11)
+					return(0);
+				if (!_add(Bfmt[t->tm_mon]))
+					return(0);
+				continue;
+			case 'b':
+			case 'h':
+				if (t->tm_mon < 0 || t->tm_mon > 11)
+					return(0);
+				if (!_add(bfmt[t->tm_mon]))
+					return(0);
+				continue;
+			case 'C':
+				if (!_fmt("%a %b %e %H:%M:%S %Y", t))
+					return(0);
+				continue;
+			case 'c':
+				if (!_fmt("%m/%d/%y %H:%M:%S", t))
+					return(0);
+				continue;
+			case 'D':
+				if (!_fmt("%m/%d/%y", t))
+					return(0);
+				continue;
+			case 'd':
+				if (!_conv(t->tm_mday, 2, '0'))
+					return(0);
+				continue;
+			case 'e':
+				if (!_conv(t->tm_mday, 2, ' '))
+					return(0);
+				continue;
+			case 'H':
+				if (!_conv(t->tm_hour, 2, '0'))
+					return(0);
+				continue;
+			case 'I':
+				if (!_conv(t->tm_hour % 12 ?
+				    t->tm_hour % 12 : 12, 2, '0'))
+					return(0);
+				continue;
+			case 'j':
+				if (!_conv(t->tm_yday + 1, 3, '0'))
+					return(0);
+				continue;
+			case 'k':
+				if (!_conv(t->tm_hour, 2, ' '))
+					return(0);
+				continue;
+			case 'l':
+				if (!_conv(t->tm_hour % 12 ?
+				    t->tm_hour % 12 : 12, 2, ' '))
+					return(0);
+				continue;
+			case 'M':
+				if (!_conv(t->tm_min, 2, '0'))
+					return(0);
+				continue;
+			case 'm':
+				if (!_conv(t->tm_mon + 1, 2, '0'))
+					return(0);
+				continue;
+			case 'n':
+				if (!_add("\n"))
+					return(0);
+				continue;
+			case 'p':
+				if (!_add(t->tm_hour >= 12 ? "PM" : "AM"))
+					return(0);
+				continue;
+			case 'R':
+				if (!_fmt("%H:%M", t))
+					return(0);
+				continue;
+			case 'r':
+				if (!_fmt("%I:%M:%S %p", t))
+					return(0);
+				continue;
+			case 'S':
+				if (!_conv(t->tm_sec, 2, '0'))
+					return(0);
+				continue;
+			case 's':
+				if (!_secs(t))
+					return(0);
+				continue;
+			case 'T':
+			case 'X':
+				if (!_fmt("%H:%M:%S", t))
+					return(0);
+				continue;
+			case 't':
+				if (!_add("\t"))
+					return(0);
+				continue;
+			case 'U':
+				if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7,
+				    2, '0'))
+					return(0);
+				continue;
+			case 'W':
+				if (!_conv((t->tm_yday + 7 -
+				    (t->tm_wday ? (t->tm_wday - 1) : 6))
+				    / 7, 2, '0'))
+					return(0);
+				continue;
+			case 'w':
+				if (!_conv(t->tm_wday, 1, '0'))
+					return(0);
+				continue;
+			case 'x':
+				if (!_fmt("%m/%d/%y", t))
+					return(0);
+				continue;
+			case 'y':
+				if (!_conv((t->tm_year + TM_YEAR_BASE)
+				    % 100, 2, '0'))
+					return(0);
+				continue;
+			case 'Y':
+				if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0'))
+					return(0);
+				continue;
+/*
+			case 'Z':
+				if (!t->tm_zone || !_add(t->tm_zone))
+					return(0);
+				continue;
+*/
+			case '%':
+			/*
+			 * X311J/88-090 (4.12.3.5): if conversion char is
+			 * undefined, behavior is undefined.  Print out the
+			 * character itself as printf(3) does.
+			 */
+			default:
+				break;
+		}
+		if (!gsize--)
+			return(0);
+		*pt++ = *format;
+	}
+	return(gsize);
+}
+
+static int
+_secs(t)
+	const struct tm *t;
+{
+	static char buf[15];
+	time_t s;
+	char *p;
+	struct tm tmp;
+
+	/* Make a copy, mktime(3) modifies the tm struct. */
+	tmp = *t;
+	s = mktime(&tmp);
+	for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10)
+		*p-- = s % 10 + '0';
+	return(_add(++p));
+}
+
+static int
+_conv(n, digits, pad)
+	int n, digits, pad;
+{
+	static char buf[10];
+	char *p;
+
+	for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits)
+		*p-- = n % 10 + '0';
+	while (p > buf && digits-- > 0)
+		*p-- = pad;
+	return(_add(++p));
+}
+
+static int
+_add(str)
+	const char *str;
+{
+	for (;; ++pt, --gsize) {
+		if (!gsize)
+			return(0);
+		if (!(*pt = *str++))
+			return(1);
+	}
+}
diff --git a/prex-0.9.0/usr/lib/libsa/Makefile b/prex-0.9.0/usr/lib/libsa/Makefile
new file mode 100755
index 0000000..836f225
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/Makefile
@@ -0,0 +1,17 @@
+include $(SRCDIR)/mk/own.mk
+
+TARGET:=	$(SRCDIR)/usr/lib/libsa.a
+
+SRCS:=		__libc_init.c _exit.c _stdio.c getchar.c \
+		putchar.c puts.c printf.c \
+		vsprintf.c assert.c sprintf.c
+
+DEFS+=		_STANDALONE
+
+include $(SRCDIR)/usr/lib/prex/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/ctype/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/errno/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/stdlib/Makefile.inc
+include $(SRCDIR)/usr/lib/libc/string/Makefile.inc
+
+include $(SRCDIR)/mk/lib.mk
diff --git a/prex-0.9.0/usr/lib/libsa/__libc_init.c b/prex-0.9.0/usr/lib/libsa/__libc_init.c
new file mode 100755
index 0000000..f38445b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/__libc_init.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+void __libc_init(void);
+
+
+void
+__libc_init(void)
+{
+}
diff --git a/prex-0.9.0/usr/lib/libsa/_exit.c b/prex-0.9.0/usr/lib/libsa/_exit.c
new file mode 100755
index 0000000..54d57af
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/_exit.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/prex.h>
+#include <unistd.h>
+
+void
+_exit(int status)
+{
+
+	for (;;)
+		task_terminate(task_self());
+}
diff --git a/prex-0.9.0/usr/lib/libsa/_stdio.c b/prex-0.9.0/usr/lib/libsa/_stdio.c
new file mode 100755
index 0000000..7d25c54
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/_stdio.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+extern void	(*__cleanup)(void);	/* in exit() */
+
+void __console_write(char *, size_t);
+char __console_read(void);
+
+
+static device_t __console_dev;
+
+static int init_done = 0;
+
+static void
+__stdio_exit(void)
+{
+
+	if (__console_dev)
+		device_close(__console_dev);
+	init_done = 0;
+}
+
+static void
+__stdio_init(void)
+{
+
+	device_open("tty", 0, &__console_dev);
+	__cleanup = __stdio_exit;
+	init_done = 1;
+}
+
+void
+__console_write(char *buf, size_t len)
+{
+
+	if (init_done == 0)
+		__stdio_init();
+
+	device_write(__console_dev, buf, &len, 0);
+}
+
+char
+__console_read(void)
+{
+	char ch;
+	size_t len = 1;
+
+	if (init_done == 0)
+		__stdio_init();
+
+	device_read(__console_dev, &ch, &len, 0);
+	return ch;
+}
diff --git a/prex-0.9.0/usr/lib/libsa/assert.c b/prex-0.9.0/usr/lib/libsa/assert.c
new file mode 100755
index 0000000..ac9f7f8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/assert.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/syslog.h>
+#include <stdlib.h>
+#include <assert.h>
+
+void
+__assert(const char *file, int line, const char *exp)
+{
+
+	syslog(LOG_ERR, "assertion \"%s\" failed: file \"%s\", line %d\n",
+	       exp, file, line);
+	abort();
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/libsa/getchar.c b/prex-0.9.0/usr/lib/libsa/getchar.c
new file mode 100755
index 0000000..7c5540b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/getchar.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+extern char __console_read(void);
+
+int
+getchar(void)
+{
+
+	return (int)__console_read();
+}
diff --git a/prex-0.9.0/usr/lib/libsa/printf.c b/prex-0.9.0/usr/lib/libsa/printf.c
new file mode 100755
index 0000000..ef31605
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/printf.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/prex.h>
+
+extern void __console_write(char *buf, size_t len);
+
+/*
+ * Note: gcc may replace 'printf' to 'puts' or 'puchar' in some case.
+ */
+int
+printf(const char *fmt, ...)
+{
+	va_list args;
+	int len = LINE_MAX;
+	char buf[LINE_MAX];
+
+	va_start(args, fmt);
+	len = vsprintf(buf, fmt, args);
+	__console_write((char *)buf, (size_t)len);
+	va_end(args);
+	return len;
+}
diff --git a/prex-0.9.0/usr/lib/libsa/putchar.c b/prex-0.9.0/usr/lib/libsa/putchar.c
new file mode 100755
index 0000000..1dbc983
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/putchar.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+extern void __console_write(char *buf, size_t len);
+
+int
+putchar(int c)
+{
+	char ch;
+
+	ch = (char)c;
+	__console_write(&ch, 1);
+	return c;
+}
diff --git a/prex-0.9.0/usr/lib/libsa/puts.c b/prex-0.9.0/usr/lib/libsa/puts.c
new file mode 100755
index 0000000..7f7b80e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/puts.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <string.h>
+#include <stdio.h>
+
+extern void __console_write(char *buf, size_t len);
+extern int putchar(int);
+
+int
+puts(const char *s)
+{
+	__console_write((char *)s, strlen((char *)s) + 1);
+	putchar('\n');
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/libsa/sprintf.c b/prex-0.9.0/usr/lib/libsa/sprintf.c
new file mode 100755
index 0000000..ef27a6a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/sprintf.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <limits.h>
+
+int
+sprintf(char *str, char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	FILE f;
+
+	f._flags = __SWR | __SSTR;
+	f._bf._base = f._p = (unsigned char *)str;
+	f._bf._size = f._w = INT_MAX;
+	va_start(ap, fmt);
+	ret = vfprintf(&f, fmt, ap);
+	va_end(ap);
+	*f._p = 0;
+	return (ret);
+}
diff --git a/prex-0.9.0/usr/lib/libsa/vsprintf.c b/prex-0.9.0/usr/lib/libsa/vsprintf.c
new file mode 100755
index 0000000..17b2c90
--- /dev/null
+++ b/prex-0.9.0/usr/lib/libsa/vsprintf.c
@@ -0,0 +1,175 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vsprintf.c - Format and output data to buffer
+ */
+
+#include <limits.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+
+#define isdigit(c)  ((unsigned)((c) - '0') < 10)
+
+static int
+divide(long *n, int base)
+{
+	int res;
+
+	/*
+	 * Note: Optimized for ARM processor which does not support
+	 * divide instructions.
+	 *
+	 * res = ((unsigned long)*n) % (unsigned int)base;
+	 * *n = ((unsigned long)*n) / (unsigned int)base;
+	 */
+
+	if (base == 10) {
+		res = (int)(((unsigned long)*n) % 10U);
+		*n = (long)(((unsigned long)*n) / 10U);
+	} else {
+		res = (int)(((unsigned long)*n) % 16U);
+		*n = (long)(((unsigned long)*n) / 16U);
+	}
+	return res;
+}
+
+static int
+atoi(const char **s)
+{
+	int i = 0;
+	while (isdigit((int)**s))
+		i = i * 10 + *((*s)++) - '0';
+	return i;
+}
+
+/*
+ * Print formatted output - scaled down version
+ *
+ * Identifiers:
+ *  %d - Decimal signed int
+ *  %x - Hex integer
+ *  %u - Unsigned integer
+ *  %c - Character
+ *  %s - String
+ *
+ * Flags:
+ *   0 - Zero pad
+ */
+int
+vsprintf(char *buf, const char *fmt, va_list args)
+{
+	char *p, *str;
+	const char *digits = "0123456789abcdef";
+	char pad, tmp[16];
+	int width, base, sign, i, size;
+	long num;
+
+	size = 0;
+	for (p = buf; *fmt && (size < LINE_MAX); fmt++, size++) {
+		if (*fmt != '%') {
+			*p++ = *fmt;
+			continue;
+		}
+		/* get flags */
+		++fmt;
+		pad = ' ';
+		if (*fmt == '0') {
+			pad = '0';
+			fmt++;
+		}
+		if (*fmt == 'l')
+			fmt++;
+		/* get width */
+		width = -1;
+		if (isdigit((int)*fmt)) {
+			width = atoi(&fmt);
+		}
+		base = 10;
+		sign = 0;
+		switch (*fmt) {
+		case 'c':
+			*p++ = (unsigned char)va_arg(args, int);
+			continue;
+		case 's':
+			str = va_arg(args, char *);
+			if (str == NULL)
+				str = "<NULL>";
+			for (; *str; str++) {
+				*p++ = *str;
+				if (size++ >= LINE_MAX)
+					break;
+			}
+			continue;
+		case 'X':
+		case 'x':
+			base = 16;
+			break;
+		case 'd':
+			sign = 1;
+			break;
+		case 'u':
+			break;
+		default:
+			continue;
+		}
+		num = va_arg(args, long);
+		if (sign && num < 0) {
+			num = -num;
+			*p++ = '-';
+			width--;
+		}
+		i = 0;
+		if (num == 0)
+			tmp[i++] = '0';
+		else
+			while (num != 0)
+				tmp[i++] = digits[divide(&num, base)];
+		width -= i;
+		while (width-- > 0)
+			*p++ = pad;
+		while (i-- > 0)
+			*p++ = tmp[i];
+	}
+	*p = '\0';
+	return (p - buf);
+}
+
+int
+sprintf(char *buf, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = vsprintf(buf, fmt, args);
+	va_end(args);
+	return i;
+}
diff --git a/prex-0.9.0/usr/lib/posix/Makefile.inc b/prex-0.9.0/usr/lib/posix/Makefile.inc
new file mode 100755
index 0000000..df3f5d8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/Makefile.inc
@@ -0,0 +1,7 @@
+
+include $(SRCDIR)/usr/lib/posix/signal/Makefile.inc
+include $(SRCDIR)/usr/lib/posix/process/Makefile.inc
+include $(SRCDIR)/usr/lib/posix/file/Makefile.inc
+include $(SRCDIR)/usr/lib/posix/exec/Makefile.inc
+include $(SRCDIR)/usr/lib/posix/gen/Makefile.inc
+include $(SRCDIR)/usr/lib/posix/time/Makefile.inc
diff --git a/prex-0.9.0/usr/lib/posix/exec/Makefile.inc b/prex-0.9.0/usr/lib/posix/exec/Makefile.inc
new file mode 100755
index 0000000..f0a645f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/exec/Makefile.inc
@@ -0,0 +1,3 @@
+VPATH:=	$(SRCDIR)/usr/lib/posix/exec:$(VPATH)
+
+SRCS+=	execve.c
diff --git a/prex-0.9.0/usr/lib/posix/exec/execve.c b/prex-0.9.0/usr/lib/posix/exec/execve.c
new file mode 100755
index 0000000..7ac3dae
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/exec/execve.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <ipc/exec.h>
+#include <ipc/ipc.h>
+
+#include <unistd.h>
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/*
+ * Note:
+ *
+ * The state after exec() are as follows:
+ * - Opened file descriptors remain open except FD_CLOEXEC flag is set.
+ * - Opened directory streams are closed
+ * - Signals set to the default action.
+ * - Any asynchronous I/O operations are cancelled.
+ */
+int
+execve(const char *path, char * const *argv, char * const *envp)
+{
+	object_t execobj;
+	struct exec_msg msg;
+	int error, i, argc, envc;
+	size_t bufsz;
+	char *dest, *src;
+
+	if ((error = object_lookup("!exec", &execobj)) != 0)
+		return ENOSYS;
+
+	if (path == NULL)
+		return EFAULT;
+/*
+    if (strlen(path) >= PATH_MAX)
+        return ENAMETOOLONG;
+*/
+
+	/* Get arg/env buffer size */
+	bufsz = 0;
+	argc = 0;
+	if (argv) {
+		while (argv[argc]) {
+			bufsz += (strlen(argv[argc]) + 1);
+			argc++;
+		}
+	}
+	envc = 0;
+	if (envp) {
+		while (envp[envc]) {
+			bufsz += (strlen(envp[envc]) + 1);
+			envc++;
+		}
+	}
+	if (bufsz >= ARG_MAX)
+		return E2BIG;
+
+	dest = msg.buf;
+	for (i = 0; i < argc; i++) {
+		src = argv[i];
+		while ((*dest++ = *src++) != 0);
+	}
+	for (i = 0; i < envc; i++) {
+		src = envp[i];
+		while ((*dest++ = *src++) != 0);
+	}
+
+	/* Request to exec server */
+	msg.hdr.code = EXEC_EXECVE;
+	msg.argc = argc;
+	msg.envc = envc;
+	msg.bufsz = bufsz;
+	getcwd(msg.cwd, PATH_MAX);
+	strlcpy(msg.path, path, PATH_MAX);
+	do {
+		error = msg_send(execobj, &msg, sizeof(msg));
+	} while (error == EINTR);
+
+	/*
+	 * If exec() request is done successfully, control never comes here.
+	 */
+	errno = 0;
+	if (error)
+		errno = EIO;
+	else if (msg.hdr.status)
+		errno = msg.hdr.status;
+
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/Makefile.inc b/prex-0.9.0/usr/lib/posix/file/Makefile.inc
new file mode 100755
index 0000000..c8a0a82
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/Makefile.inc
@@ -0,0 +1,10 @@
+VPATH:=	$(SRCDIR)/usr/lib/posix/file:$(VPATH)
+
+SRCS+=	__file.c \
+	mount.c umount.c sync.c \
+	access.c creat.c open.c close.c read.c write.c lseek.c rewinddir.c \
+	fstat.c stat.c lstat.c fsync.c dup.c dup2.c \
+	opendir.c closedir.c readdir.c rename.c chdir.c getcwd.c \
+	link.c unlink.c rmdir.c mkdir.c mknod.c chmod.c chown.c \
+	umask.c ioctl.c fcntl.c pipe.c isatty.c truncate.c ftruncate.c \
+	fchdir.c
diff --git a/prex-0.9.0/usr/lib/posix/file/__file.c b/prex-0.9.0/usr/lib/posix/file/__file.c
new file mode 100755
index 0000000..53fae46
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/__file.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/ipc.h>
+#include <ipc/fs.h>
+
+#include <stddef.h>
+
+object_t __fs_obj;
+
+/*
+ * This is called first when task is started
+ */
+void
+__file_init(void)
+{
+	int error;
+
+	/*
+	 * Look up file system server
+	 */
+	error = object_lookup("!fs", &__fs_obj);
+	if (error)
+		__fs_obj = 0;
+}
+
+/*
+ * Clean up
+ */
+void
+__file_exit(void)
+{
+	struct msg m;
+
+	/* Notify to file system server */
+	if (__fs_obj != 0) {
+		m.hdr.code = FS_EXIT;
+		msg_send(__fs_obj, &m, sizeof(m));
+	}
+}
+
+/*
+ * Notify to file system server.
+ * This routine is used by native task which uses file system.
+ */
+void
+fslib_init(void)
+{
+	struct msg m;
+
+	if (__fs_obj == 0)
+		__file_init();
+
+	m.hdr.code = FS_REGISTER;
+	msg_send(__fs_obj, &m, sizeof(m));
+}
+
+
+/*
+ * Clean up (native task)
+ */
+void
+fslib_exit(void)
+{
+
+	__file_exit();
+}
+
diff --git a/prex-0.9.0/usr/lib/posix/file/access.c b/prex-0.9.0/usr/lib/posix/file/access.c
new file mode 100755
index 0000000..9d82359
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/access.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ipc/fs.h>
+#include <sys/posix.h>
+
+#include <string.h>
+
+int
+access(const char *path, int mode)
+{
+	struct path_msg m;
+
+	m.hdr.code = FS_ACCESS;
+	m.data[0] = mode;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/chdir.c b/prex-0.9.0/usr/lib/posix/file/chdir.c
new file mode 100755
index 0000000..3cd0595
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/chdir.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+int
+chdir(char *path)
+{
+	struct path_msg m;
+
+	if (path == NULL) {
+		errno = ENOENT;
+		return -1;
+	}
+	m.hdr.code = FS_CHDIR;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/chmod.c b/prex-0.9.0/usr/lib/posix/file/chmod.c
new file mode 100755
index 0000000..f4cfe74
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/chmod.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <errno.h>
+
+int
+chmod(const char *path, mode_t mode)
+{
+
+	errno = ENOSYS;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/chown.c b/prex-0.9.0/usr/lib/posix/file/chown.c
new file mode 100755
index 0000000..e34ae57
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/chown.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <errno.h>
+
+int
+chown(const char *path, uid_t owner, gid_t group)
+{
+
+	errno = ENOSYS;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/close.c b/prex-0.9.0/usr/lib/posix/file/close.c
new file mode 100755
index 0000000..c4cd795
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/close.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+int
+close(int fd)
+{
+	struct msg m;
+
+	m.hdr.code = FS_CLOSE;
+	m.data[0] = fd;
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/closedir.c b/prex-0.9.0/usr/lib/posix/file/closedir.c
new file mode 100755
index 0000000..ed0a642
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/closedir.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <dirent.h>
+#include <stdlib.h>
+
+int
+closedir(DIR *dir)
+{
+	struct msg m;
+
+	m.hdr.code = FS_CLOSEDIR;
+	m.data[0] = dir->dd_fd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 0) != 0)
+		return -1;
+	free(dir);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/creat.c b/prex-0.9.0/usr/lib/posix/file/creat.c
new file mode 100755
index 0000000..e55b683
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/creat.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int
+creat(const char *file, mode_t mode)
+{
+
+	return open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/dup.c b/prex-0.9.0/usr/lib/posix/file/dup.c
new file mode 100755
index 0000000..1f8b4cb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/dup.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+int
+dup(int oldfd)
+{
+	struct msg m;
+
+	m.hdr.code = FS_DUP;
+	m.data[0] = oldfd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/dup2.c b/prex-0.9.0/usr/lib/posix/file/dup2.c
new file mode 100755
index 0000000..97d76a6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/dup2.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <errno.h>
+
+int
+dup2(int oldfd, int newfd)
+{
+	struct msg m;
+
+	m.hdr.code = FS_DUP2;
+	m.data[0] = oldfd;
+	m.data[1] = newfd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/fchdir.c b/prex-0.9.0/usr/lib/posix/file/fchdir.c
new file mode 100755
index 0000000..2607fc5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/fchdir.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <sys/stat.h>
+
+#include <stddef.h>
+
+int
+fchdir(int fd)
+{
+	struct msg m;
+
+	m.hdr.code = FS_FCHDIR;
+	m.data[0] = fd;
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/fcntl.c b/prex-0.9.0/usr/lib/posix/file/fcntl.c
new file mode 100755
index 0000000..d1c71ef
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/fcntl.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <sys/fcntl.h>
+
+#include <stdarg.h>
+#include <string.h>
+
+int
+fcntl(int fd, int cmd, ...)
+{
+	struct fcntl_msg m;
+	va_list args;
+	long arg;
+
+	va_start(args, cmd);
+	arg = va_arg(args, long);
+	va_end(args);
+
+	m.hdr.code = FS_FCNTL;
+	m.fd = fd;
+	m.cmd = cmd;
+	if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW)
+		memcpy(&m.lock, (char *)arg, sizeof(struct flock));
+	else
+		m.arg = arg;
+
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return m.arg;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/fstat.c b/prex-0.9.0/usr/lib/posix/file/fstat.c
new file mode 100755
index 0000000..bd6f5fb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/fstat.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <sys/stat.h>
+
+#include <stddef.h>
+#include <string.h>
+
+int
+fstat(int fd, struct stat *st)
+{
+	struct stat_msg m;
+
+	m.hdr.code = FS_FSTAT;
+	m.fd = fd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	memcpy(st, &m.st, sizeof(struct stat));
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/fsync.c b/prex-0.9.0/usr/lib/posix/file/fsync.c
new file mode 100755
index 0000000..04b0da8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/fsync.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+int
+fsync(int fd)
+{
+	struct msg m;
+
+	m.hdr.code = FS_FSYNC;
+	m.data[0] = fd;
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/ftruncate.c b/prex-0.9.0/usr/lib/posix/file/ftruncate.c
new file mode 100755
index 0000000..c5d23ec
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/ftruncate.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+int
+ftruncate(int fd, off_t length)
+{
+	struct msg m;
+
+	m.hdr.code = FS_FTRUNCATE;
+	m.data[0] = fd;
+	m.data[1] = length;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/getcwd.c b/prex-0.9.0/usr/lib/posix/file/getcwd.c
new file mode 100755
index 0000000..83a650e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/getcwd.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+char *
+getcwd(char *buf, size_t size)
+{
+	struct path_msg m;
+
+	if (size == 0 || buf == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
+	m.hdr.code = FS_GETCWD;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return NULL;
+	strlcpy(buf, m.path, PATH_MAX);
+	return buf;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/ioctl.c b/prex-0.9.0/usr/lib/posix/file/ioctl.c
new file mode 100755
index 0000000..7241d7c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/ioctl.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <sys/ioctl.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <string.h>
+
+int
+ioctl(int fd, unsigned long cmd, ...)
+{
+	struct ioctl_msg m;
+	char *argp;
+	va_list args;
+	size_t size;
+	int retval = 0;
+
+	va_start(args, cmd);
+	argp = va_arg(args, char *);
+	va_end(args);
+
+	/*
+	 * Check the parameter size
+	 */
+	size = IOCPARM_LEN(cmd);
+	if (size > IOCPARM_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	/*
+	 * Check fault
+	 */
+	if ((cmd & IOC_IN && (cmd & IOC_IVAL) == 0 && argp == NULL) ||
+	    (cmd & IOC_OUT && (cmd & IOC_OVAL) == 0 && argp == NULL)) {
+		errno = EFAULT;
+		return -1;
+	}
+
+	/*
+	 * Copy in
+	 */
+	if (cmd & IOC_IN) {
+		if (cmd & IOC_IVAL)
+			*((int *)m.buf) = (int)argp;
+		else
+			memcpy(&m.buf, argp, size);
+	}
+
+	m.hdr.code = FS_IOCTL;
+	m.fd = fd;
+	m.request = cmd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 0) != 0)
+		return -1;
+
+	/*
+	 * Copy out
+	 */
+	if (cmd & IOC_OUT) {
+		if (cmd & IOC_OVAL)
+			retval = *((int *)m.buf);
+		else
+			memcpy(argp, &m.buf, size);
+	}
+
+	return retval;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/isatty.c b/prex-0.9.0/usr/lib/posix/file/isatty.c
new file mode 100755
index 0000000..da3f7fd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/isatty.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+int
+isatty(int fd)
+{
+	struct msg m;
+
+	m.hdr.code = FS_ISATTY;
+	m.data[0] = fd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/link.c b/prex-0.9.0/usr/lib/posix/file/link.c
new file mode 100755
index 0000000..8008feb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/link.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+int
+link(char *oldpath, char *newpath)
+{
+	struct path_msg m;
+
+	if (oldpath == NULL || newpath == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	if (strlen(oldpath) >= PATH_MAX ||
+	    strlen(newpath) >= PATH_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
+	strlcpy(m.path, oldpath, PATH_MAX);
+	strlcpy(m.path2, newpath, PATH_MAX);
+
+	m.hdr.code = FS_LINK;
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/lseek.c b/prex-0.9.0/usr/lib/posix/file/lseek.c
new file mode 100755
index 0000000..9f3fe56
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/lseek.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <errno.h>
+
+off_t
+lseek(int fd, off_t offset, int whence)
+{
+	struct msg m;
+
+	m.hdr.code = FS_LSEEK;
+	m.data[0] = fd;
+	m.data[1] = (int)offset;
+	m.data[2] = whence;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return (off_t)m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/lstat.c b/prex-0.9.0/usr/lib/posix/file/lstat.c
new file mode 100755
index 0000000..c6aae1f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/lstat.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <sys/stat.h>
+
+#include <stddef.h>
+#include <string.h>
+#include <errno.h>
+
+int
+lstat(const char *path, struct stat *st)
+{
+	return stat(path, st);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/mkdir.c b/prex-0.9.0/usr/lib/posix/file/mkdir.c
new file mode 100755
index 0000000..18cf0fb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/mkdir.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+
+int
+mkdir(const char *path, mode_t mode)
+{
+	struct open_msg m;
+
+	m.hdr.code = FS_MKDIR;
+	m.flags = 0;
+	m.mode = mode;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/mknod.c b/prex-0.9.0/usr/lib/posix/file/mknod.c
new file mode 100755
index 0000000..cd6509f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/mknod.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+
+int
+mknod(const char *path, mode_t mode, dev_t dev)
+{
+	struct open_msg m;
+
+	m.hdr.code = FS_MKNOD;
+	m.flags = 0;
+	m.mode = mode;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/mount.c b/prex-0.9.0/usr/lib/posix/file/mount.c
new file mode 100755
index 0000000..fb16eff
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/mount.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+int
+mount(const char *dev, const char *dir, const char *fs, int flags,
+      const void *data)
+{
+	struct mount_msg m;
+
+	strlcpy(m.dev, (char *)dev, PATH_MAX);
+	strlcpy(m.dir, (char *)dir, PATH_MAX);
+	strlcpy(m.fs, (char *)fs, 16);
+	if (data != NULL)
+		strlcpy(m.data, (char *)data, 64);
+	m.flags = flags;
+	m.hdr.code = FS_MOUNT;
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/open.c b/prex-0.9.0/usr/lib/posix/file/open.c
new file mode 100755
index 0000000..4df25ea
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/open.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <stdarg.h>
+#include <errno.h>
+
+int
+open(const char *path, int flags, ...)
+{
+	struct open_msg m;
+	va_list args;
+	mode_t mode;
+
+	va_start(args, flags);
+	mode = va_arg(args, int);
+	va_end(args);
+
+	m.hdr.code = FS_OPEN;
+	m.flags = flags;
+	m.mode = mode;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	if (__posix_call(__fs_obj, &m, sizeof(m), 0) != 0)
+		return -1;
+	return m.fd;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/opendir.c b/prex-0.9.0/usr/lib/posix/file/opendir.c
new file mode 100755
index 0000000..e1863c7
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/opendir.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <dirent.h>
+
+DIR *
+opendir(const char *name)
+{
+	struct open_msg m;
+	struct _dirdesc *dir;
+
+	if ((dir = malloc(sizeof(struct _dirdesc))) == NULL)
+		return NULL;
+
+	m.hdr.code = FS_OPENDIR;
+	strlcpy(m.path, (char *)name, PATH_MAX);
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return NULL;
+	dir->dd_fd = m.fd;
+	return dir;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/pipe.c b/prex-0.9.0/usr/lib/posix/file/pipe.c
new file mode 100755
index 0000000..937ed11
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/pipe.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+int
+pipe(int fd[2])
+{
+	struct msg m;
+
+	m.hdr.code = FS_PIPE;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	fd[0] = m.data[0];
+	fd[1] = m.data[1];
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/read.c b/prex-0.9.0/usr/lib/posix/file/read.c
new file mode 100755
index 0000000..0c6b2a3
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/read.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <stddef.h>
+#include <errno.h>
+
+int
+read(int fd, void *buf, size_t len)
+{
+	struct io_msg m;
+
+	m.hdr.code = FS_READ;
+	m.fd = fd;
+	m.buf = buf;
+	m.size = len;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 0) != 0)
+		return -1;
+	return (int)m.size;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/readdir.c b/prex-0.9.0/usr/lib/posix/file/readdir.c
new file mode 100755
index 0000000..a45b251
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/readdir.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <stddef.h>
+#include <dirent.h>
+#include <string.h>
+#include <errno.h>
+
+struct dirent *
+readdir(DIR *dir)
+{
+	struct dir_msg m;
+	struct dirent *entry = &dir->dd_ent;
+
+	m.hdr.code = FS_READDIR;
+	m.fd = dir->dd_fd;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return NULL;
+	memcpy(entry, &m.dirent, sizeof(struct dirent));
+	return &dir->dd_ent;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/rename.c b/prex-0.9.0/usr/lib/posix/file/rename.c
new file mode 100755
index 0000000..e53d0e4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/rename.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+int
+rename(char *oldpath, char *newpath)
+{
+	struct path_msg m;
+
+	if (oldpath == NULL || newpath == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	if (strlen(oldpath) >= PATH_MAX ||
+	    strlen(newpath) >= PATH_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
+	strlcpy(m.path, oldpath, PATH_MAX);
+	strlcpy(m.path2, newpath, PATH_MAX);
+	m.hdr.code = FS_RENAME;
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/rewinddir.c b/prex-0.9.0/usr/lib/posix/file/rewinddir.c
new file mode 100755
index 0000000..644f7f2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/rewinddir.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <dirent.h>
+#include <errno.h>
+
+void
+rewinddir(DIR *dir)
+{
+	struct msg m;
+
+	m.hdr.code = FS_REWINDDIR;
+	m.data[0] = dir->dd_fd;
+	__posix_call(__fs_obj, &m, sizeof(m), 1);
+
+	/*
+	 * XXX: rewinddir() does not return error. But, we may get error...
+	 */
+
+	return;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/rmdir.c b/prex-0.9.0/usr/lib/posix/file/rmdir.c
new file mode 100755
index 0000000..9e5d593
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/rmdir.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+int
+rmdir(char *path)
+{
+	struct path_msg m;
+
+	if (path == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	if (strlen(path) >= PATH_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
+	m.hdr.code = FS_RMDIR;
+	strlcpy(m.path, path, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/stat.c b/prex-0.9.0/usr/lib/posix/file/stat.c
new file mode 100755
index 0000000..1c752e4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/stat.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <sys/stat.h>
+
+#include <stddef.h>
+#include <string.h>
+#include <errno.h>
+
+int
+stat(const char *path, struct stat *st)
+{
+	struct stat_msg m;
+
+	m.hdr.code = FS_STAT;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	memcpy(st, &m.st, sizeof(struct stat));
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/sync.c b/prex-0.9.0/usr/lib/posix/file/sync.c
new file mode 100755
index 0000000..b725c7e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/sync.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <errno.h>
+
+void
+sync(void)
+{
+	struct msg m;
+
+	m.hdr.code = FS_SYNC;
+	__posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/truncate.c b/prex-0.9.0/usr/lib/posix/file/truncate.c
new file mode 100755
index 0000000..02d615c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/truncate.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <string.h>
+
+int
+truncate(const char *path, off_t length)
+{
+	struct path_msg m;
+
+	m.hdr.code = FS_TRUNCATE;
+	m.data[0] = length;
+	strlcpy(m.path, (char *)path, PATH_MAX);
+	if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+		return -1;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/umask.c b/prex-0.9.0/usr/lib/posix/file/umask.c
new file mode 100755
index 0000000..4a08894
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/umask.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <errno.h>
+
+mode_t
+umask(mode_t mode)
+{
+
+	return 0777;
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/umount.c b/prex-0.9.0/usr/lib/posix/file/umount.c
new file mode 100755
index 0000000..3282710
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/umount.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <stddef.h>
+#include <string.h>
+#include <errno.h>
+
+int
+umount(const char *dir)
+{
+	struct path_msg m;
+
+	m.hdr.code = FS_UMOUNT;
+	strlcpy(m.path, (char *)dir, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/unlink.c b/prex-0.9.0/usr/lib/posix/file/unlink.c
new file mode 100755
index 0000000..9739781
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/unlink.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <limits.h>
+#include <string.h>
+#include <errno.h>
+
+int
+unlink(char *path)
+{
+	struct path_msg m;
+
+	if (path == NULL || strlen(path) >= PATH_MAX) {
+		errno = EINVAL;
+		return -1;
+	}
+	m.hdr.code = FS_UNLINK;
+	strlcpy(m.path, path, PATH_MAX);
+	return __posix_call(__fs_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/file/write.c b/prex-0.9.0/usr/lib/posix/file/write.c
new file mode 100755
index 0000000..20ed2be
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/file/write.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/fs.h>
+
+#include <stddef.h>
+
+int
+write(int fd, void *buf, size_t len)
+{
+	struct io_msg m;
+
+	m.hdr.code = FS_WRITE;
+	m.fd = fd;
+	m.buf = buf;
+	m.size = len;
+	if (__posix_call(__fs_obj, &m, sizeof(m), 0) != 0)
+		return -1;
+	return (int)m.size;
+}
diff --git a/prex-0.9.0/usr/lib/posix/gen/Makefile.inc b/prex-0.9.0/usr/lib/posix/gen/Makefile.inc
new file mode 100755
index 0000000..866e333
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/Makefile.inc
@@ -0,0 +1,4 @@
+VPATH:=	$(SRCDIR)/usr/lib/posix/gen:$(VPATH)
+
+SRCS+=	__posix_init.c __posix_call.c uname.c syslog.c alarm.c \
+	getrlimit.c
diff --git a/prex-0.9.0/usr/lib/posix/gen/__posix_call.c b/prex-0.9.0/usr/lib/posix/gen/__posix_call.c
new file mode 100755
index 0000000..c433f4d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/__posix_call.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+
+#include <errno.h>
+
+/*
+ * Send a message to POSIX server.
+ *
+ * Set errno as status.
+ * If 'restart' is set to true, this function will try to send the
+ * message again even if is is interrupted by a signal.
+ */
+int
+__posix_call(object_t obj, void *msg, size_t size, int restart)
+{
+	int error;
+
+	if (obj == 0) {
+		errno = ENOSYS;
+		return -1;
+	}
+
+	do {
+		error = msg_send(obj, msg, size);
+	} while (error == EINTR && restart);
+
+	if (error) {
+		errno = (error == EINTR) ? EINTR : ENOSYS;
+		return -1;
+	} else if (((struct msg_header *)msg)->status) {
+		errno = ((struct msg_header *)msg)->status;
+		return -1;
+	} else {
+		/* DO NOTHING */
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/gen/__posix_init.c b/prex-0.9.0/usr/lib/posix/gen/__posix_init.c
new file mode 100755
index 0000000..38804f5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/__posix_init.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+
+extern void __exception_init(void);
+extern void __process_init(void);
+extern void __file_init(void);
+
+void
+__posix_init(void)
+{
+	__exception_init();
+	__process_init();
+	__file_init();
+}
diff --git a/prex-0.9.0/usr/lib/posix/gen/alarm.c b/prex-0.9.0/usr/lib/posix/gen/alarm.c
new file mode 100755
index 0000000..3489b0f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/alarm.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+unsigned int
+alarm(unsigned int seconds)
+{
+	unsigned int remain = 0;
+
+	timer_alarm(seconds * 1000, (u_long *)&remain);
+	return remain;
+}
diff --git a/prex-0.9.0/usr/lib/posix/gen/getrlimit.c b/prex-0.9.0/usr/lib/posix/gen/getrlimit.c
new file mode 100755
index 0000000..5619d28
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/getrlimit.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/param.h>
+#include <sys/resource.h>
+
+int
+getrlimit(int resource, struct rlimit *rlp)
+{
+	rlim_t limit = 0;
+
+	switch (resource) {
+	case RLIMIT_CPU:
+	case RLIMIT_FSIZE:
+	case RLIMIT_CORE:
+	case RLIMIT_RSS:
+	case RLIMIT_MEMLOCK:
+		break;
+	case RLIMIT_DATA:
+	case RLIMIT_STACK:
+		limit = MAXMEM;
+		break;
+	case RLIMIT_NPROC:
+		limit = MAXTASKS;
+		break;
+	case RLIMIT_NOFILE:
+		limit = OPEN_MAX;
+		break;
+	}
+	rlp->rlim_cur = limit;
+	rlp->rlim_max = limit;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/gen/syslog.c b/prex-0.9.0/usr/lib/posix/gen/syslog.c
new file mode 100755
index 0000000..7a79869
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/syslog.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/prex.h>
+
+#define BUF_LEN	128		/* Local buffer size */
+
+extern int vsprintf(char *buf, const char *fmt, va_list args);
+
+static int	LogMask = 0xff;		/* mask of priorities to be logged */
+
+/*
+ * XXX: Remove Prex kernel dependency.
+ */
+void
+syslog(int pri, const char *fmt, ...)
+{
+	char buf[BUF_LEN];
+	va_list args;
+
+	va_start(args, fmt);
+	vsprintf(buf, fmt, args);
+	sys_log(buf);
+	va_end(args);
+}
+
+#if 0
+void
+openlog(const char *ident, int logstat, int logfac)
+{
+
+}
+#endif
+
+void
+closelog(void)
+{
+
+}
+
+int
+setlogmask(int pmask)
+{
+	int omask;
+
+	omask = LogMask;
+	if (pmask != 0)
+		LogMask = pmask;
+	return (omask);
+}
diff --git a/prex-0.9.0/usr/lib/posix/gen/uname.c b/prex-0.9.0/usr/lib/posix/gen/uname.c
new file mode 100755
index 0000000..09fbd36
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/gen/uname.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/utsname.h>
+
+#include <string.h>
+#include <errno.h>
+
+int
+uname(struct utsname *uts)
+{
+	struct kerninfo info;
+
+	sys_info(INFO_KERNEL, &info);
+	memcpy(uts, &info, sizeof(*uts));
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/Makefile.inc b/prex-0.9.0/usr/lib/posix/process/Makefile.inc
new file mode 100755
index 0000000..66419ea
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/Makefile.inc
@@ -0,0 +1,16 @@
+VPATH:=	$(SRCDIR)/usr/lib/posix/process:$(VPATH)
+
+SRCS+=	__process.c kill.c killpg.c \
+	getpgid.c getpgrp.c getpid.c getppid.c \
+	getuid.c geteuid.c setuid.c seteuid.c \
+	getgid.c setgid.c getegid.c setegid.c \
+	setsid.c getsid.c \
+	nice.c setpgid.c setpgrp.c sleep.c wait.c waitpid.c _exit.c \
+	getpriority.c setpriority.c
+
+ifeq ($(CONFIG_MMU),y)
+SRCS+=	fork.c
+else
+SRCS+=	fork_nommu.c
+endif
+
diff --git a/prex-0.9.0/usr/lib/posix/process/__process.c b/prex-0.9.0/usr/lib/posix/process/__process.c
new file mode 100755
index 0000000..031a5fb
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/__process.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+#include <ipc/proc.h>
+
+#include <stddef.h>
+
+void __process_init(void);
+void __process_exit(int status, int signo);
+
+
+object_t __proc_obj;
+
+void
+__process_init(void)
+{
+	int error;
+
+	/* Look up process server */
+	error = object_lookup("!proc", &__proc_obj);
+	if (error)
+		__proc_obj = 0;
+}
+
+void
+__process_exit(int status, int signo)
+{
+	struct msg m;
+
+	/* Notify to process server */
+	if (__proc_obj != 0) {
+		m.hdr.code = PS_EXIT;
+		m.data[0] = signo ? signo : ((status & 0xff) << 8);
+		msg_send(__proc_obj, &m, sizeof(m));
+	}
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/_exit.c b/prex-0.9.0/usr/lib/posix/process/_exit.c
new file mode 100755
index 0000000..78bf2c6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/_exit.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/prex.h>
+#include <sys/posix.h>
+
+#include <unistd.h>
+
+#ifndef _STANDALONE
+extern void __exception_exit(int *);
+extern void __file_exit(void);
+extern void __process_exit(int, int);
+#endif
+
+void
+_exit(int status)
+{
+#ifndef _STANDALONE
+	int signo;
+
+	__exception_exit(&signo);
+	__file_exit();
+	__process_exit(status, signo);
+#endif
+
+	for (;;)
+		task_terminate(task_self());
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/fork.c b/prex-0.9.0/usr/lib/posix/process/fork.c
new file mode 100755
index 0000000..ab02e42
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/fork.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <sys/signal.h>
+#include <ipc/proc.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <setjmp.h>
+#include <errno.h>
+#include <unistd.h>
+
+static void __child_entry(void);
+
+static jmp_buf __fork_env;
+
+/*
+ * fork() - fork for MMU system.
+ *
+ * RETURN VALUE:
+ *
+ *  fork() returns 0 to the child process and return the process
+ *  ID of the child process to the parent process. Or, -1 will be
+ *  returned to the parent process if error.
+ *
+ * ERRORS:
+ *
+ *  EAGAIN
+ *  ENOMEM
+ *
+ * NOTE:
+ *
+ *  Since no thread is created by task_create(), thread_create()
+ *  must be called follwing task_crate(). But, when new thread is
+ *  created by thread_create(), the stack pointer of new thread is
+ *  used at thread_create() although the stack image is copied at
+ *  task_create(). So, the stack pointer must be reset to same
+ *  address of thread_create() before calling task_create();
+ *  This is a little tricky...
+ *
+ * The new process is an exact copy of the calling process
+ * except as detailed below:
+ * - Process IDs are different.
+ * - tms_* is set to 0.
+ * - Alarm clock is set to 0.
+ * - Opend semaphore is inherited.
+ * - Pending signals are cleared.
+ *
+ * - File lock is not inherited.
+ * - File descriptor is shared.
+ * - Directory stream is shared.
+ */
+static pid_t
+fork(void)
+{
+	struct msg m;
+	task_t tsk;
+	thread_t t;
+	int error;
+	pid_t pid;
+
+	/* Save current stack pointer */
+	if (setjmp(__fork_env) == 0) {
+		/*
+		 * Create new task
+		 */
+		error = task_create(task_self(), VM_COPY, &tsk);
+		if (error) {
+			errno = error;
+			return -1;
+		}
+		if ((error = thread_create(tsk, &t)) != 0) {
+			task_terminate(tsk);
+			errno = error;
+			return -1;
+		}
+		/*
+		 * Notify to process server
+		 */
+		m.hdr.code = PS_FORK;
+		m.data[0] = tsk;		/* child task */
+		m.data[1] = 0;			/* fork type */
+		if (__posix_call(__proc_obj, &m, sizeof(m), 1) != 0)
+			return -1;
+		pid = m.data[0];
+
+		/*
+		 * Notify to file system server
+		 */
+		m.hdr.code = FS_FORK;
+		m.data[0] = tsk;		/* child task */
+		if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+			return -1;
+
+		/*
+		 * Start child task
+		 */
+		thread_load(t, __child_entry, NULL);
+		thread_resume(t);
+	} else {
+		/*
+		 * Child task
+		 */
+#ifdef _REENTRANT
+		error = mutex_init(&__sig_lock);
+#endif
+		__sig_pending = 0;
+		return 0;
+	}
+	return pid;
+}
+
+static void
+__child_entry(void)
+{
+
+	longjmp(__fork_env, 1);
+	/* NOTREACHED */
+}
+
+pid_t
+vfork(void)
+{
+
+	return fork();
+}
+
diff --git a/prex-0.9.0/usr/lib/posix/process/fork_nommu.c b/prex-0.9.0/usr/lib/posix/process/fork_nommu.c
new file mode 100755
index 0000000..d69800d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/fork_nommu.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <sys/signal.h>
+#include <ipc/proc.h>
+#include <ipc/fs.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <setjmp.h>
+#include <errno.h>
+
+static void __parent_entry(void);
+static void __child_entry(void);
+
+static jmp_buf __fork_env;
+static pid_t __child_pid;
+static thread_t __parent_thread;
+
+/*
+ * vfork() - vfork for No-MMU system.
+ *
+ * RETURN VALUE:
+ *
+ *  vfork() returns 0 to the child process and return the process
+ *  ID of the child process to the parent process. Or, -1 will be
+ *  returned to the parent process if error.
+ *
+ * ERRORS:
+ *
+ *  EAGAIN
+ *  ENOMEM
+ *
+ * NOTE:
+ *
+ *  Since no thread is created by task_create(), thread_create()
+ *  must be called follwing task_crate(). But, when new thread is
+ *  created by thread_create(), the stack pointer of new thread is
+ *  used at thread_create() although the stack image is copied at
+ *  task_create(). So, the stack pointer must be reset to same
+ *  address of thread_create() before calling task_create();
+ *  This is a little tricky...
+ *
+ * The new process is an exact copy of the calling process
+ * except as detailed below:
+ * - Process IDs are different.
+ * - tms_* is set to 0.
+ * - Alarm clock is set to 0.
+ * - Opend semaphore is inherited.
+ * - Pending signals are cleared.
+ *
+ * - File lock is not inherited.
+ * - File descriptor is shared.
+ * - Directory stream is shared.
+ */
+pid_t
+vfork(void)
+{
+	struct msg m;
+	task_t tsk;
+	thread_t t;
+	int error, sts, pri;
+
+	/* Save current stack pointer */
+	sts = setjmp(__fork_env);
+	if (sts == 0) {
+		/*
+		 * Create new task
+		 */
+		if ((error = task_create(task_self(), VM_SHARE, &tsk)) != 0) {
+			errno = error;
+			return -1;
+		}
+		if ((error = thread_create(tsk, &t)) != 0) {
+			task_terminate(tsk);
+			errno = error;
+			return -1;
+		}
+		/*
+		 * Notify to file system server
+		 */
+		m.hdr.code = FS_FORK;
+		m.data[0] = tsk;		/* child task */
+		if (__posix_call(__fs_obj, &m, sizeof(m), 1) != 0)
+			return -1;
+
+		/*
+		 * Notify to process server
+		 */
+		m.hdr.code = PS_FORK;
+		m.data[0] = tsk;		/* child task */
+		m.data[1] = 1;			/* fork type */
+		if (__posix_call(__proc_obj, &m, sizeof(m), 1) != 0)
+			return -1;
+		__child_pid = m.data[0];
+
+		/*
+		 * Start child task.
+		 *
+		 * TODO:
+		 * In order to synchronize the execution, we change
+		 * the child's priority to lower value. This ugly hack
+		 * will be replaced by some other methods...
+		 */
+		thread_load(t, __child_entry, NULL);
+		thread_getpri(t, &pri);
+		thread_setpri(t, pri + 1);
+		thread_resume(t);
+
+		/*
+		 * Suspend until child process calls exec() or exit()
+		 */
+		__parent_thread = thread_self();
+		task_suspend(task_self());
+
+	} else if (sts == 1) {
+		/*
+		 * Child task
+		 */
+		thread_load(__parent_thread, __parent_entry, NULL);
+		t = thread_self();
+		thread_getpri(t, &pri);
+		thread_setpri(t, pri - 1);
+
+#ifdef _REENTRANT
+		error = mutex_init(&__sig_lock);
+#endif
+		__sig_pending = 0;
+		thread_yield();
+		return 0;
+	}
+	return __child_pid;
+}
+
+static void
+__parent_entry(void)
+{
+
+	longjmp(__fork_env, 2);
+	/* NOTREACHED */
+}
+
+static void
+__child_entry(void)
+{
+
+	longjmp(__fork_env, 1);
+	/* NOTREACHED */
+}
+
+/*
+ * fork() is not supported on NOMMU system.
+ */
+pid_t
+fork(void)
+{
+
+	return ENOSYS;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getegid.c b/prex-0.9.0/usr/lib/posix/process/getegid.c
new file mode 100755
index 0000000..105995a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getegid.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+gid_t
+getegid(void)
+{
+
+	return (uid_t)1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/geteuid.c b/prex-0.9.0/usr/lib/posix/process/geteuid.c
new file mode 100755
index 0000000..723d749
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/geteuid.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+uid_t
+geteuid(void)
+{
+
+	return (uid_t)1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getgid.c b/prex-0.9.0/usr/lib/posix/process/getgid.c
new file mode 100755
index 0000000..3351bf6
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getgid.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+gid_t
+getgid(void)
+{
+
+	return (uid_t)1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getpgid.c b/prex-0.9.0/usr/lib/posix/process/getpgid.c
new file mode 100755
index 0000000..a70aa83
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getpgid.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+pid_t
+getpgid(pid_t pid)
+{
+	struct msg m;
+
+	m.hdr.code = PS_GETPGID;
+	m.data[0] = pid;
+	if (__posix_call(__proc_obj, &m, sizeof(m), 1))
+		return -1;
+
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getpgrp.c b/prex-0.9.0/usr/lib/posix/process/getpgrp.c
new file mode 100755
index 0000000..395b738
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getpgrp.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <unistd.h>
+
+pid_t
+getpgrp(void)
+{
+
+	return getpgid(0);
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getpid.c b/prex-0.9.0/usr/lib/posix/process/getpid.c
new file mode 100755
index 0000000..74369d2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getpid.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/ipc.h>
+#include <ipc/proc.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+pid_t
+getpid(void)
+{
+	struct msg m;
+
+	m.hdr.code = PS_GETPID;
+	__posix_call(__proc_obj, &m, sizeof(m), 1);
+
+	/* XXX: getpid can not return any error. */
+
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getppid.c b/prex-0.9.0/usr/lib/posix/process/getppid.c
new file mode 100755
index 0000000..d145309
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getppid.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/ipc.h>
+#include <ipc/proc.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+pid_t
+getppid(void)
+{
+	struct msg m;
+
+	m.hdr.code = PS_GETPPID;
+	__posix_call(__proc_obj, &m, sizeof(m), 1);
+
+
+	/* XXX: getppid does not return error */
+
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getpriority.c b/prex-0.9.0/usr/lib/posix/process/getpriority.c
new file mode 100755
index 0000000..6b7941a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getpriority.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <sys/resource.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+getpriority(int which, int who)
+{
+	int pri;
+
+	switch (which) {
+	case PRIO_PROCESS:
+	case PRIO_PGRP:
+		if (who != 0) {
+			errno = EPERM;
+			return -1;
+		}
+		break;
+	case PRIO_USER:
+		if (who != 1) {
+			errno = EPERM;
+			return -1;
+		}
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+	thread_getpri(thread_self(), &pri);
+
+	pri -= PRI_DEFAULT;
+
+	if (pri < MINPRI)
+		pri = MINPRI;
+	if (pri > MAXPRI)
+		pri = MAXPRI;
+
+	return pri;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getsid.c b/prex-0.9.0/usr/lib/posix/process/getsid.c
new file mode 100755
index 0000000..680b7af
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getsid.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+pid_t
+getsid(pid_t pid)
+{
+	struct msg m;
+
+	m.hdr.code = PS_GETSID;
+	m.data[0] = pid;
+	if (__posix_call(__proc_obj, &m, sizeof(m), 1))
+		return -1;
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/getuid.c b/prex-0.9.0/usr/lib/posix/process/getuid.c
new file mode 100755
index 0000000..e6d605e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/getuid.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+uid_t
+getuid(void)
+{
+
+	return (uid_t)1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/kill.c b/prex-0.9.0/usr/lib/posix/process/kill.c
new file mode 100755
index 0000000..817282f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/kill.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/ipc.h>
+#include <ipc/proc.h>
+
+#include <stddef.h>
+#include <signal.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+kill(pid_t pid, int sig)
+{
+	struct msg m;
+	int error;
+
+	/*
+	 * Request process server to send signal.
+	 */
+	m.hdr.code = PS_KILL;
+	m.data[0] = pid;
+	m.data[1] = sig;
+	error = msg_send(__proc_obj, &m, sizeof(m));
+
+	/*
+	 * XXX: error is always EINTR, and we can not determine whether
+	 *      msg_send() is interrupted by signal.
+	 */
+
+	if (m.hdr.status) {
+		errno = m.hdr.status;
+		return -1;
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/killpg.c b/prex-0.9.0/usr/lib/posix/process/killpg.c
new file mode 100755
index 0000000..a0ba763
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/killpg.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <unistd.h>
+#include <signal.h>
+
+int
+killpg(pid_t pgid, int sig)
+{
+
+	return kill(-pgid, sig);
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/nice.c b/prex-0.9.0/usr/lib/posix/process/nice.c
new file mode 100755
index 0000000..1605d15
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/nice.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <stddef.h>
+#include <errno.h>
+#include <unistd.h>
+
+/*
+ * Backwards compatible nice.
+ */
+int
+nice(incr)
+	int incr;
+{
+	int pri;
+
+	errno = 0;	/* XXX: Do not set 0 in errno... */
+
+	pri = getpriority(PRIO_PROCESS, 0);
+	if (pri == -1 && errno)
+		return (-1);
+	if (setpriority(PRIO_PROCESS, 0, pri + incr) != 0)
+		return (-1);
+	return (getpriority(PRIO_PROCESS, 0));
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setegid.c b/prex-0.9.0/usr/lib/posix/process/setegid.c
new file mode 100755
index 0000000..851b262
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setegid.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+int
+setegid(gid_t egid)
+{
+
+	if (egid == 1)
+		return 0;
+
+	errno = EPERM;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/seteuid.c b/prex-0.9.0/usr/lib/posix/process/seteuid.c
new file mode 100755
index 0000000..f2f89d7
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/seteuid.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+int
+seteuid(uid_t euid)
+{
+
+	if (euid == 1)
+		return 0;
+
+	errno = EPERM;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setgid.c b/prex-0.9.0/usr/lib/posix/process/setgid.c
new file mode 100755
index 0000000..808b3f9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setgid.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+int
+setgid(gid_t gid)
+{
+
+	if (gid == 1)
+		return 0;
+
+	errno = EPERM;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setpgid.c b/prex-0.9.0/usr/lib/posix/process/setpgid.c
new file mode 100755
index 0000000..868c07b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setpgid.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+setpgid(pid_t pid, pid_t pgid)
+{
+	struct msg m;
+
+	m.hdr.code = PS_SETPGID;
+	m.data[0] = pid;
+	m.data[1] = pgid;
+	return __posix_call(__proc_obj, &m, sizeof(m), 1);
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setpgrp.c b/prex-0.9.0/usr/lib/posix/process/setpgrp.c
new file mode 100755
index 0000000..1e7e991
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setpgrp.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stddef.h>
+#include <unistd.h>
+
+int
+setpgrp(pid_t pid, pid_t pgrp)
+{
+
+	return setpgid(0, 0);
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setpriority.c b/prex-0.9.0/usr/lib/posix/process/setpriority.c
new file mode 100755
index 0000000..645f3bd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setpriority.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <sys/resource.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+/*
+ * setpriority - set priority for process or process group.
+ *
+ * Note: support only for current process.
+ */
+int
+setpriority(int which, int who, int pri)
+{
+	int error, val;
+
+	switch (which) {
+	case PRIO_PROCESS:
+	case PRIO_PGRP:
+		if (who != 0) {
+			errno = EPERM;
+			return -1;
+		}
+		break;
+	case PRIO_USER:
+		if (who != 1) {
+			errno = EPERM;
+			return -1;
+		}
+		break;
+	default:
+		errno = EINVAL;
+		return -1;
+	}
+
+	if (pri < MINPRI)
+		pri = MINPRI;
+	if (pri > MAXPRI)
+		pri = MAXPRI;
+
+	val = PRI_DEFAULT + pri;
+
+	error = thread_setpri(thread_self(), val);
+	if (error) {
+		errno = error;
+		return -1;
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setsid.c b/prex-0.9.0/usr/lib/posix/process/setsid.c
new file mode 100755
index 0000000..e7d55ef
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setsid.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+pid_t
+setsid(void)
+{
+	struct msg m;
+
+	m.hdr.code = PS_SETSID;
+	if (__posix_call(__proc_obj, &m, sizeof(m), 1))
+		return -1;
+	return m.data[0];
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/setuid.c b/prex-0.9.0/usr/lib/posix/process/setuid.c
new file mode 100755
index 0000000..6190536
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/setuid.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+int
+setuid(uid_t uid)
+{
+
+	if (uid == 1)
+		return 0;
+
+	errno = EPERM;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/sleep.c b/prex-0.9.0/usr/lib/posix/process/sleep.c
new file mode 100755
index 0000000..451aa84
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/sleep.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <stddef.h>
+#include <unistd.h>
+#include <errno.h>
+
+unsigned int
+sleep(unsigned int seconds)
+{
+	unsigned int remain = 0;
+
+	timer_sleep(seconds * 1000, (u_long *)&remain);
+	return remain;
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/wait.c b/prex-0.9.0/usr/lib/posix/process/wait.c
new file mode 100755
index 0000000..bbab793
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/wait.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/wait.h>
+
+#include <stddef.h>
+#include <unistd.h>
+
+pid_t
+wait(int *status)
+{
+
+	return waitpid(-1, status, 0);
+}
diff --git a/prex-0.9.0/usr/lib/posix/process/waitpid.c b/prex-0.9.0/usr/lib/posix/process/waitpid.c
new file mode 100755
index 0000000..6c4b3f3
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/process/waitpid.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/posix.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+#include <sys/wait.h>
+
+#include <stddef.h>
+#include <errno.h>
+
+/*
+ * If the target child task calls exit() just after we
+ * send PS_WAITPID message, a process server will send an
+ * exception to us. But, we can not catch the exception
+ * before calling exception_wait().
+ */
+pid_t
+waitpid(pid_t pid, int *status, int options)
+{
+	struct msg m;
+	pid_t child;
+	int sig, error;
+	thread_t self;
+	int pri;
+
+	/* Boost current priority */
+	self = thread_self();
+	thread_getpri(self, &pri);
+	thread_setpri(self, pri - 1);
+	for (;;) {
+		m.hdr.code = PS_WAITPID;
+		m.data[0] = pid;
+		m.data[1] = options;
+		error = msg_send(__proc_obj, &m, sizeof(m));
+		if (error == EINTR)
+			continue;
+
+		if (m.hdr.status) {
+			errno = m.hdr.status;
+			return -1;
+		}
+		child = m.data[0];
+		if (child != 0 || options & WNOHANG)
+			break;
+
+		error = exception_wait(&sig);
+		if (error == EINTR) {
+			errno = EINTR;
+			break;
+		}
+	}
+	/* Restore priority */
+	thread_setpri(self, pri);
+	if (status != NULL)
+		*status = m.data[1];
+	return child;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/Makefile.inc b/prex-0.9.0/usr/lib/posix/signal/Makefile.inc
new file mode 100755
index 0000000..5e17d50
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/Makefile.inc
@@ -0,0 +1,5 @@
+VPATH:=	$(SRCDIR)/usr/lib/posix/signal:$(VPATH)
+
+SRCS+=	__exception.c \
+	pause.c sigaction.c signal.c sigpending.c sigprocmask.c \
+	sigsuspend.c sigcompat.c siglist.c
diff --git a/prex-0.9.0/usr/lib/posix/signal/__exception.c b/prex-0.9.0/usr/lib/posix/signal/__exception.c
new file mode 100755
index 0000000..dbee0a1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/__exception.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/signal.h>
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+void __exception_init(void);
+void __exception_exit(int *);
+
+static int __sig_exit;
+
+struct sigaction __sig_act[NSIG];
+sigset_t __sig_mask;
+sigset_t __sig_pending;
+
+#ifdef _REENTRANT
+volatile mutex_t __sig_lock;
+#endif
+
+/*
+ * Process all pending and unmasked signal
+ *
+ * return 0 if at least one pending signal was processed.
+ * return -1 if no signal was processed.
+ */
+int
+__sig_flush(void)
+{
+	int sig;
+	sigset_t active, org_mask;
+	struct sigaction action;
+	struct siginfo si;
+	int rc = -1;
+
+	sig = 1;
+	for (;;) {
+		SIGNAL_LOCK();
+		active = __sig_pending & ~__sig_mask;
+		action = __sig_act[sig];
+		SIGNAL_UNLOCK();
+
+		if (active == 0)
+			break;
+		if (active & sigmask(sig)) {
+
+			SIGNAL_LOCK();
+			org_mask = __sig_mask;
+			__sig_mask |= action.sa_mask;
+			SIGNAL_UNLOCK();
+
+			if (action.sa_handler == SIG_DFL) {
+				/* Default */
+				switch (sig) {
+				case SIGCHLD:
+				case SIGTSTP:
+					/* XXX: */
+					break;
+				default:
+					SIGNAL_LOCK();
+					__sig_pending &= ~sigmask(sig);
+					__sig_mask = org_mask;
+					__sig_exit = sig;
+					SIGNAL_UNLOCK();
+					exit(0);
+				}
+			} else if (action.sa_handler != SIG_IGN) {
+				/* User defined */
+				if (action.sa_flags & SA_SIGINFO) {
+					si.si_signo = sig;
+					si.si_code = 0;
+					si.si_value.sival_int = 0;
+					action.sa_sigaction(sig, &si, NULL);
+				} else {
+					action.sa_handler(sig);
+				}
+			}
+			SIGNAL_LOCK();
+			__sig_pending &= ~sigmask(sig);
+			__sig_mask = org_mask;
+			SIGNAL_UNLOCK();
+
+			switch (sig) {
+			case SIGILL:
+			case SIGTRAP:
+			case SIGFPE:
+			case SIGSEGV:
+				for (;;);	/* exception from kernel */
+				break;
+			}
+			if (action.sa_handler != SIG_IGN)
+				rc = 0;	/* Signal is processed */
+		}
+
+		if (++sig >= NSIG)
+			sig = 1;
+	}
+	return rc;
+}
+
+/*
+ * Exception handler for signal emulation
+ */
+static void
+__exception_handler(int excpt)
+{
+
+	if (excpt > 0 && excpt <= NSIG) {
+
+		SIGNAL_LOCK();
+
+		if (__sig_act[excpt].sa_handler != SIG_IGN)
+			__sig_pending |= sigmask(excpt);
+
+		SIGNAL_UNLOCK();
+	}
+	__sig_flush();
+	exception_return();
+}
+
+/*
+ * Initialize exception
+ */
+void
+__exception_init(void)
+{
+	int i;
+
+#ifdef _REENTRANT
+	mutex_init(&__sig_lock);
+#endif
+	exception_setup(EXC_DFL);
+
+	__sig_mask = 0;
+	__sig_pending = 0;
+	__sig_exit = 0;
+
+	for (i = 0; i < NSIG; i++) {
+		__sig_act[i].sa_flags = 0;
+		__sig_act[i].sa_handler = SIG_DFL;
+	}
+
+	/* Install exception handler */
+	exception_setup(__exception_handler);
+}
+
+/*
+ * Clean up
+ */
+void
+__exception_exit(int *signo)
+{
+
+#ifdef _REENTRANT
+	mutex_destroy(&__sig_lock);
+#endif
+	exception_setup(EXC_DFL);
+
+	*signo = __sig_exit;
+	__sig_exit = 0;
+	__sig_pending = 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/pause.c b/prex-0.9.0/usr/lib/posix/signal/pause.c
new file mode 100755
index 0000000..b860906
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/pause.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/signal.h>
+
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+#include <unistd.h>
+
+int
+pause(void)
+{
+	int sig, wait;
+
+	/* Wait signal if no pending singal */
+	if (__sig_flush()) {
+		wait = 1;
+		while (wait) {
+			exception_wait(&sig);
+			SIGNAL_LOCK();
+			/* It is ok if processed signal is not masked and not pending */
+			if (!(__sig_mask & sigmask(sig)) &&
+			    !(__sig_pending & sigmask(sig)))
+				wait = 0;
+			SIGNAL_UNLOCK();
+		}
+	}
+	/* Always returns error */
+	errno = EINTR;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/sigaction.c b/prex-0.9.0/usr/lib/posix/signal/sigaction.c
new file mode 100755
index 0000000..c59348a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/sigaction.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/signal.h>
+
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+/*
+ * If act is not NULL, set the action for signum.
+ * If oact is not NULL. store the old action to oact.
+ */
+int
+sigaction(int signum, const struct sigaction *act, struct sigaction *oact)
+{
+	struct sigaction *sa;
+
+	if (signum <= 0 || signum >= NSIG ||
+	    signum == SIGSTOP || signum == SIGKILL) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	SIGNAL_LOCK();
+
+	sa = &__sig_act[signum];
+
+	if (oact != NULL)
+		*oact = *sa;
+
+	if (act != NULL)
+		*sa = *act;
+
+	/* Discard pending signal in some cases */
+	if (sa->sa_handler == SIG_IGN ||
+	    (sa->sa_handler == SIG_DFL && signum == SIGCHLD))
+		__sig_pending &= ~sigmask(signum);
+
+	SIGNAL_UNLOCK();
+
+	/* Process pending signal */
+	__sig_flush();
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/sigcompat.c b/prex-0.9.0/usr/lib/posix/signal/sigcompat.c
new file mode 100755
index 0000000..5d6566f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/sigcompat.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <signal.h>
+
+int
+sigvec(signo, sv, osv)
+	int signo;
+	struct sigvec *sv, *osv;
+{
+	int ret;
+
+	if (sv)
+		sv->sv_flags ^= SV_INTERRUPT;	/* !SA_INTERRUPT */
+	ret = sigaction(signo, (struct sigaction *)sv, (struct sigaction *)osv);
+	if (ret == 0 && osv)
+		osv->sv_flags ^= SV_INTERRUPT;	/* !SA_INTERRUPT */
+	return (ret);
+}
+
+int
+sigsetmask(mask)
+	int mask;
+{
+	int omask, n;
+
+	n = sigprocmask(SIG_SETMASK, (sigset_t *) &mask, (sigset_t *) &omask);
+	if (n)
+		return (n);
+	return (omask);
+}
+
+int
+sigblock(mask)
+	int mask;
+{
+	int omask, n;
+
+	n = sigprocmask(SIG_BLOCK, (sigset_t *) &mask, (sigset_t *) &omask);
+	if (n)
+		return (n);
+	return (omask);
+}
+
+int
+sigpause(mask)
+	int mask;
+{
+	return (sigsuspend((sigset_t *)&mask));
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/siglist.c b/prex-0.9.0/usr/lib/posix/signal/siglist.c
new file mode 100755
index 0000000..ef49273
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/siglist.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 1983, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <signal.h>
+
+const char *const sys_signame[NSIG] = {
+	"Signal 0",
+	"hup",				/* SIGHUP */
+	"int",				/* SIGINT */
+	"quit",				/* SIGQUIT */
+	"ill",				/* SIGILL */
+	"trap",				/* SIGTRAP */
+	"abrt",				/* SIGABRT */
+	"emt",				/* SIGEMT */
+	"fpe",				/* SIGFPE */
+	"kill",				/* SIGKILL */
+	"bus",				/* SIGBUS */
+	"segv",				/* SIGSEGV */
+	"sys",				/* SIGSYS */
+	"pipe",				/* SIGPIPE */
+	"alrm",				/* SIGALRM */
+	"term",				/* SIGTERM */
+	"urg",				/* SIGURG */
+	"stop",				/* SIGSTOP */
+	"tstp",				/* SIGTSTP */
+	"cont",				/* SIGCONT */
+	"chld",				/* SIGCHLD */
+	"ttin",				/* SIGTTIN */
+	"ttou",				/* SIGTTOU */
+	"io",				/* SIGIO */
+	"xcpu",				/* SIGXCPU */
+	"xfsz",				/* SIGXFSZ */
+	"vtalrm",			/* SIGVTALRM */
+	"prof",				/* SIGPROF */
+	"winch",			/* SIGWINCH */
+	"info",				/* SIGINFO */
+	"usr1",				/* SIGUSR1 */
+	"usr2",				/* SIGUSR2 */
+};
+
+const char *const sys_siglist[NSIG] = {
+	"Signal 0",
+	"Hangup",			/* SIGHUP */
+	"Interrupt",			/* SIGINT */
+	"Quit",				/* SIGQUIT */
+	"Illegal instruction",		/* SIGILL */
+	"Trace/BPT trap",		/* SIGTRAP */
+	"Abort trap",			/* SIGABRT */
+	"EMT trap",			/* SIGEMT */
+	"Floating point exception",	/* SIGFPE */
+	"Killed",			/* SIGKILL */
+	"Bus error",			/* SIGBUS */
+	"Segmentation fault",		/* SIGSEGV */
+	"Bad system call",		/* SIGSYS */
+	"Broken pipe",			/* SIGPIPE */
+	"Alarm clock",			/* SIGALRM */
+	"Terminated",			/* SIGTERM */
+	"Urgent I/O condition",		/* SIGURG */
+	"Suspended (signal)",		/* SIGSTOP */
+	"Suspended",			/* SIGTSTP */
+	"Continued",			/* SIGCONT */
+	"Child exited",			/* SIGCHLD */
+	"Stopped (tty input)",		/* SIGTTIN */
+	"Stopped (tty output)",		/* SIGTTOU */
+	"I/O possible",			/* SIGIO */
+	"Cputime limit exceeded",	/* SIGXCPU */
+	"Filesize limit exceeded",	/* SIGXFSZ */
+	"Virtual timer expired",	/* SIGVTALRM */
+	"Profiling timer expired",	/* SIGPROF */
+	"Window size changes",		/* SIGWINCH */
+	"Information request",		/* SIGINFO */
+	"User defined signal 1",	/* SIGUSR1 */
+	"User defined signal 2"		/* SIGUSR2 */
+};
diff --git a/prex-0.9.0/usr/lib/posix/signal/signal.c b/prex-0.9.0/usr/lib/posix/signal/signal.c
new file mode 100755
index 0000000..91262b4
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/signal.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <signal.h>
+#include <errno.h>
+#include <stdlib.h>
+
+sig_t
+signal(int sig, sig_t handler)
+{
+	int error;
+	struct sigaction act, oact;
+
+	if (sig <= 0 || sig >= NSIG || sig == SIGSTOP || sig == SIGKILL) {
+		errno = EINVAL;
+		return SIG_ERR;
+	}
+
+	act.sa_handler = handler;
+	act.sa_flags = 0;
+	act.sa_mask = 0;
+	if (handler != SIG_IGN && handler != SIG_DFL)
+		act.sa_mask = sigmask(sig);
+
+	error = sigaction(sig, &act, &oact);
+	if (error)
+		return SIG_ERR;
+	return oact.sa_handler;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/sigpending.c b/prex-0.9.0/usr/lib/posix/signal/sigpending.c
new file mode 100755
index 0000000..f85019d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/sigpending.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/signal.h>
+
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+int
+sigpending(sigset_t *set)
+{
+	sigset_t pending;
+
+	if (set == NULL) {
+		errno = EFAULT;
+		return -1;
+	}
+	SIGNAL_LOCK();
+	pending = __sig_pending;
+	SIGNAL_UNLOCK();
+
+	*set = pending;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/sigprocmask.c b/prex-0.9.0/usr/lib/posix/signal/sigprocmask.c
new file mode 100755
index 0000000..487b031
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/sigprocmask.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/signal.h>
+
+#include <stddef.h>
+#include <signal.h>
+#include <errno.h>
+
+int
+sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
+{
+	sigset_t newset = 0;
+
+	if (set != NULL)
+		newset = *set;
+
+	SIGNAL_LOCK();
+
+	if (oldset != NULL)
+		*oldset = __sig_mask;
+
+	if (set != NULL) {
+		switch (how) {
+		case SIG_BLOCK:
+			__sig_mask |= newset;
+			break;
+		case SIG_UNBLOCK:
+			__sig_mask &= ~newset;
+			break;
+		case SIG_SETMASK:
+			__sig_mask = newset;
+			break;
+		default:
+			SIGNAL_UNLOCK();
+			errno = EINVAL;
+			return -1;
+		}
+	}
+	__sig_mask &= ~(sigmask(SIGSTOP) | sigmask(SIGKILL));
+
+	SIGNAL_UNLOCK();
+
+	/* Process pending signal */
+	__sig_flush();
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/posix/signal/sigsuspend.c b/prex-0.9.0/usr/lib/posix/signal/sigsuspend.c
new file mode 100755
index 0000000..ef1f225
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/signal/sigsuspend.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/signal.h>
+
+#include <stddef.h>
+#include <signal.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+sigsuspend(const sigset_t *mask)
+{
+	sigset_t old_mask;
+
+	if (mask == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	if (sigprocmask(SIG_SETMASK, mask, &old_mask))
+		return -1;
+
+	pause();
+
+	if (sigprocmask(SIG_SETMASK, &old_mask, NULL))
+		return -1;
+
+	/* Flush signals */
+	__sig_flush();
+
+	/* Always returns error */
+	errno = EINTR;
+	return -1;
+}
diff --git a/prex-0.9.0/usr/lib/posix/time/Makefile.inc b/prex-0.9.0/usr/lib/posix/time/Makefile.inc
new file mode 100755
index 0000000..e24404a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/time/Makefile.inc
@@ -0,0 +1,3 @@
+VPATH:=	$(SRCDIR)/usr/lib/posix/time:$(VPATH)
+
+SRCS+=	gettimeofday.c
diff --git a/prex-0.9.0/usr/lib/posix/time/gettimeofday.c b/prex-0.9.0/usr/lib/posix/time/gettimeofday.c
new file mode 100755
index 0000000..285fde5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/posix/time/gettimeofday.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/time.h>
+#include <sys/fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+	int fd, error;
+
+	if ((fd = open("/dev/rtc", 0)) < 0) {
+		errno = EPERM;
+		return -1;
+	}
+	error = ioctl(fd, RTCIOC_GET_TIME, tv);
+	close(fd);
+	if (error) {
+		errno = error;
+		return -1;
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/lib/prex/Makefile.inc b/prex-0.9.0/usr/lib/prex/Makefile.inc
new file mode 100755
index 0000000..5a2799d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/Makefile.inc
@@ -0,0 +1,3 @@
+include $(SRCDIR)/usr/lib/prex/syscalls/Makefile.inc
+include $(SRCDIR)/usr/lib/prex/malloc/Makefile.inc
+include $(SRCDIR)/usr/lib/prex/gen/Makefile.inc
diff --git a/prex-0.9.0/usr/lib/prex/gen/Makefile.inc b/prex-0.9.0/usr/lib/prex/gen/Makefile.inc
new file mode 100755
index 0000000..e5db28e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/gen/Makefile.inc
@@ -0,0 +1,3 @@
+VPATH:=	$(SRCDIR)/usr/lib/prex/gen:$(VPATH)
+
+SRCS+=	panic.c dprintf.c dassert.c
diff --git a/prex-0.9.0/usr/lib/prex/gen/dassert.c b/prex-0.9.0/usr/lib/prex/gen/dassert.c
new file mode 100755
index 0000000..d6bc398
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/gen/dassert.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+void
+__dassert(const char *file, int line, const char *exp)
+{
+	char buf[128];
+
+	sprintf(buf, "assertion \"%s\" failed: file \"%s\", line %d\n",
+		exp, file, line);
+	sys_panic(buf);
+	/* NOTREACHED */
+}
diff --git a/prex-0.9.0/usr/lib/prex/gen/dprintf.c b/prex-0.9.0/usr/lib/prex/gen/dprintf.c
new file mode 100755
index 0000000..6b2481d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/gen/dprintf.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/prex.h>
+
+extern int vsprintf(char *buf, const char *fmt, va_list args);
+
+void
+dprintf(const char *fmt, ...)
+{
+	char buf[LINE_MAX];
+	va_list args;
+
+	va_start(args, fmt);
+	vsprintf(buf, fmt, args);
+	sys_log(buf);
+	va_end(args);
+}
diff --git a/prex-0.9.0/usr/lib/prex/gen/panic.c b/prex-0.9.0/usr/lib/prex/gen/panic.c
new file mode 100755
index 0000000..0f6df68
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/gen/panic.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/prex.h>
+
+extern int vsprintf(char *buf, const char *fmt, va_list args);
+
+void
+panic(const char *fmt, ...)
+{
+	char buf[LINE_MAX];
+	va_list args;
+
+	va_start(args, fmt);
+	vsprintf(buf, fmt, args);
+	sys_panic(buf);
+	va_end(args);
+}
diff --git a/prex-0.9.0/usr/lib/prex/malloc/Makefile.inc b/prex-0.9.0/usr/lib/prex/malloc/Makefile.inc
new file mode 100755
index 0000000..adb873a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/malloc/Makefile.inc
@@ -0,0 +1,3 @@
+VPATH:=	$(SRCDIR)/usr/lib/prex/malloc:$(VPATH)
+
+SRCS+=	malloc.c malloc_r.c realloc.c
diff --git a/prex-0.9.0/usr/lib/prex/malloc/malloc.c b/prex-0.9.0/usr/lib/prex/malloc/malloc.c
new file mode 100755
index 0000000..27a2874
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/malloc/malloc.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/prex.h>
+#include <sys/param.h>
+#include <sys/syslog.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include "malloc.h"
+
+#ifdef _REENTRANT
+static mutex_t malloc_lock = MUTEX_INITIALIZER;
+#endif
+
+static struct header *more_core(size_t size);
+
+static struct header free_list;		/* start of free list */
+static struct header *scan_head;	/* start point to scan */
+
+/*
+ * Simple memory allocator from K&R
+ */
+void *
+malloc(size_t size)
+{
+	struct header *p, *prev;
+
+	if (size == 0)		/* sanity check */
+		return NULL;
+	size = ROUNDUP(size + sizeof(struct header));
+
+	MALLOC_LOCK();
+
+	if (scan_head == NULL) {
+		/* Initialize */
+		free_list.next = &free_list;
+		free_list.size = 0;
+		free_list.vm_size = 0;
+		scan_head = &free_list;
+	}
+	prev = scan_head;
+	for (p = prev->next;; prev = p, p = p->next) {
+		if (p->size >= size) {	/* big enough */
+			if (p->size == size)	/* exactly */
+				prev->next = p->next;
+			else {			/* allocate tail end */
+				p->size -= size;
+				p = (struct header *)((char *)p + p->size);
+				p->size = size;
+				p->vm_size = 0;
+			}
+#ifdef DEBUG_MALLOC
+			p->magic = MALLOC_MAGIC;
+#endif
+			scan_head = prev;
+			break;
+		}
+		if (p == scan_head) {
+			if ((p = more_core(size)) == NULL)
+				break;
+		}
+	}
+	MALLOC_UNLOCK();
+
+	if (p == NULL) {
+#ifdef DEBUG_MALLOC
+		sys_panic("malloc: out of memory");
+#endif
+		return NULL;
+	}
+	return (void *)(p + 1);
+}
+
+/*
+ * Create new block and insert it to the free list.
+ */
+static struct header *more_core(size_t size)
+{
+	struct header *p, *prev;
+
+	size = round_page(size);
+	if (vm_allocate(task_self(), (void *)&p, size, 1))
+		return NULL;
+	p->size = size;
+	p->vm_size = size;
+
+	/* Insert to free list */
+	for (prev = scan_head; !(p > prev && p < prev->next); prev = prev->next) {
+		if (prev >= prev->next && (p > prev || p < prev->next))
+			break;
+	}
+	p->next = prev->next;
+	prev->next = p;
+	scan_head = prev;
+	return prev;
+}
+
+void
+free(void *addr)
+{
+	struct header *p, *prev;
+
+	if (addr == NULL)
+		return;
+
+	MALLOC_LOCK();
+	p = (struct header *)addr - 1;
+#ifdef DEBUG_MALLOC
+	if (p->magic != MALLOC_MAGIC)
+		sys_panic("free: invalid pointer");
+	p->magic = 0;
+#endif
+	for (prev = scan_head; !(p > prev && p < prev->next); prev = prev->next) {
+		if (prev >= prev->next && (p > prev || p < prev->next))
+			break;
+	}
+	if ((prev->next->vm_size == 0) &&	/* join to upper block */
+	    ((char *)p + p->size == (char *)prev->next)) {
+		p->size += prev->next->size;
+		p->next = prev->next->next;
+	} else {
+		p->next = prev->next;
+	}
+	if ((p->vm_size == 0) &&	/* join to lower block */
+	    ((char *)prev + prev->size == (char *)p)) {
+		prev->size += p->size;
+		prev->next = p->next;
+	} else {
+		prev->next = p;
+	}
+	/* Deallocate pool */
+	if (p->size == p->vm_size) {
+		prev->next = p->next;
+		vm_free(task_self(), p);
+	}
+	scan_head = prev;
+	MALLOC_UNLOCK();
+}
+
+#ifdef DEBUG_MALLOC
+void
+mstat(void)
+{
+	struct header *p;
+
+	printf("mstat: task=%x\n", task_self());
+	for (p = free_list.next; p != &free_list; p = p->next) {
+		printf("mstat: addr=%x size=%d next=%x\n", p, p->size, p->next);
+	}
+}
+#endif
diff --git a/prex-0.9.0/usr/lib/prex/malloc/malloc.h b/prex-0.9.0/usr/lib/prex/malloc/malloc.h
new file mode 100755
index 0000000..c0cc915
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/malloc/malloc.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/param.h>
+
+/* #define DEBUG_MALLOC	1 */
+
+#define MALLOC_MAGIC	(int)0xBAADF00D	/* "bad food" from LocalAlloc :) */
+
+#ifdef _REENTRANT
+#define MALLOC_LOCK()	mutex_lock(&malloc_lock);
+#define MALLOC_UNLOCK()	mutex_unlock(&malloc_lock);
+#else
+#define MALLOC_LOCK()	do {} while (0)
+#define MALLOC_UNLOCK()	do {} while (0)
+#endif
+
+#define ALIGN_SIZE      16
+#define ALIGN_MASK      (ALIGN_SIZE - 1)
+#define ROUNDUP(size)   (((u_long)(size) + ALIGN_MASK) & ~ALIGN_MASK)
+
+struct header {
+	struct header *next;
+	size_t size;
+	size_t vm_size;
+#ifdef DEBUG_MALLOC
+	int magic;
+#endif
+};
diff --git a/prex-0.9.0/usr/lib/prex/malloc/malloc_r.c b/prex-0.9.0/usr/lib/prex/malloc/malloc_r.c
new file mode 100755
index 0000000..3f8db87
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/malloc/malloc_r.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * malloc_r() - this is used with multi-threaded native task.
+ */
+
+#include <sys/prex.h>
+#include <stdlib.h>
+#include "malloc.h"
+
+static mutex_t malloc_r_lock = MUTEX_INITIALIZER;
+
+void *
+malloc_r(size_t size)
+{
+	void *p;
+
+	mutex_lock(&malloc_r_lock);
+	p = malloc(size);
+	mutex_unlock(&malloc_r_lock);
+	return p;
+}
+
+void
+free_r(void *addr)
+{
+	mutex_lock(&malloc_r_lock);
+	free(addr);
+	mutex_unlock(&malloc_r_lock);
+}
diff --git a/prex-0.9.0/usr/lib/prex/malloc/realloc.c b/prex-0.9.0/usr/lib/prex/malloc/realloc.c
new file mode 100755
index 0000000..6d65721
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/malloc/realloc.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "malloc.h"
+
+void *
+realloc(void *addr, size_t size)
+{
+	struct header *p, *old;
+	size_t old_size;
+
+	if (addr == NULL)
+		return malloc(size);
+
+	old = (struct header *)addr - 1;
+#ifdef DEBUG_MALLOC
+	if (old->magic != MALLOC_MAGIC)
+		sys_panic("free: invalid pointer");
+#endif
+	old_size = old->size - sizeof(struct header);
+	if ((p = malloc(size)) == NULL)
+		return NULL;
+	if (old_size <= size)
+		memcpy(p, addr, old_size);
+	else
+		memcpy(p, addr, size);
+	free(addr);
+	return p;
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/Makefile.inc b/prex-0.9.0/usr/lib/prex/syscalls/Makefile.inc
new file mode 100755
index 0000000..bbf9500
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/Makefile.inc
@@ -0,0 +1,28 @@
+VPATH:=	$(SRCDIR)/usr/lib/prex/syscalls:$(VPATH)
+
+SRCS+=	$(SRCDIR)/usr/arch/$(ARCH)/_systrap.S \
+	object_create.S object_destroy.S object_lookup.S \
+	msg_send.S msg_receive.S msg_reply.S \
+	vm_allocate.S vm_free.S vm_attribute.S vm_map.S \
+	task_create.S task_terminate.S task_self.S \
+	task_suspend.S task_resume.S task_setname.S \
+	task_setcap.S task_chkcap.S \
+	thread_create.S thread_terminate.S thread_load.S thread_self.S \
+	thread_yield.S thread_suspend.S thread_resume.S thread_schedparam.S \
+	thread_getpri.c thread_setpri.c \
+	thread_getpolicy.c thread_setpolicy.c \
+	timer_sleep.S timer_alarm.S timer_periodic.S \
+	_timer_waitperiod.S timer_waitperiod.c \
+	exception_setup.S exception_return.S \
+	exception_raise.S exception_wait.S \
+	device_open.S device_close.S device_read.S device_write.S \
+	device_ioctl.S \
+	mutex_init.S mutex_destroy.S mutex_trylock.S mutex_unlock.S \
+	_mutex_lock.S mutex_lock.c \
+	cond_init.S cond_destroy.S cond_signal.S cond_broadcast.S \
+	_cond_wait.S cond_wait.c \
+	sem_init.S sem_destroy.S sem_trywait.S sem_post.S sem_getvalue.S \
+	_sem_wait.S sem_wait.c \
+	sys_log.S sys_info.S sys_panic.S sys_time.S \
+	sys_debug.S
+
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/_cond_wait.S b/prex-0.9.0/usr/lib/prex/syscalls/_cond_wait.S
new file mode 100755
index 0000000..50c805f
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/_cond_wait.S
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+#define SYS__cond_wait  SYS_cond_wait
+
+SYSCALL2(_cond_wait)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/_mutex_lock.S b/prex-0.9.0/usr/lib/prex/syscalls/_mutex_lock.S
new file mode 100755
index 0000000..edc8788
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/_mutex_lock.S
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+#define SYS__mutex_lock SYS_mutex_lock
+
+SYSCALL1(_mutex_lock)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/_sem_wait.S b/prex-0.9.0/usr/lib/prex/syscalls/_sem_wait.S
new file mode 100755
index 0000000..8e87faf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/_sem_wait.S
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+#define SYS__sem_wait  SYS_sem_wait
+
+SYSCALL2(_sem_wait)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/_timer_waitperiod.S b/prex-0.9.0/usr/lib/prex/syscalls/_timer_waitperiod.S
new file mode 100755
index 0000000..5583de8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/_timer_waitperiod.S
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+#define SYS__timer_waitperiod SYS_timer_waitperiod
+
+SYSCALL0(_timer_waitperiod)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/cond_broadcast.S b/prex-0.9.0/usr/lib/prex/syscalls/cond_broadcast.S
new file mode 100755
index 0000000..f4f1d0d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/cond_broadcast.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(cond_broadcast)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/cond_destroy.S b/prex-0.9.0/usr/lib/prex/syscalls/cond_destroy.S
new file mode 100755
index 0000000..ced9444
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/cond_destroy.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(cond_destroy)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/cond_init.S b/prex-0.9.0/usr/lib/prex/syscalls/cond_init.S
new file mode 100755
index 0000000..60c0d05
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/cond_init.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(cond_init)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/cond_signal.S b/prex-0.9.0/usr/lib/prex/syscalls/cond_signal.S
new file mode 100755
index 0000000..2f19aaf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/cond_signal.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(cond_signal)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/cond_wait.c b/prex-0.9.0/usr/lib/prex/syscalls/cond_wait.c
new file mode 100755
index 0000000..b48befc
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/cond_wait.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <errno.h>
+
+extern int _cond_wait(cond_t *cond, mutex_t *mu);
+
+/*
+ * cond_wait() is not interrupted by signal
+ */
+int
+cond_wait(cond_t *cond, mutex_t *mu)
+{
+	int error;
+
+	do
+		error = _cond_wait(cond, mu);
+	while (error == EINTR);
+	return error;
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/device_close.S b/prex-0.9.0/usr/lib/prex/syscalls/device_close.S
new file mode 100755
index 0000000..417780c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/device_close.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(device_close)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/device_ioctl.S b/prex-0.9.0/usr/lib/prex/syscalls/device_ioctl.S
new file mode 100755
index 0000000..39f53d5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/device_ioctl.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(device_ioctl)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/device_open.S b/prex-0.9.0/usr/lib/prex/syscalls/device_open.S
new file mode 100755
index 0000000..ed23252
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/device_open.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(device_open)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/device_read.S b/prex-0.9.0/usr/lib/prex/syscalls/device_read.S
new file mode 100755
index 0000000..f97123e
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/device_read.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL4(device_read)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/device_write.S b/prex-0.9.0/usr/lib/prex/syscalls/device_write.S
new file mode 100755
index 0000000..8b11f43
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/device_write.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL4(device_write)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/exception_raise.S b/prex-0.9.0/usr/lib/prex/syscalls/exception_raise.S
new file mode 100755
index 0000000..8e84257
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/exception_raise.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(exception_raise)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/exception_return.S b/prex-0.9.0/usr/lib/prex/syscalls/exception_return.S
new file mode 100755
index 0000000..dcf72cf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/exception_return.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(exception_return)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/exception_setup.S b/prex-0.9.0/usr/lib/prex/syscalls/exception_setup.S
new file mode 100755
index 0000000..3c240b9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/exception_setup.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(exception_setup)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/exception_wait.S b/prex-0.9.0/usr/lib/prex/syscalls/exception_wait.S
new file mode 100755
index 0000000..5d3dc2c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/exception_wait.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(exception_wait)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/msg_receive.S b/prex-0.9.0/usr/lib/prex/syscalls/msg_receive.S
new file mode 100755
index 0000000..9419f7c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/msg_receive.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(msg_receive)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/msg_reply.S b/prex-0.9.0/usr/lib/prex/syscalls/msg_reply.S
new file mode 100755
index 0000000..da64327
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/msg_reply.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(msg_reply)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/msg_send.S b/prex-0.9.0/usr/lib/prex/syscalls/msg_send.S
new file mode 100755
index 0000000..b4f3ae2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/msg_send.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(msg_send)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/mutex_destroy.S b/prex-0.9.0/usr/lib/prex/syscalls/mutex_destroy.S
new file mode 100755
index 0000000..9affdce
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/mutex_destroy.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(mutex_destroy)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/mutex_init.S b/prex-0.9.0/usr/lib/prex/syscalls/mutex_init.S
new file mode 100755
index 0000000..9a24c13
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/mutex_init.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(mutex_init)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/mutex_lock.c b/prex-0.9.0/usr/lib/prex/syscalls/mutex_lock.c
new file mode 100755
index 0000000..b7cbdb5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/mutex_lock.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <errno.h>
+
+extern int _mutex_lock(mutex_t *mu);
+
+/*
+ * mutex_lock() is not interrupted by signal
+ */
+int
+mutex_lock(mutex_t *mu)
+{
+	int error;
+
+	do
+		error = _mutex_lock(mu);
+	while (error == EINTR);
+	return error;
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/mutex_trylock.S b/prex-0.9.0/usr/lib/prex/syscalls/mutex_trylock.S
new file mode 100755
index 0000000..4082480
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/mutex_trylock.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(mutex_trylock)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/mutex_unlock.S b/prex-0.9.0/usr/lib/prex/syscalls/mutex_unlock.S
new file mode 100755
index 0000000..4b29ae1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/mutex_unlock.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(mutex_unlock)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/object_create.S b/prex-0.9.0/usr/lib/prex/syscalls/object_create.S
new file mode 100755
index 0000000..1ee754c
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/object_create.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(object_create)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/object_destroy.S b/prex-0.9.0/usr/lib/prex/syscalls/object_destroy.S
new file mode 100755
index 0000000..a2d1473
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/object_destroy.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(object_destroy)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/object_lookup.S b/prex-0.9.0/usr/lib/prex/syscalls/object_lookup.S
new file mode 100755
index 0000000..b01474d
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/object_lookup.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(object_lookup)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sem_destroy.S b/prex-0.9.0/usr/lib/prex/syscalls/sem_destroy.S
new file mode 100755
index 0000000..e91fdee
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sem_destroy.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(sem_destroy)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sem_getvalue.S b/prex-0.9.0/usr/lib/prex/syscalls/sem_getvalue.S
new file mode 100755
index 0000000..bed95fc
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sem_getvalue.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(sem_getvalue)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sem_init.S b/prex-0.9.0/usr/lib/prex/syscalls/sem_init.S
new file mode 100755
index 0000000..c6a33bd
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sem_init.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(sem_init)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sem_post.S b/prex-0.9.0/usr/lib/prex/syscalls/sem_post.S
new file mode 100755
index 0000000..8a27595
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sem_post.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(sem_post)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sem_trywait.S b/prex-0.9.0/usr/lib/prex/syscalls/sem_trywait.S
new file mode 100755
index 0000000..0984071
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sem_trywait.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(sem_trywait)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sem_wait.c b/prex-0.9.0/usr/lib/prex/syscalls/sem_wait.c
new file mode 100755
index 0000000..5a6ac91
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sem_wait.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <errno.h>
+
+extern int _sem_wait(sem_t *sem, unsigned long timeout);
+
+/*
+ * sem_wait is not interrupted by signal.
+ */
+int
+sem_wait(sem_t *sem, unsigned long msec)
+{
+	int error;
+
+	do
+		error = _sem_wait(sem, msec);
+	while (error == EINTR);
+	return error;
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sys_debug.S b/prex-0.9.0/usr/lib/prex/syscalls/sys_debug.S
new file mode 100755
index 0000000..80bc588
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sys_debug.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2006-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(sys_debug)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sys_info.S b/prex-0.9.0/usr/lib/prex/syscalls/sys_info.S
new file mode 100755
index 0000000..de9ec34
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sys_info.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(sys_info)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sys_log.S b/prex-0.9.0/usr/lib/prex/syscalls/sys_log.S
new file mode 100755
index 0000000..1e3f3c1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sys_log.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(sys_log)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sys_panic.S b/prex-0.9.0/usr/lib/prex/syscalls/sys_panic.S
new file mode 100755
index 0000000..a033b87
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sys_panic.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(sys_panic)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/sys_time.S b/prex-0.9.0/usr/lib/prex/syscalls/sys_time.S
new file mode 100755
index 0000000..69031d2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/sys_time.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(sys_time)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/syscall.h b/prex-0.9.0/usr/lib/prex/syscalls/syscall.h
new file mode 100755
index 0000000..b79123a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/syscall.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * syscall.h - system call number
+ */
+
+#ifndef _SYSCALL_H
+#define _SYSCALL_H
+
+#define SYS_exception_return	 0
+#define SYS_exception_setup	 1
+#define SYS_exception_raise	 2
+#define SYS_exception_wait	 3
+#define SYS_task_create		 4
+#define SYS_task_terminate	 5
+#define SYS_task_self		 6
+#define SYS_task_suspend	 7
+#define SYS_task_resume		 8
+#define SYS_task_setname	 9
+#define SYS_task_setcap		10
+#define SYS_task_chkcap		11
+#define SYS_thread_create	12
+#define SYS_thread_terminate	13
+#define SYS_thread_load		14
+#define SYS_thread_self		15
+#define SYS_thread_yield	16
+#define SYS_thread_suspend	17
+#define SYS_thread_resume	18
+#define SYS_thread_schedparam	19
+#define SYS_vm_allocate		20
+#define SYS_vm_free		21
+#define SYS_vm_attribute	22
+#define SYS_vm_map		23
+#define SYS_object_create	24
+#define SYS_object_destroy	25
+#define SYS_object_lookup	26
+#define SYS_msg_send		27
+#define SYS_msg_receive		28
+#define SYS_msg_reply		29
+#define SYS_timer_sleep		30
+#define SYS_timer_alarm		31
+#define SYS_timer_periodic	32
+#define SYS_timer_waitperiod	33
+#define SYS_device_open		34
+#define SYS_device_close	35
+#define SYS_device_read		36
+#define SYS_device_write	37
+#define SYS_device_ioctl	38
+#define SYS_mutex_init		39
+#define SYS_mutex_destroy	40
+#define SYS_mutex_lock		41
+#define SYS_mutex_trylock	42
+#define SYS_mutex_unlock	43
+#define SYS_cond_init		44
+#define SYS_cond_destroy	45
+#define SYS_cond_wait		46
+#define SYS_cond_signal		47
+#define SYS_cond_broadcast	48
+#define SYS_sem_init		49
+#define SYS_sem_destroy		50
+#define SYS_sem_wait		51
+#define SYS_sem_trywait		52
+#define SYS_sem_post		53
+#define SYS_sem_getvalue	54
+#define SYS_sys_log		55
+#define SYS_sys_panic		56
+#define SYS_sys_info		57
+#define SYS_sys_time		58
+#define SYS_sys_debug		59
+
+#endif /* _SYSCALL_H */
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_chkcap.S b/prex-0.9.0/usr/lib/prex/syscalls/task_chkcap.S
new file mode 100755
index 0000000..c8ae715
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_chkcap.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(task_chkcap)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_create.S b/prex-0.9.0/usr/lib/prex/syscalls/task_create.S
new file mode 100755
index 0000000..407fca8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_create.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(task_create)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_resume.S b/prex-0.9.0/usr/lib/prex/syscalls/task_resume.S
new file mode 100755
index 0000000..4124da9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_resume.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(task_resume)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_self.S b/prex-0.9.0/usr/lib/prex/syscalls/task_self.S
new file mode 100755
index 0000000..4cf9161
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_self.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL0(task_self)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_setcap.S b/prex-0.9.0/usr/lib/prex/syscalls/task_setcap.S
new file mode 100755
index 0000000..1f5747a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_setcap.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(task_setcap)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_setname.S b/prex-0.9.0/usr/lib/prex/syscalls/task_setname.S
new file mode 100755
index 0000000..238bfb8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_setname.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(task_setname)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_suspend.S b/prex-0.9.0/usr/lib/prex/syscalls/task_suspend.S
new file mode 100755
index 0000000..bb7c6db
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_suspend.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(task_suspend)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/task_terminate.S b/prex-0.9.0/usr/lib/prex/syscalls/task_terminate.S
new file mode 100755
index 0000000..70550e8
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/task_terminate.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(task_terminate)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_create.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_create.S
new file mode 100755
index 0000000..2db1d01
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_create.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(thread_create)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_getpolicy.c b/prex-0.9.0/usr/lib/prex/syscalls/thread_getpolicy.c
new file mode 100755
index 0000000..2bba2f2
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_getpolicy.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+extern int thread_schedparam(thread_t t, int op, int *param);
+
+int
+thread_getpolicy(thread_t t, int *policy)
+{
+
+	return thread_schedparam(t, 2, policy);
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_getpri.c b/prex-0.9.0/usr/lib/prex/syscalls/thread_getpri.c
new file mode 100755
index 0000000..96bec47
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_getpri.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+extern int thread_schedparam(thread_t t, int op, int *param);
+
+int
+thread_getpri(thread_t t, int *pri)
+{
+
+	return thread_schedparam(t, 0, pri);
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_load.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_load.S
new file mode 100755
index 0000000..20b52ad
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_load.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(thread_load)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_resume.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_resume.S
new file mode 100755
index 0000000..e3c8fb5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_resume.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(thread_resume)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_schedparam.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_schedparam.S
new file mode 100755
index 0000000..74b106b
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_schedparam.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(thread_schedparam)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_self.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_self.S
new file mode 100755
index 0000000..bc9a845
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_self.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL0(thread_self)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_setpolicy.c b/prex-0.9.0/usr/lib/prex/syscalls/thread_setpolicy.c
new file mode 100755
index 0000000..ebabc55
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_setpolicy.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+extern int thread_schedparam(thread_t t, int op, int *param);
+
+int
+thread_setpolicy(thread_t t, int policy)
+{
+
+	return thread_schedparam(t, 3, &policy);
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_setpri.c b/prex-0.9.0/usr/lib/prex/syscalls/thread_setpri.c
new file mode 100755
index 0000000..7f9ec96
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_setpri.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+extern int thread_schedparam(thread_t t, int op, int *param);
+
+int
+thread_setpri(thread_t t, int pri)
+{
+
+	return thread_schedparam(t, 1, &pri);
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_suspend.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_suspend.S
new file mode 100755
index 0000000..9034eba
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_suspend.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(thread_suspend)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_terminate.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_terminate.S
new file mode 100755
index 0000000..8bd55ea
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_terminate.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL1(thread_terminate)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/thread_yield.S b/prex-0.9.0/usr/lib/prex/syscalls/thread_yield.S
new file mode 100755
index 0000000..8566cc9
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/thread_yield.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL0(thread_yield)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/timer_alarm.S b/prex-0.9.0/usr/lib/prex/syscalls/timer_alarm.S
new file mode 100755
index 0000000..553bb1a
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/timer_alarm.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(timer_alarm)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/timer_periodic.S b/prex-0.9.0/usr/lib/prex/syscalls/timer_periodic.S
new file mode 100755
index 0000000..c01cafc
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/timer_periodic.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(timer_periodic)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/timer_sleep.S b/prex-0.9.0/usr/lib/prex/syscalls/timer_sleep.S
new file mode 100755
index 0000000..f93a579
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/timer_sleep.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(timer_sleep)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/timer_waitperiod.c b/prex-0.9.0/usr/lib/prex/syscalls/timer_waitperiod.c
new file mode 100755
index 0000000..bfc7d85
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/timer_waitperiod.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <errno.h>
+
+extern int _timer_waitperiod(void);
+
+int
+timer_waitperiod(void)
+{
+	int error;
+
+	do
+		error = _timer_waitperiod();
+	while (error == EINTR);
+	return error;
+}
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/vm_allocate.S b/prex-0.9.0/usr/lib/prex/syscalls/vm_allocate.S
new file mode 100755
index 0000000..1aa62bf
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/vm_allocate.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL4(vm_allocate)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/vm_attribute.S b/prex-0.9.0/usr/lib/prex/syscalls/vm_attribute.S
new file mode 100755
index 0000000..17c9cc5
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/vm_attribute.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL3(vm_attribute)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/vm_free.S b/prex-0.9.0/usr/lib/prex/syscalls/vm_free.S
new file mode 100755
index 0000000..77b4360
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/vm_free.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL2(vm_free)
diff --git a/prex-0.9.0/usr/lib/prex/syscalls/vm_map.S b/prex-0.9.0/usr/lib/prex/syscalls/vm_map.S
new file mode 100755
index 0000000..20a36d1
--- /dev/null
+++ b/prex-0.9.0/usr/lib/prex/syscalls/vm_map.S
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/systrap.h>
+#include "syscall.h"
+
+SYSCALL4(vm_map)
diff --git a/prex-0.9.0/usr/sample/Makefile b/prex-0.9.0/usr/sample/Makefile
new file mode 100755
index 0000000..95ac6b7
--- /dev/null
+++ b/prex-0.9.0/usr/sample/Makefile
@@ -0,0 +1,6 @@
+include $(SRCDIR)/mk/own.mk
+
+SUBDIR:=	alarm balls cpumon bench hello ipc mutex sem task thread \
+		tetris
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/usr/sample/alarm/Makefile b/prex-0.9.0/usr/sample/alarm/Makefile
new file mode 100755
index 0000000..15f040a
--- /dev/null
+++ b/prex-0.9.0/usr/sample/alarm/Makefile
@@ -0,0 +1,3 @@
+TASK=	alarm.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/alarm/alarm.c b/prex-0.9.0/usr/sample/alarm/alarm.c
new file mode 100755
index 0000000..a324d10
--- /dev/null
+++ b/prex-0.9.0/usr/sample/alarm/alarm.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * alarm.c - sample alarm program.
+ */
+
+/*
+ * Expected output:
+ *
+ * Alarm sample program
+ * Start alarm timer
+ * Ring! count=1 time=1000 msec
+ * Ring! count=2 time=1200 msec
+ * Ring! count=3 time=1600 msec
+ * Ring! count=4 time=2200 msec
+ * Ring! count=5 time=3000 msec
+ * Ring! count=6 time=4000 msec
+ * Ring! count=7 time=5200 msec
+ * Ring! count=8 time=6600 msec
+ * Ring! count=9 time=8200 msec
+ * Ring! count=10 time=10000 msec
+ * End...
+ *
+ */
+
+#include <sys/prex.h>
+#include <sys/signal.h>
+#include <stdio.h>
+
+static int hz;
+static volatile u_long count;
+static u_long start_tick;
+
+/*
+ * Re-program alarm timer as count * 200msec.
+ */
+static void
+alarm_handler(int code)
+{
+	u_long tick;
+
+	if (code == SIGALRM) {
+		count++;
+		if (count > 10) {
+			printf("End...\n");
+			task_terminate(task_self());
+		}
+		timer_alarm(count * 200, 0);
+		sys_time(&tick);
+		printf("Ring! count=%ld time=%d msec\n", count,
+		       (u_int)((tick - start_tick) * 1000 / hz));
+	}
+	exception_return();
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct timerinfo info;
+	int code;
+
+	printf("Alarm sample program\n");
+
+	sys_info(INFO_TIMER, &info);
+	if (info.hz == 0)
+		panic("can not get timer tick rate");
+	hz = info.hz;
+
+	/*
+	 * Install alarm handler
+	 */
+	exception_setup(alarm_handler);
+	timer_sleep(2000, 0);
+
+	/*
+	 * Kick first alarm timer.
+	 */
+	printf("Start alarm timer\n");
+	count = 0;
+	sys_time(&start_tick);
+	timer_alarm(1000, 0);
+
+	/* Wait alarm */
+	while (count < 10) {
+		exception_wait(&code);
+	}
+	printf("Test completed...\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/balls/Makefile b/prex-0.9.0/usr/sample/balls/Makefile
new file mode 100755
index 0000000..3eb58d8
--- /dev/null
+++ b/prex-0.9.0/usr/sample/balls/Makefile
@@ -0,0 +1,3 @@
+TASK=	balls.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/balls/balls.c b/prex-0.9.0/usr/sample/balls/balls.c
new file mode 100755
index 0000000..9913663
--- /dev/null
+++ b/prex-0.9.0/usr/sample/balls/balls.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ball.c - move many balls within screen.
+ */
+
+#include <sys/prex.h>
+
+#include <termios.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NBALLS		30
+#define STACKLEN	512
+
+/* Screen size */
+static int max_x;
+static int max_y;
+
+static char stack[NBALLS][STACKLEN];
+
+static thread_t
+thread_run(void (*start)(void), char *stack)
+{
+	thread_t t;
+
+	if (thread_create(task_self(), &t) != 0)
+		return 0;
+	if (thread_load(t, start, stack) != 0)
+		return 0;
+	if (thread_resume(t) != 0)
+		return 0;
+	return t;
+}
+
+/*
+ * A thread to move one ball.
+ */
+static void
+move_ball(void)
+{
+	int x, y;
+	int delta_x, delta_y;
+	int old_x, old_y;
+	u_long wait_msec;
+
+	/* Get random value for moving speed. */
+	old_x = old_y = 0;
+	x = random() % max_x;
+	y = random() % max_y;
+	delta_x = (random() % 10) + 1;
+	delta_y = (random() % 10) + 1;
+	wait_msec = (u_long)((random() % 20) + 1);
+
+	for (;;) {
+		/* Erase ball at old position */
+		printf("\33[%d;%dH ", old_y / 10, old_x / 10);
+
+		/* Print ball at new position */
+		printf("\33[%d;%dH*", y / 10, x / 10);
+
+		/* Wait msec */
+		timer_sleep(wait_msec, 0);
+
+		/* Update position */
+		old_x = x;
+		old_y = y;
+		x += delta_x;
+		y += delta_y;
+		if (x < 10 || x >= max_x)
+			delta_x = -delta_x;
+		if (y < 10 || y >= max_y)
+			delta_y = -delta_y;
+	}
+	/* NOTREACHED */
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct winsize ws;
+	int rows, cols, i;
+	device_t cons;
+
+	/* Get screen size */
+	device_open("tty", 0, &cons);
+	if (device_ioctl(cons, TIOCGWINSZ, &ws) == 0) {
+		rows = (int)ws.ws_row;
+		cols = (int)ws.ws_col;
+	} else {
+		/* Use default screen setting */
+		rows = 25;
+		cols = 80;
+	}
+	device_close(cons);
+
+	max_x = (cols - 1) * 10;
+	max_y = (rows - 2) * 10;
+
+	/* Clear screen */
+	printf("\33[2J");
+
+	/* Create threads and run them. */
+	for (i = 0; i < NBALLS; i++) {
+		if (thread_run(move_ball, stack[i]+STACKLEN) == 0)
+			panic("failed to create thread");
+	}
+
+	/* Don't return */
+	for (;;)
+		thread_yield();
+
+	/* NOTREACHED */
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/bench/Makefile b/prex-0.9.0/usr/sample/bench/Makefile
new file mode 100755
index 0000000..3bbd789
--- /dev/null
+++ b/prex-0.9.0/usr/sample/bench/Makefile
@@ -0,0 +1,3 @@
+TASK= bench.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/bench/bench.c b/prex-0.9.0/usr/sample/bench/bench.c
new file mode 100755
index 0000000..2224175
--- /dev/null
+++ b/prex-0.9.0/usr/sample/bench/bench.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * bench.c - benchmark program for running many threads
+ */
+
+/*
+ * Note: The system must have enough memory to run this program.
+ * At least, 512M bytes of RAM is required to create 100000 threads
+ * with x86-pc.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+/*
+ * Number of threads
+ */
+#define NR_THREADS 10000
+
+static thread_t *thread;
+
+void
+null_thread(void)
+{
+	for (;;) ;
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct timerinfo info;
+	task_t task;
+	char stack[16];
+	u_long start, end;
+	int i, pri, error;
+
+	printf("Benchmark to create/terminate %d threads\n", NR_THREADS);
+
+	sys_info(INFO_TIMER, &info);
+	if (info.hz == 0)
+		panic("can not get timer tick rate");
+
+	thread_getpri(thread_self(), &pri);
+	thread_setpri(thread_self(), pri - 1);
+
+	task = task_self();
+	error = vm_allocate(task, (void **)&thread,
+			    sizeof(thread_t) * NR_THREADS, 1);
+	if (error)
+		panic("vm_allocate is failed");
+
+	sys_time(&start);
+
+	/*
+	 * Create threads
+	 */
+	for (i = 0; i < NR_THREADS; i++) {
+		if (thread_create(task, &thread[i]) != 0)
+			panic("thread_create is failed");
+
+		if (thread_load(thread[i], null_thread, &stack) != 0)
+			panic("thread_load is failed");
+
+		if (thread_resume(thread[i]) != 0)
+			panic("thread_resume is failed");
+	}
+
+	/*
+	 * Teminate threads
+	 */
+	for (i = 0; i < NR_THREADS; i++)
+		thread_terminate(thread[i]);
+
+	sys_time(&end);
+
+	vm_free(task, thread);
+
+	printf("Complete. The score is %d msec (%d ticks).\n",
+	       (int)((end - start) * 1000 / info.hz),
+	       (int)(end - start));
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/cpumon/Makefile b/prex-0.9.0/usr/sample/cpumon/Makefile
new file mode 100755
index 0000000..f830a79
--- /dev/null
+++ b/prex-0.9.0/usr/sample/cpumon/Makefile
@@ -0,0 +1,3 @@
+TASK=	cpumon.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/cpumon/cpumon.c b/prex-0.9.0/usr/sample/cpumon/cpumon.c
new file mode 100755
index 0000000..6100e8c
--- /dev/null
+++ b/prex-0.9.0/usr/sample/cpumon/cpumon.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpumon.c - CPU voltage monitoring program
+ */
+
+#include <sys/prex.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+
+static struct cpufreqinfo cf_info;
+
+int
+main(int argc, char *argv[])
+{
+	device_t dev;
+	int last_mhz = 0;
+	int i, j;
+	static char bar[21];
+
+	/* Boost current prioriy */
+	thread_setpri(thread_self(), 50);
+
+	if (device_open("cpufreq", 0, &dev))
+		panic("open error: cpufreq");
+
+	/* Clear screen */
+	printf("\33[2J");
+
+	printf("CPU voltage monitor\n");
+	device_ioctl(dev, CFIOC_GET_INFO, &cf_info);
+	if (cf_info.freq == 0 || cf_info.volts == 0)
+		panic("Invalid cpu power/speed");
+
+	/*
+	 * Setup periodic timer for 10msec period
+	 */
+	timer_periodic(thread_self(), 100, 10);
+	for (;;) {
+		/*
+		 * Wait next period
+		 */
+		timer_waitperiod();
+		device_ioctl(dev, CFIOC_GET_INFO, &cf_info);
+		if (cf_info.freq != last_mhz) {
+			printf("\33[s"); /* save cursor */
+
+			/*
+			 * Display speed
+			 */
+			printf("\nSpeed: %4dMHz  0|", cf_info.freq);
+			j = cf_info.freq * 100 / cf_info.maxfreq;
+			for (i = 0; i < 20; i++)
+				bar[i] = (i <= j / 5) ? '*' : '-';
+			bar[i] = '\0';
+			printf("%s|100", bar);
+
+			/*
+			 * Display power
+			 */
+			printf("\nPower: %4dmV   0|", cf_info.volts);
+			j = cf_info.volts * 100 / cf_info.maxvolts;
+			for (i = 0; i < 20; i++)
+				bar[i] = (i <= j / 5) ? '*' : '-';
+			bar[i] = '\0';
+			printf("%s|100", bar);
+
+			printf("\33[u"); /* restore cursor */
+			last_mhz = cf_info.freq;
+		}
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/hello/Makefile b/prex-0.9.0/usr/sample/hello/Makefile
new file mode 100755
index 0000000..df3adbd
--- /dev/null
+++ b/prex-0.9.0/usr/sample/hello/Makefile
@@ -0,0 +1,6 @@
+PROG=	hello
+
+#DISASM= 	hello.lst
+#MAP= 		hello.map
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sample/hello/hello.c b/prex-0.9.0/usr/sample/hello/hello.c
new file mode 100755
index 0000000..97dbfd5
--- /dev/null
+++ b/prex-0.9.0/usr/sample/hello/hello.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <sys/prex.h>
+
+int
+main(int argc, char *argv[])
+{
+	printf("Hello, world!\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/ipc/Makefile b/prex-0.9.0/usr/sample/ipc/Makefile
new file mode 100755
index 0000000..23c58a6
--- /dev/null
+++ b/prex-0.9.0/usr/sample/ipc/Makefile
@@ -0,0 +1,3 @@
+TASK=	ipc.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/ipc/ipc.c b/prex-0.9.0/usr/sample/ipc/ipc.c
new file mode 100755
index 0000000..0a35377
--- /dev/null
+++ b/prex-0.9.0/usr/sample/ipc/ipc.c
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ipc.c - A sample program for IPC message transmission.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+#include <stdio.h>
+#include <string.h>
+
+/*
+ * Message structure
+ */
+struct chat_msg {
+	struct msg_header hdr;	/* Message header */
+	char	str[128];	/* String */
+};
+
+
+static char stack[1024];
+
+/*
+ * Start client task/thread
+ */
+static task_t
+start_client(void (*func)(void), char *stack)
+{
+	task_t task;
+	thread_t t;
+
+#ifdef CONFIG_MMU
+	if (task_create(task_self(), VM_COPY, &task) != 0)
+		return 0;
+#else
+	task = task_self();
+#endif
+	if (thread_create(task, &t) != 0)
+		return 0;
+
+	if (thread_load(t, func, stack) != 0)
+		return 0;
+
+	if (thread_resume(t) != 0)
+		return 0;
+
+	return task;
+}
+
+/*
+ * Send message to server
+ */
+void
+send_message(object_t obj, const char *str)
+{
+	struct chat_msg msg;
+
+	timer_sleep(2000, 0);
+	strcpy(msg.str, str);
+	msg_send(obj, &msg, sizeof(msg));
+	printf("client: Received \"%s\"\n", msg.str);
+}
+
+
+/*
+ * Client task
+ */
+static void
+client_task(void)
+{
+	object_t obj;
+	int error;
+
+	printf("Client is started\n");
+
+	/*
+	 * Find objects.
+	 */
+	if ((error = object_lookup("test", &obj)) != 0)
+		panic("can not find object");
+
+	/*
+	 * Send message per 2 second.
+	 */
+	send_message(obj, "Hello!");
+	send_message(obj, "This is a client task.");
+	send_message(obj, "Who are you?");
+	send_message(obj, "How are you?");
+	send_message(obj, "....");
+	send_message(obj, "Bye!");
+	send_message(obj, "Exit");
+
+#ifdef CONFIG_MMU
+	printf("Exit client task...\n");
+	task_terminate(task_self());
+#endif
+}
+
+int
+main(int argc, char *argv[])
+{
+	object_t obj = 0;
+	struct chat_msg msg;
+	int error, exit;
+
+	printf("IPC sample program\n");
+
+	/*
+	 * Boost priority of this thread
+	 */
+	thread_setpri(thread_self(), 90);
+
+	/*
+	 * Create object
+	 */
+	if ((error = object_create("test", &obj)) != 0)
+		panic("fail to create object");
+
+	/*
+	 * Start client task.
+	 */
+	if (start_client(client_task, stack+1024) == 0)
+		panic("fail to create task");
+
+	/*
+	 * Message loop
+	 */
+	exit = 0;
+	while (exit == 0) {
+		/*
+		 * Wait for an incoming request.
+		 */
+		error = msg_receive(obj, &msg, sizeof(msg));
+		if (error)
+			continue;
+		/*
+		 * Process request.
+		 */
+		printf("server: Received \"%s\"\n", msg.str);
+		if (!strcmp(msg.str, "Exit"))
+			exit = 1;
+
+		if (!strcmp(msg.str, "Hello!"))
+			strcpy(msg.str, "Hi.");
+		else if (!strcmp(msg.str, "Bye!"))
+			strcpy(msg.str, "Bye.");
+		else
+			strcpy(msg.str, "OK.");
+
+		/*
+		 * Reply to the client.
+		 */
+		msg_reply(obj, &msg, sizeof(msg));
+	}
+	timer_sleep(1000, 0);
+	printf("End...\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/mutex/Makefile b/prex-0.9.0/usr/sample/mutex/Makefile
new file mode 100755
index 0000000..40e75a6
--- /dev/null
+++ b/prex-0.9.0/usr/sample/mutex/Makefile
@@ -0,0 +1,3 @@
+TASK=	mutex.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/mutex/mutex.c b/prex-0.9.0/usr/sample/mutex/mutex.c
new file mode 100755
index 0000000..35846c5
--- /dev/null
+++ b/prex-0.9.0/usr/sample/mutex/mutex.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mutex.c - sample program for mutex with priority inheritance.
+ */
+
+/*
+ * Senario:
+ * This sample shows how the mutex priority is changed when three
+ * different threads lock two mutexes at same time.
+ *
+ * The priority of each thread are as follows.
+ *    Thread1 - priority 100 (highest)
+ *    Thread2 - priority 101
+ *    Thread3 - priority 102
+ *
+ * Thread priority and state are changed as follows.
+ *
+ *    Action                    Thread 1  Thread 2  Thread 3  Mutex A  Mutex B
+ *    ------------------------  --------  --------  --------  -------  -------
+ * 1) Thread 3 locks mutex A    susp/100  susp/101  run /102  owner=3
+ * 2) Thread 2 locks mutex B    susp/100  run /101  run /102  owner=3  owner=2
+ * 3) Thread 2 locks mutex A    susp/100  wait/101  run /101* owner=3  owner=2
+ * 4) Thread 1 locks mutex B    wait/100  wait/100* run /100* owner=3  owner=2
+ * 5) Thread 3 unlocks mutex A  wait/100  run /100  run /102* owner=2* owner=2
+ * 6) Thread 2 unlocks mutex B  run /100* run /100  run /102  owner=2  owner=1*
+ * 7) Thread 2 unlocks mutex A  run /100  run /100  run /102           owner=1
+ * 8) Thread 1 unlocks mutex B  wait/100  run /101  run /102
+ *
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+static char stack[3][1024];
+static thread_t th_1, th_2, th_3;
+static mutex_t mtx_A, mtx_B;
+
+static void
+dump_pri(void)
+{
+	int pri;
+
+	if (thread_getpri(th_1, &pri) == 0)
+		printf("th_1: pri=%d\n", pri);
+
+	if (thread_getpri(th_2, &pri) == 0)
+		printf("th_2: pri=%d\n", pri);
+
+	if (thread_getpri(th_3, &pri) == 0)
+		printf("th_3: pri=%d\n", pri);
+}
+
+thread_t
+thread_run(void (*start)(void), void *stack)
+{
+	thread_t t;
+
+	if (thread_create(task_self(), &t) != 0)
+		panic("thread_create is failed");
+
+	if (thread_load(t, start, stack) != 0)
+		panic("thread_load is failed");
+
+	return t;
+}
+
+/*
+ * Thread 1 - Priority = 100
+ */
+static void
+thread_1(void)
+{
+	printf("thread_1: starting\n");
+
+	/*
+	 * 4) Lock mutex B
+	 *
+	 * Priority inheritance:
+	 *    Thread 2... Pri 101 -> 100
+	 *    Thread 3... Pri 101 -> 100
+	 */
+	printf("thread_1: 4) lock B\n");
+	mutex_lock(&mtx_B);
+
+	printf("thread_1: running\n");
+	dump_pri();
+
+	/*
+	 * 8) Unlock mutex B
+	 */
+	printf("thread_1: 7) unlock B\n");
+	mutex_unlock(&mtx_B);
+
+	dump_pri();
+	printf("thread_1: exit\n");
+	thread_terminate(th_1);
+}
+
+/*
+ * Thread 2 - Priority = 101
+ */
+static void
+thread_2(void)
+{
+	printf("thread_2: starting\n");
+
+	/*
+	 * 2) Lock mutex B
+	 */
+	printf("thread_2: 2) lock B\n");
+	mutex_lock(&mtx_B);
+	dump_pri();
+
+	/*
+	 * 3) Lock mutex A (Switch to thread 3)
+	 *
+	 * Priority inheritance:
+	 *    Thread 3... Pri 102 -> 101
+	 */
+	printf("thread_2: 3) lock A\n");
+	mutex_lock(&mtx_A);
+
+	printf("thread_2: running\n");
+	dump_pri();
+
+	/*
+	 * 6) Unlock mutex B
+	 */
+	printf("thread_2: 6) unlock B\n");
+	mutex_unlock(&mtx_B);
+
+	dump_pri();
+
+	/*
+	 * 7) Unlock mutex A
+	 */
+	printf("thread_2: 8) unlock A\n");
+	mutex_unlock(&mtx_A);
+
+	printf("thread_2: exit\n");
+	thread_terminate(th_2);
+}
+
+
+/*
+ * Thread 3 - Priority = 102
+ */
+static void
+thread_3(void)
+{
+	printf("thread_3: start\n");
+
+	/*
+	 * 1) Lock mutex A
+	 */
+	printf("thread_3: 1) lock A\n");
+	mutex_lock(&mtx_A);
+	dump_pri();
+
+	/*
+	 * Start thread 2
+	 */
+	thread_resume(th_2);
+
+	/*
+	 * Check priority
+	 */
+	printf("thread_3: running-1\n");
+	dump_pri();
+
+	/*
+	 * Start thread 1
+	 */
+	thread_resume(th_1);
+	printf("thread_3: running-2\n");
+	dump_pri();
+
+	/*
+	 * 5) Unlock mutex A
+	 */
+	printf("thread_3: 5) unlock A\n");
+	mutex_unlock(&mtx_A);
+
+	dump_pri();
+	printf("thread_3: exit\n");
+	thread_terminate(th_3);
+}
+
+int
+main(int argc, char *argv[])
+{
+	printf("Mutex sample program\n");
+
+	/*
+	 * Boost priority of this thread
+	 */
+	thread_setpri(thread_self(), 90);
+
+	/*
+	 * Initialize mutexes.
+	 */
+	mutex_init(&mtx_A);
+	mutex_init(&mtx_B);
+
+	/*
+	 * Create new threads
+	 */
+	th_1 = thread_run(thread_1, stack[0]+1024);
+	thread_setpri(th_1, 100);
+
+	th_2 = thread_run(thread_2, stack[1]+1024);
+	thread_setpri(th_2, 101);
+
+	th_3 = thread_run(thread_3, stack[2]+1024);
+	thread_setpri(th_3, 102);
+
+	dump_pri();
+
+	/*
+	 * Start lowest priority thread
+	 */
+	thread_resume(th_3);
+
+	/*
+	 * Wait...
+	 */
+	thread_suspend(thread_self());
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/sem/Makefile b/prex-0.9.0/usr/sample/sem/Makefile
new file mode 100755
index 0000000..386064c
--- /dev/null
+++ b/prex-0.9.0/usr/sample/sem/Makefile
@@ -0,0 +1,3 @@
+TASK=	sem.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/sem/sem.c b/prex-0.9.0/usr/sample/sem/sem.c
new file mode 100755
index 0000000..4df4d22
--- /dev/null
+++ b/prex-0.9.0/usr/sample/sem/sem.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * sem.c - sample program for semaphore.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+static sem_t sem;
+
+void
+thread_run(void (*start)(void), void *stack)
+{
+	thread_t t;
+
+	if (thread_create(task_self(), &t) != 0)
+		panic("thread_create is failed");
+
+	if (thread_load(t, start, stack) != 0)
+		panic("thread_load is failed");
+
+	if (thread_resume(t) != 0)
+		panic("thread_resume failed");
+
+	return;
+}
+
+/*
+ * The main routine create 10 copy of this thread. But, since the
+ * initial semaphore value is 3, only 3 threads can run at same time.
+ */
+static void
+new_thread(void)
+{
+	thread_t t;
+
+	t = thread_self();
+	printf("Start thread=%x\n", (u_int)t);
+	thread_yield();
+
+	/*
+	 * Acquire semaphore
+	 */
+	sem_wait(&sem, 0);
+
+	/*
+	 * Sleep 2000 ms
+	 */
+	printf("Running thread=%x\n", (u_int)t);
+	timer_sleep(2000, 0);
+
+	/*
+	 * Release semaphore
+	 */
+	sem_post(&sem);	
+
+	printf("End thread=%x\n", (u_int)t);
+	thread_terminate(t);
+}
+
+int
+main(int argc, char *argv[])
+{
+	static char stack[10][1024];
+	int i;
+
+	printf("Semaphore sample program\n");
+
+	/*
+	 * Initialize semaphore with initial count 3
+	 */
+	sem_init(&sem, 3);
+
+	/*
+	 * Boost the priority of this thread
+	 */
+	thread_setpri(thread_self(), 100);
+
+	/*
+	 * Create 10 threads
+	 */
+	for (i = 0; i < 10; i++)
+		thread_run(new_thread, stack[i]+1024);
+
+	/*
+	 * Wait...
+	 */
+	thread_suspend(thread_self());
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/task/Makefile b/prex-0.9.0/usr/sample/task/Makefile
new file mode 100755
index 0000000..a18c2c6
--- /dev/null
+++ b/prex-0.9.0/usr/sample/task/Makefile
@@ -0,0 +1,3 @@
+TASK=	task.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/task/task.c b/prex-0.9.0/usr/sample/task/task.c
new file mode 100755
index 0000000..5800dd2
--- /dev/null
+++ b/prex-0.9.0/usr/sample/task/task.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * task.c - a sample program to run tasks.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NR_TASKS 10
+
+/*
+ * Create new task
+ */
+static task_t
+task_run(void (*func)(void))
+{
+	char *stack;
+	task_t task;
+	thread_t t;
+
+	stack = malloc(1024);
+	if (task_create(task_self(), VM_SHARE, &task) != 0)
+		return 0;
+
+	if (thread_create(task, &t) != 0)
+		return 0;
+
+	if (thread_load(t, func, stack + 1024) != 0)
+		return 0;
+
+	if (thread_resume(t) != 0)
+		return 0;
+
+	return task;
+}
+
+/*
+ * Function to be called in new task.
+ */
+static void
+hey_yo(void)
+{
+	task_t self;
+
+	/*
+	 * Display string
+	 */
+	self = task_self();
+	printf("Task %x: Hey, Yo!\n", (u_int)self);
+
+	/*
+	 * Wait 5 sec
+	 */
+	timer_sleep(5000, 0);
+
+	/*
+	 * Terminate current task.
+	 */
+	printf("Task %x: Bye!\n", (u_int)self);
+	task_terminate(task_self());
+}
+
+int
+main(int argc, char *argv[])
+{
+	int i;
+
+	printf("Task sample program\n");
+
+	/*  Create new tasks */
+	for (i = 0; i < NR_TASKS; i++) {
+		if (task_run(hey_yo) == 0)
+			panic("failed to create task");
+	}
+
+	/* Wait here... */
+	task_suspend(task_self());
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sample/tetris/Makefile b/prex-0.9.0/usr/sample/tetris/Makefile
new file mode 100755
index 0000000..67ed253
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/Makefile
@@ -0,0 +1,8 @@
+TARGET=	tetris
+SRCS=	shapes.c tetris.c input.c screen.c
+
+#MAP=		tetris.map
+#DISASM=		tetris.lst
+#SYMBOL=		tetris.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sample/tetris/input.c b/prex-0.9.0/usr/sample/tetris/input.c
new file mode 100755
index 0000000..329f2e8
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/input.c
@@ -0,0 +1,176 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)input.c	8.1 (Berkeley) 5/31/93
+ */
+
+/* Modified for Prex by Kohsuke Ohtani. */
+
+/*
+ * Tetris input.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/termios.h>
+#include <sys/prex.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "input.h"
+#include "tetris.h"
+
+/* return true if the given timeval is positive */
+#define	TV_POS(tv) \
+	((tv)->tv_sec > 0 || ((tv)->tv_sec == 0 && (tv)->tv_usec > 0))
+
+/* subtract timeval `sub' from `res' */
+#define	TV_SUB(res, sub) \
+	(res)->tv_sec -= (sub)->tv_sec; \
+	(res)->tv_usec -= (sub)->tv_usec; \
+	if ((res)->tv_usec < 0) { \
+		(res)->tv_usec += 1000000; \
+		(res)->tv_sec--; \
+	}
+
+/*
+ * Do a `read wait': select for reading from stdin, with timeout *tvp.
+ * On return, modify *tvp to reflect the amount of time spent waiting.
+ * It will be positive only if input appeared before the time ran out;
+ * otherwise it will be zero or perhaps negative.
+ *
+ * If tvp is nil, wait forever, but return if select is interrupted.
+ *
+ * Return 0 => no input, 1 => can read() from stdin
+ */
+int
+rwait(struct timeval *tvp)
+{
+	int i, ninq, timeout;
+	struct timeval starttv, endtv;
+#define	NILTZ ((struct timezone *)0)
+
+	if (tvp) {
+		(void) gettimeofday(&starttv, NILTZ);
+		endtv = *tvp;
+		timeout = tvp->tv_usec / 1000;
+	} else
+		timeout = 1000;
+
+	/*
+	 * We don't have select() or poll() as for now.
+	 * This is replaced by polling TTY input queue via ioctl().
+	 */
+	for (i = 0; i < timeout; i++) {
+		ioctl(1, TIOCINQ, &ninq);
+		if (ninq > 0)
+			break;
+		timer_sleep(1, 0);	/* wait 1ms */
+	}
+	if (i >= timeout) {	/* timed out */
+		if (tvp == NULL)
+			return (-1);
+		else {
+			tvp->tv_sec = 0;
+			tvp->tv_usec = 0;
+			return (0);
+		}
+	}
+	if (tvp) {
+		/* since there is input, we may not have timed out */
+		(void) gettimeofday(&endtv, NILTZ);
+		TV_SUB(&endtv, &starttv);
+		TV_SUB(tvp, &endtv);	/* adjust *tvp by elapsed time */
+	}
+	return (1);
+}
+
+/*
+ * `sleep' for the current turn time (using select).
+ * Eat any input that might be available.
+ */
+void
+tsleep(void)
+{
+	struct timeval tv;
+	char c;
+
+	tv.tv_sec = 0;
+	tv.tv_usec = fallrate;
+	while (TV_POS(&tv))
+		if (rwait(&tv) && read(0, &c, 1) != 1)
+			break;
+}
+
+/*
+ * Eat up any input (used at end of game).
+ */
+void
+eat_input(void)
+{
+	struct timeval tv;
+	char c;
+
+	do {
+		tv.tv_sec = tv.tv_usec = 0;
+	} while (rwait(&tv) && read(0, &c, 1) == 1);
+}
+
+/*
+ * getchar with timeout.
+ */
+int
+tgetchar(void)
+{
+	static struct timeval timeleft;
+	char c;
+
+	/*
+	 * Reset timeleft to fallrate whenever it is not positive.
+	 * In any case, wait to see if there is any input.  If so,
+	 * take it, and update timeleft so that the next call to
+	 * tgetchar() will not wait as long.  If there is no input,
+	 * make timeleft zero or negative, and return -1.
+	 *
+	 * Most of the hard work is done by rwait().
+	 */
+	if (!TV_POS(&timeleft)) {
+		faster();	/* go faster */
+		timeleft.tv_sec = 0;
+		timeleft.tv_usec = fallrate;
+	}
+	if (!rwait(&timeleft))
+		return (-1);
+	if (read(0, &c, 1) != 1)
+		stop("end of file, help");
+	return ((int)(unsigned char)c);
+}
diff --git a/prex-0.9.0/usr/sample/tetris/input.h b/prex-0.9.0/usr/sample/tetris/input.h
new file mode 100755
index 0000000..e82250d
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/input.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)input.h	8.1 (Berkeley) 5/31/93
+ */
+
+void	eat_input(void);
+int	rwait(struct timeval *);
+int	tgetchar(void);
+void	tsleep(void);
diff --git a/prex-0.9.0/usr/sample/tetris/screen.c b/prex-0.9.0/usr/sample/tetris/screen.c
new file mode 100755
index 0000000..bdd5ef7
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/screen.c
@@ -0,0 +1,226 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)screen.c	8.1 (Berkeley) 5/31/93
+ */
+
+/* Modified for Prex by Kohsuke Ohtani. */
+
+/*
+ * Tetris screen control.
+ */
+
+#include <sys/termios.h>
+#include <sys/ioctl.h>
+
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "screen.h"
+#include "tetris.h"
+
+static cell curscreen[B_SIZE];	/* 1 => standout (or otherwise marked) */
+static int curscore;
+static int isset;		/* true => terminal is in game mode */
+static struct termios oldtt;
+
+/*
+ * putstr() is for unpadded strings (either as in termcap(5) or
+ * simply literal strings); putpad() is for padded strings with
+ * count=1.  (See screen.h for putpad().)
+ */
+#define	putstr(s)	printf("%s", s)
+#define	moveto(r, c)	printf("\33[%d;%dH", r, c)
+
+/*
+ * Set up from termcap.
+ */
+void
+scr_init()
+{
+}
+
+/*
+ * Set up screen mode.
+ */
+void
+scr_set(void)
+{
+	struct winsize ws;
+	struct termios newtt;
+
+	Rows = 0, Cols = 0;
+	if (ioctl(0, TIOCGWINSZ, &ws) == 0) {
+		Rows = (int)ws.ws_row;
+		Cols = (int)ws.ws_col;
+	}
+	if (Rows == 0)
+		Rows = 25;
+	if (Cols == 0)
+		Cols = 80;
+
+	if (tcgetattr(0, &oldtt) < 0)
+		stop("tcgetattr() fails");
+	newtt = oldtt;
+	newtt.c_lflag &= ~(ICANON|ECHO);
+	newtt.c_oflag &= ~OXTABS;
+	if (tcsetattr(0, TCSADRAIN, &newtt) < 0)
+		stop("tcsetattr() fails");
+
+	isset = 1;
+	scr_clear();
+}
+
+/*
+ * End screen mode.
+ */
+void
+scr_end(void)
+{
+
+	moveto(Rows - 1, 0);
+
+	/* exit screen mode */
+	(void) fflush(stdout);
+	(void) tcsetattr(0, TCSADRAIN, &oldtt);
+	isset = 0;
+}
+
+void
+stop(char *why)
+{
+
+	if (isset)
+		scr_end();
+	(void) fprintf(stderr, "aborting: %s\n", why);
+	exit(1);
+}
+
+/*
+ * Clear the screen, forgetting the current contents in the process.
+ */
+void
+scr_clear(void)
+{
+
+	printf("\33[2J");
+	curscore = -1;
+	bzero((char *)curscreen, sizeof(curscreen));
+}
+
+#if !__GNUC__
+typedef int regcell;	/* pcc is bad at `register char', etc */
+#else
+typedef cell regcell;
+#endif
+
+/*
+ * Update the screen.
+ */
+void
+scr_update(void)
+{
+	cell *bp, *sp;
+	regcell so, cur_so = 0;
+	int i, ccol, j;
+
+	/* always leave cursor after last displayed point */
+	curscreen[D_LAST * B_COLS - 1] = -1;
+
+	if (score != curscore) {
+		moveto(0, 0);
+		printf("%d", score);
+		curscore = score;
+	}
+
+	bp = &board[D_FIRST * B_COLS];
+	sp = &curscreen[D_FIRST * B_COLS];
+	for (j = D_FIRST; j < D_LAST; j++) {
+		ccol = -1;
+		for (i = 0; i < B_COLS; bp++, sp++, i++) {
+			if (*sp == (so = *bp))
+				continue;
+			*sp = so;
+			if (i != ccol) {
+				if (cur_so) {
+					cur_so = 0;
+				}
+				moveto(RTOD(j), CTOD(i));
+			}
+			if (so != cur_so) {
+				cur_so = so;
+			}
+			putstr(so ? "XX" : "  ");
+
+			ccol = i + 1;
+			/*
+			 * Look ahead a bit, to avoid extra motion if
+			 * we will be redrawing the cell after the next.
+			 * Motion probably takes four or more characters,
+			 * so we save even if we rewrite two cells
+			 * `unnecessarily'.  Skip it all, though, if
+			 * the next cell is a different color.
+			 */
+#define	STOP (B_COLS - 3)
+			if (i > STOP || sp[1] != bp[1] || so != bp[1])
+				continue;
+			if (sp[2] != bp[2])
+				sp[1] = -1;
+			else if (i < STOP && so == bp[2] && sp[3] != bp[3]) {
+				sp[2] = -1;
+				sp[1] = -1;
+			}
+		}
+	}
+	(void) fflush(stdout);
+}
+
+/*
+ * Write a message (set!=0), or clear the same message (set==0).
+ * (We need its length in case we have to overwrite with blanks.)
+ */
+void
+scr_msg(char *s, int set)
+{
+
+	int l = (int)strlen(s);
+
+	moveto(Rows - 2, ((Cols - l) >> 1) - 1);
+	if (set)
+		putstr(s);
+	else
+		while (--l >= 0)
+			(void) putchar(' ');
+}
diff --git a/prex-0.9.0/usr/sample/tetris/screen.h b/prex-0.9.0/usr/sample/tetris/screen.h
new file mode 100755
index 0000000..1e7b975
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/screen.h
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)screen.h	8.1 (Berkeley) 5/31/93
+ */
+
+void	scr_clear(void);
+void	scr_end(void);
+void	scr_init(void);
+void	scr_msg(char *, int);
+void	scr_set(void);
+void	scr_update(void);
diff --git a/prex-0.9.0/usr/sample/tetris/shapes.c b/prex-0.9.0/usr/sample/tetris/shapes.c
new file mode 100755
index 0000000..64ce43c
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/shapes.c
@@ -0,0 +1,103 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)shapes.c	8.1 (Berkeley) 5/31/93
+ */
+
+/*
+ * Tetris shapes and related routines.
+ *
+ * Note that the first 7 are `well known'.
+ */
+
+#include <sys/cdefs.h>
+#include "tetris.h"
+
+#define	TL	-B_COLS-1	/* top left */
+#define	TC	-B_COLS		/* top center */
+#define	TR	-B_COLS+1	/* top right */
+#define	ML	-1		/* middle left */
+#define	MR	1		/* middle right */
+#define	BL	B_COLS-1	/* bottom left */
+#define	BC	B_COLS		/* bottom center */
+#define	BR	B_COLS+1	/* bottom right */
+
+const struct shape shapes[] = {
+	/* 0*/	{ 7,	{ TL, TC, MR, } },
+	/* 1*/	{ 8,	{ TC, TR, ML, } },
+	/* 2*/	{ 9,	{ ML, MR, BC, } },
+	/* 3*/	{ 3,	{ TL, TC, ML, } },
+	/* 4*/	{ 12,	{ ML, BL, MR, } },
+	/* 5*/	{ 15,	{ ML, BR, MR, } },
+	/* 6*/	{ 18,	{ ML, MR, 2   } },	/* sticks out */
+	/* 7*/	{ 0,	{ TC, ML, BL, } },
+	/* 8*/	{ 1,	{ TC, MR, BR, } },
+	/* 9*/	{ 10,	{ TC, MR, BC, } },
+	/*10*/	{ 11,	{ TC, ML, MR, } },
+	/*11*/	{ 2,	{ TC, ML, BC, } },
+	/*12*/	{ 13,	{ TC, BC, BR, } },
+	/*13*/	{ 14,	{ TR, ML, MR, } },
+	/*14*/	{ 4,	{ TL, TC, BC, } },
+	/*15*/	{ 16,	{ TR, TC, BC, } },
+	/*16*/	{ 17,	{ TL, MR, ML, } },
+	/*17*/	{ 5,	{ TC, BC, BL, } },
+	/*18*/	{ 6,	{ TC, BC, 2*B_COLS } }	/* sticks out */
+};
+
+/*
+ * Return true iff the given shape fits in the given position,
+ * taking the current board into account.
+ */
+int
+fits_in(const struct shape *shape, int pos)
+{
+	const int *o = shape->off;
+
+	if (board[pos] || board[pos + *o++] || board[pos + *o++] ||
+	    board[pos + *o])
+		return 0;
+	return 1;
+}
+
+/*
+ * Write the given shape into the current board, turning it on
+ * if `onoff' is 1, and off if `onoff' is 0.
+ */
+void
+place(const struct shape *shape, int pos, cell onoff)
+{
+	const int *o = shape->off;
+
+	board[pos] = onoff;
+	board[pos + *o++] = onoff;
+	board[pos + *o++] = onoff;
+	board[pos + *o] = onoff;
+}
diff --git a/prex-0.9.0/usr/sample/tetris/tetris.c b/prex-0.9.0/usr/sample/tetris/tetris.c
new file mode 100755
index 0000000..080fc84
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/tetris.c
@@ -0,0 +1,292 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)tetris.c	8.1 (Berkeley) 5/31/93
+ */
+
+/* Modified for Prex by Kohsuke Ohtani. */
+
+/*
+ * Tetris (or however it is spelled).
+ */
+
+#include <sys/time.h>
+#include <sys/param.h>
+#ifdef __gba__
+#include <sys/keycode.h>
+#endif
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "input.h"
+#include "screen.h"
+#include "tetris.h"
+
+#ifdef __gba__
+static char keys[6] = {K_LEFT, 'A', K_RGHT, K_DOWN, '\n', '\n'};
+#else
+static char *keys = "jkl pq";
+#endif
+
+cell	board[B_SIZE];		/* 1 => occupied, 0 => empty */
+int	Rows, Cols;		/* current screen size */
+int	score;			/* the obvious thing */
+char	key_msg[100];
+long	fallrate;		/* less than 1 million; smaller => faster */
+
+void onintr(int);
+void usage(void);
+
+/*
+ * Set up the initial board.  The bottom display row is completely set,
+ * along with another (hidden) row underneath that.  Also, the left and
+ * right edges are set.
+ */
+static void
+setup_board(void)
+{
+	int i;
+	cell *p;
+
+	p = board;
+	for (i = B_SIZE; i; i--)
+		*p++ = i <= (2 * B_COLS) || (i % B_COLS) < 2;
+}
+
+/*
+ * Elide any full active rows.
+ */
+static void
+elide(void)
+{
+	int i, j, base;
+	cell *p;
+
+	for (i = A_FIRST; i < A_LAST; i++) {
+		base = i * B_COLS + 1;
+		p = &board[base];
+		for (j = B_COLS - 2; *p++ != 0;) {
+			if (--j <= 0) {
+				/* this row is to be elided */
+				bzero(&board[base], B_COLS - 2);
+				scr_update();
+				tsleep();
+				while (--base != 0)
+					board[base + B_COLS] = board[base];
+				scr_update();
+				tsleep();
+				break;
+			}
+		}
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	int pos, c;
+	const struct shape *curshape;
+	int level = 2;
+#ifndef __gba__
+	char key_write[6][10];
+	int i;
+#endif
+	int ch;
+
+	while ((ch = getopt(argc, argv, "l")) != EOF)
+		switch(ch) {
+		case 'l':
+			level = atoi(optarg);
+			if (level < MINLEVEL || level > MAXLEVEL) {
+				(void)fprintf(stderr,
+				    "tetris: level must be from %d to %d",
+				    MINLEVEL, MAXLEVEL);
+				exit(1);
+			}
+			break;
+		case '?':
+		default:
+			usage();
+		}
+
+	argc -= optind;
+	argv += optind;
+
+	if (argc)
+		usage();
+
+	fallrate = 1000000 / level;
+
+#ifdef __gba__
+	/* No help line... */
+#else
+	for (i = 0; i <= 5; i++) {
+		if (keys[i] == ' ')
+			strcpy(key_write[i], "<space>");
+		else {
+			key_write[i][0] = keys[i];
+			key_write[i][1] = '\0';
+		}
+	}
+
+	sprintf(key_msg,
+"%s - left   %s - rotate   %s - right   %s - drop   %s - pause   %s - quit",
+		key_write[0], key_write[1], key_write[2], key_write[3],
+		key_write[4], key_write[5]);
+#endif
+
+	(void)signal(SIGINT, onintr);
+	scr_init();
+	setup_board();
+
+	srandom((unsigned long)getpid());
+	scr_set();
+
+	pos = A_FIRST*B_COLS + (B_COLS/2)-1;
+	curshape = randshape();
+
+	scr_msg(key_msg, 1);
+
+	for (;;) {
+		place(curshape, pos, 1);
+		scr_update();
+
+		place(curshape, pos, 0);
+		c = tgetchar();
+		if (c < 0) {
+			/*
+			 * Timeout.  Move down if possible.
+			 */
+			if (fits_in(curshape, pos + B_COLS)) {
+				pos += B_COLS;
+				continue;
+			}
+
+			/*
+			 * Put up the current shape `permanently',
+			 * bump score, and elide any full rows.
+			 */
+			place(curshape, pos, 1);
+			score++;
+			elide();
+
+			/*
+			 * Choose a new shape.  If it does not fit,
+			 * the game is over.
+			 */
+			curshape = randshape();
+			pos = A_FIRST*B_COLS + (B_COLS/2)-1;
+			if (!fits_in(curshape, pos))
+				break;
+			continue;
+		}
+
+		/*
+		 * Handle command keys.
+		 */
+		if (c == keys[5]) {
+			/* quit */
+			break;
+		}
+		if (c == keys[4]) {
+			static char msg[] =
+			    "paused - press RETURN to continue";
+
+			place(curshape, pos, 1);
+			do {
+				scr_update();
+				scr_msg(key_msg, 0);
+				scr_msg(msg, 1);
+				(void) fflush(stdout);
+			} while (rwait((struct timeval *)NULL) == -1);
+			scr_msg(msg, 0);
+			scr_msg(key_msg, 1);
+			place(curshape, pos, 0);
+			continue;
+		}
+		if (c == keys[0]) {
+			/* move left */
+			if (fits_in(curshape, pos - 1))
+				pos--;
+			continue;
+		}
+		if (c == keys[1]) {
+			/* turn */
+			const struct shape *new = &shapes[curshape->rot];
+
+			if (fits_in(new, pos))
+				curshape = new;
+			continue;
+		}
+		if (c == keys[2]) {
+			/* move right */
+			if (fits_in(curshape, pos + 1))
+				pos++;
+			continue;
+		}
+		if (c == keys[3]) {
+			/* move to bottom */
+			while (fits_in(curshape, pos + B_COLS)) {
+				pos += B_COLS;
+				score++;
+			}
+			continue;
+		}
+		if (c == '\f')
+			scr_clear();
+	}
+
+	scr_clear();
+	scr_end();
+
+	(void)printf("Your score:  %d point%s  x  level %d  =  %d\n",
+	    score, score == 1 ? "" : "s", level, score * level);
+	exit(0);
+}
+
+void
+onintr(int signo)
+{
+	scr_clear();
+	scr_end();
+	exit(0);
+}
+
+void
+usage()
+{
+	(void)fprintf(stderr, "usage: tetris [-l level]\n");
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/sample/tetris/tetris.h b/prex-0.9.0/usr/sample/tetris/tetris.h
new file mode 100755
index 0000000..280a610
--- /dev/null
+++ b/prex-0.9.0/usr/sample/tetris/tetris.h
@@ -0,0 +1,177 @@
+/*-
+ * Copyright (c) 1992, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek and Darren F. Provine.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)tetris.h	8.1 (Berkeley) 5/31/93
+ */
+
+/*
+ * Definitions for Tetris.
+ */
+
+/*
+ * The display (`board') is composed of 23 rows of 12 columns of characters
+ * (numbered 0..22 and 0..11), stored in a single array for convenience.
+ * Columns 1 to 10 of rows 1 to 20 are the actual playing area, where
+ * shapes appear.  Columns 0 and 11 are always occupied, as are all
+ * columns of rows 21 and 22.  Rows 0 and 22 exist as boundary areas
+ * so that regions `outside' the visible area can be examined without
+ * worrying about addressing problems.
+ */
+
+#if defined(__gba__)
+	/* the board */
+#define	B_COLS	12
+#define	B_ROWS	22
+
+	/* the displayed area (rows) */
+#define	D_FIRST	1
+#define	D_LAST	21
+
+	/* the active area (rows) */
+#define	A_FIRST	1
+#define	A_LAST	20
+
+#else /* !__gba__ */
+
+	/* the board */
+#define	B_COLS	12
+#define	B_ROWS	23
+
+	/* the displayed area (rows) */
+#define	D_FIRST	1
+#define	D_LAST	22
+
+	/* the active area (rows) */
+#define	A_FIRST	1
+#define	A_LAST	21
+#endif
+
+
+
+#define	B_SIZE	(B_ROWS * B_COLS)
+
+typedef unsigned char cell;
+extern cell	board[B_SIZE];	/* 1 => occupied, 0 => empty */
+
+extern int	Rows, Cols;	/* current screen size */
+
+/*
+ * Translations from board coordinates to display coordinates.
+ * As with board coordinates, display coordiates are zero origin.
+ */
+#define	RTOD(x)	((x) - 1)
+#define	CTOD(x)	((x) * 2 + (((Cols - 2 * B_COLS) >> 1) - 1 + 3))
+
+/*
+ * A `shape' is the fundamental thing that makes up the game.  There
+ * are 7 basic shapes, each consisting of four `blots':
+ *
+ *	X.X	  X.X		X.X
+ *	  X.X	X.X	X.X.X	X.X	X.X.X	X.X.X	X.X.X.X
+ *			  X		X	    X
+ *
+ *	  0	  1	  2	  3	  4	  5	  6
+ *
+ * Except for 3 and 6, the center of each shape is one of the blots.
+ * This blot is designated (0,0).  The other three blots can then be
+ * described as offsets from the center.  Shape 3 is the same under
+ * rotation, so its center is effectively irrelevant; it has been chosen
+ * so that it `sticks out' upward and leftward.  Except for shape 6,
+ * all the blots are contained in a box going from (-1,-1) to (+1,+1);
+ * shape 6's center `wobbles' as it rotates, so that while it `sticks out'
+ * rightward, its rotation---a vertical line---`sticks out' downward.
+ * The containment box has to include the offset (2,0), making the overall
+ * containment box range from offset (-1,-1) to (+2,+1).  (This is why
+ * there is only one row above, but two rows below, the display area.)
+ *
+ * The game works by choosing one of these shapes at random and putting
+ * its center at the middle of the first display row (row 1, column 5).
+ * The shape is moved steadily downward until it collides with something:
+ * either  another shape, or the bottom of the board.  When the shape can
+ * no longer be moved downwards, it is merged into the current board.
+ * At this time, any completely filled rows are elided, and blots above
+ * these rows move down to make more room.  A new random shape is again
+ * introduced at the top of the board, and the whole process repeats.
+ * The game ends when the new shape will not fit at (1,5).
+ *
+ * While the shapes are falling, the user can rotate them counterclockwise
+ * 90 degrees (in addition to moving them left or right), provided that the
+ * rotation puts the blots in empty spaces.  The table of shapes is set up
+ * so that each shape contains the index of the new shape obtained by
+ * rotating the current shape.  Due to symmetry, each shape has exactly
+ * 1, 2, or 4 rotations total; the first 7 entries in the table represent
+ * the primary shapes, and the remaining 12 represent their various
+ * rotated forms.
+ */
+struct shape {
+	int	rot;	/* index of rotated version of this shape */
+	int	off[3];	/* offsets to other blots if center is at (0,0) */
+};
+
+extern const struct shape shapes[];
+#define	randshape() (&shapes[random() % 7])
+
+/*
+ * Shapes fall at a rate faster than once per second.
+ *
+ * The initial rate is determined by dividing 1 million microseconds
+ * by the game `level'.  (This is at most 1 million, or one second.)
+ * Each time the fall-rate is used, it is decreased a little bit,
+ * depending on its current value, via the `faster' macro below.
+ * The value eventually reaches a limit, and things stop going faster,
+ * but by then the game is utterly impossible.
+ */
+extern long	fallrate;	/* less than 1 million; smaller => faster */
+#define	faster() (fallrate -= fallrate / 3000)
+
+/*
+ * Game level must be between 1 and 9.  This controls the initial fall rate
+ * and affects scoring.
+ */
+#define	MINLEVEL	1
+#define	MAXLEVEL	9
+
+/*
+ * Scoring is as follows:
+ *
+ * When the shape comes to rest, and is integrated into the board,
+ * we score one point.  If the shape is high up (at a low-numbered row),
+ * and the user hits the space bar, the shape plummets all the way down,
+ * and we score a point for each row it falls (plus one more as soon as
+ * we find that it is at rest and integrate it---until then, it can
+ * still be moved or rotated).
+ */
+extern int	score;		/* the obvious thing */
+extern char	key_msg[100];
+
+int	fits_in(const struct shape *, int);
+void	place(const struct shape *, int, cell);
+void	stop(char *);
diff --git a/prex-0.9.0/usr/sample/thread/Makefile b/prex-0.9.0/usr/sample/thread/Makefile
new file mode 100755
index 0000000..6b1e552
--- /dev/null
+++ b/prex-0.9.0/usr/sample/thread/Makefile
@@ -0,0 +1,3 @@
+TASK=	thread.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/sample/thread/thread.c b/prex-0.9.0/usr/sample/thread/thread.c
new file mode 100755
index 0000000..3be3c77
--- /dev/null
+++ b/prex-0.9.0/usr/sample/thread/thread.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * thread.c - sample program to create three threads.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+#define VERBOSE_MODE
+
+#ifdef VERBOSE_MODE
+#define thr_printf(s) sys_log(s)
+#else
+#define thr_printf(s)
+#endif
+
+static thread_t main_th;
+static char stack[3][1024];
+
+/*
+ * Run specified routine as new thread.
+ */
+static int
+thread_run(void (*start)(void), void *stack)
+{
+	thread_t t;
+
+	if (thread_create(task_self(), &t) != 0)
+		return -1;
+
+	if (thread_load(t, start, stack) != 0)
+		return -1;
+
+	if (thread_setpri(t, 128) != 0)
+		return -1;
+
+	if (thread_resume(t) != 0)
+		return -1;
+	return 0;
+}
+
+/*
+ * Display 'AAAA...'
+ */
+static void
+thread_A(void)
+{
+	int i;
+
+	thr_printf("\nthread A is starting\n");
+
+	for (i = 0; i < 1024; i++) {
+		thr_printf("A");
+		if ((i & 0xff) == 0)
+			thread_yield();
+	}
+	thr_printf("\nthread A is terminated\n");
+	thread_terminate(thread_self());
+}
+
+/*
+ * Display 'BBBB...'
+ */
+static void
+thread_B(void)
+{
+	int i;
+
+	thr_printf("\nthread B is starting\n");
+
+	for (i = 0; i < 4096; i++) {
+		thr_printf("B");
+		if ((i & 0xff) == 0)
+			thread_yield();
+	}
+	thr_printf("\nthread B is terminated\n");
+	thread_terminate(thread_self());
+}
+
+/*
+ * Display 'CCCC...'
+ */
+static void
+thread_C(void)
+{
+	int i;
+
+	thr_printf("\nthread C is starting\n");
+
+	for (i = 0; i < 8192; i++) {
+		thr_printf("C");
+		if ((i & 0xff) == 0)
+			thread_yield();
+	}
+	thr_printf("\nthread C is terminated\n");
+	thread_terminate(thread_self());
+}
+
+int
+main(int argc, char *argv[])
+{
+	int error;
+
+	printf("Thread sample program\n");
+	main_th = thread_self();
+
+	timer_sleep(1000, 0);
+
+	/*
+	 * Raise this thread's priority.
+	 */
+	error = thread_setpri(main_th, 100);
+
+	/*
+	 * Run threads as normal priority thread.
+	 */
+	thread_run(thread_A, stack[0]+1024);
+	thread_run(thread_B, stack[1]+1024);
+	thread_run(thread_C, stack[2]+1024);
+
+	/*
+	 * Lower this thread's priority.
+	 */
+	error = thread_setpri(main_th, 254);
+	/*
+	 * Since other threads have higher priority than
+	 * this thread, the control will come here only when
+	 * all other threads are terminated.
+	 */
+	printf("test - OK!\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sbin/Makefile b/prex-0.9.0/usr/sbin/Makefile
new file mode 100755
index 0000000..3650dbd
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/Makefile
@@ -0,0 +1,5 @@
+include $(SRCDIR)/mk/own.mk
+
+SUBDIR=		init install pmctrl diskutil ktrace lock debug
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/usr/sbin/debug/Makefile b/prex-0.9.0/usr/sbin/debug/Makefile
new file mode 100755
index 0000000..a5033dc
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/debug/Makefile
@@ -0,0 +1,5 @@
+PROG=	debug
+
+#DISASM=	debug.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/debug/debug.c b/prex-0.9.0/usr/sbin/debug/debug.c
new file mode 100755
index 0000000..a7a972f
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/debug/debug.c
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * debug.c - send debug message to the specific object.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void
+usage(void)
+{
+
+	fprintf(stderr, "usage: debug [object]\n");
+	exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+	object_t obj;
+	struct msg m;
+
+	if (argc != 2)
+		usage();
+
+	if (object_lookup(argv[1], &obj) != 0) {
+		fprintf(stderr, "debug: can not find object %s\n", argv[1]);
+		exit(1);
+	}
+	m.hdr.code = STD_DEBUG;
+	msg_send(obj, &m, sizeof(m));
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/sbin/diskutil/Makefile b/prex-0.9.0/usr/sbin/diskutil/Makefile
new file mode 100755
index 0000000..b45def3
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/diskutil/Makefile
@@ -0,0 +1,7 @@
+PROG=		diskutil
+
+#DISASM= 	diskutil.lst
+#MAP=		diskutil.map
+#SYMBOL= 	diskutil.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/diskutil/diskutil.c b/prex-0.9.0/usr/sbin/diskutil/diskutil.c
new file mode 100755
index 0000000..53d8553
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/diskutil/diskutil.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * diskutil.c - disk management utility
+ *
+ * Required capabilities:
+ *      CAP_DISKADMIN
+ */
+
+#include <sys/prex.h>
+#include <sys/ioctl.h>
+#include <ipc/ipc.h>
+
+#include <sys/mount.h>
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+static void disk_list(int, char **);
+static void disk_info(int, char **);
+static void disk_mount(int, char **);
+static void disk_unmount(int, char **);
+static void disk_eject(int, char **);
+static void disk_rename(int, char **);
+static void disk_verify(int, char **);
+static void disk_partition(int, char **);
+static void disk_help(int, char **);
+static void disk_null(int, char **);
+
+struct cmdtab {
+	const char	*cmd;
+	void		(*func)(int, char **);
+	const char	*usage;
+};
+
+static const struct cmdtab cmdtab[] = {
+	{ "list"	,disk_list	," list      - List the partitions of a disk.\n" },
+	{ "info"	,disk_info	," info      - Display information on a disk or volume.\n" },
+	{ "mount"	,disk_mount	," mount     - Mount a single volume.\n" },
+	{ "unmount"	,disk_unmount	," unmount   - Unmount a single volume.\n" },
+	{ "eject"	,disk_eject	," eject     - Eject a disk.\n" },
+	{ "rename"	,disk_rename	," rename    - Rename a volume.\n" },
+	{ "verify"	,disk_verify	," verify    - Verify the structure of a volume.\n" },
+	{ "partition"	,disk_partition	," partition - Partitiona disk, removing all volume.\n" },
+	{ "-?"		,disk_help	," -?        - This help.\n" },
+	{ NULL		,disk_null	,NULL },
+};
+
+static void
+disk_null(int argc, char **argv)
+{
+}
+
+static void
+disk_help(int argc, char **argv)
+{
+	int i = 0;
+
+	fputs("usage: diskutil command\n", stderr);
+	fputs("commands:\n", stderr);
+	while (cmdtab[i].cmd != NULL) {
+		if (cmdtab[i].usage)
+			fputs(cmdtab[i].usage, stderr);
+		i++;
+	}
+}
+
+static void
+disk_list(int argc, char **argv)
+{
+}
+
+static void
+disk_info(int argc, char **argv)
+{
+}
+
+static void
+disk_mount(int argc, char **argv)
+{
+
+	if (argc != 6) {
+		fputs("usage: diskutil mount -t vfstype device dir\n", stderr);
+		exit(1);
+	}
+	if (mount(argv[4], argv[5], argv[3], 0, NULL) < 0) {
+		perror("mount");
+		exit(1);
+	}
+}
+
+static void
+disk_unmount(int argc, char **argv)
+{
+}
+
+static void
+disk_eject(int argc, char **argv)
+{
+}
+
+static void
+disk_rename(int argc, char **argv)
+{
+}
+
+static void
+disk_verify(int argc, char **argv)
+{
+}
+
+static void
+disk_partition(int argc, char **argv)
+{
+}
+
+int
+main(int argc, char *argv[])
+{
+	int i = 0;
+	int found = 0;
+
+	if (argc < 2) {
+		disk_help(1, NULL);
+		exit(1);
+	}
+
+	while (cmdtab[i].cmd != NULL) {
+		if (!strncmp(argv[1], cmdtab[i].cmd, LINE_MAX)) {
+			(cmdtab[i].func)(argc, argv);
+			found = 1;
+			break;
+		}
+		i++;
+	}
+	if (!found)
+		disk_help(1, NULL);
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/sbin/init/Makefile b/prex-0.9.0/usr/sbin/init/Makefile
new file mode 100755
index 0000000..ef42161
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/init/Makefile
@@ -0,0 +1,7 @@
+PROG=		init
+
+#DISASM= 	init.lst
+#MAP=		init.map
+#SYMBOL= 	init.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/init/init.c b/prex-0.9.0/usr/sbin/init/init.c
new file mode 100755
index 0000000..7be1309
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/init/init.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contibutors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * init.c - traditional POSIX init.
+ *
+ * Required capabilities:
+ *      CAP_NICE, CAP_KILL, CAP_RAWIO
+ */
+
+#include <sys/prex.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <signal.h>
+#include <termios.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <setjmp.h>
+
+static const char cmdbox[] = "/boot/cmdbox";
+static const char sh[]     = "sh";
+static const char runcom[] = "/etc/rc";
+static const char ctty[]   = "/dev/console";
+
+static jmp_buf jbuf;
+
+/*
+ * The mother of all processes.
+ */
+int
+main(int argc, char *argv[])
+{
+	pid_t pid;
+
+	sys_log("init: booting\n");
+	setsid();
+
+	setjmp(jbuf);
+
+	close(0);
+	close(1);
+	close(2);
+
+	pid = vfork();
+
+	if (pid == -1)
+		exit(1);
+
+	if (pid == 0) {
+		/*
+		 * Child
+		 */
+		signal(SIGHUP, SIG_DFL);
+		signal(SIGINT, SIG_DFL);
+		signal(SIGALRM, SIG_DFL);
+		setsid();
+      		open(ctty, O_RDWR);	/* stdin */
+		dup(0);			/* stdout */
+		dup(0);			/* stderr */
+
+		sys_log("init: running boot script\n");
+		execl(cmdbox, sh, runcom);
+		sys_panic("init: no shell");
+	}
+
+	thread_setpri(thread_self(), 254);
+	while (wait((int *)0) != pid)
+		;
+
+	/*
+	 * Login shell is terminated.
+	 */
+	sys_log("init: restarting...\n");
+	sync();
+	kill(-1, SIGTERM);
+	sleep(1);
+	longjmp(jbuf, 1);
+
+	/* NOTREACHED */
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sbin/install/Makefile b/prex-0.9.0/usr/sbin/install/Makefile
new file mode 100755
index 0000000..c5b22a1
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/install/Makefile
@@ -0,0 +1,7 @@
+PROG=		install
+
+#DISASM= 	install.lst
+#MAP=		install.map
+#SYMBOL= 	install.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/install/install.c b/prex-0.9.0/usr/sbin/install/install.c
new file mode 100755
index 0000000..db6aea8
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/install/install.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * David Hitz of Auspex Systems Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* This code is derived from cp.c */
+/* modified for Prex by Kohsuke Ohtani. */
+
+/*
+ * install.c - software installer.
+ *
+ * Required capabilities:
+ *      CAP_SYSFILES
+ */
+
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+#include <unistd.h>
+#include <err.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include <libgen.h>
+#include <stdio.h>
+
+static void usage(void);
+static void error(void);
+static int copy(char *from, char *to);
+
+
+static char iobuf[BUFSIZ];
+
+int
+main(int argc, char *argv[])
+{
+	int r, ch, checkch, i;
+	char target[] = "/bin";
+	char *src;
+	struct stat to_stat;
+
+	if (argc < 2)
+		usage();
+	if (!strcmp(argv[1], "-?"))
+		usage();
+
+	r = stat(target, &to_stat);
+	if (r == -1 && errno != ENOENT)
+		error();
+	if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
+		error();
+	} else {
+		r = 0;
+		for (i = 1; i < argc; i++) {
+			src = argv[i];
+			/*
+			 * User confirmation is required for security.
+			 */
+			fputs("Are you sure you want to install ", stdout);
+			fputs(basename(src), stdout);
+			fputs("? (y/n) ", stdout);
+			checkch = ch = getchar();
+			while (ch != '\n' && ch != EOF)
+				ch = getchar();
+			if (checkch != 'y')
+				exit(0);
+
+			r = copy(src, target);
+			if (r)
+				error();
+		}
+	}
+	exit(r);
+}
+
+static void
+usage(void)
+{
+	fputs("usage: install file\n", stderr);
+	exit(1);
+	/* NOTREACHED */
+}
+
+static int
+copy(char *from, char *to)
+{
+	char path[PATH_MAX];
+	int fold, fnew, n;
+	struct stat stbuf;
+	mode_t mode;
+	char *p;
+
+	p = strrchr(from, '/');
+	p = p ? p + 1 : from;
+	strlcpy(path, to, sizeof(path));
+	strlcat(path, "/", sizeof(path));
+	strlcat(path, p, sizeof(path));
+	to = path;
+
+	if ((fold = open(from, O_RDONLY)) == -1)
+		return 1;
+	fstat(fold, &stbuf);
+	mode = stbuf.st_mode;
+
+	if ((fnew = creat(to, mode)) == -1) {
+		close(fold);
+		return 1;
+	}
+	while ((n = read(fold, iobuf, BUFSIZ)) > 0) {
+		if (write(fnew, iobuf, (size_t)n) != n) {
+			close(fold);
+			close(fnew);
+			return 1;
+		}
+	}
+	close(fold);
+	close(fnew);
+	return 0;
+}
+
+static void
+error(void)
+{
+	perror("install");
+}
diff --git a/prex-0.9.0/usr/sbin/ktrace/Makefile b/prex-0.9.0/usr/sbin/ktrace/Makefile
new file mode 100755
index 0000000..1d65633
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/ktrace/Makefile
@@ -0,0 +1,7 @@
+PROG=		ktrace
+
+#DISASM= 	ktrace.lst
+#MAP=		ktrace.map
+#SYMBOL= 	ktrace.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/ktrace/ktrace.c b/prex-0.9.0/usr/sbin/ktrace/ktrace.c
new file mode 100755
index 0000000..bc49633
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/ktrace/ktrace.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contibutors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ktrace.c - system call trace utility.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+#include <ipc/proc.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+	struct msg m;
+	object_t obj;
+
+	if (argc < 2 || !strncmp(argv[1], "-?", 2)) {
+		fputs("usage: ktrace command\n", stderr);
+		exit(1);
+	}
+
+	/*
+	 * Set trace flag for current process.
+	 */
+	if (object_lookup("!proc", &obj) != 0) {
+		fputs("No process server found\n", stderr);
+		exit(1);
+	}
+	m.hdr.code = PS_TRACE;
+	msg_send(obj, &m, sizeof(m));
+
+	/*
+	 * Execute command.
+	 */
+	execvp(argv[1], &argv[2]);
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/sbin/lock/Makefile b/prex-0.9.0/usr/sbin/lock/Makefile
new file mode 100755
index 0000000..f8c0ef6
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/lock/Makefile
@@ -0,0 +1,9 @@
+PROG:=		lock
+
+SRCS:=		lock
+
+#DISASM= 	lock.lst
+#MAP=		lock.map
+#SYMBOL= 	lock.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/lock/lock.c b/prex-0.9.0/usr/sbin/lock/lock.c
new file mode 100755
index 0000000..74bd504
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/lock/lock.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contibutors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * lock.c - terminal lock utility.
+ *
+ * Required capabilities:
+ *      CAP_USRFILES
+ */
+
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+
+#include <unistd.h>
+#include <ctype.h>
+#include <err.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdio.h>
+#include <paths.h>
+
+static void usage(void);
+static void setpass(void);
+
+int
+main(int argc, char *argv[])
+{
+	char passcode[PASSWORD_LEN + 1];
+	FILE *fp;
+	int update = 0;
+	char *p;
+
+	if (argc == 2) {
+		if (!strcmp(argv[1], "-u"))
+			update = 1;
+		else
+			usage();
+	}
+
+	/*
+	 * Load current passcode.
+	 */
+	if ((fp = fopen(_PATH_PASSWD, "r")) == NULL) {
+		printf("Passcode is not set.\n");
+		setpass();
+	}
+	if (((p = fgets(passcode, sizeof(passcode), fp)) == NULL) ||
+	    (strlen(passcode) != 4)) {
+		printf("Invalid passcode is set.\n");
+		fclose(fp);
+		setpass();
+	}
+	fclose(fp);
+
+	if (update) {
+		/*
+		 * Update current passcode.
+		 */
+		if (strcmp(getpass("Old passcode:"), passcode)) {
+			printf("Mismatch.\n");
+			exit(0);
+		}
+		setpass();
+	}
+
+	/*
+	 * Lock keyboard until correct passcode input.
+	 */
+	signal(SIGQUIT, SIG_IGN);
+	signal(SIGINT, SIG_IGN);
+	signal(SIGTSTP, SIG_IGN);
+
+	printf("\33[2J");	/* clear screen */
+	printf("Device is locked.\n");
+	for (;;) {
+		if (!strcmp(getpass("Enter passcode:"), passcode))
+			break;
+	}
+	exit(0);
+}
+
+static void
+usage(void)
+{
+	fputs("usage: lock [-u]\n", stderr);
+	exit(1);
+	/* NOTREACHED */
+}
+
+/*
+ * We don't need to encrypt passcode file because it is stored
+ * secure area in the file system.
+ */
+static void
+setpass(void)
+{
+	FILE *fp;
+	char *p, *t;
+	char buf[PASSWORD_LEN + 1];
+
+	for (buf[0] = '\0';;) {
+		p = getpass("New passcode:");
+		if (!*p) {
+			printf("Passcode unchanged.\n");
+			exit(0);
+		}
+		for (t = p; *t && isdigit(*t); ++t);
+		if (strlen(p) != 4 || *t) {
+			printf("Please enter 4 digit number for passcode.\n");
+			continue;
+		}
+		strlcpy(buf, p, sizeof(buf));
+		if (!strcmp(buf, getpass("Retype new passcode:")))
+			break;
+		printf("Mismatch; try again, EOF to quit.\n");
+	}
+	if ((fp = fopen(_PATH_PASSWD, "w+")) == NULL) {
+		err(1, NULL);
+		exit(0);
+	}
+	fputs(buf, fp);
+	fclose(fp);
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/sbin/pmctrl/Makefile b/prex-0.9.0/usr/sbin/pmctrl/Makefile
new file mode 100755
index 0000000..78f39ee
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/pmctrl/Makefile
@@ -0,0 +1,7 @@
+PROG=	pmctrl
+
+#DISASM= 	pmctrl.lst
+#MAP=		pmctrl.map
+#SYMBOL= 	pmctrl.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/sbin/pmctrl/pmctrl.c b/prex-0.9.0/usr/sbin/pmctrl/pmctrl.c
new file mode 100755
index 0000000..9c77a9c
--- /dev/null
+++ b/prex-0.9.0/usr/sbin/pmctrl/pmctrl.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pmctrl.c - power management utility
+ *
+ * Required capabilities:
+ *      CAP_POWERMGMT
+ */
+
+#include <sys/prex.h>
+#include <sys/ioctl.h>
+#include <ipc/pow.h>
+#include <ipc/ipc.h>
+
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+static void pmctrl_help(int, char **);
+static void pmctrl_off(int, char **);
+static void pmctrl_reboot(int, char **);
+static void pmctrl_suspend(int, char **);
+static void pmctrl_info(int, char **);
+static void pmctrl_policy(int, char **);
+static void pmctrl_sustime(int, char **);
+static void pmctrl_dimtime(int, char **);
+static void pmctrl_battery(int, char **);
+static void pmctrl_null(int, char **);
+
+struct cmdtab {
+	const char	*cmd;
+	void		(*func)(int, char **);
+	const char	*usage;
+};
+
+static const struct cmdtab cmdtab[] = {
+	{ "off"		,pmctrl_off	,"Power off." },
+	{ "reboot"	,pmctrl_reboot	,"Reboot system." },
+	{ "suspend"	,pmctrl_suspend	,"Suspend system." },
+	{ "info"	,pmctrl_info	,"Disaplay power management information." },
+	{ "policy"	,pmctrl_policy	,"Set power policy." },
+	{ "sustime"	,pmctrl_sustime	,"Set timeout for suspend timer." },
+	{ "dimtime"	,pmctrl_dimtime	,"Set timeout for dim timer." },
+	{ "battery"	,pmctrl_battery	,"Show current battery level." },
+	{ "-?"		,pmctrl_help	,"This help." },
+	{ NULL		,pmctrl_null	,NULL },
+};
+
+static object_t powobj;
+
+static void
+pmctrl_null(int argc, char **argv)
+{
+}
+
+static void
+pmctrl_help(int argc, char **argv)
+{
+	int i = 0;
+
+	fprintf(stderr, "usage: pmctrl command\n");
+	fprintf(stderr, "commands:\n");
+	while (cmdtab[i].cmd != NULL) {
+		if (cmdtab[i].usage)
+			fprintf(stderr, " %-8s -- %s\n", cmdtab[i].cmd,
+			       cmdtab[i].usage);
+		i++;
+	}
+}
+
+/*
+ * User confirmation is required for some actions
+ * due to security reason.
+ */
+static void
+pmctrl_confirm(char *action)
+{
+	int ch, checkch;
+
+	printf("Do you want to %s the system now? (y/n) ", action);
+	checkch = ch = getchar();
+	while (ch != '\n' && ch != EOF)
+		ch = getchar();
+	if (checkch != 'y')
+		exit(1);
+}
+
+static void
+pmctrl_off(int argc, char **argv)
+{
+	struct msg m;
+
+	pmctrl_confirm("shutdown");
+
+	printf("Shutdown system...\n");
+	m.hdr.code = POW_SET_POWER;
+	m.data[0] = PWR_OFF;
+	msg_send(powobj, &m, sizeof(m));
+
+	fprintf(stderr, "Shutdown failed!\n");
+}
+
+static void
+pmctrl_reboot(int argc, char **argv)
+{
+	struct msg m;
+
+	pmctrl_confirm("reboot");
+
+	printf("Reboot system...\n");
+	m.hdr.code = POW_SET_POWER;
+	m.data[0] = PWR_REBOOT;
+	msg_send(powobj, &m, sizeof(m));
+
+	fprintf(stderr, "Reboot failed!\n");
+}
+
+static void
+pmctrl_suspend(int argc, char **argv)
+{
+	struct msg m;
+
+	pmctrl_confirm("suspend");
+
+	printf("Suspend system...\n");
+	m.hdr.code = POW_SET_POWER;
+	m.data[0] = PWR_SUSPEND;
+	msg_send(powobj, &m, sizeof(m));
+
+	fprintf(stderr, "Suspend failed!\n");
+}
+
+static void
+pmctrl_info(int argc, char **argv)
+{
+	struct msg m;
+	int policy;
+	int timeout;
+
+	m.hdr.code = POW_GET_POLICY;
+	msg_send(powobj, &m, sizeof(m));
+	policy = m.data[0];
+	printf("Power policy   : %s mode\n",
+	       policy == PM_PERFORMANCE ? "high performance" : "power save");
+
+	m.hdr.code = POW_GET_SUSTMR;
+	msg_send(powobj, &m, sizeof(m));
+	timeout = m.data[0];
+	printf("Suspend timeout: %d sec\n", timeout);
+
+	m.hdr.code = POW_GET_DIMTMR;
+	msg_send(powobj, &m, sizeof(m));
+	timeout = m.data[0];
+	printf("Dim timeout    : %d sec\n", timeout);
+}
+
+static void
+pmctrl_policy(int argc, char **argv)
+{
+	struct msg m;
+
+	if (argc != 3) {
+		fprintf(stderr, "Usage: pmctrl policy high|save\n");
+		exit(1);
+	}
+
+	if (!strcmp(argv[2], "high"))
+		m.data[0] = PM_PERFORMANCE;
+	else if (!strcmp(argv[2], "save"))
+		m.data[0] = PM_POWERSAVE;
+	else {
+		fprintf(stderr, "Invalid policy\n");
+		exit(1);
+	}
+	m.hdr.code = POW_SET_POLICY;
+	msg_send(powobj, &m, sizeof(m));
+}
+
+static void
+pmctrl_sustime(int argc, char **argv)
+{
+	struct msg m;
+	int timeout;
+
+	if (argc < 3)
+		fprintf(stderr, "Usage: pmctrl sustime sec\n");
+	else {
+		timeout = atoi(argv[2]);
+
+		m.hdr.code = POW_SET_SUSTMR;
+		m.data[0] = timeout;
+		msg_send(powobj, &m, sizeof(m));
+	}
+}
+
+static void
+pmctrl_dimtime(int argc, char **argv)
+{
+	struct msg m;
+	int timeout;
+
+	if (argc < 3)
+		fprintf(stderr, "Usage: pmctrl dimtime sec\n");
+	else {
+		timeout = atoi(argv[2]);
+
+		m.hdr.code = POW_SET_DIMTMR;
+		m.data[0] = timeout;
+		msg_send(powobj, &m, sizeof(m));
+	}
+}
+
+static void
+pmctrl_battery(int argc, char **argv)
+{
+
+	fprintf(stderr, "Not supported...\n");
+}
+
+int
+main(int argc, char *argv[])
+{
+	int i = 0;
+	int found = 0;
+
+	if (argc < 2) {
+		pmctrl_help(1, NULL);
+		exit(1);
+	}
+
+	if (object_lookup("!pow", &powobj) != 0) {
+		fprintf(stderr, "No power server found\n");
+		exit(1);
+	}
+
+	while (cmdtab[i].cmd != NULL) {
+		if (!strncmp(argv[1], cmdtab[i].cmd, LINE_MAX)) {
+			(cmdtab[i].func)(argc, argv);
+			found = 1;
+			break;
+		}
+		i++;
+	}
+	if (!found)
+		pmctrl_help(1, NULL);
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/server/Makefile b/prex-0.9.0/usr/server/Makefile
new file mode 100755
index 0000000..b3bd4d7
--- /dev/null
+++ b/prex-0.9.0/usr/server/Makefile
@@ -0,0 +1,3 @@
+SUBDIR:=	fs boot proc exec pow
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/usr/server/boot/Makefile b/prex-0.9.0/usr/server/boot/Makefile
new file mode 100755
index 0000000..0195265
--- /dev/null
+++ b/prex-0.9.0/usr/server/boot/Makefile
@@ -0,0 +1,7 @@
+PROG:=		boot
+
+#MAP:= 		boot.map
+#DISASM:= 	boot.lst
+#SYMBOL:= 	boot.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/server/boot/boot.c b/prex-0.9.0/usr/server/boot/boot.c
new file mode 100755
index 0000000..df26bf5
--- /dev/null
+++ b/prex-0.9.0/usr/server/boot/boot.c
@@ -0,0 +1,334 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * main.c - bootstrap server
+ */
+
+/*
+ * A bootstrap server works to setup the POSIX environment for
+ * 'init' process. It sends a setup message to other servers in
+ * order to let them know that this task becomes 'init' process.
+ * The bootstrap server is gone after it launches (exec) the
+ * 'init' process.
+ */
+
+#include <sys/prex.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+#include <sys/syslog.h>
+
+#include <ipc/fs.h>
+#include <ipc/exec.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <errno.h>
+
+#ifdef DEBUG
+#define DPRINTF(a) sys_log a
+#else
+#define DPRINTF(a)
+#endif
+
+static const char *initargs[] = { "1", NULL };
+static const char *initenvs[] = { "TERM=vt100", "USER=root", NULL };
+
+static char iobuf[BUFSIZ];
+
+/*
+ * Base directories at root.
+ */
+static char *base_dir[] = {
+	"/bin",		/* applications */
+	"/boot",	/* system servers */
+	"/dev",		/* device files */
+	"/etc",		/* shareable read-only data */
+	"/mnt",		/* mount point for file systems */
+	"/private",	/* user's private data */
+	"/tmp",		/* temporary files */
+	NULL
+};
+
+static void
+wait_server(const char *name, object_t *pobj)
+{
+	int i, error = 0;
+
+	/* Give chance to run other servers. */
+	thread_yield();
+
+	/*
+	 * Wait for server loading. timeout is 1 sec.
+	 */
+	for (i = 0; i < 100; i++) {
+		error = object_lookup((char *)name, pobj);
+		if (error == 0)
+			break;
+
+		/* Wait 10msec */
+		timer_sleep(10, 0);
+		thread_yield();
+	}
+	if (error)
+		sys_panic("boot: server not found");
+}
+
+static void
+send_bootmsg(object_t obj)
+{
+	struct msg m;
+	int error;
+
+	m.hdr.code = STD_BOOT;
+	error = msg_send(obj, &m, sizeof(m));
+	if (error)
+		sys_panic("boot: server error");
+}
+
+static void
+mount_fs(void)
+{
+	char line[128];
+	FILE *fp;
+	char *spec, *file, *type, *p;
+	char nodev[] = "";
+	int i;
+
+	DPRINTF(("boot: mounting file systems\n"));
+
+	/*
+	 * Mount root.
+	 */
+	if (mount("", "/", "ramfs", 0, NULL) < 0)
+		sys_panic("boot: mount failed");
+
+	/*
+	 * Create some default directories.
+	 */
+	i = 0;
+	while (base_dir[i] != NULL) {
+		if (mkdir(base_dir[i], 0) == -1)
+			sys_panic("boot: mkdir failed");
+		i++;
+	}
+
+	/*
+	 * Mount file system for /boot.
+	 */
+	if (mount("/dev/ram0", "/boot", "arfs", 0, NULL) < 0)
+		sys_panic("boot: mount failed");
+
+	/*
+	 * Mount file systems described in fstab.
+	 */
+	if ((fp = fopen("/boot/fstab", "r")) == NULL)
+		sys_panic("boot: no fstab");
+
+	for (;;) {
+		if ((p = fgets(line, sizeof(line), fp)) == NULL)
+			break;
+		spec = strtok(p, " \t\n");
+		if (spec == NULL || *spec == '#')
+			continue;
+		file = strtok(NULL, " \t\n");
+		type = strtok(NULL, " \t\n");
+		if (!strcmp(file, "/") || !strcmp(file, "/boot"))
+			continue;
+		if (!strcmp(spec, "none"))
+			spec = nodev;
+
+		/* We create the mount point automatically */
+		mkdir(file, 0);
+		mount(spec, file, type, 0, 0);
+	}
+	fclose(fp);
+}
+
+static int
+exec_init(object_t execobj)
+{
+	struct exec_msg msg;
+	int error, i, argc, envc;
+	size_t bufsz;
+	char *dest;
+	char const *src;
+
+	DPRINTF(("boot: execute init\n"));
+
+	/* Get arg/env buffer size */
+	bufsz = 0;
+	argc = 0;
+	while (initargs[argc]) {
+		bufsz += (strlen(initargs[argc]) + 1);
+		argc++;
+	}
+	envc = 0;
+	while (initenvs[envc]) {
+		bufsz += (strlen(initenvs[envc]) + 1);
+		envc++;
+	}
+	if (bufsz >= ARG_MAX)
+		sys_panic("boot: args too long");
+
+	/*
+	 * Build exec message.
+	 */
+	dest = msg.buf;
+	for (i = 0; i < argc; i++) {
+		src = initargs[i];
+		while ((*dest++ = *src++) != 0);
+	}
+	for (i = 0; i < envc; i++) {
+		src = initenvs[i];
+		while ((*dest++ = *src++) != 0);
+	}
+	msg.hdr.code = EXEC_EXECVE;
+	msg.argc = argc;
+	msg.envc = envc;
+	msg.bufsz = bufsz;
+	strlcpy(msg.cwd, "/", sizeof(msg.cwd));
+	strlcpy(msg.path, "/boot/init", sizeof(msg.path));
+
+	do {
+		error = msg_send(execobj, &msg, sizeof(msg));
+		/*
+		 * If exec server can execute new process
+		 * properly, it will terminate the caller task
+		 * automatically. So, the control never comes
+		 * here in that case.
+		 */
+	} while (error == EINTR);
+	return -1;
+}
+
+static void
+copy_file(char *src, char *dest)
+{
+	int fold, fnew, n;
+	struct stat stbuf;
+	mode_t mode;
+
+	if ((fold = open(src, O_RDONLY)) == -1)
+		return;
+
+	fstat(fold, &stbuf);
+	mode = stbuf.st_mode;
+
+	if ((fnew = creat(dest, mode)) == -1) {
+		close(fold);
+		return;
+	}
+	while ((n = read(fold, iobuf, BUFSIZ)) > 0) {
+		if (write(fnew, iobuf, (size_t)n) != n) {
+			close(fold);
+			close(fnew);
+			return;
+		}
+	}
+	close(fold);
+	close(fnew);
+}
+
+int
+main(int argc, char *argv[])
+{
+	object_t execobj, procobj, fsobj;
+	struct bind_msg bm;
+	struct msg m;
+
+	sys_log("Starting bootstrap server\n");
+
+	thread_setpri(thread_self(), PRI_DEFAULT);
+
+	/*
+	 * Wait until all required system servers
+	 * become available.
+	 */
+	wait_server("!proc", &procobj);
+	wait_server("!fs", &fsobj);
+	wait_server("!exec", &execobj);
+
+	/*
+	 * Send boot message to all servers.
+	 * This is required to synchronize the server
+	 * initialization without deadlock.
+	 */
+	send_bootmsg(execobj);
+	send_bootmsg(procobj);
+	send_bootmsg(fsobj);
+
+	/*
+	 * Request to bind a new capabilities for us.
+	 */
+	bm.hdr.code = EXEC_BINDCAP;
+	strlcpy(bm.path, "/boot/boot", sizeof(bm.path));
+	msg_send(execobj, &bm, sizeof(bm));
+
+	/*
+	 * Register this process as 'init'.
+	 * We will become an init process later.
+	 */
+	m.hdr.code = PS_SETINIT;
+	msg_send(procobj, &m, sizeof(m));
+
+	/*
+	 * Initialize a library for file I/O.
+	 */
+	fslib_init();
+
+	/*
+	 * Mount file systems.
+	 */
+	mount_fs();
+
+	/*
+	 * Copy some files.
+	 * Note that almost applications including 'init'
+	 * does not have an access right to /boot directory...
+	 */
+	copy_file("/boot/rc", "/etc/rc");
+	copy_file("/boot/fstab", "/etc/fstab");
+
+	/*
+	 * Exec first application.
+	 */
+	exec_init(execobj);
+
+	sys_panic("boot: failed to exec init");
+
+	/* NOTREACHED */
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/exec/Makefile b/prex-0.9.0/usr/server/exec/Makefile
new file mode 100755
index 0000000..3180784
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/Makefile
@@ -0,0 +1,12 @@
+include $(SRCDIR)/mk/own.mk
+
+PROG:=		exec
+SRCS:=		main.c exec_execve.c exec_conf.c exec_cap.c \
+		exec_elf.c exec_script.c \
+		$(SRCDIR)/usr/arch/$(ARCH)/elf_reloc.c
+
+#MAP:=		exec.map
+#DISASM:= 	exec.lst
+#SYMBOL:= 	exec.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/server/exec/exec.h b/prex-0.9.0/usr/server/exec/exec.h
new file mode 100755
index 0000000..66a680a
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/exec.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _EXEC_H
+#define _EXEC_H
+
+#include <sys/cdefs.h>
+#include <sys/prex.h>
+#include <sys/elf.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <ipc/exec.h>
+
+#include <unistd.h>
+#include <assert.h>
+
+/* #define DEBUG_EXEC 1 */
+
+#ifdef DEBUG_EXEC
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)
+#define ASSERT(e)
+#endif
+
+#define HEADER_SIZE	512
+
+/*
+ * Exec descriptor
+ */
+struct exec {
+	char	*path;			/* path name */
+	void	*header;		/* buffer for header */
+	char	*xarg1;			/* extra arguments */
+	char	*xarg2;			/* extra arguments */
+	task_t	task;			/* task id */
+	vaddr_t	entry;			/* entry address */
+};
+
+/*
+ * Definition for exec loader
+ */
+struct exec_loader {
+	const char *el_name;		/* name of loader */
+	void	(*el_init)(void);	/* initialize routine */
+	int	(*el_probe)(struct exec *);	/* probe routine */
+	int	(*el_load)(struct exec *);	/* load routine */
+};
+
+/*
+ * Probe result
+ */
+#define PROBE_ERROR		0
+#define PROBE_MATCH		1
+#define PROBE_INDIRECT		2
+
+
+/*
+ * Capability mapping
+ */
+struct cap_map {
+	char	*c_path;		/* application name */
+	cap_t	c_capset;		/* capability set */
+};
+
+/*
+ * Global variables
+ */
+extern struct exec_loader loader_table[];
+extern const struct cap_map cap_table[];
+extern const int nloader;
+
+__BEGIN_DECLS
+void	 bind_cap(char *, task_t);
+int	 exec_bindcap(struct bind_msg *);
+int	 exec_execve(struct exec_msg *);
+__END_DECLS
+
+#endif /* !_EXEC_H */
diff --git a/prex-0.9.0/usr/server/exec/exec_cap.c b/prex-0.9.0/usr/server/exec/exec_cap.c
new file mode 100755
index 0000000..59d2457
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/exec_cap.c
@@ -0,0 +1,97 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exec_cap.c - file capability management routines.
+ */
+
+#include <sys/prex.h>
+#include <sys/capability.h>
+#include <string.h>
+#include <errno.h>
+
+#include "exec.h"
+
+/*
+ * Bind capabilities for the known file.
+ */
+void
+bind_cap(char *path, task_t task)
+{
+	const struct cap_map *map;
+	cap_t cap = 0;
+	int error;
+
+	/*
+	 * Set capabilities to the known applications.
+	 */
+	map = &cap_table[0];
+	while (map->c_path != NULL) {
+		if (!strncmp(path, map->c_path, PATH_MAX)) {
+			cap = map->c_capset;
+			break;
+		}
+		map++;
+	}
+	if (cap != 0) {
+		DPRINTF(("exec: set capability:%08x to %s\n", cap, path));
+		error = task_setcap(task, cap);
+		if (error)
+			sys_panic("exec: no SETPCAP capability");
+	}
+}
+
+/*
+ * Bind capability for server
+ */
+int
+exec_bindcap(struct bind_msg *msg)
+{
+	task_t task;
+	int error;
+
+	task = msg->hdr.task;
+
+	if (msg->path == NULL)
+		return EFAULT;
+
+	/*
+	 * Check capability of caller task.
+	 */
+	error = task_chkcap(task, CAP_PROTSERV);
+	if (error != 0)
+		return EPERM;
+
+	/*
+	 * Set capability
+	 */
+	bind_cap(msg->path, task);
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/exec/exec_conf.c b/prex-0.9.0/usr/server/exec/exec_conf.c
new file mode 100755
index 0000000..5492181
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/exec_conf.c
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2007-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include "exec.h"
+
+/*
+ * Include the capability table generated by configure sript.
+ */
+#include <conf/captab.h>
+
+
+extern void	elf_init(void);
+extern int	elf_probe(struct exec *);
+extern int	elf_load(struct exec *);
+
+extern void	script_init(void);
+extern int	script_probe(struct exec *);
+extern int	script_load(struct exec *);
+
+/*
+ * File format loaders.
+ */
+struct exec_loader loader_table[] = {
+	{"elf",		elf_init,	elf_probe,	elf_load},
+	{"script",	script_init,	script_probe,	script_load},
+};
+
+const int nloader = (int)(sizeof(loader_table) / sizeof(loader_table[0]));
diff --git a/prex-0.9.0/usr/server/exec/exec_elf.c b/prex-0.9.0/usr/server/exec/exec_elf.c
new file mode 100755
index 0000000..9225c1b
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/exec_elf.c
@@ -0,0 +1,395 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exec_elf.c - ELF file loader
+ */
+
+#include <sys/prex.h>
+#include <ipc/fs.h>
+#include <ipc/proc.h>
+#include <sys/elf.h>
+#include <sys/param.h>
+
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "exec.h"
+
+#define SHF_VALID	(SHF_ALLOC | SHF_EXECINSTR | SHF_ALLOC | SHF_WRITE)
+
+#ifndef CONFIG_MMU
+static char *sect_addr[32];	/* Array of section address */
+#endif
+
+#ifdef CONFIG_MMU
+/*
+ * Load executable ELF file
+ */
+static int
+load_exec(Elf32_Ehdr *ehdr, task_t task, int fd, vaddr_t *entry)
+{
+	Elf32_Phdr *phdr;
+	void *addr, *mapped;
+	size_t size = 0;
+	int i;
+
+	phdr = (Elf32_Phdr *)((u_long)ehdr + ehdr->e_phoff);
+	if (phdr == NULL)
+		return ENOEXEC;
+
+	for (i = 0; i < (int)ehdr->e_phnum; i++, phdr++) {
+		if (phdr->p_type != PT_LOAD)
+			continue;
+
+		addr = (void *)phdr->p_vaddr;
+		size = phdr->p_memsz;
+		if (size == 0)
+			continue;
+
+		if (vm_allocate(task, &addr, size, 0) != 0)
+			return ENOMEM;
+
+		if (vm_map(task, (void *)phdr->p_vaddr, size, &mapped) != 0)
+			return ENOEXEC;
+		if (phdr->p_filesz > 0) {
+			if (lseek(fd, (off_t)phdr->p_offset, SEEK_SET)
+			    == -(off_t)1)
+				goto err;
+			if (read(fd, mapped, phdr->p_filesz) < 0)
+				goto err;
+		}
+
+		vm_free(task_self(), mapped);
+
+		/* Set read-only to text */
+		if (phdr->p_flags & PF_X) {
+			if (vm_attribute(task, addr, PROT_READ) != 0)
+				return ENOEXEC;
+		}
+	}
+	*entry = (vaddr_t)ehdr->e_entry;
+	return 0;
+
+ err:
+	vm_free(task_self(), mapped);
+	return EIO;
+}
+#else /* !CONFIG_MMU */
+
+static int
+relocate_section_rela(Elf32_Sym *sym_table, Elf32_Rela *rela,
+		      char *target_sect, int nr_reloc)
+{
+	Elf32_Sym *sym;
+	Elf32_Addr sym_val;
+	int i;
+
+	for (i = 0; i < nr_reloc; i++) {
+		sym = &sym_table[ELF32_R_SYM(rela->r_info)];
+		if (sym->st_shndx != STN_UNDEF) {
+			sym_val = (Elf32_Addr)sect_addr[sym->st_shndx]
+				+ sym->st_value;
+			if (relocate_rela(rela, sym_val, target_sect) != 0)
+				return -1;
+		} else if (ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
+			DPRINTF(("undefined weak symbol for rela[%d]\n", i));
+		}
+		rela++;
+	}
+	return 0;
+}
+
+static int
+relocate_section_rel(Elf32_Sym *sym_table, Elf32_Rel *rel,
+		     char *target_sect, int nr_reloc)
+{
+	Elf32_Sym *sym;
+	Elf32_Addr sym_val;
+	int i;
+
+	for (i = 0; i < nr_reloc; i++) {
+		sym = &sym_table[ELF32_R_SYM(rel->r_info)];
+		if (sym->st_shndx != STN_UNDEF) {
+			sym_val = (Elf32_Addr)sect_addr[sym->st_shndx]
+				+ sym->st_value;
+			if (relocate_rel(rel, sym_val, target_sect) != 0)
+				return -1;
+		} else if (ELF32_ST_BIND(sym->st_info) == STB_WEAK) {
+			DPRINTF(("undefined weak symbol for rel[%d]\n", i));
+		}
+		rel++;
+	}
+	return 0;
+}
+
+/*
+ * Relocate ELF sections
+ */
+static int
+relocate_section(Elf32_Shdr *shdr, char *rel_data)
+{
+	Elf32_Sym *sym_table;
+	char *target_sect;
+	int nr_reloc, error;
+
+	if (shdr->sh_entsize == 0)
+		return 0;
+	if ((target_sect = sect_addr[shdr->sh_info]) == 0)
+		return -1;
+	if ((sym_table = (Elf32_Sym *)sect_addr[shdr->sh_link]) == 0)
+		return -1;
+
+	nr_reloc = (int)(shdr->sh_size / shdr->sh_entsize);
+	switch (shdr->sh_type) {
+	case SHT_REL:
+		error = relocate_section_rel(sym_table, (Elf32_Rel *)rel_data,
+					   target_sect, nr_reloc);
+		break;
+
+	case SHT_RELA:
+		error = relocate_section_rela(sym_table, (Elf32_Rela *)rel_data,
+					    target_sect, nr_reloc);
+		break;
+
+	default:
+		error = -1;
+		break;
+	}
+	return error;
+}
+
+/*
+ * Load ELF relocatable file.
+ */
+static int
+load_reloc(Elf32_Ehdr *ehdr, task_t task, int fd, vaddr_t *entry)
+{
+	Elf32_Shdr *shdr;
+	char *buf;
+	void *base, *addr, *mapped;
+	size_t shdr_size, total_size;
+	int i, error = 0;
+
+	DPRINTF(("exec: load_reloc\n"));
+
+	/* Read section header */
+	shdr_size = ehdr->e_shentsize * ehdr->e_shnum;
+	if ((buf = malloc(shdr_size)) == NULL) {
+		error = ENOMEM;
+		goto out0;
+	}
+
+	if (lseek(fd, ehdr->e_shoff, SEEK_SET) < 0) {
+		error = EIO;
+		goto out1;
+	}
+	if (read(fd, buf, shdr_size) < 0) {
+		error = EIO;
+		goto out1;
+	}
+
+	/* Allocate memory for text, data and bss. */
+	shdr = (Elf32_Shdr *)buf;
+	total_size = 0;
+	for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
+		if (shdr->sh_type == SHT_NOBITS) { /* bss? */
+			total_size = shdr->sh_addr + shdr->sh_size;
+			break;
+		}
+	}
+	if (total_size == 0) {
+		error = ENOEXEC;
+		goto out1;
+	}
+	if (vm_allocate(task, &base, total_size, 1) != 0) {
+		DPRINTF(("exec: out of text\n"));
+		error = ENOMEM;
+		goto out1;
+	}
+
+	if (vm_map(task, base, total_size, &mapped) != 0) {
+		error = ENOMEM;
+		goto out1;
+	}
+
+	/* Copy sections */
+	shdr = (Elf32_Shdr *)buf;
+	for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
+		/*
+		 *DPRINTF(("section: type=%x addr=%x size=%d offset=%x flags=%x\n",
+		 *   shdr->sh_type, shdr->sh_addr, shdr->sh_size,
+		 *   shdr->sh_offset, shdr->sh_flags));
+		 */
+		sect_addr[i] = 0;
+		if (shdr->sh_type == SHT_PROGBITS) {
+			switch (shdr->sh_flags & SHF_VALID) {
+			case (SHF_ALLOC | SHF_EXECINSTR): /* text */
+			case (SHF_ALLOC | SHF_WRITE): /* data */
+			case SHF_ALLOC: /* rodata */
+				break;
+			default:
+				continue;
+			}
+			addr = (char *)((u_long)mapped + shdr->sh_addr);
+			if (shdr->sh_size == 0) {
+				continue;
+			}
+		} else if (shdr->sh_type == SHT_NOBITS) {
+			/* bss */
+			sect_addr[i] = \
+				(char *)((u_long)mapped + shdr->sh_addr);
+			continue;
+		} else if (shdr->sh_type == SHT_SYMTAB ||
+			   shdr->sh_type == SHT_RELA ||
+			   shdr->sh_type == SHT_REL)
+		{
+
+			if ((addr = malloc(shdr->sh_size)) == NULL) {
+				error = ENOMEM;
+				goto out2;
+			}
+		} else
+			continue;
+
+		if (lseek(fd, shdr->sh_offset, SEEK_SET) < 0) {
+			error = EIO;
+			goto out2;
+		}
+		if (read(fd, addr, shdr->sh_size) < 0) {
+			error = EIO;
+			goto out2;
+		}
+		sect_addr[i] = addr;
+	}
+
+	/* Process relocation */
+	shdr = (Elf32_Shdr *)buf;
+	for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
+		if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) {
+			if (relocate_section(shdr, sect_addr[i]) != 0) {
+				error = EIO;
+				DPRINTF(("exec: relocation failed\n"));
+				goto out2;
+			}
+		}
+	}
+	*entry = (vaddr_t)((u_long)mapped + ehdr->e_entry);
+	DPRINTF(("exec: entry=%x\n", *entry));
+ out2:
+	/* Release symbol table */
+	shdr = (Elf32_Shdr *)buf;
+	for (i = 0; i < ehdr->e_shnum; i++, shdr++) {
+		if (shdr->sh_type == SHT_SYMTAB ||
+		    shdr->sh_type == SHT_RELA ||
+		    shdr->sh_type == SHT_REL) {
+			if (sect_addr[i])
+				free(sect_addr[i]);
+		}
+	}
+	vm_free(task_self(), mapped);
+ out1:
+	free(buf);
+ out0:
+	DPRINTF(("exec: load_reloc ret=%d\n", error));
+	return error;
+}
+
+#endif /* !CONFIG_MMU */
+
+
+/*
+ * Load ELF file
+ */
+int
+elf_load(struct exec *exec)
+{
+	int error, fd;
+
+	/*
+	 * Check permission.
+	 */
+	if (access(exec->path, X_OK) == -1) {
+		DPRINTF(("exec: no exec access\n"));
+		return errno;
+	}
+
+	if ((fd = open(exec->path, O_RDONLY)) == -1)
+		return ENOENT;
+
+#ifdef CONFIG_MMU
+	error = load_exec((Elf32_Ehdr *)exec->header, exec->task,
+			  fd, &exec->entry);
+#else
+	error = load_reloc((Elf32_Ehdr *)exec->header, exec->task,
+			  fd, &exec->entry);
+#endif
+	close(fd);
+	return error;
+}
+
+/*
+ * Probe ELF file
+ */
+int
+elf_probe(struct exec *exec)
+{
+	Elf32_Ehdr *ehdr;
+
+	/* Check ELF header */
+	ehdr = (Elf32_Ehdr *)exec->header;
+	DPRINTF(("exec: ELF magic %c %c %c %c\n",
+		 ehdr->e_ident[EI_MAG0],
+		 ehdr->e_ident[EI_MAG1],
+		 ehdr->e_ident[EI_MAG2],
+		 ehdr->e_ident[EI_MAG3]));
+
+	if ((ehdr->e_ident[EI_MAG0] != ELFMAG0) ||
+	    (ehdr->e_ident[EI_MAG1] != ELFMAG1) ||
+	    (ehdr->e_ident[EI_MAG2] != ELFMAG2) ||
+	    (ehdr->e_ident[EI_MAG3] != ELFMAG3))
+		return PROBE_ERROR;
+
+#ifdef CONFIG_MMU
+	if (ehdr->e_type != ET_EXEC)
+		return PROBE_ERROR;
+#else
+	if (ehdr->e_type != ET_REL)
+		return PROBE_ERROR;
+#endif
+	return PROBE_MATCH;
+}
+
+void
+elf_init(void)
+{
+}
diff --git a/prex-0.9.0/usr/server/exec/exec_execve.c b/prex-0.9.0/usr/server/exec/exec_execve.c
new file mode 100755
index 0000000..1705969
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/exec_execve.c
@@ -0,0 +1,473 @@
+/*-
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exec_execve.c - execve support
+ */
+
+#include <sys/prex.h>
+#include <sys/capability.h>
+#include <ipc/fs.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+#include <sys/list.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <assert.h>
+#include <errno.h>
+#include <libgen.h>	/* for basename() */
+
+#include "exec.h"
+
+#define	SP_ALIGN(p)	((unsigned)(p) &~ _ALIGNBYTES)
+
+/* forward declarations */
+static int	build_args(task_t, void *, char *, struct exec_msg *,
+			   char *, char *, void **);
+static int	conv_path(char *, char *, char *);
+static void	notify_server(task_t, task_t, void *);
+static int	read_header(char *);
+
+/*
+ * Buffer for file header
+ */
+static char hdrbuf[HEADER_SIZE];
+
+/*
+ * Execute program
+ */
+int
+exec_execve(struct exec_msg *msg)
+{
+	struct exec_loader *ldr = NULL;
+	int error, i;
+	task_t old_task, new_task;
+	thread_t t;
+	void *stack, *sp;
+	char path[PATH_MAX];
+	struct exec exec;
+	int rc;
+
+	DPRINTF(("exec_execve: path=%s task=%x\n", msg->path, msg->hdr.task));
+
+	old_task = msg->hdr.task;
+
+	/*
+	 * Make it full path.
+	 */
+	if ((error = conv_path(msg->cwd, msg->path, path)) != 0) {
+		DPRINTF(("exec: invalid path\n"));
+		goto err1;
+	}
+
+	/*
+	 * Check permission.
+	 */
+	if (access(path, X_OK) == -1) {
+		DPRINTF(("exec: no exec access\n"));
+		error = errno;
+		goto err1;
+	}
+
+	exec.path = path;
+	exec.header = hdrbuf;
+	exec.xarg1 = NULL;
+	exec.xarg2 = NULL;
+
+ again:
+	/*
+	 * Read file header
+	 */
+	DPRINTF(("exec: read header for %s\n", exec.path));
+	if ((error = read_header(exec.path)) != 0)
+		goto err1;
+
+	/*
+	 * Find file loader
+	 */
+	rc = PROBE_ERROR;
+	for (i = 0; i < nloader; i++) {
+		ldr = &loader_table[i];
+		if ((rc = ldr->el_probe(&exec)) != PROBE_ERROR) {
+			break;
+		}
+	}
+	if (rc == PROBE_ERROR) {
+		DPRINTF(("exec: unsupported file format\n"));
+		error = ENOEXEC;
+		goto err1;
+	}
+
+	/*
+	 * Check file header again if indirect case.
+	 */
+	if (rc == PROBE_INDIRECT)
+			goto again;
+
+	DPRINTF(("exec: loader=%s\n", ldr->el_name));
+
+	/*
+	 * Check file permission.
+	 */
+	if (access(exec.path, X_OK) == -1) {
+		DPRINTF(("exec: no exec access\n"));
+		error = errno;
+		goto err1;
+	}
+
+	/*
+	 * Suspend old task
+	 */
+	if ((error = task_suspend(old_task)) != 0)
+		goto err1;
+
+	/*
+	 * Create new task
+	 */
+	if ((error = task_create(old_task, VM_NEW, &new_task)) != 0) {
+		DPRINTF(("exec: failed to crete task\n"));
+		goto err1;
+	}
+
+	if (*exec.path != '\0')
+		task_setname(new_task, basename(exec.path));
+
+	/*
+	 * Bind capabilities.
+	 */
+	bind_cap(exec.path, new_task);
+
+	if ((error = thread_create(new_task, &t)) != 0)
+		goto err3;
+
+	/*
+	 * Allocate stack and build arguments on it.
+	 */
+	error = vm_allocate(new_task, &stack, DFLSTKSZ, 1);
+	if (error) {
+		DPRINTF(("exec: failed to allocate stack\n"));
+		goto err4;
+	}
+	if ((error = build_args(new_task, stack, exec.path, msg,
+				exec.xarg1, exec.xarg2, &sp)) != 0)
+		goto err5;
+
+	/*
+	 * Load file image.
+	 */
+	DPRINTF(("exec: load file image\n"));
+	exec.task = new_task;
+	if ((error = ldr->el_load(&exec)) != 0)
+		goto err5;
+	if ((error = thread_load(t, (void (*)(void))exec.entry, sp)) != 0)
+		goto err5;
+
+	/*
+	 * Notify to servers.
+	 */
+	notify_server(old_task, new_task, stack);
+
+	/*
+	 * Terminate old task.
+	 */
+	task_terminate(old_task);
+
+	/*
+	 * Set him running.
+	 */
+	thread_setpri(t, PRI_DEFAULT);
+	thread_resume(t);
+
+	DPRINTF(("exec done\n"));
+	return 0;
+ err5:
+	vm_free(new_task, stack);
+ err4:
+	thread_terminate(t);
+ err3:
+	task_terminate(new_task);
+ err1:
+	DPRINTF(("exec failed error=%d\n", error));
+	return error;
+}
+
+/*
+ * Convert to full path from the cwd of task and path.
+ * @cwd:  current working directory
+ * @path: target path
+ * @full: full path to be returned
+ */
+static int
+conv_path(char *cwd, char *path, char *full)
+{
+	char *src, *tgt, *p, *end;
+	size_t len = 0;
+
+	path[PATH_MAX - 1] = '\0';
+	len = strlen(path);
+	if (len >= PATH_MAX)
+		return ENAMETOOLONG;
+	if (strlen(cwd) + len >= PATH_MAX)
+		return ENAMETOOLONG;
+	src = path;
+	tgt = full;
+	end = src + len;
+	if (path[0] == '/') {
+		*tgt++ = *src++;
+		len++;
+	} else {
+		strlcpy(full, cwd, PATH_MAX);
+		len = strlen(cwd);
+		tgt += len;
+		if (len > 1 && path[0] != '.') {
+			*tgt = '/';
+			tgt++;
+			len++;
+		}
+	}
+	while (*src) {
+		p = src;
+		while (*p != '/' && *p != '\0')
+			p++;
+		*p = '\0';
+		if (!strcmp(src, "..")) {
+			if (len >= 2) {
+				len -= 2;
+				tgt -= 2;	/* skip previous '/' */
+				while (*tgt != '/') {
+					tgt--;
+					len--;
+				}
+				if (len == 0) {
+					tgt++;
+					len++;
+				}
+			}
+		} else if (!strcmp(src, ".")) {
+			/* Ignore "." */
+		} else {
+			while (*src != '\0') {
+				*tgt++ = *src++;
+				len++;
+			}
+		}
+		if (p == end)
+			break;
+		if (len > 0 && *(tgt - 1) != '/') {
+			*tgt++ = '/';
+			len++;
+		}
+		src = p + 1;
+	}
+	*tgt = '\0';
+	return 0;
+}
+
+/*
+ * Build argument on stack.
+ *
+ * Stack layout:
+ *    file name string
+ *    env string
+ *    arg string
+ *    NULL
+ *    envp[n]
+ *    NULL
+ *    argv[n]
+ *    argc
+ *
+ * NOTE: This may depend on processor architecture.
+ */
+static int
+build_args(task_t task, void *stack, char *path, struct exec_msg *msg,
+	   char *xarg1, char *xarg2, void **new_sp)
+{
+	int argc, envc;
+	char *file;
+	char **argv, **envp;
+	int i, error;
+	u_long arg_top, mapped, sp;
+	int len;
+
+	argc = msg->argc;
+	envc = msg->envc;
+	DPRINTF(("exec: argc=%d envc=%d\n", argc, envc));
+	DPRINTF(("exec: xarg1=%s xarg2=%s\n", xarg1, xarg2));
+
+	/*
+	 * Map target stack in current task.
+	 */
+	error = vm_map(task, stack, DFLSTKSZ, (void *)&mapped);
+	if (error)
+		return ENOMEM;
+	memset((void *)mapped, 0, DFLSTKSZ);
+	sp = mapped + DFLSTKSZ - sizeof(int) * 3;
+
+	/*
+	 * Copy items
+	 */
+
+	/* File name */
+	*(char *)sp = '\0';
+	sp -= strlen(path);
+	sp = SP_ALIGN(sp);
+	strlcpy((char *)sp, path, PATH_MAX);
+	file = (char *)sp;
+
+	/* arg/env */
+	sp -= msg->bufsz;
+	sp = SP_ALIGN(sp);
+	memcpy((char *)sp, (char *)&msg->buf, msg->bufsz);
+	arg_top = sp;
+
+	/*
+	 * Insert extra argument for indirect loader.
+	 */
+	if (xarg2 != NULL) {
+		len = strlen(xarg2);
+		sp -= (len + 1);
+		strlcpy((char *)sp, xarg2, len + 1);
+		arg_top = sp;
+		argc++;
+	}
+	if (xarg1 != NULL) {
+		len = strlen(xarg1);
+		sp -= (len + 1);
+		strlcpy((char *)sp, xarg1, len + 1);
+		arg_top = sp;
+		argc++;
+	}
+
+	/* envp[] */
+	sp -= ((envc + 1) * sizeof(char *));
+	envp = (char **)sp;
+
+	/* argv[] */
+	sp -= ((argc + 1) * sizeof(char *));
+	argv = (char **)sp;
+
+	/* argc */
+	sp -= sizeof(int);
+	*(int *)(sp) = argc + 1;
+
+	/*
+	 * Build argument list
+	 */
+	argv[0] = (char *)((u_long)stack + (u_long)file - mapped);
+
+	for (i = 1; i <= argc; i++) {
+		argv[i] = (char *)((u_long)stack + (arg_top - mapped));
+		while ((*(char *)arg_top++) != '\0');
+	}
+	argv[argc + 1] = NULL;
+
+	for (i = 0; i < envc; i++) {
+		envp[i] = (char *)((u_long)stack + (arg_top - mapped));
+		while ((*(char *)arg_top++) != '\0');
+	}
+	envp[envc] = NULL;
+
+	*new_sp = (void *)((u_long)stack + (sp - mapped));
+	vm_free(task_self(), (void *)mapped);
+
+	return 0;
+}
+
+/*
+ * Notify exec() to servers.
+ */
+static void
+notify_server(task_t org_task, task_t new_task, void *stack)
+{
+	struct msg m;
+	int error;
+	object_t fsobj, procobj;
+
+	if (object_lookup("!fs", &fsobj) != 0)
+		return;
+
+	if (object_lookup("!proc", &procobj) != 0)
+		return;
+
+	/* Notify to file system server */
+	do {
+		m.hdr.code = FS_EXEC;
+		m.data[0] = (int)org_task;
+		m.data[1] = (int)new_task;
+		error = msg_send(fsobj, &m, sizeof(m));
+	} while (error == EINTR);
+
+	/* Notify to process server */
+	do {
+		m.hdr.code = PS_EXEC;
+		m.data[0] = (int)org_task;
+		m.data[1] = (int)new_task;
+		m.data[2] = (int)stack;
+		error = msg_send(procobj, &m, sizeof(m));
+	} while (error == EINTR);
+}
+
+static int
+read_header(char *path)
+{
+	int fd;
+	struct stat st;
+
+	/*
+	 * Check target file type.
+	 */
+	if ((fd = open(path, O_RDONLY)) == -1)
+		return ENOENT;
+
+	if (fstat(fd, &st) == -1) {
+		close(fd);
+		return EIO;
+	}
+	if (!S_ISREG(st.st_mode)) {
+		DPRINTF(("exec: not regular file\n"));
+		close(fd);
+		return EACCES;	/* must be regular file */
+	}
+	/*
+	 * Read file header.
+	 */
+	memset(hdrbuf, 0, HEADER_SIZE);
+	if (read(fd, hdrbuf, HEADER_SIZE) == -1) {
+		close(fd);
+		return EIO;
+	}
+	close(fd);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/exec/exec_script.c b/prex-0.9.0/usr/server/exec/exec_script.c
new file mode 100755
index 0000000..5d8492d
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/exec_script.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exec_script.c - Script file loader
+ */
+
+#include <sys/prex.h>
+#include <ipc/fs.h>
+#include <ipc/proc.h>
+#include <sys/param.h>
+
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "exec.h"
+
+static char interp[PATH_MAX];		/* interpreter name */
+static char intarg[LINE_MAX];		/* argument to interpreter */
+static char script[LINE_MAX];		/* script name */
+
+/*
+ * Load script file
+ */
+int
+script_load(struct exec *exec)
+{
+
+	return 0;
+}
+
+/*
+ * Probe script file
+ */
+int
+script_probe(struct exec *exec)
+{
+	char *hdrstr = exec->header;
+	char *p, *name;
+
+	/* Check magic header */
+	if ((hdrstr[0] != '#') || (hdrstr[1] != '!'))
+		return PROBE_ERROR;
+
+	/* Strip spaces before the interpriter name */
+	for (p = hdrstr + 2; *p == ' ' || *p == '\t'; p++)
+		;
+	if (*p == '\0')
+		return PROBE_ERROR;
+
+	DPRINTF(("script_probe: found\n"));
+
+	/* Pick up interpreter name */
+	name = p;
+	for (; *p != '\0' && *p != ' ' && *p != '\t'; p++)
+		;
+	*p++ = '\0';
+
+	if (!strncmp(name, "/bin/sh", PATH_MAX)) {
+		strlcpy(interp, "/boot/cmdbox", sizeof(interp));
+		strlcpy(intarg, "sh", sizeof(intarg));
+		exec->xarg1 = intarg;
+		exec->xarg2 = script;
+	} else {
+		strlcpy(interp, name, sizeof(interp));
+		exec->xarg1 = intarg;
+		exec->xarg2 = NULL;
+	}
+	strlcpy(script, exec->path, sizeof(script));
+	exec->path = interp;
+
+	DPRINTF(("script_probe: interpreter=%s arg=%s script=%s\n",
+		 interp, intarg, script));
+
+	return PROBE_INDIRECT;
+}
+
+void
+script_init(void)
+{
+}
diff --git a/prex-0.9.0/usr/server/exec/main.c b/prex-0.9.0/usr/server/exec/main.c
new file mode 100755
index 0000000..fe9dc33
--- /dev/null
+++ b/prex-0.9.0/usr/server/exec/main.c
@@ -0,0 +1,235 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Exec server - Execute various types of image files.
+ */
+
+#include <sys/prex.h>
+#include <sys/capability.h>
+#include <ipc/fs.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+#include <sys/list.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "exec.h"
+
+/* forward declarations */
+static int exec_null(struct msg *);
+static int exec_debug(struct msg *);
+static int exec_boot(struct msg *);
+static int exec_shutdown(struct msg *);
+
+/*
+ * Message mapping
+ */
+struct msg_map {
+	int	code;
+	int	(*func)(struct msg *);
+};
+
+#define MSGMAP(code, fn) {code, (int (*)(struct msg *))fn}
+
+static const struct msg_map execmsg_map[] = {
+	MSGMAP(EXEC_EXECVE,	exec_execve),
+	MSGMAP(EXEC_BINDCAP,	exec_bindcap),
+	MSGMAP(STD_BOOT,	exec_boot),
+	MSGMAP(STD_SHUTDOWN,	exec_shutdown),
+	MSGMAP(STD_DEBUG,	exec_debug),
+	MSGMAP(0,		exec_null),
+};
+
+static void
+register_process(void)
+{
+	struct msg m;
+	object_t obj;
+	int error;
+
+	error = object_lookup("!proc", &obj);
+	if (error)
+		sys_panic("exec: no proc");
+
+	m.hdr.code = PS_REGISTER;
+	msg_send(obj, &m, sizeof(m));
+}
+
+static int
+exec_null(struct msg *msg)
+{
+
+	return 0;
+}
+
+static int
+exec_boot(struct msg *msg)
+{
+
+	/* Check client's capability. */
+	if (task_chkcap(msg->hdr.task, CAP_PROTSERV) != 0)
+		return EPERM;
+
+	/* Register to process server */
+	register_process();
+
+	/* Register to file server */
+	fslib_init();
+
+	return 0;
+}
+
+static int
+exec_debug(struct msg *msg)
+{
+
+#ifdef DEBUG
+	/* mstat(); */
+#endif
+	return 0;
+}
+
+static int
+exec_shutdown(struct msg *msg)
+{
+
+	DPRINTF(("exec_shutdown\n"));
+	return 0;
+}
+
+/*
+ * Initialize all exec loaders.
+ */
+static void
+exec_init(void)
+{
+	struct exec_loader *ldr;
+	int i;
+
+	for (i = 0; i < nloader; i++) {
+		ldr = &loader_table[i];
+		DPRINTF(("Initialize \'%s\' loader\n", ldr->el_name));
+		ldr->el_init();
+	}
+}
+
+static void
+exception_handler(int sig)
+{
+
+	exception_return();
+}
+
+/*
+ * Main routine for exec service.
+ */
+int
+main(int argc, char *argv[])
+{
+	const struct msg_map *map;
+	struct msg *msg;
+	object_t obj;
+	int error;
+
+	sys_log("Starting exec server\n");
+
+	/* Boost thread priority. */
+	thread_setpri(thread_self(), PRI_EXEC);
+
+	/*
+	 * Set capability for us
+	 */
+	bind_cap("/boot/exec", task_self());
+
+	/*
+	 * Setup exception handler.
+	 */
+	exception_setup(exception_handler);
+
+	/*
+	 * Initialize exec loaders.
+	 */
+	exec_init();
+
+	/*
+	 * Create an object to expose our service.
+	 */
+	error = object_create("!exec", &obj);
+	if (error)
+		sys_panic("fail to create object");
+
+	msg = malloc(MAX_EXECMSG);
+	ASSERT(msg);
+
+	/*
+	 * Message loop
+	 */
+	for (;;) {
+		/*
+		 * Wait for an incoming request.
+		 */
+		error = msg_receive(obj, msg, MAX_EXECMSG);
+		if (error)
+			continue;
+
+		error = EINVAL;
+		map = &execmsg_map[0];
+		while (map->code != 0) {
+			if (map->code == msg->hdr.code) {
+				error = (*map->func)(msg);
+				break;
+			}
+			map++;
+		}
+#ifdef DEBUG_EXEC
+		if (error)
+			DPRINTF(("exec: msg error=%d code=%x\n",
+				 error, msg->hdr.code));
+#endif
+		/*
+		 * Reply to the client.
+		 *
+		 * Note: If EXEC_EXECVE request is handled successfully,
+		 * the receiver task has been terminated here. But, we
+		 * have to call msg_reply() even in such case to reset
+		 * our IPC state.
+		 */
+		msg->hdr.status = error;
+		error = msg_reply(obj, msg, MAX_EXECMSG);
+	}
+}
diff --git a/prex-0.9.0/usr/server/fs/Makefile b/prex-0.9.0/usr/server/fs/Makefile
new file mode 100755
index 0000000..a47e187
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/Makefile
@@ -0,0 +1,32 @@
+include $(SRCDIR)/mk/own.mk
+
+PROG:=		fs
+SUBDIR:=	vfs
+OBJS:=		vfs/vfscore.o
+
+#DISASM= 	fs.lst
+#MAP= 		fs.map
+#SYMBOL= 	fs.sym
+
+ifeq ($(CONFIG_DEVFS),y)
+SUBDIR+=	devfs
+OBJS+=		devfs/devfs.o
+endif
+ifeq ($(CONFIG_RAMFS),y)
+SUBDIR+=	ramfs
+OBJS+=		ramfs/ramfs.o
+endif
+ifeq ($(CONFIG_ARFS),y)
+SUBDIR+=	arfs
+OBJS+=		arfs/arfs.o
+endif
+ifeq ($(CONFIG_FIFOFS),y)
+SUBDIR+=	fifofs
+OBJS+=		fifofs/fifofs.o
+endif
+ifeq ($(CONFIG_FATFS),y)
+SUBDIR+=	fatfs
+OBJS+=		fatfs/fatfs.o
+endif
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/server/fs/arfs/Makefile b/prex-0.9.0/usr/server/fs/arfs/Makefile
new file mode 100755
index 0000000..99fbbad
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/arfs/Makefile
@@ -0,0 +1,4 @@
+TARGET=		arfs.o
+SRCS=		arfs_vfsops.c arfs_vnops.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/server/fs/arfs/arfs.h b/prex-0.9.0/usr/server/fs/arfs/arfs.h
new file mode 100755
index 0000000..a580968
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/arfs/arfs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARFS_H
+#define _ARFS_H
+
+#include <sys/prex.h>
+#include <sys/types.h>
+
+#include <assert.h>
+
+/* #define DEBUG_ARFS 1 */
+
+#ifdef DEBUG_ARFS
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)	do {} while (0)
+#define ASSERT(e)
+#endif
+
+#if CONFIG_FS_THREADS > 1
+#define malloc(s)	malloc_r(s)
+#define free(p)		free_r(p)
+#else
+#define mutex_init(m)		do {} while (0)
+#define mutex_destroy(m)	do {} while (0)
+#define mutex_lock(m)		do {} while (0)
+#define mutex_unlock(m)		do {} while (0)
+#define mutex_trylock(m)	do {} while (0)
+#endif
+
+#endif /* !_ARFS_H */
diff --git a/prex-0.9.0/usr/server/fs/arfs/arfs_vfsops.c b/prex-0.9.0/usr/server/fs/arfs/arfs_vfsops.c
new file mode 100755
index 0000000..b9b2a04
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/arfs/arfs_vfsops.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * arfs_vfsops.c - vfs operations for archive file system.
+ */
+
+#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/param.h>
+#include <sys/buf.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <ar.h>
+
+#include "arfs.h"
+
+extern struct vnops arfs_vnops;
+
+
+static int arfs_mount	(mount_t mp, char *dev, int flags, void *data);
+static int arfs_unmount	(mount_t mp);
+#define arfs_sync	((vfsop_sync_t)vfs_nullop)
+#define arfs_vget	((vfsop_vget_t)vfs_nullop)
+#define arfs_statfs	((vfsop_statfs_t)vfs_nullop)
+
+/*
+ * File system operations
+ */
+const struct vfsops arfs_vfsops = {
+	arfs_mount,		/* mount */
+	arfs_unmount,		/* unmount */
+	arfs_sync,		/* sync */
+	arfs_vget,		/* vget */
+	arfs_statfs,		/* statfs */
+	&arfs_vnops,		/* vnops */
+};
+
+/*
+ * Mount a file system.
+ */
+static int
+arfs_mount(mount_t mp, char *dev, int flags, void *data)
+{
+	size_t size;
+	char *buf;
+	int error = 0;
+
+	DPRINTF(("arfs_mount: dev=%s\n", dev));
+
+	if ((buf = malloc(BSIZE)) == NULL)
+		return ENOMEM;
+
+	/* Read first block */
+	size = BSIZE;
+	error = device_read((device_t)mp->m_dev, buf, &size, 0);
+	if (error) {
+		DPRINTF(("arfs_mount: read error=%d\n", error));
+		goto out;
+	}
+
+	/* Check if the device includes valid archive image. */
+	if (strncmp(buf, ARMAG, SARMAG)) {
+		DPRINTF(("arfs_mount: invalid archive image!\n"));
+		error = EINVAL;
+		goto out;
+	}
+
+	/* Ok, we find the archive */
+	mp->m_flags |= MNT_RDONLY;
+ out:
+	free(buf);
+	return error;
+}
+
+static int
+arfs_unmount(mount_t mp)
+{
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/arfs/arfs_vnops.c b/prex-0.9.0/usr/server/fs/arfs/arfs_vnops.c
new file mode 100755
index 0000000..1645256
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/arfs/arfs_vnops.c
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * arfs_vnops.c - vnode operations for archive file system.
+ */
+
+/**
+ * General design:
+ *
+ * ARFS (ARchive File System) is the read-only file system which
+ * handles the generic archive (*.a) file as a file system image.
+ * The file system is typically used for the boot time file system,
+ * and it's mounted to the ram disk device mapped to the pre-loaded
+ * archive file image. All files are placed in one single directory.
+ */
+
+#include <sys/prex.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/param.h>
+#include <sys/dirent.h>
+#include <sys/buf.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <ar.h>
+
+#include "arfs.h"
+
+#define arfs_open	((vnop_open_t)vop_nullop)
+#define arfs_close	((vnop_close_t)vop_nullop)
+static int arfs_read	(vnode_t, file_t, void *, size_t, size_t *);
+#define arfs_write	((vnop_write_t)vop_nullop)
+static int arfs_seek	(vnode_t, file_t, off_t, off_t);
+#define arfs_ioctl	((vnop_ioctl_t)vop_einval)
+#define arfs_fsync	((vnop_fsync_t)vop_nullop)
+static int arfs_readdir	(vnode_t, file_t, struct dirent *);
+static int arfs_lookup	(vnode_t, char *, vnode_t);
+#define arfs_create	((vnop_create_t)vop_einval)
+#define arfs_remove	((vnop_remove_t)vop_einval)
+#define arfs_rename	((vnop_rename_t)vop_einval)
+#define arfs_mkdir	((vnop_mkdir_t)vop_einval)
+#define arfs_rmdir	((vnop_rmdir_t)vop_einval)
+#define arfs_getattr	((vnop_getattr_t)vop_nullop)
+#define arfs_setattr	((vnop_setattr_t)vop_nullop)
+#define arfs_inactive	((vnop_inactive_t)vop_nullop)
+#define arfs_truncate	((vnop_truncate_t)vop_nullop)
+
+static char iobuf[BSIZE*2];
+
+#if CONFIG_FS_THREADS > 1
+static mutex_t arfs_lock = MUTEX_INITIALIZER;
+#endif
+
+/*
+ * vnode operations
+ */
+const struct vnops arfs_vnops = {
+	arfs_open,		/* open */
+	arfs_close,		/* close */
+	arfs_read,		/* read */
+	arfs_write,		/* write */
+	arfs_seek,		/* seek */
+	arfs_ioctl,		/* ioctl */
+	arfs_fsync,		/* fsync */
+	arfs_readdir,		/* readdir */
+	arfs_lookup,		/* lookup */
+	arfs_create,		/* create */
+	arfs_remove,		/* remove */
+	arfs_rename,		/* remame */
+	arfs_mkdir,		/* mkdir */
+	arfs_rmdir,		/* rmdir */
+	arfs_getattr,		/* getattr */
+	arfs_setattr,		/* setattr */
+	arfs_inactive,		/* inactive */
+	arfs_truncate,		/* truncate */
+};
+
+/*
+ * Read blocks.
+ * iobuf is filled by read data.
+ */
+static int
+arfs_readblk(mount_t mp, int blkno)
+{
+	struct buf *bp;
+	int error;
+
+	/*
+	 * Read two blocks for archive header
+	 */
+	if ((error = bread(mp->m_dev, blkno, &bp)) != 0)
+		return error;
+	memcpy(iobuf, bp->b_data, BSIZE);
+	brelse(bp);
+
+	if ((error = bread(mp->m_dev, blkno + 1, &bp)) != 0)
+		return error;
+	memcpy(iobuf + BSIZE, bp->b_data, BSIZE);
+	brelse(bp);
+
+	return 0;
+}
+
+/*
+ * Lookup vnode for the specified file/directory.
+ * The vnode is filled properly.
+ */
+static int
+arfs_lookup(vnode_t dvp, char *name, vnode_t vp)
+{
+	struct ar_hdr *hdr;
+	int blkno, error;
+	off_t off;
+	size_t size;
+	mount_t mp;
+	char *p;
+
+	DPRINTF(("arfs_lookup: name=%s\n", name));
+	if (*name == '\0')
+		return ENOENT;
+
+	mutex_lock(&arfs_lock);
+
+	error = ENOENT;
+	mp = vp->v_mount;
+	blkno = 0;
+	off = SARMAG;	/* offset in archive image */
+	for (;;) {
+		/* Read two blocks for archive header */
+		if (arfs_readblk(mp, blkno) != 0)
+			goto out;
+
+		/* Check file header */
+		hdr = (struct ar_hdr *)(iobuf + (off % BSIZE));
+		if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(ARFMAG) - 1))
+			goto out;
+
+		/* Get file size */
+		size = (size_t)atol((char *)&hdr->ar_size);
+		if (size == 0)
+			goto out;
+
+		/* Convert archive name */
+		if ((p = memchr(&hdr->ar_name, '/', 16)) != NULL)
+			*p = '\0';
+
+		if (strncmp(name, (char *)&hdr->ar_name, 16) == 0)
+			break;
+
+		/* Proceed to next archive header */
+		off += (sizeof(struct ar_hdr) + size);
+		off += (off % 2); /* Pad to even boundary */
+
+		blkno = (int)(off / BSIZE);
+	}
+	vp->v_type = VREG;
+
+	/* No write access */
+	vp->v_mode = (mode_t)(S_IRUSR | S_IXUSR);
+	vp->v_size = size;
+	vp->v_blkno = blkno;
+	vp->v_data = (void *)(off + sizeof(struct ar_hdr));
+	error = 0;
+ out:
+	mutex_unlock(&arfs_lock);
+	DPRINTF(("arfs_lookup: error=%d\n\n", error));
+	return error;
+}
+
+static int
+arfs_read(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	off_t off, file_pos, buf_pos;
+	int blkno, error;
+	size_t nr_read, nr_copy;
+	mount_t mp;
+	struct buf *bp;
+
+	DPRINTF(("arfs_read: start size=%d\n", size));
+	mutex_lock(&arfs_lock);
+
+	*result = 0;
+	mp = vp->v_mount;
+
+	/* Check if current file position is already end of file. */
+	file_pos = fp->f_offset;
+	if (file_pos >= (off_t)vp->v_size) {
+		error = 0;
+		goto out;
+	}
+	/* Get the actual read size. */
+	if (vp->v_size - file_pos < size)
+		size = vp->v_size - file_pos;
+
+	/* Read and copy data */
+	off = (off_t)vp->v_data;
+	nr_read = 0;
+	for (;;) {
+		DPRINTF(("arfs_read: file_pos=%d buf=%x size=%d\n",
+			 file_pos, buf, size));
+
+		blkno = (off + file_pos) / BSIZE;
+		buf_pos = (off + file_pos) % BSIZE;
+		if ((error = bread(mp->m_dev, blkno, &bp)) != 0)
+			goto out;
+		nr_copy = BSIZE;
+		if (buf_pos > 0)
+			nr_copy -= buf_pos;
+		if (buf_pos + size < BSIZE)
+			nr_copy = size;
+		ASSERT(nr_copy > 0);
+		memcpy(buf, bp->b_data + buf_pos, nr_copy);
+		brelse(bp);
+
+		file_pos += nr_copy;
+		DPRINTF(("arfs_read: file_pos=%d nr_copy=%d\n",
+			 file_pos, nr_copy));
+
+		nr_read += nr_copy;
+		size -= nr_copy;
+		if (size <= 0)
+			break;
+		buf = (void *)((u_long)buf + nr_copy);
+		buf_pos = 0;
+	}
+	fp->f_offset = file_pos;
+	*result = nr_read;
+	error = 0;
+ out:
+	mutex_unlock(&arfs_lock);
+	DPRINTF(("arfs_read: error=%d\n\n", error));
+	return error;
+}
+
+/*
+ * Check if the seek offset is valid.
+ */
+static int
+arfs_seek(vnode_t vp, file_t fp, off_t oldoff, off_t newoff)
+{
+
+	if (newoff > (off_t)vp->v_size)
+		return -1;
+
+	return 0;
+}
+
+static int
+arfs_readdir(vnode_t vp, file_t fp, struct dirent *dir)
+{
+	struct ar_hdr *hdr;
+	int blkno, i, error;
+	off_t off;
+	size_t size;
+	mount_t mp;
+	char *p;
+
+	DPRINTF(("arfs_readdir: start\n"));
+	mutex_lock(&arfs_lock);
+
+	i = 0;
+	mp = vp->v_mount;
+	blkno = 0;
+	off = SARMAG;	/* offset in archive image */
+	for (;;) {
+		/* Read two blocks for archive header */
+		if ((error = arfs_readblk(mp, blkno)) != 0)
+			goto out;
+
+		hdr = (struct ar_hdr *)(iobuf + (off % BSIZE));
+
+		/* Get file size */
+		size = (size_t)atol((char *)&hdr->ar_size);
+		if (size == 0) {
+			error = ENOENT;
+			goto out;
+		}
+		if (i == fp->f_offset)
+			break;
+
+		/* Proceed to next archive header */
+		off += (sizeof(struct ar_hdr) + size);
+		off += (off % 2); /* Pad to even boundary */
+
+		blkno = off / BSIZE;
+		i++;
+	}
+
+	/* Convert archive name */
+	if ((p = memchr(&hdr->ar_name, '/', 16)) != NULL)
+		*p = '\0';
+
+	strlcpy((char *)&dir->d_name, (char *)&hdr->ar_name,
+		sizeof(dir->d_name));
+	dir->d_namlen = (uint16_t)strlen(dir->d_name);
+	dir->d_fileno = (uint32_t)fp->f_offset;
+	dir->d_type = DT_REG;
+
+	fp->f_offset++;
+	error = 0;
+ out:
+	mutex_unlock(&arfs_lock);
+	return error;
+}
+
+
+int
+arfs_init(void)
+{
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/devfs/Makefile b/prex-0.9.0/usr/server/fs/devfs/Makefile
new file mode 100755
index 0000000..6c40932
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/devfs/Makefile
@@ -0,0 +1,4 @@
+TARGET=		devfs.o
+SRCS=		devfs_vnops.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/server/fs/devfs/devfs.h b/prex-0.9.0/usr/server/fs/devfs/devfs.h
new file mode 100755
index 0000000..baae199
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/devfs/devfs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _DEVFS_H
+#define _DEVFS_H
+
+#include <sys/prex.h>
+#include <sys/types.h>
+
+#include <assert.h>
+
+/* #define DEBUG_DEVFS 1 */
+
+#ifdef DEBUG_DEVFS
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)	do {} while (0)
+#define ASSERT(e)
+#endif
+
+#if CONFIG_FS_THREADS > 1
+#define malloc(s)		malloc_r(s)
+#define free(p)			free_r(p)
+#else
+#define mutex_init(m)		do {} while (0)
+#define mutex_destroy(m)	do {} while (0)
+#define mutex_lock(m)		do {} while (0)
+#define mutex_unlock(m)		do {} while (0)
+#define mutex_trylock(m)	do {} while (0)
+#endif
+
+#endif /* !_DEVFS_H */
diff --git a/prex-0.9.0/usr/server/fs/devfs/devfs_vnops.c b/prex-0.9.0/usr/server/fs/devfs/devfs_vnops.c
new file mode 100755
index 0000000..2fb4c39
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/devfs/devfs_vnops.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * devfs - device file system.
+ */
+
+#include <sys/prex.h>
+#include <sys/device.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/syslog.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <fcntl.h>
+
+#include "devfs.h"
+
+
+#define devfs_mount	((vfsop_mount_t)vfs_nullop)
+#define devfs_unmount	((vfsop_umount_t)vfs_nullop)
+#define devfs_sync	((vfsop_sync_t)vfs_nullop)
+#define devfs_vget	((vfsop_vget_t)vfs_nullop)
+#define devfs_statfs	((vfsop_statfs_t)vfs_nullop)
+
+static int devfs_open	(vnode_t, int);
+static int devfs_close	(vnode_t, file_t);
+static int devfs_read	(vnode_t, file_t, void *, size_t, size_t *);
+static int devfs_write	(vnode_t, file_t, void *, size_t, size_t *);
+#define devfs_seek	((vnop_seek_t)vop_nullop)
+static int devfs_ioctl	(vnode_t, file_t, u_long, void *);
+#define devfs_fsync	((vnop_fsync_t)vop_nullop)
+static int devfs_readdir(vnode_t, file_t, struct dirent *);
+static int devfs_lookup	(vnode_t, char *, vnode_t);
+#define devfs_create	((vnop_create_t)vop_einval)
+#define devfs_remove	((vnop_remove_t)vop_einval)
+#define devfs_rename	((vnop_rename_t)vop_einval)
+#define devfs_mkdir	((vnop_mkdir_t)vop_einval)
+#define devfs_rmdir	((vnop_rmdir_t)vop_einval)
+#define devfs_getattr	((vnop_getattr_t)vop_nullop)
+#define devfs_setattr	((vnop_setattr_t)vop_nullop)
+#define devfs_inactive	((vnop_inactive_t)vop_nullop)
+#define devfs_truncate	((vnop_truncate_t)vop_nullop)
+
+/*
+ * vnode operations
+ */
+struct vnops devfs_vnops = {
+	devfs_open,		/* open */
+	devfs_close,		/* close */
+	devfs_read,		/* read */
+	devfs_write,		/* write */
+	devfs_seek,		/* seek */
+	devfs_ioctl,		/* ioctl */
+	devfs_fsync,		/* fsync */
+	devfs_readdir,		/* readdir */
+	devfs_lookup,		/* lookup */
+	devfs_create,		/* create */
+	devfs_remove,		/* remove */
+	devfs_rename,		/* remame */
+	devfs_mkdir,		/* mkdir */
+	devfs_rmdir,		/* rmdir */
+	devfs_getattr,		/* getattr */
+	devfs_setattr,		/* setattr */
+	devfs_inactive,		/* inactive */
+	devfs_truncate,		/* truncate */
+};
+
+/*
+ * File system operations
+ */
+struct vfsops devfs_vfsops = {
+	devfs_mount,		/* mount */
+	devfs_unmount,		/* unmount */
+	devfs_sync,		/* sync */
+	devfs_vget,		/* vget */
+	devfs_statfs,		/* statfs */
+	&devfs_vnops,		/* vnops */
+};
+
+static int
+devfs_open(vnode_t vp, int flags)
+{
+	char *path;
+	device_t dev;
+	int error;
+
+	DPRINTF(("devfs_open: path=%s\n", vp->v_path));
+
+	path = vp->v_path;
+	if (!strcmp(path, "/"))	/* root ? */
+		return 0;
+
+	if (vp->v_flags & VPROTDEV) {
+		DPRINTF(("devfs_open: failed to open protected device.\n"));
+		return EPERM;
+	}
+	if (*path == '/')
+		path++;
+	error = device_open(path, flags & DO_RWMASK, &dev);
+	if (error) {
+		DPRINTF(("devfs_open: can not open device = %s error=%d\n",
+			 path, error));
+		return error;
+	}
+	vp->v_data = (void *)dev;	/* Store private data */
+	return 0;
+}
+
+static int
+devfs_close(vnode_t vp, file_t fp)
+{
+
+	DPRINTF(("devfs_close: fp=%x\n", fp));
+
+	if (!strcmp(vp->v_path, "/"))	/* root ? */
+		return 0;
+
+	return device_close((device_t)vp->v_data);
+}
+
+static int
+devfs_read(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	int error;
+	size_t len;
+
+	len = size;
+	error = device_read((device_t)vp->v_data, buf, &len, fp->f_offset);
+	if (!error)
+		*result = len;
+	return error;
+}
+
+static int
+devfs_write(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	int error;
+	size_t len;
+
+	len = size;
+	error = device_write((device_t)vp->v_data, buf, &len, fp->f_offset);
+	if (!error)
+		*result = len;
+	DPRINTF(("devfs_write: error=%d len=%d\n", error, len));
+	return error;
+}
+
+static int
+devfs_ioctl(vnode_t vp, file_t fp, u_long cmd, void *arg)
+{
+	int error;
+
+	error = device_ioctl((device_t)vp->v_data, cmd, arg);
+	DPRINTF(("devfs_ioctl: cmd=%x\n", cmd));
+	return error;
+}
+
+static int
+devfs_lookup(vnode_t dvp, char *name, vnode_t vp)
+{
+	struct devinfo info;
+	int error, i;
+
+	DPRINTF(("devfs_lookup:%s\n", name));
+
+	if (*name == '\0')
+		return ENOENT;
+
+	i = 0;
+	error = 0;
+	info.cookie = 0;
+	for (;;) {
+		error = sys_info(INFO_DEVICE, &info);
+		if (error)
+			return ENOENT;
+		if (!strncmp(info.name, name, MAXDEVNAME))
+			break;
+		i++;
+	}
+	vp->v_type = (info.flags & D_CHR) ? VCHR : VBLK;
+	if (info.flags & D_TTY)
+		vp->v_flags |= VISTTY;
+
+	if (info.flags & D_PROT)
+		vp->v_flags |= VPROTDEV;
+	else
+		vp->v_mode = (mode_t)(S_IRUSR | S_IWUSR);
+	return 0;
+}
+
+/*
+ * @vp: vnode of the directory.
+ */
+static int
+devfs_readdir(vnode_t vp, file_t fp, struct dirent *dir)
+{
+	struct devinfo info;
+	int error, i;
+
+	DPRINTF(("devfs_readdir offset=%d\n", fp->f_offset));
+
+	i = 0;
+	error = 0;
+	info.cookie = 0;
+	do {
+		error = sys_info(INFO_DEVICE, &info);
+		if (error)
+			return ENOENT;
+	} while (i++ != fp->f_offset);
+
+	dir->d_type = 0;
+	if (info.flags & D_CHR)
+		dir->d_type = DT_CHR;
+	else if (info.flags & D_BLK)
+		dir->d_type = DT_BLK;
+	strlcpy((char *)&dir->d_name, info.name, sizeof(dir->d_name));
+	dir->d_fileno = (uint32_t)fp->f_offset;
+	dir->d_namlen = (uint16_t)strlen(dir->d_name);
+
+	DPRINTF(("devfs_readdir: %s\n", dir->d_name));
+	fp->f_offset++;
+	return 0;
+}
+
+int
+devfs_init(void)
+{
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/fatfs/Makefile b/prex-0.9.0/usr/server/fs/fatfs/Makefile
new file mode 100755
index 0000000..0698b20
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/Makefile
@@ -0,0 +1,5 @@
+TARGET=		fatfs.o
+SRCS=		fatfs_fat.c fatfs_node.c fatfs_vfsops.c \
+		fatfs_vnops.c fatfs_subr.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/server/fs/fatfs/fatfs.h b/prex-0.9.0/usr/server/fs/fatfs/fatfs.h
new file mode 100755
index 0000000..1d40388
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/fatfs.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _FATFS_H
+#define _FATFS_H
+
+#include <sys/prex.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/syslog.h>
+#include <sys/buf.h>
+
+/* #define DEBUG_FATFS 1 */
+
+#ifdef DEBUG_FATFS
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)	do {} while (0)
+#define ASSERT(e)
+#endif
+
+
+#if CONFIG_FS_THREADS > 1
+#define malloc(s)		malloc_r(s)
+#define free(p)			free_r(p)
+#else
+#define mutex_init(m)		do {} while (0)
+#define mutex_destroy(m)	do {} while (0)
+#define mutex_lock(m)		do {} while (0)
+#define mutex_unlock(m)		do {} while (0)
+#define mutex_trylock(m)	do {} while (0)
+#endif
+
+
+#define SEC_SIZE	512		/* sector size */
+#define SEC_INVAL	0xffffffff	/* invalid sector */
+
+/*
+ * Pre-defined cluster number
+ */
+#define CL_ROOT		0		/* cluster 0 means the root directory */
+#define CL_FREE		0		/* cluster 0 also means the free cluster */
+#define CL_FIRST	2		/* first legal cluster */
+#define CL_LAST		0xfffffff5	/* last legal cluster */
+#define CL_EOF		0xffffffff	/* EOF cluster */
+
+#define EOF_MASK	0xfffffff8	/* mask of eof */
+
+#define FAT12_MASK	0x00000fff
+#define FAT16_MASK	0x0000ffff
+
+#if defined(__SUNPRO_C)
+#pragma pack(1)
+#endif
+
+/*
+ * BIOS parameter block
+ */
+struct fat_bpb {
+	uint16_t	jmp_instruction;
+	uint8_t		nop_instruction;
+	uint8_t		oem_id[8];
+	uint16_t	bytes_per_sector;
+	uint8_t		sectors_per_cluster;
+	uint16_t	reserved_sectors;
+	uint8_t		num_of_fats;
+	uint16_t	root_entries;
+	uint16_t	total_sectors;
+	uint8_t		media_descriptor;
+	uint16_t	sectors_per_fat;
+	uint16_t	sectors_per_track;
+	uint16_t	heads;
+	uint32_t	hidden_sectors;
+	uint32_t	big_total_sectors;
+	uint8_t		physical_drive;
+	uint8_t		reserved;
+	uint8_t		ext_boot_signature;
+	uint32_t	serial_no;
+	uint8_t		volume_id[11];
+	uint8_t		file_sys_id[8];
+} __packed;
+
+/*
+ * FAT directory entry
+ */
+struct fat_dirent {
+	uint8_t		name[11];
+	uint8_t		attr;
+	uint8_t		reserve[10];
+	uint16_t	time;
+	uint16_t	date;
+	uint16_t	cluster;
+	uint32_t	size;
+} __packed;
+
+#if defined(__SUNPRO_C)
+#pragma pack()
+#endif
+
+#define SLOT_EMPTY	0x00
+#define SLOT_DELETED	0xe5
+
+#define DIR_PER_SEC     (SEC_SIZE / sizeof(struct fat_dirent))
+
+/*
+ * FAT attribute for attr
+ */
+#define FA_RDONLY	0x01
+#define FA_HIDDEN	0x02
+#define FA_SYSTEM	0x04
+#define FA_VOLID	0x08
+#define FA_SUBDIR	0x10
+#define FA_ARCH		0x20
+#define FA_DEVICE	0x40
+
+#define IS_DIR(de)	(((de)->attr) & FA_SUBDIR)
+#define IS_VOL(de)	(((de)->attr) & FA_VOLID)
+#define IS_FILE(de)	(!IS_DIR(de) && !IS_VOL(de))
+
+#define IS_DELETED(de)  ((de)->name[0] == 0xe5)
+#define IS_EMPTY(de)    ((de)->name[0] == 0)
+
+/*
+ * Mount data
+ */
+struct fatfsmount {
+	int	fat_type;	/* 12 or 16 */
+	u_long	root_start;	/* start sector for root directory */
+	u_long	fat_start;	/* start sector for fat entries */
+	u_long	data_start;	/* start sector for data */
+	u_long	fat_eof;	/* id of end cluster */
+	u_long	sec_per_cl;	/* sectors per cluster */
+	u_long	cluster_size;	/* cluster size */
+	u_long	last_cluster;	/* last cluser */
+	u_long	fat_mask;	/* mask for cluster# */
+	u_long	free_scan;	/* start cluster# to free search */
+	vnode_t	root_vnode;	/* vnode for root */
+	char	*io_buf;	/* local data buffer */
+	char	*fat_buf;	/* buffer for fat entry */
+	char	*dir_buf;	/* buffer for directory entry */
+	dev_t	dev;		/* mounted device */
+#if CONFIG_FS_THREADS > 1
+	mutex_t lock;		/* file system lock */
+#endif
+};
+
+#define FAT12(fat)	((fat)->fat_type == 12)
+#define FAT16(fat)	((fat)->fat_type == 16)
+
+#define IS_EOFCL(fat, cl) \
+	(((cl) & EOF_MASK) == ((fat)->fat_mask & EOF_MASK))
+
+/*
+ * File/directory node
+ */
+struct fatfs_node {
+	struct fat_dirent dirent; /* copy of directory entry */
+	u_long	sector;		/* sector# for directory entry */
+	u_long	offset;		/* offset of directory entry in sector */
+};
+
+extern struct vnops fatfs_vnops;
+
+/* Macro to convert cluster# to logical sector# */
+#define cl_to_sec(fat, cl) \
+            (fat->data_start + (cl - 2) * fat->sec_per_cl)
+
+__BEGIN_DECLS
+int	 fat_next_cluster(struct fatfsmount *fmp, u_long cl, u_long *next);
+int	 fat_set_cluster(struct fatfsmount *fmp, u_long cl, u_long next);
+int	 fat_alloc_cluster(struct fatfsmount *fmp, u_long scan_start, u_long *free);
+int	 fat_free_clusters(struct fatfsmount *fmp, u_long start);
+int	 fat_seek_cluster(struct fatfsmount *fmp, u_long start, u_long offset,
+			    u_long *cl);
+int	 fat_expand_file(struct fatfsmount *fmp, u_long cl, int size);
+int	 fat_expand_dir(struct fatfsmount *fmp, u_long cl, u_long *new_cl);
+
+void	 fat_convert_name(char *org, char *name);
+void	 fat_restore_name(char *org, char *name);
+int	 fat_valid_name(char *name);
+int	 fat_compare_name(char *n1, char *n2);
+void	 fat_mode_to_attr(mode_t mode, u_char *attr);
+void	 fat_attr_to_mode(u_char attr, mode_t *mode);
+
+int	 fatfs_lookup_node(vnode_t dvp, char *name, struct fatfs_node *node);
+int	 fatfs_get_node(vnode_t dvp, int index, struct fatfs_node *node);
+int	 fatfs_put_node(struct fatfsmount *fmp, struct fatfs_node *node);
+int	 fatfs_add_node(vnode_t dvp, struct fatfs_node *node);
+__END_DECLS
+
+#endif /* !_FATFS_H */
diff --git a/prex-0.9.0/usr/server/fs/fatfs/fatfs_fat.c b/prex-0.9.0/usr/server/fs/fatfs/fatfs_fat.c
new file mode 100755
index 0000000..67e372f
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/fatfs_fat.c
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/buf.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "fatfs.h"
+
+/*
+ * Read the FAT entry for specified cluster.
+ */
+static int
+read_fat_entry(struct fatfsmount *fmp, u_long cl)
+{
+	u_long sec;
+	char *buf = fmp->fat_buf;
+	int error, border = 0;
+	struct buf *bp;
+
+	/* Get the sector number in FAT entry. */
+	if (FAT16(fmp))
+		sec = (cl * 2) / SEC_SIZE;
+	else {
+		sec = (cl * 3 / 2) / SEC_SIZE;
+		/*
+		 * Check if the entry data is placed at the
+		 * end of sector. If so, we have to read one
+		 * more sector to get complete FAT12 entry.
+		 */
+		if ((cl * 3 / 2) % SEC_SIZE == SEC_SIZE - 1)
+			border = 1;
+	}
+	sec += fmp->fat_start;
+
+	/* Read first sector. */
+	if ((error = bread(fmp->dev, sec, &bp)) != 0)
+		return error;
+	memcpy(buf, bp->b_data, SEC_SIZE);
+	brelse(bp);
+
+	if (!FAT12(fmp) || border == 0)
+		return 0;
+
+	/* Read second sector for the border entry of FAT12. */
+	if ((error = bread(fmp->dev, sec + 1, &bp)) != 0)
+		return error;
+	memcpy(buf + SEC_SIZE, bp->b_data, SEC_SIZE);
+	brelse(bp);
+	return 0;
+}
+
+/*
+ * Write fat entry from buffer.
+ */
+static int
+write_fat_entry(struct fatfsmount *fmp, u_long cl)
+{
+	u_long sec;
+	char *buf = fmp->fat_buf;
+	int error, border = 0;
+	struct buf *bp;
+
+	/* Get the sector number in FAT entry. */
+	if (FAT16(fmp))
+		sec = (cl * 2) / SEC_SIZE;
+	else {
+		sec = (cl * 3 / 2) / SEC_SIZE;
+		/* Check if border entry for FAT12 */
+		if ((cl * 3 / 2) % SEC_SIZE == SEC_SIZE - 1)
+			border = 1;
+	}
+	sec += fmp->fat_start;
+
+	/* Write first sector. */
+	bp = getblk(fmp->dev, sec);
+	memcpy(bp->b_data, buf, SEC_SIZE);
+	if ((error = bwrite(bp)) != 0)
+		return error;
+
+	if (!FAT12(fmp) || border == 0)
+		return 0;
+
+	/* Write second sector for the border entry of FAT12. */
+	bp = getblk(fmp->dev, sec + 1);
+	memcpy(bp->b_data, buf + SEC_SIZE, SEC_SIZE);
+	error = bwrite(bp);
+	return error;
+}
+
+/*
+ * Get next cluster number of FAT chain.
+ * @fmp: fat mount data
+ * @cl: previous cluster#
+ * @next: next cluster# to return
+ */
+int
+fat_next_cluster(struct fatfsmount *fmp, u_long cl, u_long *next)
+{
+	u_int offset;
+	uint16_t val;
+	int error;
+
+	/* Read FAT entry */
+	error = read_fat_entry(fmp, cl);
+	if (error)
+		return error;
+
+	/* Get offset in buffer. */
+	if (FAT16(fmp))
+		offset = (cl * 2) % SEC_SIZE;
+	else
+		offset = (cl * 3 / 2) % SEC_SIZE;
+
+	/* Pick up cluster# */
+	val = *((uint16_t *)(fmp->fat_buf + offset));
+
+	/* Adjust data for FAT12 entry */
+	if (FAT12(fmp)) {
+		if (cl & 1)
+			val >>= 4;
+		else
+			val &= 0xfff;
+	}
+	*next = (u_long)val;
+	DPRINTF(("fat_next_cluster: %d => %d\n", cl, *next));
+	return 0;
+}
+
+/*
+ * Set next cluster number in FAT chain.
+ * @fmp: fat mount data
+ * @cl: previous cluster#
+ * @next: cluster# to set (can be eof)
+ */
+int
+fat_set_cluster(struct fatfsmount *fmp, u_long cl, u_long next)
+{
+	u_int offset;
+	char *buf = fmp->fat_buf;
+	int error;
+	uint16_t val, tmp;
+
+	/* Read FAT entry */
+	error = read_fat_entry(fmp, cl);
+	if (error)
+		return error;
+
+	/* Get offset in buffer. */
+	if (FAT16(fmp))
+		offset = (cl * 2) % SEC_SIZE;
+	else
+		offset = (cl * 3 / 2) % SEC_SIZE;
+
+	/* Modify FAT entry for target cluster. */
+	val = (uint16_t)(next & fmp->fat_mask);
+	if (FAT12(fmp)) {
+		tmp = *((uint16_t *)(buf + offset));
+		if (cl & 1) {
+			val <<= 4;
+			val |= (tmp & 0xf);
+		} else {
+			tmp &= 0xf000;
+			val |= tmp;
+		}
+	}
+	*((uint16_t *)(buf + offset)) = val;
+
+	/* Write FAT entry */
+	error = write_fat_entry(fmp, cl);
+	return error;
+}
+
+/*
+ * Allocate free cluster in FAT chain.
+ *
+ * @fmp: fat mount data
+ * @scan_start: cluster# to scan first. If 0, use the previous used value.
+ * @free: allocated cluster# to return
+ */
+int
+fat_alloc_cluster(struct fatfsmount *fmp, u_long scan_start, u_long *free)
+{
+	u_long cl, next;
+	int error;
+
+	if (scan_start == 0)
+		scan_start = fmp->free_scan;
+
+	DPRINTF(("fat_alloc_cluster: start=%d\n", scan_start));
+
+	cl = scan_start + 1;
+	while (cl != scan_start) {
+		error = fat_next_cluster(fmp, cl, &next);
+		if (error)
+			return error;
+		if (next == CL_FREE) {	/* free ? */
+			DPRINTF(("fat_alloc_cluster: free cluster=%d\n", cl));
+			*free = cl;
+			return 0;
+		}
+		if (++cl >= fmp->last_cluster)
+			cl = CL_FIRST;
+	}
+	return ENOSPC;		/* no space */
+}
+
+/*
+ * Deallocate needless cluster.
+ * @fmp: fat mount data
+ * @start: first cluster# of FAT chain
+ */
+int
+fat_free_clusters(struct fatfsmount *fmp, u_long start)
+{
+	int error;
+	u_long cl, next;
+
+	cl = start;
+	if (cl < CL_FIRST)
+		return EINVAL;
+
+	while (!IS_EOFCL(fmp, cl)) {
+		error = fat_next_cluster(fmp, cl, &next);
+		if (error)
+			return error;
+		error = fat_set_cluster(fmp, cl, CL_FREE);
+		if (error)
+			return error;
+		cl = next;
+	}
+	/* Clear eof */
+	error = fat_set_cluster(fmp, cl, CL_FREE);
+	if (error)
+		return error;
+	return 0;
+}
+
+/*
+ * Get the cluster# for the specific file offset.
+ *
+ * @fmp: fat mount data
+ * @start: start cluster# of file.
+ * @offset: file offset
+ * @cl: cluster# to return
+ */
+int
+fat_seek_cluster(struct fatfsmount *fmp, u_long start, u_long offset,
+		 u_long *cl)
+{
+	int error, i;
+	u_long c, target;
+
+	if (start > fmp->last_cluster)
+		return EIO;
+
+	c = start;
+	target = offset / fmp->cluster_size;
+	for (i = 0; i < target; i++) {
+		error = fat_next_cluster(fmp, c, &c);
+		if (error)
+			return error;
+		if (IS_EOFCL(fmp, c))
+			return EIO;
+	}
+	*cl = c;
+	return 0;
+}
+
+/*
+ * Expand file size.
+ *
+ * @fmp: fat mount data
+ * @cl: cluster# of target file.
+ * @size: new size of file in bytes.
+ */
+int
+fat_expand_file(struct fatfsmount *fmp, u_long cl, int size)
+{
+	int i, cl_len, alloc, error;
+	u_long next;
+
+	alloc = 0;
+	cl_len = size / fmp->cluster_size + 1;
+
+	for (i = 0; i < cl_len; i++) {
+		error = fat_next_cluster(fmp, cl, &next);
+		if (error)
+			return error;
+		if (alloc || next >= fmp->fat_eof) {
+			error = fat_alloc_cluster(fmp, cl, &next);
+			if (error)
+				return error;
+			alloc = 1;
+		}
+		if (alloc) {
+			error = fat_set_cluster(fmp, cl, next);
+			if (error)
+				return error;
+		}
+		cl = next;
+	}
+	if (alloc)
+		fat_set_cluster(fmp, cl, fmp->fat_eof);	/* add eof */
+	DPRINTF(("fat_expand_file: new size=%d\n", size));
+	return 0;
+}
+
+/*
+ * Expand directory size.
+ *
+ * @fmp: fat mount data
+ * @cl: cluster# of target directory
+ * @new_cl: cluster# for new directory to return
+ *
+ * Note: The root directory can not be expanded.
+ */
+int
+fat_expand_dir(struct fatfsmount *fmp, u_long cl, u_long *new_cl)
+{
+	int error;
+	u_long next;
+
+	/* Find last cluster number of FAT chain. */
+	while (!IS_EOFCL(fmp, cl)) {
+		error = fat_next_cluster(fmp, cl, &next);
+		if (error)
+			return error;
+		cl = next;
+	}
+
+	error = fat_alloc_cluster(fmp, cl, &next);
+	if (error)
+		return error;
+
+	error = fat_set_cluster(fmp, cl, next);
+	if (error)
+		return error;
+
+	error = fat_set_cluster(fmp, next, fmp->fat_eof);
+	if (error)
+		return error;
+
+	*new_cl = next;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/fatfs/fatfs_node.c b/prex-0.9.0/usr/server/fs/fatfs/fatfs_node.c
new file mode 100755
index 0000000..1448e13
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/fatfs_node.c
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+#include <sys/buf.h>
+
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "fatfs.h"
+
+/*
+ * Read directory entry to buffer, with cache.
+ */
+static int
+fat_read_dirent(struct fatfsmount *fmp, u_long sec)
+{
+	struct buf *bp;
+	int error;
+
+	if ((error = bread(fmp->dev, sec, &bp)) != 0)
+		return error;
+	memcpy(fmp->dir_buf, bp->b_data, SEC_SIZE);
+	brelse(bp);
+	return 0;
+}
+
+/*
+ * Write directory entry from buffer.
+ */
+static int
+fat_write_dirent(struct fatfsmount *fmp, u_long sec)
+{
+	struct buf *bp;
+
+	bp = getblk(fmp->dev, sec);
+	memcpy(bp->b_data, fmp->dir_buf, SEC_SIZE);
+	return bwrite(bp);
+}
+
+/*
+ * Find directory entry in specified sector.
+ * The fat vnode data is filled if success.
+ *
+ * @fmp: fatfs mount point
+ * @sec: sector#
+ * @name: file name
+ * @node: pointer to fat node
+ */
+static int
+fat_lookup_dirent(struct fatfsmount *fmp, u_long sec, char *name,
+		  struct fatfs_node *np)
+{
+	struct fat_dirent *de;
+	int error, i;
+
+	error = fat_read_dirent(fmp, sec);
+	if (error)
+		return error;
+
+	de = (struct fat_dirent *)fmp->dir_buf;
+
+	for (i = 0; i < DIR_PER_SEC; i++) {
+		/* Find specific file or directory name */
+		if (IS_EMPTY(de))
+			return ENOENT;
+		if (!IS_VOL(de) &&
+		    !fat_compare_name((char *)de->name, name)) {
+			/* Found. Fill the fat vnode data. */
+			*(&np->dirent) = *de;
+			np->sector = sec;
+			np->offset = sizeof(struct fat_dirent) * i;
+			DPRINTF(("fat_lookup_dirent: found sec=%d\n", sec));
+			return 0;
+		}
+		if (!IS_DELETED(de))
+			DPRINTF(("fat_lookup_dirent: %s\n", de->name));
+		de++;
+	}
+	return EAGAIN;
+}
+
+/*
+ * Find directory entry for specified name in directory.
+ * The fat vnode data is filled if success.
+ *
+ * @dvp: vnode for directory.
+ * @name: file name
+ * @np: pointer to fat node
+ */
+int
+fatfs_lookup_node(vnode_t dvp, char *name, struct fatfs_node *np)
+{
+	struct fatfsmount *fmp;
+	char fat_name[12];
+	u_long cl, sec;
+	int i, error;
+
+	if (name == NULL)
+		return ENOENT;
+
+	DPRINTF(("fat_lookup_denode: cl=%d name=%s\n", dvp->v_blkno, name));
+
+	fat_convert_name(name, fat_name);
+	*(fat_name + 11) = '\0';
+
+	fmp = (struct fatfsmount *)dvp->v_mount->m_data;
+	cl = dvp->v_blkno;
+	if (cl == CL_ROOT) {
+		/* Search entry in root directory */
+		for (sec = fmp->root_start; sec < fmp->data_start; sec++) {
+			error = fat_lookup_dirent(fmp, sec, fat_name, np);
+			if (error != EAGAIN)
+				return error;
+		}
+	} else {
+		/* Search entry in sub directory */
+		while (!IS_EOFCL(fmp, cl)) {
+			sec = cl_to_sec(fmp, cl);
+			for (i = 0; i < fmp->sec_per_cl; i++) {
+				error = fat_lookup_dirent(fmp, sec, fat_name,
+						   np);
+				if (error != EAGAIN)
+					return error;
+				sec++;
+			}
+			error = fat_next_cluster(fmp, cl, &cl);
+			if (error)
+				return error;
+		}
+	}
+	return ENOENT;
+}
+
+/*
+ * Get directory entry for specified index in sector.
+ * The directory entry is filled if success.
+ *
+ * @fmp: fatfs mount point
+ * @sec: sector#
+ * @target: target index
+ * @index: current index
+ * @np: pointer to fat node
+ */
+static int
+fat_get_dirent(struct fatfsmount *fmp, u_long sec, int target, int *index,
+	       struct fatfs_node *np)
+{
+	struct fat_dirent *de;
+	int error, i;
+
+	error = fat_read_dirent(fmp, sec);
+	if (error)
+		return error;
+
+	de = (struct fat_dirent *)fmp->dir_buf;
+	for (i = 0; i < DIR_PER_SEC; i++) {
+		if (IS_EMPTY(de))
+			return ENOENT;
+		if (!IS_DELETED(de) && !IS_VOL(de)) {
+			/* valid file */
+			if (*index == target) {
+				*(&np->dirent) = *de;
+				np->sector = sec;
+				np->offset = sizeof(struct fat_dirent) * i;
+				DPRINTF(("fat_get_dirent: found index=%d\n", *index));
+				return 0;
+			}
+			(*index)++;
+		}
+		DPRINTF(("fat_get_dirent: %s\n", de->name));
+		de++;
+	}
+	return EAGAIN;
+}
+
+/*
+ * Get directory entry for specified index.
+ *
+ * @dvp: vnode for directory.
+ * @index: index of the entry
+ * @np: pointer to fat node
+ */
+int
+fatfs_get_node(vnode_t dvp, int index, struct fatfs_node *np)
+{
+	struct fatfsmount *fmp;
+	u_long cl, sec;
+	int i, cur_index, error;
+
+	fmp = (struct fatfsmount *)dvp->v_mount->m_data;
+	cl = dvp->v_blkno;
+	cur_index = 0;
+
+	DPRINTF(("fatfs_get_node: index=%d\n", index));
+
+	if (cl == CL_ROOT) {
+		/* Get entry from the root directory */
+		for (sec = fmp->root_start; sec < fmp->data_start; sec++) {
+			error = fat_get_dirent(fmp, sec, index, &cur_index, np);
+			if (error != EAGAIN)
+				return error;
+		}
+	} else {
+		/* Get entry from the sub directory */
+		while (!IS_EOFCL(fmp, cl)) {
+			sec = cl_to_sec(fmp, cl);
+			for (i = 0; i < fmp->sec_per_cl; i++) {
+				error = fat_get_dirent(fmp, sec, index,
+						     &cur_index, np);
+				if (error != EAGAIN)
+					return error;
+				sec++;
+			}
+			error = fat_next_cluster(fmp, cl, &cl);
+			if (error)
+				return error;
+		}
+	}
+	return ENOENT;
+}
+
+/*
+ * Find empty directory entry and put new entry on it.
+ *
+ * @fmp: fatfs mount point
+ * @sec: sector#
+ * @np: pointer to fat node
+ */
+static int
+fat_add_dirent(struct fatfsmount *fmp, u_long sec, struct fatfs_node *np)
+{
+	struct fat_dirent *de;
+	int error, i;
+
+	error = fat_read_dirent(fmp, sec);
+	if (error)
+		return error;
+
+	de = (struct fat_dirent *)fmp->dir_buf;
+	for (i = 0; i < DIR_PER_SEC; i++) {
+		if (IS_DELETED(de) || IS_EMPTY(de))
+			goto found;
+		DPRINTF(("fat_add_dirent: scan %s\n", de->name));
+		de++;
+	}
+	return ENOENT;
+
+ found:
+	DPRINTF(("fat_add_dirent: found. sec=%d\n", sec));
+	memcpy(de, &np->dirent, sizeof(struct fat_dirent));
+	error = fat_write_dirent(fmp, sec);
+	return error;
+}
+
+/*
+ * Find empty directory entry and put new entry on it.
+ * This search is done only in directory of specified cluster.
+ * @dvp: vnode for directory.
+ * @np: pointer to fat node
+ */
+int
+fatfs_add_node(vnode_t dvp, struct fatfs_node *np)
+{
+	struct fatfsmount *fmp;
+	u_long cl, sec;
+	int i, error;
+	u_long next;
+
+	fmp = (struct fatfsmount *)dvp->v_mount->m_data;
+	cl = dvp->v_blkno;
+
+	DPRINTF(("fatfs_add_node: cl=%d\n", cl));
+
+	if (cl == CL_ROOT) {
+		/* Add entry in root directory */
+		for (sec = fmp->root_start; sec < fmp->data_start; sec++) {
+			error = fat_add_dirent(fmp, sec, np);
+			if (error != ENOENT)
+				return error;
+		}
+	} else {
+		/* Search entry in sub directory */
+		while (!IS_EOFCL(fmp, cl)) {
+			sec = cl_to_sec(fmp, cl);
+			for (i = 0; i < fmp->sec_per_cl; i++) {
+				error = fat_add_dirent(fmp, sec, np);
+				if (error != ENOENT)
+					return error;
+				sec++;
+			}
+			error = fat_next_cluster(fmp, cl, &next);
+			if (error)
+				return error;
+			cl = next;
+		}
+		/* No entry found, add one more free cluster for directory */
+		DPRINTF(("fatfs_add_node: expand dir\n"));
+		error = fat_expand_dir(fmp, cl, &next);
+		if (error)
+			return error;
+
+		/* Initialize free cluster. */
+		memset(fmp->dir_buf, 0, SEC_SIZE);
+		sec = cl_to_sec(fmp, next);
+		for (i = 0; i < fmp->sec_per_cl; i++) {
+			error = fat_write_dirent(fmp, sec);
+			if (error)
+				return error;
+			sec++;
+		}
+		/* Try again */
+		sec = cl_to_sec(fmp, next);
+		error = fat_add_dirent(fmp, sec, np);
+		return error;
+	}
+	return ENOENT;
+}
+
+/*
+ * Put directory entry.
+ * @fmp: fat mount data
+ * @np: pointer to fat node
+ */
+int
+fatfs_put_node(struct fatfsmount *fmp, struct fatfs_node *np)
+{
+	int error;
+
+	error = fat_read_dirent(fmp, np->sector);
+	if (error)
+		return error;
+
+	memcpy(fmp->dir_buf + np->offset, &np->dirent,
+	       sizeof(struct fat_dirent));
+
+	error = fat_write_dirent(fmp, np->sector);
+	return error;
+}
+
diff --git a/prex-0.9.0/usr/server/fs/fatfs/fatfs_subr.c b/prex-0.9.0/usr/server/fs/fatfs/fatfs_subr.c
new file mode 100755
index 0000000..73352f6
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/fatfs_subr.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "fatfs.h"
+
+
+/*
+ * Convert file name to 8.3 format
+ *  Ex. "foo.bar" => "foo     bar"
+ */
+void
+fat_convert_name(char *org, char *name)
+{
+	int i;
+
+	memset(name, (int)' ', 11);
+	for (i = 0; i <= 11; i++) {
+		if (!*org)
+			break;
+		if (*org == '/')
+			break;
+		if (*org == '.') {
+			i = 7;
+			org++;
+			continue;
+		}
+		*(name + i) = *org;
+		org++;
+	}
+}
+
+/*
+ * Restore file name to normal format
+ *  Ex. "foo     bar" => "foo.bar"
+ */
+void
+fat_restore_name(char *org, char *name)
+{
+	int i;
+
+	memset(name, 0, 13);
+	for (i = 0; i < 8; i++) {
+		if (*org != ' ')
+			*name++ = *org;
+		org++;
+	}
+	if (*org != ' ')
+		*name++ = '.';
+	for (i = 0; i < 3; i++) {
+		if (*org != ' ')
+			*name++ = *org;
+		org++;
+	}
+}
+
+/*
+ * Compare 2 file names.
+ *
+ * Return 0 if it matches.
+ */
+int
+fat_compare_name(char *n1, char *n2)
+{
+	int i;
+
+	for (i = 0; i < 11; i++, n1++, n2++) {
+		if (toupper((int)*n1) != toupper((int)*n2))
+			return -1;
+	}
+	return 0;
+}
+
+/*
+ * Check specified name is valid as FAT file name.
+ * Return true if valid.
+ */
+int
+fat_valid_name(char *name)
+{
+	static char invalid_char[] = "*?<>|\"+=,;[] \345";
+	int len = 0;
+
+	/* . or .. */
+	if (*name == '.') {
+		name++;
+		if (*name == '.')
+			name++;
+		return (*(name + 1) == '\0') ? 1 : 0;
+	}
+	/* First char must be alphabet or numeric */
+	if (!isalnum((int)*name))
+		return 0;
+	while (*name != '\0') {
+		if (strchr(invalid_char, *name))
+			return 0;
+		if (*name == '.')
+			break;	/* Start of extension */
+		if (++len > 8)
+			return 0;	/* Too long name */
+		name++;
+	}
+	if (*name == '\0')
+		return 1;
+	name++;
+	if (*name == '\0')	/* Empty extension */
+		return 1;
+	len = 0;
+	while (*name != '\0') {
+		if (strchr(invalid_char, *name))
+			return 0;
+		if (*name == '.')
+			return 0;	/* Second extention */
+		if (++len > 3)
+			return 0;	/* Too long name */
+		name++;
+	}
+	return 1;
+}
+
+/*
+ * mode -> attribute
+ */
+void
+fat_mode_to_attr(mode_t mode, u_char *attr)
+{
+
+	*attr = 0;
+	if (!(mode & S_IWRITE))
+		*attr |= FA_RDONLY;
+	if (!(mode & S_IREAD))
+		*attr |= FA_HIDDEN;
+	if (S_ISDIR(mode))
+		*attr |= FA_SUBDIR;
+}
+
+/*
+ * attribute -> mode
+ */
+void
+fat_attr_to_mode(u_char attr, mode_t *mode)
+{
+
+	if (attr & FA_RDONLY)
+		*mode =
+		    S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
+		    S_IXOTH;
+	else
+		*mode = S_IRWXU | S_IRWXG | S_IRWXO;
+
+	if (attr & FA_SUBDIR)
+		*mode |= S_IFDIR;
+	else
+		*mode |= S_IFREG;
+}
diff --git a/prex-0.9.0/usr/server/fs/fatfs/fatfs_vfsops.c b/prex-0.9.0/usr/server/fs/fatfs/fatfs_vfsops.c
new file mode 100755
index 0000000..fc13645
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/fatfs_vfsops.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/buf.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include "fatfs.h"
+
+static int fatfs_mount	(mount_t mp, char *dev, int flags, void *data);
+static int fatfs_unmount(mount_t mp);
+#define fatfs_sync	((vfsop_sync_t)vfs_nullop)
+static int fatfs_vget	(mount_t mp, vnode_t vp);
+#define fatfs_statfs	((vfsop_statfs_t)vfs_nullop)
+
+/*
+ * File system operations
+ */
+struct vfsops fatfs_vfsops = {
+	fatfs_mount,		/* mount */
+	fatfs_unmount,		/* unmount */
+	fatfs_sync,		/* sync */
+	fatfs_vget,		/* vget */
+	fatfs_statfs,		/* statfs */
+	&fatfs_vnops,		/* vnops */
+};
+
+/*
+ * Read BIOS parameter block.
+ * Return 0 on sucess.
+ */
+static int
+fat_read_bpb(struct fatfsmount *fmp)
+{
+	struct fat_bpb *bpb;
+	size_t size;
+	int error;
+
+	bpb = malloc(SEC_SIZE);
+	if (bpb == NULL)
+		return ENOMEM;
+
+	/* Read boot sector (block:0) */
+	size = SEC_SIZE;
+	error = device_read(fmp->dev, bpb, &size, 0);
+	if (error) {
+		free(bpb);
+		return error;
+	}
+	if (bpb->bytes_per_sector != SEC_SIZE) {
+		DPRINTF(("fatfs: invalid sector size\n"));
+		free(bpb);
+		return EINVAL;
+	}
+
+	/* Build FAT mount data */
+	fmp->fat_start = bpb->hidden_sectors + bpb->reserved_sectors;
+	fmp->root_start = fmp->fat_start +
+		(bpb->num_of_fats * bpb->sectors_per_fat);
+	fmp->data_start =
+		fmp->root_start + (bpb->root_entries / DIR_PER_SEC);
+	fmp->sec_per_cl = bpb->sectors_per_cluster;
+	fmp->cluster_size = bpb->sectors_per_cluster * SEC_SIZE;
+	fmp->last_cluster = (bpb->total_sectors - fmp->data_start) /
+		bpb->sectors_per_cluster + CL_FIRST;
+	fmp->free_scan = CL_FIRST;
+
+	if (!strncmp((const char *)bpb->file_sys_id, "FAT12   ", 8)) {
+		fmp->fat_type = 12;
+		fmp->fat_mask = FAT12_MASK;
+		fmp->fat_eof = CL_EOF & FAT12_MASK;
+	} else if (!strncmp((const char *)bpb->file_sys_id, "FAT16   ", 8)) {
+		fmp->fat_type = 16;
+		fmp->fat_mask = FAT16_MASK;
+		fmp->fat_eof = CL_EOF & FAT16_MASK;
+	} else {
+		/* FAT32 is not supported now! */
+		DPRINTF(("fatfs: invalid FAT type\n"));
+		free(bpb);
+		return EINVAL;
+	}
+	free(bpb);
+
+	DPRINTF(("----- FAT info -----\n"));
+	DPRINTF(("drive:%x\n", (int)bpb->physical_drive));
+	DPRINTF(("total_sectors:%d\n", (int)bpb->total_sectors));
+	DPRINTF(("heads       :%d\n", (int)bpb->heads));
+	DPRINTF(("serial      :%x\n", (int)bpb->serial_no));
+	DPRINTF(("cluster size:%u sectors\n", (int)fmp->sec_per_cl));
+	DPRINTF(("fat_type    :FAT%u\n", (int)fmp->fat_type));
+	DPRINTF(("fat_eof     :0x%x\n\n", (int)fmp->fat_eof));
+	return 0;
+}
+
+/*
+ * Mount file system.
+ */
+static int
+fatfs_mount(mount_t mp, char *dev, int flags, void *data)
+{
+	struct fatfsmount *fmp;
+	vnode_t vp;
+	int error = 0;
+
+	DPRINTF(("fatfs_mount device=%s\n", dev));
+
+	fmp = malloc(sizeof(struct fatfsmount));
+	if (fmp == NULL)
+		return ENOMEM;
+
+	fmp->dev = mp->m_dev;
+	if (fat_read_bpb(fmp) != 0)
+		goto err1;
+
+	error = ENOMEM;
+	fmp->io_buf = malloc(fmp->sec_per_cl * SEC_SIZE);
+	if (fmp->io_buf == NULL)
+		goto err1;
+
+	fmp->fat_buf = malloc(SEC_SIZE * 2);
+	if (fmp->fat_buf == NULL)
+		goto err2;
+
+	fmp->dir_buf = malloc(SEC_SIZE);
+	if (fmp->dir_buf == NULL)
+		goto err3;
+
+	mutex_init(&fmp->lock);
+	mp->m_data = fmp;
+	vp = mp->m_root;
+	vp->v_blkno = CL_ROOT;
+	return 0;
+ err3:
+	free(fmp->fat_buf);
+ err2:
+	free(fmp->io_buf);
+ err1:
+	free(fmp);
+	return error;
+}
+
+/*
+ * Unmount the file system.
+ */
+static int
+fatfs_unmount(mount_t mp)
+{
+	struct fatfsmount *fmp;
+
+	fmp = mp->m_data;
+	free(fmp->dir_buf);
+	free(fmp->fat_buf);
+	free(fmp->io_buf);
+	mutex_destroy(&fmp->lock);
+	free(fmp);
+	return 0;
+}
+
+/*
+ * Prepare the FAT specific node and fill the vnode.
+ */
+static int
+fatfs_vget(mount_t mp, vnode_t vp)
+{
+	struct fatfs_node *np;
+
+	np = malloc(sizeof(struct fatfs_node));
+	if (np == NULL)
+		return ENOMEM;
+	vp->v_data = np;
+	return 0;
+}
+
diff --git a/prex-0.9.0/usr/server/fs/fatfs/fatfs_vnops.c b/prex-0.9.0/usr/server/fs/fatfs/fatfs_vnops.c
new file mode 100755
index 0000000..e865200
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fatfs/fatfs_vnops.c
@@ -0,0 +1,719 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/prex.h>
+
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/dirent.h>
+#include <sys/buf.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include "fatfs.h"
+
+/*
+ *  Time bits: 15-11 hours (0-23), 10-5 min, 4-0 sec /2
+ *  Date bits: 15-9 year - 1980, 8-5 month, 4-0 day
+ */
+#define TEMP_DATE   0x3021
+#define TEMP_TIME   0
+
+#define fatfs_open	((vnop_open_t)vop_nullop)
+#define fatfs_close	((vnop_close_t)vop_nullop)
+static int fatfs_read	(vnode_t, file_t, void *, size_t, size_t *);
+static int fatfs_write	(vnode_t, file_t, void *, size_t, size_t *);
+#define fatfs_seek	((vnop_seek_t)vop_nullop)
+#define fatfs_ioctl	((vnop_ioctl_t)vop_einval)
+#define fatfs_fsync	((vnop_fsync_t)vop_nullop)
+static int fatfs_readdir(vnode_t, file_t, struct dirent *);
+static int fatfs_lookup	(vnode_t, char *, vnode_t);
+static int fatfs_create	(vnode_t, char *, mode_t);
+static int fatfs_remove	(vnode_t, vnode_t, char *);
+static int fatfs_rename	(vnode_t, vnode_t, char *, vnode_t, vnode_t, char *);
+static int fatfs_mkdir	(vnode_t, char *, mode_t);
+static int fatfs_rmdir	(vnode_t, vnode_t, char *);
+static int fatfs_getattr(vnode_t, struct vattr *);
+static int fatfs_setattr(vnode_t, struct vattr *);
+static int fatfs_inactive(vnode_t);
+static int fatfs_truncate(vnode_t, off_t);
+
+/*
+ * vnode operations
+ */
+struct vnops fatfs_vnops = {
+	fatfs_open,		/* open */
+	fatfs_close,		/* close */
+	fatfs_read,		/* read */
+	fatfs_write,		/* write */
+	fatfs_seek,		/* seek */
+	fatfs_ioctl,		/* ioctl */
+	fatfs_fsync,		/* fsync */
+	fatfs_readdir,		/* readdir */
+	fatfs_lookup,		/* lookup */
+	fatfs_create,		/* create */
+	fatfs_remove,		/* remove */
+	fatfs_rename,		/* remame */
+	fatfs_mkdir,		/* mkdir */
+	fatfs_rmdir,		/* rmdir */
+	fatfs_getattr,		/* getattr */
+	fatfs_setattr,		/* setattr */
+	fatfs_inactive,		/* inactive */
+	fatfs_truncate,		/* truncate */
+};
+
+/*
+ * Read one cluster to buffer.
+ */
+static int
+fat_read_cluster(struct fatfsmount *fmp, u_long cluster)
+{
+	u_long sec;
+	size_t size;
+
+	sec = cl_to_sec(fmp, cluster);
+	size = fmp->sec_per_cl * SEC_SIZE;
+	return device_read(fmp->dev, fmp->io_buf, &size, sec);
+}
+
+/*
+ * Write one cluster from buffer.
+ */
+static int
+fat_write_cluster(struct fatfsmount *fmp, u_long cluster)
+{
+	u_long sec;
+	size_t size;
+
+	sec = cl_to_sec(fmp, cluster);
+	size = fmp->sec_per_cl * SEC_SIZE;
+	return device_write(fmp->dev, fmp->io_buf, &size, sec);
+}
+
+/*
+ * Lookup vnode for the specified file/directory.
+ * The vnode data will be set properly.
+ */
+static int
+fatfs_lookup(vnode_t dvp, char *name, vnode_t vp)
+{
+	struct fatfsmount *fmp;
+	struct fat_dirent *de;
+	struct fatfs_node *np;
+	int error;
+
+	if (*name == '\0')
+		return ENOENT;
+
+	fmp = vp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	DPRINTF(("fatfs_lookup: name=%s\n", name));
+
+	np = vp->v_data;
+	error = fatfs_lookup_node(dvp, name, np);
+	if (error) {
+		DPRINTF(("fatfs_lookup: failed!! name=%s\n", name));
+		mutex_unlock(&fmp->lock);
+		return error;
+	}
+	de = &np->dirent;
+	vp->v_type = IS_DIR(de) ? VDIR : VREG;
+	fat_attr_to_mode(de->attr, &vp->v_mode);
+	vp->v_mode = ALLPERMS;
+	vp->v_size = de->size;
+	vp->v_blkno = de->cluster;
+
+	DPRINTF(("fatfs_lookup: cl=%d\n", de->cluster));
+	mutex_unlock(&fmp->lock);
+	return 0;
+}
+
+static int
+fatfs_read(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	struct fatfsmount *fmp;
+	int nr_read, nr_copy, buf_pos, error;
+	u_long cl, file_pos;
+
+	DPRINTF(("fatfs_read: vp=%x\n", vp));
+
+	*result = 0;
+	fmp = vp->v_mount->m_data;
+
+	if (vp->v_type == VDIR)
+		return EISDIR;
+	if (vp->v_type != VREG)
+		return EINVAL;
+
+	/* Check if current file position is already end of file. */
+	file_pos = fp->f_offset;
+	if (file_pos >= vp->v_size)
+		return 0;
+
+	mutex_lock(&fmp->lock);
+
+	/* Get the actual read size. */
+	if (vp->v_size - file_pos < size)
+		size = vp->v_size - file_pos;
+
+	/* Seek to the cluster for the file offset */
+	error = fat_seek_cluster(fmp, vp->v_blkno, file_pos, &cl);
+	if (error)
+		goto out;
+
+	/* Read and copy data */
+	nr_read = 0;
+	buf_pos = file_pos % fmp->cluster_size;
+	do {
+		if (fat_read_cluster(fmp, cl)) {
+			error = EIO;
+			goto out;
+		}
+
+		nr_copy = fmp->cluster_size;
+		if (buf_pos > 0)
+			nr_copy -= buf_pos;
+		if (buf_pos + size < fmp->cluster_size)
+			nr_copy = size;
+		memcpy(buf, fmp->io_buf + buf_pos, nr_copy);
+
+		file_pos += nr_copy;
+		nr_read += nr_copy;
+		size -= nr_copy;
+		if (size <= 0)
+			break;
+
+		error = fat_next_cluster(fmp, cl, &cl);
+		if (error)
+			goto out;
+
+		buf = (void *)((u_long)buf + nr_copy);
+		buf_pos = 0;
+	} while (!IS_EOFCL(fmp, cl));
+
+	fp->f_offset = file_pos;
+	*result = nr_read;
+	error = 0;
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+static int
+fatfs_write(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node *np;
+	struct fat_dirent *de;
+	int nr_copy, nr_write, buf_pos, i, cl_size, error;
+	u_long file_pos, end_pos;
+	u_long cl;
+
+	DPRINTF(("fatfs_write: vp=%x\n", vp));
+
+	*result = 0;
+	fmp = vp->v_mount->m_data;
+
+	if (vp->v_type == VDIR)
+		return EISDIR;
+	if (vp->v_type != VREG)
+		return EINVAL;
+
+	mutex_lock(&fmp->lock);
+
+	/* Check if file position exceeds the end of file. */
+	end_pos = vp->v_size;
+	file_pos = (fp->f_flags & O_APPEND) ? end_pos : fp->f_offset;
+	if (file_pos + size > end_pos) {
+		/* Expand the file size before writing to it */
+		end_pos = file_pos + size;
+		error = fat_expand_file(fmp, vp->v_blkno, end_pos);
+		if (error) {
+			error = EIO;
+			goto out;
+		}
+
+		/* Update directory entry */
+		np = vp->v_data;
+		de = &np->dirent;
+		de->size = end_pos;
+		error = fatfs_put_node(fmp, np);
+		if (error)
+			goto out;
+		vp->v_size = end_pos;
+	}
+
+	/* Seek to the cluster for the file offset */
+	error = fat_seek_cluster(fmp, vp->v_blkno, file_pos, &cl);
+	if (error)
+		goto out;
+
+	buf_pos = file_pos % fmp->cluster_size;
+	cl_size = size / fmp->cluster_size + 1;
+	nr_write = 0;
+	i = 0;
+	do {
+		/* First and last cluster must be read before write */
+		if (i == 0 || i == cl_size) {
+			if (fat_read_cluster(fmp, cl)) {
+				error = EIO;
+				goto out;
+			}
+		}
+		nr_copy = fmp->cluster_size;
+		if (buf_pos > 0)
+			nr_copy -= buf_pos;
+		if (buf_pos + size < fmp->cluster_size)
+			nr_copy = size;
+		memcpy(fmp->io_buf + buf_pos, buf, nr_copy);
+
+		if (fat_write_cluster(fmp, cl)) {
+			error = EIO;
+			goto out;
+		}
+		file_pos += nr_copy;
+		nr_write += nr_copy;
+		size -= nr_copy;
+		if (size <= 0)
+			break;
+
+		error = fat_next_cluster(fmp, cl, &cl);
+		if (error)
+			goto out;
+
+		buf = (void *)((u_long)buf + nr_copy);
+		buf_pos = 0;
+		i++;
+	} while (!IS_EOFCL(fmp, cl));
+
+	fp->f_offset = file_pos;
+
+	/*
+	 * XXX: Todo!
+	 *    de.time = ?
+	 *    de.date = ?
+	 *    if (dirent_set(fp, &de))
+	 *        return EIO;
+	 */
+	*result = nr_write;
+	error = 0;
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+static int
+fatfs_readdir(vnode_t vp, file_t fp, struct dirent *dir)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node np;
+	struct fat_dirent *de;
+	int error;
+
+	fmp = vp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	error = fatfs_get_node(vp, fp->f_offset, &np);
+	if (error)
+		goto out;
+	de = &np.dirent;
+	fat_restore_name((char *)&de->name, dir->d_name);
+
+	if (de->attr & FA_SUBDIR)
+		dir->d_type = DT_DIR;
+	else if (de->attr & FA_DEVICE)
+		dir->d_type = DT_BLK;
+	else
+		dir->d_type = DT_REG;
+
+	dir->d_fileno = fp->f_offset;
+	dir->d_namlen = strlen(dir->d_name);
+
+	fp->f_offset++;
+	error = 0;
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+/*
+ * Create empty file.
+ */
+static int
+fatfs_create(vnode_t dvp, char *name, mode_t mode)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node np;
+	struct fat_dirent *de;
+	u_long cl;
+	int error;
+
+	DPRINTF(("fatfs_create: %s\n", name));
+
+	if (!S_ISREG(mode))
+		return EINVAL;
+
+	if (!fat_valid_name(name))
+		return EINVAL;
+
+	fmp = dvp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	/* Allocate free cluster for new file. */
+	error = fat_alloc_cluster(fmp, 0, &cl);
+	if (error)
+		goto out;
+
+	de = &np.dirent;
+	memset(de, 0, sizeof(struct fat_dirent));
+	fat_convert_name(name, (char *)de->name);
+	de->cluster = cl;
+	de->time = TEMP_TIME;
+	de->date = TEMP_DATE;
+	fat_mode_to_attr(mode, &de->attr);
+	error = fatfs_add_node(dvp, &np);
+	if (error)
+		goto out;
+	error = fat_set_cluster(fmp, cl, fmp->fat_eof);
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+static int
+fatfs_remove(vnode_t dvp, vnode_t vp, char *name)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node np;
+	struct fat_dirent *de;
+	int error;
+
+	if (*name == '\0')
+		return ENOENT;
+
+	fmp = dvp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	error = fatfs_lookup_node(dvp, name, &np);
+	if (error)
+		goto out;
+	de = &np.dirent;
+	if (IS_DIR(de)) {
+		error = EISDIR;
+		goto out;
+	}
+	if (!IS_FILE(de)) {
+		error = EPERM;
+		goto out;
+	}
+
+	/* Remove clusters */
+	error = fat_free_clusters(fmp, de->cluster);
+	if (error)
+		goto out;
+
+	/* remove directory */
+	de->name[0] = 0xe5;
+	error = fatfs_put_node(fmp, &np);
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+static int
+fatfs_rename(vnode_t dvp1, vnode_t vp1, char *name1,
+	     vnode_t dvp2, vnode_t vp2, char *name2)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node np1;
+	struct fat_dirent *de1, *de2;
+	int error;
+
+	fmp = dvp1->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	error = fatfs_lookup_node(dvp1, name1, &np1);
+	if (error)
+		goto out;
+	de1 = &np1.dirent;
+
+	if (IS_FILE(de1)) {
+		/* Remove destination file, first */
+		error = fatfs_remove(dvp2, vp1, name2);
+		if (error == EIO)
+			goto out;
+
+		/* Change file name of directory entry */
+		fat_convert_name(name2, (char *)de1->name);
+
+		/* Same directory ? */
+		if (dvp1 == dvp2) {
+			/* Change the name of existing file */
+			error = fatfs_put_node(fmp, &np1);
+			if (error)
+				goto out;
+		} else {
+			/* Create new directory entry */
+			error = fatfs_add_node(dvp2, &np1);
+			if (error)
+				goto out;
+
+			/* Remove souce file */
+			error = fatfs_remove(dvp1, vp2, name1);
+			if (error)
+				goto out;
+		}
+	} else {
+
+		/* remove destination directory */
+		error = fatfs_rmdir(dvp2, NULL, name2);
+		if (error == EIO)
+			goto out;
+
+		/* Change file name of directory entry */
+		fat_convert_name(name2, (char *)de1->name);
+
+		/* Same directory ? */
+		if (dvp1 == dvp2) {
+			/* Change the name of existing directory */
+			error = fatfs_put_node(fmp, &np1);
+			if (error)
+				goto out;
+		} else {
+			/* Create new directory entry */
+			error = fatfs_add_node(dvp2, &np1);
+			if (error)
+				goto out;
+
+			/* Update "." and ".." for renamed directory */
+			if (fat_read_cluster(fmp, de1->cluster)) {
+				error = EIO;
+				goto out;
+			}
+
+			de2 = (struct fat_dirent *)fmp->io_buf;
+			de2->cluster = de1->cluster;
+			de2->time = TEMP_TIME;
+			de2->date = TEMP_DATE;
+			de2++;
+			de2->cluster = dvp2->v_blkno;
+			de2->time = TEMP_TIME;
+			de2->date = TEMP_DATE;
+
+			if (fat_write_cluster(fmp, de1->cluster)) {
+				error = EIO;
+				goto out;
+			}
+
+			/* Remove souce directory */
+			error = fatfs_rmdir(dvp1, NULL, name1);
+			if (error)
+				goto out;
+		}
+	}
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+static int
+fatfs_mkdir(vnode_t dvp, char *name, mode_t mode)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node np;
+	struct fat_dirent *de;
+	u_long cl;
+	int error;
+
+	if (!S_ISDIR(mode))
+		return EINVAL;
+
+	if (!fat_valid_name(name))
+		return ENOTDIR;
+
+	fmp = dvp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	/* Allocate free cluster for directory data */
+	error = fat_alloc_cluster(fmp, 0, &cl);
+	if (error)
+		goto out;
+
+	memset(&np, 0, sizeof(struct fatfs_node));
+	de = &np.dirent;
+	fat_convert_name(name, (char *)&de->name);
+	de->cluster = cl;
+	de->time = TEMP_TIME;
+	de->date = TEMP_DATE;
+	fat_mode_to_attr(mode, &de->attr);
+	error = fatfs_add_node(dvp, &np);
+	if (error)
+		goto out;
+
+	/* Initialize "." and ".." for new directory */
+	memset(fmp->io_buf, 0, fmp->cluster_size);
+
+	de = (struct fat_dirent *)fmp->io_buf;
+	memcpy(de->name, ".          ", 11);
+	de->attr = FA_SUBDIR;
+	de->cluster = cl;
+	de->time = TEMP_TIME;
+	de->date = TEMP_DATE;
+	de++;
+	memcpy(de->name, "..         ", 11);
+	de->attr = FA_SUBDIR;
+	de->cluster = dvp->v_blkno;
+	de->time = TEMP_TIME;
+	de->date = TEMP_DATE;
+
+	if (fat_write_cluster(fmp, cl)) {
+		error = EIO;
+		goto out;
+	}
+	/* Add eof */
+	error = fat_set_cluster(fmp, cl, fmp->fat_eof);
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+/*
+ * remove can be done only with empty directory
+ */
+static int
+fatfs_rmdir(vnode_t dvp, vnode_t vp, char *name)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node np;
+	struct fat_dirent *de;
+	int error;
+
+	if (*name == '\0')
+		return ENOENT;
+
+	fmp = dvp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	error = fatfs_lookup_node(dvp, name, &np);
+	if (error)
+		goto out;
+
+	de = &np.dirent;
+	if (!IS_DIR(de)) {
+		error = ENOTDIR;
+		goto out;
+	}
+
+	/* Remove clusters */
+	error = fat_free_clusters(fmp, de->cluster);
+	if (error)
+		goto out;
+
+	/* remove directory */
+	de->name[0] = 0xe5;
+
+	error = fatfs_put_node(fmp, &np);
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+static int
+fatfs_getattr(vnode_t vp, struct vattr *vap)
+{
+	/* XXX */
+	return 0;
+}
+
+static int
+fatfs_setattr(vnode_t vp, struct vattr *vap)
+{
+	/* XXX */
+	return 0;
+}
+
+
+static int
+fatfs_inactive(vnode_t vp)
+{
+
+	free(vp->v_data);
+	return 0;
+}
+
+static int
+fatfs_truncate(vnode_t vp, off_t length)
+{
+	struct fatfsmount *fmp;
+	struct fatfs_node *np;
+	struct fat_dirent *de;
+	int error;
+
+	fmp = vp->v_mount->m_data;
+	mutex_lock(&fmp->lock);
+
+	np = vp->v_data;
+	de = &np->dirent;
+
+	if (length == 0) {
+		/* Remove clusters */
+		error = fat_free_clusters(fmp, de->cluster);
+		if (error)
+			goto out;
+	} else if (length > vp->v_size) {
+		error = fat_expand_file(fmp, vp->v_blkno, length);
+		if (error) {
+			error = EIO;
+			goto out;
+		}
+	}
+
+	/* Update directory entry */
+	de->size = length;
+	error = fatfs_put_node(fmp, np);
+	if (error)
+		goto out;
+	vp->v_size = length;
+ out:
+	mutex_unlock(&fmp->lock);
+	return error;
+}
+
+int
+fatfs_init(void)
+{
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/fifofs/Makefile b/prex-0.9.0/usr/server/fs/fifofs/Makefile
new file mode 100755
index 0000000..00632ea
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fifofs/Makefile
@@ -0,0 +1,4 @@
+TARGET=		fifofs.o
+SRCS=		fifo_vnops.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/server/fs/fifofs/fifo.h b/prex-0.9.0/usr/server/fs/fifofs/fifo.h
new file mode 100755
index 0000000..6e6acb8
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fifofs/fifo.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _FIFO_H
+#define _FIFO_H
+
+#include <sys/prex.h>
+#include <sys/types.h>
+
+#include <assert.h>
+
+/* #define DEBUG_FIFO 1 */
+
+#ifdef DEBUG_FIFO
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)	do {} while (0)
+#define ASSERT(e)
+#endif
+
+#if CONFIG_FS_THREADS > 1
+#define malloc(s)		malloc_r(s)
+#define free(p)			free_r(p)
+#else
+#define mutex_init(m)		do {} while (0)
+#define mutex_destroy(m)	do {} while (0)
+#define mutex_lock(m)		do {} while (0)
+#define mutex_unlock(m)		do {} while (0)
+#define mutex_trylock(m)	do {} while (0)
+#endif
+
+#endif /* !_FIFO_H */
diff --git a/prex-0.9.0/usr/server/fs/fifofs/fifo_vnops.c b/prex-0.9.0/usr/server/fs/fifofs/fifo_vnops.c
new file mode 100755
index 0000000..66ec5c0
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/fifofs/fifo_vnops.c
@@ -0,0 +1,515 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fifofs - FIFO/pipe file system.
+ */
+
+#include <sys/prex.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/syslog.h>
+#include <sys/dirent.h>
+#include <sys/list.h>
+
+#include <ctype.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <fcntl.h>
+
+#include "fifo.h"
+
+struct fifo_node {
+	struct list fn_link;
+	int	fn_type;	/* type: VFIFO or VPIPE */
+	char	*fn_name;	/* name (null-terminated) */
+	cond_t	fn_rcond;	/* cv for read */
+	cond_t	fn_wcond;	/* cv for write */
+	mutex_t	fn_rmtx;	/* mutex for read */
+	mutex_t	fn_wmtx;	/* mutex for write */
+	int	fn_readers;	/* reader count */
+	int	fn_writers;	/* writer count */
+	int	fn_start;	/* start offset of buffer data */
+	int	fn_size;	/* size of buffer data */
+	char	*fn_buf;	/* pointer to buffer */
+};
+
+#define fifo_mount	((vfsop_mount_t)vfs_nullop)
+#define fifo_unmount	((vfsop_umount_t)vfs_nullop)
+#define fifo_sync	((vfsop_sync_t)vfs_nullop)
+#define fifo_vget	((vfsop_vget_t)vfs_nullop)
+#define fifo_statfs	((vfsop_statfs_t)vfs_nullop)
+
+static int fifo_open	(vnode_t, int);
+static int fifo_close	(vnode_t, file_t);
+static int fifo_read	(vnode_t, file_t, void *, size_t, size_t *);
+static int fifo_write	(vnode_t, file_t, void *, size_t, size_t *);
+#define fifo_seek	((vnop_seek_t)vop_nullop)
+static int fifo_ioctl	(vnode_t, file_t, u_long, void *);
+#define fifo_fsync	((vnop_fsync_t)vop_nullop)
+static int fifo_readdir	(vnode_t, file_t, struct dirent *);
+static int fifo_lookup	(vnode_t, char *, vnode_t);
+static int fifo_create	(vnode_t, char *, mode_t);
+static int fifo_remove	(vnode_t, vnode_t, char *);
+#define fifo_rename	((vnop_rename_t)vop_einval)
+#define fifo_mkdir	((vnop_mkdir_t)vop_einval)
+#define fifo_rmdir	((vnop_rmdir_t)vop_einval)
+#define fifo_getattr	((vnop_getattr_t)vop_nullop)
+#define fifo_setattr	((vnop_setattr_t)vop_nullop)
+#define fifo_inactive	((vnop_inactive_t)vop_nullop)
+#define fifo_truncate	((vnop_truncate_t)vop_nullop)
+
+static void cleanup_fifo(vnode_t);
+static void wait_reader(vnode_t);
+static void wakeup_reader(vnode_t);
+static void wait_writer(vnode_t);
+static void wakeup_writer(vnode_t);
+
+#if CONFIG_FS_THREADS > 1
+static mutex_t fifo_lock = MUTEX_INITIALIZER;
+#endif
+
+static struct list fifo_head;
+
+/*
+ * vnode operations
+ */
+struct vnops fifofs_vnops = {
+	fifo_open,		/* open */
+	fifo_close,		/* close */
+	fifo_read,		/* read */
+	fifo_write,		/* write */
+	fifo_seek,		/* seek */
+	fifo_ioctl,		/* ioctl */
+	fifo_fsync,		/* fsync */
+	fifo_readdir,		/* readdir */
+	fifo_lookup,		/* lookup */
+	fifo_create,		/* create */
+	fifo_remove,		/* remove */
+	fifo_rename,		/* remame */
+	fifo_mkdir,		/* mkdir */
+	fifo_rmdir,		/* rmdir */
+	fifo_getattr,		/* getattr */
+	fifo_setattr,		/* setattr */
+	fifo_inactive,		/* inactive */
+	fifo_truncate,		/* truncate */
+};
+
+/*
+ * File system operations
+ */
+struct vfsops fifofs_vfsops = {
+	fifo_mount,		/* mount */
+	fifo_unmount,		/* unmount */
+	fifo_sync,		/* sync */
+	fifo_vget,		/* vget */
+	fifo_statfs,		/* statfs */
+	&fifofs_vnops,		/* vnops */
+};
+
+static int
+fifo_open(vnode_t vp, int flags)
+{
+	struct fifo_node *np = vp->v_data;
+
+	DPRINTF(("fifo_open: path=%s\n", vp->v_path));
+
+	if (!strcmp(vp->v_path, "/"))	/* root ? */
+		return 0;
+
+	/*
+	 * Unblock all threads who are waiting in open().
+	 */
+	if (flags & FREAD) {
+		if (np->fn_readers == 0 && np->fn_writers > 0)
+			wakeup_writer(vp);
+		np->fn_readers++;
+	}
+	if (flags & FWRITE) {
+		if (np->fn_writers == 0 && np->fn_readers > 0)
+			wakeup_reader(vp);
+		np->fn_writers++;
+	}
+
+	/*
+	 * If no-one opens FIFO at the other side, wait for open().
+	 */
+	if (flags & FREAD) {
+		if (flags & O_NONBLOCK) {
+		} else {
+			while (np->fn_writers == 0)
+				wait_writer(vp);
+		}
+	}
+	if (flags & FWRITE) {
+		if (flags & O_NONBLOCK) {
+			if (np->fn_readers == 0)
+				return ENXIO;
+		} else {
+			while (np->fn_readers == 0)
+				wait_reader(vp);
+		}
+	}
+	return 0;
+}
+
+static int
+fifo_close(vnode_t vp, file_t fp)
+{
+	struct fifo_node *np = vp->v_data;
+
+	DPRINTF(("fifo_close: fp=%x\n", fp));
+
+	if (np == NULL)
+		return 0;
+
+	if (fp->f_flags & FREAD) {
+		np->fn_readers--;
+		if (np->fn_readers == 0)
+			wakeup_writer(vp);
+	}
+	if (fp->f_flags & FWRITE) {
+		np->fn_writers--;
+		if (np->fn_writers == 0)
+			wakeup_reader(vp);
+	}
+	if (vp->v_refcnt > 1)
+		return 0;
+
+	/* Clearn up pipe */
+	if (!strncmp(np->fn_name, "pipe", 4)) {
+		DPRINTF(("fifo_close: remove pipe\n"));
+		cleanup_fifo(vp);
+	}
+	return 0;
+}
+
+static int
+fifo_read(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	struct fifo_node *np = vp->v_data;
+	char *p = buf;
+	u_int pos, nbytes;
+
+	DPRINTF(("fifo_read\n"));
+
+	/*
+	 * If nothing in the pipe, wait.
+	 */
+	while (np->fn_size == 0) {
+		/*
+		 * No data and no writer, then EOF
+		 */
+		if (np->fn_writers == 0) {
+			*result = 0;
+			return 0;
+		}
+		/*
+ 		 * wait for data
+		 */
+		wait_writer(vp);
+	}
+	/*
+	 * Read
+	 */
+	nbytes = (np->fn_size < size) ? np->fn_size : size;
+	np->fn_size -= nbytes;
+	*result = nbytes;
+
+	pos = np->fn_start;
+	while (nbytes > 0) {
+		*p++ = np->fn_buf[pos];
+		if (++pos > PIPE_BUF)
+			pos = 0;
+		nbytes--;
+	}
+	np->fn_start = pos;
+
+	wakeup_writer(vp);
+	return 0;
+}
+
+static int
+fifo_write(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	struct fifo_node *np = vp->v_data;
+	char *p = buf;
+	u_int pos, nfree, nbytes, count = 0;
+
+	DPRINTF(("fifo_write\n"));
+
+ again:
+	/*
+	 * If the pipe is full,
+	 * wait for reads to deplete
+	 * and truncate it.
+	 */
+	while (np->fn_size >= PIPE_BUF)
+		wait_reader(vp);
+
+	/*
+	 * Write
+	 */
+	nfree = PIPE_BUF - np->fn_size;
+	nbytes = (nfree < size) ? nfree : size;
+
+	pos = np->fn_start + np->fn_size;
+	if (pos >= PIPE_BUF)
+		pos -= PIPE_BUF;
+	np->fn_size += nbytes;
+	size -= nbytes;
+	while (nbytes > 0) {
+		np->fn_buf[pos] = *p++;
+		if (++pos > PIPE_BUF)
+			pos = 0;
+		nbytes--;
+		count++;
+	}
+
+	wakeup_reader(vp);
+
+	if (size > 0)
+		goto again;
+
+	*result = count;
+	return 0;
+}
+
+static int
+fifo_ioctl(vnode_t vp, file_t fp, u_long cmd, void *arg)
+{
+	DPRINTF(("fifo_ioctl\n"));
+	return EINVAL;
+}
+
+static int
+fifo_lookup(vnode_t dvp, char *name, vnode_t vp)
+{
+	list_t head, n;
+	struct fifo_node *np = NULL;
+	int found;
+
+	DPRINTF(("fifo_lookup: %s\n", name));
+
+	if (*name == '\0')
+		return ENOENT;
+
+	mutex_lock(&fifo_lock);
+
+	found = 0;
+	head = &fifo_head;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		np = list_entry(n, struct fifo_node, fn_link);
+		if (strcmp(name, np->fn_name) == 0) {
+			found = 1;
+			break;
+		}
+	}
+	if (found == 0) {
+		mutex_unlock(&fifo_lock);
+		return ENOENT;
+	}
+	vp->v_data = np;
+	vp->v_mode = ALLPERMS;
+	vp->v_size = 0;
+	vp->v_type = VFIFO;
+	mutex_unlock(&fifo_lock);
+	return 0;
+}
+
+static int
+fifo_create(vnode_t dvp, char *name, mode_t mode)
+{
+	struct fifo_node *np;
+	size_t len;
+
+	DPRINTF(("create %s in %s\n", name, dvp->v_path));
+
+#if 0
+	if (!S_ISFIFO(mode))
+		return EINVAL;
+#endif
+
+	if ((np = malloc(sizeof(struct fifo_node))) == NULL)
+		return ENOMEM;
+
+	if ((np->fn_buf = malloc(PIPE_BUF)) == NULL) {
+		free(np);
+		return ENOMEM;
+	}
+	len = strlen(name) + 1;
+	np->fn_name = malloc(len);
+	if (np->fn_name == NULL) {
+		free(np->fn_buf);
+		free(np);
+		return ENOMEM;
+	}
+
+	strlcpy(np->fn_name, name, len);
+	mutex_init(&np->fn_rmtx);
+	mutex_init(&np->fn_wmtx);
+	cond_init(&np->fn_rcond);
+	cond_init(&np->fn_wcond);
+	np->fn_readers = 0;
+	np->fn_writers = 0;
+	np->fn_start = 0;
+	np->fn_size = 0;
+
+	mutex_lock(&fifo_lock);
+	list_insert(&fifo_head, &np->fn_link);
+	mutex_unlock(&fifo_lock);
+	return 0;
+}
+
+static void
+cleanup_fifo(vnode_t vp)
+{
+	struct fifo_node *np = vp->v_data;
+
+	mutex_lock(&fifo_lock);
+	list_remove(&np->fn_link);
+	mutex_unlock(&fifo_lock);
+
+	free(np->fn_name);
+	free(np->fn_buf);
+	free(np);
+
+	vp->v_data = NULL;
+}
+
+static int
+fifo_remove(vnode_t dvp, vnode_t vp, char *name)
+{
+	DPRINTF(("remove %s in %s\n", name, dvp->v_path));
+
+	cleanup_fifo(vp);
+	return 0;
+}
+
+/*
+ * @vp: vnode of the directory.
+ */
+static int
+fifo_readdir(vnode_t vp, file_t fp, struct dirent *dir)
+{
+	struct fifo_node *np;
+	list_t head, n;
+	int i;
+
+	mutex_lock(&fifo_lock);
+
+	if (fp->f_offset == 0) {
+		dir->d_type = DT_DIR;
+		strlcpy((char *)&dir->d_name, ".", sizeof(dir->d_name));
+	} else if (fp->f_offset == 1) {
+		dir->d_type = DT_DIR;
+		strlcpy((char *)&dir->d_name, "..", sizeof(dir->d_name));
+	} else {
+		i = 0;
+		np = NULL;
+		head = &fifo_head;
+		for (n = list_first(head); n != head; n = list_next(n)) {
+			if (i == (fp->f_offset - 2)) {
+				np = list_entry(n, struct fifo_node, fn_link);
+				break;
+			}
+		}
+		if (np == NULL) {
+			mutex_unlock(&fifo_lock);
+			return ENOENT;
+		}
+		dir->d_type = DT_FIFO;
+		strlcpy((char *)&dir->d_name, np->fn_name,
+			sizeof(dir->d_name));
+	}
+	dir->d_fileno = fp->f_offset;
+	dir->d_namlen = (uint16_t)strlen(dir->d_name);
+
+	fp->f_offset++;
+
+	mutex_unlock(&fifo_lock);
+	return 0;
+}
+
+int
+fifofs_init(void)
+{
+	list_init(&fifo_head);
+	return 0;
+}
+
+
+static void
+wait_reader(vnode_t vp)
+{
+	struct fifo_node *np = vp->v_data;
+
+	DPRINTF(("wait_reader: %x\n", np));
+	vn_unlock(vp);
+	mutex_lock(&np->fn_rmtx);
+	cond_wait(&np->fn_rcond, &np->fn_rmtx);
+	mutex_unlock(&np->fn_rmtx);
+	vn_lock(vp);
+}
+
+static void
+wakeup_writer(vnode_t vp)
+{
+	struct fifo_node *np = vp->v_data;
+
+	DPRINTF(("wakeup_writer: %x\n", np));
+	cond_broadcast(&np->fn_rcond);
+}
+
+static void
+wait_writer(vnode_t vp)
+{
+	struct fifo_node *np = vp->v_data;
+
+	DPRINTF(("wait_writer: %x\n", np));
+	vn_unlock(vp);
+	mutex_lock(&np->fn_wmtx);
+	cond_wait(&np->fn_wcond, &np->fn_wmtx);
+	mutex_unlock(&np->fn_wmtx);
+	vn_lock(vp);
+}
+
+static void
+wakeup_reader(vnode_t vp)
+{
+	struct fifo_node *np = vp->v_data;
+
+	DPRINTF(("wakeup_reader: %x\n", np));
+	cond_broadcast(&np->fn_wcond);
+}
diff --git a/prex-0.9.0/usr/server/fs/ramfs/Makefile b/prex-0.9.0/usr/server/fs/ramfs/Makefile
new file mode 100755
index 0000000..63729dc
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/ramfs/Makefile
@@ -0,0 +1,4 @@
+TARGET=		ramfs.o
+SRCS=		ramfs_vfsops.c ramfs_vnops.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/server/fs/ramfs/ramfs.h b/prex-0.9.0/usr/server/fs/ramfs/ramfs.h
new file mode 100755
index 0000000..e15bba2
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/ramfs/ramfs.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _RAMFS_H
+#define _RAMFS_H
+
+#include <sys/cdefs.h>
+#include <sys/prex.h>
+#include <sys/types.h>
+
+/* #define DEBUG_RAMFS 1 */
+
+#ifdef DEBUG_RAMFS
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)	do {} while (0)
+#define ASSERT(e)
+#endif
+
+#if CONFIG_FS_THREADS > 1
+#define malloc(s)		malloc_r(s)
+#define free(p)			free_r(p)
+#else
+#define mutex_init(m)		do {} while (0)
+#define mutex_destroy(m)	do {} while (0)
+#define mutex_lock(m)		do {} while (0)
+#define mutex_unlock(m)		do {} while (0)
+#define mutex_trylock(m)	do {} while (0)
+#endif
+
+/*
+ * File/directory node for RAMFS
+ */
+struct ramfs_node {
+	struct	ramfs_node *rn_next;   /* next node in the same directory */
+	struct	ramfs_node *rn_child;  /* first child node */
+	int	 rn_type;	/* file or directory */
+	char	*rn_name;	/* name (null-terminated) */
+	size_t	 rn_namelen;	/* length of name not including terminator */
+	size_t	 rn_size;	/* file size */
+	char	*rn_buf;	/* buffer to the file data */
+	size_t	 rn_bufsize;	/* allocated buffer size */
+};
+
+__BEGIN_DECLS
+struct ramfs_node *ramfs_allocate_node(char *name, int type);
+void ramfs_free_node(struct ramfs_node *node);
+__END_DECLS
+
+#endif /* !_RAMFS_H */
diff --git a/prex-0.9.0/usr/server/fs/ramfs/ramfs_vfsops.c b/prex-0.9.0/usr/server/fs/ramfs/ramfs_vfsops.c
new file mode 100755
index 0000000..1484a26
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/ramfs/ramfs_vfsops.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/vnode.h>
+#include <sys/mount.h>
+
+#include <errno.h>
+
+#include "ramfs.h"
+
+extern struct vnops ramfs_vnops;
+
+static int ramfs_mount(mount_t mp, char *dev, int flags, void *data);
+static int ramfs_unmount(mount_t mp);
+#define ramfs_sync	((vfsop_sync_t)vfs_nullop)
+#define ramfs_vget	((vfsop_vget_t)vfs_nullop)
+#define ramfs_statfs	((vfsop_statfs_t)vfs_nullop)
+
+/*
+ * File system operations
+ */
+struct vfsops ramfs_vfsops = {
+	ramfs_mount,		/* mount */
+	ramfs_unmount,		/* unmount */
+	ramfs_sync,		/* sync */
+	ramfs_vget,		/* vget */
+	ramfs_statfs,		/* statfs */
+	&ramfs_vnops,		/* vnops */
+};
+
+/*
+ * Mount a file system.
+ */
+static int
+ramfs_mount(mount_t mp, char *dev, int flags, void *data)
+{
+	struct ramfs_node *np;
+
+	DPRINTF(("ramfs_mount: dev=%s\n", dev));
+
+	/* Create a root node */
+	np = ramfs_allocate_node("/", VDIR);
+	if (np == NULL)
+		return ENOMEM;
+	mp->m_root->v_data = np;
+	return 0;
+}
+
+/*
+ * Unmount a file system.
+ *
+ * NOTE: Currently, we don't support unmounting of the RAMFS. This is
+ *       because we have to deallocate all nodes included in all sub
+ *       directories, and it requires more work...
+ */
+static int
+ramfs_unmount(mount_t mp)
+{
+
+	return EBUSY;
+}
diff --git a/prex-0.9.0/usr/server/fs/ramfs/ramfs_vnops.c b/prex-0.9.0/usr/server/fs/ramfs/ramfs_vnops.c
new file mode 100755
index 0000000..ed7574b
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/ramfs/ramfs_vnops.c
@@ -0,0 +1,500 @@
+/*
+ * Copyright (c) 2006-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * rmafs_vnops.c - vnode operations for RAM file system.
+ */
+
+#include <sys/prex.h>
+
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/dirent.h>
+#include <sys/param.h>
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include "ramfs.h"
+
+#define ramfs_open	((vnop_open_t)vop_nullop)
+#define ramfs_close	((vnop_close_t)vop_nullop)
+static int ramfs_read	(vnode_t, file_t, void *, size_t, size_t *);
+static int ramfs_write	(vnode_t, file_t, void *, size_t, size_t *);
+#define ramfs_seek	((vnop_seek_t)vop_nullop)
+#define ramfs_ioctl	((vnop_ioctl_t)vop_einval)
+#define ramfs_fsync	((vnop_fsync_t)vop_nullop)
+static int ramfs_readdir(vnode_t, file_t, struct dirent *);
+static int ramfs_lookup	(vnode_t, char *, vnode_t);
+static int ramfs_create	(vnode_t, char *, mode_t);
+static int ramfs_remove	(vnode_t, vnode_t, char *);
+static int ramfs_rename	(vnode_t, vnode_t, char *, vnode_t, vnode_t, char *);
+static int ramfs_mkdir	(vnode_t, char *, mode_t);
+static int ramfs_rmdir	(vnode_t, vnode_t, char *);
+#define ramfs_getattr	((vnop_getattr_t)vop_nullop)
+#define ramfs_setattr	((vnop_setattr_t)vop_nullop)
+#define ramfs_inactive	((vnop_inactive_t)vop_nullop)
+static int ramfs_truncate(vnode_t, off_t);
+
+
+#if CONFIG_FS_THREADS > 1
+static mutex_t ramfs_lock = MUTEX_INITIALIZER;
+#endif
+
+/*
+ * vnode operations
+ */
+struct vnops ramfs_vnops = {
+	ramfs_open,		/* open */
+	ramfs_close,		/* close */
+	ramfs_read,		/* read */
+	ramfs_write,		/* write */
+	ramfs_seek,		/* seek */
+	ramfs_ioctl,		/* ioctl */
+	ramfs_fsync,		/* fsync */
+	ramfs_readdir,		/* readdir */
+	ramfs_lookup,		/* lookup */
+	ramfs_create,		/* create */
+	ramfs_remove,		/* remove */
+	ramfs_rename,		/* remame */
+	ramfs_mkdir,		/* mkdir */
+	ramfs_rmdir,		/* rmdir */
+	ramfs_getattr,		/* getattr */
+	ramfs_setattr,		/* setattr */
+	ramfs_inactive,		/* inactive */
+	ramfs_truncate,		/* truncate */
+};
+
+struct ramfs_node *
+ramfs_allocate_node(char *name, int type)
+{
+	struct ramfs_node *np;
+
+	np = malloc(sizeof(struct ramfs_node));
+	if (np == NULL)
+		return NULL;
+	memset(np, 0, sizeof(struct ramfs_node));
+
+	np->rn_namelen = strlen(name);
+	np->rn_name = malloc(np->rn_namelen + 1);
+	if (np->rn_name == NULL) {
+		free(np);
+		return NULL;
+	}
+	strlcpy(np->rn_name, name, np->rn_namelen + 1);
+	np->rn_type = type;
+	return np;
+}
+
+void
+ramfs_free_node(struct ramfs_node *np)
+{
+
+	free(np->rn_name);
+	free(np);
+}
+
+static struct ramfs_node *
+ramfs_add_node(struct ramfs_node *dnp, char *name, int type)
+{
+	struct ramfs_node *np, *prev;
+
+	np = ramfs_allocate_node(name, type);
+	if (np == NULL)
+		return NULL;
+
+	mutex_lock(&ramfs_lock);
+
+	/* Link to the directory list */
+	if (dnp->rn_child == NULL) {
+		dnp->rn_child = np;
+	} else {
+		prev = dnp->rn_child;
+		while (prev->rn_next != NULL)
+			prev = prev->rn_next;
+		prev->rn_next = np;
+	}
+	mutex_unlock(&ramfs_lock);
+	return np;
+}
+
+static int
+ramfs_remove_node(struct ramfs_node *dnp, struct ramfs_node *np)
+{
+	struct ramfs_node *prev;
+
+	if (dnp->rn_child == NULL)
+		return EBUSY;
+
+	mutex_lock(&ramfs_lock);
+
+	/* Unlink from the directory list */
+	if (dnp->rn_child == np) {
+		dnp->rn_child = np->rn_next;
+	} else {
+		for (prev = dnp->rn_child; prev->rn_next != np;
+		     prev = prev->rn_next) {
+			if (prev->rn_next == NULL) {
+				mutex_unlock(&ramfs_lock);
+				return ENOENT;
+			}
+		}
+		prev->rn_next = np->rn_next;
+	}
+	ramfs_free_node(np);
+
+	mutex_unlock(&ramfs_lock);
+	return 0;
+}
+
+static int
+ramfs_rename_node(struct ramfs_node *np, char *name)
+{
+	size_t len;
+	char *tmp;
+
+	len = strlen(name);
+	if (len <= np->rn_namelen) {
+		/* Reuse current name buffer */
+		strlcpy(np->rn_name, name, sizeof(np->rn_name));
+	} else {
+		/* Expand name buffer */
+		tmp = malloc(len + 1);
+		if (tmp == NULL)
+			return ENOMEM;
+		strlcpy(tmp, name, len + 1);
+		free(np->rn_name);
+		np->rn_name = tmp;
+	}
+	np->rn_namelen = len;
+	return 0;
+}
+
+static int
+ramfs_lookup(vnode_t dvp, char *name, vnode_t vp)
+{
+	struct ramfs_node *np, *dnp;
+	size_t len;
+	int found;
+
+	if (*name == '\0')
+		return ENOENT;
+
+	mutex_lock(&ramfs_lock);
+
+	len = strlen(name);
+	dnp = dvp->v_data;
+	found = 0;
+	for (np = dnp->rn_child; np != NULL; np = np->rn_next) {
+		if (np->rn_namelen == len &&
+		    memcmp(name, np->rn_name, len) == 0) {
+			found = 1;
+			break;
+		}
+	}
+	if (found == 0) {
+		mutex_unlock(&ramfs_lock);
+		return ENOENT;
+	}
+	vp->v_data = np;
+	vp->v_mode = ALLPERMS;
+	vp->v_type = np->rn_type;
+	vp->v_size = np->rn_size;
+
+	mutex_unlock(&ramfs_lock);
+	return 0;
+}
+
+static int
+ramfs_mkdir(vnode_t dvp, char *name, mode_t mode)
+{
+	struct ramfs_node *np;
+
+	DPRINTF(("mkdir %s\n", name));
+	if (!S_ISDIR(mode))
+		return EINVAL;
+
+	np = ramfs_add_node(dvp->v_data, name, VDIR);
+	if (np == NULL)
+		return ENOMEM;
+	np->rn_size = 0;
+	return 0;
+}
+
+/* Remove a directory */
+static int
+ramfs_rmdir(vnode_t dvp, vnode_t vp, char *name)
+{
+
+	return ramfs_remove_node(dvp->v_data, vp->v_data);
+}
+
+/* Remove a file */
+static int
+ramfs_remove(vnode_t dvp, vnode_t vp, char *name)
+{
+	struct ramfs_node *np;
+	int error;
+
+	DPRINTF(("remove %s in %s\n", name, dvp->v_path));
+	error = ramfs_remove_node(dvp->v_data, vp->v_data);
+	if (error)
+		return error;
+
+	np = vp->v_data;
+	if (np->rn_buf != NULL)
+		vm_free(task_self(), np->rn_buf);
+	return 0;
+}
+
+/* Truncate file */
+static int
+ramfs_truncate(vnode_t vp, off_t length)
+{
+	struct ramfs_node *np;
+	void *new_buf;
+	size_t new_size;
+	task_t task;
+
+	DPRINTF(("truncate %s length=%d\n", vp->v_path, length));
+	np = vp->v_data;
+
+	if (length == 0) {
+		if (np->rn_buf != NULL) {
+			vm_free(task_self(), np->rn_buf);
+			np->rn_buf = NULL;
+			np->rn_bufsize = 0;
+		}
+	} else if (length > np->rn_bufsize) {
+		task = task_self();
+		new_size = round_page(length);
+		if (vm_allocate(task, &new_buf, new_size, 1))
+			return EIO;
+		if (np->rn_size != 0) {
+			memcpy(new_buf, np->rn_buf, vp->v_size);
+			vm_free(task, np->rn_buf);
+		}
+		np->rn_buf = new_buf;
+		np->rn_bufsize = new_size;
+	}
+	np->rn_size = length;
+	vp->v_size = length;
+	return 0;
+}
+
+/*
+ * Create empty file.
+ */
+static int
+ramfs_create(vnode_t dvp, char *name, mode_t mode)
+{
+	struct ramfs_node *np;
+
+	DPRINTF(("create %s in %s\n", name, dvp->v_path));
+	if (!S_ISREG(mode))
+		return EINVAL;
+
+	np = ramfs_add_node(dvp->v_data, name, VREG);
+	if (np == NULL)
+		return ENOMEM;
+	return 0;
+}
+
+static int
+ramfs_read(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	struct ramfs_node *np;
+	off_t off;
+
+	*result = 0;
+	if (vp->v_type == VDIR)
+		return EISDIR;
+	if (vp->v_type != VREG)
+		return EINVAL;
+
+	off = fp->f_offset;
+	if (off >= (off_t)vp->v_size)
+		return 0;
+
+	if (vp->v_size - off < size)
+		size = vp->v_size - off;
+
+	np = vp->v_data;
+	memcpy(buf, np->rn_buf + off, size);
+
+	fp->f_offset += size;
+	*result = size;
+	return 0;
+}
+
+static int
+ramfs_write(vnode_t vp, file_t fp, void *buf, size_t size, size_t *result)
+{
+	struct ramfs_node *np;
+	off_t file_pos, end_pos;
+	void *new_buf;
+	size_t new_size;
+	task_t task;
+
+	*result = 0;
+	if (vp->v_type == VDIR)
+		return EISDIR;
+	if (vp->v_type != VREG)
+		return EINVAL;
+
+	np = vp->v_data;
+	/* Check if the file position exceeds the end of file. */
+	end_pos = vp->v_size;
+	file_pos = (fp->f_flags & O_APPEND) ? end_pos : fp->f_offset;
+	if (file_pos + size > (size_t)end_pos) {
+		/* Expand the file size before writing to it */
+		end_pos = file_pos + size;
+		if (end_pos > (off_t)np->rn_bufsize) {
+			task = task_self();
+			/*
+			 * We allocate the data buffer in page boundary.
+			 * So that we can reduce the memory allocation unless
+			 * the file size exceeds next page boundary.
+			 * This will prevent the memory fragmentation by
+			 * many malloc/free calls.
+			 */
+			new_size = round_page(end_pos);
+			if (vm_allocate(task, &new_buf, new_size, 1))
+				return EIO;
+			if (np->rn_size != 0) {
+				memcpy(new_buf, np->rn_buf, vp->v_size);
+				vm_free(task, np->rn_buf);
+			}
+			np->rn_buf = new_buf;
+			np->rn_bufsize = new_size;
+		}
+		np->rn_size = end_pos;
+		vp->v_size = end_pos;
+	}
+	memcpy(np->rn_buf + file_pos, buf, size);
+	fp->f_offset += size;
+	*result = size;
+	return 0;
+}
+
+static int
+ramfs_rename(vnode_t dvp1, vnode_t vp1, char *name1,
+	     vnode_t dvp2, vnode_t vp2, char *name2)
+{
+	struct ramfs_node *np, *old_np;
+	int error;
+
+	if (vp2) {
+		/* Remove destination file, first */
+		error = ramfs_remove_node(dvp2->v_data, vp2->v_data);
+		if (error)
+			return error;
+	}
+	/* Same directory ? */
+	if (dvp1 == dvp2) {
+		/* Change the name of existing file */
+		error = ramfs_rename_node(vp1->v_data, name2);
+		if (error)
+			return error;
+	} else {
+		/* Create new file or directory */
+		old_np = vp1->v_data;
+		np = ramfs_add_node(dvp2->v_data, name2, VREG);
+		if (np == NULL)
+			return ENOMEM;
+
+		if (vp1->v_type == VREG) {
+			/* Copy file data */
+			np->rn_buf = old_np->rn_buf;
+			np->rn_size = old_np->rn_size;
+			np->rn_bufsize = old_np->rn_bufsize;
+		}
+		/* Remove source file */
+		ramfs_remove_node(dvp1->v_data, vp1->v_data);
+	}
+	return 0;
+}
+
+/*
+ * @vp: vnode of the directory.
+ */
+static int
+ramfs_readdir(vnode_t vp, file_t fp, struct dirent *dir)
+{
+	struct ramfs_node *np, *dnp;
+	int i;
+
+	mutex_lock(&ramfs_lock);
+
+	if (fp->f_offset == 0) {
+		dir->d_type = DT_DIR;
+		strlcpy((char *)&dir->d_name, ".", sizeof(dir->d_name));
+	} else if (fp->f_offset == 1) {
+		dir->d_type = DT_DIR;
+		strlcpy((char *)&dir->d_name, "..", sizeof(dir->d_name));
+	} else {
+		dnp = vp->v_data;
+		np = dnp->rn_child;
+		if (np == NULL) {
+			mutex_unlock(&ramfs_lock);
+			return ENOENT;
+		}
+
+		for (i = 0; i != (fp->f_offset - 2); i++) {
+			np = np->rn_next;
+			if (np == NULL) {
+				mutex_unlock(&ramfs_lock);
+				return ENOENT;
+			}
+		}
+		if (np->rn_type == VDIR)
+			dir->d_type = DT_DIR;
+		else
+			dir->d_type = DT_REG;
+		strlcpy((char *)&dir->d_name, np->rn_name,
+			sizeof(dir->d_name));
+	}
+	dir->d_fileno = (uint32_t)fp->f_offset;
+	dir->d_namlen = (uint16_t)strlen(dir->d_name);
+
+	fp->f_offset++;
+
+	mutex_unlock(&ramfs_lock);
+	return 0;
+}
+
+int
+ramfs_init(void)
+{
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/Makefile b/prex-0.9.0/usr/server/fs/vfs/Makefile
new file mode 100755
index 0000000..a7cab41
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/Makefile
@@ -0,0 +1,6 @@
+TARGET=		vfscore.o
+SRCS=		main.c vfs_conf.c vfs_task.c vfs_syscalls.c \
+		vfs_mount.c vfs_bio.c vfs_vnode.c vfs_lookup.c \
+		vfs_security.c
+
+include $(SRCDIR)/mk/obj.mk
diff --git a/prex-0.9.0/usr/server/fs/vfs/main.c b/prex-0.9.0/usr/server/fs/vfs/main.c
new file mode 100755
index 0000000..e917946
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/main.c
@@ -0,0 +1,1129 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * main.c - File system server
+ */
+
+/*
+ * All file systems work as a sub-modules under VFS (Virtual File System).
+ * The routines in this file have the responsible to the following jobs.
+ *
+ *  - Interpret the IPC message and pass the request into VFS routines.
+ *  - Validate the some of passed arguments in the message.
+ *  - Mapping of the task ID and cwd/file pointers.
+ *
+ * Note: All path string is translated to the full path before passing
+ * it to the sys_* routines.
+ */
+
+#include <sys/prex.h>
+#include <sys/capability.h>
+#include <sys/param.h>
+#include <ipc/fs.h>
+#include <ipc/proc.h>
+#include <ipc/exec.h>
+#include <ipc/ipc.h>
+#include <sys/list.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/buf.h>
+#include <sys/file.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include "vfs.h"
+
+#ifdef DEBUG_VFS
+int	vfs_debug = VFSDB_FLAGS;
+#endif
+
+/*
+ * Message mapping
+ */
+struct msg_map {
+	int	code;
+	int	(*func)(struct task *, struct msg *);
+};
+
+#define MSGMAP(code, fn) {code, (int (*)(struct task *, struct msg *))fn}
+
+/* object for file service */
+static object_t fsobj;
+
+static int
+fs_mount(struct task *t, struct mount_msg *msg)
+{
+	int error = 0;
+
+	/* Check client's mount capability. */
+	if (task_chkcap(t->t_taskid, CAP_DISKADMIN) != 0)
+		error = EPERM;
+
+	if (error == 0) {
+		error = sys_mount(msg->dev, msg->dir, msg->fs, msg->flags,
+				(void *)msg->data);
+	}
+#ifdef DEBUG
+	if (error)
+		dprintf("VFS: mount failed!\n");
+#endif
+	return error;
+}
+
+static int
+fs_umount(struct task *t, struct path_msg *msg)
+{
+
+	/* Check mount capability. */
+	if (task_chkcap(t->t_taskid, CAP_DISKADMIN) != 0)
+		return EPERM;
+
+	return sys_umount(msg->path);
+}
+
+static int
+fs_sync(struct task *t, struct msg *msg)
+{
+
+	return sys_sync();
+}
+
+static int
+fs_open(struct task *t, struct open_msg *msg)
+{
+	char path[PATH_MAX];
+	file_t fp;
+	int fd, error;
+	int acc;
+
+	/* Find empty slot for file descriptor. */
+	if ((fd = task_newfd(t)) == -1)
+		return EMFILE;
+
+	acc = 0;
+	switch (msg->flags & O_ACCMODE) {
+	case O_RDONLY:
+		acc = VREAD;
+		break;
+	case O_WRONLY:
+		acc = VWRITE;
+		break;
+	case O_RDWR:
+		acc = VREAD | VWRITE;
+		break;
+	}
+	if ((error = task_conv(t, msg->path, acc, path)) != 0)
+		return error;
+
+	if ((error = sys_open(path, msg->flags, msg->mode, &fp)) != 0)
+		return error;
+
+	t->t_ofile[fd] = fp;
+	t->t_nopens++;
+	msg->fd = fd;
+	return 0;
+}
+
+static int
+fs_close(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	int fd, error;
+
+	fd = msg->data[0];
+	if (fd >= OPEN_MAX)
+		return EBADF;
+
+	fp = t->t_ofile[fd];
+	if (fp == NULL)
+		return EBADF;
+
+	if ((error = sys_close(fp)) != 0)
+		return error;
+
+	t->t_ofile[fd] = NULL;
+	t->t_nopens--;
+	return 0;
+}
+
+static int
+fs_mknod(struct task *t, struct open_msg *msg)
+{
+	char path[PATH_MAX];
+	int error;
+
+	if ((error = task_conv(t, msg->path, VWRITE, path)) != 0)
+		return error;
+
+	return sys_mknod(path, msg->mode);
+}
+
+static int
+fs_lseek(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	off_t offset, org;
+	int error, type;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+	offset = (off_t)msg->data[1];
+	type = msg->data[2];
+
+	error = sys_lseek(fp, offset, type, &org);
+	msg->data[0] = (int)org;
+	return error;
+}
+
+static int
+fs_read(struct task *t, struct io_msg *msg)
+{
+	file_t fp;
+	void *buf;
+	size_t size, bytes;
+	int error;
+
+	if ((fp = task_getfp(t, msg->fd)) == NULL)
+		return EBADF;
+	size = msg->size;
+	if ((error = vm_map(msg->hdr.task, msg->buf, size, &buf)) != 0)
+		return EFAULT;
+
+	error = sys_read(fp, buf, size, &bytes);
+	msg->size = bytes;
+	vm_free(task_self(), buf);
+	return error;
+}
+
+static int
+fs_write(struct task *t, struct io_msg *msg)
+{
+	file_t fp;
+	void *buf;
+	size_t size, bytes;
+	int error;
+
+	if ((fp = task_getfp(t, msg->fd)) == NULL)
+		return EBADF;
+	size = msg->size;
+	if ((error = vm_map(msg->hdr.task, msg->buf, size, &buf)) != 0)
+		return EFAULT;
+
+	error = sys_write(fp, buf, size, &bytes);
+	msg->size = bytes;
+	vm_free(task_self(), buf);
+	return error;
+}
+
+static int
+fs_ioctl(struct task *t, struct ioctl_msg *msg)
+{
+	file_t fp;
+
+	if ((fp = task_getfp(t, msg->fd)) == NULL)
+		return EBADF;
+
+	return sys_ioctl(fp, msg->request, msg->buf);
+}
+
+static int
+fs_fsync(struct task *t, struct msg *msg)
+{
+	file_t fp;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+
+	return sys_fsync(fp);
+}
+
+static int
+fs_fstat(struct task *t, struct stat_msg *msg)
+{
+	file_t fp;
+	struct stat *st;
+	int error;
+
+	if ((fp = task_getfp(t, msg->fd)) == NULL)
+		return EBADF;
+
+	st = &msg->st;
+	error = sys_fstat(fp, st);
+	return error;
+}
+
+static int
+fs_opendir(struct task *t, struct open_msg *msg)
+{
+	char path[PATH_MAX];
+	file_t fp;
+	int fd, error;
+
+	/* Find empty slot for file descriptor. */
+	if ((fd = task_newfd(t)) == -1)
+		return EMFILE;
+
+	/* Get the mounted file system and node */
+	if ((error = task_conv(t, msg->path, VREAD, path)) != 0)
+		return error;
+
+	if ((error = sys_opendir(path, &fp)) != 0)
+		return error;
+	t->t_ofile[fd] = fp;
+	msg->fd = fd;
+	return 0;
+}
+
+static int
+fs_closedir(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	int fd, error;
+
+	fd = msg->data[0];
+	if (fd >= OPEN_MAX)
+		return EBADF;
+	fp = t->t_ofile[fd];
+	if (fp == NULL)
+		return EBADF;
+
+	if ((error = sys_closedir(fp)) != 0)
+		return error;
+	t->t_ofile[fd] = NULL;
+	return 0;
+}
+
+static int
+fs_readdir(struct task *t, struct dir_msg *msg)
+{
+	file_t fp;
+
+	if ((fp = task_getfp(t, msg->fd)) == NULL)
+		return EBADF;
+
+	return sys_readdir(fp, &msg->dirent);
+}
+
+static int
+fs_rewinddir(struct task *t, struct msg *msg)
+{
+	file_t fp;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+
+	return sys_rewinddir(fp);
+}
+
+static int
+fs_seekdir(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	long loc;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+	loc = msg->data[1];
+
+	return sys_seekdir(fp, loc);
+}
+
+static int
+fs_telldir(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	long loc;
+	int error;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+	loc = msg->data[1];
+
+	if ((error = sys_telldir(fp, &loc)) != 0)
+		return error;
+	msg->data[0] = loc;
+	return 0;
+}
+
+static int
+fs_mkdir(struct task *t, struct open_msg *msg)
+{
+	char path[PATH_MAX];
+	int error;
+
+	if ((error = task_conv(t, msg->path, VWRITE, path)) != 0)
+		return error;
+
+	return sys_mkdir(path, msg->mode);
+}
+
+static int
+fs_rmdir(struct task *t, struct path_msg *msg)
+{
+	char path[PATH_MAX];
+	int error;
+
+	if (msg->path == NULL)
+		return ENOENT;
+	if ((error = task_conv(t, msg->path, VWRITE, path)) != 0)
+		return error;
+
+	return sys_rmdir(path);
+}
+
+static int
+fs_rename(struct task *t, struct path_msg *msg)
+{
+	char src[PATH_MAX];
+	char dest[PATH_MAX];
+	int error;
+
+	if (msg->path == NULL || msg->path2 == NULL)
+		return ENOENT;
+
+	if ((error = task_conv(t, msg->path, VREAD, src)) != 0)
+		return error;
+
+	if ((error = task_conv(t, msg->path2, VWRITE, dest)) != 0)
+		return error;
+
+	return sys_rename(src, dest);
+}
+
+static int
+fs_chdir(struct task *t, struct path_msg *msg)
+{
+	char path[PATH_MAX];
+	file_t fp;
+	int error;
+
+	if (msg->path == NULL)
+		return ENOENT;
+	if ((error = task_conv(t, msg->path, VREAD, path)) != 0)
+		return error;
+
+	/* Check if directory exits */
+	if ((error = sys_opendir(path, &fp)) != 0)
+		return error;
+	if (t->t_cwdfp)
+		sys_closedir(t->t_cwdfp);
+	t->t_cwdfp = fp;
+	strlcpy(t->t_cwd, path, sizeof(t->t_cwd));
+ 	return 0;
+}
+
+static int
+fs_fchdir(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	int fd;
+
+	fd = msg->data[0];
+	if ((fp = task_getfp(t, fd)) == NULL)
+		return EBADF;
+
+	if (t->t_cwdfp)
+		sys_closedir(t->t_cwdfp);
+	t->t_cwdfp = fp;
+	return sys_fchdir(fp, t->t_cwd);
+}
+
+static int
+fs_link(struct task *t, struct msg *msg)
+{
+	/* XXX */
+	return EPERM;
+}
+
+static int
+fs_unlink(struct task *t, struct path_msg *msg)
+{
+	char path[PATH_MAX];
+	int error;
+
+	if (msg->path == NULL)
+		return ENOENT;
+	if ((error = task_conv(t, msg->path, VWRITE, path)) != 0)
+		return error;
+
+	return sys_unlink(path);
+}
+
+static int
+fs_stat(struct task *t, struct stat_msg *msg)
+{
+	char path[PATH_MAX];
+	struct stat *st;
+	int error;
+
+	error = task_conv(t, msg->path, 0, path);
+	if (error == 0) {
+		st = &msg->st;
+		error = sys_stat(path, st);
+	}
+	return error;
+}
+
+static int
+fs_getcwd(struct task *t, struct path_msg *msg)
+{
+
+	strlcpy(msg->path, t->t_cwd, sizeof(msg->path));
+	return 0;
+}
+
+/*
+ * Duplicate a file descriptor
+ */
+static int
+fs_dup(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	int old_fd, new_fd;
+
+	old_fd = msg->data[0];
+	if ((fp = task_getfp(t, old_fd)) == NULL)
+		return EBADF;
+
+	/* Find smallest empty slot as new fd. */
+	if ((new_fd = task_newfd(t)) == -1)
+		return EMFILE;
+
+	t->t_ofile[new_fd] = fp;
+
+	/* Increment file reference */
+	vref(fp->f_vnode);
+	fp->f_count++;
+
+	msg->data[0] = new_fd;
+	return 0;
+}
+
+/*
+ * Duplicate a file descriptor to a particular value.
+ */
+static int
+fs_dup2(struct task *t, struct msg *msg)
+{
+	file_t fp, org;
+	int old_fd, new_fd;
+	int error;
+
+	old_fd = msg->data[0];
+	new_fd = msg->data[1];
+	if (old_fd >= OPEN_MAX || new_fd >= OPEN_MAX)
+		return EBADF;
+	fp = t->t_ofile[old_fd];
+	if (fp == NULL)
+		return EBADF;
+	org = t->t_ofile[new_fd];
+	if (org != NULL) {
+		/* Close previous file if it's opened. */
+		error = sys_close(org);
+	}
+	t->t_ofile[new_fd] = fp;
+
+	/* Increment file reference */
+	vref(fp->f_vnode);
+	fp->f_count++;
+
+	msg->data[0] = new_fd;
+	return 0;
+}
+
+/*
+ * The file control system call.
+ */
+static int
+fs_fcntl(struct task *t, struct fcntl_msg *msg)
+{
+	file_t fp;
+	int arg, new_fd;
+
+	if ((fp = task_getfp(t, msg->fd)) == NULL)
+		return EBADF;
+
+	arg = msg->arg;
+	switch (msg->cmd) {
+	case F_DUPFD:
+		if (arg >= OPEN_MAX)
+			return EINVAL;
+		/* Find smallest empty slot as new fd. */
+		if ((new_fd = task_newfd(t)) == -1)
+			return EMFILE;
+		t->t_ofile[new_fd] = fp;
+
+		/* Increment file reference */
+		vref(fp->f_vnode);
+		fp->f_count++;
+		msg->arg = new_fd;
+		break;
+	case F_GETFD:
+		msg->arg = fp->f_flags & FD_CLOEXEC;
+		break;
+	case F_SETFD:
+		fp->f_flags = (fp->f_flags & ~FD_CLOEXEC) |
+			(msg->arg & FD_CLOEXEC);
+		msg->arg = 0;
+		break;
+	case F_GETFL:
+	case F_SETFL:
+		msg->arg = -1;
+		break;
+	default:
+		msg->arg = -1;
+		break;
+	}
+	return 0;
+}
+
+/*
+ * Check permission for file access
+ */
+static int
+fs_access(struct task *t, struct path_msg *msg)
+{
+	char path[PATH_MAX];
+	int acc, mode, error = 0;
+
+	mode = msg->data[0];
+	acc = 0;
+	if (mode & R_OK)
+		acc |= VREAD;
+	if (mode & W_OK)
+		acc |= VWRITE;
+
+	if ((error = task_conv(t, msg->path, acc, path)) != 0)
+		return error;
+
+	return sys_access(path, mode);
+}
+
+/*
+ * Copy parent's cwd & file/directory descriptor to child's.
+ */
+static int
+fs_fork(struct task *t, struct msg *msg)
+{
+	struct task *newtask;
+	file_t fp;
+	int error, i;
+
+	DPRINTF(VFSDB_CORE, ("fs_fork\n"));
+
+	if ((error = task_alloc((task_t)msg->data[0], &newtask)) != 0)
+		return error;
+
+	/*
+	 * Copy task related data
+	 */
+	newtask->t_cwdfp = t->t_cwdfp;
+	strlcpy(newtask->t_cwd, t->t_cwd, sizeof(newtask->t_cwd));
+	for (i = 0; i < OPEN_MAX; i++) {
+		fp = t->t_ofile[i];
+		newtask->t_ofile[i] = fp;
+		/*
+		 * Increment file reference if it's
+		 * already opened.
+		 */
+		if (fp != NULL) {
+			vref(fp->f_vnode);
+			fp->f_count++;
+		}
+	}
+	if (newtask->t_cwdfp)
+		newtask->t_cwdfp->f_count++;
+	/* Increment cwd's reference count */
+	if (newtask->t_cwdfp)
+		vref(newtask->t_cwdfp->f_vnode);
+
+	DPRINTF(VFSDB_CORE, ("fs_fork-complete\n"));
+	return 0;
+}
+
+/*
+ * fs_exec() is called for POSIX exec().
+ * It closes all directory stream.
+ * File descriptor which is marked close-on-exec are also closed.
+ */
+static int
+fs_exec(struct task *t, struct msg *msg)
+{
+	task_t old_id, new_id;
+	struct task *target;
+	file_t fp;
+	int fd;
+
+	old_id = (task_t)msg->data[0];
+	new_id = (task_t)msg->data[1];
+
+	if (!(target = task_lookup(old_id)))
+		return EINVAL;
+
+	/* Update task id in the task. */
+	task_setid(target, new_id);
+
+	/* Close all directory descriptor */
+	for (fd = 0; fd < OPEN_MAX; fd++) {
+		fp = target->t_ofile[fd];
+		if (fp) {
+			if (fp->f_vnode->v_type == VDIR) {
+				sys_close(fp);
+				target->t_ofile[fd] = NULL;
+			}
+
+			/* XXX: need to check close-on-exec flag */
+		}
+	}
+	task_unlock(target);
+	return 0;
+}
+
+/*
+ * fs_exit() cleans up data for task's termination.
+ */
+static int
+fs_exit(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	int fd;
+
+	DPRINTF(VFSDB_CORE, ("fs_exit\n"));
+
+	/*
+	 * Close all files opened by task.
+	 */
+	for (fd = 0; fd < OPEN_MAX; fd++) {
+		fp = t->t_ofile[fd];
+		if (fp != NULL)
+			sys_close(fp);
+	}
+	if (t->t_cwdfp)
+		sys_close(t->t_cwdfp);
+	task_free(t);
+	return 0;
+}
+
+/*
+ * fs_register() is called by boot tasks.
+ * This can be called even when no fs is mounted.
+ */
+static int
+fs_register(struct task *t, struct msg *msg)
+{
+	struct task *tmp;
+	int error;
+
+	DPRINTF(VFSDB_CORE, ("fs_register\n"));
+
+	error = task_alloc(msg->hdr.task, &tmp);
+	return error;
+}
+
+static int
+fs_pipe(struct task *t, struct msg *msg)
+{
+#ifdef CONFIG_FIFOFS
+	char path[PATH_MAX];
+	file_t rfp, wfp;
+	int error, rfd, wfd;
+
+	DPRINTF(VFSDB_CORE, ("fs_pipe\n"));
+
+	if ((rfd = task_newfd(t)) == -1)
+		return EMFILE;
+	t->t_ofile[rfd] = (file_t)1; /* temp */
+
+	if ((wfd = task_newfd(t)) == -1) {
+		t->t_ofile[rfd] = NULL;
+		return EMFILE;
+	}
+	sprintf(path, "/mnt/fifo/pipe-%x-%d", (u_int)t->t_taskid, rfd);
+
+	if ((error = sys_mknod(path, S_IFIFO)) != 0)
+		goto out;
+	if ((error = sys_open(path, O_RDONLY | O_NONBLOCK, 0, &rfp)) != 0) {
+		goto out;
+	}
+	if ((error = sys_open(path, O_WRONLY | O_NONBLOCK, 0, &wfp)) != 0) {
+		goto out;
+	}
+	t->t_ofile[rfd] = rfp;
+	t->t_ofile[wfd] = wfp;
+	t->t_nopens += 2;
+	msg->data[0] = rfd;
+	msg->data[1] = wfd;
+	return 0;
+ out:
+	t->t_ofile[rfd] = NULL;
+	t->t_ofile[wfd] = NULL;
+	return error;
+#else
+	return ENOSYS;
+#endif
+}
+
+/*
+ * Return if specified file is a tty
+ */
+static int
+fs_isatty(struct task *t, struct msg *msg)
+{
+	file_t fp;
+	int istty = 0;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+
+	if (fp->f_vnode->v_flags & VISTTY)
+		istty = 1;
+	msg->data[0] = istty;
+	return 0;
+}
+
+static int
+fs_truncate(struct task *t, struct path_msg *msg)
+{
+	char path[PATH_MAX];
+	int error;
+
+	if (msg->path == NULL)
+		return ENOENT;
+	if ((error = task_conv(t, msg->path, VWRITE, path)) != 0)
+		return error;
+
+	return sys_truncate(path, msg->data[0]);
+}
+
+static int
+fs_ftruncate(struct task *t, struct msg *msg)
+{
+	file_t fp;
+
+	if ((fp = task_getfp(t, msg->data[0])) == NULL)
+		return EBADF;
+
+	return sys_ftruncate(fp, msg->data[1]);
+}
+
+/*
+ * Prepare for boot
+ */
+static int
+fs_boot(struct task *t, struct msg *msg)
+{
+	object_t execobj, procobj;
+	struct bind_msg bm;
+	struct msg m;
+
+	/* Check client's capability. */
+	if (task_chkcap(msg->hdr.task, CAP_PROTSERV) != 0)
+		return EPERM;
+
+	/*
+	 * Request exec server to bind an appropriate
+	 * capability for us.
+	 */
+	if (object_lookup("!exec", &execobj) != 0)
+		sys_panic("fs: no exec found");
+	bm.hdr.code = EXEC_BINDCAP;
+	strlcpy(bm.path, "/boot/fs", sizeof(bm.path));
+	msg_send(execobj, &bm, sizeof(bm));
+
+	/*
+	 * Notify to process server.
+	 */
+	if (object_lookup("!proc", &procobj) != 0)
+		sys_panic("fs: no proc found");
+	m.hdr.code = PS_REGISTER;
+	msg_send(procobj, &m, sizeof(m));
+
+	return 0;
+}
+
+/*
+ * Prepare for shutdown
+ */
+static int
+fs_shutdown(struct task *t, struct msg *msg)
+{
+
+	DPRINTF(VFSDB_CORE, ("fs_shutdown\n"));
+	return 0;
+}
+
+int
+fs_noop(void)
+{
+	return 0;
+}
+
+#ifdef DEBUG_VFS
+/*
+ * Dump internal data.
+ */
+static int
+fs_debug(struct task *t, struct msg *msg)
+{
+
+	dprintf("<File System Server>\n");
+	task_dump();
+	vnode_dump();
+	mount_dump();
+	return 0;
+}
+#endif
+
+static void
+vfs_init(void)
+{
+	const struct vfssw *fs;
+	struct msg msg;
+
+	/*
+	 * Initialize VFS core.
+	 */
+	task_init();
+	bio_init();
+	vnode_init();
+
+	/*
+	 * Initialize each file system.
+	 */
+	for (fs = vfssw; fs->vs_name; fs++) {
+		DPRINTF(VFSDB_CORE, ("VFS: initializing %s\n",
+				     fs->vs_name));
+		fs->vs_init();
+	}
+
+	/*
+	 * Create task data for ourselves.
+	 */
+	msg.hdr.task = task_self();
+	fs_register(NULL, &msg);
+}
+
+/*
+ * Run specified routine as a thread.
+ */
+static int
+run_thread(void (*entry)(void))
+{
+	task_t self;
+	thread_t t;
+	void *stack, *sp;
+	int error;
+
+	self = task_self();
+	if ((error = thread_create(self, &t)) != 0)
+		return error;
+	if ((error = vm_allocate(self, &stack, DFLSTKSZ, 1)) != 0)
+		return error;
+
+	sp = (void *)((u_long)stack + DFLSTKSZ - sizeof(u_long) * 3);
+	if ((error = thread_load(t, entry, sp)) != 0)
+		return error;
+
+	return thread_resume(t);
+}
+
+static void
+exception_handler(int sig)
+{
+
+	exception_return();
+}
+
+/*
+ * Message mapping
+ */
+static const struct msg_map fsmsg_map[] = {
+	MSGMAP( FS_MOUNT,	fs_mount ),
+	MSGMAP( FS_UMOUNT,	fs_umount ),
+	MSGMAP( FS_SYNC,	fs_sync ),
+	MSGMAP( FS_OPEN,	fs_open ),
+	MSGMAP( FS_CLOSE,	fs_close ),
+	MSGMAP( FS_MKNOD,	fs_mknod ),
+	MSGMAP( FS_LSEEK,	fs_lseek ),
+	MSGMAP( FS_READ,	fs_read ),
+	MSGMAP( FS_WRITE,	fs_write ),
+	MSGMAP( FS_IOCTL,	fs_ioctl ),
+	MSGMAP( FS_FSYNC,	fs_fsync ),
+	MSGMAP( FS_FSTAT,	fs_fstat ),
+	MSGMAP( FS_OPENDIR,	fs_opendir ),
+	MSGMAP( FS_CLOSEDIR,	fs_closedir ),
+	MSGMAP( FS_READDIR,	fs_readdir ),
+	MSGMAP( FS_REWINDDIR,	fs_rewinddir ),
+	MSGMAP( FS_SEEKDIR,	fs_seekdir ),
+	MSGMAP( FS_TELLDIR,	fs_telldir ),
+	MSGMAP( FS_MKDIR,	fs_mkdir ),
+	MSGMAP( FS_RMDIR,	fs_rmdir ),
+	MSGMAP( FS_RENAME,	fs_rename ),
+	MSGMAP( FS_CHDIR,	fs_chdir ),
+	MSGMAP( FS_LINK,	fs_link ),
+	MSGMAP( FS_UNLINK,	fs_unlink ),
+	MSGMAP( FS_STAT,	fs_stat ),
+	MSGMAP( FS_GETCWD,	fs_getcwd ),
+	MSGMAP( FS_DUP,		fs_dup ),
+	MSGMAP( FS_DUP2,	fs_dup2 ),
+	MSGMAP( FS_FCNTL,	fs_fcntl ),
+	MSGMAP( FS_ACCESS,	fs_access ),
+	MSGMAP( FS_FORK,	fs_fork ),
+	MSGMAP( FS_EXEC,	fs_exec ),
+	MSGMAP( FS_EXIT,	fs_exit ),
+	MSGMAP( FS_REGISTER,	fs_register ),
+	MSGMAP( FS_PIPE,	fs_pipe ),
+	MSGMAP( FS_ISATTY,	fs_isatty ),
+	MSGMAP( FS_TRUNCATE,	fs_truncate ),
+	MSGMAP( FS_FTRUNCATE,	fs_ftruncate ),
+	MSGMAP( FS_FCHDIR,	fs_fchdir ),
+	MSGMAP( STD_BOOT,	fs_boot ),
+	MSGMAP( STD_SHUTDOWN,	fs_shutdown ),
+#ifdef DEBUG_VFS
+	MSGMAP( STD_DEBUG,	fs_debug ),
+#endif
+	MSGMAP( 0,		NULL ),
+};
+
+/*
+ * File system thread.
+ */
+static void
+fs_thread(void)
+{
+	struct msg *msg;
+	const struct msg_map *map;
+	struct task *t;
+	int error;
+
+	msg = malloc(MAX_FSMSG);
+
+	/*
+	 * Message loop
+	 */
+	for (;;) {
+		/*
+		 * Wait for an incoming request.
+		 */
+		if ((error = msg_receive(fsobj, msg, MAX_FSMSG)) != 0)
+			continue;
+
+		error = EINVAL;
+		map = &fsmsg_map[0];
+		while (map->code != 0) {
+			if (map->code == msg->hdr.code) {
+				/*
+				 * Handle messages by non-registerd tasks
+				 */
+				if (map->code == STD_BOOT) {
+					error = fs_boot(NULL, msg);
+					break;
+				}
+				if (map->code == FS_REGISTER) {
+					error = fs_register(NULL, msg);
+					break;
+				}
+
+				/* Lookup and lock task */
+				t = task_lookup(msg->hdr.task);
+				if (t == NULL)
+					break;
+
+				/* Dispatch request */
+				error = (*map->func)(t, msg);
+				if (map->code != FS_EXIT)
+					task_unlock(t);
+				break;
+			}
+			map++;
+		}
+#ifdef DEBUG_VFS
+		if (error)
+			dprintf("VFS: task=%x code=%x error=%d\n",
+				msg->hdr.task, map->code, error);
+#endif
+		/*
+		 * Reply to the client.
+		 */
+		msg->hdr.status = error;
+		msg_reply(fsobj, msg, MAX_FSMSG);
+	}
+}
+
+/*
+ * Main routine for file system service
+ */
+int
+main(int argc, char *argv[])
+{
+	int i;
+
+	sys_log("Starting file system server\n");
+
+	DPRINTF(VFSDB_CORE, ("VFS: number of fs threads: %d\n",
+			     CONFIG_FS_THREADS));
+
+	/* Set thread priority. */
+	thread_setpri(thread_self(), PRI_FS);
+
+	/* Setup exception handler */
+	exception_setup(exception_handler);
+
+	/* Initialize the file systems. */
+	vfs_init();
+
+	/* Create an object to expose our service. */
+	if (object_create("!fs", &fsobj))
+		sys_panic("VFS: fail to create object");
+
+	/*
+	 * Create new server threads.
+	 */
+	i = CONFIG_FS_THREADS;
+	while (--i > 0) {
+		if (run_thread(fs_thread))
+			goto err;
+	}
+	fs_thread();
+
+	sys_panic("VFS: exit!");
+	exit(0);
+ err:
+	sys_panic("VFS: failed to create thread");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs.h b/prex-0.9.0/usr/server/fs/vfs/vfs.h
new file mode 100755
index 0000000..c37feaa
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs.h
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _VFS_H
+#define _VFS_H
+
+#include <sys/cdefs.h>
+#include <sys/prex.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/dirent.h>
+
+#include <assert.h>
+
+/* #define DEBUG_VFS 1 */
+
+/*
+ * Tunable parameters
+ */
+#define FSMAXNAMES	16		/* max length of 'file system' name */
+
+#ifdef DEBUG_VFS
+extern int vfs_debug;
+
+#define	VFSDB_CORE	0x00000001
+#define	VFSDB_SYSCALL	0x00000002
+#define	VFSDB_VNODE	0x00000004
+#define	VFSDB_BIO	0x00000008
+#define	VFSDB_CAP	0x00000010
+
+#define VFSDB_FLAGS	0x00000013
+
+#define	DPRINTF(_m,X)	if (vfs_debug & (_m)) dprintf X
+#define ASSERT(e)	dassert(e)
+#else
+#define	DPRINTF(_m, X)
+#define ASSERT(e)
+#endif
+
+#if CONFIG_FS_THREADS > 1
+#define malloc(s)		malloc_r(s)
+#define free(p)			free_r(p)
+#else
+#define mutex_init(m)		do {} while (0)
+#define mutex_destroy(m)	do {} while (0)
+#define mutex_lock(m)		do {} while (0)
+#define mutex_unlock(m)		do {} while (0)
+#define mutex_trylock(m)	do {} while (0)
+#endif
+
+/*
+ * per task data
+ */
+struct task {
+	struct list t_link;		/* hash link */
+	task_t	    t_taskid;		/* task id */
+	char 	    t_cwd[PATH_MAX];	/* current working directory */
+	file_t	    t_cwdfp;		/* directory for cwd */
+	file_t	    t_ofile[NOFILE];	/* pointers to file structures of open files */
+	int	    t_nopens;		/* number of opening files */
+	mutex_t	    t_lock;		/* lock for this task */
+};
+
+extern const struct vfssw vfssw[];
+
+__BEGIN_DECLS
+int	 sys_open(char *path, int flags, mode_t mode, file_t *pfp);
+int	 sys_close(file_t fp);
+int	 sys_read(file_t fp, void *buf, size_t size, size_t *result);
+int	 sys_write(file_t fp, void *buf, size_t size, size_t *result);
+int	 sys_lseek(file_t fp, off_t off, int type, off_t * cur_off);
+int	 sys_ioctl(file_t fp, u_long request, void *buf);
+int	 sys_fstat(file_t fp, struct stat *st);
+int	 sys_fsync(file_t fp);
+int	 sys_ftruncate(file_t fp, off_t length);
+
+int	 sys_opendir(char *path, file_t * file);
+int	 sys_closedir(file_t fp);
+int	 sys_readdir(file_t fp, struct dirent *dirent);
+int	 sys_rewinddir(file_t fp);
+int	 sys_seekdir(file_t fp, long loc);
+int	 sys_telldir(file_t fp, long *loc);
+int	 sys_fchdir(file_t fp, char *path);
+
+int	 sys_mkdir(char *path, mode_t mode);
+int	 sys_rmdir(char *path);
+int	 sys_mknod(char *path, mode_t mode);
+int	 sys_rename(char *src, char *dest);
+int	 sys_unlink(char *path);
+int	 sys_access(char *path, int mode);
+int	 sys_stat(char *path, struct stat *st);
+int	 sys_truncate(char *path, off_t length);
+
+int	 sys_mount(char *dev, char *dir, char *fsname, int flags, void *data);
+int	 sys_umount(char *path);
+int	 sys_sync(void);
+
+
+struct task *task_lookup(task_t task);
+int	 task_alloc(task_t task, struct task **pt);
+void	 task_free(struct task *t);
+void	 task_setid(struct task *t, task_t task);
+void	 task_unlock(struct task *t);
+
+file_t	 task_getfp(struct task *t, int fd);
+void	 task_setfp(struct task *t, int fd, file_t fp);
+int	 task_newfd(struct task *t);
+void	 task_delfd(struct task *t, int fd);
+
+int	 task_conv(struct task *t, char *path, int mode, char *full);
+void	 task_init(void);
+
+int	 sec_file_permission(task_t task, char *path, int mode);
+int	 sec_vnode_permission(char *path);
+
+int	 namei(char *path, vnode_t *vpp);
+int	 lookup(char *path, vnode_t *vpp, char **name);
+void	 vnode_init(void);
+
+int	 vfs_findroot(char *path, mount_t *mp, char **root);
+void	 vfs_busy(mount_t mp);
+void	 vfs_unbusy(mount_t mp);
+
+int	 fs_noop(void);
+
+#ifdef DEBUG_VFS
+void	 task_dump(void);
+void	 vnode_dump(void);
+void	 mount_dump(void);
+#endif
+__END_DECLS
+
+#endif /* !_VFS_H */
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_bio.c b/prex-0.9.0/usr/server/fs/vfs/vfs_bio.c
new file mode 100755
index 0000000..5dfebeb
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_bio.c
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_bio.c - buffered I/O operations
+ */
+
+/*
+ * References:
+ *	Bach: The Design of the UNIX Operating System (Prentice Hall, 1986)
+ */
+
+#include <sys/prex.h>
+#include <sys/list.h>
+#include <sys/param.h>
+#include <sys/buf.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vfs.h"
+
+/* number of buffer cache */
+#define NBUFS		CONFIG_BUF_CACHE
+
+/* macros to clear/set/test flags. */
+#define	SET(t, f)	(t) |= (f)
+#define	CLR(t, f)	(t) &= ~(f)
+#define	ISSET(t, f)	((t) & (f))
+
+/*
+ * Global lock to access all buffer headers and lists.
+ */
+#if CONFIG_FS_THREADS > 1
+static mutex_t bio_lock = MUTEX_INITIALIZER;
+#define BIO_LOCK()	mutex_lock(&bio_lock)
+#define BIO_UNLOCK()	mutex_unlock(&bio_lock)
+#else
+#define BIO_LOCK()
+#define BIO_UNLOCK()
+#endif
+
+
+/* set of buffers */
+static char buffers[NBUFS][BSIZE];
+
+static struct buf buf_table[NBUFS];
+static struct list free_list = LIST_INIT(free_list);
+
+static sem_t free_sem;
+
+
+/*
+ * Insert buffer to the head of free list
+ */
+static void
+bio_insert_head(struct buf *bp)
+{
+
+	list_insert(&free_list, &bp->b_link);
+	sem_post(&free_sem);
+}
+
+/*
+ * Insert buffer to the tail of free list
+ */
+static void
+bio_insert_tail(struct buf *bp)
+{
+
+	list_insert(list_prev(&free_list), &bp->b_link);
+	sem_post(&free_sem);
+}
+
+/*
+ * Remove buffer from free list
+ */
+static void
+bio_remove(struct buf *bp)
+{
+
+	sem_wait(&free_sem, 0);
+	ASSERT(!list_empty(&free_list));
+	list_remove(&bp->b_link);
+}
+
+/*
+ * Remove buffer from the head of free list
+ */
+static struct buf *
+bio_remove_head(void)
+{
+	struct buf *bp;
+
+	sem_wait(&free_sem, 0);
+	ASSERT(!list_empty(&free_list));
+	bp = list_entry(list_first(&free_list), struct buf, b_link);
+	list_remove(&bp->b_link);
+	return bp;
+}
+
+/*
+ * Determine if a block is in the cache.
+ */
+static struct buf *
+incore(dev_t dev, int blkno)
+{
+	struct buf *bp;
+	int i;
+
+	for (i = 0; i < NBUFS; i++) {
+		bp = &buf_table[i];
+		if (bp->b_blkno == blkno && bp->b_dev == dev &&
+		    !ISSET(bp->b_flags, B_INVAL))
+			return bp;
+	}
+	return NULL;
+}
+
+/*
+ * Assign a buffer for the given block.
+ *
+ * The block is selected from the buffer list with LRU
+ * algorithm.  If the appropriate block already exists in the
+ * block list, return it.  Otherwise, the least recently used
+ * block is used.
+ */
+struct buf *
+getblk(dev_t dev, int blkno)
+{
+	struct buf *bp;
+
+	DPRINTF(VFSDB_BIO, ("getblk: dev=%x blkno=%d\n", dev, blkno));
+ start:
+	BIO_LOCK();
+	bp = incore(dev, blkno);
+	if (bp != NULL) {
+		/* Block found in cache. */
+		if (ISSET(bp->b_flags, B_BUSY)) {
+			/*
+			 * Wait buffer ready.
+			 */
+			BIO_UNLOCK();
+			mutex_lock(&bp->b_lock);
+			mutex_unlock(&bp->b_lock);
+			/* Scan again if it's busy */
+			goto start;
+		}
+		bio_remove(bp);
+		SET(bp->b_flags, B_BUSY);
+	} else {
+		bp = bio_remove_head();
+		if (ISSET(bp->b_flags, B_DELWRI)) {
+			BIO_UNLOCK();
+			bwrite(bp);
+			goto start;
+		}
+		bp->b_flags = B_BUSY;
+		bp->b_dev = dev;
+		bp->b_blkno = blkno;
+	}
+	mutex_lock(&bp->b_lock);
+	BIO_UNLOCK();
+	DPRINTF(VFSDB_BIO, ("getblk: done bp=%x\n", bp));
+	return bp;
+}
+
+/*
+ * Release a buffer, with no I/O implied.
+ */
+void
+brelse(struct buf *bp)
+{
+	ASSERT(ISSET(bp->b_flags, B_BUSY));
+	DPRINTF(VFSDB_BIO, ("brelse: bp=%x dev=%x blkno=%d\n",
+				bp, bp->b_dev, bp->b_blkno));
+
+	BIO_LOCK();
+	CLR(bp->b_flags, B_BUSY);
+	mutex_unlock(&bp->b_lock);
+	if (ISSET(bp->b_flags, B_INVAL))
+		bio_insert_head(bp);
+	else
+		bio_insert_tail(bp);
+	BIO_UNLOCK();
+}
+
+/*
+ * Block read with cache.
+ * @dev:   device id to read from.
+ * @blkno: block number.
+ * @buf:   buffer pointer to be returned.
+ *
+ * An actual read operation is done only when the cached
+ * buffer is dirty.
+ */
+int
+bread(dev_t dev, int blkno, struct buf **bpp)
+{
+	struct buf *bp;
+	size_t size;
+	int error;
+
+	DPRINTF(VFSDB_BIO, ("bread: dev=%x blkno=%d\n", dev, blkno));
+	bp = getblk(dev, blkno);
+
+	if (!ISSET(bp->b_flags, (B_DONE | B_DELWRI))) {
+		size = BSIZE;
+		error = device_read((device_t)dev, bp->b_data, &size, blkno);
+		if (error) {
+			DPRINTF(VFSDB_BIO, ("bread: i/o error\n"));
+			brelse(bp);
+			return error;
+		}
+	}
+	CLR(bp->b_flags, B_INVAL);
+	SET(bp->b_flags, (B_READ | B_DONE));
+	DPRINTF(VFSDB_BIO, ("bread: done bp=%x\n\n", bp));
+	*bpp = bp;
+	return 0;
+}
+
+/*
+ * Block write with cache.
+ * @buf:   buffer to write.
+ *
+ * The data is copied to the buffer.
+ * Then release the buffer.
+ */
+int
+bwrite(struct buf *bp)
+{
+	size_t size;
+	int error;
+
+	ASSERT(ISSET(bp->b_flags, B_BUSY));
+	DPRINTF(VFSDB_BIO, ("bwrite: dev=%x blkno=%d\n", bp->b_dev,
+			    bp->b_blkno));
+
+	BIO_LOCK();
+	CLR(bp->b_flags, (B_READ | B_DONE | B_DELWRI));
+	BIO_UNLOCK();
+
+	size = BSIZE;
+	error = device_write((device_t)bp->b_dev, bp->b_data, &size,
+			   bp->b_blkno);
+	if (error)
+		return error;
+	BIO_LOCK();
+	SET(bp->b_flags, B_DONE);
+	BIO_UNLOCK();
+	brelse(bp);
+	return 0;
+}
+
+/*
+ * Delayed write.
+ *
+ * The buffer is marked dirty, but an actual I/O is not
+ * performed.  This routine should be used when the buffer
+ * is expected to be modified again soon.
+ */
+void
+bdwrite(struct buf *bp)
+{
+
+	BIO_LOCK();
+	SET(bp->b_flags, B_DELWRI);
+	CLR(bp->b_flags, B_DONE);
+	BIO_UNLOCK();
+	brelse(bp);
+}
+
+/*
+ * Flush write-behind block
+ */
+void
+bflush(struct buf *bp)
+{
+
+	BIO_LOCK();
+	if (ISSET(bp->b_flags, B_DELWRI))
+		bwrite(bp);
+	BIO_UNLOCK();
+}
+
+/*
+ * Invalidate buffer for specified device.
+ * This is called when unmount.
+ */
+void
+binval(dev_t dev)
+{
+	struct buf *bp;
+	int i;
+
+	BIO_LOCK();
+	for (i = 0; i < NBUFS; i++) {
+		bp = &buf_table[i];
+		if (bp->b_dev == dev) {
+			if (ISSET(bp->b_flags, B_DELWRI))
+				bwrite(bp);
+			else if (ISSET(bp->b_flags, B_BUSY))
+				brelse(bp);
+			bp->b_flags = B_INVAL;
+		}
+	}
+	BIO_UNLOCK();
+}
+
+/*
+ * Invalidate all buffers.
+ * This is called when unmount.
+ */
+void
+bio_sync(void)
+{
+	struct buf *bp;
+	int i;
+
+ start:
+	BIO_LOCK();
+	for (i = 0; i < NBUFS; i++) {
+		bp = &buf_table[i];
+		if (ISSET(bp->b_flags, B_BUSY)) {
+			BIO_UNLOCK();
+			mutex_lock(&bp->b_lock);
+			mutex_unlock(&bp->b_lock);
+			goto start;
+		}
+		if (ISSET(bp->b_flags, B_DELWRI))
+			bwrite(bp);
+	}
+	BIO_UNLOCK();
+}
+
+/*
+ * Initialize the buffer I/O system.
+ */
+void
+bio_init(void)
+{
+	struct buf *bp;
+	int i;
+
+	for (i = 0; i < NBUFS; i++) {
+		bp = &buf_table[i];
+		bp->b_flags = B_INVAL;
+		bp->b_data = buffers[i];
+		mutex_init(&bp->b_lock);
+		list_insert(&free_list, &bp->b_link);
+	}
+	sem_init(&free_sem, NBUFS);
+
+	DPRINTF(VFSDB_BIO, ("bio: Buffer cache size %dK bytes\n",
+			    BSIZE * NBUFS / 1024));
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_conf.c b/prex-0.9.0/usr/server/fs/vfs/vfs_conf.c
new file mode 100755
index 0000000..6cc170a
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_conf.c
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_conf.c - File system configuration.
+ */
+
+#include <sys/prex.h>
+#include <sys/mount.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "vfs.h"
+
+extern struct vfsops ramfs_vfsops;
+extern struct vfsops devfs_vfsops;
+extern struct vfsops arfs_vfsops;
+extern struct vfsops fifofs_vfsops;
+extern struct vfsops fatfs_vfsops;
+
+extern int ramfs_init(void);
+extern int devfs_init(void);
+extern int arfs_init(void);
+extern int fifofs_init(void);
+extern int fatfs_init(void);
+
+/*
+ * VFS switch table
+ */
+const struct vfssw vfssw[] = {
+#ifdef CONFIG_RAMFS
+	{"ramfs",	ramfs_init,	&ramfs_vfsops}, /* RAM */
+#endif
+#ifdef CONFIG_DEVFS
+	{"devfs",	devfs_init,	&devfs_vfsops},	/* device fs */
+#endif
+#ifdef CONFIG_ARFS
+	{"arfs",	arfs_init,	&arfs_vfsops},	/* archive fs */
+#endif
+#ifdef CONFIG_FIFOFS
+	{"fifofs",	fifofs_init,	&fifofs_vfsops}, /* FIFO & pipe */
+#endif
+#ifdef CONFIG_FATFS
+	{"fatfs",	fatfs_init,	&fatfs_vfsops},	/* DOS FAT */
+#endif
+	{NULL, fs_noop, NULL},
+};
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_lookup.c b/prex-0.9.0/usr/server/fs/vfs/vfs_lookup.c
new file mode 100755
index 0000000..7081896
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_lookup.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_lookup.c - vnode lookup function.
+ */
+
+#include <sys/vnode.h>
+#include <sys/mount.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "vfs.h"
+
+/*
+ * Convert a pathname into a pointer to a locked vnode.
+ *
+ * @path: full path name.
+ * @vpp:  vnode to be returned.
+ */
+int
+namei(char *path, vnode_t *vpp)
+{
+	char *p;
+	char node[PATH_MAX];
+	char name[PATH_MAX];
+	mount_t mp;
+	vnode_t dvp, vp;
+	int error, i;
+
+	DPRINTF(VFSDB_VNODE, ("namei: path=%s\n", path));
+
+	/*
+	 * Convert a full path name to its mount point and
+	 * the local node in the file system.
+	 */
+	if (vfs_findroot(path, &mp, &p))
+		return ENOTDIR;
+	strlcpy(node, "/", sizeof(node));
+	strlcat(node, p, sizeof(node));
+	vp = vn_lookup(mp, node);
+	if (vp) {
+		/* vnode is already active. */
+		*vpp = vp;
+		return 0;
+	}
+	/*
+	 * Find target vnode, started from root directory.
+	 * This is done to attach the fs specific data to
+	 * the target vnode.
+	 */
+	if ((dvp = mp->m_root) == NULL)
+		sys_panic("VFS: no root");
+
+	vref(dvp);
+	vn_lock(dvp);
+	node[0] = '\0';
+
+	while (*p != '\0') {
+		/*
+		 * Get lower directory/file name.
+		 */
+		while (*p == '/')
+			p++;
+		for (i = 0; i < PATH_MAX; i++) {
+			if (*p == '\0' || *p == '/')
+				break;
+			name[i] = *p++;
+		}
+		name[i] = '\0';
+
+		/*
+		 * Get a vnode for the target.
+		 */
+		strlcat(node, "/", sizeof(node));
+		strlcat(node, name, sizeof(node));
+		vp = vn_lookup(mp, node);
+		if (vp == NULL) {
+			vp = vget(mp, node);
+			if (vp == NULL) {
+				vput(dvp);
+				return ENOMEM;
+			}
+			/* Find a vnode in this directory. */
+			error = VOP_LOOKUP(dvp, name, vp);
+			if (error || (*p == '/' && vp->v_type != VDIR)) {
+				/* Not found */
+				vput(vp);
+				vput(dvp);
+				return error;
+			}
+		}
+		vput(dvp);
+		dvp = vp;
+		while (*p != '\0' && *p != '/')
+			p++;
+	}
+
+	/*
+	 * Detemine X permission.
+	 */
+	if (vp->v_type != VDIR && sec_vnode_permission(path) != 0) {
+		vp->v_mode &= ~(0111);
+	}
+
+	*vpp = vp;
+	return 0;
+}
+
+/*
+ * Search a pathname.
+ * This is a very central but not so complicated routine. ;-P
+ *
+ * @path: full path.
+ * @vpp:  pointer to locked vnode for directory.
+ * @name: pointer to file name in path.
+ *
+ * This routine returns a locked directory vnode and file name.
+ */
+int
+lookup(char *path, vnode_t *vpp, char **name)
+{
+	char buf[PATH_MAX];
+	char root[] = "/";
+	char *file, *dir;
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_VNODE, ("lookup: path=%s\n", path));
+
+	/*
+	 * Get the path for directory.
+	 */
+	strlcpy(buf, path, sizeof(buf));
+	file = strrchr(buf, '/');
+	if (!buf[0])
+		return ENOTDIR;
+	if (file == buf)
+		dir = root;
+	else {
+		*file = '\0';
+		dir = buf;
+	}
+	/*
+	 * Get the vnode for directory
+	 */
+	if ((error = namei(dir, &vp)) != 0)
+		return error;
+	if (vp->v_type != VDIR) {
+		vput(vp);
+		return ENOTDIR;
+	}
+	*vpp = vp;
+
+	/*
+	 * Get the file name
+	 */
+	*name = strrchr(path, '/') + 1;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_mount.c b/prex-0.9.0/usr/server/fs/vfs/vfs_mount.c
new file mode 100755
index 0000000..840daba
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_mount.c
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_mount.c - mount operations
+ */
+
+#include <sys/prex.h>
+
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/dirent.h>
+#include <sys/list.h>
+#include <sys/buf.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "vfs.h"
+
+/*
+ * List for VFS mount points.
+ */
+static struct list mount_list = LIST_INIT(mount_list);
+
+/*
+ * Global lock to access mount point.
+ */
+#if CONFIG_FS_THREADS > 1
+static mutex_t mount_lock = MUTEX_INITIALIZER;
+#define MOUNT_LOCK()	mutex_lock(&mount_lock)
+#define MOUNT_UNLOCK()	mutex_unlock(&mount_lock)
+#else
+#define MOUNT_LOCK()
+#define MOUNT_UNLOCK()
+#endif
+
+/*
+ * Lookup file system.
+ */
+static const struct vfssw *
+fs_getfs(char *name)
+{
+	const struct vfssw *fs;
+
+	for (fs = vfssw; fs->vs_name; fs++) {
+		if (!strncmp(name, fs->vs_name, FSMAXNAMES))
+			break;
+	}
+	if (!fs->vs_name)
+		return NULL;
+	return fs;
+}
+
+int
+sys_mount(char *dev, char *dir, char *fsname, int flags, void *data)
+{
+	const struct vfssw *fs;
+	mount_t mp;
+	list_t head, n;
+	device_t device;
+	vnode_t vp, vp_covered;
+	int error;
+
+#ifdef DEBUG
+	dprintf("VFS: mounting %s at %s\n", fsname, dir);
+#endif
+
+	if (!dir || *dir == '\0')
+		return ENOENT;
+
+	/* Find a file system. */
+	if (!(fs = fs_getfs(fsname)))
+		return ENODEV;	/* No such file system */
+
+	/* Open device. NULL can be specified as a device. */
+	device = 0;
+	if (*dev != '\0') {
+		if (strncmp(dev, "/dev/", 5))
+			return ENOTBLK;
+		if ((error = device_open(dev + 5, DO_RDWR, &device)) != 0)
+			return error;
+	}
+
+	MOUNT_LOCK();
+
+	/* Check if device or directory has already been mounted. */
+	head = &mount_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		mp = list_entry(n, struct mount, m_link);
+		if (!strcmp(mp->m_path, dir) ||
+		    (device && mp->m_dev == (dev_t)device)) {
+			error = EBUSY;	/* Already mounted */
+			goto err1;
+		}
+	}
+	/*
+	 * Create VFS mount entry.
+	 */
+	if (!(mp = malloc(sizeof(struct mount)))) {
+		error = ENOMEM;
+		goto err1;
+	}
+	mp->m_count = 0;
+	mp->m_op = fs->vs_op;
+	mp->m_flags = flags;
+	mp->m_dev = (dev_t)device;
+	strlcpy(mp->m_path, dir, sizeof(mp->m_path));
+
+	/*
+	 * Get vnode to be covered in the upper file system.
+	 */
+	if (*dir == '/' && *(dir + 1) == '\0') {
+		/* Ignore if it mounts to global root directory. */
+		vp_covered = NULL;
+	} else {
+		if ((error = namei(dir, &vp_covered)) != 0) {
+
+			error = ENOENT;
+			goto err2;
+		}
+		if (vp_covered->v_type != VDIR) {
+			error = ENOTDIR;
+			goto err3;
+		}
+	}
+	mp->m_covered = vp_covered;
+
+	/*
+	 * Create a root vnode for this file system.
+	 */
+	if ((vp = vget(mp, "/")) == NULL) {
+		error = ENOMEM;
+		goto err3;
+	}
+	vp->v_type = VDIR;
+	vp->v_flags = VROOT;
+	vp->v_mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
+	mp->m_root = vp;
+
+	/*
+	 * Call a file system specific routine.
+	 */
+	if ((error = VFS_MOUNT(mp, dev, flags, data)) != 0)
+		goto err4;
+
+	if (mp->m_flags & MNT_RDONLY)
+		vp->v_mode &=~S_IWUSR;
+
+	/*
+	 * Keep reference count for root/covered vnode.
+	 */
+	vn_unlock(vp);
+	if (vp_covered)
+		vn_unlock(vp_covered);
+
+	/*
+	 * Insert to mount list
+	 */
+	list_insert(&mount_list, &mp->m_link);
+	MOUNT_UNLOCK();
+
+	return 0;	/* success */
+ err4:
+	vput(vp);
+ err3:
+	if (vp_covered)
+		vput(vp_covered);
+ err2:
+	free(mp);
+ err1:
+	device_close(device);
+
+	MOUNT_UNLOCK();
+	return error;
+}
+
+int
+sys_umount(char *path)
+{
+	mount_t mp;
+	list_t head, n;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_umount: path=%s\n", path));
+
+	MOUNT_LOCK();
+
+	/* Get mount entry */
+	head = &mount_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		mp = list_entry(n, struct mount, m_link);
+		if (!strcmp(path, mp->m_path))
+			break;
+	}
+	if (n == head) {
+		error = EINVAL;
+		goto out;
+	}
+	/*
+	 * Root fs can not be unmounted.
+	 */
+	if (mp->m_covered == NULL) {
+		error = EINVAL;
+		goto out;
+	}
+	if ((error = VFS_UNMOUNT(mp)) != 0)
+		goto out;
+	list_remove(&mp->m_link);
+
+	/* Decrement referece count of root vnode */
+	vrele(mp->m_covered);
+
+	/* Release all vnodes */
+	vflush(mp);
+
+	/* Flush all buffers */
+	binval(mp->m_dev);
+
+	if (mp->m_dev)
+		device_close((device_t)mp->m_dev);
+	free(mp);
+ out:
+	MOUNT_UNLOCK();
+	return error;
+}
+
+int
+sys_sync(void)
+{
+	mount_t mp;
+	list_t head, n;
+
+	/* Call each mounted file system. */
+	MOUNT_LOCK();
+	head = &mount_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		mp = list_entry(n, struct mount, m_link);
+		VFS_SYNC(mp);
+	}
+	MOUNT_UNLOCK();
+	bio_sync();
+	return 0;
+}
+
+/*
+ * Compare two path strings. Return matched length.
+ * @path: target path.
+ * @root: vfs root path as mount point.
+ */
+static size_t
+count_match(char *path, char *mount_root)
+{
+	size_t len = 0;
+
+	while (*path && *mount_root) {
+		if (*path++ != *mount_root++)
+			break;
+		len++;
+	}
+	if (*mount_root != '\0')
+		return 0;
+
+	if (len == 1 && *(path - 1) == '/')
+		return 1;
+
+	if (*path == '\0' || *path == '/')
+		return len;
+	return 0;
+}
+
+/*
+ * Get the root directory and mount point for specified path.
+ * @path: full path.
+ * @mp: mount point to return.
+ * @root: pointer to root directory in path.
+ */
+int
+vfs_findroot(char *path, mount_t *mp, char **root)
+{
+	mount_t m, tmp;
+	list_t head, n;
+	size_t len, max_len = 0;
+
+	if (!path)
+		return -1;
+
+	/* Find mount point from nearest path */
+	MOUNT_LOCK();
+	m = NULL;
+	head = &mount_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		tmp = list_entry(n, struct mount, m_link);
+		len = count_match(path, tmp->m_path);
+		if (len > max_len) {
+			max_len = len;
+			m = tmp;
+		}
+	}
+	MOUNT_UNLOCK();
+	if (m == NULL)
+		return -1;
+	*root = (char *)(path + max_len);
+	if (**root == '/')
+		(*root)++;
+	*mp = m;
+	return 0;
+}
+
+/*
+ * Mark a mount point as busy.
+ */
+void
+vfs_busy(mount_t mp)
+{
+
+	MOUNT_LOCK();
+	mp->m_count++;
+	MOUNT_UNLOCK();
+}
+
+
+/*
+ * Mark a mount point as busy.
+ */
+void
+vfs_unbusy(mount_t mp)
+{
+
+	MOUNT_LOCK();
+	mp->m_count--;
+	MOUNT_UNLOCK();
+}
+
+int
+vfs_nullop(void)
+{
+	return 0;
+}
+
+int
+vfs_einval(void)
+{
+	return EINVAL;
+}
+
+#ifdef DEBUG_VFS
+void
+mount_dump(void)
+{
+	list_t head, n;
+	mount_t mp;
+
+	MOUNT_LOCK();
+
+	dprintf("mount_dump\n");
+	dprintf("dev      count root\n");
+	dprintf("-------- ----- --------\n");
+	head = &mount_list;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		mp = list_entry(n, struct mount, m_link);
+		dprintf("%8x %5d %s\n", mp->m_dev, mp->m_count, mp->m_path);
+	}
+	MOUNT_UNLOCK();
+}
+#endif
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_security.c b/prex-0.9.0/usr/server/fs/vfs/vfs_security.c
new file mode 100755
index 0000000..276a7f4
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_security.c
@@ -0,0 +1,237 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_security.c - Routines to check security permission.
+ */
+
+/**
+ * General Design:
+ *
+ * Prex supports the file access permission based on the path
+ * name. It means that the applications can access to only
+ * certain area of the file system.
+ *
+ * The file system has the following structure:
+ *
+ * /boot
+ *
+ *   This directory contains the server executable files and
+ *   the system files required for OS boot. Reading this
+ *   directory is allowed only to the server process which has
+ *   CAP_SYSFILES capability.  Nobody can write to this
+ *   directory at any time.
+ *
+ * /bin
+ *
+ *   This directory contains the trusted applications.  This
+ *   is read-only directory for normal processes, and
+ *   CAP_SYSFILES is required to write files to it. In typical
+ *   case, a software installer has right to copy the
+ *   executable files to this directory.
+ *
+ * /etc
+ *
+ *   This directory contains the various configuration files.
+ *   This is read-only for normal processes, and CAP_SYSFILES
+ *   is required to modify /etc. The system configurator has
+ *   responsible to modify the contents in /etc.
+ *
+ * /private
+ *
+ *   This is the restricted system area and is inaccessible to
+ *   the normal processes. It contains private user data like
+ *   address book or calendar entries. CAP_USERFILES
+ *   capability is required to access to the /private
+ *   contents. The PIM application will have CAP_USERFILES.
+ *
+ * /all the rest
+ *
+ *   Access to all the other directories is unrestricted.
+ *
+ *
+ * <Directories and required capabilities>
+ *
+ *  Directory  Read           Write          Execute
+ *  ---------  -------------  -------------  --------------
+ *  /boot      CAP_SYSFILES   Not Allowed    Any
+ *
+ *  /bin       Any            CAP_SYSFILES   Any
+ *
+ *  /etc       Any            CAP_SYSFILES   Not Allowed
+ *
+ *  /private   CAP_USERFILES  CAP_USERFILES  Not Allowed
+ *
+ *  /other     Any            Any            Not Allowed
+ *
+ */
+
+#include <sys/prex.h>
+#include <sys/list.h>
+#include <sys/fcntl.h>
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "vfs.h"
+
+#define ACC_NG		-1		/* access is not allowed */
+#define ACC_OK		0		/* access is allowed */
+
+/*
+ * Capability mapping for path and file access
+ */
+struct fscap_map {
+	char	*path;			/* directory name */
+	size_t	len;			/* length of directory name */
+	int	cap_read;		/* required capability to read */
+	int	cap_write;		/* required capability to write */
+	int	cap_exec;		/* required capability to execute */
+};
+
+/*
+ * Capability mapping table
+ */
+static const struct fscap_map fscap_table[] =
+{
+	/* path        len read           write          execute       */
+	/* ----------- --- -------------- -------------- ------------- */
+	{ "/boot/",     6, CAP_SYSFILES,  ACC_NG,        ACC_OK       },
+	{ "/bin/",      5, ACC_OK,        CAP_SYSFILES,  ACC_OK       },
+	{ "/etc/",      5, ACC_OK,        CAP_SYSFILES,  ACC_NG       },
+	{ "/private/",  9, CAP_USERFILES, CAP_USERFILES, ACC_NG       },
+	{ NULL,         0, 0,             0,             0            },
+};
+
+
+/*
+ * Return true if the task has specified capability.
+ */
+static int
+capable(task_t task, cap_t cap)
+{
+
+	if (cap == ACC_OK)
+		return 1;
+
+	if (cap == ACC_NG)
+		return 0;
+
+	if (task_chkcap(task, cap) != 0) {
+		/* No capability */
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Check if the task has capability to access the file.
+ * Return 0 if it has capability.
+ */
+int
+sec_file_permission(task_t task, char *path, int acc)
+{
+	const struct fscap_map *map;
+	int found = 0;
+	int error = 0;
+
+	if (acc == 0)
+		return 0;
+
+	/*
+	 * Look up capability mapping table.
+	 */
+	map = &fscap_table[0];
+	while (map->path != NULL) {
+		if (!strncmp(path, map->path, map->len)) {
+			found = 1;
+			break;
+		}
+		map++;
+	}
+
+	if (found) {
+		/*
+		 * File under known directory.
+		 */
+		if (acc & VREAD) {
+			if (!capable(task, map->cap_read))
+				error = EACCES;
+		}
+		if (acc & VWRITE) {
+			if (!capable(task, map->cap_write))
+				error = EACCES;
+		}
+		DPRINTF(VFSDB_CAP,
+			("sec_file_permission: known directory "
+			 "path=%s read=%x write=%x execute=%d\n",
+			 path, map->cap_read, map->cap_write, map->cap_exec));
+	}
+
+	if (error != 0) {
+		DPRINTF(VFSDB_CAP,
+			("sec_file_permission: no capability for %02x "
+			 "task=%08x path=%s\n",
+			 acc, task, path));
+	}
+	return error;
+}
+
+/*
+ * Check if the file is executable.
+ */
+int
+sec_vnode_permission(char *path)
+{
+	const struct fscap_map *map;
+	int found = 0;
+
+	/*
+	 * Look up capability mapping table.
+	 */
+	map = &fscap_table[0];
+	while (map->path != NULL) {
+		if (!strncmp(path, map->path, map->len)) {
+			found = 1;
+			break;
+		}
+		map++;
+	}
+
+	/*
+	 * We allow the file execution only with the file
+	 * under specific directories.
+	 */
+	if ((found == 1) && (map->cap_exec == ACC_OK)) {
+		return 0;
+	}
+	return EACCES;
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_syscalls.c b/prex-0.9.0/usr/server/fs/vfs/vfs_syscalls.c
new file mode 100755
index 0000000..eac2734
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_syscalls.c
@@ -0,0 +1,757 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_syscalls.c - everything in this file is a routine implementing
+ *                  a VFS system call.
+ */
+
+#include <sys/prex.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/mount.h>
+#include <sys/dirent.h>
+#include <sys/list.h>
+#include <sys/buf.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "vfs.h"
+
+int
+sys_open(char *path, int flags, mode_t mode, file_t *pfp)
+{
+	vnode_t vp, dvp;
+	file_t fp;
+	char *filename;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_open: path=%s flags=%x mode=%x\n",
+				path, flags, mode));
+
+	flags = FFLAGS(flags);
+	if  ((flags & (FREAD | FWRITE)) == 0)
+		return EINVAL;
+	if (flags & O_CREAT) {
+		error = namei(path, &vp);
+		if (error == ENOENT) {
+			/* Create new file. */
+			if ((error = lookup(path, &dvp, &filename)) != 0)
+				return error;
+			if ((error = vn_access(dvp, VWRITE)) != 0) {
+				vput(dvp);
+				return error;
+			}
+			mode &= ~S_IFMT;
+			mode |= S_IFREG;
+			error = VOP_CREATE(dvp, filename, mode);
+			vput(dvp);
+			if (error)
+				return error;
+			if ((error = namei(path, &vp)) != 0)
+				return error;
+			flags &= ~O_TRUNC;
+		} else if (error) {
+			return error;
+		} else {
+			/* File already exits */
+			if (flags & O_EXCL) {
+				vput(vp);
+				return EEXIST;
+			}
+			flags &= ~O_CREAT;
+		}
+	} else {
+		/* Open */
+		if ((error = namei(path, &vp)) != 0)
+			return error;
+	}
+	if ((flags & O_CREAT) == 0) {
+		if (flags & FWRITE || flags & O_TRUNC) {
+			if ((error = vn_access(vp, VWRITE)) != 0) {
+				vput(vp);
+				return error;
+			}
+			if (vp->v_type == VDIR) {
+				/* Openning directory with writable. */
+				vput(vp);
+				return EISDIR;
+			}
+		}
+	}
+	/* Process truncate request */
+	if (flags & O_TRUNC) {
+		if (!(flags & FWRITE) || (vp->v_type == VDIR)) {
+			vput(vp);
+			return EINVAL;
+		}
+		if ((error = VOP_TRUNCATE(vp, 0)) != 0) {
+			vput(vp);
+			return error;
+		}
+	}
+	/* Setup file structure */
+	if (!(fp = malloc(sizeof(struct file)))) {
+		vput(vp);
+		return ENOMEM;
+	}
+	/* Request to file system */
+	if ((error = VOP_OPEN(vp, flags)) != 0) {
+		free(fp);
+		vput(vp);
+		return error;
+	}
+	memset(fp, 0, sizeof(struct file));
+	fp->f_vnode = vp;
+	fp->f_flags = flags;
+	fp->f_offset = 0;
+	fp->f_count = 1;
+	*pfp = fp;
+	vn_unlock(vp);
+	return 0;
+}
+
+int
+sys_close(file_t fp)
+{
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_close: fp=%x count=%d\n",
+				(u_int)fp, fp->f_count));
+
+	if (fp->f_count <= 0)
+		sys_panic("sys_close");
+
+	vp = fp->f_vnode;
+	if (--fp->f_count > 0) {
+		vrele(vp);
+		return 0;
+	}
+	vn_lock(vp);
+	if ((error = VOP_CLOSE(vp, fp)) != 0) {
+		vn_unlock(vp);
+		return error;
+	}
+	vput(vp);
+	free(fp);
+	return 0;
+}
+
+int
+sys_read(file_t fp, void *buf, size_t size, size_t *count)
+{
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_read: fp=%x buf=%x size=%d\n",
+				(u_int)fp, (u_int)buf, size));
+
+	if ((fp->f_flags & FREAD) == 0)
+		return EBADF;
+	if (size == 0) {
+		*count = 0;
+		return 0;
+	}
+	vp = fp->f_vnode;
+	vn_lock(vp);
+	error = VOP_READ(vp, fp, buf, size, count);
+	vn_unlock(vp);
+	return error;
+}
+
+int
+sys_write(file_t fp, void *buf, size_t size, size_t *count)
+{
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_write: fp=%x buf=%x size=%d\n",
+				(u_int)fp, (u_int)buf, size));
+
+	if ((fp->f_flags & FWRITE) == 0)
+		return EBADF;
+	if (size == 0) {
+		*count = 0;
+		return 0;
+	}
+	vp = fp->f_vnode;
+	vn_lock(vp);
+	error = VOP_WRITE(vp, fp, buf, size, count);
+	vn_unlock(vp);
+	return error;
+}
+
+int
+sys_lseek(file_t fp, off_t off, int type, off_t *origin)
+{
+	vnode_t vp;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_seek: fp=%x off=%d type=%d\n",
+				(u_int)fp, (u_int)off, type));
+
+	vp = fp->f_vnode;
+	vn_lock(vp);
+	switch (type) {
+	case SEEK_SET:
+		if (off < 0)
+			off = 0;
+		if (off > (off_t)vp->v_size)
+			off = vp->v_size;
+		break;
+	case SEEK_CUR:
+		if (fp->f_offset + off > (off_t)vp->v_size)
+			off = vp->v_size;
+		else if (fp->f_offset + off < 0)
+			off = 0;
+		else
+			off = fp->f_offset + off;
+		break;
+	case SEEK_END:
+		if (off > 0)
+			off = vp->v_size;
+		else if ((int)vp->v_size + off < 0)
+			off = 0;
+		else
+			off = vp->v_size + off;
+		break;
+	default:
+		vn_unlock(vp);
+		return EINVAL;
+	}
+	/* Request to check the file offset */
+	if (VOP_SEEK(vp, fp, fp->f_offset, off) != 0) {
+		vn_unlock(vp);
+		return EINVAL;
+	}
+	*origin = off;
+	fp->f_offset = off;
+	vn_unlock(vp);
+	return 0;
+}
+
+int
+sys_ioctl(file_t fp, u_long request, void *buf)
+{
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_ioctl: fp=%x request=%x\n", fp, request));
+
+	if ((fp->f_flags & (FREAD | FWRITE)) == 0)
+		return EBADF;
+
+	vp = fp->f_vnode;
+	vn_lock(vp);
+	error = VOP_IOCTL(vp, fp, request, buf);
+	vn_unlock(vp);
+	DPRINTF(VFSDB_SYSCALL, ("sys_ioctl: comp error=%d\n", error));
+	return error;
+}
+
+int
+sys_fsync(file_t fp)
+{
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_fsync: fp=%x\n", fp));
+
+	if ((fp->f_flags & FWRITE) == 0)
+		return EBADF;
+
+	vp = fp->f_vnode;
+	vn_lock(vp);
+	error = VOP_FSYNC(vp, fp);
+	vn_unlock(vp);
+	return error;
+}
+
+int
+sys_fstat(file_t fp, struct stat *st)
+{
+	vnode_t vp;
+	int error = 0;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_fstat: fp=%x\n", fp));
+
+	vp = fp->f_vnode;
+	vn_lock(vp);
+	error = vn_stat(vp, st);
+	vn_unlock(vp);
+	return error;
+}
+
+/*
+ * Return 0 if directory is empty
+ */
+static int
+check_dir_empty(char *path)
+{
+	int error;
+	file_t fp;
+	struct dirent dir;
+
+	DPRINTF(VFSDB_SYSCALL, ("check_dir_empty\n"));
+
+	if ((error = sys_opendir(path, &fp)) != 0)
+		return error;
+	do {
+		error = sys_readdir(fp, &dir);
+		if (error != 0 && error != EACCES)
+			break;
+	} while (!strcmp(dir.d_name, ".") || !strcmp(dir.d_name, ".."));
+
+	sys_closedir(fp);
+
+	if (error == ENOENT)
+		return 0;
+	else if (error == 0)
+		return EEXIST;
+	return error;
+}
+
+int
+sys_opendir(char *path, file_t *file)
+{
+	vnode_t dvp;
+	file_t fp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_opendir: path=%s\n", path));
+
+	if ((error = sys_open(path, O_RDONLY, 0, &fp)) != 0)
+		return error;
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		sys_close(fp);
+		return ENOTDIR;
+	}
+	vn_unlock(dvp);
+
+	*file = fp;
+	return 0;
+}
+
+int
+sys_closedir(file_t fp)
+{
+	vnode_t dvp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_closedir: fp=%x\n", fp));
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		return EBADF;
+	}
+	vn_unlock(dvp);
+	error = sys_close(fp);
+	return error;
+}
+
+int
+sys_readdir(file_t fp, struct dirent *dir)
+{
+	vnode_t dvp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_readdir: fp=%x\n", fp));
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		return EBADF;
+	}
+	error = VOP_READDIR(dvp, fp, dir);
+	DPRINTF(VFSDB_SYSCALL, ("sys_readdir: error=%d path=%s\n",
+				error, dir->d_name));
+	vn_unlock(dvp);
+	return error;
+}
+
+int
+sys_rewinddir(file_t fp)
+{
+	vnode_t dvp;
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		return EBADF;
+	}
+	fp->f_offset = 0;
+	vn_unlock(dvp);
+	return 0;
+}
+
+int
+sys_seekdir(file_t fp, long loc)
+{
+	vnode_t dvp;
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		return EBADF;
+	}
+	fp->f_offset = (off_t)loc;
+	vn_unlock(dvp);
+	return 0;
+}
+
+int
+sys_telldir(file_t fp, long *loc)
+{
+	vnode_t dvp;
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		return EBADF;
+	}
+	*loc = (long)fp->f_offset;
+	vn_unlock(dvp);
+	return 0;
+}
+
+int
+sys_mkdir(char *path, mode_t mode)
+{
+	char *name;
+	vnode_t vp, dvp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_mkdir: path=%s mode=%d\n",	path, mode));
+
+	if ((error = namei(path, &vp)) == 0) {
+		/* File already exists */
+		vput(vp);
+		return EEXIST;
+	}
+	/* Notice: vp is invalid here! */
+
+	if ((error = lookup(path, &dvp, &name)) != 0) {
+		/* Directory already exists */
+		return error;
+	}
+	if ((error = vn_access(dvp, VWRITE)) != 0)
+		goto out;
+	mode &= ~S_IFMT;
+	mode |= S_IFDIR;
+
+	error = VOP_MKDIR(dvp, name, mode);
+ out:
+	vput(dvp);
+	return error;
+}
+
+int
+sys_rmdir(char *path)
+{
+	vnode_t vp, dvp;
+	int error;
+	char *name;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_rmdir: path=%s\n", path));
+
+	if ((error = check_dir_empty(path)) != 0)
+		return error;
+	if ((error = namei(path, &vp)) != 0)
+		return error;
+	if ((error = vn_access(vp, VWRITE)) != 0)
+		goto out;
+	if (vp->v_type != VDIR) {
+		error = ENOTDIR;
+		goto out;
+	}
+	if (vp->v_flags & VROOT || vcount(vp) >= 2) {
+		error = EBUSY;
+		goto out;
+	}
+	if ((error = lookup(path, &dvp, &name)) != 0)
+		goto out;
+
+	error = VOP_RMDIR(dvp, vp, name);
+	vn_unlock(vp);
+	vgone(vp);
+	vput(dvp);
+	return error;
+
+ out:
+	vput(vp);
+	return error;
+}
+
+int
+sys_mknod(char *path, mode_t mode)
+{
+	char *name;
+	vnode_t vp, dvp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_mknod: path=%s mode=%d\n",	path, mode));
+
+	switch (mode & S_IFMT) {
+	case S_IFREG:
+	case S_IFDIR:
+	case S_IFIFO:
+	case S_IFSOCK:
+		/* OK */
+		break;
+	default:
+		return EINVAL;
+	}
+
+	if ((error = namei(path, &vp)) == 0) {
+		vput(vp);
+		return EEXIST;
+	}
+
+	if ((error = lookup(path, &dvp, &name)) != 0)
+		return error;
+	if ((error = vn_access(dvp, VWRITE)) != 0)
+		goto out;
+	if (S_ISDIR(mode))
+		error = VOP_MKDIR(dvp, name, mode);
+	else
+		error = VOP_CREATE(dvp, name, mode);
+ out:
+	vput(dvp);
+	return error;
+}
+
+int
+sys_rename(char *src, char *dest)
+{
+	vnode_t vp1, vp2 = 0, dvp1, dvp2;
+	char *sname, *dname;
+	int error;
+	size_t len;
+	char root[] = "/";
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_rename: src=%s dest=%s\n", src, dest));
+
+	if ((error = namei(src, &vp1)) != 0)
+		return error;
+	if ((error = vn_access(vp1, VWRITE)) != 0)
+		goto err1;
+
+	/* If source and dest are the same, do nothing */
+	if (!strncmp(src, dest, PATH_MAX))
+		goto err1;
+
+	/* Check if target is directory of source */
+	len = strlen(dest);
+	if (!strncmp(src, dest, len)) {
+		error = EINVAL;
+		goto err1;
+	}
+	/* Is the source busy ? */
+	if (vcount(vp1) >= 2) {
+		error = EBUSY;
+		goto err1;
+	}
+	/* Check type of source & target */
+	error = namei(dest, &vp2);
+	if (error == 0) {
+		/* target exists */
+		if (vp1->v_type == VDIR && vp2->v_type != VDIR) {
+			error = ENOTDIR;
+			goto err2;
+		} else if (vp1->v_type != VDIR && vp2->v_type == VDIR) {
+			error = EISDIR;
+			goto err2;
+		}
+		if (vp2->v_type == VDIR && check_dir_empty(dest)) {
+			error = EEXIST;
+			goto err2;
+		}
+
+		if (vcount(vp2) >= 2) {
+			error = EBUSY;
+			goto err2;
+		}
+	}
+
+	dname = strrchr(dest, '/');
+	if (dname == NULL) {
+		error = ENOTDIR;
+		goto err2;
+	}
+	if (dname == dest)
+		dest = root;
+
+	*dname = 0;
+	dname++;
+
+	if ((error = lookup(src, &dvp1, &sname)) != 0)
+		goto err2;
+
+	if ((error = namei(dest, &dvp2)) != 0)
+		goto err3;
+
+	/* The source and dest must be same file system */
+	if (dvp1->v_mount != dvp2->v_mount) {
+		error = EXDEV;
+		goto err4;
+	}
+	error = VOP_RENAME(dvp1, vp1, sname, dvp2, vp2, dname);
+ err4:
+	vput(dvp2);
+ err3:
+	vput(dvp1);
+ err2:
+	if (vp2)
+		vput(vp2);
+ err1:
+	vput(vp1);
+	return error;
+}
+
+int
+sys_unlink(char *path)
+{
+	char *name;
+	vnode_t vp, dvp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_unlink: path=%s\n", path));
+
+	if ((error = namei(path, &vp)) != 0)
+		return error;
+	if ((error = vn_access(vp, VWRITE)) != 0)
+		goto out;
+	if (vp->v_type == VDIR) {
+		error = EPERM;
+		goto out;
+	}
+	/* XXX: Need to allow unlink for opened file. */
+	if (vp->v_flags & VROOT || vcount(vp) >= 2) {
+		error = EBUSY;
+		goto out;
+	}
+	if ((error = lookup(path, &dvp, &name)) != 0)
+		goto out;
+
+	error = VOP_REMOVE(dvp, vp, name);
+
+	vn_unlock(vp);
+	vgone(vp);
+	vput(dvp);
+	return 0;
+ out:
+	vput(vp);
+	return error;
+}
+
+int
+sys_access(char *path, int mode)
+{
+	vnode_t vp;
+	int error, flags;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_access: path=%s mode=%x\n", path, mode));
+
+	/* If F_OK is set, we return here if file is not found. */
+	if ((error = namei(path, &vp)) != 0)
+		return error;
+
+	flags = 0;
+	if (mode & R_OK)
+		flags |= VREAD;
+	if (mode & W_OK)
+		flags |= VWRITE;
+	if (mode & X_OK)
+		flags |= VEXEC;
+
+	error = vn_access(vp, flags);
+
+	vput(vp);
+	return error;
+}
+
+int
+sys_stat(char *path, struct stat *st)
+{
+	vnode_t vp;
+	int error;
+
+	DPRINTF(VFSDB_SYSCALL, ("sys_stat: path=%s\n", path));
+
+	if ((error = namei(path, &vp)) != 0)
+		return error;
+	error = vn_stat(vp, st);
+	vput(vp);
+	return error;
+}
+
+int
+sys_truncate(char *path, off_t length)
+{
+	return 0;
+}
+
+int
+sys_ftruncate(file_t fp, off_t length)
+{
+	return 0;
+}
+
+int
+sys_fchdir(file_t fp, char *cwd)
+{
+	vnode_t dvp;
+
+	dvp = fp->f_vnode;
+	vn_lock(dvp);
+	if (dvp->v_type != VDIR) {
+		vn_unlock(dvp);
+		return EBADF;
+	}
+	strlcpy(cwd, dvp->v_path, PATH_MAX);
+	vn_unlock(dvp);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_task.c b/prex-0.9.0/usr/server/fs/vfs/vfs_task.c
new file mode 100755
index 0000000..1a06ec0
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_task.c
@@ -0,0 +1,324 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_task.c - Routines to manage the per task data.
+ */
+
+#include <sys/prex.h>
+#include <sys/list.h>
+
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "vfs.h"
+
+#define TASK_MAXBUCKETS	32		/* number of task hash buckets */
+
+#define TASKHASH(x)        (int)((x) & (TASK_MAXBUCKETS - 1))
+
+/*
+ * Hash table for task.
+ */
+static struct list task_table[TASK_MAXBUCKETS];
+
+/*
+ * Global lock for task access.
+ */
+#if CONFIG_FS_THREADS > 1
+static mutex_t task_lock = MUTEX_INITIALIZER;
+#define TASK_LOCK()	mutex_lock(&task_lock)
+#define TASK_UNLOCK()	mutex_unlock(&task_lock)
+#else
+#define TASK_LOCK()
+#define TASK_UNLOCK()
+#endif
+
+/*
+ * Convert task ID to a task structure.
+ * Returns locked task. Caller must unlock it after using it.
+ */
+struct task *
+task_lookup(task_t task)
+{
+	list_t head, n;
+	struct task *t;
+
+	if (task == TASK_NULL)
+		return NULL;
+
+	TASK_LOCK();
+	head = &task_table[TASKHASH(task)];
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		t = list_entry(n, struct task, t_link);
+		ASSERT(t->t_taskid);
+		if (t->t_taskid == task) {
+			TASK_UNLOCK();
+			mutex_lock(&t->t_lock);
+			return t;
+		}
+	}
+	TASK_UNLOCK();
+
+	/* Not found */
+	return NULL;
+}
+
+/*
+ * Allocate new task.
+ */
+int
+task_alloc(task_t task, struct task **pt)
+{
+	struct task *t;
+
+	/* Check if specified task already exists. */
+	if (task_lookup(task) != NULL)
+		return EINVAL;
+
+	if (!(t = malloc(sizeof(struct task))))
+		return ENOMEM;
+	memset(t, 0, sizeof(struct task));
+	t->t_taskid = task;
+	strlcpy(t->t_cwd, "/", sizeof(t->t_cwd));
+	mutex_init(&t->t_lock);
+
+	TASK_LOCK();
+	list_insert(&task_table[TASKHASH(task)], &t->t_link);
+	TASK_UNLOCK();
+	*pt = t;
+	return 0;
+}
+
+/*
+ * Free task and related resource.
+ */
+void
+task_free(struct task *t)
+{
+
+	TASK_LOCK();
+	list_remove(&t->t_link);
+	mutex_unlock(&t->t_lock);
+	mutex_destroy(&t->t_lock);
+	free(t);
+	TASK_UNLOCK();
+}
+
+/*
+ * Set task id of the specified task.
+ */
+void
+task_setid(struct task *t, task_t task)
+{
+
+	TASK_LOCK();
+	list_remove(&t->t_link);
+	t->t_taskid = task;
+	list_insert(&task_table[TASKHASH(task)], &t->t_link);
+	TASK_UNLOCK();
+}
+
+/*
+ * Unlock task.
+ */
+void
+task_unlock(struct task *t)
+{
+
+	mutex_unlock(&t->t_lock);
+}
+
+/*
+ * Convert a file descriptor into a pointer
+ * to a file structre.
+ */
+file_t
+task_getfp(struct task *t, int fd)
+{
+
+	if (fd < 0 || fd >= OPEN_MAX)
+		return NULL;
+
+	return t->t_ofile[fd];
+}
+
+/*
+ * Set file pointer for task/fd pair.
+ */
+void
+task_setfp(struct task *t, int fd, file_t fp)
+{
+
+	t->t_ofile[fd] = fp;
+}
+
+/*
+ * Get new file descriptor in the task.
+ * Returns -1 if there is no empty slot.
+ */
+int
+task_newfd(struct task *t)
+{
+	int fd;
+
+	/*
+	 * Find the smallest empty slot in the fd array.
+	 */
+	for (fd = 0; fd < OPEN_MAX; fd++) {
+		if (t->t_ofile[fd] == NULL)
+			break;
+	}
+	if (fd == OPEN_MAX)
+		return -1;	/* slot full */
+
+	return fd;
+}
+
+/*
+ * Delete a file descriptor.
+ */
+void
+task_delfd(struct task *t, int fd)
+{
+
+	t->t_ofile[fd] = NULL;
+}
+
+/*
+ * Convert to full path from the cwd of task and path.
+ * @t:    task structure
+ * @path: target path
+ * @full: full path to be returned
+ * @acc: access mode
+ */
+int
+task_conv(struct task *t, char *path, int acc, char *full)
+{
+	char *src, *tgt, *p, *end, *cwd;
+	size_t len = 0;
+
+	cwd = t->t_cwd;
+	path[PATH_MAX - 1] = '\0';
+	len = strlen(path);
+	if (len >= PATH_MAX)
+		return ENAMETOOLONG;
+	if (strlen(cwd) + len >= PATH_MAX)
+		return ENAMETOOLONG;
+	src = path;
+	tgt = full;
+	end = src + len;
+	if (path[0] == '/') {
+		*tgt++ = *src++;
+		len++;
+	} else {
+		strlcpy(full, cwd, PATH_MAX);
+		len = strlen(cwd);
+		tgt += len;
+		if (len > 1 && path[0] != '.') {
+			*tgt = '/';
+			tgt++;
+			len++;
+		}
+	}
+	while (*src) {
+		p = src;
+		while (*p != '/' && *p != '\0')
+			p++;
+		*p = '\0';
+		if (!strcmp(src, "..")) {
+			if (len >= 2) {
+				len -= 2;
+				tgt -= 2;	/* skip previous '/' */
+				while (*tgt != '/') {
+					tgt--;
+					len--;
+				}
+				if (len == 0) {
+					tgt++;
+					len++;
+				}
+			}
+		} else if (!strcmp(src, ".")) {
+			/* Ignore "." */
+		} else {
+			while (*src != '\0') {
+				*tgt++ = *src++;
+				len++;
+			}
+		}
+		if (p == end)
+			break;
+		if (len > 0 && *(tgt - 1) != '/') {
+			*tgt++ = '/';
+			len++;
+		}
+		src = p + 1;
+	}
+	*tgt = '\0';
+
+	/* Check if the client task has required permission */
+	return sec_file_permission(t->t_taskid, full, acc);
+}
+
+#ifdef DEBUG_VFS
+void
+task_dump(void)
+{
+	list_t head, n;
+	struct task *t;
+	int i;
+
+	TASK_LOCK();
+	dprintf("Dump file data\n");
+	dprintf(" task     opens   cwd\n");
+	dprintf(" -------- ------- ------------------------------\n");
+	for (i = 0; i < TASK_MAXBUCKETS; i++) {
+		head = &task_table[i];
+		for (n = list_first(head); n != head; n = list_next(n)) {
+			t = list_entry(n, struct task, t_link);
+			dprintf(" %08x %7x %s\n", (int)t->t_taskid, t->t_nopens,
+			       t->t_cwd);
+		}
+	}
+	dprintf("\n");
+	TASK_UNLOCK();
+}
+#endif
+
+void
+task_init(void)
+{
+	int i;
+
+	for (i = 0; i < TASK_MAXBUCKETS; i++)
+		list_init(&task_table[i]);
+}
diff --git a/prex-0.9.0/usr/server/fs/vfs/vfs_vnode.c b/prex-0.9.0/usr/server/fs/vfs/vfs_vnode.c
new file mode 100755
index 0000000..93036bd
--- /dev/null
+++ b/prex-0.9.0/usr/server/fs/vfs/vfs_vnode.c
@@ -0,0 +1,480 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * vfs_vnode.c - vnode service
+ */
+
+#include <sys/prex.h>
+#include <sys/list.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "vfs.h"
+
+/*
+ * Memo:
+ *
+ * Function   Ref count Lock
+ * ---------- --------- ----------
+ * vn_lock     *        Lock
+ * vn_unlock   *        Unlock
+ * vget        1        Lock
+ * vput       -1        Unlock
+ * vref       +1        *
+ * vrele      -1        *
+ */
+
+#define VNODE_BUCKETS 32		/* size of vnode hash table */
+
+/*
+ * vnode table.
+ * All active (opened) vnodes are stored on this hash table.
+ * They can be accessed by its path name.
+ */
+static struct list vnode_table[VNODE_BUCKETS];
+
+/*
+ * Global lock to access all vnodes and vnode table.
+ * If a vnode is already locked, there is no need to
+ * lock this global lock to access internal data.
+ */
+#if CONFIG_FS_THREADS > 1
+static mutex_t vnode_lock = MUTEX_INITIALIZER;
+#define VNODE_LOCK()	mutex_lock(&vnode_lock)
+#define VNODE_UNLOCK()	mutex_unlock(&vnode_lock)
+#else
+#define VNODE_LOCK()
+#define VNODE_UNLOCK()
+#endif
+
+
+/*
+ * Get the hash value from the mount point and path name.
+ */
+static u_int
+vn_hash(mount_t mp, char *path)
+{
+	u_int val = 0;
+
+	if (path) {
+		while (*path)
+			val = ((val << 5) + val) + *path++;
+	}
+	return (val ^ (u_int)mp) & (VNODE_BUCKETS - 1);
+}
+
+/*
+ * Returns locked vnode for specified mount point and path.
+ * vn_lock() will increment the reference count of vnode.
+ */
+vnode_t
+vn_lookup(mount_t mp, char *path)
+{
+	list_t head, n;
+	vnode_t vp;
+
+	VNODE_LOCK();
+	head = &vnode_table[vn_hash(mp, path)];
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		vp = list_entry(n, struct vnode, v_link);
+		if (vp->v_mount == mp &&
+		    !strncmp(vp->v_path, path, PATH_MAX)) {
+			vp->v_refcnt++;
+			VNODE_UNLOCK();
+			mutex_lock(&vp->v_lock);
+			vp->v_nrlocks++;
+			return vp;
+		}
+	}
+	VNODE_UNLOCK();
+	return NULL;		/* not found */
+}
+
+/*
+ * Lock vnode
+ */
+void
+vn_lock(vnode_t vp)
+{
+	ASSERT(vp);
+	ASSERT(vp->v_refcnt > 0);
+
+	mutex_lock(&vp->v_lock);
+	vp->v_nrlocks++;
+	DPRINTF(VFSDB_VNODE, ("vn_lock:   %s\n", vp->v_path));
+}
+
+/*
+ * Unlock vnode
+ */
+void
+vn_unlock(vnode_t vp)
+{
+	ASSERT(vp);
+	ASSERT(vp->v_refcnt > 0);
+	ASSERT(vp->v_nrlocks > 0);
+
+	DPRINTF(VFSDB_VNODE, ("vn_unlock: %s\n", vp->v_path));
+	vp->v_nrlocks--;
+	mutex_unlock(&vp->v_lock);
+}
+
+/*
+ * Allocate new vnode for specified path.
+ * Increment its reference count and lock it.
+ */
+vnode_t
+vget(mount_t mp, char *path)
+{
+	vnode_t vp;
+	int error;
+	size_t len;
+
+	DPRINTF(VFSDB_VNODE, ("vget: %s\n", path));
+
+	if (!(vp = malloc(sizeof(struct vnode))))
+		return NULL;
+	memset(vp, 0, sizeof(struct vnode));
+
+	len = strlen(path) + 1;
+	if (!(vp->v_path = malloc(len))) {
+		free(vp);
+		return NULL;
+	}
+	vp->v_mount = mp;
+	vp->v_refcnt = 1;
+	vp->v_op = mp->m_op->vfs_vnops;
+	strlcpy(vp->v_path, path, len);
+	mutex_init(&vp->v_lock);
+	vp->v_nrlocks = 0;
+
+	/*
+	 * Request to allocate fs specific data for vnode.
+	 */
+	if ((error = VFS_VGET(mp, vp)) != 0) {
+		mutex_destroy(&vp->v_lock);
+		free(vp->v_path);
+		free(vp);
+		return NULL;
+	}
+	vfs_busy(vp->v_mount);
+	mutex_lock(&vp->v_lock);
+	vp->v_nrlocks++;
+
+	VNODE_LOCK();
+	list_insert(&vnode_table[vn_hash(mp, path)], &vp->v_link);
+	VNODE_UNLOCK();
+	return vp;
+}
+
+/*
+ * Unlock vnode and decrement its reference count.
+ */
+void
+vput(vnode_t vp)
+{
+	ASSERT(vp);
+	ASSERT(vp->v_nrlocks > 0);
+	ASSERT(vp->v_refcnt > 0);
+	DPRINTF(VFSDB_VNODE, ("vput: ref=%d %s\n", vp->v_refcnt,
+			      vp->v_path));
+
+	vp->v_refcnt--;
+	if (vp->v_refcnt > 0) {
+		vn_unlock(vp);
+		return;
+	}
+	VNODE_LOCK();
+	list_remove(&vp->v_link);
+	VNODE_UNLOCK();
+
+	/*
+	 * Deallocate fs specific vnode data
+	 */
+	VOP_INACTIVE(vp);
+	vfs_unbusy(vp->v_mount);
+	vp->v_nrlocks--;
+	ASSERT(vp->v_nrlocks == 0);
+	mutex_unlock(&vp->v_lock);
+	mutex_destroy(&vp->v_lock);
+	free(vp->v_path);
+	free(vp);
+}
+
+/*
+ * Increment the reference count on an active vnode.
+ */
+void
+vref(vnode_t vp)
+{
+	ASSERT(vp);
+	ASSERT(vp->v_refcnt > 0);	/* Need vget */
+
+	VNODE_LOCK();
+	DPRINTF(VFSDB_VNODE, ("vref: ref=%d %s\n", vp->v_refcnt,
+			      vp->v_path));
+	vp->v_refcnt++;
+	VNODE_UNLOCK();
+}
+
+/*
+ * Decrement the reference count of the vnode.
+ * Any code in the system which is using vnode should call vrele()
+ * when it is finished with the vnode.
+ * If count drops to zero, call inactive routine and return to freelist.
+ */
+void
+vrele(vnode_t vp)
+{
+	ASSERT(vp);
+	ASSERT(vp->v_refcnt > 0);
+
+	VNODE_LOCK();
+	DPRINTF(VFSDB_VNODE, ("vrele: ref=%d %s\n", vp->v_refcnt,
+			      vp->v_path));
+	vp->v_refcnt--;
+	if (vp->v_refcnt > 0) {
+		VNODE_UNLOCK();
+		return;
+	}
+	list_remove(&vp->v_link);
+	VNODE_UNLOCK();
+
+	/*
+	 * Deallocate fs specific vnode data
+	 */
+	VOP_INACTIVE(vp);
+	vfs_unbusy(vp->v_mount);
+	mutex_destroy(&vp->v_lock);
+	free(vp->v_path);
+	free(vp);
+}
+
+/*
+ * vgone() is called when unlocked vnode is no longer valid.
+ */
+void
+vgone(vnode_t vp)
+{
+	ASSERT(vp->v_nrlocks == 0);
+
+	VNODE_LOCK();
+	DPRINTF(VFSDB_VNODE, ("vgone: %s\n", vp->v_path));
+	list_remove(&vp->v_link);
+	vfs_unbusy(vp->v_mount);
+	mutex_destroy(&vp->v_lock);
+	free(vp->v_path);
+	free(vp);
+	VNODE_UNLOCK();
+}
+
+/*
+ * Return reference count.
+ */
+int
+vcount(vnode_t vp)
+{
+	int count;
+
+	vn_lock(vp);
+	count = vp->v_refcnt;
+	vn_unlock(vp);
+	return count;
+}
+
+/*
+ * Remove all vnode in the vnode table for unmount.
+ */
+void
+vflush(mount_t mp)
+{
+	int i;
+	list_t head, n;
+	vnode_t vp;
+
+	VNODE_LOCK();
+	for (i = 0; i < VNODE_BUCKETS; i++) {
+		head = &vnode_table[i];
+		for (n = list_first(head); n != head; n = list_next(n)) {
+			vp = list_entry(n, struct vnode, v_link);
+			if (vp->v_mount == mp) {
+				/* XXX: */
+			}
+		}
+	}
+	VNODE_UNLOCK();
+}
+
+int
+vn_stat(vnode_t vp, struct stat *st)
+{
+	mode_t mode;
+
+	memset(st, 0, sizeof(struct stat));
+
+	st->st_ino = (ino_t)vp;
+	st->st_size = vp->v_size;
+	mode = vp->v_mode;
+	switch (vp->v_type) {
+	case VREG:
+		mode |= S_IFREG;
+		break;
+	case VDIR:
+		mode |= S_IFDIR;
+		break;
+	case VBLK:
+		mode |= S_IFBLK;
+		break;
+	case VCHR:
+		mode |= S_IFCHR;
+		break;
+	case VLNK:
+		mode |= S_IFLNK;
+		break;
+	case VSOCK:
+		mode |= S_IFSOCK;
+		break;
+	case VFIFO:
+		mode |= S_IFIFO;
+		break;
+	default:
+		return EBADF;
+	};
+	st->st_mode = mode;
+	st->st_blksize = BSIZE;
+	st->st_blocks = vp->v_size / S_BLKSIZE;
+	st->st_uid = 0;
+	st->st_gid = 0;
+	if (vp->v_type == VCHR || vp->v_type == VBLK)
+		st->st_rdev = (dev_t)vp->v_data;
+
+	return 0;
+}
+
+/*
+ * Chceck permission on vnode pointer.
+ */
+int
+vn_access(vnode_t vp, int flags)
+{
+	int error = 0;
+
+	if ((flags & VEXEC) && (vp->v_mode & 0111) == 0) {
+		error = EACCES;
+		goto out;
+	}
+	if ((flags & VREAD) && (vp->v_mode & 0444) == 0) {
+		error = EACCES;
+		goto out;
+	}
+	if (flags & VWRITE) {
+		if (vp->v_mount->m_flags & MNT_RDONLY) {
+			error = EROFS;
+			goto out;
+		}
+		if ((vp->v_mode & 0222) == 0) {
+			error = EACCES;
+			goto out;
+		}
+	}
+ out:
+	return error;
+}
+
+#ifdef DEBUG_VFS
+/*
+ * Dump all all vnode.
+ */
+void
+vnode_dump(void)
+{
+	int i;
+	list_t head, n;
+	vnode_t vp;
+	mount_t mp;
+	char type[][6] = { "VNON ", "VREG ", "VDIR ", "VBLK ", "VCHR ",
+			   "VLNK ", "VSOCK", "VFIFO" };
+
+	VNODE_LOCK();
+	dprintf("Dump vnode\n");
+	dprintf(" vnode    mount    type  refcnt blkno    path\n");
+	dprintf(" -------- -------- ----- ------ -------- ------------------------------\n");
+
+	for (i = 0; i < VNODE_BUCKETS; i++) {
+		head = &vnode_table[i];
+		for (n = list_first(head); n != head; n = list_next(n)) {
+			vp = list_entry(n, struct vnode, v_link);
+			mp = vp->v_mount;
+
+			dprintf(" %08x %08x %s %6d %8d %s%s\n", (u_int)vp,
+				(u_int)mp, type[vp->v_type], vp->v_refcnt,
+				(u_int)vp->v_blkno,
+				(strlen(mp->m_path) == 1) ? "\0" : mp->m_path,
+				vp->v_path);
+		}
+	}
+	dprintf("\n");
+	VNODE_UNLOCK();
+}
+#endif
+
+int
+vop_nullop(void)
+{
+
+	return 0;
+}
+
+int
+vop_einval(void)
+{
+
+	return EINVAL;
+}
+
+/*
+ * vnode_init() is called once (from vfs_init)
+ * in initialization.
+ */
+void
+vnode_init(void)
+{
+	int i;
+
+	for (i = 0; i < VNODE_BUCKETS; i++)
+		list_init(&vnode_table[i]);
+}
diff --git a/prex-0.9.0/usr/server/pow/Makefile b/prex-0.9.0/usr/server/pow/Makefile
new file mode 100755
index 0000000..9d78f6d
--- /dev/null
+++ b/prex-0.9.0/usr/server/pow/Makefile
@@ -0,0 +1,6 @@
+PROG=		pow
+
+#DISASM= 	pow.lst
+#SYMBOL= 	pow.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/server/pow/pow.c b/prex-0.9.0/usr/server/pow/pow.c
new file mode 100755
index 0000000..ba4a3dd
--- /dev/null
+++ b/prex-0.9.0/usr/server/pow/pow.c
@@ -0,0 +1,479 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pow.c - power server
+ */
+
+#include <sys/prex.h>
+#include <sys/mount.h>
+#include <sys/ioctl.h>
+#include <ipc/proc.h>
+#include <ipc/pow.h>
+#include <ipc/exec.h>
+#include <ipc/ipc.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <errno.h>
+
+/* #define DEBUG_POW 1 */
+
+#ifdef DEBUG_POW
+#define DPRINTF(a) dprintf a
+#else
+#define DPRINTF(a)
+#endif
+
+/*
+ * Action for each power event.
+ */
+struct power_action {
+	int	pwrbtn;		/* state for power button press */
+	int	slpbtn;		/* state for sleep button press */
+	int	lcdclose;	/* state for LCD close */
+	int	lowbatt;	/* state for low battery */
+};
+
+static int pow_noop(struct msg *);
+static int pow_set_power(struct msg *);
+static int pow_get_policy(struct msg *);
+static int pow_set_policy(struct msg *);
+static int pow_get_sustmr(struct msg *);
+static int pow_set_sustmr(struct msg *);
+static int pow_get_dimtmr(struct msg *);
+static int pow_set_dimtmr(struct msg *);
+static int pow_battery_lvl(struct msg *);
+static int pow_debug(struct msg *);
+
+static void set_power_state(int);
+static void shutdown_server(const char *);
+
+/*
+ * Message mapping
+ */
+struct msg_map {
+	int	code;
+	int	(*func)(struct msg *);
+};
+
+static const struct msg_map powermsg_map[] = {
+	{POW_SET_POWER,	pow_set_power},
+	{POW_GET_POLICY,	pow_get_policy},
+	{POW_SET_POLICY,	pow_set_policy},
+	{POW_GET_SUSTMR,	pow_get_sustmr},
+	{POW_SET_SUSTMR,	pow_set_sustmr},
+	{POW_GET_DIMTMR,	pow_get_dimtmr},
+	{POW_SET_DIMTMR,	pow_set_dimtmr},
+	{POW_BATTERY_LVL,	pow_battery_lvl},
+	{STD_DEBUG,		pow_debug},
+	{0,			pow_noop},
+};
+
+static struct power_action pmact;
+static device_t pmdev;
+
+static int
+pow_noop(struct msg *msg)
+{
+	return 0;
+}
+
+static int
+pow_set_power(struct msg *msg)
+{
+	int state;
+
+	state = msg->data[0];
+	set_power_state(state);
+	return 0;
+}
+
+static int
+pow_get_policy(struct msg *msg)
+{
+	int policy;
+
+	device_ioctl(pmdev, PMIOC_GET_POLICY, &policy);
+	msg->data[0] = policy;
+	return 0;
+}
+
+static int
+pow_set_policy(struct msg *msg)
+{
+	int policy;
+
+	policy = msg->data[0];
+	device_ioctl(pmdev, PMIOC_SET_POLICY, &policy);
+	return 0;
+}
+
+static int
+pow_get_sustmr(struct msg *msg)
+{
+	int timeout;
+
+	device_ioctl(pmdev, PMIOC_GET_SUSTMR, &timeout);
+	msg->data[0] = timeout;
+	return 0;
+}
+
+static int
+pow_set_sustmr(struct msg *msg)
+{
+	int timeout;
+
+	timeout = msg->data[0];
+	device_ioctl(pmdev, PMIOC_SET_SUSTMR, &timeout);
+	return 0;
+}
+
+static int
+pow_get_dimtmr(struct msg *msg)
+{
+	int timeout;
+
+	device_ioctl(pmdev, PMIOC_GET_DIMTMR, &timeout);
+	msg->data[0] = timeout;
+	return 0;
+}
+
+static int
+pow_set_dimtmr(struct msg *msg)
+{
+	int timeout;
+
+	timeout = msg->data[0];
+	device_ioctl(pmdev, PMIOC_SET_DIMTMR, &timeout);
+	return 0;
+}
+
+static int
+pow_battery_lvl(struct msg *msg)
+{
+	/* TODO: Get current battery level from battery driver. */
+	return 0;
+}
+
+static void
+set_power_state(int state)
+{
+
+	if (pmdev != NODEV) {
+		DPRINTF(("set_power_state: state=%d\n", state));
+
+		sync();
+		if (state == PWR_OFF || state == PWR_REBOOT) {
+			kill(-1, SIGTERM);
+			shutdown_server("!exec");
+			shutdown_server("!fs");
+			shutdown_server("!proc");
+		}
+		device_ioctl(pmdev, PMIOC_SET_POWER, &state);
+	}
+}
+
+static void
+exception_handler(int sig)
+{
+
+	if (sig == SIGPWR) {
+		DPRINTF(("SIGPWR!\n"));
+	}
+	exception_return();
+}
+
+static void
+power_thread(void)
+{
+	int sig, event, state;
+
+	DPRINTF(("power_thread: start\n"));
+
+	for (;;) {
+		/*
+		 * Wait signals from PM driver.
+		 */
+		exception_wait(&sig);
+		DPRINTF(("power_thread: sig=%d\n", sig));
+
+		if (sig == SIGPWR) {
+			/*
+			 * Query PM events.
+			 */
+			device_ioctl(pmdev, PMIOC_QUERY_EVENT, &event);
+			DPRINTF(("power_thread: event=%d\n", event));
+
+			/*
+			 * Do action for current power settings.
+			 */
+			state = PWR_ON;
+			switch (event) {
+			case PME_PWRBTN_PRESS:
+				state = pmact.pwrbtn;
+				break;
+			case PME_LOW_BATTERY:
+				state = pmact.lowbatt;
+				break;
+			case PME_SLPBTN_PRESS:
+				state = pmact.slpbtn;
+				break;
+			case PME_LCD_CLOSE:
+				state = pmact.lcdclose;
+				break;
+			}
+			if (state != PWR_ON)
+				set_power_state(state);
+
+		}
+	}
+}
+
+/*
+ * Run specified routine as a thread.
+ */
+static int
+run_thread(void (*entry)(void))
+{
+	task_t self;
+	thread_t t;
+	void *stack, *sp;
+	int error;
+
+	self = task_self();
+	if ((error = thread_create(self, &t)) != 0)
+		return error;
+	if ((error = vm_allocate(self, &stack, DFLSTKSZ, 1)) != 0)
+		return error;
+
+	sp = (void *)((u_long)stack + DFLSTKSZ - sizeof(u_long) * 3);
+	if ((error = thread_load(t, entry, sp)) != 0)
+		return error;
+
+	return thread_resume(t);
+}
+
+static void
+pow_init(void)
+{
+	task_t self;
+
+	/*
+	 * Set default power actions
+	 */
+	pmact.pwrbtn = PWR_OFF;
+	pmact.slpbtn = PWR_SUSPEND;
+	pmact.lcdclose = PWR_SUSPEND;
+	pmact.lowbatt = PWR_OFF;
+
+	/*
+	 * Connect to the pm driver to get all power events.
+	 */
+	if (device_open("pm", 0, &pmdev) != 0) {
+		/*
+		 * Bad config...
+		 */
+		sys_panic("pow: no pm driver");
+	}
+	self = task_self();
+	device_ioctl(pmdev, PMIOC_CONNECT, &self);
+
+	/*
+	 * Setup exception to receive signals from pm driver.
+	 */
+	exception_setup(exception_handler);
+
+	/*
+	 * Start power thread.
+	 */
+	if (run_thread(power_thread))
+		sys_panic("pow_init");
+}
+
+static void
+register_process(void)
+{
+	struct msg m;
+	object_t obj;
+	int error;
+
+	error = object_lookup("!proc", &obj);
+	if (error)
+		sys_panic("pow: no proc found");
+
+	m.hdr.code = PS_REGISTER;
+	msg_send(obj, &m, sizeof(m));
+}
+
+/*
+ * Wait until specified server starts.
+ */
+static void
+wait_server(const char *name, object_t *pobj)
+{
+	int i, error = 0;
+
+	/* Give chance to run other servers. */
+	thread_yield();
+
+	/*
+	 * Wait for server loading. timeout is 1 sec.
+	 */
+	for (i = 0; i < 100; i++) {
+		error = object_lookup((char *)name, pobj);
+		if (error == 0)
+			break;
+
+		/* Wait 10msec */
+		timer_sleep(10, 0);
+		thread_yield();
+	}
+	if (error)
+		sys_panic("pow: server not found");
+}
+
+static void
+shutdown_server(const char *name)
+{
+	struct msg m;
+	object_t obj;
+	int error;
+
+	DPRINTF(("pow: shutdown %s\n", name));
+	error = object_lookup((char *)name, &obj);
+	if (error != 0)
+		return;
+
+	m.hdr.code = STD_SHUTDOWN;
+	error = msg_send(obj, &m, sizeof(m));
+	if (error)
+		sys_panic("pow: shutdown error");
+}
+
+static int
+pow_debug(struct msg *msg)
+{
+	return 0;
+}
+
+/*
+ * Main routine for power server.
+ */
+int
+main(int argc, char *argv[])
+{
+	static struct msg msg;
+	const struct msg_map *map;
+	object_t obj;
+	struct bind_msg bm;
+	object_t execobj, procobj;
+	int error;
+
+	sys_log("Starting power server\n");
+
+	/* Boost thread priority. */
+	thread_setpri(thread_self(), PRI_POW);
+
+	/*
+	 * Wait until all required system servers
+	 * become available.
+	 */
+	wait_server("!proc", &procobj);
+	wait_server("!exec", &execobj);
+
+	/*
+	 * Request to bind a new capabilities for us.
+	 */
+	bm.hdr.code = EXEC_BINDCAP;
+	strlcpy(bm.path, "/boot/pow", sizeof(bm.path));
+	msg_send(execobj, &bm, sizeof(bm));
+
+	/*
+	 * Register to process server
+	 */
+	register_process();
+
+	/*
+	 * Initialize power service.
+	 */
+	pow_init();
+
+	/*
+	 * Create an object to expose our service.
+	 */
+	error = object_create("!pow", &obj);
+	if (error)
+		sys_panic("fail to create object");
+
+	/*
+	 * Message loop
+	 */
+	for (;;) {
+		/*
+		 * Wait for an incoming request.
+		 */
+		error = msg_receive(obj, &msg, sizeof(msg));
+		if (error)
+			continue;
+
+		DPRINTF(("pow: msg code=%x task=%x\n",
+			 msg.hdr.code, msg.hdr.task));
+
+
+		/* Check client's capability. */
+		if (task_chkcap(msg.hdr.task, CAP_POWERMGMT) != 0) {
+			map = NULL;
+			error = EPERM;
+		} else {
+			error = EINVAL;
+			map = &powermsg_map[0];
+			while (map->code != 0) {
+				if (map->code == msg.hdr.code) {
+					error = (*map->func)(&msg);
+					break;
+				}
+				map++;
+			}
+		}
+		/*
+		 * Reply to the client.
+		 */
+		msg.hdr.status = error;
+		msg_reply(obj, &msg, sizeof(msg));
+#ifdef DEBUG_POWER
+		if (map != NULL && error != 0)
+			DPRINTF(("pow: msg code=%x error=%d\n",
+				 map->code, error));
+#endif
+	}
+}
diff --git a/prex-0.9.0/usr/server/proc/Makefile b/prex-0.9.0/usr/server/proc/Makefile
new file mode 100755
index 0000000..160661a
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/Makefile
@@ -0,0 +1,9 @@
+PROG=		proc
+SRCS=		main.c proc_hash.c proc_pid.c proc_fork.c proc_exit.c \
+		proc_sig.c proc_tty.c
+
+#DISASM= 	proc.lst
+#MAP=	 	proc.map
+#SYMBOL= 	proc.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/server/proc/main.c b/prex-0.9.0/usr/server/proc/main.c
new file mode 100755
index 0000000..296fb7d
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/main.c
@@ -0,0 +1,582 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Process server:
+ *
+ * A process server is responsible to handle process ID, group
+ * ID, signal and fork()/exec() state. Since Prex microkernel
+ * does not have the concept about process or process group, the
+ * process server will map each Prex task to POSIX process.
+ *
+ * Prex does not support uid (user ID) and gid (group ID) because
+ * it runs only in a single user mode. The value of uid and gid is
+ * always returned as 1 for all process. These are handled by the
+ * library stubs, and it is out of scope in this server.
+ *
+ * Important Notice:
+ * This server is made as a single thread program to reduce many
+ * locks and to keep the code clean. So, we should not block in
+ * the kernel for any service. If some service must wait an
+ * event, it should wait within the library stub in the client
+ * application.
+ */
+
+#include <sys/prex.h>
+#include <sys/param.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+#include <ipc/exec.h>
+#include <sys/list.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "proc.h"
+
+/* forward declarations */
+static int proc_getpid(struct msg *);
+static int proc_getppid(struct msg *);
+static int proc_getpgid(struct msg *);
+static int proc_setpgid(struct msg *);
+static int proc_getsid(struct msg *);
+static int proc_setsid(struct msg *);
+static int proc_fork(struct msg *);
+static int proc_exit(struct msg *);
+static int proc_stop(struct msg *);
+static int proc_waitpid(struct msg *);
+static int proc_kill(struct msg *);
+static int proc_exec(struct msg *);
+static int proc_pstat(struct msg *);
+static int proc_register(struct msg *);
+static int proc_setinit(struct msg *);
+static int proc_trace(struct msg *);
+static int proc_boot(struct msg *);
+static int proc_shutdown(struct msg *);
+static int proc_noop(struct msg *);
+static int proc_debug(struct msg *);
+
+/*
+ * Message mapping
+ */
+struct msg_map {
+	int	code;
+	int	(*func)(struct msg *);
+};
+
+static const struct msg_map procmsg_map[] = {
+	{PS_GETPID,	proc_getpid},
+	{PS_GETPPID,	proc_getppid},
+	{PS_GETPGID,	proc_getpgid},
+	{PS_SETPGID,	proc_setpgid},
+	{PS_GETSID,	proc_getsid},
+	{PS_SETSID,	proc_setsid},
+	{PS_FORK,	proc_fork},
+	{PS_EXIT,	proc_exit},
+	{PS_STOP,	proc_stop},
+	{PS_WAITPID,	proc_waitpid},
+	{PS_KILL,	proc_kill},
+	{PS_EXEC,	proc_exec},
+	{PS_PSTAT,	proc_pstat},
+	{PS_REGISTER,	proc_register},
+	{PS_SETINIT,	proc_setinit},
+	{PS_TRACE,	proc_trace},
+	{STD_BOOT,	proc_boot},
+	{STD_SHUTDOWN,	proc_shutdown},
+	{STD_DEBUG,	proc_debug},
+	{0,		proc_noop},
+};
+
+static struct proc proc0;	/* process data of this server (pid=0) */
+static struct pgrp pgrp0;	/* process group for first process */
+static struct session session0;	/* session for first process */
+
+struct proc initproc;		/* process slot for init process (pid=1) */
+struct proc *curproc;		/* current (caller) process */
+struct list allproc;		/* list of all processes */
+
+static int
+proc_getpid(struct msg *msg)
+{
+	pid_t pid;
+
+	pid = sys_getpid();
+
+	msg->data[0] = (int)pid;
+	return 0;
+}
+
+static int
+proc_getppid(struct msg *msg)
+{
+	pid_t ppid;
+
+	ppid = sys_getppid();
+
+	msg->data[0] = (int)ppid;
+	return 0;
+}
+
+static int
+proc_getpgid(struct msg *msg)
+{
+	pid_t pid, pgid;
+	int error;
+
+	pid = (pid_t)msg->data[0];
+
+	error = sys_getpgid(pid, &pgid);
+	if (error)
+		return error;
+
+	msg->data[0] = (int)pgid;
+	return 0;
+}
+
+static int
+proc_setpgid(struct msg *msg)
+{
+	pid_t pid, pgid;
+
+	pid = (pid_t)msg->data[0];
+	pgid = (pid_t)msg->data[1];
+
+	return sys_setpgid(pid, pgid);
+}
+
+static int
+proc_getsid(struct msg *msg)
+{
+	pid_t pid, sid;
+	int error;
+
+	pid = (pid_t)msg->data[0];
+
+	error = sys_getsid(pid, &sid);
+	if (error)
+		return error;
+
+	msg->data[0] = (int)sid;
+	return 0;
+}
+
+static int
+proc_setsid(struct msg *msg)
+{
+	pid_t sid;
+	int error;
+
+	error = sys_setsid(&sid);
+	if (error)
+		return error;
+
+	msg->data[0] = (int)sid;
+	return 0;
+}
+
+static int
+proc_fork(struct msg *msg)
+{
+	task_t child;
+	int vfork;
+	pid_t pid;
+	int error;
+
+	child = (task_t)msg->data[0];
+	vfork = msg->data[1];
+
+	error = sys_fork(child, vfork, &pid);
+	if (error)
+		return error;
+
+	msg->data[0] = (int)pid;
+	return 0;
+}
+
+static int
+proc_exit(struct msg *msg)
+{
+	int exitcode;
+
+	exitcode = msg->data[0];
+
+	return sys_exit(exitcode);
+}
+
+static int
+proc_stop(struct msg *msg)
+{
+	int exitcode;
+
+	exitcode = msg->data[0];
+
+	return stop(exitcode);
+}
+
+static int
+proc_waitpid(struct msg *msg)
+{
+	pid_t pid, pid_child;
+	int options, status, error;
+
+	pid = (pid_t)msg->data[0];
+	options = msg->data[1];
+
+	error = sys_waitpid(pid, &status, options, &pid_child);
+	if (error)
+		return error;
+
+	msg->data[0] = pid_child;
+	msg->data[1] = status;
+
+	return 0;
+}
+
+static int
+proc_kill(struct msg *msg)
+{
+	pid_t pid;
+	int sig;
+
+	pid = (pid_t)msg->data[0];
+	sig = msg->data[1];
+
+	return sys_kill(pid, sig);
+}
+
+/*
+ * exec() - Update pid to track the mapping with task id.
+ * The almost all work is done by a exec server for exec()
+ * emulation. So, there is not so many jobs here...
+ */
+static int
+proc_exec(struct msg *msg)
+{
+	task_t orgtask, newtask;
+	struct proc *p, *parent;
+
+	DPRINTF(("proc: exec pid=%x\n", curproc->p_pid));
+
+	orgtask = (task_t)msg->data[0];
+	newtask = (task_t)msg->data[1];
+	if ((p = task_to_proc(orgtask)) == NULL)
+		return EINVAL;
+
+	p_remove(p);
+	p->p_task = newtask;
+	p_add(p);
+	p->p_invfork = 0;
+	p->p_stackbase = (void *)msg->data[2];
+
+	if (p->p_flag & P_TRACED) {
+		DPRINTF(("proc: traced!\n"));
+		sys_debug(DBGC_TRACE, (void *)newtask);
+	}
+
+	parent = p->p_parent;
+	if (parent != NULL && parent->p_vforked)
+		vfork_end(parent);
+
+	return 0;
+}
+
+/*
+ * Get process status.
+ */
+static int
+proc_pstat(struct msg *msg)
+{
+	task_t task;
+	struct proc *p;
+
+	DPRINTF(("proc: pstat task=%x\n", msg->data[0]));
+
+	task = (task_t)msg->data[0];
+	if ((p = task_to_proc(task)) == NULL)
+		return EINVAL;
+
+	msg->data[0] = (int)p->p_pid;
+	msg->data[2] = (int)p->p_stat;
+	if (p->p_parent == NULL)
+		msg->data[1] = (int)0;
+	else
+		msg->data[1] = (int)p->p_parent->p_pid;
+	return 0;
+}
+
+/*
+ * Set init process (pid=1).
+ */
+static int
+proc_setinit(struct msg *msg)
+{
+
+	DPRINTF(("proc: setinit task=%x\n", msg->hdr.task));
+
+	/* Check client's capability. */
+	if (task_chkcap(msg->hdr.task, CAP_PROTSERV) != 0)
+		return EPERM;
+
+	if (initproc.p_stat == SRUN)
+		return EPERM;
+
+	curproc = &proc0;
+	newproc(&initproc, 1, msg->hdr.task);
+
+	return 0;
+}
+
+/*
+ * Set trace flag
+ */
+static int
+proc_trace(struct msg *msg)
+{
+	task_t task = msg->hdr.task;
+	struct proc *p;
+
+	DPRINTF(("proc: trace task=%x\n", task));
+
+	if ((p = task_to_proc(task)) == NULL)
+		return EINVAL;
+
+	/* Toggle trace flag */
+	p->p_flag ^= P_TRACED;
+	return 0;
+}
+
+/*
+ * Register boot task.
+ */
+static int
+proc_register(struct msg *msg)
+{
+	struct proc *p;
+
+	DPRINTF(("proc: register task=%x\n", msg->hdr.task));
+
+	/* Check client's capability. */
+	if (task_chkcap(msg->hdr.task, CAP_PROTSERV) != 0)
+		return EPERM;
+
+	if ((p = malloc(sizeof(struct proc))) == NULL)
+		return ENOMEM;
+	memset(p, 0, sizeof(struct proc));
+
+	curproc = &proc0;
+	if (newproc(p, 0, msg->hdr.task))
+		sys_panic("proc: fail to register boot task");
+
+	DPRINTF(("proc: register pid=%d\n", p->p_pid));
+	return 0;
+}
+
+/*
+ * Ready to boot
+ */
+static int
+proc_boot(struct msg *msg)
+{
+	object_t obj;
+	struct bind_msg m;
+
+	DPRINTF(("proc: boot\n"));
+
+	/* Check client's capability. */
+	if (task_chkcap(msg->hdr.task, CAP_PROTSERV) != 0)
+		return EPERM;
+
+	/*
+	 * Request exec server to bind an appropriate
+	 * capability for us.
+	 */
+	if (object_lookup("!exec", &obj) != 0)
+		sys_panic("proc: no exec found");
+	m.hdr.code = EXEC_BINDCAP;
+	strlcpy(m.path, "/boot/proc", sizeof(m.path));
+	msg_send(obj, &m, sizeof(m));
+
+	return 0;
+}
+
+static int
+proc_shutdown(struct msg *msg)
+{
+
+	DPRINTF(("proc: shutdown\n"));
+	return 0;
+}
+
+static int
+proc_noop(struct msg *msg)
+{
+
+	return 0;
+}
+
+static int
+proc_debug(struct msg *msg)
+{
+#ifdef DEBUG_PROC
+	struct proc *p;
+	list_t n;
+	char stat[][5] = { "    ", "RUN ", "ZOMB", "STOP" };
+
+	dprintf("<Process Server>\n");
+	dprintf("Dump process\n");
+	dprintf(" pid    ppid   pgid   sid    stat task\n");
+	dprintf(" ------ ------ ------ ------ ---- --------\n");
+
+	for (n = list_first(&allproc); n != &allproc;
+	     n = list_next(n)) {
+		p = list_entry(n, struct proc, p_link);
+		dprintf(" %6d %6d %6d %6d %s %08x\n", p->p_pid,
+			p->p_parent->p_pid, p->p_pgrp->pg_pgid,
+			p->p_pgrp->pg_session->s_leader->p_pid,
+			stat[p->p_stat], p->p_task);
+	}
+	dprintf("\n");
+#endif
+	return 0;
+}
+
+static void
+proc_init(void)
+{
+
+	list_init(&allproc);
+	tty_init();
+	table_init();
+}
+
+
+/*
+ * Initialize process 0.
+ */
+static void
+proc0_init(void)
+{
+	struct proc *p;
+	struct pgrp *pg;
+	struct session *sess;
+
+	p = &proc0;
+	pg = &pgrp0;
+	sess = &session0;
+
+	pg->pg_pgid = 0;
+	list_init(&pg->pg_members);
+	pg_add(pg);
+
+	pg->pg_session = sess;
+	sess->s_refcnt = 1;
+	sess->s_leader = p;
+	sess->s_ttyhold = 0;
+
+	p->p_parent = 0;
+	p->p_pgrp = pg;
+	p->p_stat = SRUN;
+	p->p_exitcode = 0;
+	p->p_pid = 0;
+	p->p_task = task_self();
+	p->p_vforked = 0;
+	p->p_invfork = 0;
+
+	list_init(&p->p_children);
+	p_add(p);
+	list_insert(&pg->pg_members, &p->p_pgrp_link);
+}
+
+/*
+ * Main routine for process service.
+ */
+int
+main(int argc, char *argv[])
+{
+	static struct msg msg;
+	const struct msg_map *map;
+	object_t obj;
+	int error;
+
+	sys_log("Starting process server\n");
+
+	/* Boost thread priority. */
+	thread_setpri(thread_self(), PRI_PROC);
+
+	/* Initialize process and pgrp structures. */
+	proc_init();
+
+	/* Create process 0 (process server). */
+	proc0_init();
+
+	/* Create an object to expose our service. */
+	if ((error = object_create("!proc", &obj)) != 0)
+		sys_panic("proc: fail to create object");
+
+	/*
+	 * Message loop
+	 */
+	for (;;) {
+		/*
+		 * Wait for an incoming request.
+		 */
+		error = msg_receive(obj, &msg, sizeof(msg));
+		if (error)
+			continue;
+
+		DPRINTF(("proc: msg code=%x task=%x\n",
+			 msg.hdr.code, msg.hdr.task));
+
+		error = EINVAL;
+		map = &procmsg_map[0];
+		while (map->code != 0) {
+			if (map->code == msg.hdr.code) {
+
+				/* Get current process */
+				curproc = task_to_proc(msg.hdr.task);
+				error = (*map->func)(&msg);
+				break;
+			}
+			map++;
+		}
+		/*
+		 * Reply to the client.
+		 */
+		msg.hdr.status = error;
+		msg_reply(obj, &msg, sizeof(msg));
+#ifdef DEBUG_PROC
+		if (error) {
+			DPRINTF(("proc: msg code=%x error=%d\n",
+				 map->code, error));
+		}
+#endif
+	}
+}
diff --git a/prex-0.9.0/usr/server/proc/proc.h b/prex-0.9.0/usr/server/proc/proc.h
new file mode 100755
index 0000000..e9b4ffb
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PROC_H
+#define _PROC_H
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/list.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+#include <sys/capability.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <assert.h>
+
+/* #define DEBUG_PROC 1 */
+
+#ifdef DEBUG_PROC
+#define DPRINTF(a)	dprintf a
+#define ASSERT(e)	dassert(e)
+#else
+#define DPRINTF(a)
+#define ASSERT(e)
+#endif
+
+#define PID_MAX		0x8000		/* max number for PID */
+
+#define ID_MAXBUCKETS	32
+#define IDHASH(x)	((x) & (ID_MAXBUCKETS - 1))
+
+struct proc;
+
+/*
+ * Session
+ */
+struct session {
+	int		s_refcnt;	/* reference count */
+	struct proc	*s_leader;	/* session leader */
+	int		s_ttyhold;	/* true if hold tty */
+};
+
+
+/*
+ * Process group
+ */
+struct pgrp {
+	struct list	pg_link;	/* link for pgid hash */
+	struct list	pg_members;	/* list head of processes */
+	struct session	*pg_session;	/* pointer to session */
+	pid_t		pg_pgid;	/* pgrp id */
+};
+
+/*
+ * Description of a process
+ */
+struct proc {
+	struct list	p_link;		/* link for all processes */
+	struct proc 	*p_parent;	/* pointer to parent process */
+	struct list 	p_children;	/* list head of child processes */
+	struct list 	p_sibling;	/* link for sibling processes */
+	struct list 	p_pid_link;	/* link for pid hash */
+	struct list 	p_task_link;	/* link for task hash */
+	struct list 	p_pgrp_link;	/* link for process group */
+	struct pgrp 	*p_pgrp;	/* pointer to process group */
+	int		p_stat;		/* process status S* */
+	int		p_flag;		/* P_* flags */
+	int		p_exitcode;	/* exit code to send to parrent */
+	int		p_vforked;	/* true while processing vfork() */
+	int		p_invfork;	/* true if child of vfork() */
+	pid_t		p_pid;		/* process id */
+	task_t		p_task;		/* task id */
+	void		*p_stackbase;	/* pointer to stack */
+	void		*p_stacksaved;	/* pointer to saved stack */
+};
+
+/* Status values. */
+#define SRUN	1	/* running */
+#define SZOMB	2	/* process terminated but not waited for */
+#define SSTOP	3	/* proces stopped */
+
+/* These flags are kept in p_flags. */
+#define	P_TRACED	0x00001		/* debugged process being traced. */
+
+/*
+ * Global variables.
+ */
+extern struct proc initproc;		/* process slot for init */
+extern struct list allproc;		/* list of all processes */
+extern struct proc *curproc;		/* current (caller) process */
+extern int perrno;			/* errno */
+
+__BEGIN_DECLS
+
+/* pid.c */
+pid_t	sys_getpid(void);
+pid_t	sys_getppid(void);
+int	sys_getpgid(pid_t, pid_t *);
+int	sys_setpgid(pid_t, pid_t);
+int	sys_getsid(pid_t, pid_t *);
+int	sys_setsid(pid_t *);
+
+/* fork.c */
+int	newproc(struct proc *, pid_t, task_t);
+int	sys_fork(task_t, int, pid_t *);
+void	cleanup(struct proc *);
+void	vfork_end(struct proc *);
+
+/* exit.c */
+int	sys_exit(int);
+int	stop(int);
+int	sys_waitpid(pid_t, int *, int, pid_t *);
+
+/* kill.c */
+int	sys_kill(pid_t pid, int sig);
+int	kill_pg(pid_t, int);
+
+/* hash.c */
+struct proc *p_find(pid_t);
+struct pgrp *pg_find(pid_t);
+struct proc *task_to_proc(task_t);
+void	p_add(struct proc *);
+void	p_remove(struct proc *);
+void	pg_add(struct pgrp *);
+void	pg_remove(struct pgrp *);
+void	table_init(void);
+
+/* tty.c */
+void	tty_init(void);
+
+__END_DECLS
+
+#endif /* !_PROC_H */
diff --git a/prex-0.9.0/usr/server/proc/proc_exit.c b/prex-0.9.0/usr/server/proc/proc_exit.c
new file mode 100755
index 0000000..65fee3e
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc_exit.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2005-2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exit.c - process exit and wait
+ */
+
+#include <sys/prex.h>
+#include <ipc/proc.h>
+#include <sys/list.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+
+#include "proc.h"
+
+/*
+ * Exit process.
+ *
+ * process_exit() sets the process state to zombie state, and it
+ * saves the exit code for waiting process.
+ */
+int
+sys_exit(int exitcode)
+{
+	struct proc *child, *parent;
+	list_t head, n;
+	int error;
+
+	DPRINTF(("proc: exit pid=%d code=%x\n", curproc->p_pid, exitcode));
+
+	if (curproc->p_stat == SZOMB)
+		return EBUSY;
+
+	/*
+	 * Enter zombie state.
+	 */
+	curproc->p_stat = SZOMB;
+	curproc->p_exitcode = exitcode;
+	p_remove(curproc);
+
+	/*
+	 * Set the parent pid of all child processes to 1 (init).
+	 */
+	head = &curproc->p_children;
+	n = list_first(head);
+	while (n != head) {
+		child = list_entry(n, struct proc, p_sibling);
+		n = list_next(n);
+
+		child->p_parent = &initproc;
+		list_remove(&child->p_sibling);
+		list_insert(&initproc.p_children, &child->p_sibling);
+	}
+
+	/*
+	 * Resume parent process which is wating in vfork.
+	 */
+	parent = curproc->p_parent;
+	if (parent != NULL && parent->p_vforked) {
+		vfork_end(parent);
+
+		/*
+		 * The child task loses its stack data.
+		 * So, it can not run anymore.
+		 */
+		error = task_terminate(curproc->p_task);
+		if (error)
+			sys_panic("proc: can not terminate a task for exit");
+	}
+
+	/* Send a signal to the parent process. */
+	DPRINTF(("proc: exit send SIGCHLD to pid=%d\n",
+		 curproc->p_parent->p_pid));
+	exception_raise(curproc->p_parent->p_task, SIGCHLD);
+
+	return 0;
+}
+
+/*
+ * Stop process.
+ *
+ * This is similar with exit(), but it does not update the parent
+ * pid of any child processes.
+ */
+int
+stop(int exitcode)
+{
+
+	DPRINTF(("proc: stop code=%x\n", exitcode));
+
+	if (curproc->p_stat == SZOMB)
+		return EBUSY;
+
+	curproc->p_stat = SSTOP;
+	curproc->p_exitcode = exitcode;
+
+	/* Send a signal to the parent process. */
+	exception_raise(curproc->p_parent->p_task, SIGCHLD);
+
+	return 0;
+}
+
+/*
+ * Find the zombie process in the child processes. It just
+ * returns the pid and exit code if it find at least one zombie
+ * process.
+ *
+ * The library stub for waitpid() will wait the SIGCHLD signal in
+ * the stub code if there is no zombie process in child process.
+ * This signal is sent by proc_exit() or proc_stop() routines in
+ * the process server.
+ */
+int
+sys_waitpid(pid_t pid, int *status, int options, pid_t *retval)
+{
+	pid_t pid_child;
+	int code, match;
+	struct proc *p;
+	list_t head, n;
+
+	DPRINTF(("proc: wait pid=%d options=%x\n", pid, options));
+
+	if (list_empty(&curproc->p_children))
+		return ECHILD;	/* No child process */
+
+	/* Set the default pid and exit code */
+	pid_child = 0;
+	code = 0;
+
+	/*
+	 * Check all processes.
+	 */
+	p = NULL;
+	head = &curproc->p_children;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		p = list_entry(n, struct proc, p_sibling);
+
+		/*
+		 * Check if pid matches.
+		 */
+		match = 0;
+		if (pid > 0) {
+			/*
+			 * Wait a specific child process.
+			 */
+			if (p->p_pid == pid)
+				match = 1;
+		} else if (pid == 0) {
+			/*
+			 * Wait a process who has same pgid.
+			 */
+			if (p->p_pgrp->pg_pgid == curproc->p_pgrp->pg_pgid)
+				match = 1;
+		} else if (pid != -1) {
+			/*
+			 * Wait a specific pgid.
+			 */
+			if (p->p_pgrp->pg_pgid == -pid)
+				match = 1;
+		} else {
+			/*
+			 * pid = -1 means wait any child process.
+			 */
+			match = 1;
+		}
+		if (match) {
+			/*
+			 * Get the exit code.
+			 */
+			if (p->p_stat == SSTOP) {
+				pid_child = p->p_pid;
+				code = p->p_exitcode;
+				break;
+			} else if (p->p_stat == SZOMB) {
+				pid_child = p->p_pid;
+				code = p->p_exitcode;
+				cleanup(p);
+				break;
+			}
+		}
+	}
+	*status = code;
+	*retval = pid_child;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/proc/proc_fork.c b/prex-0.9.0/usr/server/proc/proc_fork.c
new file mode 100755
index 0000000..02133b9
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc_fork.c
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fork.c - fork() support
+ */
+
+#include <sys/prex.h>
+#include <ipc/proc.h>
+#include <sys/list.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "proc.h"
+
+static int vfork_start(struct proc *);
+
+/*
+ * PID previously allocated.
+ *
+ * Note: The following pids are reserved by default.
+ *   pid = 0: Process server
+ *   pid = 1: Init process
+ */
+static pid_t last_pid = 1;
+
+/*
+ * Assign new pid.
+ * Returns pid on sucess, or 0 on failure.
+ */
+static pid_t
+pid_alloc(void)
+{
+	pid_t pid;
+
+	pid = last_pid + 1;
+	if (pid >= PID_MAX)
+		pid = 1;
+	while (pid != last_pid) {
+		if (p_find(pid) == NULL)
+			break;
+		if (++pid >= PID_MAX)
+			pid = 1;
+	}
+	if (pid == last_pid)
+		return 0;
+	last_pid = pid;
+	return pid;
+}
+
+/*
+ * Create a new process.
+ */
+int
+newproc(struct proc *p, pid_t pid, task_t task)
+{
+	struct pgrp *pg;
+
+	pg = curproc->p_pgrp;
+
+	if (pid == 0) {
+		pid = pid_alloc();
+		if (pid == 0) {
+			/* Too many processes */
+			return EAGAIN;
+		}
+	}
+	/*
+	 * make proc entry for new proc
+	 */
+	p->p_parent = curproc;
+	p->p_pgrp = pg;
+	p->p_stat = SRUN;
+	p->p_exitcode = 0;
+	p->p_pid = pid;
+	p->p_task = task;
+	p->p_vforked = 0;
+	p->p_invfork = 0;
+
+	list_init(&p->p_children);
+	p_add(p);
+	list_insert(&curproc->p_children, &p->p_sibling);
+	list_insert(&pg->pg_members, &p->p_pgrp_link);
+	list_insert(&allproc, &p->p_link);
+
+	return 0;
+}
+
+/*
+ * fork() support.
+ *
+ * It creates new process data and update all process relations.
+ * The task creation and the thread creation are done by the
+ * fork() library stub.
+ */
+int
+sys_fork(task_t child, int vfork, pid_t *retval)
+{
+	struct proc *p;
+	int error;
+
+	DPRINTF(("proc: fork child=%x vfork=%d\n", child, vfork));
+
+	if (vfork && curproc->p_invfork) {
+		DPRINTF(("proc: vfork under vfork!\n"));
+		return EINVAL;
+	}
+
+	if (task_to_proc(child) != NULL) {
+		DPRINTF(("proc: process already exists\n"));
+		return EINVAL;
+	}
+
+	if ((p = malloc(sizeof(struct proc))) == NULL)
+		return ENOMEM;
+	memset(p, 0, sizeof(*p));
+
+	error = newproc(p, 0, child);
+	if (error)
+		return error;
+
+	if (vfork) {
+		vfork_start(curproc);
+		p->p_invfork = 1;
+	}
+
+	DPRINTF(("proc: fork newpid=%d\n", p->p_pid));
+	*retval = p->p_pid;
+	return 0;
+}
+
+/*
+ * Clean up all resource created by fork().
+ */
+void
+cleanup(struct proc *p)
+{
+	struct proc *pp;
+
+	DPRINTF(("proc: cleanup pid=%d\n", p->p_pid));
+	pp = p->p_parent;
+	list_remove(&p->p_sibling);
+	list_remove(&p->p_pgrp_link);
+	list_remove(&p->p_link);
+	free(p);
+}
+
+static int
+vfork_start(struct proc *p)
+{
+	void *stack;
+
+	/*
+	 * Save parent's stack
+	 */
+	DPRINTF(("proc: vfork_start stack=%x\n", p->p_stackbase));
+
+	if (vm_allocate(p->p_task, &stack, DFLSTKSZ, 1) != 0) {
+		DPRINTF(("proc: failed to allocate save stack\n"));
+		return ENOMEM;
+	}
+
+	memcpy(stack, p->p_stackbase, DFLSTKSZ);
+	p->p_stacksaved = stack;
+
+	p->p_vforked = 1;
+	return 0;
+}
+
+void
+vfork_end(struct proc *p)
+{
+
+	DPRINTF(("proc: vfork_end org=%x saved=%x\n", p->p_stackbase,
+		 p->p_stacksaved));
+	/*
+	 * Restore parent's stack
+	 */
+	memcpy(p->p_stackbase, p->p_stacksaved, DFLSTKSZ);
+	vm_free(p->p_task, p->p_stacksaved);
+
+	/*
+	 * Resume parent
+	 */
+	p->p_vforked = 0;
+	task_resume(p->p_task);
+}
diff --git a/prex-0.9.0/usr/server/proc/proc_hash.c b/prex-0.9.0/usr/server/proc/proc_hash.c
new file mode 100755
index 0000000..cfff6ac
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc_hash.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * hash.c - pid/pgid mapping tables.
+ */
+
+#include <sys/prex.h>
+
+#include <ipc/ipc.h>
+#include <sys/list.h>
+#include <unistd.h>
+
+#include "proc.h"
+
+/*
+ * Hash tables for ID mapping
+ */
+static struct list pid_table[ID_MAXBUCKETS];	/* mapping: pid  -> proc */
+static struct list task_table[ID_MAXBUCKETS];	/* mapping: task -> proc */
+static struct list pgid_table[ID_MAXBUCKETS];	/* mapping: pgid -> pgrp */
+
+/*
+ * Locate a process by number
+ */
+struct proc *
+p_find(pid_t pid)
+{
+	list_t head, n;
+	struct proc *p = NULL;
+
+	head = &pid_table[IDHASH(pid)];
+	n = list_first(head);
+	while (n != head) {
+		p = list_entry(n, struct proc, p_pid_link);
+		if (p->p_pid == pid)
+			return p;
+		n = list_next(n);
+	}
+	return NULL;
+}
+
+/*
+ * Locate a process group by number
+ */
+struct pgrp *
+pg_find(pid_t pgid)
+{
+	list_t head, n;
+	struct pgrp *g = NULL;
+
+	head = &pgid_table[IDHASH(pgid)];
+	n = list_first(head);
+	while (n != head) {
+		g = list_entry(n, struct pgrp, pg_link);
+		if (g->pg_pgid == pgid)
+			return g;
+		n = list_next(n);
+	}
+	return NULL;
+}
+
+/*
+ * Find process by task ID.
+ */
+struct proc *
+task_to_proc(task_t task)
+{
+	list_t head, n;
+	struct proc *p = NULL;
+
+	head = &task_table[IDHASH(task)];
+	n = list_first(head);
+
+	while (n != head) {
+		p = list_entry(n, struct proc, p_task_link);
+		if (p->p_task == task)
+			return p;
+		n = list_next(n);
+	}
+	return NULL;
+}
+
+/*
+ * Add process to the pid table and the task table.
+ * This routine assumes pid and task data has been already initialized.
+ */
+void
+p_add(struct proc *p)
+{
+
+	list_insert(&pid_table[IDHASH(p->p_pid)], &p->p_pid_link);
+	list_insert(&task_table[IDHASH(p->p_task)], &p->p_task_link);
+}
+
+/*
+ * Remove process from both of pid table and task table.
+ */
+void
+p_remove(struct proc *p)
+{
+
+	list_remove(&p->p_pid_link);
+	list_remove(&p->p_task_link);
+}
+
+/*
+ * Add process group to table.
+ * This routine assumes pgid has been already initialized.
+ */
+void
+pg_add(struct pgrp *pgrp)
+{
+
+	list_insert(&pgid_table[IDHASH(pgrp->pg_pgid)], &pgrp->pg_link);
+}
+
+/*
+ * Remove process from pgid table.
+ */
+void
+pg_remove(struct pgrp *pgrp)
+{
+
+	list_remove(&pgrp->pg_link);
+}
+
+/*
+ * Initialize tables.
+ */
+void
+table_init(void)
+{
+	int i;
+
+	for (i = 0; i < ID_MAXBUCKETS; i++) {
+		list_init(&pid_table[i]);
+		list_init(&task_table[i]);
+		list_init(&pgid_table[i]);
+	}
+}
diff --git a/prex-0.9.0/usr/server/proc/proc_pid.c b/prex-0.9.0/usr/server/proc/proc_pid.c
new file mode 100755
index 0000000..2f8beef
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc_pid.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pid.c - service for process id.
+ */
+
+#include <sys/prex.h>
+#include <ipc/proc.h>
+#include <ipc/ipc.h>
+#include <sys/list.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "proc.h"
+
+/*
+ * getpid - get the process ID.
+ */
+pid_t
+sys_getpid(void)
+{
+
+	ASSERT(curproc);
+	return curproc->p_pid;
+}
+
+/*
+ * getppid - get the parent process ID.
+ */
+pid_t
+sys_getppid(void)
+{
+
+	ASSERT(curproc);
+	return curproc->p_parent->p_pid;
+}
+
+/*
+ * getpgid - get the process group ID for a process.
+ *
+ * If the specified pid is equal to 0, it returns the process
+ * group ID of the calling process.
+ */
+int
+sys_getpgid(pid_t pid, pid_t *retval)
+{
+	struct proc *p;
+
+	ASSERT(curproc);
+
+	if (pid == 0)
+		p = curproc;
+	else {
+		if ((p = p_find(pid)) == NULL)
+			return ESRCH;
+	}
+	*retval = p->p_pgrp->pg_pgid;
+	return 0;
+}
+
+/*
+ * getsid - get the process group ID of a session leader.
+ */
+int
+sys_getsid(pid_t pid, pid_t *retval)
+{
+	pid_t sid;
+	struct proc *p, *leader;
+
+	ASSERT(curproc);
+
+	if (pid == 0)
+		p = curproc;
+	else {
+		if ((p = p_find(pid)) == NULL)
+			return ESRCH;
+	}
+	leader = p->p_pgrp->pg_session->s_leader;
+	sid = leader->p_pid;
+
+	DPRINTF(("proc: getsid sid=%d\n", sid));
+	*retval = sid;
+	return 0;
+}
+
+/*
+ * Move process to a new or existing process group.
+ */
+int
+enterpgrp(struct proc *p, pid_t pgid)
+{
+	struct pgrp *pgrp;
+
+	DPRINTF(("proc: enter pgrp pid=%d pgid=%d\n", p->p_pid, pgid));
+	if ((pgrp = pg_find(pgid)) == NULL) {
+		/*
+		 * Create a new process group.
+		 */
+		DPRINTF(("proc: create new pgrp\n"));
+		if ((pgrp = malloc(sizeof(struct pgrp))) == NULL)
+			return ENOMEM;
+		memset(pgrp, 0, sizeof(*pgrp));
+		list_init(&pgrp->pg_members);
+		pgrp->pg_pgid = pgid;
+		pg_add(pgrp);
+	}
+	/*
+	 * Remove from the old process group.
+	 * And, join an existing process group.
+	 */
+	list_remove(&p->p_pgrp_link);
+	list_insert(&pgrp->pg_members, &p->p_pgrp_link);
+	pgrp->pg_session = curproc->p_pgrp->pg_session;
+	p->p_pgrp = pgrp;
+	return 0;
+}
+
+/*
+ * Remove process from process group.
+ */
+int
+leavepgrp(struct proc *p)
+{
+	struct pgrp *pgrp = p->p_pgrp;
+
+	list_remove(&p->p_pgrp_link);
+	if (list_empty(&pgrp->pg_members)) {
+
+		/* XXX: do some work for session */
+
+		pg_remove(pgrp);
+		free(pgrp);
+	}
+	p->p_pgrp = 0;
+	return (0);
+}
+
+
+/*
+ * setpgid - set process group ID for job control.
+ *
+ * If the specified pid is equal to 0, the process ID of
+ * the calling process is used. Also, if pgid is 0, the process
+ * ID of the indicated process is used.
+ */
+int
+sys_setpgid(pid_t pid, pid_t pgid)
+{
+	struct proc *p;
+
+	DPRINTF(("proc: setpgid pid=%d pgid=%d\n", pid, pgid));
+
+	if (pid == 0)
+		p = curproc;
+	else {
+		if ((p = p_find(pid)) == NULL)
+			return ESRCH;
+	}
+	if (pgid < 0)
+		return EINVAL;
+	if (pgid == 0)
+		pgid = p->p_pid;
+	if (p->p_pgrp->pg_pgid == pgid)	/* already leader */
+		return 0;
+	return (enterpgrp(p, pgid));
+}
+
+/*
+ * setsid - create session and set process group ID.
+ */
+int
+sys_setsid(pid_t *retval)
+{
+	struct proc *p;
+	struct pgrp *pgrp;
+	struct session *sess;
+	int error;
+
+	DPRINTF(("proc: setsid sid=%d\n", curproc->p_pid));
+
+	p = curproc;
+	if (p->p_pid == p->p_pgrp->pg_pgid)	/* already leader */
+		return EPERM;
+
+	if ((sess = malloc(sizeof(struct session))) == NULL)
+		return ENOMEM;
+	memset(sess, 0, sizeof(*sess));
+
+	/*
+	 * Create a new process group.
+	 */
+	if ((error = enterpgrp(p, p->p_pid)) != 0) {
+		free(sess);
+		return error;
+	}
+	pgrp = p->p_pgrp;
+
+	/*
+	 * Create a new session.
+	 */
+	sess->s_refcnt = 1;
+	sess->s_leader = p;
+	sess->s_ttyhold = 0;
+	pgrp->pg_session = sess;
+
+	*retval = p->p_pid;
+	return 0;
+}
diff --git a/prex-0.9.0/usr/server/proc/proc_sig.c b/prex-0.9.0/usr/server/proc/proc_sig.c
new file mode 100755
index 0000000..6de9a74
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc_sig.c
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * proc_sig.c - signal transfer.
+ */
+
+#include <sys/prex.h>
+#include <sys/capability.h>
+#include <ipc/proc.h>
+#include <sys/list.h>
+
+#include <unistd.h>
+#include <errno.h>
+
+#include "proc.h"
+
+/*
+ * Check if current process has CAP_KILL capability.
+ */
+static int
+kill_capable(void)
+{
+
+	if (task_chkcap(curproc->p_task, CAP_KILL) == 0)
+		return 1;
+	return 0;
+}
+
+/*
+ * Send a signal to the process.
+ */
+static int
+sendsig(struct proc *p, int sig)
+{
+
+	/*
+	 * We never allow to send signal to the
+	 * process server in any case.
+	 */
+	if (p->p_pid == 0)
+		return EPERM;
+
+	/*
+	 * Filter signals for init process.
+	 * This is for fail safe...
+	 */
+	if (p->p_pid == 1 && sig != SIGCHLD)
+		return EPERM;
+
+	DPRINTF(("proc: sendsig task=%x\n", p->p_task));
+	return exception_raise(p->p_task, sig);
+}
+
+/*
+ * Send a signal to one process.
+ */
+static int
+kill_one(pid_t pid, int sig)
+{
+	struct proc *p;
+
+	DPRINTF(("proc: killone pid=%d sig=%d\n", pid, sig));
+
+	if ((p = p_find(pid)) == NULL)
+		return ESRCH;
+	return sendsig(p, sig);
+}
+
+/*
+ * Send a signal to all process in the process group.
+ */
+int
+kill_pg(pid_t pgid, int sig)
+{
+	struct proc *p;
+	struct pgrp *pgrp;
+	list_t head, n;
+	int error = 0;
+
+	DPRINTF(("proc: killpg pgid=%d sig=%d\n", pgid, sig));
+
+	if ((pgrp = pg_find(pgid)) == NULL)
+		return ESRCH;
+
+	head = &pgrp->pg_members;
+	for (n = list_first(head); n != head; n = list_next(n)) {
+		p = list_entry(n, struct proc, p_pgrp_link);
+		if ((error = sendsig(p, sig)) != 0)
+			break;
+	}
+	return error;
+}
+
+/*
+ * Send a signal.
+ *
+ * The behavior is different for the pid value.
+ *
+ *  if (pid > 0)
+ *    Send a signal to specific process.
+ *
+ *  if (pid == 0)
+ *    Send a signal to all processes in same process group.
+ *
+ *  if (pid == -1)
+ *    Send a signal to all processes except init.
+ *
+ *  if (pid < -1)
+ *     Send a signal to the process group.
+ *
+ * Note: Need CAP_KILL capability to send a signal to the different
+ * process/group.
+ */
+int
+sys_kill(pid_t pid, int sig)
+{
+	struct proc *p;
+	list_t n;
+	int error = 0;
+
+	DPRINTF(("proc: kill pid=%d sig=%d\n", pid, sig));
+
+	switch (sig) {
+	case SIGFPE:
+	case SIGILL:
+	case SIGSEGV:
+		return EINVAL;
+	}
+
+	if (pid > 0) {
+		if (pid != curproc->p_pid && !kill_capable()) {
+			DPRINTF(("proc: EPERM\n"));
+			return EPERM;
+		}
+		error = kill_one(pid, sig);
+	}
+	else if (pid == -1) {
+		DPRINTF(("proc: kill? curproc=%x\n", curproc));
+		if (!kill_capable())
+			return EPERM;
+
+		DPRINTF(("proc: kill all!\n"));
+		for (n = list_first(&allproc); n != &allproc;
+		     n = list_next(n)) {
+			p = list_entry(n, struct proc, p_link);
+
+			/*
+			 * We don't send a signal to the following processes.
+			 *
+			 *  pid=0   - process server
+			 *  pid=1   - init process
+			 *  curproc - current process (sleeping in msg_send)
+			 */
+			if (p->p_pid != 0 && p->p_pid != 1 &&
+			    p->p_pid != curproc->p_pid)
+			{
+				error = kill_one(p->p_pid, sig);
+				if (error != 0)
+					break;
+			}
+		}
+	}
+	else if (pid == 0) {
+		error = kill_pg(curproc->p_pgrp->pg_pgid, sig);
+	}
+	else {	/* pid < -1 */
+		if (curproc->p_pgrp->pg_pgid != -pid && !kill_capable())
+			return EPERM;
+		error = kill_pg(-pid, sig);
+	}
+	return error;
+}
diff --git a/prex-0.9.0/usr/server/proc/proc_tty.c b/prex-0.9.0/usr/server/proc/proc_tty.c
new file mode 100755
index 0000000..dbdc2ee
--- /dev/null
+++ b/prex-0.9.0/usr/server/proc/proc_tty.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * tty.c - TTY signal support
+ */
+
+#include <sys/prex.h>
+#include <ipc/proc.h>
+#include <sys/list.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <termios.h>
+
+#include "proc.h"
+
+static device_t ttydev;
+
+/*
+ * Send TTY signal.
+ */
+static void
+tty_signal(int sig)
+{
+	pid_t pgid;
+
+	/*
+	 * Get the process group that was active when
+	 * the TTY signal was invoked.
+	 */
+	if (device_ioctl(ttydev, TIOCGPGRP, &pgid) != 0)
+		return;
+
+	DPRINTF(("proc: tty_signal pgid=%d sig=%d\n", pgid, sig));
+	kill_pg(pgid, sig);
+}
+
+/*
+ * Catch TTY related signals and forward them
+ * to the appropriate processes.
+ */
+static void
+exception_handler(int sig)
+{
+
+	/*
+	 * Handle signals from tty input.
+	 */
+	switch (sig) {
+	case SIGINT:
+	case SIGQUIT:
+	case SIGTSTP:
+	case SIGTTIN:
+	case SIGTTOU:
+	case SIGINFO:
+	case SIGWINCH:
+	case SIGIO:
+		if (ttydev != NODEV)
+			tty_signal(sig);
+		break;
+	}
+	exception_return();
+}
+
+
+/*
+ * Initialize TTY.
+ *
+ * Since we manage the process group only in the process
+ * server, the TTY driver can not know anything about the
+ * process group.  However, POSIX specification requires TTY
+ * driver to send a signal to the specific process group.
+ * So, we will catch all TTY related signals by this server
+ * and forward them to the actual process or process group.
+ */
+void
+tty_init(void)
+{
+	task_t self;
+
+	/*
+	 * Setup exception to receive signals from tty.
+	 */
+	exception_setup(exception_handler);
+
+	if (device_open("tty", 0, &ttydev) != 0) {
+		DPRINTF(("proc: no tty found\n"));
+		ttydev = NODEV;
+	} else {
+		/*
+		 * Notify the TTY driver to send all tty related
+		 * signals in system to this task.
+		 */
+		self = task_self();
+		device_ioctl(ttydev, TIOCSETSIGT, &self);
+	}
+}
diff --git a/prex-0.9.0/usr/test/Makefile b/prex-0.9.0/usr/test/Makefile
new file mode 100755
index 0000000..f5677d4
--- /dev/null
+++ b/prex-0.9.0/usr/test/Makefile
@@ -0,0 +1,17 @@
+include $(SRCDIR)/mk/own.mk
+
+# Test for kernel
+SUBDIR:=	task thread ipc timer exception fault deadlock sem mutex \
+		cpufreq ipc_mt kmon attack stack memleak object
+
+# Test for driver
+SUBDIR+=	console kbd fdd ramdisk reset time zero
+
+# Test for library
+SUBDIR+=	errno malloc stderr environ
+
+# Test for servers
+SUBDIR+=	fileio fork forkbomb args signal fifo pipe dup creat conf \
+		mount umount shutdown
+
+include $(SRCDIR)/mk/subdir.mk
diff --git a/prex-0.9.0/usr/test/args/Makefile b/prex-0.9.0/usr/test/args/Makefile
new file mode 100755
index 0000000..3eeaf42
--- /dev/null
+++ b/prex-0.9.0/usr/test/args/Makefile
@@ -0,0 +1,5 @@
+PROG=	args
+
+#DISASM=	args.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/args/args.c b/prex-0.9.0/usr/test/args/args.c
new file mode 100755
index 0000000..5cf5079
--- /dev/null
+++ b/prex-0.9.0/usr/test/args/args.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * args.c - check arguments for main() routine.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+extern char **environ;
+
+int
+main(int argc, char *argv[])
+{
+	int i;
+	char **envp = environ;
+
+	printf("argument test\n");
+
+	/*
+	 * Print all arguments that were input by user.
+	 */
+	printf("argc=%d argv=%x\n", argc, (unsigned int)argv);
+	printf("Dump args:\n");
+	for (i = 0; i < argc; i++) {
+		/* printf("argv[%d]: 0x%x\n", i, (unsigned int)argv[i]); */
+		printf("argv[%d]: %s\n", i, argv[i]);
+	}
+	printf("Dump envs:\n");
+	for (i = 0; envp[i] != NULL; i++) {
+		/* printf("envp[%d]: 0x%x\n", i, (unsigned int)envp[i]); */
+		printf("envp[%d]: %s\n", i, envp[i]);
+	}
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/test/attack/Makefile b/prex-0.9.0/usr/test/attack/Makefile
new file mode 100755
index 0000000..00ea802
--- /dev/null
+++ b/prex-0.9.0/usr/test/attack/Makefile
@@ -0,0 +1,3 @@
+PROG=	attack
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/attack/attack.c b/prex-0.9.0/usr/test/attack/attack.c
new file mode 100755
index 0000000..2545ba3
--- /dev/null
+++ b/prex-0.9.0/usr/test/attack/attack.c
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * attack.c - invalid parameter attack.
+ */
+
+#include <sys/prex.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define NATTACKS	1000
+
+void
+attack(void)
+{
+	object_t *objp	= (object_t *)random();
+	object_t obj	= (object_t)random();
+	char *name	= (char *)random();
+	void *msg	= (void *)random();
+	size_t size	= (size_t)random();
+	task_t self	= task_self();
+	void *addr	= (void *)random();
+	int attr	= random() & 7;
+	thread_t t	= (thread_t)random();
+	thread_t *tp	= (thread_t *)random();
+
+	object_create(NULL, NULL);
+	object_create(NULL, objp);
+	object_create(name, NULL);
+	object_create(name, objp);
+
+	object_destroy(0);
+	object_destroy(obj);
+
+	object_lookup(NULL, objp);
+	object_lookup(name, NULL);
+	object_lookup(name, objp);
+
+	msg_send(0, msg, size);
+	msg_send(obj, NULL, size);
+	msg_send(obj, msg, 0);
+	msg_send(0, msg, 0);
+	msg_send(0, NULL, size);
+	msg_send(obj, msg, size);
+
+	msg_receive(0, msg, size);
+	msg_receive(obj, NULL, size);
+	msg_receive(obj, msg, 0);
+	msg_receive(0, msg, 0);
+	msg_receive(0, NULL, size);
+	msg_receive(obj, msg, size);
+
+	msg_reply(0, msg, size);
+	msg_reply(obj, NULL, size);
+	msg_reply(obj, msg, 0);
+	msg_reply(0, msg, 0);
+	msg_reply(0, NULL, size);
+	msg_reply(obj, msg, size);
+
+	vm_allocate(self, addr, size, 1);
+	vm_allocate(self, &addr, size, 1);
+
+	vm_free(self, addr);
+	vm_attribute(self, addr, attr);
+	vm_map(self, addr, size, &addr);
+
+	thread_create(self, tp);
+	thread_suspend(t);
+	thread_terminate(t);
+}
+
+int
+main(int argc, char *argv[])
+{
+	int i;
+
+	printf("starting invalid parameter attack.\n");
+
+	for (i = 0; i < NATTACKS; i++)
+		attack();
+
+	printf("test complete\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/conf/Makefile b/prex-0.9.0/usr/test/conf/Makefile
new file mode 100755
index 0000000..c4ae2ed
--- /dev/null
+++ b/prex-0.9.0/usr/test/conf/Makefile
@@ -0,0 +1,2 @@
+PROG=	conf
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/conf/conf.c b/prex-0.9.0/usr/test/conf/conf.c
new file mode 100755
index 0000000..d4aee65
--- /dev/null
+++ b/prex-0.9.0/usr/test/conf/conf.c
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * conf.c - test POSIX configuration interface
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(int argc, char *argv[])
+{
+	char *pathbuf; size_t sz;
+
+	printf("configuration test\n");
+
+	sz = confstr(_CS_PATH,NULL,(size_t)0);
+	if ((pathbuf = malloc(sz)) == NULL) {
+		printf("no mem\n");
+		exit(1);
+	}
+	confstr(_CS_PATH, pathbuf, sz);
+	printf("_CS_PATH=%s\n", pathbuf);
+
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/test/console/Makefile b/prex-0.9.0/usr/test/console/Makefile
new file mode 100755
index 0000000..b261aa8
--- /dev/null
+++ b/prex-0.9.0/usr/test/console/Makefile
@@ -0,0 +1,3 @@
+TASK=	console.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/console/console.c b/prex-0.9.0/usr/test/console/console.c
new file mode 100755
index 0000000..a6a9d72
--- /dev/null
+++ b/prex-0.9.0/usr/test/console/console.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * console.c - test program for console driver
+ */
+
+#include <sys/prex.h>
+#include <string.h>
+
+int
+main(int argc, char *argv[])
+{
+	device_t console_dev;
+	char buf[] = "ABCDEFGHIJKLMN";
+	int i, error;
+	size_t len;
+
+	sys_log("console test program\n");
+	error = device_open("console", 0, &console_dev);
+	if (error)
+		sys_log("device open error!\n");
+
+	/*
+	 * Display 'ABCDE'
+	 */
+	len = 5;
+	device_write(console_dev, buf, &len, 0);
+
+	/*
+	 * Display 'AAAA...'
+	 */
+	len = 1;
+	for (i = 0; i < 100; i++)
+		device_write(console_dev, buf, &len, 0);
+
+	/*
+	 * Try to pass invalid pointer.
+	 * It will cause a fault, and get EFAULT.
+	 */
+	sys_log("\ntest an invalid pointer.\n");
+	len = 100;
+	error = device_write(console_dev, 0, &len, 0);
+	if (error)
+		sys_log("OK!\n");
+	else
+		sys_log("Bad!\n");
+
+	error = device_close(console_dev);
+	if (error)
+		sys_log("device close error!\n");
+
+       	sys_log("Completed\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/cpufreq/Makefile b/prex-0.9.0/usr/test/cpufreq/Makefile
new file mode 100755
index 0000000..53a8371
--- /dev/null
+++ b/prex-0.9.0/usr/test/cpufreq/Makefile
@@ -0,0 +1,3 @@
+TASK=	cpufreq.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/cpufreq/cpufreq.c b/prex-0.9.0/usr/test/cpufreq/cpufreq.c
new file mode 100755
index 0000000..45f41c4
--- /dev/null
+++ b/prex-0.9.0/usr/test/cpufreq/cpufreq.c
@@ -0,0 +1,123 @@
+/*-
+ * Copyright (c) 2005-2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cpufreq.c - test cpu frequency controll
+ */
+
+/*
+ * This program changes the CPU load periodically. Since the cpufreq driver
+ * is polling the CPU load, the driver will change the CPU voltage/freqency
+ * automatically when CPU becomes idle state.
+ *
+ * It is recommended to run CPU voltage monitor 'cpumon' with this program.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+static void
+set_0_or_100(void)
+{
+	u_long t1, t2;
+	char index[] = "-\\|/";
+	char bar[] = "*\033[1D";
+	int i, cnt;
+
+	i = 0;
+	for (cnt = 0; cnt < 2; cnt++) {
+		/*
+		 * Display indicator for 5 sec.
+		 */
+		printf("\rCPU Busy:");
+		sys_time(&t1);
+		for (;;) {
+			sys_time(&t2);
+			if (t2 > t1 + 5000)
+				break;
+			/*
+			 * Update indicator per 100 msec.
+			 */
+			if ((t2 % 100) == 0) {
+				bar[0] = index[i++ % 4];
+				printf("%s", bar);
+			}
+		}
+		/*
+		 * Sleep 5 sec.
+		 */
+		printf("\rCPU Idle  ");
+		timer_sleep(5000, 0);
+	}
+}
+
+static void
+set_50(void)
+{
+	u_long t1, t2;
+	char index[] = "-\\|/";
+	char bar[] = "*\033[1D";
+	int i, cnt;
+
+	printf("\rCPU half speed:");
+	i = 0;
+	for (cnt = 0; cnt < 5000; cnt++) {
+		/*
+		 * Update indicator per 100 msec.
+		 */
+		if ((t2 % 100) == 0) {
+			bar[0] = index[i++ % 4];
+			printf("%s", bar);
+		}
+		sys_time(&t1);
+		for (;;) {
+			sys_time(&t2);
+			if (t2 > t1 + 1)
+				break;
+		}
+		/*
+		 * Sleep 1msec.
+		 */
+		timer_sleep(1, 0);
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	thread_yield();
+
+	printf("cpufreq test program\n");
+
+	for (;;) {
+		set_0_or_100();
+		set_50();
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/creat/Makefile b/prex-0.9.0/usr/test/creat/Makefile
new file mode 100755
index 0000000..ad5c89b
--- /dev/null
+++ b/prex-0.9.0/usr/test/creat/Makefile
@@ -0,0 +1,4 @@
+PROG=	creat
+#DISASM= creat.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/creat/creat.c b/prex-0.9.0/usr/test/creat/creat.c
new file mode 100755
index 0000000..933f3a2
--- /dev/null
+++ b/prex-0.9.0/usr/test/creat/creat.c
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * creat.c - file creation test.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+
+#define FILE_NUM 100
+
+static char path[128];
+
+int
+main(int argc, char *argv[])
+{
+	int fd, i;
+	char file[128];
+	pid_t pid = getpid();
+
+	sprintf(path, "t%05d", pid);
+	if (mkdir(path, 0770) < 0)
+		err(1, "mkdir(%s)", path);
+	if (chdir(path) == -1)
+		err(1, "chdir(%s)", path);
+
+	for (i = 0; i < FILE_NUM; i++) {
+		sprintf(file, "p%05d.%03d", pid, i);
+		if ((fd = creat(file, 0660)) == -1) {
+			if (errno != EINTR) {
+				warn("creat(%s)", file);
+				break;
+			}
+		}
+		if (fd != -1 && close(fd) == -1)
+			err(2, "close(%d)", i);
+	}
+
+	for (i--; i >= 0; i--) {
+		sprintf(file, "p%05d.%03d", pid, i);
+		if (unlink(file) == -1)
+			err(3, "unlink(%s)", file);
+	}
+
+	return (0);
+}
diff --git a/prex-0.9.0/usr/test/deadlock/Makefile b/prex-0.9.0/usr/test/deadlock/Makefile
new file mode 100755
index 0000000..614d691
--- /dev/null
+++ b/prex-0.9.0/usr/test/deadlock/Makefile
@@ -0,0 +1,3 @@
+TASK=	deadlock.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/deadlock/deadlock.c b/prex-0.9.0/usr/test/deadlock/deadlock.c
new file mode 100755
index 0000000..c4771a7
--- /dev/null
+++ b/prex-0.9.0/usr/test/deadlock/deadlock.c
@@ -0,0 +1,178 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * deadlock.c - test program for a kernel deadlock detection.
+ */
+
+/*
+ * Prex kernel has the feature of deadlock detection. The following
+ * senario is tested with this program.
+ *
+ * 1) Thread-2 locks mutex-A.
+ * 2) Thread-1 locks mutex-B.
+ * 3) Thread-1 locks mutex-A.
+ * 4) Thread-2 locks mutex-B.
+ *
+ * The deadlock occurs at 4) because mutex-B has been already locked by
+ * thread-1 and thread-1 is waiting for thread-2 (mutex-A).
+ * The kernel will detect this condition, and the mutex_lock() system
+ * call will return EDEADLK error code.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <errno.h>
+
+static char stack[2][1024];
+static thread_t th_1, th_2;
+static mutex_t mtx_A, mtx_B;
+
+thread_t
+thread_run(void (*start)(void), void *stack)
+{
+	thread_t t;
+	int error;
+
+	error = thread_create(task_self(), &t);
+	if (error)
+		panic("thread_create is failed");
+
+	error = thread_load(t, start, stack);
+	if (error)
+		panic("thread_load is failed");
+
+	return t;
+}
+
+/*
+ * Thread 1 - Priority = 100
+ */
+static void
+thread_1(void)
+{
+	int error;
+
+	printf("thread_1: starting\n");
+
+	/*
+	 * 2) Lock mutex B
+	 */
+	printf("thread_1: 2) lock B\n");
+	error = mutex_lock(&mtx_B);
+	if (error) printf("error=%d\n", error);
+
+	/*
+	 * 3) Lock mutex A
+	 *
+	 * Switch to thread 1.
+	 */
+	printf("thread_1: 3) lock A\n");
+	error = mutex_lock(&mtx_A);
+	if (error) printf("error=%d\n", error);
+
+	printf("thread_1: exit\n");
+	thread_terminate(th_1);
+}
+
+/*
+ * Thread 2 - Priority = 101
+ */
+static void
+thread_2(void)
+{
+	int error;
+
+	printf("thread_2: starting\n");
+
+	/*
+	 * 1) Lock mutex A
+	 */
+	printf("thread_2: 1) lock A\n");
+	error = mutex_lock(&mtx_A);
+	if (error) printf("error=%d\n", error);
+
+	/*
+	 * Switch to thread 1
+	 */
+	thread_resume(th_1);
+
+	printf("thread_2: running\n");
+	/*
+	 * 4) Lock mutex B
+	 *
+	 * Deadlock occurs here!
+	 */
+	printf("thread_2: 4) lock B\n");
+	error = mutex_lock(&mtx_B);
+	if (error) printf("error=%d\n", error);
+	if (error == EDEADLK)
+		printf("**** DEADLOCK!! ****\n");
+
+	printf("thread_2: exit\n");
+	thread_terminate(th_2);
+}
+
+int
+main(int argc, char *argv[])
+{
+	printf("Deadlock test program\n");
+
+	/*
+	 * Boost priority of this thread
+	 */
+	thread_setpri(thread_self(), 90);
+
+	/*
+	 * Initialize mutexes.
+	 */
+	mutex_init(&mtx_A);
+	mutex_init(&mtx_B);
+
+	/*
+	 * Create new threads
+	 */
+	th_1 = thread_run(thread_1, stack[0]+1024);
+	thread_setpri(th_1, 100);
+
+	th_2 = thread_run(thread_2, stack[1]+1024);
+	thread_setpri(th_2, 101);
+
+	/*
+	 * Start thread 2
+	 */
+	thread_resume(th_2);
+
+	/*
+	 * Wait...
+	 */
+	thread_suspend(thread_self());
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/dup/Makefile b/prex-0.9.0/usr/test/dup/Makefile
new file mode 100755
index 0000000..7f924b9
--- /dev/null
+++ b/prex-0.9.0/usr/test/dup/Makefile
@@ -0,0 +1,4 @@
+PROG=	dup
+#DISASM= dup.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/dup/dup.c b/prex-0.9.0/usr/test/dup/dup.c
new file mode 100755
index 0000000..b4019c7
--- /dev/null
+++ b/prex-0.9.0/usr/test/dup/dup.c
@@ -0,0 +1,168 @@
+/*
+ * $OpenBSD: dup2test.c,v 1.3 2003/07/31 21:48:08 deraadt Exp $
+ * $OpenBSD: dup2_self.c,v 1.3 2003/07/31 21:48:08 deraadt Exp $
+ * $OpenBSD: fcntl_dup.c,v 1.2 2003/07/31 21:48:08 deraadt Exp $
+ *
+ * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain.
+ *
+ * $FreeBSD: src/tools/regression/file/dup/dup.c,v 1.2.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $
+ */
+
+/* Modified for Prex by Kohsuke Ohtani */
+
+/*
+ * Test #1:  check if dup(2) works.
+ * Test #2:  check if dup2(2) works.
+ * Test #3:  check if dup2(2) returned a fd we asked for.
+ * Test #4:  check if dup2(2) cleared close-on-exec flag for duped fd.
+ * Test #5:  check if dup2(2) allows to dup fd to itself.
+ * Test #6:  check if dup2(2) returned a fd we asked for.
+ * Test #7:  check if dup2(2) did not clear close-on-exec flag for duped fd.
+ * Test #8:  check if fcntl(F_DUPFD) works.
+ * Test #9:  check if fcntl(F_DUPFD) cleared close-on-exec flag for duped fd.
+ * Test #10: check if dup2() to a fd > current maximum number of open files
+ *           limit work.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+static int	getafile(void);
+
+static int
+getafile(void)
+{
+	int fd;
+
+	char temp[] = "/tmp/dup2XXXXXXXXX";
+	if ((fd = mkstemp(temp)) < 0)
+		err(1, "mkstemp");
+	remove(temp);
+	if (ftruncate(fd, 1024) != 0)
+		err(1, "ftruncate");
+	return (fd);
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct rlimit rlp;
+	int orgfd, fd1, fd2, test = 0;
+
+	orgfd = getafile();
+
+	printf("1..17\n");
+
+	/* If dup(2) ever work? */
+	if ((fd1 = dup(orgfd)) < 0)
+		err(1, "dup");
+	printf("ok %d - dup(2) works\n", ++test);
+
+	/* Set close-on-exec */
+	if (fcntl(fd1, F_SETFD, 1) != 0)
+		err(1, "fcntl(F_SETFD)");
+
+	/* If dup2(2) ever work? */
+	if ((fd2 = dup2(fd1, fd1 + 1)) < 0)
+		err(1, "dup2");
+	printf("ok %d - dup2(2) works\n", ++test);
+
+	/* Do we get the right fd? */
+	++test;
+	if (fd2 != fd1 + 1)
+		printf("no ok %d - dup2(2) didn't give us the right fd\n",
+		    test);
+	else
+		printf("ok %d - dup2(2) returned a correct fd\n", test);
+
+#if 0
+	/* Was close-on-exec cleared? */
+	++test;
+	if (fcntl(fd2, F_GETFD) != 0)
+		printf("not ok %d - dup2(2) didn't clear close-on-exec\n",
+		    test);
+	else
+		printf("ok %d - dup2(2) cleared close-on-exec\n", test);
+#endif
+
+	/*
+	 * Dup to itself.
+	 *
+	 * We're testing a small tweak in dup2 semantics.
+	 * Normally dup and dup2 will clear the close-on-exec
+	 * flag on the new fd (which appears to be an implementation
+	 * mistake from start and not some planned behavior).
+	 * In todays implementations of dup and dup2 we have to make
+	 * an effort to really clear that flag.  But all tested
+	 * implementations of dup2 have another tweak.  If we
+	 * dup2(old, new) when old == new, the syscall short-circuits
+	 * and returns early (because there is no need to do all the
+	 * work (and there is a risk for serious mistakes)).
+	 * So although the docs say that dup2 should "take 'old',
+	 * close 'new' perform a dup(2) of 'old' into 'new'"
+	 * the docs are not really followed because close-on-exec
+	 * is not cleared on 'new'.
+	 *
+	 * Since everyone has this bug, we pretend that this is
+	 * the way it is supposed to be and test here that it really
+	 * works that way.
+	 *
+	 * This is a fine example on where two separate implementation
+	 * fuckups take out each other and make the end-result the way
+	 * it was meant to be.
+	 */
+	if ((fd2 = dup2(fd1, fd1)) < 0)
+		err(1, "dup2");
+	printf("ok %d - dup2(2) to itself works\n", ++test);
+
+	/* Do we get the right fd? */
+	++test;
+	if (fd2 != fd1)
+		printf("not ok %d - dup2(2) didn't give us the right fd\n",
+		    test);
+	else
+		printf("ok %d - dup2(2) to itself returned a correct fd\n",
+		    test);
+
+#if 0
+	/* Was close-on-exec cleared? */
+	++test;
+	if (fcntl(fd2, F_GETFD) == 0)
+		printf("not ok %d - dup2(2) cleared close-on-exec\n", test);
+	else
+		printf("ok %d - dup2(2) didn't clear close-on-exec\n", test);
+#endif
+
+	/* Does fcntl(F_DUPFD) work? */
+	if ((fd2 = fcntl(fd1, F_DUPFD, 0)) < 0)
+		err(1, "fcntl(F_DUPFD)");
+	printf("ok %d - fcntl(F_DUPFD) works\n", ++test);
+
+#if 0
+	/* Was close-on-exec cleared? */
+	++test;
+        if (fcntl(fd2, F_GETFD) != 0)
+		printf(
+		    "not ok %d - fcntl(F_DUPFD) didn't clear close-on-exec\n",
+		    test);
+	else
+		printf("ok %d - fcntl(F_DUPFD) cleared close-on-exec\n", test);
+
+#endif
+	++test;
+	if (getrlimit(RLIMIT_NOFILE, &rlp) < 0)
+		err(1, "getrlimit");
+	if ((fd2 = dup2(fd1, (int)(rlp.rlim_cur + 1))) >= 0)
+		printf("not ok %d - dup2(2) bypassed NOFILE limit\n", test);
+	else
+		printf("ok %d - dup2(2) didn't bypass NOFILE limit\n", test);
+
+	return (0);
+}
diff --git a/prex-0.9.0/usr/test/environ/Makefile b/prex-0.9.0/usr/test/environ/Makefile
new file mode 100755
index 0000000..e866075
--- /dev/null
+++ b/prex-0.9.0/usr/test/environ/Makefile
@@ -0,0 +1,2 @@
+PROG=	environ
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/environ/environ.c b/prex-0.9.0/usr/test/environ/environ.c
new file mode 100755
index 0000000..f4dcd03
--- /dev/null
+++ b/prex-0.9.0/usr/test/environ/environ.c
@@ -0,0 +1,112 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * environ.c - test POSIX environment variable
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+extern char **environ;
+
+static void
+oops(void)
+{
+	printf("oops!\n");
+	exit(1);
+}
+
+static void
+show_env(void)
+{
+	char **envp = environ;
+	int i;
+
+	for (i = 0; envp[i] != NULL; i++) {
+		printf("envp[%d]: %s\n", i, envp[i]);
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	char *val;
+
+	printf("test environment variables\n");
+
+	/* Show environment passed by shell */
+	printf("show env\n");
+	show_env();
+
+	/* Set new viriable */
+	printf("setenv-1\n");
+	setenv("PATH", "/boot", 1);
+	show_env();
+
+	/* Overwirte existing viriable */
+	printf("setenv-2\n");
+	setenv("PATH", "/boot:/bin", 1);
+	show_env();
+
+	/* No overwirte please... */
+	printf("setenv-3\n");
+	setenv("PATH", "/boot", 0);
+	show_env();
+
+	/* No overwirte please... */
+	printf("setenv-4\n");
+	setenv("PATH", "/boot", 0);
+	show_env();
+
+	/* Get non existing variable */
+	printf("getenv-1\n");
+	val = getenv("TMP");
+	if (val != NULL)
+		oops();
+
+	/* Get existing variable */
+	printf("getenv-2\n");
+	val = getenv("PATH");
+	if (val == NULL)
+		oops();
+	printf("PATH=%s\n", val);
+
+	/* putenv */
+	printf("putenv-1\n");
+	putenv("TMP=/tmp");
+	show_env();
+
+	printf("putenv-2\n");
+	putenv("ABC=/abc");
+	show_env();
+
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/test/errno/Makefile b/prex-0.9.0/usr/test/errno/Makefile
new file mode 100755
index 0000000..c7a48ca
--- /dev/null
+++ b/prex-0.9.0/usr/test/errno/Makefile
@@ -0,0 +1,3 @@
+TASK=	errno.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/errno/errno.c b/prex-0.9.0/usr/test/errno/errno.c
new file mode 100755
index 0000000..80bb513
--- /dev/null
+++ b/prex-0.9.0/usr/test/errno/errno.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * errno.c - dump the detail of all avilable errno.
+ */
+
+#include <string.h>
+#include <stdio.h>
+
+extern const int sys_nerr;
+
+int
+main(int argc, char *argv[])
+{
+	int i;
+
+	printf("Dump errno\n");
+	for (i = 0; i < sys_nerr; i++)
+		printf("error #%d:%s\n", i, strerror(i));
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/exception/Makefile b/prex-0.9.0/usr/test/exception/Makefile
new file mode 100755
index 0000000..c8c9a6a
--- /dev/null
+++ b/prex-0.9.0/usr/test/exception/Makefile
@@ -0,0 +1,3 @@
+TASK=	exception.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/exception/exception.c b/prex-0.9.0/usr/test/exception/exception.c
new file mode 100755
index 0000000..4b5d7de
--- /dev/null
+++ b/prex-0.9.0/usr/test/exception/exception.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * exception.c - test kernel exception feature.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+static void
+my_exception(int code)
+{
+	printf("Get exception code=%x\n", code);
+
+	exception_return();
+
+	/* Control never comes here */
+	panic("Ooops!");
+}
+
+int
+main(int argc, char *argv[])
+{
+	task_t task;
+
+	printf("Exception test program\n");
+
+	timer_sleep(2000, 0);
+
+	task = task_self();
+
+	/* Install exception handler */
+	exception_setup(my_exception);
+
+	/* Raise some exception */
+	exception_raise(task, 1);
+	exception_raise(task, 2);
+	exception_raise(task, 4);
+	exception_raise(task, 8);
+
+	/* Uninstall exception handler */
+	exception_setup(EXC_DFL);
+
+	/* Raise exception. This must be ignored */
+	exception_raise(task, 1);
+	timer_sleep(1000, 0);
+
+	printf("OK\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/fault/Makefile b/prex-0.9.0/usr/test/fault/Makefile
new file mode 100755
index 0000000..8afff27
--- /dev/null
+++ b/prex-0.9.0/usr/test/fault/Makefile
@@ -0,0 +1,3 @@
+TASK=	fault.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/fault/fault.c b/prex-0.9.0/usr/test/fault/fault.c
new file mode 100755
index 0000000..239e8af
--- /dev/null
+++ b/prex-0.9.0/usr/test/fault/fault.c
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fault.c - page fault test
+ */
+#include <sys/prex.h>
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+	int c;
+	volatile int data;	/* prevent optimization from gcc */
+	char *ptr;
+
+	printf("Fault test program is staring...\n");
+	printf("Waiting for key input.\n");
+
+	c = getchar();
+
+	printf("Key pressed!\n");
+	printf("Try to read from NULL pointer\n");
+	ptr = 0;
+	data = *ptr;
+
+	/* Control never comes here */
+	panic("Oops!");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/fdd/Makefile b/prex-0.9.0/usr/test/fdd/Makefile
new file mode 100755
index 0000000..e181752
--- /dev/null
+++ b/prex-0.9.0/usr/test/fdd/Makefile
@@ -0,0 +1,3 @@
+TASK=	fdd.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/fdd/fdd.c b/prex-0.9.0/usr/test/fdd/fdd.c
new file mode 100755
index 0000000..bed85b0
--- /dev/null
+++ b/prex-0.9.0/usr/test/fdd/fdd.c
@@ -0,0 +1,138 @@
+/*-
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fdd.c - fdd driver test program.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+int
+test_read(int sector)
+{
+	device_t fdd;
+	size_t size;
+	int error, i, j;
+	static unsigned char disk_buf[512];
+	unsigned char ch;
+
+	printf("open fd0\n");
+	error = device_open("fd0", 0, &fdd);
+	if (error) {
+		printf("open failed\n");
+		return 0;
+	}
+	printf("opened\n");
+
+	printf("fdd read: sector=%d buf=%x\n", sector, (u_int)disk_buf);
+	size = 512;
+	error = device_read(fdd, disk_buf, &size, sector);
+	if (error) {
+		printf("read failed\n");
+		device_close(fdd);
+		return 0;
+	}
+	printf("read comp: sector=%d buf=%x\n", sector, (u_int)disk_buf);
+
+	for (i = 0; i < (512 / 16); i++) {
+		for (j = 0; j < 16; j++)
+			printf("%02x ", disk_buf[i * 16 + j]);
+		printf("    ");
+		for (j = 0; j < 16; j++) {
+			ch = disk_buf[i * 16 + j];
+			if (isprint(ch))
+				putchar(ch);
+			else
+				putchar('.');
+
+		}
+		printf("\n");
+	}
+	printf("\n");
+	error = device_close(fdd);
+	if (error)
+		printf("close failed\n");
+
+	return 0;
+}
+
+int
+test_write(int sector)
+{
+	device_t fdd;
+	size_t size;
+	int error;
+	static unsigned char disk_buf[512];
+
+	printf("open fd0\n");
+	error = device_open("fd0", 0, &fdd);
+	if (error) {
+		printf("open failed\n");
+		return 0;
+	}
+	printf("opened\n");
+
+	size = 512;
+	error = device_read(fdd, disk_buf, &size, sector);
+	if (error) {
+		printf("read failed\n");
+		device_close(fdd);
+		return 0;
+	}
+	printf("read comp sector=%d\n", sector);
+
+	size = 512;
+	error = device_write(fdd, disk_buf, &size, sector);
+	if (error) {
+		printf("write failed\n");
+		device_close(fdd);
+		return 0;
+	}
+	printf("write comp sector=%d\n", sector);
+
+	error = device_close(fdd);
+	if (error)
+		printf("close failed\n");
+	return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+	test_read(0);
+	test_read(1);
+	test_read(2);
+
+	test_write(1);
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/fifo/Makefile b/prex-0.9.0/usr/test/fifo/Makefile
new file mode 100755
index 0000000..574812c
--- /dev/null
+++ b/prex-0.9.0/usr/test/fifo/Makefile
@@ -0,0 +1,3 @@
+PROG=	fifo
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/fifo/fifo.c b/prex-0.9.0/usr/test/fifo/fifo.c
new file mode 100755
index 0000000..5bd2dd1
--- /dev/null
+++ b/prex-0.9.0/usr/test/fifo/fifo.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fifo.c - test FIFO function
+ */
+
+#include <sys/prex.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/errno.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int
+main(int argc, char *argv[])
+{
+	int pid, fd1, fd2, len;
+	char buf1[256], buf2[256];
+
+	printf("FIFO test program\n");
+
+	if (mknod("/mnt/fifo/test", (mode_t)(S_IFIFO | 0666), 0) == -1) {
+		perror("mkfifo");
+		exit(1);
+	}
+	pid = vfork();
+	if (pid == -1) {
+		perror("fork");
+		exit(1);
+	}
+	if (pid == 0) {
+		/* child */
+		printf("child: task=%x\n", (int)task_self());
+
+		fd1 = open("/mnt/fifo/test", O_RDONLY);
+		if (fd1 == -1) {
+			perror("open");
+			exit(1);
+		}
+		for (;;) {
+			printf("child: reading data from FIFO\n");
+			len = read(fd1, buf1, sizeof(buf1) - 1);
+			if (len == 0)
+				break;
+			buf1[len] = '\0';
+			printf("child: length=%d data=%s\n", len, buf1);
+		}
+		close(fd1);
+		printf("child: exit\n");
+		exit(0);
+	}
+	printf("parent: task=%x\n", (int)task_self());
+
+	fd2 = open("/mnt/fifo/test", O_WRONLY);
+	if (fd2 == -1) {
+		perror("open");
+		exit(1);
+	}
+	for (;;) {
+		printf("parent: please input string...\n");
+		fgets(buf2, sizeof(buf2) - 1, stdin);
+		if (feof(stdin))
+			break;
+		printf("parent: writing to FIFO\n");
+		write(fd2, buf2, strlen(buf2));
+	}
+	close(fd2);
+	printf("parent: exit\n");
+	exit(0);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/fileio/Makefile b/prex-0.9.0/usr/test/fileio/Makefile
new file mode 100755
index 0000000..82f1fa2
--- /dev/null
+++ b/prex-0.9.0/usr/test/fileio/Makefile
@@ -0,0 +1,3 @@
+PROG=	fileio
+
+include $(SRCDIR)/mk/prog.mk
\ No newline at end of file
diff --git a/prex-0.9.0/usr/test/fileio/fileio.c b/prex-0.9.0/usr/test/fileio/fileio.c
new file mode 100755
index 0000000..d487d1c
--- /dev/null
+++ b/prex-0.9.0/usr/test/fileio/fileio.c
@@ -0,0 +1,182 @@
+/*-
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fileio.c - file I/O test program
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+
+#include <sys/syslog.h>
+#include <sys/mount.h>
+#include <sys/fcntl.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#define IOBUFSZ	512
+#define READ_TARGET	"/boot/LICENSE"
+#define WRITE_TARGET	"/tmp/test"
+
+static	char iobuf[IOBUFSZ];
+
+static void
+test_write(void)
+{
+	int fd, i;
+
+	if ((fd = open(WRITE_TARGET, O_CREAT|O_RDWR, 0)) < 0)
+		panic("can not open file " WRITE_TARGET);
+
+	for (i = 0; i < 50; i++) {
+		memset(iobuf, i, IOBUFSZ);
+		write(fd, iobuf, IOBUFSZ);
+	}
+	close(fd);
+}
+
+/*
+ * Display file contents
+ */
+static void
+cat_file(void)
+{
+	int rd, fd;
+
+	if ((fd = open(READ_TARGET, O_RDONLY, 0)) < 0)
+		panic("can not open file " READ_TARGET);
+
+	while ((rd = read(fd, iobuf, IOBUFSZ)) > 0)
+		write(STDOUT_FILENO, iobuf, (size_t)rd);
+	close(fd);
+}
+
+/*
+ * Test invalid request
+ */
+static void
+test_invalid(void)
+{
+	object_t fsobj;
+	struct msg m;
+
+	object_lookup("!fs", &fsobj);
+	m.hdr.code = 0x300;
+	msg_send(fsobj, &m, sizeof(m));
+}
+
+/*
+ * Test open/close
+ */
+static void
+test_open(void)
+{
+	int fd;
+
+	for (;;) {
+		if ((fd = open(READ_TARGET, O_RDONLY, 0)) < 0)
+			panic("can not open file " READ_TARGET);
+		close(fd);
+	}
+}
+
+/*
+ * Test file read
+ */
+static void
+test_read(void)
+{
+	int rd, fd;
+
+	if ((fd = open(READ_TARGET, O_RDONLY, 0)) < 0)
+		panic("can not open file " READ_TARGET);
+
+	for (;;)
+		while ((rd = read(fd, iobuf, IOBUFSZ)) > 0)
+			;
+
+	close(fd);
+}
+
+/*
+ * Main routine
+ */
+int
+main(int argc, char *argv[])
+{
+	char test_str[] = "test stdout...\n\n";
+
+	syslog(LOG_INFO, "\nfileio: fs test program\n");
+
+	/* Wait 1 sec until loading fs server */
+	timer_sleep(1000, 0);
+
+	/*
+	 * Prepare to use a file system.
+	 */
+	fslib_init();
+
+	/*
+	 * Mount file systems
+	 */
+	mount("", "/", "ramfs", 0, NULL);
+	mkdir("/dev", 0);
+	mount("", "/dev", "devfs", 0, NULL);		/* device */
+	mkdir("/boot", 0);
+	mount("/dev/ram0", "/boot", "arfs", 0, NULL);	/* archive */
+	mkdir("/tmp", 0);
+	/*
+	 * Prepare stdio
+	 */
+	open("/dev/tty", O_RDWR);	/* stdin */
+	dup(0);				/* stdout */
+	dup(0);				/* stderr */
+
+	/* Test device write */
+	write(STDOUT_FILENO, test_str, strlen(test_str));
+
+	test_write();
+
+	cat_file();		/* test read/write */
+
+	test_invalid();		/* test invalid request */
+
+	test_read();		/* test read loop */
+
+	test_open();		/* test open/close loop */
+
+	/*
+	 * Disconnect from a file system.
+	 */
+	fslib_exit();
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/fork/Makefile b/prex-0.9.0/usr/test/fork/Makefile
new file mode 100755
index 0000000..2b1cd82
--- /dev/null
+++ b/prex-0.9.0/usr/test/fork/Makefile
@@ -0,0 +1,4 @@
+PROG=	fork
+#DISASM=	fork.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/fork/fork.c b/prex-0.9.0/usr/test/fork/fork.c
new file mode 100755
index 0000000..d2ab817
--- /dev/null
+++ b/prex-0.9.0/usr/test/fork/fork.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * fork.c - fork test program.
+ */
+
+#include <sys/prex.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+	pid_t pid;
+	int sts;
+
+	printf("Test fork\n");
+
+	for (;;) {
+		sys_log("fork\n");
+		pid = vfork();
+		if (pid == 0) {
+			sys_log("child\n");
+			exit(0);
+		} else {
+			sys_log("parent\n");
+			while (wait(&sts) != pid)
+				;
+		}
+	}
+	printf("Done.\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/forkbomb/Makefile b/prex-0.9.0/usr/test/forkbomb/Makefile
new file mode 100755
index 0000000..a5a5a04
--- /dev/null
+++ b/prex-0.9.0/usr/test/forkbomb/Makefile
@@ -0,0 +1,4 @@
+PROG=	forkbomb
+#DISASM=	forkbomb.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/forkbomb/forkbomb.c b/prex-0.9.0/usr/test/forkbomb/forkbomb.c
new file mode 100755
index 0000000..c2ab979
--- /dev/null
+++ b/prex-0.9.0/usr/test/forkbomb/forkbomb.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * forkbomb.c - denial-of-service attack with fork.
+ */
+
+#include <unistd.h>
+
+int
+main(int argc, char *argv[])
+{
+
+	for (;;)
+		vfork();
+}
diff --git a/prex-0.9.0/usr/test/ipc/Makefile b/prex-0.9.0/usr/test/ipc/Makefile
new file mode 100755
index 0000000..12926ec
--- /dev/null
+++ b/prex-0.9.0/usr/test/ipc/Makefile
@@ -0,0 +1,3 @@
+TASK	= ipc.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/ipc/ipc.c b/prex-0.9.0/usr/test/ipc/ipc.c
new file mode 100755
index 0000000..5f62f08
--- /dev/null
+++ b/prex-0.9.0/usr/test/ipc/ipc.c
@@ -0,0 +1,174 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ipc.c - IPC test program.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+#include <stdio.h>
+
+static char stack[1024];
+
+/*
+ * Run specified thread
+ */
+static int
+thread_run(void (*start)(void), void *stack)
+{
+	thread_t t;
+	int error;
+
+	error = thread_create(task_self(), &t);
+	if (error)
+		return error;
+
+	error = thread_load(t, start, stack);
+	if (error)
+		return error;
+
+	error = thread_resume(t);
+	if (error)
+		return error;
+
+	return 0;
+}
+
+/*
+ * Send thread
+ */
+static void
+send_thread(void)
+{
+	struct msg msg;
+	object_t o1, o2;
+	int error;
+
+	printf("Send thread is starting...\n");
+
+	/*
+	 * Find objects.
+	 */
+	error = object_lookup("test-A", &o1);
+	error = object_lookup("test-B", &o2);
+
+	/*
+	 * Wait a sec.
+	 */
+	timer_sleep(1000, 0);
+
+	/*
+	 * Delete object A.
+	 */
+	printf("Delete object A\n");
+	object_destroy(o1);
+
+	/*
+	 * Wait a sec.
+	 */
+	timer_sleep(1000, 0);
+
+	/*
+	 * Send message to object B.
+	 */
+	printf("Send message to object B.\n");
+	msg_send(o2, &msg, sizeof(msg));
+
+	printf("Send completed.\n");
+	for (;;) ;
+}
+
+int
+main(int argc, char *argv[])
+{
+	object_t o1, o2, o3;
+	struct msg msg;
+	int error;
+
+	printf("IPC test program\n");
+
+	/*
+	 * Create two objects.
+	 */
+	error = object_create("test-A", &o1);
+	error = object_create("test-B", &o2);
+
+	/*
+	 * Create existing object.
+	 * This must be error.
+	 */
+	error = object_create("test-B", &o3);
+	if (error == 0)
+		panic("Oops! object exist...");
+
+	/*
+	 * Start sender thread.
+	 */
+	error = thread_run(send_thread, stack + 1024);
+	if (error)
+		panic("failed to run thread");
+
+	/*
+	 * Wait message from non-existing object
+	 * This must be error.
+	 */
+	o3 = 0x12345678;
+	error = msg_receive(o3, &msg, sizeof(msg));
+	if (error == 0)
+		panic("Oops! invalid object...");
+
+	/*
+	 * Wait message from object 'A'. However, it will be failed
+	 * because the sender thread will delete the object A.
+	 */
+	printf("Wait message from object A\n");
+	error = msg_receive(o1, &msg, sizeof(msg));
+	if (error)
+		printf("Receive error!\n");
+	else {
+		printf("Rreceive ok!\n");
+		msg_reply(o1, &msg, sizeof(msg));
+	}
+
+	/*
+	 * Wait message from object 'B'.
+	 */
+	printf("Wait message from object B\n");
+	error = msg_receive(o2, &msg, sizeof(msg));
+	if (error)
+		printf("Receive error!\n");
+	else {
+		printf("Receive ok!\n");
+		msg_reply(o2, &msg, sizeof(msg));
+	}
+
+	printf("Test completed...\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/ipc_mt/Makefile b/prex-0.9.0/usr/test/ipc_mt/Makefile
new file mode 100755
index 0000000..c95b878
--- /dev/null
+++ b/prex-0.9.0/usr/test/ipc_mt/Makefile
@@ -0,0 +1,3 @@
+TASK=	ipc_mt.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/ipc_mt/ipc_mt.c b/prex-0.9.0/usr/test/ipc_mt/ipc_mt.c
new file mode 100755
index 0000000..efeb87b
--- /dev/null
+++ b/prex-0.9.0/usr/test/ipc_mt/ipc_mt.c
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ipc_mt.c - IPC test for multi threaded servers.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+#include <stdio.h>
+
+#define NR_THREADS	5
+
+static char stack[NR_THREADS][1024];
+
+/*
+ * Run specified thread
+ */
+static int
+thread_run(void (*start)(void), void *stack)
+{
+	thread_t t;
+	int error;
+
+	error = thread_create(task_self(), &t);
+	if (error)
+		return error;
+
+	error = thread_load(t, start, stack);
+	if (error)
+		return error;
+
+	error = thread_resume(t);
+	if (error)
+		return error;
+
+
+	return 0;
+}
+
+/*
+ * Receiver thread
+ */
+static void
+receive_thread(void)
+{
+	struct msg msg;
+	object_t obj;
+	int error;
+
+	printf("Receiver thread is starting...\n");
+
+	thread_setpri(thread_self(), 240);
+
+	/*
+	 * Find objects.
+	 */
+	error = object_lookup("test-A", &obj);
+
+	for (;;) {
+		/*
+		 * Receive message from object.
+		 */
+		printf("Wait message.\n");
+		msg_receive(obj, &msg, sizeof(msg));
+
+		printf("Message received.\n");
+		/*
+		 * Wait a sec.
+		 */
+		timer_sleep(1000, 0);
+
+		printf("Reply message.\n");
+		msg_reply(obj, &msg, sizeof(msg));
+
+		for (;;);
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	object_t obj;
+	int error, i;
+
+	printf("IPC test for multi threads\n");
+
+	/*
+	 * Create an object.
+	 */
+	error = object_create("test-A", &obj);
+	if (error)
+		panic("failed to create object");
+
+	/*
+	 * Start receiver thread.
+	 */
+	for (i = 0; i < NR_THREADS; i++) {
+		error = thread_run(receive_thread, stack[i] + 1024);
+		if (error)
+			panic("failed to run thread");
+	}
+	printf("ok?\n");
+	thread_setpri(thread_self(), 241);
+	for (;;)
+		thread_yield();
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/kbd/Makefile b/prex-0.9.0/usr/test/kbd/Makefile
new file mode 100755
index 0000000..78eb71a
--- /dev/null
+++ b/prex-0.9.0/usr/test/kbd/Makefile
@@ -0,0 +1,3 @@
+TASK=	kbd.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/kbd/kbd.c b/prex-0.9.0/usr/test/kbd/kbd.c
new file mode 100755
index 0000000..0aafbe0
--- /dev/null
+++ b/prex-0.9.0/usr/test/kbd/kbd.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * kbd.c - test keyboard function
+ */
+
+#include <sys/prex.h>
+
+int
+main(int argc, char *argv[])
+{
+	device_t tty_dev;
+	int i, error;
+	char buf[] = "?\n";
+	size_t len;
+
+ 	sys_log("Keyboard test program\n");
+	error = device_open("tty", 0, &tty_dev);
+	if (error)
+		sys_log("device open error!\n");
+
+ 	sys_log("Press any key 10 times\n");
+	for (i = 0; i < 10; i++) {
+		len = 1;
+		device_read(tty_dev, buf, &len, 0);
+		sys_log(buf);
+	}
+
+	error = device_close(tty_dev);
+	if (error)
+		sys_log("device close error!\n");
+
+	sys_log("Test completed.\n");
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/kmon/Makefile b/prex-0.9.0/usr/test/kmon/Makefile
new file mode 100755
index 0000000..c1aee67
--- /dev/null
+++ b/prex-0.9.0/usr/test/kmon/Makefile
@@ -0,0 +1,6 @@
+TASK=	 	kmon.rt
+SRCS=		kmon.c cmd.c
+
+#DISASM= 	kmon.lst
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/kmon/cmd.c b/prex-0.9.0/usr/test/kmon/cmd.c
new file mode 100755
index 0000000..f763719
--- /dev/null
+++ b/prex-0.9.0/usr/test/kmon/cmd.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * cmd.c - command processor
+ */
+
+#include <sys/prex.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+
+static void cmd_help(int argc, char **argv);
+static void cmd_ver(int argc, char **argv);
+static void cmd_mem(int argc, char **argv);
+static void cmd_clear(int argc, char **argv);
+static void cmd_kill(int argc, char **argv);
+static void cmd_reboot(int argc, char **argv);
+static void cmd_shutdown(int argc, char **argv);
+
+struct cmd_entry {
+	const char *cmd;
+	void	   (*func)(int, char **);
+	const char *usage;
+};
+
+static const struct cmd_entry cmd_table[] = {
+	{ "ver"	 	,cmd_ver	,"Version information" },
+	{ "mem"	 	,cmd_mem	,"Show memory usage" },
+	{ "clear"	,cmd_clear	,"Clear screen" },
+	{ "kill"	,cmd_kill	,"Terminate thread" },
+	{ "reboot"	,cmd_reboot	,"Reboot system" },
+	{ "shutdown"	,cmd_shutdown	,"Shutdown system" },
+	{ "help"	,cmd_help	,"This help" },
+	{ NULL		,NULL		,NULL },
+};
+
+static void
+cmd_help(int argc, char **argv)
+{
+	int i = 0;
+
+	while (cmd_table[i].cmd != NULL) {
+		printf("%s - %s\n", cmd_table[i].cmd, cmd_table[i].usage);
+		i++;
+	}
+}
+
+static void
+cmd_ver(int argc, char **argv)
+{
+	struct kerninfo info;
+
+	sys_info(INFO_KERNEL, &info);
+
+	printf("Kernel version:\n");
+	printf("%s version %s for %s\n",
+	       info.sysname, info.version, info.machine);
+}
+
+static void
+cmd_mem(int argc, char **argv)
+{
+	struct meminfo info;
+
+	sys_info(INFO_MEMORY, &info);
+
+	printf("Memory usage:\n");
+	printf(" Used     : %8d KB\n",
+	       (u_int)((info.total - info.free) / 1024));
+	printf(" Free     : %8d KB\n", (u_int)(info.free / 1024));
+	printf(" Total    : %8d KB\n", (u_int)(info.total / 1024));
+	printf(" Bootdisk : %8d KB\n", (u_int)(info.bootdisk / 1024));
+}
+
+static void
+cmd_clear(int argc, char **argv)
+{
+
+	printf("\33[2J");
+}
+
+static void
+cmd_kill(int argc, char **argv)
+{
+	thread_t t;
+	char *ep;
+
+	if (argc < 2) {
+		puts("Usage: kill thread");
+		return;
+	}
+	t = (thread_t)strtoul(argv[1], &ep, 16);
+	printf("Kill thread id:%x\n", (u_int)t);
+
+	if (thread_terminate(t))
+		printf("Thread %x does not exist\n", (u_int)t);
+}
+
+static void
+cmd_reboot(int argc, char **argv)
+{
+	device_t pm_dev;
+	int error, state = PWR_REBOOT;
+
+	if ((error = device_open("pm", 0, &pm_dev)) == 0) {
+		error = device_ioctl(pm_dev, PMIOC_SET_POWER, &state);
+		device_close(pm_dev);
+	}
+	if (error)
+		printf("Error %d\n", error);
+}
+
+static void
+cmd_shutdown(int argc, char **argv)
+{
+	device_t pm_dev;
+	int error, state = PWR_OFF;
+
+	if ((error = device_open("pm", 0, &pm_dev)) == 0) {
+		error = device_ioctl(pm_dev, PMIOC_SET_POWER, &state);
+		device_close(pm_dev);
+	}
+	if (error)
+		printf("Error %d\n", error);
+}
+
+int
+dispatch_cmd(int argc, char **argv)
+{
+	int i = 0;
+
+	while (cmd_table[i].cmd != NULL) {
+		if (!strcmp(argv[0], cmd_table[i].cmd)) {
+			(cmd_table[i].func)(argc, argv);
+			break;
+		}
+		i++;
+	}
+	if (cmd_table[i].cmd == NULL)
+		printf("%s: command not found\n", argv[0]);
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/kmon/kmon.c b/prex-0.9.0/usr/test/kmon/kmon.c
new file mode 100755
index 0000000..ac04114
--- /dev/null
+++ b/prex-0.9.0/usr/test/kmon/kmon.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * kmon.c - main routine for kernel monitor
+ */
+
+#include <sys/prex.h>
+#include <sys/keycode.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <limits.h>
+
+#define ARGMAX		32
+
+extern int dispatch_cmd(int argc, char **args);
+
+/*
+ * Parse an entire given line.
+ */
+static int
+parse_line(char *line)
+{
+	static char *args[ARGMAX];
+	char *p, *word = NULL;
+	int argc = 0;
+	int rc = 0;
+
+	if (line[0] != ' ' && line[0] != '\t')
+		word = line;
+
+	p = line;
+	while (*p) {
+		if (word == NULL) {
+			/* Skip white space. */
+			if (*p != ' ' && *p != '\t')
+				word = p;
+		} else {
+			if (*p == ' ' || *p == '\t') {
+				*p = '\0';
+				args[argc++] = word;
+				word = NULL;
+				if (argc >= ARGMAX - 1) {
+					printf("Too many args\n");
+					return 0;
+				}
+			}
+		}
+		p++;
+	}
+	if (word)
+		args[argc++] = word;
+	args[argc] = NULL;
+
+	if (argc) {
+		if (dispatch_cmd(argc, args))
+			rc = 1;
+	}
+	return rc;
+}
+
+static void
+read_line(char *line)
+{
+	int c, len = 0;
+	char *p = line;
+
+	for (;;) {
+		c = getchar();
+		if (c == '\n' || len > LINE_MAX) {
+			*p = '\0';
+			return;
+		}
+		*p = (char)c;
+		p++;
+		len++;
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	static char line[LINE_MAX];
+
+	printf("Prex kernel monitor - type 'help' to list commands\n");
+
+	for (;;) {
+		printf("[kmon]$ ");
+		read_line(line);
+		if (parse_line(line))
+			break;
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/malloc/Makefile b/prex-0.9.0/usr/test/malloc/Makefile
new file mode 100755
index 0000000..4c7714a
--- /dev/null
+++ b/prex-0.9.0/usr/test/malloc/Makefile
@@ -0,0 +1,3 @@
+TASK=	malloc.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/malloc/malloc.c b/prex-0.9.0/usr/test/malloc/malloc.c
new file mode 100755
index 0000000..7bb508f
--- /dev/null
+++ b/prex-0.9.0/usr/test/malloc/malloc.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * malloc.c - malloc test program.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define NR_ALLOCS	30
+
+static void *ptr[NR_ALLOCS];
+
+static char *
+alloc(int buflen)
+{
+	char *p, *q;
+	int i;
+
+	printf("Allocate %d bytes - ", buflen);
+
+	p = malloc((size_t)buflen);
+	if (p == NULL) {
+		printf("Error: malloc() returns NULL!\n");
+		return NULL;
+	}
+	for (q = p, i = 0; i < buflen; i++)
+		*(q++) = '@';
+#if 0
+	for (q = p, i = 0; i < buflen; i++)
+		putchar(*(q++));
+#endif
+	printf("OK!\n");
+	return p;
+}
+
+static void
+test_1(void)
+{
+	char *p;
+
+	printf("test_1 - start\n");
+
+	p = alloc(1);
+	free(p);
+	p = alloc(2);
+	free(p);
+	p = alloc(256);
+	free(p);
+	p = alloc(1024);
+	free(p);
+	p = alloc(8096);
+	free(p);
+	p = alloc(-1);
+	free(p);
+
+	printf("test_1 - done\n");
+}
+
+static void
+test_2(void)
+{
+	int i, j;
+
+	printf("test_2 - start\n");
+
+	for (i = 0; i < NR_ALLOCS; i++)
+		ptr[i] = alloc(random() & 0xf);
+	for (i = 0; i < NR_ALLOCS; i++)
+		free(ptr[i]);
+
+	for (i = 0; i < NR_ALLOCS; i++)
+		ptr[i] = alloc(random() & 0xff);
+	for (i = 0; i < NR_ALLOCS; i++)
+		free(ptr[i]);
+
+	for (i = 0; i < NR_ALLOCS; i++)
+		ptr[i] = alloc(random() & 0xfff);
+	for (i = 0; i < NR_ALLOCS; i++)
+		free(ptr[i]);
+
+	for (i = 0; i < NR_ALLOCS; i++)
+		ptr[i] = alloc(random() & 0xfff);
+	for (i = 0; i < 10000; i++) {
+		j = random() % NR_ALLOCS;
+		if (ptr[j] != NULL) {
+			free(ptr[j]);
+			ptr[j] = NULL;
+		}
+	}
+	printf("test_2 - done\n");
+}
+
+static void
+test_3(void)
+{
+	char *p;
+
+	printf("test_3 - start\n");
+
+	p = alloc(256);
+	free(p);
+
+	printf("test_3 - try to free invalid area...\n");
+	free(p); /* invalid */
+
+	printf("test_3 - done!?\n");
+}
+
+int
+main(int argc, char *argv[])
+{
+	printf("Malloc test program.\n");
+
+	test_1();
+	test_2();
+	test_3();
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/memleak/Makefile b/prex-0.9.0/usr/test/memleak/Makefile
new file mode 100755
index 0000000..d45ad0f
--- /dev/null
+++ b/prex-0.9.0/usr/test/memleak/Makefile
@@ -0,0 +1,4 @@
+PROG=	memleak
+#DISASM= memleak.lst
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/memleak/memleak.c b/prex-0.9.0/usr/test/memleak/memleak.c
new file mode 100755
index 0000000..7fa0e72
--- /dev/null
+++ b/prex-0.9.0/usr/test/memleak/memleak.c
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * memleak.c - test for memory leak.
+ */
+
+#include <sys/prex.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(int argc, char *argv[])
+{
+	char *p;
+	int i, error;
+	size_t size;
+	object_t obj;
+	char str[5];
+
+	printf("memory leak test\n");
+
+	size = 1;
+	for (i = 0; i < 20; i++) {
+		printf("memleak: malloc %d bytes\n", size);
+		p = malloc(size);
+		if (!p) {
+			printf("memleak: malloc failed\n");
+			break;
+		}
+		size *= 2;
+	}
+
+	str[0] = '1';
+	str[1] = 0;
+	for (i = 0; i < 100; i++) {
+		printf("memleak: object create name=%s\n", str);
+		error = object_create(str, &obj);
+		if (error) {
+			printf("memleak: object create failed\n");
+			break;
+		}
+		str[0] += 1;
+	}
+
+
+	return (0);
+}
diff --git a/prex-0.9.0/usr/test/mount/Makefile b/prex-0.9.0/usr/test/mount/Makefile
new file mode 100755
index 0000000..e3a71dc
--- /dev/null
+++ b/prex-0.9.0/usr/test/mount/Makefile
@@ -0,0 +1,3 @@
+PROG=	mount
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/mount/mount.c b/prex-0.9.0/usr/test/mount/mount.c
new file mode 100755
index 0000000..df4f591
--- /dev/null
+++ b/prex-0.9.0/usr/test/mount/mount.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mount.c - test mount function.
+ *
+ * NOTE: This program requires CAP_DISKADMIN capability.
+ */
+
+#include <sys/mount.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+main(int argc, char *argv[])
+{
+
+	if (argc != 5) {
+		fprintf(stderr, "usage: mount -t vfstype device dir\n");
+		exit(1);
+	}
+	if (mount(argv[3], argv[4], argv[2], 0, NULL) < 0) {
+		perror("mount");
+		exit(1);
+	}
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/test/mutex/Makefile b/prex-0.9.0/usr/test/mutex/Makefile
new file mode 100755
index 0000000..40e75a6
--- /dev/null
+++ b/prex-0.9.0/usr/test/mutex/Makefile
@@ -0,0 +1,3 @@
+TASK=	mutex.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/mutex/mutex.c b/prex-0.9.0/usr/test/mutex/mutex.c
new file mode 100755
index 0000000..aa79244
--- /dev/null
+++ b/prex-0.9.0/usr/test/mutex/mutex.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * mutex.c - test priority inheritance of mutex.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+static mutex_t mtx_A = MUTEX_INITIALIZER;
+static mutex_t mtx_B, mtx_C;
+
+int
+main(int argc, char *argv[])
+{
+	int error;
+
+	printf("Mutex test program\n");
+
+	/*
+	 * Initialize only B
+	 */
+	mutex_init(&mtx_B);
+
+	/*
+	 * Lock test
+	 */
+	error = mutex_lock(&mtx_A);
+	printf("1) Lock mutex A: error=%d\n", error);
+
+	error = mutex_lock(&mtx_B);
+	printf("2) Lock mutex B: error=%d\n", error);
+
+	/* Error: Mutex C is not initialized. */
+	error = mutex_lock(&mtx_C);
+	printf("3e) Lock mutex C: error=%d\n", error);
+
+	/*
+	 * Unlock test
+	 */
+	error = mutex_unlock(&mtx_A);
+	printf("4) Unlock mutex A: error=%d\n", error);
+
+	error = mutex_unlock(&mtx_B);
+	printf("5) Unlock mutex B: error=%d\n", error);
+
+	/* Error: Mutex C is not initialized. */
+	error = mutex_unlock(&mtx_C);
+	printf("6e) Unlock mutex B: error=%d\n", error);
+
+	/* Error: B is not locked. */
+	error = mutex_unlock(&mtx_B);
+	printf("7e) Unlock mutex B: error=%d\n", error);
+
+	/*
+	 * Destoroy mutex.
+	 */
+	mutex_destroy(&mtx_B);
+
+	/* Error: Mutex B is destoroyed. */
+	error = mutex_lock(&mtx_B);
+	printf("8e) Lock mutex B: error=%d\n", error);
+
+	/*
+	 * Double lock test
+	 */
+	error = mutex_lock(&mtx_A);
+	printf("9) Lock mutex A: error=%d\n", error);
+
+	/* Erorr: Mutex A is already locked */
+	error = mutex_lock(&mtx_A);
+	printf("10e) Lock mutex A: error=%d\n", error);
+
+	error = mutex_unlock(&mtx_A);
+	printf("11) Unlock mutex A: error=%d\n", error);
+
+	printf("Test completed...\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/object/Makefile b/prex-0.9.0/usr/test/object/Makefile
new file mode 100755
index 0000000..6a386d2
--- /dev/null
+++ b/prex-0.9.0/usr/test/object/Makefile
@@ -0,0 +1,3 @@
+PROG	= object
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/object/object.c b/prex-0.9.0/usr/test/object/object.c
new file mode 100755
index 0000000..1db9308
--- /dev/null
+++ b/prex-0.9.0/usr/test/object/object.c
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * object.c - test for object security.
+ */
+
+#include <sys/prex.h>
+#include <ipc/ipc.h>
+
+#include <stdio.h>
+
+
+int
+main(int argc, char *argv[])
+{
+	object_t obj;
+	int error;
+
+	printf("test for object security\n");
+
+	/*
+	 * Try to make normal object.
+	 */
+	error = object_create("test", &obj);
+	if (error)
+		panic("Failed to create an object.\n");
+
+	error = object_destroy(obj);
+	if (error)
+		panic("Failed to destroy an object.\n");
+
+	/*
+	 * We can not use an object name that started with '!'.
+	 */
+	error = object_create("!test", &obj);
+	if (error == 0)
+		panic("Oops! We could create protected object!");
+
+	/*
+	 * Find process object and destroy it!
+	 */
+	error = object_lookup("!proc", &obj);
+	if (error)
+		panic("Could not find a process object!");
+
+	error = object_destroy(obj);
+	if (error == 0)
+		panic("Oops! We could destroy a process object!");
+
+	printf("test ok\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/pipe/Makefile b/prex-0.9.0/usr/test/pipe/Makefile
new file mode 100755
index 0000000..d556763
--- /dev/null
+++ b/prex-0.9.0/usr/test/pipe/Makefile
@@ -0,0 +1,3 @@
+PROG=	pipe
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/pipe/pipe.c b/prex-0.9.0/usr/test/pipe/pipe.c
new file mode 100755
index 0000000..063cc9d
--- /dev/null
+++ b/prex-0.9.0/usr/test/pipe/pipe.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * pipe.c - test unix pipe
+ */
+
+#include <sys/prex.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/errno.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+static void
+test1(void)
+{
+	int fd[2];
+	char str[] = "test1";
+	char buf[256];
+
+	printf("pipe test program\n");
+
+	if (pipe(fd) == -1) {
+		perror("pipe");
+		exit(1);
+	}
+	write(fd[1], str, sizeof(str));
+	read(fd[0], buf, sizeof(buf));
+	printf("str=%s\n", buf);
+}
+
+static void
+test2(void)
+{
+	int fd[2];
+	char str[] = "test2: hello!";
+	char buf[256];
+
+	printf("pipe test program\n");
+
+	if (pipe(fd) == -1) {
+		perror("pipe");
+		exit(1);
+	}
+	switch(vfork()) {
+	case -1:
+		perror("fork");
+		break;
+
+	case 0: /* child */
+		close(fd[1]);
+		read(fd[0], buf, 256);
+		close(fd[0]);
+		printf("str=%s\n", buf);
+		exit(0);
+		break;
+
+	default: /* parent */
+		close(fd[0]);
+		write(fd[1], str, sizeof(str));
+		close(fd[1]);
+		exit(0);
+		break;
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	test1();
+	test2();
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/ramdisk/Makefile b/prex-0.9.0/usr/test/ramdisk/Makefile
new file mode 100755
index 0000000..bda5c0d
--- /dev/null
+++ b/prex-0.9.0/usr/test/ramdisk/Makefile
@@ -0,0 +1,3 @@
+TASK=	ramdisk.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/ramdisk/ramdisk.c b/prex-0.9.0/usr/test/ramdisk/ramdisk.c
new file mode 100755
index 0000000..49f1060
--- /dev/null
+++ b/prex-0.9.0/usr/test/ramdisk/ramdisk.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * ramdisk.c - ramdisk driver test program.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+static char test_msg[] = "Hello. This is a test message.";
+
+int
+test_read(int sector)
+{
+	device_t ramdev;
+	size_t size;
+	int error, i, j;
+	static unsigned char disk_buf[512];
+	unsigned char ch;
+
+	printf("open ram0\n");
+	error = device_open("ram0", 0, &ramdev);
+	if (error) {
+		printf("open failed\n");
+		return 0;
+	}
+	printf("opened\n");
+
+	printf("ramdisk read: sector=%d buf=%x\n", sector, (u_int)disk_buf);
+	size = 512;
+	error = device_read(ramdev, disk_buf, &size, sector);
+	if (error) {
+		printf("read failed\n");
+		device_close(ramdev);
+		return 0;
+	}
+	printf("read comp: sector=%d buf=%x\n", sector, (u_int)disk_buf);
+
+	for (i = 0; i < (512 / 16); i++) {
+		for (j = 0; j < 16; j++)
+			printf("%02x ", disk_buf[i * 16 + j]);
+		printf("    ");
+		for (j = 0; j < 16; j++) {
+			ch = disk_buf[i * 16 + j];
+			if (isprint(ch))
+				putchar(ch);
+			else
+				putchar('.');
+
+		}
+		printf("\n");
+	}
+	printf("\n");
+	error = device_close(ramdev);
+	if (error)
+		printf("close failed\n");
+
+	return 0;
+}
+
+int
+test_write(int sector)
+{
+	device_t ramdev;
+	size_t size;
+	int error;
+	static unsigned char disk_buf[512];
+
+	printf("open ram0\n");
+	error = device_open("ram0", 0, &ramdev);
+	if (error) {
+		printf("open failed\n");
+		return 0;
+	}
+	printf("opened\n");
+
+	size = 512;
+	error = device_read(ramdev, disk_buf, &size, sector);
+	if (error) {
+		printf("read failed\n");
+		device_close(ramdev);
+		return 0;
+	}
+	printf("read comp sector=%d\n", sector);
+
+	strcpy((char *)disk_buf, test_msg);
+
+	size = 512;
+	error = device_write(ramdev, disk_buf, &size, sector);
+	if (error) {
+		printf("write failed\n");
+		device_close(ramdev);
+		return 0;
+	}
+	printf("write comp sector=%d\n", sector);
+
+	error = device_close(ramdev);
+	if (error)
+		printf("close failed\n");
+	return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+	test_read(0);
+	test_read(1);
+	test_write(1);
+	test_read(1);
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/reset/Makefile b/prex-0.9.0/usr/test/reset/Makefile
new file mode 100755
index 0000000..2a62737
--- /dev/null
+++ b/prex-0.9.0/usr/test/reset/Makefile
@@ -0,0 +1,3 @@
+TASK=	reset.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/reset/reset.c b/prex-0.9.0/usr/test/reset/reset.c
new file mode 100755
index 0000000..1642c7c
--- /dev/null
+++ b/prex-0.9.0/usr/test/reset/reset.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * reset.c - reset test
+ */
+
+#include <sys/prex.h>
+#include <sys/ioctl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+	device_t pm_dev;
+	int state = PWR_REBOOT;
+
+	printf("Reset test program. Wait 5 sec...\n");
+	timer_sleep(5000, 0);
+
+	printf("Reset!\n");
+	if (device_open("pm", 0, &pm_dev) != 0)
+		exit(1);
+	device_ioctl(pm_dev, PMIOC_SET_POWER, &state);
+	device_close(pm_dev);
+	exit(1);
+}
diff --git a/prex-0.9.0/usr/test/script/hello.sh b/prex-0.9.0/usr/test/script/hello.sh
new file mode 100755
index 0000000..d242139
--- /dev/null
+++ b/prex-0.9.0/usr/test/script/hello.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+echo Hello, world!
diff --git a/prex-0.9.0/usr/test/sem/Makefile b/prex-0.9.0/usr/test/sem/Makefile
new file mode 100755
index 0000000..386064c
--- /dev/null
+++ b/prex-0.9.0/usr/test/sem/Makefile
@@ -0,0 +1,3 @@
+TASK=	sem.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/sem/sem.c b/prex-0.9.0/usr/test/sem/sem.c
new file mode 100755
index 0000000..af3ae9a
--- /dev/null
+++ b/prex-0.9.0/usr/test/sem/sem.c
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * sem.c - test program for semaphore.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+	sem_t sem;
+	int error;
+	u_int val;
+
+	printf("Semaphore test program\n");
+
+	/*
+	 * Test initialize
+	 */
+	sem_init(&sem, 3);
+
+	/*
+	 * Test wait
+	 */
+	error = sem_getvalue(&sem, &val);
+	printf("Semaphore value=%d\n", val);
+
+	printf("1) Wait semahore\n");
+	error = sem_wait(&sem, 0);
+	if (error)
+		panic("wait error");
+
+	error = sem_getvalue(&sem, &val);
+	printf("Semaphore value=%d\n", val);
+
+	printf("2) Wait semahore\n");
+	error = sem_wait(&sem, 0);
+	if (error)
+		panic("wait error");
+
+	error = sem_getvalue(&sem, &val);
+	printf("Semaphore value=%d\n", val);
+
+	printf("3) Wait semahore\n");
+	error = sem_wait(&sem, 0);
+	if (error)
+		panic("wait error");
+
+	error = sem_getvalue(&sem, &val);
+	printf("Semaphore value=%d\n", val);
+
+#if 0
+	/*
+	 * Sleep by wait
+	 */
+	printf("4) Wait semahore\n");
+	error = sem_wait(&sem, 0);
+	if (error)
+		panic("wait error");
+#endif
+	/*
+	 * trywait must be error.
+	 */
+	printf("4e) Try to wait semahore\n");
+	error = sem_trywait(&sem);
+	printf("Try wait error=%d\n", error);
+
+	/*
+	 * Test post
+	 */
+	printf("5) Post semahore\n");
+	error = sem_post(&sem);
+	if (error)
+		panic("post error");
+	error = sem_getvalue(&sem, &val);
+	printf("Semaphore value=%d\n", val);
+
+	printf("Test complete\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/shutdown/Makefile b/prex-0.9.0/usr/test/shutdown/Makefile
new file mode 100755
index 0000000..90b202b
--- /dev/null
+++ b/prex-0.9.0/usr/test/shutdown/Makefile
@@ -0,0 +1,7 @@
+PROG=	shutdown
+
+#DISASM= 	shutdown.lst
+#MAP=		shutdown.map
+#SYMBOL= 	shutdown.sym
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/shutdown/shutdown.c b/prex-0.9.0/usr/test/shutdown/shutdown.c
new file mode 100755
index 0000000..b3bb1e6
--- /dev/null
+++ b/prex-0.9.0/usr/test/shutdown/shutdown.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2006-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * shutdown.c - test shutdown function.
+ *
+ * NOTE: This program requires CAP_PWRMGMT capability.
+ */
+
+#include <sys/prex.h>
+#include <sys/ioctl.h>
+#include <ipc/pow.h>
+#include <ipc/ipc.h>
+
+#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <signal.h>
+
+static void usage(void);
+static void shutdown(int);
+
+int
+main(int argc, char *argv[])
+{
+	int ch, checkch, rflag;
+
+	rflag = 0;
+	if (argc > 1) {
+		if (!strcmp(argv[1], "-r"))
+			rflag = 1;	/* reboot */
+		else {
+			usage();
+			exit(1);
+		}
+	}
+	/*
+	 * User confirmation is required for security.
+	 */
+	printf("Do you want to shutdown the system now? (y/n) ");
+	checkch = ch = getchar();
+	while (ch != '\n' && ch != EOF)
+		ch = getchar();
+	if (checkch != 'y')
+		exit(0);
+
+	shutdown(rflag);
+
+	fprintf(stderr, "Shutdown failed!\n");
+	exit(1);
+}
+
+static void
+usage(void)
+{
+
+	fprintf(stderr, "usage: shutdown [-r]\n");
+	exit(1);
+	/* NOTREACHED */
+}
+
+static void
+shutdown(int reboot)
+{
+	object_t powobj;
+	struct msg m;
+	int error;
+
+	if ((error = object_lookup("!pow", &powobj)) != 0)
+		return;
+
+	m.hdr.code = POW_SET_POWER;
+	m.data[0] = reboot ? PWR_REBOOT : PWR_OFF;
+	error = msg_send(powobj, &m, sizeof(m));
+}
diff --git a/prex-0.9.0/usr/test/signal/Makefile b/prex-0.9.0/usr/test/signal/Makefile
new file mode 100755
index 0000000..83dd8ed
--- /dev/null
+++ b/prex-0.9.0/usr/test/signal/Makefile
@@ -0,0 +1,3 @@
+PROG=	signal
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/signal/signal.c b/prex-0.9.0/usr/test/signal/signal.c
new file mode 100755
index 0000000..659ddec
--- /dev/null
+++ b/prex-0.9.0/usr/test/signal/signal.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * signal.c - test signal.
+ */
+
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void gotsig(int sig);
+
+int
+main(int argc, char *argv[])
+{
+	int ttyfd;
+	pid_t pgrp;
+
+	printf("signal test program\n");
+
+	if ((ttyfd = open("/dev/tty", O_RDWR)) == -1) {
+		printf("failed to open tty\n");
+		exit(1);
+	}
+	pgrp = getpgrp();
+	printf("tcsetpgrp=%x\n", pgrp);
+	tcsetpgrp(ttyfd, pgrp);
+	signal(SIGHUP, gotsig);
+	signal(SIGINT, gotsig);
+	signal(SIGQUIT, gotsig);
+	signal(SIGTERM, gotsig);
+	signal(SIGTSTP, gotsig);
+	signal(SIGCONT, gotsig);
+	while (1)
+		sleep (1);
+	return 0;
+}
+
+static void
+gotsig(int sig)
+{
+	printf("Got signal: %d\n", sig);
+}
diff --git a/prex-0.9.0/usr/test/stack/Makefile b/prex-0.9.0/usr/test/stack/Makefile
new file mode 100755
index 0000000..3f02d9c
--- /dev/null
+++ b/prex-0.9.0/usr/test/stack/Makefile
@@ -0,0 +1,3 @@
+PROG=	stack
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/stack/stack.c b/prex-0.9.0/usr/test/stack/stack.c
new file mode 100755
index 0000000..3eba3a7
--- /dev/null
+++ b/prex-0.9.0/usr/test/stack/stack.c
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2008, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * stack.c - stack overflow test.
+ */
+
+#include <sys/prex.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+static void
+print_recursive(int num)
+{
+
+	printf("%d %x\n", num, (unsigned int)&num);
+	if (num < 1000)
+		print_recursive(num + 1);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+	printf("starting stack overflow test.\n");
+
+	print_recursive(0);
+
+	printf("test complete\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/stderr/Makefile b/prex-0.9.0/usr/test/stderr/Makefile
new file mode 100755
index 0000000..0d3891b
--- /dev/null
+++ b/prex-0.9.0/usr/test/stderr/Makefile
@@ -0,0 +1,3 @@
+PROG=	stderr
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/stderr/stderr.c b/prex-0.9.0/usr/test/stderr/stderr.c
new file mode 100755
index 0000000..9855cef
--- /dev/null
+++ b/prex-0.9.0/usr/test/stderr/stderr.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * stderr.c - test program for stderr
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+	fprintf(stderr, "test1\n");
+	fprintf(stderr, "test2\n");
+	fprintf(stderr, "test3\n");
+	fprintf(stderr, "test4\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/task/Makefile b/prex-0.9.0/usr/test/task/Makefile
new file mode 100755
index 0000000..a18c2c6
--- /dev/null
+++ b/prex-0.9.0/usr/test/task/Makefile
@@ -0,0 +1,3 @@
+TASK=	task.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/task/task.c b/prex-0.9.0/usr/test/task/task.c
new file mode 100755
index 0000000..67f6696
--- /dev/null
+++ b/prex-0.9.0/usr/test/task/task.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2005-2006, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * task.c - test program for kernel task services.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NR_THREADS 16
+
+static char stack[NR_THREADS][1024];
+
+static void
+test_thread(void)
+{
+	printf("New thread %x is started\n", (u_int)thread_self());
+
+	for (;;) {
+		timer_sleep(100, 0);
+		printf("@");
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	task_t task;
+	thread_t t;
+	int i, error;
+
+	printf("Task test program\n");
+	sys_log("Task test program\n");
+
+	/*
+	 * Boost priority of this thread
+	 */
+	thread_setpri(thread_self(), 90);
+
+	/*
+	 * Create test task
+	 */
+#ifdef CONFIG_MMU
+	error = task_create(task_self(), VM_COPY, &task);
+#else
+	error = task_create(task_self(), VM_SHARE, &task);
+#endif
+	if (error) {
+		printf("task_create failed. error=%d\n", error);
+		exit(1);
+	}
+
+	/*
+	 * Run threads
+	 */
+	for (i = 0; i < NR_THREADS; i++) {
+		error = thread_create(task, &t);
+		printf("thread_create: error=%d\n", error);
+		error = thread_load(t, test_thread, stack[i]+1024);
+		printf("thread_load: error=%d\n", error);
+		thread_resume(t);
+	}
+
+	/*
+	 * Sleep for a while
+	 */
+	timer_sleep(1000, 0);
+
+	/*
+	 * Suspend test task
+	 */
+	printf("\nSuspend test task.\n");
+	error = task_suspend(task);
+	if (error)
+		panic("task suspend failed");
+
+	/*
+	 * Sleep for a while
+	 */
+	printf("Sleep\n");
+	timer_sleep(500, 0);
+
+	printf("\nResume test task.\n");
+	error = task_resume(task);
+	if (error)
+		panic("task resume failed");
+
+	/*
+	 * Sleep for a while
+	 */
+	timer_sleep(3000, 0);
+
+	printf("\nResume task, again.\n");
+	error = task_resume(task);
+	if (error)
+		printf("Error - OK!\n");
+
+	timer_sleep(1000, 0);
+
+	printf("\nTerminate task.\n");
+	task_terminate(task);
+
+	printf("\nTest OK!\n");
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/thread/Makefile b/prex-0.9.0/usr/test/thread/Makefile
new file mode 100755
index 0000000..05219aa
--- /dev/null
+++ b/prex-0.9.0/usr/test/thread/Makefile
@@ -0,0 +1,3 @@
+TASK= thread.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/thread/thread.c b/prex-0.9.0/usr/test/thread/thread.c
new file mode 100755
index 0000000..dbb4ad3
--- /dev/null
+++ b/prex-0.9.0/usr/test/thread/thread.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * thread.c - test to run threads
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+static char stack[1024];
+
+static thread_t
+thread_run(void (*start)(void), char *stack)
+{
+	thread_t t;
+	int error;
+
+	if ((error = thread_create(task_self(), &t)) != 0)
+		panic("thread_create() is failed");
+
+	if ((error = thread_load(t, start, stack)) != 0)
+		panic("thread_load() is failed");
+
+	if ((error = thread_resume(t)) != 0)
+		panic("thread_resume() is failed");
+
+	return t;
+}
+
+static void
+test_thread(void)
+{
+	printf("test thread is starting...\n");
+	for (;;)
+		putchar('@');
+}
+
+int
+main(int argc, char *argv[])
+{
+	int error;
+	thread_t self, t;
+
+	printf("Thread test program\n");
+
+	self = thread_self();
+
+	/*
+	 * Create new thread
+	 */
+	printf("Start test thread\n");
+	t = thread_run(test_thread, stack+1024);
+
+	/*
+	 * Wait 1 sec
+	 */
+	timer_sleep(3000, 0);
+
+	/*
+	 * Suspend test thread
+	 */
+	printf("\nSuspend test thread\n");
+	error = thread_suspend(t);
+
+	/*
+	 * Wait 2 sec
+	 */
+	timer_sleep(2000, 0);
+
+	/*
+	 * Resume test thread
+	 */
+	printf("\nResume test thread\n");
+	error = thread_resume(t);
+
+	/*
+	 * Wait 100 msec
+	 */
+	timer_sleep(100, 0);
+
+	/*
+	 * Suspend test thread
+	 */
+	thread_suspend(t);
+
+	/*
+	 * Wait 2 sec
+	 */
+	timer_sleep(2000, 0);
+
+	/*
+	 * Resume test thread
+	 */
+	thread_resume(t);
+
+	/*
+	 * We can check this thread can run 10 times than test thread,
+	 */
+	for (;;)
+		putchar('!');
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/time/Makefile b/prex-0.9.0/usr/test/time/Makefile
new file mode 100755
index 0000000..1bc9772
--- /dev/null
+++ b/prex-0.9.0/usr/test/time/Makefile
@@ -0,0 +1,3 @@
+TASK=	time.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/time/time.c b/prex-0.9.0/usr/test/time/time.c
new file mode 100755
index 0000000..8300e18
--- /dev/null
+++ b/prex-0.9.0/usr/test/time/time.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * time.c - test time function
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+u_long
+get_time(void)
+{
+	device_t rtc_dev;
+	int error;
+	u_long sec;
+	size_t len;
+
+	error = device_open("rtc", 0, &rtc_dev);
+	if (error) {
+		printf("error to open rtc device!\n");
+		return 0;
+	}
+	len = sizeof(sec);
+	error = device_read(rtc_dev, &sec, &len, 0);
+	if (error) {
+		printf("error in reading from rtc device\n");
+		device_close(rtc_dev);
+		return 0;
+	}
+	device_close(rtc_dev);
+	return sec;
+}
+
+int
+main(int argc, char *argv[])
+{
+	u_long sys_time;
+	u_long sec, min, hour;
+
+	printf("Time test program\n");
+
+	sys_time = get_time();
+	if (sys_time == 0)
+		return 0;
+
+	sec = sys_time % 60;
+	min = (sys_time / 60) % 60;
+	hour = (sys_time / 60 / 60) % 24;
+	printf("Current time: %lu:%lu:%lu\n", hour, min, sec);
+
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/timer/Makefile b/prex-0.9.0/usr/test/timer/Makefile
new file mode 100755
index 0000000..df9ab2e
--- /dev/null
+++ b/prex-0.9.0/usr/test/timer/Makefile
@@ -0,0 +1,3 @@
+TASK=	timer.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/timer/timer.c b/prex-0.9.0/usr/test/timer/timer.c
new file mode 100755
index 0000000..610625b
--- /dev/null
+++ b/prex-0.9.0/usr/test/timer/timer.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * timer.c - test kernel timer functions
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+	printf("Timer Test program\n");
+
+	printf("Sleep 5000 msec...\n");
+	timer_sleep(5000, 0);
+	printf("Wake!\n");
+
+	printf("Kick periodic timer start=5000 msec, period=2000msec\n");
+	timer_periodic(thread_self(), 5000, 2000);
+	for (;;) {
+		printf("Wait timer\n");
+		timer_waitperiod();
+		printf("Wake!\n");
+	}
+	return 0;
+}
diff --git a/prex-0.9.0/usr/test/umount/Makefile b/prex-0.9.0/usr/test/umount/Makefile
new file mode 100755
index 0000000..5f04ebe
--- /dev/null
+++ b/prex-0.9.0/usr/test/umount/Makefile
@@ -0,0 +1,3 @@
+PROG=	umount
+
+include $(SRCDIR)/mk/prog.mk
diff --git a/prex-0.9.0/usr/test/umount/umount.c b/prex-0.9.0/usr/test/umount/umount.c
new file mode 100755
index 0000000..444ac78
--- /dev/null
+++ b/prex-0.9.0/usr/test/umount/umount.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005-2009, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * umount.c - test unmount function.
+ *
+ * NOTE: This program requires CAP_DISKADMIN capability.
+ */
+
+#include <sys/mount.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+main(int argc, char *argv[])
+{
+
+	if (umount(argv[1]) < 0)
+		perror("umount");
+	exit(0);
+}
diff --git a/prex-0.9.0/usr/test/zero/Makefile b/prex-0.9.0/usr/test/zero/Makefile
new file mode 100755
index 0000000..aff0a7e
--- /dev/null
+++ b/prex-0.9.0/usr/test/zero/Makefile
@@ -0,0 +1,3 @@
+TASK=	zero.rt
+
+include $(SRCDIR)/mk/task.mk
diff --git a/prex-0.9.0/usr/test/zero/zero.c b/prex-0.9.0/usr/test/zero/zero.c
new file mode 100755
index 0000000..e3d4741
--- /dev/null
+++ b/prex-0.9.0/usr/test/zero/zero.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2005, Kohsuke Ohtani
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * zero.c - test zero device driver.
+ */
+
+#include <sys/prex.h>
+#include <stdio.h>
+#include <string.h>
+
+static char buf[100];
+
+void
+dump_buf(void)
+{
+	int i;
+
+	for (i = 0; i < 100; i++)
+		putchar(buf[i]);
+	putchar('\n');
+}
+
+int
+main(int argc, char *argv[])
+{
+	device_t zero_dev;
+	int i, error;
+	size_t len;
+
+	printf("zero test\n");
+
+	/* 0000000000111111111122222.... */
+	for (i = 0; i < 100; i++)
+		buf[i] = '0' + i / 10;
+	dump_buf();
+
+	error = device_open("zero", 0, &zero_dev);
+	if (error)
+		printf("device open error!\n");
+
+	/* zero fill 50 character */
+	len = 50;
+	error = device_read(zero_dev, buf, &len, 0);
+	if (error)
+		printf("device read error!\n");	
+
+	/* 5555555555666666666777... */
+	dump_buf();
+
+	return 0;
+}
