Index: init/init.c
===================================================================
--- init/init.c	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ init/init.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -28,7 +28,9 @@
 
 #include <unistd.h>
+#include <stdio.h>
 
 int main(int argc, char *argv[])
 {
+	puts("Hello world\n");
 	return 0;
 }
Index: libc/Makefile
===================================================================
--- libc/Makefile	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ libc/Makefile	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -31,8 +31,4 @@
 
 LIBC_PREFIX = .
-DEFS = -DARCH=$(ARCH)
-CFLAGS = -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -I$(LIBC_PREFIX)/include
-LFLAGS = -M
-AFLAGS =
 
 ## Setup toolchain
@@ -45,9 +41,10 @@
 
 GENERIC_SOURCES = \
-	generic/libc.c
+	generic/libc.c \
+	generic/io.c
 
 ARCH_SOURCES = \
-	arch/$(ARCH)/entry.s \
-	arch/$(ARCH)/syscall.c
+	arch/$(ARCH)/src/entry.s \
+	arch/$(ARCH)/src/syscall.c
 
 GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES)))
Index: libc/Makefile.toolchain
===================================================================
--- libc/Makefile.toolchain	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ libc/Makefile.toolchain	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -28,5 +28,5 @@
 
 DEFS = -DARCH=$(ARCH)
-CFLAGS = -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -I$(LIBC_PREFIX)/include
+CFLAGS = -fno-builtin -fomit-frame-pointer -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -nostdlib -nostdinc -I$(LIBC_PREFIX)/include -I$(LIBC_PREFIX)/arch/$(ARCH)/include
 LFLAGS = -M
 AFLAGS =
Index: libc/_link.ld.in
===================================================================
--- libc/_link.ld.in	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ libc/_link.ld.in	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -1,4 +1,4 @@
 OUTPUT_FORMAT(binary)
-STARTUP(../libc/arch/ARCH/entry.o)
+STARTUP(../libc/arch/ARCH/src/entry.o)
 ENTRY(__entry)
 
