Index: boot/arch/ppc32/loader/Makefile
===================================================================
--- boot/arch/ppc32/loader/Makefile	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc32/loader/Makefile	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -51,5 +51,5 @@
 SOURCES = \
 	main.c \
-	ofw.c \
+	ofwarch.c \
 	../../../genarch/ofw.c \
 	../../../generic/printf.c \
Index: boot/arch/ppc32/loader/asm.h
===================================================================
--- boot/arch/ppc32/loader/asm.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc32/loader/asm.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __ASM_H__
-#define __ASM_H__
+#ifndef BOOT_ppc32_ASM_H_
+#define BOOT_ppc32_ASM_H_
 
 #define PAGE_SIZE 4096
Index: boot/arch/ppc32/loader/boot.S
===================================================================
--- boot/arch/ppc32/loader/boot.S	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc32/loader/boot.S	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -38,5 +38,5 @@
 	stw r5, 0(r4)
 	
-	bl init
+	bl ofw_init
 	
 	b bootstrap
Index: boot/arch/ppc32/loader/main.c
===================================================================
--- boot/arch/ppc32/loader/main.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc32/loader/main.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -31,4 +31,6 @@
 #include "asm.h"
 #include "_components.h"
+#include <ofw.h>
+#include <align.h>
 
 #define HEAP_GAP 1024000
Index: boot/arch/ppc32/loader/main.h
===================================================================
--- boot/arch/ppc32/loader/main.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc32/loader/main.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,15 +27,8 @@
  */
 
-#ifndef __MAIN_H__
-#define __MAIN_H__
+#ifndef BOOT_ppc32_MAIN_H_
+#define BOOT_ppc32_MAIN_H_
 
 #include "ofw.h"
-
-/** Align to the nearest higher address.
- *
- * @param addr  Address or size to be aligned.
- * @param align Size of alignment, must be power of 2.
- */
-#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
 
 #define TASKMAP_MAX_RECORDS 32
