diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/Makefile linux-2.2.19-0.98.0-ibr-sparc/Makefile
--- linux-2.2.19-0.98.0/Makefile	Sat Apr 21 17:00:53 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/Makefile	Mon Apr 23 01:39:00 2001
@@ -3,7 +3,8 @@
 SUBLEVEL = 19
 EXTRAVERSION = 
 
-ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+#ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+ARCH=sparc
 
 .EXPORT_ALL_VARIABLES:
 
@@ -18,7 +19,7 @@
 HOSTCC  	=gcc
 HOSTCFLAGS	=-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 
-CROSS_COMPILE 	=
+CROSS_COMPILE 	=sparc-sun-linux-
 
 AS	=$(CROSS_COMPILE)as
 LD	=$(CROSS_COMPILE)ld
@@ -104,10 +105,12 @@
 # standard CFLAGS
 #
 
+CFLAGS = -g -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+
 ifdef CONFIG_MOSIX_UDB
-CFLAGS = -Wall -Wstrict-prototypes -O2 -fno-omit-frame-pointer
+#CFLAGS = -Wall -Wstrict-prototypes -O2 -fno-omit-frame-pointer
 else
-CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+#CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
 endif
 
 # use '-fno-strict-aliasing', but only if the compiler can take it
@@ -134,21 +137,21 @@
 DRIVERS		=drivers/block/block.a \
 		 drivers/char/char.o \
 	         drivers/misc/misc.a
-LIBS		=$(TOPDIR)/lib/lib.a
+LIBS		=lib/lib.a
 ifdef CONFIG_MOSIX
 ifdef CONFIG_MOSIX_MODULE
-MOSIXS		=$(TOPDIR)/mos/mos.o
+MOSIXS		=mos/mos.o
 SUBDIRS		=mos kernel drivers mm fs net ipc lib
 MOD_SUB_DIRS	+= mosix
 else
-MOSIXS		=$(TOPDIR)/mosix/mosix.o $(TOPDIR)/mos/mos.o
+MOSIXS		=mosix/mosix.o mos/mos.o
 SUBDIRS		=mos mosix kernel drivers mm fs net ipc lib
 endif
 else
 SUBDIRS		=kernel drivers mm fs net ipc lib
 endif
 ifdef CONFIG_MOSIX_UDB
-MOSIXS		+= $(TOPDIR)/udb/debugger.o
+MOSIXS		+= udb/debugger.o
 SUBDIRS		+= udb
 endif
 
@@ -259,48 +262,37 @@
 boot: vmlinux
 	@$(MAKE) -C arch/$(ARCH)/boot
 
+
+OBJS1	= $(HEAD) init/main.o init/version.o
+OBJS2	= $(FILESYSTEMS) $(NETWORKS) $(DRIVERS) $(LIBS)
+
 ifdef CONFIG_MOSIX
+OBJS2  := $(MOSIXS) $(OBJS2)
+endif
+
+
 vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs
