Index: Makefile
===================================================================
--- Makefile	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ Makefile	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -1,4 +1,5 @@
 include Makefile.config
 include arch/$(ARCH)/Makefile.inc
+include genarch/Makefile.inc
 
 sources=src/cpu/cpu.c \
@@ -51,4 +52,5 @@
 endif
 arch_objects:=$(addsuffix .o,$(basename $(arch_sources)))
+genarch_objects:=$(addsuffix .o,$(basename $(genarch_sources)))
 objects:=$(addsuffix .o,$(basename $(sources)))
 
@@ -61,14 +63,17 @@
 config:
 	find src/ include/ -name arch -type l -exec rm \{\} \;
+	find src/ include/ -name genarch -type l -exec rm \{\} \;	
 	ln -s ../arch/$(ARCH)/src/ src/arch
 	ln -s ../arch/$(ARCH)/include/ include/arch
+	ln -s ../genarch/src/ src/genarch
+	ln -s ../genarch/include/ include/genarch
 
 depend:
-	$(CC) $(CFLAGS) -M $(arch_sources) $(sources) >Makefile.depend
+	$(CC) $(CFLAGS) -M $(arch_sources) $(genarch_sources) $(sources) >Makefile.depend
 
 build: kernel.bin boot
 
 clean:
-	find src/ arch/$(ARCH)/src/ test/ -name '*.o' -exec rm \{\} \;
+	find src/ arch/$(ARCH)/src/ genarch/src/ test/ -name '*.o' -exec rm \{\} \;
 	-rm *.bin kernel.map kernel.map.pre kernel.objdump src/debug/real_map.bin
 	$(MAKE) -C arch/$(ARCH)/boot/ clean
@@ -76,11 +81,12 @@
 dist-clean:
 	find src/ include/ -name arch -type l -exec rm \{\} \;
+	find src/ include/ -name genarch -type l -exec rm \{\} \;	
 	-rm Makefile.depend
 	-$(MAKE) clean
 
