Index: arch/amd64/_link.ld.in
===================================================================
--- arch/amd64/_link.ld.in	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/amd64/_link.ld.in	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -63,6 +63,14 @@
 	_hardcoded_kernel_size = (ktext_end - ktext_start) + (unmapped_ktext_end - unmapped_ktext_start) + (kdata_end - kdata_start) + (unmapped_kdata_end - unmapped_kdata_start);
 
+	/* Symbols that need to be accessed both from real mode & long mode */
+	/* e820*_boot is real mode (pre-above-1MB-move), e820* is */
+	/* kernel mapped above-1MB-physical copied symbol */
 	e820table_boot = KA2PA(e820table) - BOOT_OFFSET;
 	e820counter_boot = KA2PA(e820counter) - BOOT_OFFSET;
+
+	/* real_bootstrap_gdtr is mapped real_bootstrap_gdtr_boot */
+	/* It is physically outside of kernel area, we have to access */
+	/* it after modification from long mode for booting */
+	/* SMP slave processors */
 	real_bootstrap_gdtr = PA2KA(real_bootstrap_gdtr_boot);
 }
Index: arch/amd64/include/byteorder.h
===================================================================
--- arch/amd64/include/byteorder.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/amd64/include/byteorder.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -31,5 +31,6 @@
 
 /* AMD64 is little-endian */
-#define native_le2host(n)		n
+#define native_le2host(n)		(n)
+#define u64_le2host(n)		(n)
 
 #endif
Index: arch/amd64/src/asm_utils.S
===================================================================
--- arch/amd64/src/asm_utils.S	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/amd64/src/asm_utils.S	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -59,9 +59,4 @@
 .global utext
 utext:
-	xor %ax,%ax;
-	mov %ax,%ds;
-	mov %ax,%es;
-	mov %ax,%fs;
-	mov %ax,%gs;
 0:
 	int $48
@@ -178,9 +173,8 @@
 	push_all_gpr
 
-	# trap_dispatcher(i, stack)
 	movq $(\i),%rdi   # %rdi - first parameter
 	movq %rbp, %rsi
 	addq $8, %rsi     # %rsi - second parameter - original stack
-	call trap_dispatcher
+	call trap_dispatcher 	# trap_dispatcher(i, stack)
 
 # Test if this is interrupt with error word or not
@@ -217,7 +211,4 @@
 h_start:
 	handler 0 IDT_ITEMS
-#	handler 64 128	
-#	handler 128 192
-#	handler 192 256
 h_end:
 	
Index: arch/amd64/src/fpu_context.c
===================================================================
--- arch/amd64/src/fpu_context.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/amd64/src/fpu_context.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -32,4 +32,5 @@
 #include <cpu.h>
 
+/** Save FPU (mmx, sse) context using fxsave instruction */
 void fpu_context_save(fpu_context_t *fctx)
 {
@@ -44,4 +45,5 @@
 }
 
+/** Restore FPU (mmx,sse) context using fxrstor instruction */
 void fpu_context_restore(fpu_context_t *fctx)
 {
Index: arch/amd64/src/pm.c
===================================================================
--- arch/amd64/src/pm.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/amd64/src/pm.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -92,5 +92,5 @@
 	  .granularity = 1, 
 	  .base_24_31  = 0 },