Index: ot/arch/ppc32/loader/ofw.c
===================================================================
--- boot/arch/ppc32/loader/ofw.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ 	(revision )
@@ -1,67 +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 <ofw.h>
-#include <printf.h>
-
-typedef int (* ofw_entry_t)(ofw_args_t *args);
-
-int ofw(ofw_args_t *args)
-{
-	return ((ofw_entry_t) ofw_cif)(args);
-}
-
-void write(const char *str, const int len)
-{
-	ofw_write(str, len);
-}
-
-int ofw_keyboard(keyboard_t *keyboard)
-{
-	char device_name[BUF_SIZE];
-	
-	if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
-		return false;
-				
-	phandle device = ofw_find_device(device_name);
-	if (device == -1)
-		return false;
-								
-	pci_reg_t macio;
-	if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
-		return false;
-	keyboard->addr = macio.addr.addr_lo;
-	keyboard->size = macio.size_lo;
-
-	return true;
-}
-
-int ofw_translate_failed(ofw_arg_t flag)
-{
-	return 0;
-}
Index: boot/arch/ppc32/loader/ofwarch.c
===================================================================
--- boot/arch/ppc32/loader/ofwarch.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/arch/ppc32/loader/ofwarch.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,68 @@
+/*
+ * 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 <ofwarch.h> 
+#include <ofw.h>
+#include <printf.h>
+
+typedef int (* ofw_entry_t)(ofw_args_t *args);
+
+int ofw(ofw_args_t *args)
+{
+	return ((ofw_entry_t) ofw_cif)(args);
+}
+
+void write(const char *str, const int len)
+{
+	ofw_write(str, len);
+}
+
+int ofw_keyboard(keyboard_t *keyboard)
+{
+	char device_name[BUF_SIZE];
+	
+	if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
+		return false;
+				
+	phandle device = ofw_find_device(device_name);
+	if (device == -1)
+		return false;
+								
+	pci_reg_t macio;
+	if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
+		return false;
+	keyboard->addr = (void *) macio.addr.addr_lo;
+	keyboard->size = macio.size_lo;
+
+	return true;
+}
+
+int ofw_translate_failed(ofw_arg_t flag)
+{
+	return 0;
+}
Index: boot/arch/ppc32/loader/ofwarch.h
===================================================================
--- boot/arch/ppc32/loader/ofwarch.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/arch/ppc32/loader/ofwarch.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 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 BOOT_ppc32_OFWARCH_H_
+#define BOOT_ppc32_OFWARCH_H_
+
+#define OFW_ADDRESS_CELLS	1
+#define OFW_SIZE_CELLS		1
+
+#endif
Index: boot/arch/ppc32/loader/types.h
===================================================================
--- boot/arch/ppc32/loader/types.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc32/loader/types.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef TYPES_H__
-#define TYPES_H__
+#ifndef BOOT_ppc32_TYPES_H_
+#define BOOT_ppc32_TYPES_H_
 
 #include <gentypes.h>
Index: boot/arch/ppc64/loader/Makefile
===================================================================
--- boot/arch/ppc64/loader/Makefile	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc64/loader/Makefile	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -52,4 +52,5 @@
 SOURCES = \
 	main.c \
+	ofwarch.c \
 	../../../genarch/ofw.c \
 	../../../generic/printf.c \
Index: boot/arch/ppc64/loader/boot.S
===================================================================
--- boot/arch/ppc64/loader/boot.S	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc64/loader/boot.S	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -38,5 +38,5 @@
 	stw r5, 0(r4)
 	
-	bl init
+	bl ofw_init
 	
 	b bootstrap
Index: boot/arch/ppc64/loader/main.c
===================================================================
--- boot/arch/ppc64/loader/main.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc64/loader/main.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -31,4 +31,5 @@
 #include "asm.h"
 #include "_components.h"
+#include <ofw.h>
 
 #define HEAP_GAP 1024000
Index: boot/arch/ppc64/loader/main.h
===================================================================
--- boot/arch/ppc64/loader/main.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc64/loader/main.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,15 +27,8 @@
  */
 
-#ifndef __MAIN_H__
-#define __MAIN_H__
+#ifndef BOOT_ppc64_MAIN_H_
+#define BOOT_ppc64_MAIN_H_
 
-#include "ofw.h"
-
-/** Align to the nearest higher address.
- *
- * @param addr  Address or size to be aligned.
- * @param align Size of alignment, must be power of 2.
- */
-#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
+#include <ofw.h>
 
 #define TASKMAP_MAX_RECORDS 32
