Index: boot/arch/sparc64/loader/main.c
===================================================================
--- boot/arch/sparc64/loader/main.c	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ boot/arch/sparc64/loader/main.c	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -58,19 +58,10 @@
 	}
 	
-	if (!ofw_screen(&bootinfo.screen)) {
-		printf("Error: unable to get screen properties, halting.\n");
-		halt();
-	}
-	bootinfo.screen.addr = ofw_translate(bootinfo.screen.addr);
-	/* transform scanline to bytes with respect to potential alignment */
-	bootinfo.screen.scanline = bootinfo.screen.scanline*bpp2align[bootinfo.screen.bpp >> 3];
-	
 	if (!ofw_cpu(&bootinfo.cpu))
 		printf("Error: unable to get cpu properties\n");
 
-	printf("\nDevice statistics\n");
+	printf("\nDevice info\n");
 	printf(" cpu: %dMHz\n", bootinfo.cpu.clock_frequency/1000000);
 	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("\nMemory statistics\n");
Index: boot/arch/sparc64/loader/main.h
===================================================================
--- boot/arch/sparc64/loader/main.h	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ boot/arch/sparc64/loader/main.h	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -54,5 +54,4 @@
 	taskmap_t taskmap;
 	memmap_t memmap;
-	screen_t screen;
 	cpu_t cpu;
 	ballocs_t ballocs;
Index: boot/arch/sparc64/loader/ofwarch.c
===================================================================
--- boot/arch/sparc64/loader/ofwarch.c	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ boot/arch/sparc64/loader/ofwarch.c	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -38,12 +38,4 @@
 #include "main.h"
 