-	/* KTEXT 32-bit protected */
+	/* KTEXT 32-bit protected, for protected mode before long mode */
 	{ .limit_0_15  = 0xffff, 
 	  .base_0_15   = 0, 
Index: arch/ia32/include/byteorder.h
===================================================================
--- arch/ia32/include/byteorder.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/ia32/include/byteorder.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -31,5 +31,6 @@
 
 /* IA-32 is little-endian */
-#define native_le2host(n)		n
+#define native_le2host(n)		(n)
+#define u64_le2host(n)		(n)
 
 #endif
Index: arch/ia64/include/byteorder.h
===================================================================
--- arch/ia64/include/byteorder.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/ia64/include/byteorder.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -31,5 +31,6 @@
 
 /* IA-64 is little-endian */
-#define native_le2host(n)		n
+#define native_le2host(n)		(n)
+#define u64_le2host(n)		(n)
 
 #endif
Index: arch/mips/Makefile.inc
===================================================================
--- arch/mips/Makefile.inc	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/Makefile.inc	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -1,4 +1,3 @@
 MIPS_TARGET=mipsel-linux-gnu
-
 MIPS_CC_DIR=/usr/local/mipsel/bin
 MIPS_BINUTILS_DIR=/usr/local/mipsel/bin
@@ -9,5 +8,4 @@
 OBJDUMP=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-objdump
 OBJCOPY=$(MIPS_BINUTILS_DIR)/$(MIPS_TARGET)-objcopy
-BFD_NAME=elf32-tradlittlemips
 BFD_ARCH=mips
 
@@ -15,13 +13,18 @@
 CFLAGS=$(DEFS) -mno-abicalls -G 0 -nostdlib -fno-builtin -O2  -fno-zero-initialized-in-bss 
 LFLAGS=-M -N
+BFD_ARCH=mips
 
-# It seems that on big endian either GCC or the simulators
-# have the swl/swr/lwl/lwr instructions wrong. Just for sure,
-# disable it with -mmemcpy (force calling memcpy instead of inlining)
+# 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.
+ifeq (${MACHINE},indy)
+ MIPS_TARGET=mips-sgi-irix5
+ MIPS_CC_DIR=/usr/local/mips/bin
+ MIPS_BINUTILS_DIR=/usr/local/mips/bin
 
-ifeq (${MACHINE},indy)
- CFLAGS += -EB -mmemcpy -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -march=r4600
+ CFLAGS += -EB -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -march=r4600
  BFD = ecoff-bigmips
  KERNEL_LOAD_ADDRESS = 0x88002000
+ BFD_NAME=elf32-big
 endif
 
@@ -30,10 +33,16 @@
  BFD = ecoff-littlemips
  KERNEL_LOAD_ADDRESS = 0x80100000
+ BFD_NAME=elf32-little
 endif
 
 ifeq (${MACHINE},bgxemul)
- CFLAGS += -EB -mmemcpy -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -mips3
+ MIPS_TARGET=mips-sgi-irix5
+ MIPS_CC_DIR=/usr/local/mips/bin
+ MIPS_BINUTILS_DIR=/usr/local/mips/bin
+
+ CFLAGS += -EB -DBIG_ENDIAN -DHAVE_FPU -DFPU_LAZY -mips3
  BFD = ecoff-bigmips
  KERNEL_LOAD_ADDRESS = 0x80100000
+ BFD_NAME=elf32-big
 endif
 
@@ -44,4 +53,5 @@
  CFLAGS += -msoft-float -march=4kc 
  KERNEL_LOAD_ADDRESS = 0x80100000
+ BFD_NAME=elf32-little
 endif
 
@@ -52,4 +62,5 @@
  CFLAGS += -msoft-float -mips3
  KERNEL_LOAD_ADDRESS = 0x80100000
+ BFD_NAME=elf32-little
 endif
 
@@ -73,3 +84,4 @@
 	arch/mm/tlb.c \
 	arch/fpu_context.c \
-	arch/fmath.c
+	arch/fmath.c \
+	arch/drivers/arc.c
Index: arch/mips/_link.ld.in
===================================================================
--- arch/mips/_link.ld.in	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/_link.ld.in	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -34,4 +34,9 @@
 		*(.sdata);
 		*(.reginfo);
+		/* Unfortunately IRIX does not allow us
+	         * to include this as a last section :-(
+		 * BSS/SBSS addresses will be wrong */
+		symbol_table = .;
+		*(symtab.*);             
 	}
 	_gp = . + 0x8000;
@@ -47,8 +52,4 @@
 	}
 