Index: ot/arch/ppc64/loader/ofw.c
===================================================================
--- boot/arch/ppc64/loader/ofw.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ 	(revision )
@@ -1,67 +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 <ofw.h>
-#include <printf.h>
-
-typedef int (* ofw_entry_t)(ofw_args_t *args);
-
-int ofw(ofw_args_t *args)
-{
-	return ((ofw_entry_t) ofw_cif)(args);
-}
-
-void write(const char *str, const int len)
-{
-	ofw_write(str, len);
-}
-
-int ofw_keyboard(keyboard_t *keyboard)
-{
-	char device_name[BUF_SIZE];
-	
-	if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
-		return false;
-				
-	phandle device = ofw_find_device(device_name);
-	if (device == -1)
-		return false;
-								
-	pci_reg_t macio;
-	if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
-		return false;
-	keyboard->addr = (void *) macio.addr.addr_lo;
-	keyboard->size = macio.size_lo;
-
-	return true;
-}
-
-int ofw_translate_failed(ofw_arg_t flag)
-{
-	return 0;
-}
Index: boot/arch/ppc64/loader/ofwarch.c
===================================================================
--- boot/arch/ppc64/loader/ofwarch.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/arch/ppc64/loader/ofwarch.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,68 @@
+/*
+ * 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 <ofwarch.h>
+#include <ofw.h>
+#include <printf.h>
+
+typedef int (* ofw_entry_t)(ofw_args_t *args);
+
+int ofw(ofw_args_t *args)
+{
+	return ((ofw_entry_t) ofw_cif)(args);
+}
+
+void write(const char *str, const int len)
+{
+	ofw_write(str, len);
+}
+
+int ofw_keyboard(keyboard_t *keyboard)
+{
+	char device_name[BUF_SIZE];
+	
+	if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(device_name)) <= 0)
+		return false;
+				
+	phandle device = ofw_find_device(device_name);
+	if (device == -1)
+		return false;
+								
+	pci_reg_t macio;
+	if (ofw_get_property(device, "assigned-addresses", &macio, sizeof(macio)) <= 0)
+		return false;
+	keyboard->addr = (void *) macio.addr.addr_lo;
+	keyboard->size = macio.size_lo;
+
+	return true;
+}
+
+int ofw_translate_failed(ofw_arg_t flag)
+{
+	return 0;
+}
Index: boot/arch/ppc64/loader/ofwarch.h
===================================================================
--- boot/arch/ppc64/loader/ofwarch.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/arch/ppc64/loader/ofwarch.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 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 BOOT_ppc64_OFWARCH_H_
+#define BOOT_ppc64_OFWARCH_H_
+
+#define OFW_ADDRESS_CELLS	2
+#define OFW_SIZE_CELLS		2
+
+#endif
Index: boot/arch/ppc64/loader/types.h
===================================================================
--- boot/arch/ppc64/loader/types.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/ppc64/loader/types.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef TYPES_H__
-#define TYPES_H__
+#ifndef BOOT_ppc64_TYPES_H_
+#define BOOT_ppc64_TYPES_H_
 
 #include <gentypes.h>
Index: boot/arch/sparc64/loader/Makefile
===================================================================
--- boot/arch/sparc64/loader/Makefile	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/sparc64/loader/Makefile	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -53,5 +53,5 @@
 	../../../generic/printf.c \
 	../../../genarch/ofw.c \
-	ofw.c \
+	ofwarch.c \
 	asm.S \
 	boot.S
@@ -65,5 +65,5 @@
 .PHONY: all clean depend
 
-all: image.boot
+all: image.boot disasm
 
 -include Makefile.depend
@@ -86,2 +86,5 @@
 %.o: %.c
 	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+
+disasm: image.boot
+	$(OBJDUMP) -d image.boot > boot.disasm
Index: boot/arch/sparc64/loader/asm.h
===================================================================
--- boot/arch/sparc64/loader/asm.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/sparc64/loader/asm.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __ASM_H__
-#define __ASM_H__
+#ifndef BOOT_sparc64_ASM_H_
+#define BOOT_sparc64_ASM_H_
 
 #define PAGE_SIZE 8192
Index: boot/arch/sparc64/loader/boot.S
===================================================================
--- boot/arch/sparc64/loader/boot.S	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/sparc64/loader/boot.S	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -30,4 +30,5 @@
 
 #define PSTATE_IE_BIT	2
+#define PSTATE_AM_BIT	8
 
 .register %g2, #scratch
@@ -56,8 +57,8 @@
 
 	/*
-	 * Disable interrupts.
+	 * Disable interrupts and disable address masking.
 	 */
 	rdpr %pstate, %g2
-	and %g2, ~PSTATE_IE_BIT, %g2	! mask the Interrupt Enable bit
+	and %g2, ~(PSTATE_IE_BIT|PSTATE_AM_BIT), %g2
 	wrpr %g2, 0, %pstate
 
@@ -66,5 +67,5 @@
 	set ofw_cif, %l0
  
-	call init		! initialize OpenFirmware
+	call ofw_init		! initialize OpenFirmware
 	stx %o4, [%l0]
 	