-	$(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \
-		--start-group \
-		$(CORE_FILES) \
-		$(MOSIXS) \
-		$(FILESYSTEMS) \
-		$(NETWORKS) \
-		$(DRIVERS) \
-		$(LIBS) \
-		--end-group \
-		-o vmlinux
-else
-vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs
-	$(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \
+	$(LD) $(LINKFLAGS) $(OBJS1) \
 		--start-group \
 		$(CORE_FILES) \
-		$(FILESYSTEMS) \
-		$(NETWORKS) \
-		$(DRIVERS) \
-		$(LIBS) \
+		$(OBJS2) \
 		--end-group \
 		-o vmlinux
-endif
 ifdef CONFIG_MOSIX_UDB
 	$(NM) vmlinux | grep -v '\(compiled\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' > vmlinux.symtab
 	udb/symtab < vmlinux.symtab > udb/symbols.c
 	$(CC) -c $(CFLAGS) udb/symbols.c -o udb/symbols.o
-	$(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \
+	$(LD) $(LINKFLAGS) $(OBJS1) \
 		--start-group \
 		$(CORE_FILES) \
-		$(MOSIXS) \
-		$(FILESYSTEMS) \
-		$(NETWORKS) \
-		$(DRIVERS) \
-		$(LIBS) \
+		$(OBJS2) \
 		--end-group \
 		udb/symbols.o \
 		-o vmlinux
 endif
 	$(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
 
+
 symlinks:
 	rm -f include/asm
 	( cd include ; ln -sf asm-$(ARCH) asm)
@@ -473,10 +465,6 @@
 		rm -f core `find modules/ -type f -print`; \
 	fi
 	rm -f submenu*
-ifdef CONFIG_MOSIX
-# We would have liked to enclose the following 4 lines within
-# an ifdef CONFIG_MOSIX, but it does not work...
-endif
 	rm -f arch/i386/kernel/mosasm.h arch/i386/kernel/offset
 	rm -f mos/mkext mos/mkdefcalls mos/auto_syscalls.c mos/auto_export.c
 	rm -f mos/alternate.c include/mos/fill.h include/mos/shorthand.h
@@ -512,6 +500,7 @@
 	rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
 		-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
 		-o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS
+	rm -f include/mosix/config.h mosix/compile.h
 
 backup: mrproper
 	cd .. && tar cf - linux/ | gzip -9 > backup.gz
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/Makefile linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/Makefile
--- linux-2.2.19-0.98.0/arch/sparc/Makefile	Tue Jan  4 20:12:12 2000
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/Makefile	Sat Apr 21 17:17:31 2001
@@ -41,8 +41,9 @@
 CORE_FILES := arch/sparc/kernel/kernel.o arch/sparc/mm/mm.o $(CORE_FILES) \
 	arch/sparc/math-emu/math-emu.o
 
-LIBS := $(TOPDIR)/lib/lib.a $(LIBS) $(TOPDIR)/arch/sparc/prom/promlib.a \
-	$(TOPDIR)/arch/sparc/lib/lib.a
+LIBS := $(LIBS) \
+	arch/sparc/prom/promlib.a \
+	arch/sparc/lib/lib.a
 
 ifdef CONFIG_AP1000
 SUBDIRS := $(SUBDIRS) arch/sparc/ap1000 mpp
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/boot/Makefile linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/boot/Makefile
--- linux-2.2.19-0.98.0/arch/sparc/boot/Makefile	Tue Oct 27 19:52:20 1998
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/boot/Makefile	Sat Apr 21 17:17:31 2001
@@ -22,16 +22,17 @@
 clean:
 	rm -f btfixupprep piggyback tftpboot.img btfix.o btfix.s
 
-BTOBJS := $(HEAD) init/main.o init/version.o \
-	$(CORE_FILES_NO_BTFIX) $(FILESYSTEMS) \
-	$(NETWORKS) $(DRIVERS)
-
 # I wanted to make this depend upon BTOBJS so that a parallel
 # build would work, but this fails because $(HEAD) cannot work
 # properly as it will cause head.o to be built with the implicit
 # rules not the ones in kernel/Makefile.  Someone please fix. --DaveM
 vmlinux.o: dummy
-	$(LD) -r $(patsubst %,$(TOPDIR)/%,$(BTOBJS)) $(LIBS) -o vmlinux.o
+	$(LD) -r $(patsubst %,$(TOPDIR)/%,$(OBJS1)) \
+		--start-group \
+		$(patsubst %,$(TOPDIR)/%,$(CORE_FILES_NO_BTFIX)) \
+		$(patsubst %,$(TOPDIR)/%,$(OBJS2)) \
+		--end-group \
+		-o vmlinux.o
 
 btfix.s: btfixupprep vmlinux.o
 	$(OBJDUMP) -x vmlinux.o | ./btfixupprep > btfix.s
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/config.in linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/config.in
--- linux-2.2.19-0.98.0/arch/sparc/config.in	Mon Apr  9 19:09:38 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/config.in	Mon Apr 23 10:44:08 2001
@@ -5,6 +5,32 @@
 mainmenu_name "Linux/SPARC Kernel Configuration"
 
 mainmenu_option next_comment
+comment 'MOSIX'
+bool 'MOSIX process migration support' CONFIG_MOSIX
+if [ "$CONFIG_MOSIX" = "y" ]; then
+#	define_bool CONFIG_MOSIX_MODULE y  ibr begin end
+	bool 'Support clusters with a complex network topology' CONFIG_MOSIX_TOPOLOGY
+	if [ "$CONFIG_MOSIX_TOPOLOGY" = "y" ]; then
+	    int  'Maximum network-topology complexity to support (2-10)' CONFIG_MOSIX_MAXTOPOLOGY 4
+	fi
+	
+	bool 'MOSIX Kernel Debugger' CONFIG_MOSIX_UDB
+	if [ "$CONFIG_MOSIX_UDB" = "y" ]; then
+		bool 'MOSIX Kernel Debugging Code' CONFIG_MOSIX_DEBUG
+		bool 'Allow migration to self (for easyier testing)' CONFIG_MOSIX_CHEAT_MIGSELF
+		bool 'Process-arrival messages' CONFIG_MOSIX_WEEEEEEEEE
+	fi
+	bool 'MOSIX Kernel Diagnostics' CONFIG_MOSIX_DIAG
+	bool 'Prevent the -mosix extension in kernel name' CONFIG_MOSIX_NOEXT
+	bool 'Stricter security on MOSIX ports' CONFIG_MOSIX_SECUREPORTS
+	int  'Level of process-identity disclosure (0-3)' CONFIG_MOSIX_DISCLOSURE 1
+	bool 'Direct File-System Access (Alpha-testers)' CONFIG_MOSIX_DFSA
+	bool 'MOSIX File-System (Alpha-testers)' CONFIG_MOSIX_FS
+	bool 'Poll/Select exceptions on pipes' CONFIG_MOSIX_PIPE_EXCEPTIONS
+fi
+endmenu
+
+mainmenu_option next_comment
 comment 'Code maturity level options'
 bool 'Prompt for development and/or incomplete code/drivers' CONFIG_EXPERIMENTAL
 endmenu
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/defconfig linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/defconfig
--- linux-2.2.19-0.98.0/arch/sparc/defconfig	Mon Apr  9 19:09:38 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/defconfig	Mon Apr 23 10:43:57 2001
@@ -3,6 +3,26 @@
 #
 
 #
+# MOSIX options
+#
+
+CONFIG_MOSIX=y
+#CONFIG_MOSIX_MODULE=y
+# CONFIG_MOSIX_TOPOLOGY is not set
+CONFIG_MOSIX_MAXTOPOLOGY=4
+# CONFIG_MOSIX_UDB is not set
+# CONFIG_MOSIX_CHEAT_MIGSELF is not set
+# CONFIG_MOSIX_DEBUG is not set
+# CONFIG_MOSIX_WEEEEEEEEE is not set
+# CONFIG_MOSIX_NOEXT is not set
+CONFIG_MOSIX_DIAG=y
+CONFIG_MOSIX_SECUREPORTS=y
+CONFIG_MOSIX_DISCLOSURE=1
+# CONFIG_MOSIX_DFSA is not set
+# CONFIG_MOSIX_FS is not set
+# CONFIG_MOSIX_PIPE_EXCEPTIONS is not set
+
+#
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/kernel/process.c linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/kernel/process.c
--- linux-2.2.19-0.98.0/arch/sparc/kernel/process.c	Tue Jan  4 20:12:12 2000
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/kernel/process.c	Sat May 19 16:34:32 2001
@@ -510,6 +510,10 @@
 	if(regs->psr & PSR_PS)
 		stack_offset -= REGWIN_SZ;
 	childregs = ((struct pt_regs *) (((unsigned long)p) + stack_offset));
+#ifdef CONFIG_MOSIX
+	p->mosix.altregs = (mu32 *)childregs;
+	p->mosix.deputy_regs = current->mosix.deputy_regs;
+#endif  /* CONFIG_MOSIX */
 	copy_regs(childregs, regs);
 	new_stack = (((struct reg_window *) childregs) - 1);
 	copy_regwin(new_stack, (((struct reg_window *) regs) - 1));
@@ -720,3 +724,34 @@
 			   "g1", "g2", "g3", "o0", "o1", "memory", "cc");
 	return retval;
 }
+
+#ifdef CONFIG_MOSIX  /* ibr begin */
+/* see arch/i386/kernel/i386/process.c, mos/mig.c */
+pid_t user_thread(int (*fn)(void *), void * arg, unsigned long flags)
+{
+	long retval;
+
+	__asm__ __volatile("mov %4, %%g2\n\t"    /* Set aside fn ptr... */
+			   "mov %5, %%g3\n\t"    /* and arg. */
+			   "mov %1, %%g1\n\t"
+			   "mov %2, %%o0\n\t"    /* Clone flags. */
+			   "mov 0, %%o1\n\t"     /* usp arg == 0 */
+			   "t 0x10\n\t"          /* Linux/Sparc clone(). */
+			   "cmp %%o1, 0\n\t"
+			   "be 1f\n\t"           /* The parent, just return. */
+			   " nop\n\t"            /* Delay slot. */
+			   /*"sub %%sp, %6, %%sp"*/  /* space for user-registers? */
+			   "jmpl %%g2, %%o7\n\t" /* Call the function. */
+			   " mov %%g3, %%o0\n\t" /* Get back the arg in delay. */
+			   "mov %3, %%g1\n\t"
+			   "t 0x10\n\t"          /* Linux/Sparc exit(). */
+			   /* Notreached by child. */
+			   "1: mov %%o0, %0\n\t" :
+			   "=r" (retval) :
+			   "i" (__NR_clone), "r" (flags | SIGCHLD),
+			   "i" (__NR_exit),  "r" (fn), "r" (arg),
+			   "i" (sizeof(struct pt_regs)) :
+			   "g1", "g2", "g3", "o0", "o1", "memory", "cc");
+	return retval;
+}
+#endif  /* MOSIX_CONFIG ibr end */
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/kernel/ptrace.c linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/kernel/ptrace.c
--- linux-2.2.19-0.98.0/arch/sparc/kernel/ptrace.c	Tue Jan  4 20:12:12 2000
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/kernel/ptrace.c	Sat Apr 21 17:17:31 2001
@@ -22,6 +22,10 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
+#ifdef CONFIG_MOSIX
+#include <linux/mosix.h>
+#endif CONFIG_MOSIX
+
 #define MAGIC_CONSTANT 0x80000000
 
 /*
@@ -188,11 +192,20 @@
  * This routine checks the page boundaries, and that the offset is
  * within the task area. It then calls get_long() to read a long.
  */
+#ifdef CONFIG_MOSIX  /* ibr begin */
+int read_long(struct task_struct * tsk, unsigned long addr,
+		     unsigned long * result)
+{
+	struct vm_area_struct * vma;
+
+        if(tsk != current)
+                return(request_process(tsk, result, PR_PTRACE_READ_LONG, addr));	vma = find_extend_vma(tsk, addr);
+#else
 static int read_long(struct task_struct * tsk, unsigned long addr,
 		     unsigned long * result)
 {
 	struct vm_area_struct * vma = find_extend_vma(tsk, addr);
-
+#endif CONFIG_MOSIX  /* ibr end */
 	if (!vma)
 		return -EIO;
 	*result = get_long(tsk, vma, addr);
@@ -229,10 +242,22 @@
  * This routine checks the page boundaries, and that the offset is
  * within the task area. It then calls put_long() to write a long.
  */
+#ifdef CONFIG_MOSIX  /* ibr begin */
+int write_long(struct task_struct * tsk, unsigned long addr,
+		      unsigned long data)
+{
+	struct vm_area_struct * vma;
+
+        if (tsk != current)
+                return(request_process_arg2(tsk, NULL, PR_PTRACE_WRITE_LONG,
+                        (int)addr, (int)data));
+	vma = find_extend_vma(tsk, addr);
+#else
 static int write_long(struct task_struct * tsk, unsigned long addr,
 		      unsigned long data)
 {
 	struct vm_area_struct * vma = find_extend_vma(tsk, addr);
+#endif CONFIG_MOSIX  /* ibr end */
 
 	if (!vma)
 		return -EIO;
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/kernel/rtrap.S linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/kernel/rtrap.S
--- linux-2.2.19-0.98.0/arch/sparc/kernel/rtrap.S	Wed Aug  5 02:03:34 1998
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/kernel/rtrap.S	Sat May 19 19:01:58 2001
@@ -3,7 +3,11 @@
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  */
-
+/*
+ * MOSIX support code copyright (c) 2001, Baurjan Ismagulov.
+ * Changes:
+ * 11.05.2001  Added call to mosix_pre_usermode_actions before jumping to user mode.
+ */
 #include <asm/cprefix.h>
 #include <asm/page.h>
 #include <asm/ptrace.h>
@@ -92,6 +96,13 @@
 	ld	[%sp + REGWIN_SZ + PT_PSR], %t_psr
 	clr	%l6
 ret_trap_continue:
+/* ibr begin */
+	call	C_LABEL(mosix_pre_usermode_actions)
+	 add	%sp, REGWIN_SZ, %o0	! struct pt_regs *
+	orcc	%o0, %o0, %g0		! mimicking i386 behaviour
+	bne	ret_trap_entry
+	 nop
+/* ibr end */
 	wr	%t_psr, 0x0, %psr
 	WRITE_PAUSE
 
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/arch/sparc/mm/fault.c linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/mm/fault.c
--- linux-2.2.19-0.98.0/arch/sparc/mm/fault.c	Tue Jan  4 20:12:13 2000
+++ linux-2.2.19-0.98.0-ibr-sparc/arch/sparc/mm/fault.c	Sun May  6 10:52:13 2001
@@ -32,6 +32,10 @@
 #include <asm/kdebug.h>
 #include <asm/uaccess.h>
 
+#ifdef CONFIG_MOSIX
+#include <linux/mosix.h>
+#endif CONFIG_MOSIX
+
 #define ELEMENTS(arr) (sizeof (arr)/sizeof (arr[0]))
 
 extern struct sparc_phys_banks sp_banks[SPARC_PHYS_BANKS];
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/drivers/char/console.c linux-2.2.19-0.98.0-ibr-sparc/drivers/char/console.c
--- linux-2.2.19-0.98.0/drivers/char/console.c	Sat Apr 21 17:00:53 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/drivers/char/console.c	Mon Apr 23 18:51:00 2001
@@ -2070,6 +2070,7 @@
 }
 
 #ifdef CONFIG_MOSIX_UDB
+#ifdef __i386__  /* ibr begin */
 int
 vt_console_read(struct console *co, const char *into, unsigned cnt)
 {
@@ -2093,6 +2094,12 @@
 	keyboard_manual_mode(0);
 	return(n);
 }
+#else
+int vt_console_read(struct console *co, const char *into, unsigned cnt)
+{
+	return 0;
+}
+#endif  /* __i386__ ibr end */
 #endif CONFIG_MOSIX_UDB
 
 static kdev_t vt_console_device(struct console *c)
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/fs/binfmt_elf.c linux-2.2.19-0.98.0-ibr-sparc/fs/binfmt_elf.c
--- linux-2.2.19-0.98.0/fs/binfmt_elf.c	Sat Apr 21 17:00:53 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/fs/binfmt_elf.c	Mon Apr 23 19:03:18 2001
@@ -429,7 +429,9 @@
 		goto out;
 #ifdef CONFIG_MOSIX
 #ifndef __i386__
+#if 0  /* ibr begin */
 On platforms where "flush_icache_range" is non-empty, it has to distributed
+#endif  /* ibr end */
 #endif __i386__
 #endif CONFIG_MOSIX
 	flush_icache_range((unsigned long)addr,
@@ -806,8 +808,11 @@
 	extras.gid = current->gid;
 	extras.egid = current->egid;
 	extras.hwcap = ELF_HWCAP;
+#ifdef __i386__  /* ibr begin */
 	memcpy(extras.platform, ELF_PLATFORM, sizeof(extras.platform));
+	/* ELF_PLATFORM is NULL on sparc */
 	extras.cpu_model = ELF_CPU_MODEL;
+#endif  /* ibr end */
 	if(current->mosix.dflags & DDEPUTY)
 		bprm->p = mosix_deputy_elf_setup((char *)bprm->p,
 			bprm->argc, bprm->envc,
@@ -876,12 +881,14 @@
 
 #ifdef CONFIG_MOSIX
 	}
+#ifdef __i386__  /* ibr begin */
 	mosix_obtain_registers(BIT_OF_REGISTER(xds)|BIT_OF_REGISTER(xes)|
 		BIT_OF_REGISTER(xss)|BIT_OF_REGISTER(xcs)|BIT_OF_REGISTER(eip)|
 #ifdef ELF_PLAT_INIT
 		ELF_PLAT_INIT_REGS|
 #endif ELF_PLAT_INIT
 		BIT_OF_REGISTER(esp));
+#endif  /* ibr end */
 #endif CONFIG_MOSIX
 
 #ifdef ELF_PLAT_INIT
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/fs/exec.c linux-2.2.19-0.98.0-ibr-sparc/fs/exec.c
--- linux-2.2.19-0.98.0/fs/exec.c	Sat Apr 21 17:00:53 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/fs/exec.c	Sun May  6 20:34:10 2001
@@ -392,7 +392,7 @@
 		result = dfsa_optimized_read(&file, offset, (int)addr, count);
 #else
 		result = file.f_op->read(&file, addr, count, &file.f_pos);
-#endif CONFIG_MSOIX_DFSA
+#endif CONFIG_MOSIX_DFSA
 	}
 close_readexec:
 	if (file.f_op->release)
@@ -474,7 +474,7 @@
  * disturbing other processes.  (Other processes might share the signal
  * table via the CLONE_SIGHAND option to clone().)
  */
- 
+
 static inline int make_private_signals(void)
 {
 	struct signal_struct * newsig;
@@ -935,7 +935,18 @@
 #ifdef CONFIG_MOSIX
 	current->mosix.inexec = &bprm;
 	if((current->mosix.dflags & DDEPUTY) && retval >= 0)
-		retval = mosix_deputy_bring_strings(&bprm.p, (char *)regs->ebx,
+		retval = mosix_deputy_bring_strings(&bprm.p,
+#if defined(__i386__)  /* ibr begin */
+				(char *)regs->ebx,
+#elif defined(__sparc__)
+				(char *)regs->u_regs[/*base +*/ UREG_I0],
+/* user-supplied pathname?
+   mimicked according to the original i386 code above.
+   this code might break if a SunOS binary executes
+   indirect syscall (syscall 0)?
+   see also arch/sparc/kernel/process.c:sparc_execve()
+        and arch/sparc/kernel/entry.S:sunos_indir(). */
+#endif  /* ibr end */
 				&bprm.exec, envp, bprm.envc, argv, bprm.argc);
 	else
 #endif CONFIG_MOSIX
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/fs/proc/array.c linux-2.2.19-0.98.0-ibr-sparc/fs/proc/array.c
--- linux-2.2.19-0.98.0/fs/proc/array.c	Sat Apr 21 17:00:53 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/fs/proc/array.c	Mon Apr 23 18:52:07 2001
@@ -1126,10 +1126,12 @@
 		t->start_code = tsk->mm->start_code;
 		t->end_code = tsk->mm->end_code;
 		t->start_stack = tsk->mm->start_stack;
+#ifdef __i386__  /* ibr begin */
 		if(tsk == current && (tsk->mosix.dflags & DREMOTE))
 		/* just in case EIP and/or ESP are held by DEPUTY: */
 			mosix_obtain_registers(
 				BIT_OF_REGISTER(eip)|BIT_OF_REGISTER(esp));
+#endif  /* ibr end */
 		t->eip = KSTK_EIP(tsk);
 		t->esp = KSTK_ESP(tsk);
 	}
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/asm-sparc/atomic.h linux-2.2.19-0.98.0-ibr-sparc/include/asm-sparc/atomic.h
--- linux-2.2.19-0.98.0/include/asm-sparc/atomic.h	Sun Mar 25 14:06:29 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/asm-sparc/atomic.h	Mon May 14 01:46:07 2001
@@ -138,6 +138,32 @@
 #define atomic_inc(v) atomic_add(1,(v))
 #define atomic_dec(v) atomic_sub(1,(v))
 
+/* ibr begin */
+static __inline__ void __atomic_set_mask32(unsigned long mask, unsigned int __volatile__ *addr)
+{
+	*addr |= mask;
+}
+
+static __inline__ void __atomic_clear_mask32(unsigned long mask, unsigned int __volatile__ *addr)
+{
+	*addr &= ~mask;
+}
+
+static __inline__ void __atomic_set_mask(unsigned long mask, unsigned long *addr)
+{
+	*addr |= mask;
+}
+
+static __inline__ void __atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+	*addr &= ~mask;
+}
+
+#define atomic_set_mask(mask, addr)	__atomic_set_mask32(mask, addr)
+#define atomic_clear_mask(mask, addr)	__atomic_clear_mask32(mask, addr)
+
+/* ibr end */
+
 #endif /* !(__KERNEL__) */
 
 #endif /* !(__ARCH_SPARC_ATOMIC__) */
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/asm-sparc/siginfo.h linux-2.2.19-0.98.0-ibr-sparc/include/asm-sparc/siginfo.h
--- linux-2.2.19-0.98.0/include/asm-sparc/siginfo.h	Mon Apr  9 19:09:49 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/asm-sparc/siginfo.h	Sun Apr 22 16:36:05 2001
@@ -62,6 +62,12 @@
 			int _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
 			int _fd;
 		} _sigpoll;
+#ifdef CONFIG_MOSIX  /* ibr begin */
+		struct {
+			int _newplace;
+			int _reason;
+		} _sigmig;
+#endif CONFIG_MOSIX  /* ibr end */
 	} _sifields;
 } siginfo_t;
 
@@ -80,6 +86,10 @@
 #define si_trapno	_sifields._sigfault._trapno
 #define si_band		_sifields._sigpoll._band
 #define si_fd		_sifields._sigpoll._fd
+#ifdef CONFIG_MOSIX  /* ibr begin */
+#define       si_newplace     _sifields._sigmig._newplace
+#define       si_reason       _sifields._sigmig._reason
+#endif CONFIG_MOSIX  /* ibr end */
 
 /*
  * si_code values
@@ -92,6 +102,9 @@
 #define SI_MESGQ	-3	/* sent by real time mesq state change */
 #define SI_ASYNCIO	-4	/* sent by AIO completion */
 #define SI_SIGIO	-5	/* sent by queued SIGIO */
+#ifdef CONFIG_MOSIX  /* ibr begin */
+#define SI_MIGRATION    0x100   /* sent by migration */
+#endif CONFIG_MOSIX  /* ibr end */
 
 #define SI_FROMUSER(siptr)	((siptr)->si_code <= 0 && (siptr)->si_code != SI_SIGIO)
 #define SI_FROMKERNEL(siptr)	((siptr)->si_code > 0 || (siptr)->si_code == SI_SIGIO)
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/linux/mosix.h linux-2.2.19-0.98.0-ibr-sparc/include/linux/mosix.h
--- linux-2.2.19-0.98.0/include/linux/mosix.h	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/linux/mosix.h	Fri May 18 11:40:56 2001
@@ -106,7 +106,9 @@
 extern int deputy_mprotect(unsigned long, size_t, unsigned long);
 extern void mosix_deputy_rlimit(int, struct rlimit);
 extern void mosix_deputy_copy_filename(struct linux_binprm *, int);
+#ifdef __i386__  /* ibr begin */
 extern int mosix_deputy_dump_fpu(struct user_i387_struct *);
+#endif  /* ibr end */
 extern int mosix_sync_caps(kernel_cap_t);
 
 #define	ALL_REGISTERS	0x7fff	/* as many as in struct pt_regs */
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/mos/debug.h linux-2.2.19-0.98.0-ibr-sparc/include/mos/debug.h
--- linux-2.2.19-0.98.0/include/mos/debug.h	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/mos/debug.h	Mon Apr 23 19:11:11 2001
@@ -64,10 +64,21 @@
 
 #endif CONFIG_MOSIX_DEBUG
 
+
 #ifdef CONFIG_MOSIX_UDB
+
+#if defined(__i386__)  /* ibr begin */
 extern void mosix_debugger(char *);
 #define mosix_panic	mosix_debugger
-#else
+#elif defined(__sparc__)
+#define mosix_debugger(str)	breakpoint()
+#define mosix_panic(str)	breakpoint()
+void breakpoint(void);  /* arch/sparc/kernel/sparc-stub.c */
+#endif  /* ibr end */
+
+#else  /* CONFIG_MOSIX_UDB */
 #define mosix_panic	panic
-#endif CONFIG_MOSIX_UDB
+#endif  /* CONFIG_MOSIX_UDB */
+
+
 #endif
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/mos/hardirq.h linux-2.2.19-0.98.0-ibr-sparc/include/mos/hardirq.h
--- linux-2.2.19-0.98.0/include/mos/hardirq.h	Thu Jan  1 02:00:00 1970
+++ linux-2.2.19-0.98.0-ibr-sparc/include/mos/hardirq.h	Sat Apr 21 17:17:31 2001
@@ -0,0 +1,15 @@
+#ifndef _MOS_HARDIRQ_H
+#define _MOS_HARDIRQ_H
+
+#include <asm/hardirq.h>
+
+#define LOCAL_IRQ_COUNT(cpu)    local_irq_count[cpu]
+
+#ifdef __sparc__
+#ifndef __SMP__
+#undef LOCAL_IRQ_COUNT
+#define LOCAL_IRQ_COUNT(cpu)    local_irq_count
+#endif
+#endif
+
+#endif _MOS_HARDIRQ_H
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/mos/mosixtask.h linux-2.2.19-0.98.0-ibr-sparc/include/mos/mosixtask.h
--- linux-2.2.19-0.98.0/include/mos/mosixtask.h	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/mos/mosixtask.h	Sat Apr 21 17:17:31 2001
@@ -19,6 +19,10 @@
 #ifndef _LINUX_MOSIXTASK_H
 #define _LINUX_MOSIXTASK_H
 
+#ifdef __sparc__  /* ibr begin */
+#include <asm/head.h>  /* for KERNBASE -- see task_size hack in INIT_TASK macro */
+#endif  /* ibr end */
+
 typedef long long m64;
 typedef int m32;
 typedef unsigned int mu32;
@@ -165,6 +169,12 @@
 #define DFSA_INIT_TASK
 #endif CONFIG_MOSIX_DFSA
 
+#if defined(__i386__)  /* ibr begin */
+#define __INIT_TASK_TASK_SIZE	TASK_SIZE,
+#elif defined(__sparc__)
+#define __INIT_TASK_TASK_SIZE	KERNBASE /* hack -- TASK_SIZE isn't a constant on sparc. */,
+#endif  /* ibr end */
+
 #ifdef CONFIG_MOSIX_FS
 #define	MFS_INIT_TASK	0, 0, NULL, 0, 0, 0, 0, NULL, 0, 0, 0, NULL,
 #else
@@ -236,7 +246,7 @@
 /* ps */	NULL,	\
 /* memusage */	0,0,0,	\
 /* last_memsort */ 0,   \
-/* task_size */ TASK_SIZE, \
+__INIT_TASK_TASK_SIZE  /* ibr begin end */ \
 /* depinfo */	{0, 0},	\
 DFSA_INIT_TASK \
 MFS_INIT_TASK \
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/mos/protocol.h linux-2.2.19-0.98.0-ibr-sparc/include/mos/protocol.h
--- linux-2.2.19-0.98.0/include/mos/protocol.h	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/mos/protocol.h	Mon Apr 23 19:07:58 2001
@@ -37,7 +37,9 @@
 	short reason;
 	short topology;
 	int personality;
+#ifdef __i386__  /* ibr begin */
 	int wp_works_ok;
+#endif  /* ibr end */
 	int pages_sent;
 	int from_remote;
 	int has_dfsa;
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/include/mos/request.h linux-2.2.19-0.98.0-ibr-sparc/include/mos/request.h
--- linux-2.2.19-0.98.0/include/mos/request.h	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/include/mos/request.h	Mon Apr 23 19:08:21 2001
@@ -107,8 +107,10 @@
 extern void ptrace_pokeuser(long, long);
 extern void ptrace_cont(int);
 extern void ptrace_single_step(void);
+#ifdef __i386__  /* ibr begin */
 extern void ptrace_getfpregs(struct user_i387_struct *);
 extern void ptrace_setfpregs(struct user_i387_struct *);
+#endif  /* ibr end */
 extern struct file *first_executable(void); 
 
 #endif CONFIG_MOSIX
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/kernel/panic.c linux-2.2.19-0.98.0-ibr-sparc/kernel/panic.c
--- linux-2.2.19-0.98.0/kernel/panic.c	Sat Apr 21 17:00:53 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/kernel/panic.c	Sun Apr 22 18:27:07 2001
@@ -16,6 +16,10 @@
 #include <linux/sysrq.h>
 #include <linux/interrupt.h>
 
+#ifdef CONFIG_MOSIX_UDB  /* ibr begin */
+#include <mos/debug.h>
+#endif  /* ibr end */
+
 asmlinkage void sys_sync(void);	/* it's really int */
 extern void unblank_console(void);
 extern int C_A_D;
@@ -88,7 +92,9 @@
 		CHECK_EMERGENCY_SYNC
 #ifdef CONFIG_MOSIX_UDB
 	{
+#if 0  /* ibr begin */
 		extern void mosix_debugger(char *);
+#endif  /* ibr end */
 		mosix_debugger("panic");
 	}
 #endif CONFIG_MOSIX_UDB
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/Makefile linux-2.2.19-0.98.0-ibr-sparc/mos/Makefile
--- linux-2.2.19-0.98.0/mos/Makefile	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/Makefile	Fri May 11 14:33:01 2001
@@ -16,11 +16,19 @@
 # unless it's something special (ie not a .c file).
 #
 
+# ibr begin
+CFLAGS += -O1 -fno-omit-frame-pointer
+# ibr end
+
 O_TARGET := mos.o
 O_OBJS   := kernel.o prequest.o mosproc.o mosadmin.o calcmem.o \
 	    mosmodule.o mosdecay.o link.o alternate.o interface.o service.o \
 	    auto_syscalls.o comm.o config.o mig.o deputy.o remote.o \
-	    log.o syscalls.o rinode.o cache.o div.o
+	    log.o syscalls.o rinode.o cache.o
+
+ifeq ($(ARCH),i386)
+O_OBJS += div.o
+endif
 
 ifdef CONFIG_MOSIX_DFSA
 O_OBJS += dfsa.o badops.o
@@ -33,13 +41,13 @@
 first_rule: $(TOPDIR)/include/mos/shorthand.h $(TOPDIR)/include/mos/fill.h
 
 mkext: mkext.c
-	$(HOSTCC) $(HOSTCFLAGS) -o mkext mkext.c
+	$(HOSTCC) $(HOSTCFLAGS) -DARCH=$(ARCH) -o mkext mkext.c
 
-auto_syscalls.c: mkdefcalls $(TOPDIR)/arch/i386/kernel/entry.S syscalls.c
+auto_syscalls.c: mkdefcalls $(TOPDIR)/arch/$(ARCH)/kernel/entry.S syscalls.c
 	./mkdefcalls
 
 mkdefcalls: mkdefcalls.c $(TOPDIR)/include/linux/config.h $(TOPDIR)/include/linux/types.h $(TOPDIR)/include/linux/sched.h $(TOPDIR)/include/linux/signal.h $(TOPDIR)/include/linux/sys.h $(TOPDIR)/include/linux/kernel.h
-	$(HOSTCC) $(HOSTCFLAGS) -I$(HPATH) -o mkdefcalls -DENTRY_IN=\"$(TOPDIR)/arch/i386/kernel/entry.S\" -DSYSCALLS_IN=\"$(TOPDIR)/mos/syscalls.c\" -DSYSCALLS_OUT=\"$(TOPDIR)/mos/auto_syscalls.c\" mkdefcalls.c
+	$(HOSTCC) $(HOSTCFLAGS) -I$(HPATH) -o mkdefcalls -DENTRY_IN=\"$(TOPDIR)/arch/$(ARCH)/kernel/entry.S\" -DSYSCALLS_IN=\"$(TOPDIR)/mos/syscalls.c\" -DSYSCALLS_OUT=\"$(TOPDIR)/mos/auto_syscalls.c\" mkdefcalls.c
 
 link.S $(TOPDIR)/include/mos/shorthand.h $(TOPDIR)/include/mos/fill.h auto_export.c: extlist mkext
 	./mkext extlist link.S $(TOPDIR)/include/mos/fill.h $(TOPDIR)/include/mos/shorthand.h auto_export.c
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/cache.c linux-2.2.19-0.98.0-ibr-sparc/mos/cache.c
--- linux-2.2.19-0.98.0/mos/cache.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/cache.c	Sat Apr 21 17:17:31 2001
@@ -32,7 +32,7 @@
 extern void print_dcache(void);
 
 void
-breakpoint(char *str)
+mosix_breakpoint(char *str)
 {
 	KERNEL_LOCKED;
 	if(ds_debug & DSDEB_CACHE)
@@ -64,8 +64,8 @@
 }
 
 #else
-#define	breakpoint(x)		do {} while(0)
-#define	breakpoint1(x,a)	do {} while(0)
+#define	mosix_breakpoint(x)		do {} while(0)
+#define	breakpoint1(x,a)		do {} while(0)
 #endif CONFIG_MOSIX_DEBUG
 
 #define	CACHE_ENTRIES	10
@@ -156,7 +156,7 @@
 	}
 	d->next[CACHE_ENTRIES-1] = END_MARK;
 	d->prev[0] = END_MARK;
-	breakpoint("dcache allocated");
+	mosix_breakpoint("dcache allocated");
 	return(1);
 }
 