-	mysymtab : {
-		symbol_table = .;
-		*(symtab.*);             /* Symbol table, must be LAST symbol!*/
-	}
 	kdata_end = .;
 
Index: arch/mips/include/byteorder.h
===================================================================
--- arch/mips/include/byteorder.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/include/byteorder.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -32,4 +32,16 @@
 /* MIPS is little-endian */
 #ifdef BIG_ENDIAN
+static inline __u64 u64_le2host(__u64 n)
+{
+	return ((n & 0xff) << 56) |
+		((n & 0xff00) << 40) |
+		((n & 0xff0000) << 24) |
+		((n & 0xff000000LL) << 8) |
+		((n & 0xff00000000LL) >>8) |
+		((n & 0xff0000000000LL) >> 24) |
+		((n & 0xff000000000000LL) >> 40) |
+		((n & 0xff00000000000000LL) >> 56);
+}
+
 static inline __native native_le2host(__native n)
 {
@@ -40,5 +52,6 @@
 }
 #else
-#  define native_le2host(n)		n
+#  define native_le2host(n)		(n)
+#  define u64_le2host(n)		(n)
 #endif
 
Index: arch/mips/include/console.h
===================================================================
--- arch/mips/include/console.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/include/console.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -39,6 +39,3 @@
 void console_init(void);
 
-extern int bios_write(int fd, const char *buf, int size, int *cnt);
-
-
 #endif
Index: arch/mips/include/drivers/arc.h
===================================================================
--- arch/mips/include/drivers/arc.h	(revision 315658278d687936226e1093e482b272fcfe7720)
+++ arch/mips/include/drivers/arc.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ */
+
+#ifndef __mips_ARC_H_
+#define __mips_ARC_H_
+
+#include <arch/types.h>
+
+#define ARC_BASE_ADDR 0x1000;
+#define ARC_MAGIC 0x53435241
+
+typedef struct  {
+} arc_component;
+
+typedef struct {
+	__u16 year;
+	__u16 month;
+	__u16 day;
+	__u16 hour;
+	__u16 minutes;
+	__u16 seconds;
+	__u16 mseconds;
+} 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;
+	__u32 basepage;  /* *4096 = baseaddr */
+	__u32 basecount;
+}arc_memdescriptor_t;
+
+typedef struct {
+	char vendorid[8];
+	char prodid[8];
+}arc_sysid_t;
+
+typedef struct {
+	long (*load)(void); /* ... */
+	long (*invoke)(__u32 eaddr,__u32 saddr,__u32 argc,char **argv,
+		       char **envp);
+	long (*execute)(char *path,__u32 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);
+	__u32 (*getrelativetime)(void);
+	long (*getdirectoryentry)();
+	long (*open)(void); /* ... */
+	long (*close)(__u32 fileid);
+	long (*read)(__u32 fileid,void *buf,__u32 n,__u32 *cnt);
+	long (*getreadstatus)();
+	long (*write)(__u32 fileid, void *buf,__u32 n,__u32 *cnt);
+	long (*seek)(void); /* ... */
+/* 30 */
+	long (*mount)(void); /* ... */
+	char * (*getenvironmentvariable)(char *name);
+	char * (*setenvironmentvariable)(char *name, char *value);
+	long (*getfileinformation)(void); /* ... */
+	long (*setfileinformation)(__u32 fileid,__u32 attflags,__u32 attmask);
+	void (*flushallcaches)(void);
+	long (*testunicodecharacter)(void); /* ... */
+	long (*getdisplaystatus)(void); /* ... */
+} arc_func_vector_t;
+
+typedef struct {
+	__u32 signature;
+	__u32 length;
+	__u16 version;
+	__u16 revision;
+	void *restartblock;
+	void *debugblock;
+	void *gevector;
+	void *utlbmissvector;
+	__u32 firmwarevectorlen;
+	arc_func_vector_t *firmwarevector;
+	__u32 privvectorlen;
+	void *privvector;
+	__u32 adaptercount;
+}__attribute__ ((packed)) arc_sbp;
+
+extern int init_arc(void);
+extern void arc_print_memory_map(void);
+extern int arc_enabled(void);
+extern void arc_putchar(char ch);
+
+#endif
Index: arch/mips/include/interrupt.h
===================================================================
--- arch/mips/include/interrupt.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/include/interrupt.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -30,7 +30,9 @@
 #define __INTERRUPT_H__
 