Index: boot/arch/sparc64/loader/main.c
===================================================================
--- boot/arch/sparc64/loader/main.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/sparc64/loader/main.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -32,4 +32,5 @@
 #include "_components.h"
 #include <ofw.h>
+#include <align.h>
 
 #define KERNEL_VIRTUAL_ADDRESS 0x400000
@@ -44,11 +45,37 @@
 	init_components(components);
 
+	if (!ofw_memmap(&bootinfo.memmap)) {
+		printf("Error: unable to get memory map, halting.\n");
+		halt();
+	}
+	
+	if (bootinfo.memmap.total == 0) {
+		printf("Error: no memory detected, halting.\n");
+		halt();
+	}
+	
+	if (!ofw_screen(&bootinfo.screen)) {
+		printf("Error: unable to get screen properties, halting.\n");
+		halt();
+	}
+	bootinfo.screen.addr = ofw_translate(bootinfo.screen.addr);
+	
+	if (!ofw_keyboard(&bootinfo.keyboard)) {
+		printf("Error: unable to get keyboard properties, halting.\n");
+		halt();
+	}
+	
+	printf("\nDevice statistics\n");
+	printf(" memory: %dM\n", bootinfo.memmap.total>>20);
+	printf(" screen at %P, resolution %dx%d, %d bpp (scanline %d bytes)\n", (uintptr_t) bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height, bootinfo.screen.bpp, bootinfo.screen.scanline);
+	printf(" keyboard at %P (size %d bytes)\n", (uintptr_t) bootinfo.keyboard.addr, bootinfo.keyboard.size);
+
 	printf("\nMemory statistics\n");
-	printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS);
-	printf(" %L: boot info structure\n", &bootinfo);
+	printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS);
+	printf(" %P: boot info structure\n", &bootinfo);
 	
 	unsigned int i;
 	for (i = 0; i < COMPONENTS; i++)
-		printf(" %L: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
+		printf(" %P: %s image (size %d bytes)\n", components[i].start, components[i].name, components[i].size);
 
 	printf("\nCopying components\n");
Index: boot/arch/sparc64/loader/main.h
===================================================================
--- boot/arch/sparc64/loader/main.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/sparc64/loader/main.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,13 +27,8 @@
  */
 
-#ifndef __MAIN_H__
-#define __MAIN_H__
+#ifndef BOOT_sparc64_MAIN_H_
+#define BOOT_sparc64_MAIN_H_
 
-/** Align to the nearest higher address.
- *
- * @param addr  Address or size to be aligned.
- * @param align Size of alignment, must be power of 2.
- */
-#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
+#include <ofw.h>
 
 #define TASKMAP_MAX_RECORDS 32
@@ -47,4 +42,7 @@
 	unsigned int cnt;
 	task_t tasks[TASKMAP_MAX_RECORDS];
+	memmap_t memmap;
+	screen_t screen;
+	keyboard_t keyboard;
 } bootinfo_t;
 
