Index: kernel/arch/sparc64/src/drivers/fhc.c
===================================================================
--- kernel/arch/sparc64/src/drivers/fhc.c	(revision b366a6f4b86cb7fe82fcf415965c5a7de1a59638)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/*
- * 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
- * @brief	FireHose Controller (FHC) driver.
- *
- * Note that this driver is a result of reverse engineering
- * rather than implementation of a specification. This
- * is due to the fact that the FHC documentation is not
- * publicly available.
- */
-
-#include <arch/drivers/fhc.h>
-#include <arch/trap/interrupt.h>
-#include <mm/page.h>
-#include <mm/slab.h>
-#include <typedefs.h>
-#include <genarch/ofw/ofw_tree.h>
-#include <genarch/ofw/fhc.h>
-#include <sysinfo/sysinfo.h>
-
-fhc_t *central_fhc = NULL;
-
-/**
- * I suspect this must be hardcoded in the FHC.
- * If it is not, than we can read all IMAP registers
- * and get the complete mapping.
- */
-#define FHC_UART_INR	0x39	
-
-#define FHC_UART_IMAP	0x0
-#define FHC_UART_ICLR	0x4
-
-#define UART_IMAP_REG	4
-
-fhc_t *fhc_init(ofw_tree_node_t *node)
-{
-	fhc_t *fhc;
-	ofw_tree_property_t *prop;
-
-	prop = ofw_tree_getprop(node, "reg");
-	
-	if (!prop || !prop->value)
-		return NULL;
-		
-	size_t regs = prop->size / sizeof(ofw_central_reg_t);
-	if (regs + 1 < UART_IMAP_REG)
-		return NULL;
-
-	ofw_central_reg_t *reg = &((ofw_central_reg_t *) prop->value)[UART_IMAP_REG];
-
-	uintptr_t paddr;
-	if (!ofw_central_apply_ranges(node->parent, reg, &paddr))
-		return NULL;
-
-	fhc = (fhc_t *) malloc(sizeof(fhc_t), FRAME_ATOMIC);
-	if (!fhc)
-		return NULL;
-
-	fhc->uart_imap = (uint32_t *) hw_map(paddr, reg->size);
-	
-	/*
-	 * Set sysinfo data needed by the uspace FHC driver.
-	 */
-	sysinfo_set_item_val("fhc.uart.size", NULL, reg->size);
-	sysinfo_set_item_val("fhc.uart.physical", NULL, paddr);
-	sysinfo_set_item_val("kbd.cir.fhc", NULL, 1);
-
-	return fhc;
-}
-
-void fhc_enable_interrupt(fhc_t *fhc, int inr)
-{
-	switch (inr) {
-	case FHC_UART_INR:
-		fhc->uart_imap[FHC_UART_IMAP] |= IMAP_V_MASK;
-		break;
-	default:
-		panic("Unexpected INR (%d).", inr);
-		break;
-	}
-}
-
-void fhc_clear_interrupt(void *fhcp, int inr)
-{
-	fhc_t *fhc = (fhc_t *)fhcp;
-	ASSERT(fhc->uart_imap);
-
-	switch (inr) {
-	case FHC_UART_INR:
-		fhc->uart_imap[FHC_UART_ICLR] = 0;
-		break;
-	default:
-		panic("Unexpected INR (%d).", inr);
-		break;
-	}
-}
-
-/** @}
- */
Index: kernel/arch/sparc64/src/drivers/kbd.c
===================================================================
--- kernel/arch/sparc64/src/drivers/kbd.c	(revision b366a6f4b86cb7fe82fcf415965c5a7de1a59638)
+++ kernel/arch/sparc64/src/drivers/kbd.c	(revision 3f08fd2b9072227f3006fed60b75c6f38e7ac5d9)
@@ -35,5 +35,4 @@
 #include <arch/drivers/kbd.h>
 #include <genarch/ofw/ofw_tree.h>
-#include <genarch/ofw/fhc.h>
 #include <genarch/ofw/ebus.h>
 #include <console/console.h>
@@ -51,8 +50,4 @@
 #endif
 
-#ifdef CONFIG_Z8530
-#include <genarch/drivers/z8530/z8530.h>
-#endif
-
 #ifdef CONFIG_NS16550
 #include <genarch/drivers/ns16550/ns16550.h>
@@ -60,90 +55,4 @@
 
 #ifdef CONFIG_SUN_KBD
