Index: arch/ia32/include/arg.h
===================================================================
--- arch/ia32/include/arg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
+++ arch/ia32/include/arg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005 Jakub Jermar
+ * 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 __ia32_ARG_H__
+#define __ia32_ARG_H__
+
+#include <stackarg.h>
+
+#endif
Index: arch/ia32/include/types.h
===================================================================
--- arch/ia32/include/types.h	(revision 47d78c6b7e84f7a6010baa23b8d356f10ea71f3f)
+++ arch/ia32/include/types.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -43,3 +43,5 @@
 typedef __u32 pri_t;
 
+typedef __u32 __native;
+
 #endif
Index: arch/ia64/include/arg.h
===================================================================
--- arch/ia64/include/arg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
+++ arch/ia64/include/arg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2005 Jakub Jermar
+ * 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 __ia64_ARG_H__
+#define __ia64_ARG_H__
+
+/* TODO: to be replaced by real IA-64 stuff */
+#include <stackarg.h>
+
+#endif
Index: arch/ia64/include/types.h
===================================================================
--- arch/ia64/include/types.h	(revision 47d78c6b7e84f7a6010baa23b8d356f10ea71f3f)
+++ arch/ia64/include/types.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -43,3 +43,5 @@
 typedef __u32 pri_t;
 
+typedef __u64 __native;
+
 #endif
Index: arch/mips/include/arg.h
===================================================================
--- arch/mips/include/arg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
+++ arch/mips/include/arg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005 Jakub Jermar
+ * 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 __mips_ARG_H__
+#define __mips_ARG_H__
+
+#include <stackarg.h>
+
+#endif
Index: arch/mips/include/types.h
===================================================================
--- arch/mips/include/types.h	(revision 47d78c6b7e84f7a6010baa23b8d356f10ea71f3f)
+++ arch/mips/include/types.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -43,3 +43,5 @@
 typedef __u32 pri_t;
 
+typedef __u32 __native;
+
 #endif
Index: include/stackarg.h
===================================================================
--- include/stackarg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
+++ include/stackarg.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2005 Jakub Jermar
+ * 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.
+ */
+
+
+/*
+ * Variable argument list manipulation macors
+ * for architectures using stack to pass arguments.
+ */
+ 
+#ifndef __STACKARG_H__
+#define __STACKARG_H__
+
+#include <arch/types.h>
+
+typedef struct va_list {
+	int pos;
+	__address *last;
+} va_list;
+
+#define va_start(ap, lst) 		\
+	(ap).pos = 0; 			\
+	(ap).last = (__address *) &(lst)
+
+#define va_arg(ap, type) 		\
+	((type) *((ap).last + ++((ap).pos)))
+
+#define va_end(ap)
+    
+
+#endif
Index: include/typedefs.h
===================================================================
--- include/typedefs.h	(revision 47d78c6b7e84f7a6010baa23b8d356f10ea71f3f)
+++ include/typedefs.h	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -60,3 +60,5 @@
 typedef struct link link_t;
 
+typedef char *char_ptr;
+
 #endif
Index: src/debug/print.c
===================================================================
--- src/debug/print.c	(revision 47d78c6b7e84f7a6010baa23b8d356f10ea71f3f)
+++ src/debug/print.c	(revision 0d2f8058babf45e17ed29e67097158b7d3387b3f)
@@ -30,4 +30,6 @@
 #include <print.h>
 #include <synch/spinlock.h>
+#include <arch/arg.h>
+
 
 static char digits[] = "0123456789abcdef";
@@ -80,9 +82,13 @@
 void printf(char *fmt, ...)
 {
-	int irqpri, i = 0, pos = 0;
-	char c;
+	int irqpri, i = 0;
+	va_list ap;
+	char c;	
+
+	va_start(ap, fmt);
 
 	irqpri = cpu_priority_high();
 	spinlock_lock(&printflock);
+
 	while (c = fmt[i++]) {
 		switch (c) {
@@ -100,9 +106,9 @@
 				 */
 				case 's':
-					print_str((char *) *(((__address *) &fmt + (++pos))));
+					print_str(va_arg(ap, char_ptr));
 					goto loop;
 
 				case 'c':
-					c = *((char *) ((__address *)(&fmt + (++pos))));
+					c = va_arg(ap, char);
 					break;
 
@@ -113,5 +119,5 @@
 					print_str("0x");
 				case 'l':
-		    			print_fixed_hex(*((__address *)(&fmt + (++pos))),INT32);
+		    			print_fixed_hex(va_arg(ap, __native), INT32);
 					goto loop;
 
@@ -119,5 +125,5 @@
 					print_str("0x");
 				case 'w':
-		    			print_fixed_hex(*((__address *)(&fmt + (++pos))),INT16);
+		    			print_fixed_hex(va_arg(ap, __native), INT16);
 					goto loop;
 
@@ -125,5 +131,5 @@
 					print_str("0x");
 				case 'b':
-		    			print_fixed_hex(*((__address *)(&fmt + (++pos))),INT8);
+		    			print_fixed_hex(va_arg(ap, __native), INT8);
 					goto loop;
 
@@ -132,5 +138,5 @@
 		                 */
 				case 'd':
-		    			print_number(*((__address *)(&fmt + (++pos))), 10);
+		    			print_number(va_arg(ap, __native), 10);
 					goto loop;
 
@@ -138,5 +144,5 @@
 			                print_str("0x");
 				case 'x':
-		    			print_number(*((__address *)(&fmt + (++pos))), 16);
+		    			print_number(va_arg(ap, __native), 16);
 					goto loop;
 	    
@@ -158,3 +164,5 @@
 	spinlock_unlock(&printflock);
 	cpu_priority_restore(irqpri);
+	
+	va_end(ap);
 }