@@ -186,7 +186,7 @@
 
 	if(d)
 	{
-		breakpoint("free dcache");
+		mosix_breakpoint("free dcache");
 		for(i = d->first ; i != END_MARK ; i = d->next[i])
 		if((cb = d->bp[i]))
 		{
@@ -318,7 +318,7 @@
 
 	if(!d)
 		return;
-	breakpoint("flushing read_cache");
+	mosix_breakpoint("flushing read_cache");
 	if(!(current->mosix.dflags & DDEPUTY))
 	{
 		one_by_one:
@@ -329,7 +329,7 @@
 			data_was_read(d, i);
 			goto one_by_one;	/* list may be scrambled */
 		}
-		breakpoint("read cache flushed one by one");
+		mosix_breakpoint("read cache flushed one by one");
 		return;
 	}
 	for(n = 0 , i = d->first ; i != END_MARK ; i = d->next[i])
@@ -340,21 +340,21 @@
 	}
 	if(!n)
 	{
-		breakpoint("there was no read-cache to free");
+		mosix_breakpoint("there was no read-cache to free");
 		return;
 	}
 	if(n == 1)
 	{
 		write_read_cache(d, j);
 		data_was_read(d, j);
-		breakpoint("there was only one read-cache to free");
+		mosix_breakpoint("there was only one read-cache to free");
 		return;
 	}
 	if((p = pack_read_cache_data(&n)))
 	{
 		comm_send(DEP_CACHE_READ_DATA, NULL, 0, p, n, 0);
 		kfree(p);
-		breakpoint("freed multiple read-cache entries");
+		mosix_breakpoint("freed multiple read-cache entries");
 	}
 	else	/* no memory -- too bad: */
 		goto one_by_one;
