Index: kernel/arch/mips32/Makefile.inc
===================================================================
--- kernel/arch/mips32/Makefile.inc	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/Makefile.inc	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -57,18 +57,4 @@
 #
 
-ifeq ($(MACHINE),indy)
-	# GCC 4.0.1 compiled for mipsEL has problems compiling in 
-	# BigEndian mode with the swl/swr/lwl/lwr instructions.
-	# We have to compile it with mips-sgi-irix5 to get it right.
-	
-	BFD_NAME = elf32-bigmips
-	BFD = ecoff-bigmips --impure
-	TARGET = mips-sgi-irix5
-	TOOLCHAIN_DIR = /usr/local/mips/bin
-	KERNEL_LOAD_ADDRESS = 0x88002000
-	GCC_CFLAGS += -EB -DBIG_ENDIAN -DARCH_HAS_FPU -march=r4600
-	INIT_ADDRESS = 0
-	INIT_SIZE = 0
-endif
 ifeq ($(MACHINE),lgxemul)
 	BFD_NAME = elf32-tradlittlemips
@@ -124,5 +110,4 @@
 	arch/$(ARCH)/src/fpu_context.c \
 	arch/$(ARCH)/src/ddi/ddi.c \
-	arch/$(ARCH)/src/drivers/arc.c \
 	arch/$(ARCH)/src/drivers/msim.c \
 	arch/$(ARCH)/src/drivers/serial.c \