-int bpp2align[] = {
-	[0] = 0,		/** Invalid bpp. */
-	[1] = 1,		/** 8bpp is not aligned. */
-	[2] = 2,		/** 16bpp is naturally aligned. */
-	[3] = 4,		/** 24bpp is aligned on 4 byte boundary. */
-	[4] = 4,		/** 32bpp is naturally aligned. */
-};
-
 void write(const char *str, const int len)
 {
@@ -60,25 +52,4 @@
 {
 	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: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/arch/sparc64/Makefile.inc	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -96,5 +96,6 @@
 	arch/$(ARCH)/src/ddi/ddi.c \
 	arch/$(ARCH)/src/drivers/tick.c \
-	arch/$(ARCH)/src/drivers/kbd.c
+	arch/$(ARCH)/src/drivers/kbd.c \
+	arch/$(ARCH)/src/drivers/scr.c
 
 ifeq ($(CONFIG_TSB),y)
Index: kernel/arch/sparc64/include/boot/boot.h
===================================================================
--- kernel/arch/sparc64/include/boot/boot.h	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/arch/sparc64/include/boot/boot.h	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -72,12 +72,4 @@
 
 typedef struct {
-	uintptr_t addr;
-	uint32_t width;
-	uint32_t height;
-	uint32_t bpp;
-	uint32_t scanline;
-} screen_t;
-
-typedef struct {
 	uint32_t clock_frequency;
 } processor_t;
@@ -90,5 +82,4 @@
 	taskmap_t taskmap;
 	memmap_t memmap;
-	screen_t screen;
 	processor_t processor;
 	ballocs_t ballocs;
Index: kernel/arch/sparc64/include/drivers/scr.h
===================================================================
--- kernel/arch/sparc64/include/drivers/scr.h	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
+++ kernel/arch/sparc64/include/drivers/scr.h	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup sparc64	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_sparc64_SCR_H_
+#define KERN_sparc64_SCR_H_
+
+#include <arch/types.h>
+#include <genarch/ofw/ofw_tree.h>
+
+typedef enum {
+	SCR_UNKNOWN,
+	SCR_ATYFB,
+	SCR_FFB
+} scr_type_t;
+
+extern scr_type_t scr_type;
+
+extern void scr_init(ofw_tree_node_t *node);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/sparc64/src/console.c
===================================================================
--- kernel/arch/sparc64/src/console.c	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/arch/sparc64/src/console.c	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -36,8 +36,8 @@
 #include <arch/types.h>
 #include <typedefs.h>
-#include <genarch/fb/fb.h>
-#include <arch/drivers/fb.h>
 
+#include <arch/drivers/scr.h>
 #include <arch/drivers/kbd.h>
+
 #ifdef CONFIG_Z8530
 #include <genarch/kbd/z8530.h>
@@ -53,5 +53,4 @@
 #include <proc/thread.h>
 #include <arch/mm/tlb.h>
-#include <arch/boot/boot.h>
 #include <genarch/ofw/ofw_tree.h>
 #include <arch.h>
@@ -84,7 +83,6 @@
 		panic("Can't find %s\n", prop->value);
 
-	fb_init(bootinfo.screen.addr, bootinfo.screen.width, bootinfo.screen.height,
-		bootinfo.screen.bpp, bootinfo.screen.scanline, true);
-	
+	scr_init(screen);
+
 	prop = ofw_tree_getprop(aliases, "keyboard");
 	if (!prop)
Index: kernel/arch/sparc64/src/drivers/scr.c
===================================================================
--- kernel/arch/sparc64/src/drivers/scr.c	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
+++ kernel/arch/sparc64/src/drivers/scr.c	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+/** @addtogroup sparc64	
+ * @{
+ */
+/** @file
+ */
+
+#include <arch/drivers/scr.h>
+#include <genarch/ofw/ofw_tree.h>
+#include <genarch/fb/fb.h>
+#include <arch/types.h>
+#include <typedefs.h>
+#include <func.h>
+#include <align.h>
+#include <print.h>
+
+scr_type_t scr_type = SCR_UNKNOWN;
+
+/** Initialize screen.
+ *
+ * Traverse OpenFirmware device tree in order to find necessary
+ * info about the screen device.
+ *
+ * @param node Screen device node.
+ */
+void scr_init(ofw_tree_node_t *node)
+{
+	ofw_tree_property_t *prop;
+	const char *name;
+	
+	name = ofw_tree_node_name(node);
+	
+	if (strcmp(name, "SUNW,m64B") == 0)
+		scr_type = SCR_ATYFB;
+	else if (strcmp(name, "SUNW,ffb") == 0)
+		scr_type = SCR_FFB;
+	
+	if (scr_type == SCR_UNKNOWN) {
+		printf("Unknown keyboard device.\n");
+		return;
+	}
+	
+	uintptr_t fb_addr;
+	uint32_t fb_width = 0;
+	uint32_t fb_height = 0;
+	uint32_t fb_depth = 0;
+	uint32_t fb_linebytes = 0;
+	uint32_t fb_scanline = 0;
+
+	prop = ofw_tree_getprop(node, "width");
+	if (prop && prop->value)
+		fb_width = *((uint32_t *) prop->value);
+
+	prop = ofw_tree_getprop(node, "height");
+	if (prop && prop->value)
+		fb_height = *((uint32_t *) prop->value);
+
+	prop = ofw_tree_getprop(node, "depth");
+	if (prop && prop->value)
+		fb_depth = *((uint32_t *) prop->value);
+
+	prop = ofw_tree_getprop(node, "linebytes");
+	if (prop && prop->value)
+		fb_linebytes = *((uint32_t *) prop->value);
+
+	prop = ofw_tree_getprop(node, "reg");
+	if (!prop)
+		panic("Can't find \"reg\" property.\n");
+
+	switch (scr_type) {
+	case SCR_ATYFB:
+		if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
+			printf("Too few screen registers.\n");
+			return;
+		}
+	
+		ofw_pci_reg_t *fb_reg = &((ofw_pci_reg_t *) prop->value)[1];
+		ofw_pci_reg_t abs_reg;
+		
+		if (!ofw_pci_reg_absolutize(node, fb_reg, &abs_reg)) {
+			printf("Failed to absolutize fb register.\n");
+			return;
+		}
+	
+		if (!ofw_pci_apply_ranges(node->parent, &abs_reg , &fb_addr)) {
+			printf("Failed to determine screen address.\n");
+			return;
+		}
+
+		if (fb_depth == 24)
+			fb_scanline = fb_linebytes * 4;
+		else
+			fb_scanline = fb_linebytes * (fb_depth >> 3);
+		
+		break;
+	case SCR_FFB:
+	default:
+		panic("Unexpected type.\n");
+	}
+
+	fb_init(fb_addr, fb_width, fb_height, fb_depth, fb_scanline, true);
+}
+
+/** @}
+ */
Index: kernel/genarch/include/ofw/ofw_tree.h
===================================================================
--- kernel/genarch/include/ofw/ofw_tree.h	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/genarch/include/ofw/ofw_tree.h	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -134,3 +134,5 @@
 extern bool ofw_ffb_apply_ranges(ofw_tree_node_t *node, ofw_ffb_reg_t *reg, uintptr_t *pa);
 
+extern bool ofw_pci_reg_absolutize(ofw_tree_node_t *node, ofw_pci_reg_t *reg, ofw_pci_reg_t *out);
+
 #endif
Index: kernel/genarch/src/ofw/pci.c
===================================================================
--- kernel/genarch/src/ofw/pci.c	(revision 28ecadba2f66309e3ea4c819f1e768f64d97b699)
+++ kernel/genarch/src/ofw/pci.c	(revision 5d684e4c0dde4f587dd5aca281c366f71f72853b)
@@ -42,5 +42,7 @@
 #include <macros.h>
 
-#define PCI_SPACE_MASK	0x03000000
+#define PCI_SPACE_MASK		0x03000000
+#define PCI_ABS_MASK		0x80000000	
+#define PCI_REG_MASK		0x000000ff
 
 bool ofw_pci_apply_ranges(ofw_tree_node_t *node, ofw_pci_reg_t *reg, uintptr_t *pa)
@@ -74,4 +76,39 @@
 }
 
+bool ofw_pci_reg_absolutize(ofw_tree_node_t *node, ofw_pci_reg_t *reg, ofw_pci_reg_t *out)
+{
+	if (reg->space & PCI_ABS_MASK) {
+		/* already absolute */
+		out->space = reg->space;
+		out->addr = reg->addr;
+		out->size = reg->size;
+		return true;
+	}
+	
+	ofw_tree_property_t *prop;
+	ofw_pci_reg_t *assigned_address;
+	count_t assigned_addresses;
+	
+	prop = ofw_tree_getprop(node, "assigned-addresses");
+	if (!prop)
+		panic("Can't find \"assigned-addresses\" property.\n");
+	
+	assigned_addresses = prop->size / sizeof(ofw_pci_reg_t);
+	assigned_address = prop->value;
+	
+	int i;
+	
+	for (i = 0; i < assigned_addresses; i++) {
+		if ((assigned_address[i].space & PCI_REG_MASK) == (reg->space & PCI_REG_MASK)) {
+			out->space = assigned_address[i].space;
+			out->addr = reg->addr + assigned_address[i].addr;
+			out->size = reg->size;
+			return true;
+		}
+	}
+	
+	return false;
+}
+
 /** @}
  */