Index: bc/arch/ia32/entry.s
===================================================================
--- libc/arch/ia32/entry.s	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#
-# Copyright (C) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - 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.
-#
-
-.text
-
-.org 0
-
-.globl __entry
-
-## User-space task entry point
-#
-#
-__entry:
-	
-	call main
-	call __exit
-	
-.end __entry
Index: libc/arch/ia32/include/types.h
===================================================================
--- libc/arch/ia32/include/types.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/ia32/include/types.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2005 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - 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.
+ */
+
+#ifndef __LIBC__TYPES_H__
+#define __LIBC__TYPES_H__
+
+typedef unsigned int sysarg_t;
+typedef unsigned int size_t;
+typedef signed int ssize_t;
+
+#endif
Index: libc/arch/ia32/src/entry.s
===================================================================
--- libc/arch/ia32/src/entry.s	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/ia32/src/entry.s	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2005 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - 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.
+#
+
+.text
+
+.org 0
+
+.globl __entry
+
+## User-space task entry point
+#
+#
+__entry:
+	
+	call main
+	call __exit
+	
+.end __entry
Index: libc/arch/ia32/src/syscall.c
===================================================================
--- libc/arch/ia32/src/syscall.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/ia32/src/syscall.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2005 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - 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.
+ */
+
+#include <libc.h>
+
+unsigned int __syscall(const syscall_t id, const unsigned int p1, const unsigned int p2, const unsigned int p3)
+{
+	unsigned int ret;
+	
+	asm volatile (
+		"int $0x80\n"
+		: "=a" (ret)
+		: "a" (id),
+		  "b" (p1),
+		  "c" (p2),
+		  "d" (p3)
+	);
+	
+	return ret;
+}
Index: bc/arch/ia32/syscall.c
===================================================================
--- libc/arch/ia32/syscall.c	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/*
- * Copyright (C) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - 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.
- */
-
-#include <libc.h>
-
-void __syscall(const unsigned int id, const unsigned int p1, const unsigned int p2, const unsigned int p3)
-{
-
-}
Index: bc/arch/mips32/entry.s
===================================================================
--- libc/arch/mips32/entry.s	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../mips32el/entry.s
Index: libc/arch/mips32/include
===================================================================
--- libc/arch/mips32/include	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/mips32/include	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,1 @@
+../mips32el/include
Index: libc/arch/mips32/src
===================================================================
--- libc/arch/mips32/src	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/mips32/src	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,1 @@
+../mips32el/src
Index: bc/arch/mips32/syscall.c
===================================================================
--- libc/arch/mips32/syscall.c	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,1 +1,0 @@
-../mips32el/syscall.c
Index: bc/arch/mips32el/entry.s
===================================================================
--- libc/arch/mips32el/entry.s	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,46 +1,0 @@
-#
-# Copyright (C) 2005 Martin Decky
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - 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.
-#
-
-.text
-
-.org 0
-
-.globl __entry
-
-## User-space task entry point
-#
-#
-__entry:
-
-	jal main
-	nop
-	
-	jal __exit
-	nop	
-	
-.end __entry
Index: libc/arch/mips32el/include/types.h
===================================================================
--- libc/arch/mips32el/include/types.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/mips32el/include/types.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2005 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - 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.
+ */
+
+#ifndef __LIBC__TYPES_H__
+#define __LIBC__TYPES_H__
+
+typedef unsigned int sysarg_t;
+typedef unsigned int size_t;
+typedef signed int ssize_t;
+
+#endif
Index: libc/arch/mips32el/src/entry.s
===================================================================
--- libc/arch/mips32el/src/entry.s	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/mips32el/src/entry.s	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2005 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - 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.
+#
+
+.text
+
+.org 0
+
+.globl __entry
+
+## User-space task entry point
+#
+#
+__entry:
+
+	jal main
+	nop
+	
+	jal __exit
+	nop	
+	
+.end __entry
Index: libc/arch/mips32el/src/syscall.c
===================================================================
--- libc/arch/mips32el/src/syscall.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/arch/mips32el/src/syscall.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - 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.
+ */
+
+#include <libc.h>
+
+unsigned int __syscall(const syscall_t id, const unsigned int p1, const unsigned int p2, const unsigned int p3)
+{
+	register unsigned int __mips_reg_a0 asm("$4") = p1;
+	register unsigned int __mips_reg_a1 asm("$5") = p2;
+	register unsigned int __mips_reg_a2 asm("$6") = p3;
+	register unsigned int __mips_reg_a3 asm("$7") = id;
+	register unsigned int __mips_reg_v0 asm("$2");
+	
+	asm volatile (
+		"syscall\n"
+		: "=r" (__mips_reg_v0)
+		: "r" (__mips_reg_a0),
+		  "r" (__mips_reg_a1),
+		  "r" (__mips_reg_a2),
+		  "r" (__mips_reg_a3)
+	);
+	
+	return __mips_reg_v0;
+}
Index: bc/arch/mips32el/syscall.c
===================================================================
--- libc/arch/mips32el/syscall.c	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,47 +1,0 @@
-/*
- * Copyright (C) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - 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.
- */
-
-#include <libc.h>
-
-void __syscall(const unsigned int id, const unsigned int p1, const unsigned int p2, const unsigned int p3)
-{
-	register unsigned int __mips_reg_a0 asm("$4") = p1;
-	register unsigned int __mips_reg_a1 asm("$5") = p2;
-	register unsigned int __mips_reg_a2 asm("$6") = p3;
-	register unsigned int __mips_reg_a3 asm("$7") = id;
-	
-	asm volatile (
-		"syscall\n"
-		:
-		: "r" (__mips_reg_a0),
-		  "r" (__mips_reg_a1),
-		  "r" (__mips_reg_a2),
-		  "r" (__mips_reg_a3)
-		: "v0"
-	);
-}
Index: libc/generic/io.c
===================================================================
--- libc/generic/io.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/generic/io.c	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2005 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - 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.
+ */ 
+
+#include <libc.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int puts(const char * str)
+{
+	size_t count;
+	
+	for (count = 0; str[count] != 0; count++);
+	if (write(1, (void * ) str, count) == count)
+		return 0;
+	else
+		return EOF;
+}
+
+ssize_t write(int fd, const void * buf, size_t count)
+{
+	return __syscall(SYS_IO, (sysarg_t) fd, (sysarg_t) buf, (sysarg_t) count);
+}
Index: libc/include/libc.h
===================================================================
--- libc/include/libc.h	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ libc/include/libc.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -30,8 +30,16 @@
 #define __LIBC__LIBC_H__
 
+#include <types.h>
+
+
+typedef enum {
+	SYS_CTL = 0,
+	SYS_IO	= 1
+} syscall_t;
+
 
 extern void __main(void);
 extern void __exit(void);
-extern void __syscall(const unsigned int id, const unsigned int p1, const unsigned int p2, const unsigned int p3);
+extern unsigned int __syscall(const syscall_t id, const sysarg_t p1, const sysarg_t p2, const sysarg_t p3);
 
 
Index: libc/include/stdio.h
===================================================================
--- libc/include/stdio.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
+++ libc/include/stdio.h	(revision cc6f688f354a22e73aa08bf66a55f9faa4fea32c)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2005 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - 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.
+ */
+
+#ifndef __LIBC__STDIO_H__
+#define __LIBC__STDIO_H__
+
+#include <types.h>
+
+#define EOF -1
+
+extern int puts(const char * str);
+
+#endif
Index: bc/include/unistd.h
===================================================================
--- libc/include/unistd.h	(revision 25b0e6a7a58aae15fdd78041df3db0d184f6d2ee)
+++ 	(revision )
@@ -1,36 +1,0 @@
-/*
- * Copyright (C) 2005 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - 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.
- */
-
-#ifndef __LIBC__UNISTD_H__
-#define __LIBC__UNISTD_H__
-
-#define NULL 0
-
-extern void puts(const char *str);
-
-#endif