Index: kernel/arch/mips32/include/drivers/arc.h
===================================================================
--- kernel/arch/mips32/include/drivers/arc.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ 	(revision )
@@ -1,267 +1,0 @@
-/*
- * Copyright (c) 2005 Ondrej Palkovsky
- * 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 mips32	
- * @{
- */
-/** @file
- */
-
-#ifndef KERN_mips32_ARC_H_
-#define KERN_mips32_ARC_H_
-
-#include <arch/types.h>
-#include <console/chardev.h>
-
-#define ARC_BASE_ADDR 0x1000;
-#define ARC_MAGIC 0x53435241
-/* Frame size used by ARC */
-#define ARC_FRAME 4096
-
-typedef enum {
-	CmResourceTypeNull = 0,
-	CmResourceTypePort,
-	CmResourceTypeInterrupt,
-	CmResourceTypeMemory,
-	CmResourceTypeDma,
-	CmResourceTypeDeviceSpecific,
-	CmResourceTypeVendor,
-	CmResourceTypeProductName,
-	CmResourceTypeSerialNumber
-} cm_resource_type;
-
-typedef struct {
-	uint8_t type;
-	uint8_t sharedisposition;
-	uint16_t flags;
-	union {
-		struct {
-			long long start; /* 64-bit phys address */
-			unsigned long length;
-		}port;
-		struct {
-			unsigned long level;
-			unsigned long vector;
-			unsigned long reserved1;
-		}interrupt;
-		struct {
-			long long start; /* 64-bit phys address */
-			unsigned long length;
-		}memory;
-	}u;
-} __attribute__ ((packed)) cm_resource_descriptor;
-
-typedef struct {
-	uint16_t version;
-	uint16_t revision;
-	unsigned long count;
-	cm_resource_descriptor descr[1];
-} __attribute__ ((packed)) cm_resource_list;
-
-typedef enum {
-	SystemClass = 0,
-	ProcessorClass,
-	CacheClass,
-	AdapterClass,
-	ControllerClass,
-	PeripheralClass,
-	MemoryClass
-} arc_component_class;
-
-typedef enum {
-	ARC_type = 0,
-	CPU_type,
-	FPU_type,
-	PrimaryICache,
-	PrimaryDCache,
-	SecondaryICache,
-	SecondaryDCache,
-	SecondaryCache,
-	Memory, /* Not in NT PROM */
-	EISAAdapter,
-	TCAdapter,
-	SCSIAdapter,
-	DTIAdapter,
-	MultiFunctionAdapter,
-	DiskController,
-	TapeController,
-	CDROMController,
-	WORMController,
-	SerialController,
-	NetworkController,
-	DisplayController,
-	ParallelController,
-	PointerController,
-	KeyboardController,
-	AudioController,
-	OtherController,
-	DiskPeripheral,
-	FloppyDiskPeripheral,
-	TapePeripheral,
-	ModemPeripheral,
-	MonitorPeripheral,
-	PrinterPeripheral,
-	PointerPeripheral,
-	KeyboardPeripheral,
-	TerminalPeripheral,
-	LinePeripheral,
-	NetworkPeripheral,
-	OtherPeripheral,
-	XTalkAdapter,
-	PCIAdapter,
-	GIOAdapter,
-	TPUAdapter,
-	Anonymous
-} arc_component_type;
-
-typedef enum {
-	Failed = 1,
-	ReadOnly = 2,
-	Removable = 4,
-	ConsoleIn = 8,
-	ConsoleOut = 16,
-	Input = 32,
-	Output = 64
-} arc_component_flags;
-
-typedef struct  {
-	arc_component_class class;
-	arc_component_type type;
-	arc_component_flags flags;
-	uint16_t revision;
-	uint16_t version;
-	uint32_t key;
-	uint32_t affinitymask;
-	uint32_t configdatasize;
-	uint32_t identifier_len;
-	char *identifier;
-} __attribute__ ((packed)) arc_component;
-
-typedef struct {
-	uint16_t year;
-	uint16_t month;
-	uint16_t day;
-	uint16_t hour;
-	uint16_t minutes;
-	uint16_t seconds;
-	uint16_t mseconds;
-} __attribute__ ((packed)) arc_timeinfo;
-
-/* This is the SGI block structure, WinNT has it different */
-typedef enum {
-	ExceptionBlock,
-	SystemParameterBlock,
-	FreeContiguous,
-	FreeMemory,
-	BadMemory,
-	LoadedProgram,
-	FirmwareTemporary,
-	FirmwarePermanent
-} arc_memorytype_t;
-
-typedef struct  {
-	arc_memorytype_t type;
-	uint32_t basepage;  /* *4096 = baseaddr */
-	uint32_t basecount;
-} arc_memdescriptor_t;
-
-typedef struct {
-	char vendorid[8];
-	char prodid[8];
-} arc_sysid_t;
-
-typedef struct {
-	long (*load)(void); /* ... */
-	long (*invoke)(uint32_t eaddr,uint32_t saddr,uint32_t argc,char **argv,
-		       char **envp);
-	long (*execute)(char *path,uint32_t argc,char **argv,char **envp);
-	void (*halt)(void);
-	void (*powerdown)(void);
-	void (*restart)(void);
-	void (*reboot)(void);
-	void (*enterinteractivemode)(void);
-	long (*reserved)(void);
-/* 10 */	
-	arc_component * (*getpeer)(arc_component *c); 
-	arc_component * (*getchild)(arc_component *c);
-	arc_component * (*getparent)(arc_component *c);
-	long (*getconfigurationdata)(void *configdata, arc_component *c);
-	long (*addchild)(arc_component *c, arc_component *template,
-			 void *configdata);
-	long (*deletecomponet)(arc_component *current);
-	long (*getcomponent)(char *path);
-	long (*saveconfiguration)(void);
-	arc_sysid_t (*getsystemid)(void);
-	arc_memdescriptor_t * (*getmemorydescriptor)(arc_memdescriptor_t *cur);
-/* 20 */
-	long (*reserved2)(void);
-	arc_timeinfo * (*gettime)(void);
-	uint32_t (*getrelativetime)(void);
-	long (*getdirectoryentry)();
-	long (*open)(void); /* ... */
-	long (*close)(uint32_t fileid);
-	long (*read)(uint32_t fileid,void *buf,uint32_t n,uint32_t *cnt);
-	long (*getreadstatus)(uint32_t fileid);
-	long (*write)(uint32_t fileid, void *buf,uint32_t n,uint32_t *cnt);
-	long (*seek)(void); /* ... */
-/* 30 */
-	long (*mount)(void); /* ... */
-	char * (*getenvironmentvariable)(char *name);
-	char * (*setenvironmentvariable)(char *name, char *value);
-	long (*getfileinformation)(void); /* ... */
-	long (*setfileinformation)(uint32_t fileid,uint32_t attflags,uint32_t attmask);
-	void (*flushallcaches)(void);
-	long (*testunicodecharacter)(void); /* ... */
-	long (*getdisplaystatus)(void); /* ... */
-} arc_func_vector_t;
-
-typedef struct {
-	uint32_t signature;
-	uint32_t length;
-	uint16_t version;
-	uint16_t revision;
-	void *restartblock;
-	void *debugblock;
-	void *gevector;
-	void *utlbmissvector;
-	uint32_t firmwarevectorlen;
-	arc_func_vector_t *firmwarevector;
-	uint32_t privvectorlen;
-	void *privvector;
-	uint32_t adaptercount;
-} __attribute__ ((packed)) arc_sbp;
-
-extern int arc_init(void);
-extern int arc_reboot(void);
-extern int arc_frame_init(void);
-extern int arc_console(void);
-
-#endif
-
- /** @}
- */
Index: kernel/arch/mips32/include/drivers/msim.h
===================================================================
--- kernel/arch/mips32/include/drivers/msim.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/include/drivers/msim.h	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -36,4 +36,9 @@
 #define KERN_mips32_MSIM_H_
 
+/** Address of devices. */
+#define MSIM_VIDEORAM		0xB0000000
+#define MSIM_KBD_ADDRESS	0xB0000000
+#define MSIM_KBD_IRQ 		2
+
 #include <console/chardev.h>
 