@@ -546,7 +546,7 @@
 
 	if(!d || d->first == END_MARK)
 		return;
-	breakpoint("flush_dcache");
+	mosix_breakpoint("flush_dcache");
 	if(!(current->mosix.dflags & DREMOTE)) /* save time - no READDATA */
 		flush_read_cache();
 	for(i = 0 ; i < CACHE_ENTRIES ; i++)
@@ -691,7 +691,7 @@
 	breakpoint1("copy_from_cache from 0x%X - something relevant", from);
 	if(!d->bp[i] && !obtain_dcache_block(d, i, from))
 	{
-		breakpoint("copy_from_cache: failed allocating a cblock");
+		mosix_breakpoint("copy_from_cache: failed allocating a cblock");
 		free_dcache_entry(d, i);
 		*non_cache = find_non_cached(d, WRITE_STATUS|READDATA,
 								from, orlen);
@@ -778,7 +778,7 @@
 	}
 	if(zero_found)
 	{
-		breakpoint("zero found");
+		mosix_breakpoint("zero found");
 		*non_cache = -1;
 	}
 	else
@@ -852,7 +852,7 @@
 	breakpoint1("copy_to_cache from 0x%X - something relevant", to);
 	if(!d->bp[i] && !obtain_dcache_block(d, i, to))
 	{
-		breakpoint("copy_to_cache: failed allocating a cblock");
+		mosix_breakpoint("copy_to_cache: failed allocating a cblock");
 		cant_do_it:
 		free_dcache_entry(d, i);
 		*non_cache = find_non_cached(d, READ_STATUS|WRITEDATA,
@@ -879,7 +879,7 @@
 	 * but now we must discard this entry.
 	 */
 	{
-		breakpoint("copy_to_cache: Sorry Only read-permission");
+		mosix_breakpoint("copy_to_cache: Sorry Only read-permission");
 		goto cant_do_it;
 	}
 	breakpoint1("copy_to_cache: copying %d bytes", len);
@@ -977,7 +977,7 @@
 
 	sprintf(msg, "add_dcache_entry at 0x%X, len=0x%X", (int)addr, len);
 	lock_kernel();
-	breakpoint(msg);
+	mosix_breakpoint(msg);
 	if(len <= 0 || len > MAX_POSITIVE || addr + len < addr)
 		goto out;
 	if(!d)
@@ -1076,7 +1076,7 @@
 		goto next_part;
 	}
 	all_done:
-	breakpoint("after add_dcache_entry");
+	mosix_breakpoint("after add_dcache_entry");
 	out:
 	unlock_kernel();
 }
@@ -1339,7 +1339,7 @@
 		if(--cb->count == 0)
 			kfree(cb);
 	}
-	breakpoint("opened_dcache_envelope");
+	mosix_breakpoint("opened_dcache_envelope");
 	return(0);
 }
 
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/config.c linux-2.2.19-0.98.0-ibr-sparc/mos/config.c
--- linux-2.2.19-0.98.0/mos/config.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/config.c	Sun Apr 29 23:27:49 2001
@@ -259,11 +259,13 @@
 	int error = 0;
 	static char within;
 
+#ifdef __i386__  /* ibr begin */
 	if (!boot_cpu_data.hard_math)
 	{
 		printk("Sorry, MOSIX requires a math-unit.\n");
 		return(-ENODEV);
 	}
+#endif  /* ibr end */
 	if (within)
 		return(-EBUSY);
 	if (nents > MAX_MOSNET_ENTS)
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/deputy.c linux-2.2.19-0.98.0-ibr-sparc/mos/deputy.c
--- linux-2.2.19-0.98.0/mos/deputy.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/deputy.c	Mon Apr 23 19:17:17 2001
@@ -246,7 +246,9 @@
 			delay_sigs ^= 1;
 			deputy_add_rusage((struct rusage *)head);
 			comm_free(head);
+#ifdef __i386__  /* ibr begin */
 			do_syscall_trace();
