Index: arch/ppc32/loader/ofw.c
===================================================================
--- arch/ppc32/loader/ofw.c	(revision d22645e4c7c59d8de3b5151b7e9c72f593c52351)
+++ arch/ppc32/loader/ofw.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -34,2 +34,22 @@
 	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;
+}
Index: arch/ppc64/loader/ofw.c
===================================================================
--- arch/ppc64/loader/ofw.c	(revision d22645e4c7c59d8de3b5151b7e9c72f593c52351)
+++ arch/ppc64/loader/ofw.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -30,6 +30,26 @@
 #include <printf.h>
 
-void write(const char *str, const long len)
+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;
+}
Index: arch/sparc64/Makefile.inc
===================================================================
--- arch/sparc64/Makefile.inc	(revision d22645e4c7c59d8de3b5151b7e9c72f593c52351)
+++ arch/sparc64/Makefile.inc	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -32,4 +32,5 @@
 
 image.iso: kernel
+	make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) IMAGE=$(CONFIG_IMAGE)
 	mkdir -p $(TMP)/boot
 	mkdir -p $(TMP)/kernel
Index: arch/sparc64/loader/Makefile
===================================================================
--- arch/sparc64/loader/Makefile	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/Makefile	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,87 @@
+#
+# Copyright (C) 2006 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.
+#
+
+## Toolchain configuration
+#
+
+TARGET = sparc64-linux-gnu
+TOOLCHAIN_DIR = /usr/local/sparc64/bin
+
+ifeq ($(COMPILER),native)
+	CC = gcc
+	AS = as
+	LD = ld
+	OBJCOPY = objcopy
+	OBJDUMP = objdump
+else
+	CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc
+	AS = $(TOOLCHAIN_DIR)/$(TARGET)-as
+	LD = $(TOOLCHAIN_DIR)/$(TARGET)-ld
+	OBJCOPY = $(TOOLCHAIN_DIR)/$(TARGET)-objcopy
+	OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
+endif
+
+CFLAGS = -I. -I../../../generic -I../../../genarch -nostdinc -nostdlib -fno-builtin -Werror-implicit-function-declaration -Wmissing-prototypes -Werror -O3 -mcpu=ultrasparc -m64
+
+SOURCES = \
+	main.c \
+	../../../generic/printf.c \
+	../../../genarch/ofw.c \
+	ofw.c \
+	asm.S \
+	boot.S
+
+COMPONENTS = \
+	$(KERNELDIR)/kernel.bin
+
+OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
+COMPONENT_OBJECTS := $(addsuffix .o,$(basename $(notdir $(COMPONENTS))))
+
+.PHONY: all clean depend
+
+all: image.boot
+
+-include Makefile.depend
+
+image.boot: depend _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) kernel.o 
+	$(LD) -no-check-sections -N -T _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) -o $@
+
+depend:
+	-makedepend $(DEFS) $(CFLAGS) -f - $(SOURCES) > Makefile.depend 2> /dev/null
+
+clean:
+	-rm -f _components.h _link.ld $(COMPONENT_OBJECTS) $(OBJECTS) image.boot Makefile.depend
+
+_components.h _link.ld $(COMPONENT_OBJECTS): $(COMPONENTS)
+	./pack $(IMAGE) $(OBJCOPY) $(COMPONENTS)
+
+%.o: %.S
+	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -c $< -o $@
+
+%.o: %.c
+	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
Index: arch/sparc64/loader/asm.S
===================================================================
--- arch/sparc64/loader/asm.S	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/asm.S	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,45 @@
+#
+# Copyright (C) 2006 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
+
+.global halt
+.global memcpy
+.global jump_to_kernel
+
+halt:
+	b halt
+	nop
+	
+memcpy:
+	b memcpy
+	nop
+
+jump_to_kernel:
+	b jump_to_kernel
+	nop
Index: arch/sparc64/loader/asm.h
===================================================================
--- arch/sparc64/loader/asm.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/asm.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2006 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 __ASM_H__
+#define __ASM_H__
+
+#define PAGE_SIZE 8192
+#define PAGE_WIDTH 13
+
+#define memcpy(dst, src, cnt)  __builtin_memcpy((dst), (src), (cnt))
+
+extern void halt(void);
+extern void jump_to_kernel(void *entry, void *bootinfo, unsigned int bootinfo_size) __attribute__((noreturn));
+
+#endif
Index: arch/sparc64/loader/boot.S
===================================================================
--- arch/sparc64/loader/boot.S	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/boot.S	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2006 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.
+#
+
+#define INITIAL_STACK 0x0
+
+.section BOOTSTRAP, "ax"
+
+.global start
+start:
+	# TODO: set initial stack
+	
+	b bootstrap
+	nop
Index: arch/sparc64/loader/main.c
===================================================================
--- arch/sparc64/loader/main.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/main.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,70 @@
+/*
+ * 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 "main.h" 
+#include <printf.h>
+#include "asm.h"
+#include "_components.h"
+
+#define KERNEL_VIRTUAL_ADDRESS 0x400000
+
+void bootstrap(void)
+{
+	printf("HelenOS SPARC64 Bootloader\n");
+	
+	component_t components[COMPONENTS];
+	bootinfo_t bootinfo;
+	init_components(components);
+	
+	printf("\nMemory statistics\n");
+	printf(" kernel entry point at %L\n", KERNEL_VIRTUAL_ADDRESS);
+	printf(" %L: 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("\nCopying components\n");
+	unsigned int top = 0;
+	bootinfo.cnt = 0;
+	for (i = 0; i < COMPONENTS; i++) {
+		printf(" %s...", components[i].name);
+		top = ALIGN_UP(top, PAGE_SIZE);
+		memcpy(((void *) KERNEL_VIRTUAL_ADDRESS) + top, components[i].start, components[i].size);
+		if (i > 0) {
+			bootinfo.tasks[bootinfo.cnt].addr = ((void *) KERNEL_VIRTUAL_ADDRESS) + top;
+			bootinfo.tasks[bootinfo.cnt].size = components[i].size;
+			bootinfo.cnt++;
+		}
+		top += components[i].size;
+		printf("done.\n");
+	}
+	
+	printf("\nBooting the kernel...\n");
+	jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, &bootinfo, sizeof(bootinfo));
+}
Index: arch/sparc64/loader/main.h
===================================================================
--- arch/sparc64/loader/main.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/main.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,54 @@
+/*
+ * 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 __MAIN_H__
+#define __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))
+
+#define TASKMAP_MAX_RECORDS 32
+
+typedef struct {
+	void *addr;
+	unsigned int size;
+} task_t;
+
+typedef struct {
+	unsigned int cnt;
+	task_t tasks[TASKMAP_MAX_RECORDS];
+} bootinfo_t;
+
+extern void start(void);
+extern void bootstrap(void);
+
+#endif
Index: arch/sparc64/loader/ofw.c
===================================================================
--- arch/sparc64/loader/ofw.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/ofw.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,35 @@
+/*
+ * 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)
+{
+	ofw_write(str, len);
+}
Index: arch/sparc64/loader/pack
===================================================================
--- arch/sparc64/loader/pack	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/pack	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,110 @@
+#! /bin/sh
+
+#
+# Copyright (C) 2006 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.
+#
+
+[ "$#" -lt 1 ] && exit 1
+
+OBJCOPY="$1"
+LINK="_link.ld"
+HEADER="_components.h"
+
+shift
+
+echo 'OUTPUT_FORMAT("elf64-sparc")
+ENTRY(start)
+
+SECTIONS {
+	.boot 0x4000: AT (0) {
+		*(BOOTSTRAP);
+		*(.text);
+		*(.rodata);
+		*(.rodata.*);
+		*(.data);               /* initialized data */
+		*(.sdata);
+		*(.sdata2);
+		*(.sbss);
+		*(.bss);                /* uninitialized static variables */
+		*(COMMON);' > "$LINK"
+
+echo '#ifndef ___COMPONENTS_H__
+#define ___COMPONENTS_H__
+
+typedef struct {
+	char *name;
+	
+	void *start;
+	void *end;
+	unsigned int size;
+} component_t;' > "$HEADER"
+
+COUNT="0"
+DATA=""
+
+for TASK in "$@" ; do
+	BASENAME="`basename "$TASK" | sed 's/^\(.*\)\.[^.]*$/\1/'`"
+	OBJECT="${BASENAME}.o"
+	SYMBOL="`echo "_binary_$TASK" | tr "./" "__"`"
+	MACRO="`echo "$BASENAME" | tr [:lower:] [:upper:]`"
+	echo "$TASK -> $OBJECT"
+	
+	echo "
+		. = ALIGN(8192);
+		*(.${BASENAME}_image);" >> "$LINK"
+	
+	echo "
+extern int ${SYMBOL}_start;
+extern int ${SYMBOL}_end;
+
+#define ${MACRO}_START ((void *) &${SYMBOL}_start)
+#define ${MACRO}_END ((void *) &${SYMBOL}_end)
+#define ${MACRO}_SIZE ((unsigned int) ${MACRO}_END - (unsigned int) ${MACRO}_START)" >> "$HEADER"
+	
+	"$OBJCOPY" -I binary -O elf64-sparc -B sparc --rename-section ".data=.${BASENAME}_image" "$TASK" "$OBJECT"
+		
+	DATA="${DATA}
+	components[$COUNT].name = \"${BASENAME}\";
+	components[$COUNT].start = ${MACRO}_START;
+	components[$COUNT].end = ${MACRO}_END;
+	components[$COUNT].size = ${MACRO}_SIZE;";
+	COUNT="`expr "$COUNT" + 1`"
+done
+
+echo '	}
+}' >> "$LINK"
+
+echo "
+#define COMPONENTS $COUNT
+
+static void init_components(component_t components[])
+{
+$DATA
+}
+
+#endif
+" >> "$HEADER"
Index: arch/sparc64/loader/types.h
===================================================================
--- arch/sparc64/loader/types.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
+++ arch/sparc64/loader/types.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2006 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 TYPES_H__
+#define TYPES_H__
+
+#include <gentypes.h>
+
+typedef signed char __s8;
+
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned int __u32;
+typedef unsigned long __u64;
+
+typedef __u64 __address;
+typedef __u64 __native;
+
+#endif
Index: genarch/ofw.c
===================================================================
--- genarch/ofw.c	(revision d22645e4c7c59d8de3b5151b7e9c72f593c52351)
+++ genarch/ofw.c	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -32,9 +32,4 @@
 
 #define MAX_OFW_ARGS		10