+#include <arch/exception.h>
+
 #define TIMER_INTERRUPT   7
 
-extern void interrupt(void);
+extern void interrupt(struct exception_regdump *pstate);
 
 #endif
Index: arch/mips/include/types.h
===================================================================
--- arch/mips/include/types.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/include/types.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -33,9 +33,14 @@
 
 typedef signed char __s8;
+typedef unsigned char __u8;
 
-typedef unsigned char __u8;
+typedef signed short __s16;
 typedef unsigned short __u16;
+
 typedef unsigned long __u32;
-typedef long long __u64;
+typedef signed long __s32;
+
+typedef unsigned long long __u64;
+typedef signed long long __s64;
 
 typedef __u32 __address;
Index: arch/mips/src/asm.S
===================================================================
--- arch/mips/src/asm.S	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/src/asm.S	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -118,11 +118,4 @@
 
 
-.global bios_write
-bios_write:
-	lw	$2, 0x80001020
-	lw	$2, 0x6c($2)
-	j	$2
-	nop
-	
 .global cpu_halt
 cpu_halt:
Index: arch/mips/src/console.c
===================================================================
--- arch/mips/src/console.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/src/console.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -32,17 +32,8 @@
 #include <arch/console.h>
 #include <arch.h>
+#include <arch/drivers/arc.h>
+#include <arch/arch.h>
 
-static void arc_putchar(const char ch)
-{
-	int cnt;
-	pri_t pri;
-
-	/* TODO: Should be spinlock? */
-	pri = cpu_priority_high();
-	bios_write(1, &ch, 1, &cnt);
-	cpu_priority_restore(pri);
-	
-}
-
+/** Putchar that works with MSIM & gxemul */
 static void cons_putchar(const char ch)
 {
@@ -50,5 +41,5 @@
 }
 