Index: kernel/arch/mips32/include/drivers/serial.h
===================================================================
--- kernel/arch/mips32/include/drivers/serial.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/include/drivers/serial.h	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -38,4 +38,6 @@
 #include <console/chardev.h>
 
+#define SERIAL_ADDRESS    0xB8000000
+
 #define SERIAL_MAX        4
 #define SERIAL_COM1       0x3f8
@@ -44,14 +46,17 @@
 #define SERIAL_COM2_IRQ   3
 
-#define P_WRITEB(where,what)     (*((volatile char *) (0xB8000000+where))=what)
-#define P_READB(where)           (*((volatile char *)(0xB8000000+where)))
+#define P_WRITEB(where, what)     (*((volatile char *) (SERIAL_ADDRESS + where)) = what)
+#define P_READB(where)            (*((volatile char *) (SERIAL_ADDRESS + where)))
 
-#define SERIAL_READ(x)           P_READB(x)
-#define SERIAL_WRITE(x,c)        P_WRITEB(x,c)
+#define SERIAL_READ(x)            P_READB(x)
+#define SERIAL_WRITE(x, c)        P_WRITEB(x, c)
+
 /* Interrupt enable register */
 #define SERIAL_READ_IER(x)              (P_READB((x) + 1))
-#define SERIAL_WRITE_IER(x,c)           (P_WRITEB((x)+1,c))
+#define SERIAL_WRITE_IER(x,c)           (P_WRITEB((x) + 1, c))
+
 /* Interrupt identification register */
 #define SERIAL_READ_IIR(x)             (P_READB((x) + 2))
+
 /* Line status register */
 #define SERIAL_READ_LSR(x)             (P_READB((x) + 5))
Index: kernel/arch/mips32/include/mm/as.h
===================================================================
--- kernel/arch/mips32/include/mm/as.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/include/mm/as.h	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -39,5 +39,5 @@
 
 #define KERNEL_ADDRESS_SPACE_START_ARCH		(unsigned long) 0x80000000
-#define KERNEL_ADDRESS_SPACE_END_ARCH		(unsigned long) 0xffffffff
+#define KERNEL_ADDRESS_SPACE_END_ARCH		(unsigned long) 0x9fffffff
 #define USER_ADDRESS_SPACE_START_ARCH		(unsigned long) 0x00000000
 #define USER_ADDRESS_SPACE_END_ARCH		(unsigned long) 0x7fffffff
Index: kernel/arch/mips32/include/mm/tlb.h
===================================================================
--- kernel/arch/mips32/include/mm/tlb.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/include/mm/tlb.h	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -36,4 +36,7 @@
 #define KERN_mips32_TLB_H_
 
+#include <arch/types.h>
+#include <typedefs.h>
+#include <arch/mm/asid.h>
 #include <arch/exception.h>
 
@@ -47,5 +50,5 @@
 #define TLB_KSTACK_WIRED_INDEX	0
 
-#define TLB_PAGE_MASK_16K	(0x3<<13)
+#define TLB_PAGE_MASK_16K	(0x3 << 13)
 
 #define PAGE_UNCACHED			2
@@ -160,4 +163,6 @@
 extern void tlb_refill(istate_t *istate);
 extern void tlb_modified(istate_t *istate);
+extern void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn);
+extern void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr);
 
 #endif
Index: kernel/arch/mips32/src/console.c
===================================================================
--- kernel/arch/mips32/src/console.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/console.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -35,5 +35,4 @@
 #include <console/console.h>
 #include <arch/console.h>
-#include <arch/drivers/arc.h>
 #include <arch/drivers/serial.h>
 #include <arch/drivers/msim.h>
@@ -41,10 +40,8 @@
 void console_init(devno_t devno)
 {
-	if (!arc_console()) {
-		if (serial_init())
-			serial_console(devno);
-		else
-			msim_console(devno);
-	}
+	if (serial_init())
+		serial_console(devno);
+	else
+		msim_console(devno);
 }
 