-#define BUF_SIZE		1024
-
-typedef unsigned int ofw_arg_t;
-typedef unsigned int ihandle;
-typedef unsigned int phandle;
 
 /** OpenFirmware command structure
@@ -50,18 +45,4 @@
 typedef void (*ofw_entry)(ofw_args_t *);
 
-
-typedef struct {
-	unsigned int info;
-	unsigned int addr_hi;
-    unsigned int addr_lo;
-} pci_addr_t;
-
-typedef struct {
-	pci_addr_t addr;
-    unsigned int size_hi;
-    unsigned int size_lo;
-} pci_reg_t;
-
-
 ofw_entry ofw;
 
@@ -100,5 +81,5 @@
 
 
-static phandle ofw_find_device(const char *name)
+phandle ofw_find_device(const char *name)
 {
 	return ofw_call("finddevice", 1, 1, NULL, name);
@@ -106,5 +87,5 @@
 
 
-static int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
+int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen)
 {
 	return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen);
@@ -205,6 +186,6 @@
 int ofw_memmap(memmap_t *map)
 {
-	unsigned int buf[BUF_SIZE];
-	int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(unsigned int) * BUF_SIZE);
+	unsigned long buf[BUF_SIZE];
+	int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf));
 	if (ret <= 0)
 		return false;
@@ -216,5 +197,5 @@
 	map->total = 0;
 	map->count = 0;
-	for (pos = 0; (pos < ret / sizeof(unsigned int)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
+	for (pos = 0; (pos < ret / sizeof(unsigned long)) && (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) {
 		void * start = (void *) buf[pos + ac - 1];
 		unsigned int size = buf[pos + ac + sc - 1];
@@ -234,5 +215,5 @@
 	char device_name[BUF_SIZE];
 	
-	if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(char) * BUF_SIZE) <= 0)
+	if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0)
 		return false;
 	
@@ -259,23 +240,2 @@
 }
 
-
-int ofw_keyboard(keyboard_t *keyboard)
-{
-	char device_name[BUF_SIZE];
-	
-	if (ofw_get_property(ofw_aliases, "macio", device_name, sizeof(char) * BUF_SIZE) <= 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;
-}
Index: genarch/ofw.h
===================================================================
--- genarch/ofw.h	(revision d22645e4c7c59d8de3b5151b7e9c72f593c52351)
+++ genarch/ofw.h	(revision b7b5f83ead84480fb41306eb3fdb4c6b2f2c628d)
@@ -30,14 +30,10 @@
 #define __OFW_H__
 
-#define NULL 0
-#define MEMMAP_MAX_RECORDS 32
-#define false 0
-#define true 1
+#include <types.h>
+#include <stdarg.h>
 
-typedef __builtin_va_list va_list;
+#define BUF_SIZE		1024
 
-#define va_start(ap, last) 		__builtin_va_start(ap, last)
-#define va_arg(ap, type) 		__builtin_va_arg(ap, type)
-#define va_end(ap)			__builtin_va_end(ap)
+#define MEMMAP_MAX_RECORDS 	32
 
 typedef struct {
@@ -65,7 +61,27 @@
 } keyboard_t;
 
+typedef struct {
+	unsigned int info;
+	unsigned int addr_hi;
+	unsigned int addr_lo;
+} pci_addr_t;
+
+typedef struct {
+	pci_addr_t addr;
+	unsigned int size_hi;
+	unsigned int size_lo;
+} pci_reg_t;
+
+typedef unsigned long ofw_arg_t;
+typedef unsigned int ihandle;
+typedef unsigned int phandle;
+
+extern phandle ofw_aliases;
 
 extern void init(void);
 extern void ofw_write(const char *str, const int len);
+
+extern int ofw_get_property(const phandle device, const char *name, const void *buf, const int buflen);
+extern phandle ofw_find_device(const char *name);
 
 extern void *ofw_translate(const void *virt);