+#endif  /* ebr end */
 			if(!(current->mosix.dflags & DDEPUTY))
 				break;
 			if(deputy_reply(REM_SYSCALL_TRACE, NULL, 0, NULL, 0, 0,
@@ -344,7 +346,9 @@
 	if(deputy_request(DEP_RESTORESIGCONTEXT, &frame, sizeof(frame), NULL,
 		0, 0, (void **)&r, -sizeof(r)))
 		r.result = 1;
+#ifdef __i386__  /* ibr begin */
 	mosix_obtain_registers(BIT_OF_REGISTER(esp));
+#endif  /* ibr end */
 	unlock_kernel();
 	*eax = r.eax;
 	return(r.result);
@@ -919,19 +923,25 @@
 		case __NR_vfork:
 		case __NR_clone:
 		case __NR_execve:
+#ifdef __i386__  /* ibr begin */
 		case __NR_iopl:
 		case __NR_ioperm:
+#endif  /* ibr end */
 		case __NR_sigsuspend:
 		case __NR_rt_sigsuspend:
 		case __NR_sigreturn:
 		case __NR_rt_sigreturn:
+#ifdef __i386__  /* ibr begin */
 		case __NR_vm86old:
 		case __NR_vm86:
+#endif  /* ibr end */
 			if(delay_sigs)
 				atomic_set_mask(DTRACESYS1, &p->mosix.dflags);
 				/* (for the son to set "delay_sigs") */
+#ifdef __i386__  /* ibr begin */
 			r.ret = call_with_regs((void *)sys_call_table[n],
 								&regs, &regs);
+#endif  /* ibr end */
 			atomic_clear_mask(DTRACESYS1, &p->mosix.dflags);
 			if(p->mosix.deputy_regs ||
 					!(current->mosix.dflags & DDEPUTY))
@@ -946,7 +956,9 @@
 	}
 	if(!(p->mosix.dflags & DDEPUTY))
 	{
+#ifdef __i386__  /* ibr begin */
 		mos_to_regs(&current->mosix)->eax = r.ret;
+#endif  /* ibr end */
 		return;
 	}
 	cdata = deputy_pack_read_cache_data(&l, &r, &tofree);
@@ -1016,12 +1028,14 @@
 {
 	u64 r;
 
+#ifdef __i386__  /* ibr begin */
 	__asm__ __volatile__(
 		"rdtsc\n\t"
 		"movl %%eax, 0(%%ebx)\n\t"
 		"movl %%edx, 4(%%ebx)"
 		: "=m" (r)
 		: "b" (&r));
+#endif  /* ibr end */
 	return(deputy_reply(REM_GETTSC|REPLY, &r, sizeof(r), NULL, 0, 0, 2));
 }
 
@@ -1193,7 +1207,11 @@
 
 	KERNEL_LOCKED;
 	flush_dcache();
+#ifdef __i386__  /* ibr begin */
 	if(!__addr_ok(filename))
+#else
+	if (0)
+#endif  /* ibr end */
 	{
 		/* new file-name in kernel */
 		register int i;
@@ -1325,7 +1343,11 @@
 	char *tofree = NULL;
 
 	KERNEL_LOCKED;
+#ifdef __i386__  /* ibr begin */
 	if(!__addr_ok(bprm->filename))	/* filename already in kernel */
+#else
+	if (0)
+#endif
 	{
 		i_name = java ? java_filename(bprm->filename) : bprm->filename;
 		goto doit;
@@ -1398,8 +1420,10 @@
 	if(deputy_request(DEP_DUMP_FPU, NULL, 0, NULL, 0, 0,
 		(void **)&r, -sizeof(r)))
 		return(0);
+#ifdef __i386__  /* ibr begin */
 	if(r && comm_copydata(f, sizeof(*f), 0))
 		return(0);
+#endif  /* ibr end */
 	return(r);
 }
 
@@ -1432,7 +1456,9 @@
 	f.do_forkmigrate = !migrated;
 	f.pid = son->pid;
 	resend:
+#ifdef __i386__  /* ibr begin */
 	m->pass_regs = ALL_REGISTERS & ~BIT_OF_REGISTER(eax);
+#endif  /* ibr end */
 	if(comm_send(DEP_PLEASE_FORK, &f, sizeof(f), NULL, 0, 0))
 	{
 		bad:
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/export2.c linux-2.2.19-0.98.0-ibr-sparc/mos/export2.c
--- linux-2.2.19-0.98.0/mos/export2.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/export2.c	Mon Apr 23 19:17:41 2001
@@ -23,6 +23,7 @@
 /* the following exports are required only for 3rd-party modules */
 /* (eg. not for the MOSIX load-balancing module) */
 
+#ifdef __i386__  /* ibr begin */
 EXPORT_SYMBOL(deputy_copy_to_user);
 EXPORT_SYMBOL(deputy_copy_from_user);
 EXPORT_SYMBOL(deputy_clear_user);
@@ -34,6 +35,7 @@
 EXPORT_SYMBOL(mosix_obtain_registers);
 EXPORT_SYMBOL(mosix_deputy_setup_args);
 EXPORT_SYMBOL(mosix_deputy_dump_thread);
+#endif  /* ibr end */
 
 #ifdef CONFIG_MOSIX_DFSA
 EXPORT_SYMBOL(dfsa_touch_file);
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/interface.c linux-2.2.19-0.98.0-ibr-sparc/mos/interface.c
--- linux-2.2.19-0.98.0/mos/interface.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/interface.c	Sun Apr 29 23:30:58 2001
@@ -186,15 +186,19 @@
 INLINE void
 use_fp_in_kernel(void)
 {
+#ifdef __i386__  /* ibr begin */
 	unlazy_fpu(current);
 	clts();
 	__asm__("fninit");
+#endif  /* ibr end */
 }
 
 INLINE void
 stop_using_fp_in_kernel(void)
 {
+#ifdef __i386__  /* ibr begin */
 	stts();
+#endif  /* ibr end */
 }
 
 #ifdef CONFIG_MOSIX_SEEKERNEL
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/kernel.c linux-2.2.19-0.98.0-ibr-sparc/mos/kernel.c
--- linux-2.2.19-0.98.0/mos/kernel.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/kernel.c	Mon May 21 12:28:39 2001
@@ -11,6 +11,11 @@
 /*
  * Author(s): Amnon Shiloh.
  */
+/*
+ * SPARC support code copyright (c) 2001, Baurjan Ismagulov.
+ * Changes:
+ * - user_mode check fix in mosix_pre_usermode_actions.
+ */
 #include <linux/sched.h>
 #include <linux/mosctl.h>
 #include <linux/mosix.h>
@@ -68,7 +73,10 @@
 int dep_consider_reply = DEP_CONSIDER | REPLY;
 
 #ifdef CONFIG_MOSIX_DEBUG
-unsigned long ds_debug;		/* generic debug mask */
+/* ibr begin */
+/* DSDEB_* #define's in include/mos/debug.h */
+unsigned long ds_debug = DSDEB_MIG | DSDEB_MIGSTAGE;		/* generic debug mask */
+/* ibr end */
 #endif CONFIG_MOSIX_DEBUG
 
 struct mosix_cost mosix_cost[MAX_MOSIX_TOPOLOGY] =
@@ -420,8 +428,11 @@
 	register struct task_struct *p = current;
 	int any = 0;
 
+#ifdef __i386__  /* ibr begin */
 	if((regs.xcs & 3) != 3)	/* going back to kernel -- not to use mode */
 		return(0);
+/* On SPARC this gets called when returning to user mode only. */
+#endif  /* ibr end */
 	__sti();		/* could be called after an interrupt */
 	current->mosix.altregs = (mu32 *)&regs;
 
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/mig.c linux-2.2.19-0.98.0-ibr-sparc/mos/mig.c
--- linux-2.2.19-0.98.0/mos/mig.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/mig.c	Sat May 19 16:57:48 2001
@@ -33,10 +33,12 @@
 #include <linux/stddef.h>
 #include <asm/mman.h>
 #include <asm/mmu_context.h>
-#include <asm/ldt.h>
 #include <linux/vmalloc.h>
-#include <asm/desc.h>
 #include <linux/module.h>
+#ifdef __i386__  /* ibr begin */
+#include <asm/ldt.h>
+#include <asm/desc.h>
+#endif  /* ibr end */
 #ifdef CONFIG_MOSIX_DFSA
 #include <mos/dfsa.h>
 #endif CONFIG_MOSIX_DFSA
@@ -231,8 +233,10 @@
 		printk("%s-migrating: 2\n", desc_mostask(NULL));
 #endif CONFIG_MOSIX_DEBUG
 
+#ifdef __i386__  /* ibr begin */
 	if(mrp->wp_works_ok && !boot_cpu_data.wp_works_ok)
 		reply = -ENOEXEC;
+#endif  /* ibr end */
 
 	if (mrp->personality != current->personality)
 	{
@@ -568,7 +572,9 @@
 	mrp.topology = MAX_MOSIX_TOPOLOGY;
 	mrp.reason = reason;
 	mrp.personality = current->personality;
+#ifdef __i386__  /* ibr begin */
 	mrp.wp_works_ok = boot_cpu_data.wp_works_ok;
+#endif  /* ibr end */
 	if(from_remote != 1)
 		mrp.pages_sent =
 			current->mosix.migpages ? : count_migrating_pages();
@@ -1224,12 +1230,17 @@
 int
 mig_send_fp(void)
 {
+#ifdef __i386__  /* ibr begin */
 	unlazy_fpu(current);
 	expel_progress = 1;
 	return(comm_send(MIG_FP, &current->tss.i387, sizeof(current->tss.i387),
 		NULL, 0, 0));
+#else
+	return 0;
+#endif  /* ibr end */
 }
 
+#ifdef __i386__  /* ibr begin */
 int
 mig_send_ldt(void)
 {
@@ -1237,6 +1248,7 @@
 	return(comm_send(MIG_LDT, NULL, 0,
 		current->mm->segments, LDT_ENTRIES*LDT_ENTRY_SIZE, 0));
 }
+#endif  /* ibr end */
 
 int
 mig_send_misc(int credit)
@@ -1250,8 +1262,10 @@
 
 	m.flags = p->flags & (PF_TRACESYS|PF_DTRACE|PF_PTRACED);
 	m.dflags = p->mosix.dflags & (DTRACESYS1|DTRACESYS2);
+#ifdef __i386__  /* ibr begin */
 	memcpy((caddr_t)m.debugreg, (caddr_t)p->tss.debugreg,
 							sizeof(m.debugreg));
+#endif  /* ibr end */
 	m.priority = p->priority;
 	m.caps = p->cap_effective;
 	p->mosix.remote_caps = m.caps;
@@ -1279,7 +1293,9 @@
 	m.deccycle = p->mosix.deccycle;
 	m.decay = p->mosix.decay;
 	m.dpolicy = p->mosix.dpolicy;
+#ifdef __i386__  /* ibr begin */
 	m.features = boot_cpu_data.x86_capability;
+#endif  /* ibr end */
 	m.mypid = (p->mosix.dflags & DREMOTE) ? p->mosix.mypid : p->pid;
 	memcpy(m.depcost, deputy_here, sizeof(deputy_here));
 	m.depspeed = cpuspeed;
@@ -1346,6 +1362,15 @@
 	spin_unlock_irqrestore(&runqueue_lock, flags);
 }
 
+static inline void mig_do_send_failure_cleanup(void)
+{
+	comm_send(MIG_NOT_COMING, NULL, 0, NULL, 0, 0);
+	comm_migration_mode(0);
+	neutralize_my_load(0);
+	if(mosix_is_loaded)
+		changed_my_mind_and_staying();
+}
+
 int
 mig_do_send(void)
 {
@@ -1354,19 +1379,65 @@
 	comm_migration_mode(1);
 	/* Don't count me: I'm going to disappear */
 	neutralize_my_load(1);
-	if(mig_send_mm_stats() || mig_send_mm_areas() ||
-		(credit = mig_send_pages()) < 0 ||
-		(current->used_math && mig_send_fp()) ||
-		(current->mm->segments && mig_send_ldt()) ||
-		mig_send_misc(credit))
-	{
-		comm_send(MIG_NOT_COMING, NULL, 0, NULL, 0, 0);
-		comm_migration_mode(0);
-		neutralize_my_load(0);
-		if(mosix_is_loaded)
-			changed_my_mind_and_staying();
-		return(-1);
+
+/* ibr begin */
+	if (mig_send_mm_stats()) {
+#ifdef CONFIG_MOSIX_DEBUG
+		if (ds_debug & DSDEB_MIG)
+			printk("%s-" __FUNCTION__ ": mig_send_mm_stats failed.\n", desc_mostask(NULL));
+#endif
+		mig_do_send_failure_cleanup();
+		return -1;
+	}
+
+	if (mig_send_mm_areas()) {
+#ifdef CONFIG_MOSIX_DEBUG
+		if (ds_debug & DSDEB_MIG)
+			printk("%s-" __FUNCTION__ ": mig_send_mm_areas failed.\n", desc_mostask(NULL));
+#endif
+		mig_do_send_failure_cleanup();
+		return -1;
+	}
+
+	if ((credit = mig_send_pages()) < 0) {
+#ifdef CONFIG_MOSIX_DEBUG
+		if (ds_debug & DSDEB_MIG)
+			printk("%s-" __FUNCTION__ ": mig_send_pages returned %d\n", desc_mostask(NULL), credit);
+#endif
+		mig_do_send_failure_cleanup();
+		return -1;
+	}
+
+	if (current->used_math && mig_send_fp()) {
+#ifdef CONFIG_MOSIX_DEBUG
+		if (ds_debug & DSDEB_MIG)
+			printk("%s-" __FUNCTION__ ": mig_send_fp failed.\n", desc_mostask(NULL));
+#endif
+		mig_do_send_failure_cleanup();
+		return -1;
+	}
+
+#ifdef __i386__
+	if (current->mm->segments && mig_send_ldt()) {
+#ifdef CONFIG_MOSIX_DEBUG
+		if (ds_debug & DSDEB_MIG)
+			printk("%s-" __FUNCTION__ ": mig_send_ldt failed.\n", desc_mostask(NULL));
+#endif
+		mig_do_send_failure_cleanup();
+		return -1;
+	}
+#endif  /* __i386__ */
+
+	if (mig_send_misc(credit)) {
+#ifdef CONFIG_MOSIX_DEBUG
+		if (ds_debug & DSDEB_MIG)
+			printk("%s-" __FUNCTION__ ": mig_send_misc failed.\n", desc_mostask(NULL));
+#endif
+		mig_do_send_failure_cleanup();
+		return -1;
 	}
+/* ibr end */
+
 	/* "comm_migration_mode(0);" was done by "mig_send_misc" */
 	neutralize_my_load(0);
 	return(0);
@@ -1574,6 +1645,7 @@
 	return(0);
 }
 
+#ifdef __i386__  /* ibr begin */
 void
 mig_do_receive_fp(struct user_i387_struct *i)
 {
@@ -1581,7 +1653,9 @@
 	unlazy_fpu(current);
 	memcpy((caddr_t)&current->tss.i387.hard, (caddr_t)i, sizeof(*i));
 }
+#endif  /* ibr end */
 
+#ifdef __i386__  /* ibr begin */
 int
 mig_do_receive_ldt(void)
 {
@@ -1607,6 +1681,7 @@
 	load_ldt(i);
 	return(0);
 }
+#endif  /* __i386__ ibr end */
 
 void
 mig_do_receive_misc(struct mig_misc_h *m)
@@ -1630,8 +1705,10 @@
 	}
 	atomic_clear_mask(DTRACESYS1|DTRACESYS2, &p->mosix.dflags);
 	atomic_set_mask(m->dflags, &p->mosix.dflags);
+#ifdef __i386__  /* ibr begin */
 	memcpy((caddr_t)p->tss.debugreg, (caddr_t)m->debugreg,
 		sizeof(m->debugreg));
+#endif  /* ibr end */
 	p->it_prof_incr = m->it_prof_incr;
 	p->it_virt_incr = m->it_virt_incr;
 	p->mosix.deputy_regs = m->deputy_regs;
@@ -1727,9 +1804,14 @@
 				}
 				break;
 			case MIG_FP:
+#ifdef __i386__  /* ibr begin */
 				mig_do_receive_fp((struct user_i387_struct *)head);
+#else
+				printk(__FUNCTION__ ": FIXME: MIG_FP encountered\n");
+#endif  /* ibr end */
 				break;
 			case MIG_LDT:
+#ifdef __i386__  /* ibr begin */
 				if(mig_do_receive_ldt())
 				{
 #ifdef CONFIG_MOSIX_DEBUG
@@ -1739,30 +1821,46 @@
 					comm_free(head);
 					goto fail;
 				}
+#else
+				printk(__FUNCTION__ ": FIXME: MIG_LDT encountered\n");
+#endif  /* ibr end */
 				break;
 			case MIG_MISC:
 				mig_do_receive_misc((struct mig_misc_h *)head);
 				comm_free(head);
 				atomic_clear_mask(DINCOMING, &m->dflags);
+#ifdef __i386__  /* ibr begin */
 				flush_tlb();	/* for all the new pages */
+#else
+				/* FIXME: what to do with flush_tlb? */
+#endif  /* ibr end */
 				comm_send(MIG_MISC|REPLY, NULL, 0, NULL, 0, 0);
 				return(0);
 			case MIG_NOT_COMING:
+#ifdef CONFIG_MOSIX_DEBUG
+				if(ds_debug & DSDEB_MIG)
+					printk("%s-mig_receive: MIG_NOT_COMING received\n", desc_mostask(NULL));
+#endif CONFIG_MOSIX_DEBUG
 				got_not_coming = 1;
 				goto fail;
 			default:
 				if(m->dflags & DDEPUTY)
 					deputy_communication_failed(1);
 #ifdef CONFIG_MOSIX_DEBUG
-				printk("%s - Bad Message Type (0x%x) on mig_do_receive\n",
-					desc_mostask(NULL), type);
+					printk("%s - Bad Message Type (0x%x) on mig_do_receive\n",
+						desc_mostask(NULL), type);
 #endif CONFIG_MOSIX_DEBUG
 				comm_free(head);
 				goto fail;
 		}
 		comm_free(head);
-		if((m->dflags & DREMOTE) && (mosadmin_mode_block || !NPE))
+		if((m->dflags & DREMOTE) && (mosadmin_mode_block || !NPE)) {
+#ifdef CONFIG_MOSIX_DEBUG
+			if(ds_debug & DSDEB_MIG)
+				printk("%s-mig_receive: m->dflags=%08x (DREMOTE=%08x), mosadmin_mode_block=%d, NPE=%d\n", desc_mostask(NULL), m->dflags, DREMOTE, mosadmin_mode_block, NPE);
+#endif CONFIG_MOSIX_DEBUG
 			goto fail;
+		}
 	}
 	fail:
 #ifdef CONFIG_MOSIX_DEBUG
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/mkext.c linux-2.2.19-0.98.0-ibr-sparc/mos/mkext.c
--- linux-2.2.19-0.98.0/mos/mkext.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/mkext.c	Mon Apr 23 19:21:45 2001
@@ -54,7 +54,7 @@
 	fprintf(link, "#include <linux/linkage.h>\n\n");
 	fprintf(link, "ENTRY(start_mosix_routines)\n");
 	fprintf(fill, "/* Filling real module symbols when loading the MOSIX module - auto-generated */\n\n");