Index: kernel/arch/mips32/src/drivers/arc.c
===================================================================
--- kernel/arch/mips32/src/drivers/arc.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ 	(revision )
@@ -1,394 +1,0 @@
-/*
- * Copyright (c) 2005 Ondrej Palkovsky
- * 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 mips32	
- * @{
- */
-/** @file
- */
-
-#include <arch/drivers/arc.h>
-#include <arch/mm/page.h>
-#include <print.h>
-#include <arch.h>
-#include <byteorder.h>
-#include <arch/mm/frame.h>
-#include <mm/frame.h>
-#include <interrupt.h>
-#include <align.h>
-#include <console/console.h>
-#include <console/kconsole.h>
-#include <console/cmd.h>
-#include <mm/slab.h>
-
-/* This is a good joke, SGI HAS different types than NT bioses... */
-/* Here is the SGI type */
-static char *basetypes[] = {
-	"ExceptionBlock",
-	"SystemParameterBlock",
-	"FreeContiguous",
-	"FreeMemory",
-	"BadMemory",
-	"LoadedProgram",
-	"FirmwareTemporary",
-	"FirmwarePermanent"
-};
-
-static char *ctypes[] = {
-	"ARC_type",
-	"CPU_type",
-	"FPU_type",
-	"PrimaryICache",
-	"PrimaryDCache",
-	"SecondaryICache",
-	"SecondaryDCache",
-	"SecondaryCache",
-	"Memory",
-	"EISAAdapter",
-	"TCAdapter",
-	"SCSIAdapter",
-	"DTIAdapter",
-	"MultiFunctionAdapter",
-	"DiskController",
-	"TapeController",
-	"CDROMController",
-	"WORMController",
-	"SerialController",
-	"NetworkController",
-	"DisplayController",
-	"ParallelController",
-	"PointerController",
-	"KeyboardController",
-	"AudioController",
-	"OtherController",
-	"DiskPeripheral",
-	"FloppyDiskPeripheral",
-	"TapePeripheral",
-	"ModemPeripheral",
-	"MonitorPeripheral",
-	"PrinterPeripheral",
-	"PointerPeripheral",
-	"KeyboardPeripheral",
-	"TerminalPeripheral",
-	"OtherPeripheral",
-	"LinePeripheral",
-	"NetworkPeripheral"
-	"OtherPeripheral",
-	"XTalkAdapter",
-	"PCIAdapter",
-	"GIOAdapter",
-	"TPUAdapter",
-	"Anonymous"
-};
-
-static arc_sbp *sbp = (arc_sbp *) PA2KA(0x1000);
-static arc_func_vector_t *arc_entry; 
-
-
-/** Return true if ARC is available */
-#define arc_enabled() (sbp != NULL)
-
-
-/** Print configuration data that ARC reports about component */
-static void arc_print_confdata(arc_component *c)
-{
-	cm_resource_list *configdata;
-	unsigned int i;
-
-	if (!c->configdatasize)
-		return; /* No configuration data */
-
-	configdata = malloc(c->configdatasize, 0);
-
-	if (arc_entry->getconfigurationdata(configdata, c)) {
-		free(configdata);
-		return;
-	}
-	/* Does not seem to return meaningful data, don't use now */
-	free(configdata);
-	return;
-	
-	for (i = 0; i < configdata->count; i++) {
-		switch (configdata->descr[i].type) {
-		case CmResourceTypePort:
-			printf("Port: %p-size:%d ",
-			       (uintptr_t) configdata->descr[i].u.port.start,
-			       configdata->descr[i].u.port.length);
-			break;
-		case CmResourceTypeInterrupt:
-			printf("Irq: level(%d) vector(%d) ",
-			       configdata->descr[i].u.interrupt.level,
-			       configdata->descr[i].u.interrupt.vector);
-			break;
-		case CmResourceTypeMemory:
-			printf("Memory: %p-size:%d ",
-			       (uintptr_t)configdata->descr[i].u.port.start,
-			       configdata->descr[i].u.port.length);
-			break;
-		default:
-			break;
-		}
-	}
-
-	free(configdata);
-}
-
-/** Print information about component */
-static void arc_print_component(arc_component *c)
-{
-	unsigned int i;
-
-	printf("%s: ",ctypes[c->type]);
-	for (i = 0; i < c->identifier_len; i++)
-		printf("%c", c->identifier[i]);
-
-	printf(" ");
-	arc_print_confdata(c);
-	printf("\n");
-}
-
-/**
- * Read from ARC bios configuration data and print it
- */
-static int cmd_arc_print_devices(cmd_arg_t *argv)
-{
-	arc_component *c, *next;
-
-	c = arc_entry->getchild(NULL);
-	while (c) {
-		arc_print_component(c);
-		next = arc_entry->getchild(c);
-		while (!next) {
-			next = arc_entry->getpeer(c);
-			if (!next)
-				c = arc_entry->getparent(c);
-			if (!c)
-				return 0;
-		}
-		c = next;
-	}
-	return 1;
-}
-static cmd_info_t devlist_info = {
-	.name = "arcdevlist",
-	.description = "Print arc device list",
-	.func = cmd_arc_print_devices,
-	.argc = 0
-};
-
-
-/** Read from arc bios memory map and print it
- *
- */
-void physmem_print(void)
-{
-	printf("Base       Size       Type\n");
-	printf("---------- ---------- ---------\n");
-	
-	if (arc_enabled()) {
-		arc_memdescriptor_t *desc = arc_entry->getmemorydescriptor(NULL);
-		
-		while (desc) {
-			printf("%#10x %#10x %s\n",
-				desc->basepage * ARC_FRAME, desc->basecount * ARC_FRAME,
-				basetypes[desc->type]);
-			desc = arc_entry->getmemorydescriptor(desc);
-		}	
-	} else
-		printf("%#10x %#10x free\n", 0, CONFIG_MEMORY_SIZE);
-}
-
-/** Print charactor to console */
-static void arc_putchar(char ch)
-{
-	uint32_t cnt;
-	ipl_t ipl;
-
-	/* TODO: Should be spinlock? */
-	ipl = interrupts_disable();
-	arc_entry->write(1, &ch, 1, &cnt);
-	interrupts_restore(ipl);
-}
-
-
-/** Initialize ARC structure
- *
- * @return 0 - ARC OK, -1 - ARC does not exist
- */
-int arc_init(void)
-{
-	if (sbp->signature != ARC_MAGIC) {
-		sbp = NULL;
-		return -1;
-	}
-	arc_entry = sbp->firmwarevector;
-
-	arc_putchar('A');
-	arc_putchar('R');
-	arc_putchar('C');
-	arc_putchar('\n');
-
-	/* Add command for resetting the computer */
-	cmd_initialize(&devlist_info);
-	cmd_register(&devlist_info);
-
-	return 0;
-}
-
-int arc_reboot(void)
-{
-	if (arc_enabled()) {
-		arc_entry->reboot();
-		return true;
-	}
-	
-	return false;
-}
-
-
-static bool kbd_polling_enabled;
-static chardev_t console;
-
-/** Try to get character, return character or -1 if not available */
-static void arc_keyboard_poll(void)
-{
-	char ch;
-	uint32_t count;
-	long result;
-	
-	if (!kbd_polling_enabled)
-		return;
-
-	if (arc_entry->getreadstatus(0))
-		return;
-	result = arc_entry->read(0, &ch, 1, &count);
-	if ((result) || (count != 1)) {
-		return;
-	}
-	if (ch == '\r')
-		ch = '\n';
-	if (ch == 0x7f)
-		ch = '\b';
-	
-	chardev_push_character(&console, ch);
-}
-
-static char arc_read(chardev_t *dev)
-{
-	char ch;
-	uint32_t count;
-	long result;
-
-	result = arc_entry->read(0, &ch, 1, &count);
-	if ((result) || (count != 1)) {
-		printf("Error reading from ARC keyboard.\n");
-		cpu_halt();
-	}
-	if (ch == '\r')
-		return '\n';
-	if (ch == 0x7f)
-		return '\b';
-	return ch;
-}
-
-static void arc_write(chardev_t *dev, const char ch)
-{
-	arc_putchar(ch);
-}
-
-static void arc_enable(chardev_t *dev)
-{
-	kbd_polling_enabled = true;
-}
-
-static void arc_disable(chardev_t *dev)
-{
-	kbd_polling_enabled = false;
-}
-
-static chardev_operations_t arc_ops = {
-	.resume = arc_enable,
-	.suspend = arc_disable,
-	.write = arc_write,
-	.read = arc_read
-};
-
-int arc_console(void)
-{
-	if (arc_enabled()) {
-		kbd_polling_enabled = true;
-		
-		chardev_initialize("arc_console", &console, &arc_ops);
-		virtual_timer_fnc = &arc_keyboard_poll;
-		stdin = &console;
-		stdout = &console;
-		
-		return true;
-	}
-	
-	return false;
-}
-
-/* Initialize frame zones from ARC firmware. 
- * In the future we may use even the FirmwareTemporary regions,
- * currently we use the FreeMemory (what about the LoadedProgram?)
- */
-int arc_frame_init(void)
-{
-	if (arc_enabled()) {
-		arc_memdescriptor_t *desc;
-		uintptr_t base;
-		size_t basesize;
-	
-		desc = arc_entry->getmemorydescriptor(NULL);
-		while (desc) {
-			if ((desc->type == FreeMemory) ||
-			    (desc->type == FreeContiguous)) {
-				base = desc->basepage*ARC_FRAME;
-				basesize = desc->basecount*ARC_FRAME;
-	
-				if (base % FRAME_SIZE ) {
-					basesize -= FRAME_SIZE - (base % FRAME_SIZE);
-					base = ALIGN_UP(base, FRAME_SIZE);
-				}
-				basesize = ALIGN_DOWN(basesize, FRAME_SIZE);
-	
-				zone_create(ADDR2PFN(base), SIZE2FRAMES(basesize),
-					    ADDR2PFN(base), 0);
-			}
-			desc = arc_entry->getmemorydescriptor(desc);
-		}
-	
-		return true;
-	}
-	
-	return false;
-}
-
-/** @}
- */
Index: kernel/arch/mips32/src/drivers/msim.c
===================================================================
--- kernel/arch/mips32/src/drivers/msim.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/drivers/msim.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -40,9 +40,4 @@
 #include <console/console.h>
 #include <sysinfo/sysinfo.h>