-
-#ifdef CONFIG_Z8530
-
-static bool kbd_z8530_init(ofw_tree_node_t *node)
-{
-	const char *name = ofw_tree_node_name(node);
-	
-	if (str_cmp(name, "zs") != 0)
-		return false;
-	
-	/*
-	 * Read 'interrupts' property.
-	 */
-	ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts");
-	if ((!prop) || (!prop->value)) {
-		printf("z8530: Unable to find interrupts property\n");
-		return false;
-	}
-	
-	uint32_t interrupts = *((uint32_t *) prop->value);
-	
-	/*
-	 * Read 'reg' property.
-	 */
-	prop = ofw_tree_getprop(node, "reg");
-	if ((!prop) || (!prop->value)) {
-		printf("z8530: Unable to find reg property\n");
-		return false;
-	}
-	
-	size_t size = ((ofw_fhc_reg_t *) prop->value)->size;
-	
-	uintptr_t pa;
-	if (!ofw_fhc_apply_ranges(node->parent,
-	    ((ofw_fhc_reg_t *) prop->value), &pa)) {
-		printf("z8530: Failed to determine address\n");
-		return false;
-	}
-	
-	inr_t inr;
-	cir_t cir;
-	void *cir_arg;
-	if (!ofw_fhc_map_interrupt(node->parent,
-	    ((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir,
-	    &cir_arg)) {
-		printf("z8530: Failed to determine interrupt\n");
-		return false;
-	}
-	
-	/*
-	 * We need to pass aligned address to hw_map().
-	 * However, the physical keyboard address can
-	 * be pretty much unaligned, depending on the
-	 * underlying controller.
-	 */
-	uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE);
-	size_t offset = pa - aligned_addr;
-	
-	z8530_t *z8530 = (z8530_t *)
-	    (hw_map(aligned_addr, offset + size) + offset);
-	
-	z8530_instance_t *z8530_instance = z8530_init(z8530, inr, cir, cir_arg);
-	if (z8530_instance) {
-		kbrd_instance_t *kbrd_instance = kbrd_init();
-		if (kbrd_instance) {
-			indev_t *sink = stdin_wire();
-			indev_t *kbrd = kbrd_wire(kbrd_instance, sink);
-			z8530_wire(z8530_instance, kbrd);
-		}
-	}
-	
-	/*
-	 * This is the necessary evil until the userspace drivers are
-	 * entirely self-sufficient.
-	 */
-	sysinfo_set_item_val("kbd", NULL, true);
-	sysinfo_set_item_val("kbd.inr", NULL, inr);
-	sysinfo_set_item_val("kbd.address.kernel", NULL,
-	    (uintptr_t) z8530);
-	sysinfo_set_item_val("kbd.address.physical", NULL, pa);
-	sysinfo_set_item_val("kbd.type.z8530", NULL, true);
-	
-	return true;
-}
-
-#endif /* CONFIG_Z8530 */
 
 #ifdef CONFIG_NS16550
@@ -243,8 +152,4 @@
 void kbd_init(ofw_tree_node_t *node)
 {
-#ifdef CONFIG_Z8530
-	kbd_z8530_init(node);
-#endif
-	
 #ifdef CONFIG_NS16550
 	kbd_ns16550_init(node);
Index: kernel/arch/sparc64/src/drivers/sgcn.c
===================================================================
--- kernel/arch/sparc64/src/drivers/sgcn.c	(revision b366a6f4b86cb7fe82fcf415965c5a7de1a59638)
+++ 	(revision )
@@ -1,359 +1,0 @@
-/*
- * Copyright (c) 2008 Pavel Rimsky
- * 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
- * @brief SGCN driver.
- */
-
-#include <arch.h>
-#include <arch/drivers/sgcn.h>
-#include <arch/drivers/kbd.h>
-#include <genarch/ofw/ofw_tree.h>
-#include <debug.h>
-#include <str.h>
-#include <print.h>
-#include <mm/page.h>
-#include <proc/thread.h>
-#include <console/chardev.h>
-#include <console/console.h>
-#include <sysinfo/sysinfo.h>
-#include <synch/spinlock.h>
-
-#define POLL_INTERVAL  10000
-
-/*
- * Physical address at which the SBBC starts. This value has been obtained
- * by inspecting (using Simics) memory accesses made by OBP. It is valid
- * for the Simics-simulated Serengeti machine. The author of this code is
- * not sure whether this value is valid generally. 
- */
-#define SBBC_START  0x63000000000
-
-/* offset of SRAM within the SBBC memory */
-#define SBBC_SRAM_OFFSET  0x900000
-
-/* size (in bytes) of the physical memory area which will be mapped */
-#define MAPPED_AREA_SIZE  (128 * 1024)
-
-/* magic string contained at the beginning of SRAM */
-#define SRAM_TOC_MAGIC  "TOCSRAM"
-
-/*
- * Key into the SRAM table of contents which identifies the entry
- * describing the OBP console buffer. It is worth mentioning
- * that the OBP console buffer is not the only console buffer
- * which can be used. It is, however, used because when the kernel
- * is running, the OBP buffer is not used by OBP any more but OBP
- * has already made necessary arrangements so that the output will
- * be read from the OBP buffer and input will go to the OBP buffer.
- * Therefore HelenOS needs to make no such arrangements any more.
- */
-#define CONSOLE_KEY  "OBPCONS"
-
-/* magic string contained at the beginning of the console buffer */
-#define SGCN_BUFFER_MAGIC  "CON"
-
-/*
- * Returns a pointer to the object of a given type which is placed at the given
- * offset from the SRAM beginning.
- */
-#define SRAM(type, offset)  ((type *) (instance->sram_begin + (offset)))
-
-/* Returns a pointer to the SRAM table of contents. */
-#define SRAM_TOC  (SRAM(iosram_toc_t, 0))
-
-/*
- * Returns a pointer to the object of a given type which is placed at the given
- * offset from the console buffer beginning.
- */
-#define SGCN_BUFFER(type, offset) \
-	((type *) (instance->buffer_begin + (offset)))
-
-/** Returns a pointer to the console buffer header. */
-#define SGCN_BUFFER_HEADER  (SGCN_BUFFER(sgcn_buffer_header_t, 0))
-
-static void sgcn_putchar(outdev_t *, const wchar_t);
-
-static outdev_operations_t sgcndev_ops = {
-	.write = sgcn_putchar,
-	.redraw = NULL
-};
-
-static sgcn_instance_t *instance = NULL;
-
-/** Initialize the starting address of SRAM.
- *
- * The SRAM starts 0x900000 + C bytes behind the SBBC start in the
- * physical memory, where C is the value read from the "iosram-toc"
- * property of the "/chosen" OBP node. The sram_begin variable will
- * be set to the virtual address which maps to the SRAM physical
- * address.
- *
- */
-static void init_sram_begin(void)
-{
-	ASSERT(instance);
-	
-	ofw_tree_node_t *chosen = ofw_tree_lookup("/chosen");
-	if (!chosen)
-		panic("Cannot find '/chosen'.");
-	
-	ofw_tree_property_t *iosram_toc =
-	    ofw_tree_getprop(chosen, "iosram-toc");
-	if (!iosram_toc)
-		panic("Cannot find property 'iosram-toc'.");
-	if (!iosram_toc->value)
-		panic("Cannot find SRAM TOC.");
-	
-	uintptr_t sram_begin_physical = SBBC_START + SBBC_SRAM_OFFSET
-	    + *((uint32_t *) iosram_toc->value);
-	instance->sram_begin = hw_map(sram_begin_physical, MAPPED_AREA_SIZE);
-	
-	link_initialize(&instance->parea.link);
-	instance->parea.pbase = sram_begin_physical;
-	instance->parea.frames = SIZE2FRAMES(MAPPED_AREA_SIZE);
-	instance->parea.unpriv = false;
-	instance->parea.mapped = false;
-	ddi_parea_register(&instance->parea);
-	
-	sysinfo_set_item_val("sram.area.size", NULL, MAPPED_AREA_SIZE);
-	sysinfo_set_item_val("sram.address.physical", NULL,
-	    sram_begin_physical);
-}
-
-/** Get unread characters from the input queue.
- *
- * Check for unread characters in the input queue.
- *
- */
-static void sgcn_poll(sgcn_instance_t *instance)
-{
-	uint32_t begin = SGCN_BUFFER_HEADER->in_begin;
-	uint32_t end = SGCN_BUFFER_HEADER->in_end;
-	uint32_t size = end - begin;
-	
-	if ((instance->parea.mapped) && (!console_override))
-		return;
-	
-	spinlock_lock(&instance->input_lock);
-	
-	/* We need pointers to volatile variables */
-	volatile char *buf_ptr = (volatile char *)
-	    SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr);
-	volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr);
-	volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr);
-	
-	while (*in_rdptr_ptr != *in_wrptr_ptr) {
-		buf_ptr = (volatile char *)
-		    SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr);
-		char c = *buf_ptr;
-		*in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin;
-		
-		indev_push_character(instance->srlnin, c);
-	}
-	
-	spinlock_unlock(&instance->input_lock);
-}
-
-/** Polling thread function.
- *
- */
-static void ksgcnpoll(void *instance) {
-	while (true) {
-		sgcn_poll(instance);
-		thread_usleep(POLL_INTERVAL);
-	}
-}
-
-/** Initialize the starting address of the SGCN buffer.
- *
- * The offset of the SGCN buffer within SRAM is obtained from the
- * SRAM table of contents. The table of contents contains
- * information about several buffers, among which there is an OBP
- * console buffer -- this one will be used as the SGCN buffer.
- *
- * This function also writes the offset of the SGCN buffer within SRAM
- * under the sram.buffer.offset sysinfo key.
- *
- */
-static void sgcn_init(void)
-{
-	if (instance)
-		return;
-	
-	instance = malloc(sizeof(sgcn_instance_t), FRAME_ATOMIC);
-	
-	if (instance) {
-		instance->thread = thread_create(ksgcnpoll, instance, TASK, 0,
-		    "ksgcnpoll", true);
-		
-		if (!instance->thread) {
-			free(instance);
-			instance = NULL;
-			return;
-		}
-		
-		init_sram_begin();
-		
-		ASSERT(str_cmp(SRAM_TOC->magic, SRAM_TOC_MAGIC) == 0);
-		
-		/* Lookup TOC entry with the correct key */
-		uint32_t i;
-		for (i = 0; i < MAX_TOC_ENTRIES; i++) {
-			if (str_cmp(SRAM_TOC->keys[i].key, CONSOLE_KEY) == 0)
-				break;
-		}
-		ASSERT(i < MAX_TOC_ENTRIES);
-		
-		instance->buffer_begin =
-		    instance->sram_begin + SRAM_TOC->keys[i].offset;
-		
-		sysinfo_set_item_val("sram.buffer.offset", NULL,
-		    SRAM_TOC->keys[i].offset);
-		
-		instance->srlnin = NULL;
-	}
-}
-
-/** Write a single character to the SGCN output buffer
- *
- * Write a single character to the SGCN (circular) output buffer
- * and update the output write pointer so that SGCN gets to know
- * that the character has been written.
- *
- */
-static void sgcn_do_putchar(const char c)
-{
-	uint32_t begin = SGCN_BUFFER_HEADER->out_begin;
-	uint32_t end = SGCN_BUFFER_HEADER->out_end;
-	uint32_t size = end - begin;
-	
-	/* We need pointers to volatile variables */
-	volatile char *buf_ptr = (volatile char *)
-	    SGCN_BUFFER(char, SGCN_BUFFER_HEADER->out_wrptr);
-	volatile uint32_t *out_wrptr_ptr = &(SGCN_BUFFER_HEADER->out_wrptr);
-	volatile uint32_t *out_rdptr_ptr = &(SGCN_BUFFER_HEADER->out_rdptr);
-	
-	/*
-	 * Write the character and increment the write pointer modulo the
-	 * output buffer size. Note that if we are to rewrite a character
-	 * which has not been read by the SGCN controller yet (i.e. the output
-	 * buffer is full), we need to wait until the controller reads some more
-	 * characters. We wait actively, which means that all threads waiting
-	 * for the lock are blocked. However, this situation is
-	 *   1) rare - the output buffer is big, so filling the whole
-	 *             output buffer is improbable
-	 *   2) short-lasting - it will take the controller only a fraction
-	 *             of millisecond to pick the unread characters up
-	 *   3) not serious - the blocked threads are those that print something
-	 *             to user console, which is not a time-critical operation
-	 */
-	uint32_t new_wrptr = (((*out_wrptr_ptr) - begin + 1) % size) + begin;
-	while (*out_rdptr_ptr == new_wrptr);
-	
-	*buf_ptr = c;
-	*out_wrptr_ptr = new_wrptr;
-}
-
-/** SGCN output operation
- *
- * Print a single character to the SGCN. Newline
- * character is converted to CRLF.
- *
- */
-static void sgcn_putchar(outdev_t *dev, const wchar_t ch)
-{
-	if ((!instance->parea.mapped) || (console_override)) {
-		spinlock_lock(&instance->output_lock);
-		
-		if (ascii_check(ch)) {
-			if (ch == '\n')
-				sgcn_do_putchar('\r');
-			sgcn_do_putchar(ch);
-		} else
-			sgcn_do_putchar(U_SPECIAL);
-		
-		spinlock_unlock(&instance->output_lock);
-	}
-}
-
-/** Initialize input from the Serengeti console.
- *
- */
-sgcn_instance_t *sgcnin_init(void)
-{
-	sgcn_init();
-	return instance;
-}
-
-void sgcnin_wire(sgcn_instance_t *instance, indev_t *srlnin)
-{
-	ASSERT(instance);
-	ASSERT(srlnin);
-	
-	instance->srlnin = srlnin;
-	thread_ready(instance->thread);
-	
-	sysinfo_set_item_val("kbd", NULL, true);
-}
-
-/** Initialize output to the Serengeti console.
- *
- */
-outdev_t *sgcnout_init(void)
-{
-	sgcn_init();
-	if (!instance)
-		return NULL;
-	
-	outdev_t *sgcndev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
-	if (!sgcndev)
-		return NULL;
-	
-	outdev_initialize("sgcndev", sgcndev, &sgcndev_ops);
-	sgcndev->data = instance;
-	
-	if (!fb_exported) {
-		/*
-		 * This is the necessary evil until the userspace driver is entirely
-		 * self-sufficient.
-		 */
-		sysinfo_set_item_val("fb.kind", NULL, 4);
-		
-		fb_exported = true;
-	}
-	
-	return sgcndev;
-}
-
-/** @}
- */