-
+/** Putchar that works with simics */
 static void serial_putchar(const char ch)
 {
@@ -68,6 +59,8 @@
 void console_init(void)
 {
+	if (arc_enabled()) 
+		putchar_func = arc_putchar;
 	/* The LSR on the start usually contains this value */
-	if (*SERIAL_LSR == 0x60)
+	else if (*SERIAL_LSR == 0x60)
 		putchar_func = serial_putchar;
 	else
Index: arch/mips/src/drivers/arc.c
===================================================================
--- arch/mips/src/drivers/arc.c	(revision 315658278d687936226e1093e482b272fcfe7720)
+++ arch/mips/src/drivers/arc.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+#include <arch/drivers/arc.h>
+#include <arch/mm/page.h>
+#include <print.h>
+#include <arch.h>
+#include <arch/byteorder.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 arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000);
+static arc_func_vector_t *arc_entry; 
+
+static void _arc_putchar(char ch);
+
+/** Initialize ARC structure
+ *
+ * @return 0 - ARC OK, -1 - ARC does not exist
+ */
+int init_arc(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');
+}
+
+/** Return true if ARC is available */
+int arc_enabled(void)
+{
+	return sbp != NULL;
+}
+
+void arc_print_memory_map(void)
+{
+	arc_memdescriptor_t *desc;
+
+	if (!sbp) {
+		printf("ARC not enabled.\n");
+		return;
+	}
+
+	printf("Memory map:\n");
+
+	desc = arc_entry->getmemorydescriptor(NULL);
+	while (desc) {
+		printf("%s: %d (size: %dKB)\n",basetypes[desc->type],
+		       desc->basepage * 4096,
+		       desc->basecount*4);
+		desc = arc_entry->getmemorydescriptor(desc);
+	}
+}
+
+/** Print charactor to console */
+void arc_putchar(char ch)
+{
+	__u32 cnt;
+	pri_t pri;
+
+	/* TODO: Should be spinlock? */
+	pri = cpu_priority_high();
+	arc_entry->write(1, &ch, 1, &cnt);
+	cpu_priority_restore(pri);
+	
+}
Index: arch/mips/src/exception.c
===================================================================
--- arch/mips/src/exception.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/src/exception.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -66,5 +66,5 @@
 	switch (excno) {
 		case EXC_Int:
-			interrupt();
+			interrupt(pstate);
 			break;
 		case EXC_TLBL:
Index: arch/mips/src/interrupt.c
===================================================================
--- arch/mips/src/interrupt.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/src/interrupt.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -33,4 +33,23 @@
 #include <time/clock.h>
 #include <panic.h>
+#include <print.h>
+#include <symtab.h>
+#include <arch/drivers/arc.h>
+
+static void print_regdump(struct exception_regdump *pstate)
+{
+	char *pcsymbol = "";
+	char *rasymbol = "";
+
+	char *s = get_symtab_entry(pstate->epc);
+	if (s)
+		pcsymbol = s;
+	s = get_symtab_entry(pstate->ra);
+	if (s)
+		rasymbol = s;
+	
+	printf("PC: %X(%s) RA: %X(%s)\n",pstate->epc,pcsymbol,
+	       pstate->ra,rasymbol);
+}
 
 pri_t cpu_priority_high(void)
@@ -58,5 +77,5 @@
 }
 
-void interrupt(void)
+void interrupt(struct exception_regdump *pstate)
 {
 	__u32 cause;
@@ -70,8 +89,8 @@
 			switch (i) {
 				case 0: /* SW0 - Software interrupt 0 */
-					cp0_cause_write(cause & ~(1 << 8)); /* clear SW0 interrupt */
+					cp0_cause_write(cp0_cause_read() & ~(1 << 8)); /* clear SW0 interrupt */
 					break;
 				case 1: /* SW1 - Software interrupt 1 */
-					cp0_cause_write(cause & ~(1 << 9)); /* clear SW1 interrupt */
+					cp0_cause_write(cp0_cause_read() & ~(1 << 9)); /* clear SW1 interrupt */
 					break;
 				case 2: /* IRQ0 */
@@ -80,4 +99,5 @@
 				case 5: /* IRQ3 */
 				case 6: /* IRQ4 */
+					print_regdump(pstate);
 					panic("unhandled interrupt %d\n", i);
 					break;
Index: arch/mips/src/mips.c
===================================================================
--- arch/mips/src/mips.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/src/mips.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -37,4 +37,5 @@
 #include <memstr.h>
 #include <arch/interrupt.h>
+#include <arch/drivers/arc.h>
 
 #include <print.h>
@@ -53,4 +54,6 @@
 	/* It is not assumed by default */
 	cpu_priority_high();
+
+	init_arc();
 
 	/* Copy the exception vectors to the right places */
@@ -80,4 +83,5 @@
 
 	console_init();
+	arc_print_memory_map();
 }
 
@@ -111,4 +115,2 @@
 	supervisor_sp = (__address) &THREAD->kstack[THREAD_STACK_SIZE-SP_DELTA];
 }
-
-
Index: arch/mips/src/mm/tlb.c
===================================================================
--- arch/mips/src/mm/tlb.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/mips/src/mm/tlb.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -41,12 +41,10 @@
 	char *sym2 = "";
 
-	if (THREAD) {
-		char *s = get_symtab_entry(pstate->epc);
-		if (s)
-			symbol = s;
-		s = get_symtab_entry(pstate->ra);
-		if (s)
-			sym2 = s;
-	}
+	char *s = get_symtab_entry(pstate->epc);
+	if (s)
+		symbol = s;
+	s = get_symtab_entry(pstate->ra);
+	if (s)
+		sym2 = s;
 	panic("%X: tlb_refill exception at %X(%s<-%s)\n", cp0_badvaddr_read(),
 	      pstate->epc, symbol,sym2);
@@ -57,9 +55,7 @@
 	char *symbol = "";
 
-	if (THREAD) {
-		char *s = get_symtab_entry(pstate->epc);
-		if (s)
-			symbol = s;
-	}
+	char *s = get_symtab_entry(pstate->epc);
+	if (s)
+		symbol = s;
 	panic("%X: TLB exception at %X(%s)\n", cp0_badvaddr_read(), 
 	      pstate->epc, symbol);
Index: arch/ppc/include/byteorder.h
===================================================================
--- arch/ppc/include/byteorder.h	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ arch/ppc/include/byteorder.h	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -41,4 +41,15 @@
  *
  */
+static inline __u64 u64_le2host(__u64 n)
+{
+	return ((n & 0xff) << 56) |
+		((n & 0xff00) << 40) |
+		((n & 0xff0000) << 24) |
+		((n & 0xff000000LL) << 8) |
+		((n & 0xff00000000LL) >>8) |
+		((n & 0xff0000000000LL) >> 24) |
+		((n & 0xff000000000000LL) >> 40) |
+		((n & 0xff00000000000000LL) >> 56);
+}
 static inline __native native_le2host(__native n)
 {
Index: ntrib/toolchain/toolchain.mips.sh
===================================================================
--- contrib/toolchain/toolchain.mips.sh	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ 	(revision )
@@ -1,84 +1,0 @@
-#!/bin/bash
-
-# Cross-Compiler Toolchain for ${PLATFORM}
-#  by Martin Decky <martin@decky.cz>
-#
-#  GPL'ed, copyleft
-#
-
-
-check_error() {
-    if [ "$1" -ne "0" ]; then
-	echo
-	echo "Script failed: $2"
-	exit
-    fi
-}
-
-BINUTILS_VERSION="2.16"
-GCC_VERSION="4.0.1"
-
-BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
-GCC="gcc-core-${GCC_VERSION}.tar.bz2"
-
-BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
-GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
-
-PLATFORM="mipsel"
-WORKDIR=`pwd`
-TARGET="${PLATFORM}-linux-gnu"
-HOST="i686-pc-linux-gnu"
-PREFIX="/usr/local/${PLATFORM}"
-BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
-GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
-OBJDIR="${WORKDIR}/gcc-obj"
-
-echo ">>> Downloading tarballs"
-
-if [ ! -f "${BINUTILS}" ]; then
-    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
-    check_error $? "Error downloading binutils."
-fi
-if [ ! -f "${GCC}" ]; then
-    wget -c "${GCC_SOURCE}${GCC}"
-    check_error $? "Error downloading GCC."
-fi
-
-echo ">>> Creating destionation directory"
-if [ ! -d "${PREFIX}" ]; then
-    mkdir -p "${PREFIX}" 
-    test -d "${PREFIX}"
-    check_error $? "Unable to create ${PREFIX}."
-fi
-
-echo ">>> Creating GCC work directory"
-if [ ! -d "${OBJDIR}" ]; then
-    mkdir -p "${OBJDIR}"
-    test -d "${OBJDIR}"
-    check_error $? "Unable to create ${OBJDIR}."
-fi
-
-echo ">>> Unpacking tarballs"
-tar -xvzf "${BINUTILS}"
-check_error $? "Error unpacking binutils."
-tar -xvjf "${GCC}"
-check_error $? "Error unpacking GCC."
-
-echo ">>> Compiling and installing binutils"
-cd "${BINUTILSDIR}"
-check_error $? "Change directory failed."
-./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
-check_error $? "Error configuring binutils."
-make all install
-check_error $? "Error compiling/installing binutils."
-
-echo ">>> Compiling and installing GCC"
-cd "${OBJDIR}"
-check_error $? "Change directory failed."
-"${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c --disable-multilib --disable-libgcj --without-headers --disable-shared
-check_error $? "Error configuring GCC."
-PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
-check_error $? "Error compiling/installing GCC."
-
-echo
-echo ">>> Cross-compiler for ${TARGET} installed."
Index: contrib/toolchain/toolchain.mipseb.sh
===================================================================
--- contrib/toolchain/toolchain.mipseb.sh	(revision 315658278d687936226e1093e482b272fcfe7720)
+++ contrib/toolchain/toolchain.mipseb.sh	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# Cross-Compiler Toolchain for ${PLATFORM}
+#  by Martin Decky <martin@decky.cz>
+#
+#  GPL'ed, copyleft
+#
+
+
+check_error() {
+    if [ "$1" -ne "0" ]; then
+	echo
+	echo "Script failed: $2"
+	exit
+    fi
+}
+
+BINUTILS_VERSION="2.16"
+GCC_VERSION="4.0.1"
+
+BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
+GCC="gcc-core-${GCC_VERSION}.tar.bz2"
+
+BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
+GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
+
+PLATFORM="mips"
+WORKDIR=`pwd`
+TARGET="${PLATFORM}-sgi-irix5"
+HOST="i686-pc-linux-gnu"
+PREFIX="/usr/local/${PLATFORM}"
+BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
+GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
+OBJDIR="${WORKDIR}/gcc-obj"
+
+echo ">>> Downloading tarballs"
+
+if [ ! -f "${BINUTILS}" ]; then
+    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
+    check_error $? "Error downloading binutils."
+fi
+if [ ! -f "${GCC}" ]; then
+    wget -c "${GCC_SOURCE}${GCC}"
+    check_error $? "Error downloading GCC."
+fi
+
+echo ">>> Creating destionation directory"
+if [ ! -d "${PREFIX}" ]; then
+    mkdir -p "${PREFIX}" 
+    test -d "${PREFIX}"
+    check_error $? "Unable to create ${PREFIX}."
+fi
+
+echo ">>> Creating GCC work directory"
+if [ ! -d "${OBJDIR}" ]; then
+    mkdir -p "${OBJDIR}"
+    test -d "${OBJDIR}"
+    check_error $? "Unable to create ${OBJDIR}."
+fi
+
+echo ">>> Unpacking tarballs"
+tar -xvzf "${BINUTILS}"
+check_error $? "Error unpacking binutils."
+tar -xvjf "${GCC}"
+check_error $? "Error unpacking GCC."
+
+echo ">>> Compiling and installing binutils"
+cd "${BINUTILSDIR}"
+check_error $? "Change directory failed."
+./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
+check_error $? "Error configuring binutils."
+make all install
+check_error $? "Error compiling/installing binutils."
+
+echo ">>> Compiling and installing GCC"
+cd "${OBJDIR}"
+check_error $? "Change directory failed."
+"${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c --disable-multilib --disable-libgcj --without-headers --disable-shared
+check_error $? "Error configuring GCC."
+PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
+check_error $? "Error compiling/installing GCC."
+
+echo
+echo ">>> Cross-compiler for ${TARGET} installed."
Index: contrib/toolchain/toolchain.mipsel.sh
===================================================================
--- contrib/toolchain/toolchain.mipsel.sh	(revision 315658278d687936226e1093e482b272fcfe7720)
+++ contrib/toolchain/toolchain.mipsel.sh	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+# Cross-Compiler Toolchain for ${PLATFORM}
+#  by Martin Decky <martin@decky.cz>
+#
+#  GPL'ed, copyleft
+#
+
+
+check_error() {
+    if [ "$1" -ne "0" ]; then
+	echo
+	echo "Script failed: $2"
+	exit
+    fi
+}
+
+BINUTILS_VERSION="2.16"
+GCC_VERSION="4.0.1"
+
+BINUTILS="binutils-${BINUTILS_VERSION}.tar.gz"
+GCC="gcc-core-${GCC_VERSION}.tar.bz2"
+
+BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
+GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
+
+PLATFORM="mipsel"
+WORKDIR=`pwd`
+TARGET="${PLATFORM}-linux-gnu"
+HOST="i686-pc-linux-gnu"
+PREFIX="/usr/local/${PLATFORM}"
+BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
+GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
+OBJDIR="${WORKDIR}/gcc-obj"
+
+echo ">>> Downloading tarballs"
+
+if [ ! -f "${BINUTILS}" ]; then
+    wget -c "${BINUTILS_SOURCE}${BINUTILS}"
+    check_error $? "Error downloading binutils."
+fi
+if [ ! -f "${GCC}" ]; then
+    wget -c "${GCC_SOURCE}${GCC}"
+    check_error $? "Error downloading GCC."
+fi
+
+echo ">>> Creating destionation directory"
+if [ ! -d "${PREFIX}" ]; then
+    mkdir -p "${PREFIX}" 
+    test -d "${PREFIX}"
+    check_error $? "Unable to create ${PREFIX}."
+fi
+
+echo ">>> Creating GCC work directory"
+if [ ! -d "${OBJDIR}" ]; then
+    mkdir -p "${OBJDIR}"
+    test -d "${OBJDIR}"
+    check_error $? "Unable to create ${OBJDIR}."
+fi
+
+echo ">>> Unpacking tarballs"
+tar -xvzf "${BINUTILS}"
+check_error $? "Error unpacking binutils."
+tar -xvjf "${GCC}"
+check_error $? "Error unpacking GCC."
+
+echo ">>> Compiling and installing binutils"
+cd "${BINUTILSDIR}"
+check_error $? "Change directory failed."
+./configure "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" "--disable-nls"
+check_error $? "Error configuring binutils."
+make all install
+check_error $? "Error compiling/installing binutils."
+
+echo ">>> Compiling and installing GCC"
+cd "${OBJDIR}"
+check_error $? "Change directory failed."
+"${GCCDIR}/configure" "--host=${HOST}" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c --disable-multilib --disable-libgcj --without-headers --disable-shared
+check_error $? "Error configuring GCC."
+PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
+check_error $? "Error compiling/installing GCC."
+
+echo
+echo ">>> Cross-compiler for ${TARGET} installed."
Index: src/debug/symtab.c
===================================================================
--- src/debug/symtab.c	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ src/debug/symtab.c	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -40,8 +40,8 @@
 
 	for (i=1;symbol_table[i].address_le;++i) {
-		if (addr < native_le2host(symbol_table[i].address_le))
+		if (addr < u64_le2host(symbol_table[i].address_le))
 			break;
 	}
-	if (addr >= native_le2host(symbol_table[i-1].address_le))
+	if (addr >= u64_le2host(symbol_table[i-1].address_le))
 		return symbol_table[i-1].symbol_name;
 	return NULL;
Index: tools/genmap.py
===================================================================
--- tools/genmap.py	(revision 8491c4861418774a24bfc679b903b93cda4a4ffb)
+++ tools/genmap.py	(revision 315658278d687936226e1093e482b272fcfe7720)
@@ -9,5 +9,5 @@
 
 
-funcline = re.compile(r'([0-9a-f]+)\s+[lg]\s+F\s+\.text\s+([0-9a-f]+)\s+(.*)$')
+funcline = re.compile(r'([0-9a-f]+)\s+[lg]\s+.\s+\.text\s+([0-9a-f]+)\s+(.*)$')
 bssline = re.compile(r'([0-9a-f]+)\s+[lg]\s+[a-zA-Z]\s+\.bss\s+([0-9a-f]+)\s+(.*)$')
 dataline = re.compile(r'([0-9a-f]+)\s+[lg]\s+[a-zA-Z]\s+\.data\s+([0-9a-f]+)\s+(.*)$')