-
-/** Address of devices. */
-#define MSIM_VIDEORAM		0xB0000000
-#define MSIM_KBD_ADDRESS	0xB0000000
-#define MSIM_KBD_IRQ 		2
 
 static chardev_t console;
Index: kernel/arch/mips32/src/interrupt.c
===================================================================
--- kernel/arch/mips32/src/interrupt.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/interrupt.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -39,5 +39,4 @@
 #include <arch/cp0.h>
 #include <time/clock.h>
-#include <arch/drivers/arc.h>
 #include <ipc/sysipc.h>
 #include <ddi/device.h>
Index: kernel/arch/mips32/src/mips32.c
===================================================================
--- kernel/arch/mips32/src/mips32.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/mips32.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -49,5 +49,4 @@
 
 #include <arch/interrupt.h>
-#include <arch/drivers/arc.h>
 #include <console/chardev.h>
 #include <arch/barrier.h>
@@ -98,5 +97,4 @@
 	/* Initialize dispatch table */
 	exception_init();
-	arc_init();
 
 	/* Copy the exception vectors to the right places */
@@ -188,6 +186,5 @@
 void arch_reboot(void)
 {
-	if (!arc_reboot())
-		___halt();
+	___halt();
 	
 	while (1)
Index: kernel/arch/mips32/src/mm/as.c
===================================================================
--- kernel/arch/mips32/src/mm/as.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/mm/as.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -45,5 +45,5 @@
 void as_arch_init(void)
 {
-        as_operations = &as_pt_operations;
+	as_operations = &as_pt_operations;
 	asid_fifo_init();
 }
Index: kernel/arch/mips32/src/mm/frame.c
===================================================================
--- kernel/arch/mips32/src/mm/frame.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/mm/frame.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -33,24 +33,206 @@
  */
 
+#include <macros.h>
 #include <arch/mm/frame.h>
+#include <arch/mm/tlb.h>
 #include <mm/frame.h>
+#include <mm/asid.h>
 #include <config.h>
-#include <arch/drivers/arc.h>
+#include <arch/drivers/msim.h>
+#include <arch/drivers/serial.h>
+#include <print.h>
+#include <debug.h>
+
+#define TLB_PAGE_MASK_1M	(0xff << 13)
+
+#define ZERO_FRAMES			4096
+#define ZERO_PAGE_WIDTH		20  /* 1M */
+#define ZERO_PAGE_SIZE		(1 << ZERO_PAGE_WIDTH)
+#define ZERO_PAGE_ASID		ASID_INVALID
+#define ZERO_PAGE_TLBI		0
+#define ZERO_PAGE_ADDR		0
+#define ZERO_PAGE_OFFSET	(ZERO_PAGE_SIZE / sizeof(uint32_t) - 1)
+#define ZERO_PAGE_VALUE		(*((volatile uint32_t *) ZERO_PAGE_ADDR + ZERO_PAGE_OFFSET))
+
+#define MAX_REGIONS			32
+
+typedef struct {
+	pfn_t start;
+	pfn_t count;
+} phys_region_t;
+
+static count_t phys_regions_count = 0;
+static phys_region_t phys_regions[MAX_REGIONS];
+
+
+/** Check whether frame is available
+ *
+ * Returns true if given frame is generally available for use.
+ * Returns false if given frame is used for physical memory
+ * mapped devices and cannot be used.
+ *
+ */
+static bool frame_available(pfn_t frame)
+{
+	/* MSIM device (dprinter) */
+	if (frame == (KA2PA(MSIM_VIDEORAM) >> ZERO_PAGE_WIDTH))
+		return false;
+	
+	/* MSIM device (dkeyboard) */
+	if (frame == (KA2PA(MSIM_KBD_ADDRESS) >> ZERO_PAGE_WIDTH))
+		return false;
+	
+	/* Simics device (serial line) */
+	if (frame == (KA2PA(SERIAL_ADDRESS) >> ZERO_PAGE_WIDTH))
+		return false;
+	
+	return true;
+}
+
+
+/** Check whether frame is safe to write
+ *
+ * Returns true if given frame is safe for read/write test.
+ * Returns false if given frame should not be touched.
+ *
+ */
+static bool frame_safe(pfn_t frame) __attribute__((unused));
+static bool frame_safe(pfn_t frame)
+{
+	/* Kernel structures */
+	if ((frame << ZERO_PAGE_WIDTH) < KA2PA(config.base))
+		return false;
+	
+	/* Kernel */
+	if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
+	    KA2PA(config.base), config.kernel_size))
+		return false;
+	
+	/* Kernel stack */
+	if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
+	    KA2PA(config.stack_base), config.stack_size))
+		return false;
+	
+	/* Init tasks */
+	bool safe = true;
+	count_t i;
+	for (i = 0; i < init.cnt; i++)
+		if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE,
+		    KA2PA(init.tasks[i].addr), init.tasks[i].size)) {
+			safe = false;
+			break;
+		}
+	
+	return safe;
+}
+
+static void frame_add_region(pfn_t start_frame, pfn_t end_frame)
+{
+	if (end_frame > start_frame) {
+		/* Convert 1M frames to 16K frames */
+		pfn_t first = ADDR2PFN(start_frame << ZERO_PAGE_WIDTH);
+		pfn_t count = ADDR2PFN((end_frame - start_frame - 1) << ZERO_PAGE_WIDTH);
+		
+		/* Interrupt vector frame is blacklisted */
+		pfn_t conf_frame;
+		if (start_frame == 0)
+			conf_frame = 1;
+		else
+			conf_frame = first;
+		
+		zone_create(first, count, conf_frame, 0);
+		
+		if (phys_regions_count < MAX_REGIONS) {
+			phys_regions[phys_regions_count].start = first;
+			phys_regions[phys_regions_count].count = count;
+			phys_regions_count++;
+		}
+	}
+}
+
 
 /** Create memory zones
  *
- * If ARC is known, read information from ARC, otherwise
- * assume some defaults. 
- * - blacklist first FRAME because there is an exception vector
+ * Walk through available 1 MB chunks of physical
+ * memory and create zones.
+ *
  */
 void frame_arch_init(void)
 {
-	if (!arc_frame_init()) {
-		zone_create(0, ADDR2PFN(CONFIG_MEMORY_SIZE), 1, 0);
-		/*
-		 * Blacklist interrupt vector
-		 */
-		frame_mark_unavailable(0, 1);
+	cp0_index_write(ZERO_PAGE_TLBI);
+	tlbr();
+	
+	uint32_t orig_pagemask = cp0_pagemask_read();
+	uint32_t orig_lo0 = cp0_entry_lo0_read();
+	uint32_t orig_lo1 = cp0_entry_lo1_read();
+	uint32_t orig_hi = cp0_entry_hi_read();
+		
+	pfn_t start_frame = 0;
+	pfn_t frame;
+	bool avail = true;
+	
+	/* Walk through all 1 MB frames */
+	for (frame = 0; frame < ZERO_FRAMES; frame++) {
+		if (!frame_available(frame))
+			avail = false;
+		else {
+			if (frame_safe(frame)) {
+				entry_lo_t lo0;
+				entry_lo_t lo1;
+				entry_hi_t hi;
+				tlb_prepare_entry_lo(&lo0, false, true, true, false, frame << (ZERO_PAGE_WIDTH - 12));
+				tlb_prepare_entry_lo(&lo1, false, false, false, false, 0);
+				tlb_prepare_entry_hi(&hi, ZERO_PAGE_ASID, ZERO_PAGE_ADDR);
+				
+				cp0_index_write(ZERO_PAGE_TLBI);
+				cp0_pagemask_write(TLB_PAGE_MASK_1M);
+				cp0_entry_lo0_write(lo0.value);
+				cp0_entry_lo1_write(lo1.value);
+				cp0_entry_hi_write(hi.value);
+				tlbwi();
+				
+				ZERO_PAGE_VALUE = 0;
+				if (ZERO_PAGE_VALUE != 0)
+					avail = false;
+				else {
+					ZERO_PAGE_VALUE = 0xdeadbeef;
+					if (ZERO_PAGE_VALUE != 0xdeadbeef)
+						avail = false;
+				}
+			}
+		}
+		
+		if (!avail) {
+			frame_add_region(start_frame, frame);
+			start_frame = frame + 1;
+			avail = true;
+		}
 	}
+	
+	frame_add_region(start_frame, frame);
+	
+	/* Cleanup TLB */
+	cp0_index_write(ZERO_PAGE_TLBI);
+	cp0_pagemask_write(orig_pagemask);
+	cp0_entry_lo0_write(orig_lo0);
+	cp0_entry_lo1_write(orig_lo1);
+	cp0_entry_hi_write(orig_hi);
+	tlbwi();
+	
+	/* Blacklist interrupt vector frame */
+	frame_mark_unavailable(0, 1);
+}
+
+
+void physmem_print(void)
+{
+	printf("Base       Size\n");
+	printf("---------- ----------\n");
+	
+	count_t i;
+	for (i = 0; i < phys_regions_count; i++) {
+		printf("%#10x %10u\n",
+			PFN2ADDR(phys_regions[i].start), PFN2ADDR(phys_regions[i].count));
+	}	
 }
 
Index: kernel/arch/mips32/src/mm/tlb.c
===================================================================
--- kernel/arch/mips32/src/mm/tlb.c	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/arch/mips32/src/mm/tlb.c	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -54,7 +54,4 @@
 static pte_t *find_mapping_and_check(uintptr_t badvaddr, int access, istate_t *istate, int *pfrc);
 
-static void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn);
-static void prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr);
-
 /** Initialize TLB
  *
@@ -77,5 +74,4 @@
 		tlbwi();
 	}
-
 		
 	/*
@@ -132,6 +128,6 @@
 	pte->a = 1;
 
-	prepare_entry_hi(&hi, asid, badvaddr);
-	prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
+	tlb_prepare_entry_hi(&hi, asid, badvaddr);
+	tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
 
 	/*
@@ -179,5 +175,5 @@
 	 */
 	hi.value = cp0_entry_hi_read();