-	fprintf(fill, ".globl fill_mosix_links\n");
+	fprintf(fill, "\t.globl\tfill_mosix_links\n");
 	fprintf(fill, "fill_mosix_links:\n");
 	fprintf(shorthand, "/* bypass the module link-table within MOSIX -- auto-generated */\n\n");
 	fprintf(export, "/* exporting symbols in the MOSIX module -- auto-generated */\n\n");
@@ -64,16 +64,62 @@
 	{
 		extname[sizeof(extname)-1] = '\0';
 		extname[strlen(extname)-1] = '\0';	/* remove the \n */
-		fprintf(link, "ENTRY(%s)\n\tjmp panic_mosix_not_loaded\n", extname);
-		fprintf(fill, "subl $panic_mosix_not_loaded,%s+1\n", extname);
-		fprintf(fill, "addl $__%s,%s+1\n", extname, extname);
+
+#if ARCH == i386  /* ibr begin */
+		fprintf(link, "ENTRY(%s)\n\tjmp\tpanic_mosix_not_loaded\n", extname);
+#elif ARCH == sparc
+		fprintf(link, "ENTRY(%s)\n\tba,a\tpanic_mosix_not_loaded\n", extname);
+#else
+#error your arch here
+/*
+ *  These are MOSIX function hooks in main kernel binary.
+ *  They go to mos/link.S by default.
+ *  By default, they cause panic.
+ *  They are initialized at MOSIX module startup (see include/mos/fill.h).
+ */
+#endif  /* ARCH */
+
+#if ARCH == i386
+/* [extname] is 0xe9, jmp opcode. [extname+1] is an absolute? 32-bit address.
+   We make it jump to the address the function is actually loaded to. */
+		fprintf(fill, "\tsubl\t$panic_mosix_not_loaded, %s+1\n", extname);
+		fprintf(fill, "\taddl\t$__%s, %s+1\n", extname, extname);
+#elif ARCH == sparc
+		fprintf(fill,
+			"\tsethi\t%%hi(%s), %%o1\n"
+			"\tld\t[%%o1+%%lo(%s)], %%g3\n"
+			"\tsethi\t%%hi(panic_mosix_not_loaded), %%g2\n"
+			"\tor\t%%g2, %%lo(panic_mosix_not_loaded), %%g2\n"
+			"\tsra\t%%g2, 2, %%g2\n"
+			"\tsub\t%%g3, %%g2, %%g3\n"
+			"\tsethi\t%%hi(__%s), %%g2\n"
+			"\tor\t%%g2, %%lo(__%s), %%g2\n"
+			"\tsra\t%%g2, 2, %%g2\n"
+			"\tadd\t%%g3, %%g2, %%g3\n"
+			"\tst\t%%g3, [%%o1+%%lo(%s)]\n\n",
+			extname, extname, extname, extname, extname);
+#else
+#error your arch here
+/*
+ *  These patch function hooks in the main kernel binary
+ *  so that they jump to real addresses in the MOSIX module.
+ */
+#endif  /* ARCH ibr end */
+
 		fprintf(shorthand, "#define %s __%s\n", extname, extname);
 		fprintf(export, "extern int %s;EXPORT_SYMBOL_NOVERS(%s);\n", extname, extname);
 	}
 	fprintf(link, "ENTRY(end_mosix_routines)\n");
-	fprintf(fill, "ret\n");
+#if ARCH == i386  /* ibr begin */
+	fprintf(fill, "\tret\n");
+#elif ARCH == sparc
+	fprintf(fill, "\tretl\n\tnop\n");
+#else
+#error your arch here
+#endif  /* ARCH ibr end */
 	fprintf(fill, ".globl fill_panic_links\n");
 	fprintf(fill, "fill_panic_links:\n");
+#if ARCH == i386  /* ibr begin */
 	fprintf(fill, "movl $start_mosix_routines+1,%%eax\n");
 	fprintf(fill, "1: cmpl $end_mosix_routines,%%eax\n");
 	fprintf(fill, "jae 2f\n");
@@ -83,6 +129,21 @@
 	fprintf(fill, "addl $8,%%eax\n");
 	fprintf(fill, "jmp 1b\n");
 	fprintf(fill, "2: ret\n");