-src/debug/real_map.bin: $(arch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld 
+src/debug/real_map.bin: $(arch_objects) $(genarch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld 
 	$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile src/debug/empty_map.o
-	$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(objects) $(test_objects) src/debug/empty_map.o -o $@ -Map kernel.map.pre
-	$(OBJDUMP) -t $(arch_objects) $(objects) $(test_objects) > kernel.objdump
+	$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(genarch_objects) $(objects) $(test_objects) src/debug/empty_map.o -o $@ -Map kernel.map.pre
+	$(OBJDUMP) -t $(arch_objects) $(genarch_objects) $(objects) $(test_objects) > kernel.objdump
 	tools/genmap.py kernel.map.pre kernel.objdump src/debug/real_map.bin 
 
@@ -89,6 +95,6 @@
 
 
-kernel.bin: $(arch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld src/debug/real_map.o
-	$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(objects) $(test_objects) src/debug/real_map.o -o $@ -Map kernel.map
+kernel.bin: $(arch_objects) $(genarch_objects) $(objects) $(test_objects) arch/$(ARCH)/_link.ld src/debug/real_map.o
+	$(LD) -T arch/$(ARCH)/_link.ld $(LFLAGS) $(arch_objects) $(genarch_objects) $(objects) $(test_objects) src/debug/real_map.o -o $@ -Map kernel.map
 
 %.o: %.S
Index: arch/ppc32/Makefile.inc
===================================================================
--- arch/ppc32/Makefile.inc	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ arch/ppc32/Makefile.inc	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -30,4 +30,3 @@
 	src/arch/mm/memory_init.c \
 	src/arch/mm/page.c \
-	src/arch/drivers/ofw.c \
 	src/arch/fmath.c
Index: arch/ppc32/include/arch.h
===================================================================
--- arch/ppc32/include/arch.h	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ arch/ppc32/include/arch.h	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -30,5 +30,5 @@
 #define __ppc32_ARCH_H__
 
-#include <arch/drivers/ofw.h>
+#include <genarch/firmware/ofw/ofw.h>
 
 #ifdef early_mapping
Index: ch/ppc32/include/drivers/ofw.h
===================================================================
--- arch/ppc32/include/drivers/ofw.h	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ 	(revision )
@@ -1,63 +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 __ppc32_OFW_H__
-#define __ppc32_OFW_H__
-
-#include <arch/types.h>
-
-#define MAX_OFW_ARGS	10
-
-typedef __u32 ofw_arg_t;
-typedef __u32 ihandle;
-typedef __u32 phandle;
-
-/** OpenFirmware command structure
- *
- */
-typedef struct {
-	const char *service;          /**< Command name */
-	__u32 nargs;                  /**< Number of in arguments */
-	__u32 nret;                   /**< Number of out arguments */
-	ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
-} ofw_args_t;
-
-typedef void (*ofw_entry)(ofw_args_t *);
-
-extern ofw_entry ofw;
-
-extern void ofw_init(void);
-extern void ofw_done(void);
-extern int ofw_call(const char *service, const int nargs, const int nret, ...);
-extern void ofw_putchar(const char ch);
-extern phandle ofw_find_device(const char *name);
-extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
-extern void *ofw_claim(const void *addr, const int size, const int align);
-extern void putchar(const char ch);
-
-#endif
Index: ch/ppc32/src/drivers/ofw.c
===================================================================
--- arch/ppc32/src/drivers/ofw.c	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ 	(revision )
@@ -1,104 +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 <arch/drivers/ofw.h>
-#include <arch/asm.h>
-#include <stdarg.h>
-#include <cpu.h>
-
-ofw_entry ofw;
-
-phandle ofw_chosen;
-ihandle ofw_stdout;
-
-void ofw_init(void)
-{
-	ofw_chosen = ofw_find_device("/chosen");
-	if (ofw_chosen == -1)
-		ofw_done();
-	
-	if (ofw_get_property(ofw_chosen, "stdout",  &ofw_stdout, sizeof(ofw_stdout)) <= 0)
-		ofw_stdout = 0;
-}
-
-void ofw_done(void)
-{
-	ofw_call("exit", 0, 0);
-	cpu_halt();
-}
-
-int ofw_call(const char *service, const int nargs, const int nret, ...)
-{
-	va_list list;
-	ofw_args_t args;
-	int i;
-	
-	args.service = service;
-	args.nargs = nargs;
-	args.nret = nret;
-	
-	va_start(list, nret);
-	for (i = 0; i < nargs; i++)
-		args.args[i] = va_arg(list, ofw_arg_t);
-	va_end(list);
-	
-	for (i = 0; i < nret; i++)
-		args.args[i + nargs] = 0;
-	
-	ofw(&args);
-	
-	return args.args[nargs];
-}
-
-void ofw_putchar(const char ch)
-{
-	if (ofw_stdout == 0)
-		return;
-	
-	ofw_call("write", 3, 1, ofw_stdout, &ch, 1);
-}
-
-phandle ofw_find_device(const char *name)
-{
-	return ofw_call("finddevice", 1, 1, name);
-}
-
-int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
-{
-	return ofw_call("getprop", 4, 1, device, name, buf, buflen);
-}
-
-void *ofw_claim(const void *addr, const int size, const int align)
-{
-	return (void *) ofw_call("claim", 3, 1, addr, size, align);
-}
-
-void putchar(const char ch)
-{
-	ofw_putchar(ch);
-}
Index: arch/ppc32/src/mm/memory_init.c
===================================================================
--- arch/ppc32/src/mm/memory_init.c	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ arch/ppc32/src/mm/memory_init.c	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -28,5 +28,5 @@
 
 #include <arch/mm/memory_init.h>
-#include <arch/drivers/ofw.h>
+#include <genarch/firmware/ofw/ofw.h>
 #include <panic.h>
 
Index: arch/sparc64/boot/boot.S
===================================================================
--- arch/sparc64/boot/boot.S	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ arch/sparc64/boot/boot.S	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -1,4 +1,4 @@
 #
-# Copyright (C) 2005 Martin Decky
+# Copyright (C) 2005 Jakub Jermar
 # All rights reserved.
 #
Index: arch/sparc64/src/dummy.s
===================================================================
--- arch/sparc64/src/dummy.s	(revision 81e13965b2696d0b2799d4d1e2c9512c9ef83aff)
+++ arch/sparc64/src/dummy.s	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -56,5 +56,4 @@
 .global page_arch_init
 .global panic_printf
-.global putchar
 .global userspace
 
@@ -88,5 +87,4 @@
 page_arch_init:
 panic_printf:
-putchar:
 userspace:
 
Index: genarch/Makefile.inc
===================================================================
--- genarch/Makefile.inc	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
+++ genarch/Makefile.inc	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -0,0 +1,14 @@
+# Open Firmware
+OFW=no
+
+ifeq ($(ARCH),ppc32)
+OFW=yes
+endif
+
+ifeq ($(ARCH),sparc64)
+OFW=yes
+endif
+
+ifeq ($(OFW),yes)
+genarch_sources+=src/genarch/firmware/ofw/ofw.c
+endif
Index: genarch/include/firmware/ofw/ofw.h
===================================================================
--- genarch/include/firmware/ofw/ofw.h	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
+++ genarch/include/firmware/ofw/ofw.h	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -0,0 +1,63 @@
+/*
+ * 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 __ppc32_OFW_H__
+#define __ppc32_OFW_H__
+
+#include <arch/types.h>
+
+#define MAX_OFW_ARGS	10
+
+typedef __u32 ofw_arg_t;
+typedef __u32 ihandle;
+typedef __u32 phandle;
+
+/** OpenFirmware command structure
+ *
+ */
+typedef struct {
+	const char *service;          /**< Command name */
+	__u32 nargs;                  /**< Number of in arguments */
+	__u32 nret;                   /**< Number of out arguments */
+	ofw_arg_t args[MAX_OFW_ARGS]; /**< List of arguments */
+} ofw_args_t;
+
+typedef void (*ofw_entry)(ofw_args_t *);
+
+extern ofw_entry ofw;
+
+extern void ofw_init(void);
+extern void ofw_done(void);
+extern __address ofw_call(const char *service, const int nargs, const int nret, ...);
+extern void ofw_putchar(const char ch);
+extern phandle ofw_find_device(const char *name);
+extern int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen);
+extern void *ofw_claim(const void *addr, const int size, const int align);
+extern void putchar(const char ch);
+
+#endif
Index: genarch/src/firmware/ofw/ofw.c
===================================================================
--- genarch/src/firmware/ofw/ofw.c	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
+++ genarch/src/firmware/ofw/ofw.c	(revision 34d9ab28be200edae8133cce97eb8ad2ff9d30a3)
@@ -0,0 +1,105 @@
+/*
+ * 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 <genarch/firmware/ofw/ofw.h>
+#include <arch/asm.h>
+#include <stdarg.h>
+#include <cpu.h>
+#include <arch/types.h>
+
+ofw_entry ofw;
+
+phandle ofw_chosen;
+ihandle ofw_stdout;
+
+void ofw_init(void)
+{
+	ofw_chosen = ofw_find_device("/chosen");
+	if (ofw_chosen == -1)
+		ofw_done();
+	
+	if (ofw_get_property(ofw_chosen, "stdout",  &ofw_stdout, sizeof(ofw_stdout)) <= 0)
+		ofw_stdout = 0;
+}
+
+void ofw_done(void)
+{
+	ofw_call("exit", 0, 0);
+	cpu_halt();
+}
+
+__address ofw_call(const char *service, const int nargs, const int nret, ...)
+{
+	va_list list;
+	ofw_args_t args;
+	int i;
+	
+	args.service = service;
+	args.nargs = nargs;
+	args.nret = nret;
+	
+	va_start(list, nret);
+	for (i = 0; i < nargs; i++)
+		args.args[i] = va_arg(list, ofw_arg_t);
+	va_end(list);
+	
+	for (i = 0; i < nret; i++)
+		args.args[i + nargs] = 0;
+	
+	ofw(&args);
+	
+	return args.args[nargs];
+}
+
+void ofw_putchar(const char ch)
+{
+	if (ofw_stdout == 0)
+		return;
+	
+	ofw_call("write", 3, 1, ofw_stdout, &ch, 1);
+}
+
+phandle ofw_find_device(const char *name)
+{
+	return ofw_call("finddevice", 1, 1, name);
+}
+
+int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen)
+{
+	return ofw_call("getprop", 4, 1, device, name, buf, buflen);
+}
+
+void *ofw_claim(const void *addr, const int size, const int align)
+{
+	return (void *) ofw_call("claim", 3, 1, addr, size, align);
+}
+
+void putchar(const char ch)
+{
+	ofw_putchar(ch);
+}