-	prepare_entry_hi(&hi, hi.asid, badvaddr);
+	tlb_prepare_entry_hi(&hi, hi.asid, badvaddr);
 	cp0_entry_hi_write(hi.value);
 	tlbp();
@@ -222,5 +218,5 @@
 	pte->a = 1;
 
-	prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
+	tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->d, pte->cacheable, pte->pfn);
 
 	/*
@@ -263,5 +259,5 @@
 	 */
 	hi.value = cp0_entry_hi_read();
-	prepare_entry_hi(&hi, hi.asid, badvaddr);
+	tlb_prepare_entry_hi(&hi, hi.asid, badvaddr);
 	cp0_entry_hi_write(hi.value);
 	tlbp();
@@ -313,5 +309,5 @@
 	pte->d = 1;
 
-	prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable, pte->pfn);
+	tlb_prepare_entry_lo(&lo, pte->g, pte->p, pte->w, pte->cacheable, pte->pfn);
 
 	/*
@@ -446,5 +442,5 @@
 }
 
-void prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn)
+void tlb_prepare_entry_lo(entry_lo_t *lo, bool g, bool v, bool d, bool cacheable, uintptr_t pfn)
 {
 	lo->value = 0;
@@ -456,5 +452,5 @@
 }
 
-void prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr)
+void tlb_prepare_entry_hi(entry_hi_t *hi, asid_t asid, uintptr_t addr)
 {
 	hi->value = ALIGN_DOWN(addr, PAGE_SIZE * 2);
@@ -586,5 +582,5 @@
 	for (i = 0; i < cnt + 1; i += 2) {
 		hi.value = 0;
-		prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE);
+		tlb_prepare_entry_hi(&hi, asid, page + i * PAGE_SIZE);
 		cp0_entry_hi_write(hi.value);
 
Index: kernel/doc/arch/mips32
===================================================================
--- kernel/doc/arch/mips32	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/doc/arch/mips32	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -4,9 +4,7 @@
 mips32 is the second port of SPARTAN kernel originally written by Jakub Jermar.
 It was first developed to run on MIPS R4000 32-bit simulator.
-Now it can run on real hardware as well.
 It can be compiled and run either as little- or big-endian.
 
 HARDWARE REQUIREMENTS
-        o SGI Indy R4600
         o emulated MIPS 4K CPU
 
Index: kernel/generic/include/config.h
===================================================================
--- kernel/generic/include/config.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/generic/include/config.h	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -41,6 +41,4 @@
 #define STACK_SIZE		PAGE_SIZE
 
-#define CONFIG_MEMORY_SIZE	(16 * 1024 * 1024)
-
 #define CONFIG_INIT_TASKS	32
 
Index: kernel/generic/include/macros.h
===================================================================
--- kernel/generic/include/macros.h	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/generic/include/macros.h	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -49,5 +49,5 @@
 #define max(a,b)	((a) > (b) ? (a) : (b))
 
-/** Return true if the interlvals overlap.
+/** Return true if the intervals overlap.
  *
  * @param s1 Start address of the first interval.
@@ -70,4 +70,7 @@
 #define SIZE2MB(size) (size >> 20)
 
+#define KB2SIZE(size) (size << 10)
+#define MB2SIZE(size) (size << 20)
+
 #define STRING(arg) STRING_ARG(arg)
 #define STRING_ARG(arg) #arg
Index: kernel/kernel.config
===================================================================
--- kernel/kernel.config	(revision 5e8ddf5690a75f99176a2b7d8083393b9361e06b)
+++ kernel/kernel.config	(revision edebc15c65ded52ed661523a687334ecc04a7578)
@@ -82,5 +82,4 @@
 @ "lgxemul" GXEmul Little Endian
 @ "bgxemul" GXEmul Big Endian
-@ "indy" SGI Indy
 ! [ARCH=mips32] MACHINE (choice)
 