Index: ot/arch/sparc64/loader/ofw.c
===================================================================
--- boot/arch/sparc64/loader/ofw.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ 	(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.
- */
- 
-#include <ofw.h>
-#include <printf.h>
-
-void write(const char *str, const int len)
-{
-	int i;
-	
-	for (i = 0; i < len; i++) {
-		if (str[i] == '\n')
-			ofw_write("\r", 1);
-		ofw_write(&str[i], 1);
-	}
-}
-
-int ofw_translate_failed(ofw_arg_t flag)
-{
-	return flag != -1;
-}
Index: boot/arch/sparc64/loader/ofwarch.c
===================================================================
--- boot/arch/sparc64/loader/ofwarch.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/arch/sparc64/loader/ofwarch.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+/**
+ * @file
+ * @brief	Architecture dependent parts of OpenFirmware interface.
+ */
+
+#include <ofwarch.h>  
+#include <ofw.h>
+#include <printf.h>
+
+void write(const char *str, const int len)
+{
+	int i;
+	
+	for (i = 0; i < len; i++) {
+		if (str[i] == '\n')
+			ofw_write("\r", 1);
+		ofw_write(&str[i], 1);
+	}
+}
+
+int ofw_translate_failed(ofw_arg_t flag)
+{
+	return flag != -1;
+}
+
+int ofw_keyboard(keyboard_t *keyboard)
+{
+	char device_name[BUF_SIZE];
+	uint32_t virtaddr;
+		
+	if (ofw_get_property(ofw_aliases, "keyboard", device_name, sizeof(device_name)) <= 0)
+		return false;
+					
+	phandle device = ofw_find_device(device_name);
+	if (device == -1)
+		return false;
+									
+	if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0)
+		return false;
+												
+	if (!(keyboard->addr = ofw_translate((void *) ((uintptr_t) virtaddr))))
+		return false;
+
+	return true;
+}
Index: boot/arch/sparc64/loader/ofwarch.h
===================================================================
--- boot/arch/sparc64/loader/ofwarch.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/arch/sparc64/loader/ofwarch.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2006 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 BOOT_sparc64_OFWARCH_H_
+#define BOOT_sparc64_OFWARCH_H_
+
+#define OFW_ADDRESS_CELLS	2
+#define OFW_SIZE_CELLS		2
+
+#endif
Index: boot/arch/sparc64/loader/types.h
===================================================================
--- boot/arch/sparc64/loader/types.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/arch/sparc64/loader/types.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef TYPES_H__
-#define TYPES_H__
+#ifndef BOOT_sparc64_TYPES_H_
+#define BOOT_sparc64_TYPES_H_
 
 #include <gentypes.h>
Index: boot/genarch/ofw.c
===================================================================
--- boot/genarch/ofw.c	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/genarch/ofw.c	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,5 +27,6 @@
  */
  
-#include "ofw.h"
+#include <ofw.h>
+#include <ofwarch.h>
 #include <printf.h>
 #include <asm.h>
@@ -41,4 +42,38 @@
 phandle ofw_aliases;
 