+#elif ARCH == sparc
+	fprintf(fill,
+		"/*movl $start_mosix_routines+1,%%eax*/\n"
+		"/*1: cmpl $end_mosix_routines,%%eax*/\n"
+		"/*jae 2f*/\n"
+		"/*movl $panic_mosix_not_loaded,(%%eax)*/\n"
+		"/*subl %%eax,(%%eax)*/\n"
+		"/*subl $4,(%%eax)*/\n"
+		"/*addl $8,%%eax*/\n"
+		"/*jmp 1b*/\n"
+		"2:\tretl\n"
+		"\tnop\n");
+#else
+#error
+#endif ARCH  /* ibr end */
 	if(ferror(link) || ferror(fill) || ferror(shorthand) || ferror(export))
 	{
 		fprintf(stderr, "Write Error\n");
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/mosadmin.c linux-2.2.19-0.98.0-ibr-sparc/mos/mosadmin.c
--- linux-2.2.19-0.98.0/mos/mosadmin.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/mosadmin.c	Sat Apr 21 17:17:31 2001
@@ -14,14 +14,17 @@
 #include <linux/config.h>
 #include <linux/mosctl.h>
 #include <linux/mosix.h>
-#include <asm/hardirq.h>
+/* ibr begin */
+/*#include <asm/hardirq.h>*/
+#include <mos/hardirq.h>
+/* ibr end */
 #include <linux/smp_lock.h>
 #include <mos/routines.h>
 #include <mos/defs.h>
 #include <mos/debug.h>
 #ifdef CONFIG_MOSIX_FS
 #include <linux/mfs.h>
-#endif CONFGI_MOSIX_FS
+#endif CONFIG_MOSIX_FS
 
 char bootexpel, expel_progress;
 static int in_bring, in_expel;
@@ -213,10 +216,10 @@
 
 			printk("Expelling...");
 			bootexpel = 1;
-			if(local_irq_count[this_cpu])
+			if(LOCAL_IRQ_COUNT(this_cpu))
 			{
 				cli();
-				while(local_irq_count[this_cpu])
+				while(LOCAL_IRQ_COUNT(this_cpu))
 				{
 					hardirq_exit(this_cpu);
 #ifdef CONFIG_SMP
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/mosmodule.c linux-2.2.19-0.98.0-ibr-sparc/mos/mosmodule.c
--- linux-2.2.19-0.98.0/mos/mosmodule.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/mosmodule.c	Mon Apr 23 19:22:34 2001
@@ -36,7 +36,9 @@
 void
 init_mosix(void)
 {
+#ifdef __i386__  /* ibr begin */
 	extern int x86_udelay_tsc;
+#endif
 #ifdef CONFIG_MOSIX_UDB
 	extern void config_udb(void);
 #endif CONFIG_MOSIX_UDB
@@ -48,8 +50,10 @@
 	config_udb();
 #endif CONFIG_MOSIX_UDB
 	cpuspeed = ((m64)loops_per_jiffy) * STD_SPD / STD_LOOPS;
+#ifdef __i386__  /* ibr begin */
 	if(x86_udelay_tsc)
 		cpuspeed /= 2;
+#endif  /* ibr end */
 	number_of_processors = smp_num_cpus;
 	total_number_of_pages = num_physpages;
 	proc_update_costs();
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/mosproc.c linux-2.2.19-0.98.0-ibr-sparc/mos/mosproc.c
--- linux-2.2.19-0.98.0/mos/mosproc.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/mosproc.c	Mon Apr 23 10:49:56 2001
@@ -794,7 +794,7 @@
 	proc_register(&proc_mosix, &proc_mosix_info);
 	proc_mosix_register(&proc_mosix_info, info_ctl);
 
-	/*	/proc/mosix/deacy:	*/
+	/*	/proc/mosix/decay:	*/
 	proc_register(&proc_mosix, &proc_mosix_decay);
 	proc_mosix_register(&proc_mosix_decay, decay_ctl);
 
@@ -1185,7 +1185,7 @@
 			return (error);
 		if(pe < 0)
 			return(-ENOSYS);
-#ifdef CONFIG_KMOD
+#if defined(CONFIG_KMOD) && defined(CONFIG_MOSIX_MODULE)  /* ibr begin */
 		if(pe && !mosix_is_loaded && !mosix_being_unloaded)
 		{
 			extern struct module *find_module(char *);
@@ -1196,7 +1196,7 @@
 			if((mosix = find_module("mosix")))
 				mosix->flags &= ~MOD_AUTOCLEAN;
 		}
-#endif CONFIG_KMOD
+#endif  /* CONFIG_KMOD && CONFIG_MOSIX_MODULE ibr end */
 		return (mosix_config_set_pe(pe));
 	} else {
 		int n;
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/prequest.c linux-2.2.19-0.98.0-ibr-sparc/mos/prequest.c
--- linux-2.2.19-0.98.0/mos/prequest.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/prequest.c	Sat Apr 21 17:17:31 2001
@@ -10,6 +10,7 @@
  */
 /*
  * Author(s): Amnon Shiloh.
+ * edited by ibr.
  */
 #include <linux/sched.h>
 #include <linux/mosix.h>
@@ -181,42 +182,62 @@
 				(unsigned long)pr->param2);
 			break;
 		case PR_PTRACE_GET_STACK_LONG:
+#ifdef __i386__  /* ibr begin */
 			pr->reply = get_stack_long(current, pr->param);
+#endif  /* ibr end */
 			break;
 		case PR_PTRACE_PUT_STACK_LONG:
+#ifdef __i386__  /* ibr begin */
 			pr->reply = put_stack_long(current, pr->param,
 				(unsigned long)pr->param2);
+#endif  /* ibr end */
 			break;
 		case PR_PTRACE_GETREGS:
+#ifdef __i386__  /* ibr begin */
 			ptrace_getregs((unsigned long *)pr->ereply);
+#endif  /* ibr end */
 			break;
 		case PR_PTRACE_SETREGS:
+#ifdef __i386__  /* ibr begin */
 			ptrace_putregs((unsigned long *)pr->ereply);
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 		case PR_PTRACE_PEEKUSER:
+#ifdef __i386__  /* ibr begin */
 			*((unsigned long *)pr->ereply) =
 				ptrace_peekuser(pr->param);
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 		case PR_PTRACE_POKEUSER:
+#ifdef __i386__  /* ibr begin */
 			ptrace_pokeuser(pr->param, pr->param2);
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 		case PR_PTRACE_CONT:
+#ifdef __i386__  /* ibr begin */
 			ptrace_cont(pr->param);
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 		case PR_PTRACE_SINGLE_STEP:
+#ifdef __i386__  /* ibr begin */
 			ptrace_single_step();
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 		case PR_PTRACE_GETFPREGS:
+#ifdef __i386__  /* ibr begin */
 			ptrace_getfpregs((struct user_i387_struct *)pr->ereply);
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 		case PR_PTRACE_SETFPREGS:
+#ifdef __i386__  /* ibr begin */
 			ptrace_setfpregs((struct user_i387_struct *)pr->ereply);
+#endif  /* ibr end */
 			pr->reply = 0;
 			break;
 	}
@@ -298,7 +319,9 @@
 			break;
 		case PR_PTRACE_SETFPREGS:
 			snd = pr->ereply;
+#ifdef __i386__  /* ibr begin */
 			sndlen = sizeof(struct user_i387_struct);
+#endif  /* ibr end */
 			break;
 			/* the following may be done locally */
 		case PR_PROCFS_GET_STAT_PARTS:
@@ -457,14 +480,20 @@
 				r.error = r.reply;
 			break;
 		case PR_PTRACE_GET_STACK_LONG:
+#ifdef __i386__  /* ibr begin */
 			r.reply = get_stack_long(current, p->param);
+#endif  /* ibr end */
 			break;
 		case PR_PTRACE_PUT_STACK_LONG:
+#ifdef __i386__  /* ibr begin */
 			r.reply = put_stack_long(current, p->param,
 				(unsigned long)p->param2);
+#endif  /* ibr end */
 			break;
 		case PR_PTRACE_GETREGS:
+#ifdef __i386__  /* ibr begin */
 			ptrace_getregs((unsigned long *)buffer);
+#endif  /* ibr end */
 			r.datalen = 17 * sizeof(unsigned long);
 			r.reply = 0;
 			break;
@@ -472,38 +501,52 @@
 			r.reply = 0;
 			if(!comm_recvdata((void **)&buffer))
 			{
+#ifdef __i386__  /* ibr begin */
 				ptrace_putregs((unsigned long *)buffer);
+#endif  /* ibr end */
 				comm_free(buffer);
 			}
 			break;
 		case PR_PTRACE_PEEKUSER:
+#ifdef __i386__  /* ibr begin */
 			data[0] = ptrace_peekuser(p->param);
+#endif  /* ibr end */
 			r.datalen = sizeof(unsigned long);
 			r.reply = 0;
 			break;
 		case PR_PTRACE_POKEUSER:
+#ifdef __i386__  /* ibr begin */
 			ptrace_pokeuser(p->param, p->param2);
+#endif  /* ibr end */
 			r.datalen = r.reply = 0;
 			break;
 		case PR_PTRACE_CONT:
+#ifdef __i386__  /* ibr begin */
 			ptrace_cont(p->param);
+#endif  /* ibr end */
 			r.datalen = r.reply = 0;
 			break;
 		case PR_PTRACE_SINGLE_STEP:
+#ifdef __i386__  /* ibr begin */
 			ptrace_single_step();
+#endif  /* ibr end */
 			r.datalen = r.reply = 0;
 			break;
 		case PR_PTRACE_GETFPREGS:
+#ifdef __i386__  /* ibr begin */
 			ptrace_getfpregs((struct user_i387_struct *)buffer);
 			r.datalen = sizeof(struct user_i387_struct);
+#endif  /* ibr end */
 			r.reply = 0;
 			break;
 		case PR_PTRACE_SETFPREGS:
 			r.reply = 0;
 			if(!comm_recvdata((void **)&buffer))
 			{
+#ifdef __i386__  /* ibr begin */
 				ptrace_setfpregs(
 					(struct user_i387_struct *)buffer);
+#endif  /* ibr end */
 				comm_free(buffer);
 			}
 			break;
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/remote.c linux-2.2.19-0.98.0-ibr-sparc/mos/remote.c
--- linux-2.2.19-0.98.0/mos/remote.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/remote.c	Sat Apr 21 17:17:31 2001
@@ -86,7 +86,9 @@
 			if(expect == DEP_USERMODE)
 			{
 				if(has_ret_value)
+#ifdef __i386__  /* ibr begin */
 					mos_to_regs(m)->eax = ret_value;
+#endif  /* ibr end */
 				return(0);
 			}
 			if(type != (expect | USERMODE))
@@ -415,15 +417,21 @@
 		case __NR_fork:
 		case __NR_vfork:
 		case __NR_clone:
+#ifdef __i386__  /* ibr begin */
 			current->mosix.pass_regs |= BIT_OF_REGISTER(esp);
+#endif  /* ibr end */
 			break;
 		case __NR_execve:
+#ifdef __i386__  /* ibr begin */
 			current->mosix.pass_regs |= BIT_OF_REGISTER(edx);
+#endif  /* ibr end */
 			break;
 		case __NR_sigsuspend:
 		case __NR_rt_sigsuspend:
+#ifdef __i386__  /* ibr begin */
 			current->mosix.pass_regs |= BIT_OF_REGISTER(orig_eax) |
 				BIT_OF_REGISTER(eax) | BIT_OF_REGISTER(eip);
+#endif  /* ibr end */
 			break;
 		case __NR_sigreturn:
 		case __NR_rt_sigreturn:
@@ -560,10 +568,12 @@
 	ka.sa.sa_restorer = s->restorer;
 	current->sas_ss_sp = s->ss_sp;
 	current->sas_ss_size = s->ss_size;
+#ifdef __i386__  /* ibr begin */
 	if(s->flags & SA_SIGINFO)
 		setup_rt_frame(s->sig, &ka, &s->info, &s->set, mos_to_regs(&current->mosix));
 	else
 		setup_frame(s->sig, &ka, &s->set, mos_to_regs(&current->mosix));
+#endif  /* ibr end */
 	comm_free(s);
 	return(comm_send(DEP_SETUPFRAME|REPLY, NULL, 0, NULL, 0, 0));
 }
@@ -639,11 +649,13 @@
 									int *);
 	struct restore_sigcontext_ret_h r;
 
+#ifdef __i386__  /* ibr begin */
 	r.result = restore_sigcontext(mos_to_regs(&current->mosix), *frame,
 									&r.eax);
 
 	comm_free(frame);
 	current->mosix.pass_regs |= BIT_OF_REGISTER(esp);
+#endif  /* ibr end */
 	return(comm_send(DEP_RESTORESIGCONTEXT|REPLY, &r, sizeof(r),
 								NULL, 0, 0));
 }
@@ -842,11 +854,13 @@
 int
 remote_verify_write(struct user_copy_h *u)
 {
+#ifdef __i386__  /* ibr begin */
 	int result = __verify_write(u->addr, u->size);
 
 	comm_free(u);
 	return(comm_send(DEP_VERIFY_WRITE|REPLY, &result, sizeof(result),
 		NULL, 0, 0));
+#endif  /* ibr end */
 }
 
 int
@@ -1097,9 +1111,11 @@
 		r.loader = bprm->loader;
 		r.exec = bprm->exec;
 	}
+#ifdef __i386__  /* ibr begin */
 	current->mosix.pass_regs |= BIT_OF_REGISTER(xds)|BIT_OF_REGISTER(xes)|
 		BIT_OF_REGISTER(xss)|BIT_OF_REGISTER(xcs)|BIT_OF_REGISTER(eip)|
 		BIT_OF_REGISTER(esp);
+#endif  /* ibr end */
 	err = comm_send(DEP_SETUP_ARGS|REPLY, &r, sizeof(r), NULL, 0, 0);
 	mosix_decay_exec();
 	out:
@@ -1260,7 +1276,9 @@
 	int done, ret;
 
 	comm_free(f);
+#ifdef __i386__  /* ibr begin */
 	mosix_obtain_registers(ALL_REGISTERS & ~BIT_OF_REGISTER(eax));
+#endif  /* ibr end */
 	if(lf.do_forkmigrate && mosix_is_loaded)
 		mosix_forkmigrate();	/* may not return */
 	ret = -EAGAIN;
@@ -1336,12 +1354,14 @@
 int
 remote_dump_fpu(void)
 {
+#ifdef __i386__  /* ibr begin */
 	extern int dump_fpu (struct pt_regs *, struct user_i387_struct *);
 	struct user_i387_struct f;
 	int r = dump_fpu(mos_to_regs(&current->mosix), &f);
 
 	return(comm_send(DEP_DUMP_FPU|REPLY, &r, sizeof(r),
 		r ? &f : NULL, r ? sizeof(f) : 0, 0));
+#endif  /* ibr end */
 }
 
 int
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/service.c linux-2.2.19-0.98.0-ibr-sparc/mos/service.c
--- linux-2.2.19-0.98.0/mos/service.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/service.c	Mon May 21 12:18:17 2001
@@ -11,6 +11,12 @@
 /*
  * Author(s): Amnon Shiloh.
  */
+/*
+ * SPARC support code copyright (c) 2001, Baurjan Ismagulov.
+ * Changes:
+ * 30.03.2001  commented out i386-specific code in kickstart.
+ * 10.05.2001  kickstart hacks.
+ */
 #include <linux/sched.h>
 #include <linux/mosctl.h>
 #include <net/sock.h>
@@ -148,6 +154,7 @@
 	 * interrupt and avoid returning via ret_with_reschedule...
 	 * the remedy is:
 	 */
+#if defined(__i386__)  /* ibr begin */
 	regs->xcs |= 3;
 
 	if(current->tss.debugreg[7])
@@ -159,9 +166,19 @@
 		loaddebug(current,6);
 		loaddebug(current,7);
 	}
+#elif defined(__sparc__)
+	regs->psr |= PSR_PS;
+#endif  /* __i386__ ibr end */
 	release_kernel_lock(current, smp_processor_id());
 	current->lock_depth = -1;
+#if defined(__i386__)  /*  ibr begin*/
 	asm("movl %0,%%esp ; jmp ret_from_kickstart" : : "r" (regs));