+void ofw_init(void)
+{
+	ofw_chosen = ofw_find_device("/chosen");
+	if (ofw_chosen == -1)
+		halt();
+	
+	if (ofw_get_property(ofw_chosen, "stdout",  &ofw_stdout, sizeof(ofw_stdout)) <= 0)
+		ofw_stdout = 0;
+	
+	ofw_root = ofw_find_device("/");
+	if (ofw_root == -1) {
+		puts("\r\nError: Unable to find / device, halted.\r\n");
+		halt();
+	}
+	
+	if (ofw_get_property(ofw_chosen, "mmu",  &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
+		puts("\r\nError: Unable to get mmu property, halted.\r\n");
+		halt();
+	}
+
+	ofw_memory = ofw_find_device("/memory");
+	if (ofw_memory == -1) {
+		puts("\r\nError: Unable to find /memory device, halted.\r\n");
+		halt();
+	}
+	
+	ofw_aliases = ofw_find_device("/aliases");
+	if (ofw_aliases == -1) {
+		puts("\r\nError: Unable to find /aliases device, halted.\r\n");
+		halt();
+	}
+}
+
+
 static unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...)
 {
@@ -80,11 +115,11 @@
 
 
-static unsigned int ofw_get_address_cells(const phandle device)
-{
-	unsigned int ret;
+unsigned int ofw_get_address_cells(const phandle device)
+{
+	unsigned int ret = 1;
 	
 	if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0)
 		if (ofw_get_property(ofw_root, "#address-cells", &ret, sizeof(ret)) <= 0)
-			ret = 1;
+			ret = OFW_ADDRESS_CELLS;
 	
 	return ret;
@@ -92,5 +127,5 @@
 
 
-static unsigned int ofw_get_size_cells(const phandle device)
+unsigned int ofw_get_size_cells(const phandle device)
 {
 	unsigned int ret;
@@ -98,5 +133,5 @@
 	if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0)
 		if (ofw_get_property(ofw_root, "#size-cells", &ret, sizeof(ret)) <= 0)
-			ret = 1;
+			ret = OFW_SIZE_CELLS;
 	
 	return ret;
@@ -107,38 +142,4 @@
 {
 	return ofw_call("open", 1, 1, NULL, name);
-}
-
-
-void init(void)
-{
-	ofw_chosen = ofw_find_device("/chosen");
-	if (ofw_chosen == -1)
-		halt();
-	
-	if (ofw_get_property(ofw_chosen, "stdout",  &ofw_stdout, sizeof(ofw_stdout)) <= 0)
-		ofw_stdout = 0;
-	
-	ofw_root = ofw_find_device("/");
-	if (ofw_root == -1) {
-		puts("\r\nError: Unable to find / device, halted.\r\n");
-		halt();
-	}
-	
-	if (ofw_get_property(ofw_chosen, "mmu",  &ofw_mmu, sizeof(ofw_mmu)) <= 0) {
-		puts("\r\nError: Unable to get mmu property, halted.\r\n");
-		halt();
-	}
-	
-	ofw_memory = ofw_find_device("/memory");
-	if (ofw_memory == -1) {
-		puts("\r\nError: Unable to find /memory device, halted.\r\n");
-		halt();
-	}
-	
-	ofw_aliases = ofw_find_device("/aliases");
-	if (ofw_aliases == -1) {
-		puts("\r\nError: Unable to find /aliases device, halted.\r\n");
-		halt();
-	}
 }
 
@@ -170,5 +171,5 @@
 	else
 		shift = 0;
-		
+
 	return (void *) ((result[2]<<shift)|result[3]);
 }
@@ -207,17 +208,17 @@
 int ofw_memmap(memmap_t *map)
 {
-	unsigned long buf[BUF_SIZE];
-	int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
-	if (ret <= 0)
-		return false;
-		
 	unsigned int ac = ofw_get_address_cells(ofw_memory);
 	unsigned int sc = ofw_get_size_cells(ofw_memory);
-	
+
+	uint32_t buf[((ac+sc)*MEMMAP_MAX_RECORDS)];
+	int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
+	if (ret <= 0)		/* ret is the number of written bytes */
+		return false;
+
 	int pos;
 	map->total = 0;
 	map->count = 0;
-	for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
-		void * start = (void *) buf[pos + ac - 1];
+	for (pos = 0; (pos < ret / sizeof(uint32_t)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
+		void * start = (void *) ((uintptr_t) buf[pos + ac - 1]);
 		unsigned int size = buf[pos + ac + sc - 1];
 		
@@ -229,4 +230,6 @@
 		}
 	}
+	
+	return true;
 }
 
@@ -235,4 +238,5 @@
 {
 	char device_name[BUF_SIZE];
+	uint32_t virtaddr;
 	
 	if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
@@ -243,7 +247,9 @@
 		return false;
 	
-	if (ofw_get_property(device, "address", &screen->addr, sizeof(screen->addr)) <= 0)
-		return false;
-	
+	if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0)
+		return false;
+
+	screen->addr = (void *) ((uintptr_t) virtaddr);
+
 	if (ofw_get_property(device, "width", &screen->width, sizeof(screen->width)) <= 0)
 		return false;
Index: boot/genarch/ofw.h
===================================================================
--- boot/genarch/ofw.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/genarch/ofw.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef __OFW_H__
-#define __OFW_H__
+#ifndef BOOT_OFW_H_
+#define BOOT_OFW_H_
 
 #include <types.h>
@@ -39,5 +39,5 @@
 #define MAX_OFW_ARGS            12
 
-typedef unsigned long ofw_arg_t;
+typedef unative_t ofw_arg_t;
 typedef unsigned int ihandle;
 typedef unsigned int phandle;
@@ -65,5 +65,5 @@
 
 typedef struct {
-	uint32_t addr;
+	void *addr;
 	unsigned int width;
 	unsigned int height;
@@ -73,5 +73,5 @@
 
 typedef struct {
-	uint32_t addr;
+	void *addr;
 	unsigned int size;
 } keyboard_t;
@@ -93,5 +93,5 @@
 extern phandle ofw_aliases;
 
-extern void init(void);
+extern void ofw_init(void);
 extern void ofw_write(const char *str, const int len);
 
@@ -100,4 +100,6 @@
 
 extern int ofw(ofw_args_t *arg);
+extern unsigned int ofw_get_address_cells(const phandle device);
+extern unsigned int ofw_get_size_cells(const phandle device);
 extern void *ofw_translate(const void *virt);
 extern int ofw_translate_failed(ofw_arg_t flag);
Index: boot/generic/align.h
===================================================================
--- boot/generic/align.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ boot/generic/align.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2006 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 BOOT_ALIGN_H_
+#define BOOT_ALIGN_H_
+
+/** Align to the nearest higher address.
+ *
+ * @param addr  Address or size to be aligned.
+ * @param align Size of alignment, must be power of 2.
+ */
+#define ALIGN_UP(addr, align) (((addr) + ((align) - 1)) & ~((align) - 1))
+
+#endif
Index: boot/generic/gentypes.h
===================================================================
--- boot/generic/gentypes.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/generic/gentypes.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef GENTYPES_H__
-#define GENTYPES_H__
+#ifndef BOOT_GENTYPES_H_
+#define BOOT_GENTYPES_H_
 
 #define NULL 0
Index: boot/generic/printf.h
===================================================================
--- boot/generic/printf.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ boot/generic/printf.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -27,6 +27,6 @@
  */
 
-#ifndef PRINTF_H__
-#define PRINTF_H__
+#ifndef BOOT_PRINTF_H_
+#define BOOT_PRINTF_H_
 
 #define INT8	1
Index: kernel/arch/sparc64/include/regdef.h
===================================================================
--- kernel/arch/sparc64/include/regdef.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
+++ kernel/arch/sparc64/include/regdef.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup sparc64	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc64_REGDEF_H_
+#define KERN_sparc64_REGDEF_H_
+
+#define PSTATE_IE_BIT	2
+#define PSTATE_AM_BIT	8
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc64/include/register.h
===================================================================
--- kernel/arch/sparc64/include/register.h	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ kernel/arch/sparc64/include/register.h	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -36,9 +36,5 @@
 #define KERN_sparc64_REGISTER_H_
 
-#ifdef __ASM__
-#define PSTATE_IE_BIT	2
-#define PSTATE_AM_BIT	8
-#else
-
+#include <arch/regdef.h>
 #include <arch/types.h>
 
@@ -112,6 +108,4 @@
 #endif
 
-#endif
-
 /** @}
  */
Index: kernel/arch/sparc64/src/asm.S
===================================================================
--- kernel/arch/sparc64/src/asm.S	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ kernel/arch/sparc64/src/asm.S	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -28,5 +28,5 @@
 
 #include <arch/stack.h>
-#include <arch/register.h>
+#include <arch/regdef.h>
 
 .text
Index: kernel/arch/sparc64/src/start.S
===================================================================
--- kernel/arch/sparc64/src/start.S	(revision eda7bf81c075340c94f824b63d60c145c13254b5)
+++ kernel/arch/sparc64/src/start.S	(revision 63cda71efb0a2f95861470401dbc781d7f284896)
@@ -28,5 +28,5 @@
 
 #include <arch/boot/boot.h>
-#include <arch/register.h>
+#include <arch/regdef.h>
 
 .register %g2, #scratch
@@ -38,5 +38,6 @@
 
 /*
- * Here is where the kernel is passed control.
+ * Here is where the kernel is passed control
+ * from the boot loader.
  */
 