+#elif defined(__sparc__)
+	asm(	"mov	%0, %%sp; "
+		"ba,a	ret_trap_entry; "
+		"nop"
+	: : "r" (regs));
+#endif  /* __i386__ ibr end */
 	/*NOTREACHED*/
 }
 
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mos/syscalls.c linux-2.2.19-0.98.0-ibr-sparc/mos/syscalls.c
--- linux-2.2.19-0.98.0/mos/syscalls.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mos/syscalls.c	Sat Apr 21 17:17:31 2001
@@ -160,9 +160,11 @@
 int
 remote_sys_modify_ldt(int n, int func, void *ptr, unsigned long bytecount)
 {
+#ifdef __i386__  /* ibr begin */
 	extern asmlinkage int sys_modify_ldt(int, void *, unsigned long);
 
 	return(sys_modify_ldt(func, ptr, bytecount));
+#endif  /* ibr end */
 }
 
 int
@@ -1668,7 +1670,9 @@
 int
 remote_sys_sigreturn(int n, struct pt_regs regs)
 {
+#ifdef __i386__  /* ibr begin */
 	set_write_region(regs.esp - 8, 220);
+#endif  /* ibr end */
 	/* Eek, struct sigframe not defined outise arch/i386/kernel/signal.c */
 	return(remote_standard_system_call(n, &regs));
 }
@@ -2076,7 +2080,9 @@
 int
 remote_sys_rt_sigreturn(int n, struct pt_regs regs)
 {
+#ifdef __i386__  /* ibr begin */
 	set_write_region(regs.esp - 8, 380);
+#endif  /* ibr end */
 	/*Eek, struct rt_sigframe not defined outise arch/i386/kernel/signal.c*/
 	return(remote_standard_system_call(n, &regs));
 }
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mosix/Makefile linux-2.2.19-0.98.0-ibr-sparc/mosix/Makefile
--- linux-2.2.19-0.98.0/mosix/Makefile	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mosix/Makefile	Fri May 11 14:33:23 2001
@@ -16,20 +16,16 @@
 # unless it's something special (ie not a .c file).
 #
 
+# ibr begin
+CFLAGS += -O1 -fno-omit-frame-pointer
+# ibr end
+
 ifdef CONFIG_MOSIX_MODULE
 M_OBJS := mosix.o
 SUB_OBJS := balance.o load.o decay.o mem.o mosixmodule.o
 
 $(SUB_OBJS): $(TOPDIR)/include/mosix/config.h
 
-$(TOPDIR)/include/mosix/config.h: $(TOPDIR)/include/linux/autoconf.h
-	fgrep _MOSIX $(TOPDIR)/include/linux/autoconf.h > $(TOPDIR)/include/mosix/config.h
-
-mosixmodule.c: increment
-
-increment:
-	sh -c 'n=`cat compile.h`; expr 0$$n + 1 > compile.h'
-
 fill.o: fill.S $(TOPDIR)/include/mos/fill.h
 	$(CC) -c -o fill.o fill.S
 
@@ -37,11 +33,24 @@
 	$(LD) $(LD_RFLAG) -r -o $(M_OBJS) $(SUB_OBJS) fill.o
 
 else
+
 O_TARGET := mosix.o
 O_OBJS   := balance.o load.o decay.o mem.o fill.o
 
-OX_OBJS += mosixmodule.o config.o
+OX_OBJS += mosixmodule.o
+
+$(O_TARGET):	$(O_OBJS)
+	$(LD) $(LD_RFLAG) -r -o $(O_TARGET) $(O_OBJS) $(OX_OBJS)
+
 endif
+
+mosixmodule.c: increment
+
+increment:
+	sh -c 'n=`cat compile.h`; expr 0$$n + 1 > compile.h'
+
+$(TOPDIR)/include/mosix/config.h: $(TOPDIR)/include/linux/autoconf.h
+	fgrep _MOSIX $(TOPDIR)/include/linux/autoconf.h > $(TOPDIR)/include/mosix/config.h
 
 include $(TOPDIR)/Rules.make
 
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mosix/balance.c linux-2.2.19-0.98.0-ibr-sparc/mosix/balance.c
--- linux-2.2.19-0.98.0/mosix/balance.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mosix/balance.c	Mon May 14 16:28:35 2001
@@ -11,6 +11,11 @@
 /*
  * Author(s): Amnon Shiloh, Amnon Barak, Oren Laadan.
  */
+/*
+ * SPARC support code copyright (c) 2001, Baurjan Ismagulov.
+ * Changes:
+ * - Header inclusion order.
+ */
 #include <mosix/config.h>
 #include <mos/shorthand.h>
 #include <mos/mosixtask.h>
@@ -20,11 +25,15 @@
 #include <mos/mosixroutines.h>
 #include <mos/comm.h>
 #include <mos/factor.h>
-#include <mos/interface.h>
 #include <mos/debug.h>
 #include <mos/version.h>
 #include <mosix/balance.h>
 #include <asm/atomic.h>
+/* ibr begin */
+/* this one should be included last to avoid compilation problems on SPARC
+   (which arise due to "printf" and "panic" #defined there). */
+#include <mos/interface.h>
+/* ibr end */
 
 static mosix_addr *ra;		/* reply address */
 
@@ -59,6 +68,7 @@
 char *
 fformat(double v)
 {
+#ifdef __i386__  /* ibr begin */
 	static char buf1[40], buf2[40];
 	static int x;
 	char *b = (x = !x) ? buf1 : buf2;
@@ -128,6 +138,9 @@
 	}
 	*p = '\0';
 	return(b);
+#else  /* __i386__ */
+	return "0";
+#endif  /* __i386__ ibr end */
 }
 #endif CONFIG_MOSIX_DEBUG
 
@@ -195,6 +208,7 @@
 	msg = (struct infomsg *) info_buf;
 	load = (struct loadinfo *) &msg->load;
 
+#ifdef __i386__ /* ibr begin */
 	while (1) {
 		if(mosix_being_unloaded)
 			goto bailout;
@@ -245,6 +259,7 @@
 				raise_all(0, DMBALANCING);
 		}
 	}
+#endif  /* ibr end */
 }
 
 static void
@@ -1533,6 +1548,7 @@
 void
 consider(int reason, struct sonstats *sons)
 {
+#ifdef __i386__  /* ibr begin */
 #define	INFLOAD 0x8000000
 #define	MAX_CONSIDERED	(INFO_WIN+1+MAX_MFS_STATNODES)
 #if MAX_CONSIDERED > 127
@@ -1958,6 +1974,7 @@
 	}
 	if(m->dflags & DREMOTE)
 		ask_deputy_to_goto(0);
+#endif  /* ibr end */
 }
 
 int
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/mosix/mosixmodule.c linux-2.2.19-0.98.0-ibr-sparc/mosix/mosixmodule.c
--- linux-2.2.19-0.98.0/mosix/mosixmodule.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/mosix/mosixmodule.c	Mon May 14 16:29:02 2001
@@ -11,15 +11,22 @@
 /*
  * Author(s): Amnon Shiloh.
  */
+/*
+ * SPARC support code copyright (c) 2001, Baurjan Ismagulov.
+ * Changes:
+ * - Header inclusion order.
+ */
 #include <mosix/config.h>
 #include <mos/shorthand.h>
 #include <mos/mosixtask.h>
 #include <mos/defs.h>
 #include <mos/mosroutines.h>
 #include <mos/version.h>
-#include <mos/interface.h>
 #include <mosix/balance.h>
 #include <asm/atomic.h>
+/* ibr begin */
+#include <mos/interface.h>
+/* ibr end */
 
 extern void fill_mosix_links(void), fill_panic_links(void);
 
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/udb/Makefile linux-2.2.19-0.98.0-ibr-sparc/udb/Makefile
--- linux-2.2.19-0.98.0/udb/Makefile	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/udb/Makefile	Sat Apr 21 17:17:32 2001
@@ -23,6 +23,5 @@
 
 all_targets: symtab
 
-symtab:	symtab.o
+symtab:	symtab.c
 	$(HOSTCC) $(HOSTCFLAGS) $< -o $@
-
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/udb/udb.c linux-2.2.19-0.98.0-ibr-sparc/udb/udb.c
--- linux-2.2.19-0.98.0/udb/udb.c	Thu Apr 12 02:07:07 2001
+++ linux-2.2.19-0.98.0-ibr-sparc/udb/udb.c	Mon Apr 23 01:21:56 2001
@@ -21,7 +21,10 @@
 #include <linux/sysrq.h>
 #include <linux/reboot.h>
 #include <linux/ptrace.h>
-#include <asm/hardirq.h>
+/* ibr begin */
+/*#include <asm/hardirq.h>*/
+#include <mos/hardirq.h>
+/* ibr end */
 #include <linux/sched.h>
 #include <asm/delay.h>
 #include <linux/sys.h>
@@ -717,6 +720,10 @@
 	printk("Command (%s) Not Recognized!\n", dbbuf);
 }
 
+#ifdef mosix_debugger  /* ibr begin */
+#undef mosix_debugger
+#endif  /* ibr end */
+
 void
 mosix_debugger(char *msg)
 {
@@ -870,7 +877,9 @@
 
 again:
 	skip_one = 0;
+#ifdef __i386__  /* ibr begin */
 	__asm__("movl %%ebp,%0" : "=r" (ebp));
+#endif  /* ibr end */
 	for(; ebp >= stack_area && ebp < 8188+stack_area ;
 		ebp = skip_one ? ebp : *(unsigned long *) ebp , skip_one = 0)
 	{
@@ -915,9 +924,12 @@
 	static char was_here = 0;
 	int i;
 	int this_cpu = smp_processor_id();
-	extern void set_fastest_reboot(void);
 
+#ifdef __i386__  /* ibr begin */
+	extern void set_fastest_reboot(void);
 	set_fastest_reboot();
+#endif __i386__  /* ibr end */
+
 	current->mosix.catchme = 0;
 	if(!udb_booting)
 	for(i = 0 ; i < smp_num_cpus ; i++)
@@ -927,7 +939,7 @@
 		/* a remote process cannot migrate back without losing thread */
 
 		cli();
-		while(local_irq_count[this_cpu])
+		while(LOCAL_IRQ_COUNT(this_cpu))
 		{
 			hardirq_exit(this_cpu);
 #ifdef CONFIG_SMP
@@ -972,6 +984,7 @@
 int
 udb_breakpoint(struct pt_regs *regs)
 {
+#ifdef __i386__  /* ibr begin */
 	unsigned long eip = (unsigned long)regs->eip;
 	register int b;
 	static char msg[100];
@@ -991,6 +1004,7 @@
 
 	set_bpt = regs->eip;
 	mosix_debugger(msg);
+#endif  /* ibr end */
 	return(1);
 }
 
@@ -1318,8 +1332,10 @@
 	char resp;
 
 	for(i = 0 ; i < 100000 ; i++)
+#ifdef __i386__  /* ibr begin */
 	if(can_read_lock(&tasklist_lock))
 		break;
+#endif  /* ibr end */
 	if(i < 100000)
 	{
 		read_lock(&tasklist_lock);
@@ -1599,6 +1615,7 @@
 void
 low_do_regs(struct task_struct *p, char *num)
 {
+#ifdef __i386__  /* ibr begin */
 	printk("%d(%s):", p->pid, p->comm);
 	printreg(p, "eip", BIT_OF_REGISTER(eip));
 	printreg(p, "esp", BIT_OF_REGISTER(esp));
@@ -1618,6 +1635,7 @@
 	printreg(p, "xes", BIT_OF_REGISTER(xes));
 	printreg(p, "xss", BIT_OF_REGISTER(xss));
 	printk("\n");
+#endif  /* ibr end */
 }
 
 void
diff -Naur -X ./dontdiff.ibr linux-2.2.19-0.98.0/version.txt linux-2.2.19-0.98.0-ibr-sparc/version.txt
--- linux-2.2.19-0.98.0/version.txt	Thu Jan  1 02:00:00 1970
+++ linux-2.2.19-0.98.0-ibr-sparc/version.txt	Mon May 21 12:47:23 2001
@@ -0,0 +1 @@
+20010521-1247

