From 88eb101ec97624874092bd4670ed24fca83eb064 Mon Sep 17 00:00:00 2001
From: root <root@major.home.treblig.org>
Date: Thu, 31 Jul 2025 01:46:53 +0100
Subject: [PATCH] Javastation/krups 2.5.1 hacks

This is a set of hacks that gets 2.5.1 hobbling along on Javastation
krups using 3.3.5 gcc and binutils 2.15.

They're mostly very selective backports, and some hacks.
This is on top of:

commit 650f733976e7e0f25cce57ff19e2f221c46c3c83
Author: torvalds <torvalds>
Date:   Tue Feb 5 23:59:17 2002 +0000

    v2.5.0.11 -> v2.5.1

    - Al Viro: floppy_eject cleanup, mount cleanups
    - Jens Axboe: bio updates
    - Ingo Molnar: mempool fixes
    - GOTO Masanori: Fix O_DIRECT error handling

    BKrev: 3c6071d5t7MsPmVkUVmBvZNcKfms0g
---
 arch/sparc/boot/Makefile        |   6 +-
 arch/sparc/boot/btfixupprep.c   |  23 +++--
 arch/sparc/kernel/head.S        |   2 +-
 arch/sparc/kernel/traps.c       |   5 ++
 arch/sparc/kernel/unaligned.c   |   2 +-
 arch/sparc/lib/checksum.S       |  87 +++++++++----------
 arch/sparc/lib/copy_user.S      |  95 +++++++++++----------
 arch/sparc/lib/memset.S         |  31 +++----
 arch/sparc/math-emu/sfp-util.h  | 137 +++++++++++++++---------------
 include/asm-sparc/checksum.h    | 144 +++++++++++++++++---------------
 include/asm-sparc/io.h          |   2 +
 include/asm-sparc/sfp-machine.h |  38 ++++-----
 include/asm-sparc/string.h      |   4 +-
 include/asm-sparc/system.h      |  12 +--
 include/linux/kbd_kern.h        |   1 +
 include/linux/vt_kern.h         |   1 +
 init/main.c                     |  12 +++
 kernel/sched.c                  |   8 +-
 18 files changed, 334 insertions(+), 276 deletions(-)

diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile
index a7a5625498..21bbf9977a 100644
--- a/arch/sparc/boot/Makefile
+++ b/arch/sparc/boot/Makefile
@@ -22,8 +22,8 @@ btfixupprep: btfixupprep.c
 clean:
 	rm -f btfixupprep piggyback tftpboot.img btfix.o btfix.s
 
-BTOBJS := $(HEAD) init/main.o init/version.o
-BTLIBS := $(CORE_FILES_NO_BTFIX) $(FILESYSTEMS) \
+BTOBJS := $(HEAD) init/main.o init/version.o init/do_mounts.o
+BTLIBS := $(CORE_FILES_NO_BTFIX) \
 	$(DRIVERS) $(NETWORKS)
 
 # I wanted to make this depend upon BTOBJS so that a parallel
@@ -31,7 +31,7 @@ BTLIBS := $(CORE_FILES_NO_BTFIX) $(FILESYSTEMS) \
 # 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)) \
+	$(LD) -T ../vmlinux.lds -r $(patsubst %,$(TOPDIR)/%,$(BTOBJS)) \
 		--start-group \
 		$(patsubst %,$(TOPDIR)/%,$(BTLIBS)) \
 		$(LIBS) \
diff --git a/arch/sparc/boot/btfixupprep.c b/arch/sparc/boot/btfixupprep.c
index 7327e6bc16..515eb47344 100644
--- a/arch/sparc/boot/btfixupprep.c
+++ b/arch/sparc/boot/btfixupprep.c
@@ -115,34 +115,41 @@ int main(int argc,char **argv)
 		if (!strncmp (buffer, symtab, symlen))
 			goto main0;
 	fatal();
-main0:
+main0: /* After 'symbol table' */
 	rellen = strlen(relrec);
 	while (fgets (buffer, 1024, stdin) != NULL)
 		if (!strncmp (buffer, relrec, rellen))
 			goto main1;
 	fatal();
-main1:
+main1: /* After 'Relocation records for' */
 	sect = malloc(strlen (buffer + rellen) + 1);
 	if (!sect) fatal();
 	strcpy (sect, buffer + rellen);
 	p = strchr (sect, ']');
 	if (!p) fatal();
-	*p = 0;
+	*p = 0; /* sect now has something like '.text' */
+        /* Throws away header */
 	if (fgets (buffer, 1024, stdin) == NULL)
 		fatal();
 	while (fgets (buffer, 1024, stdin) != NULL) {
+                /* A line like: 00000018 R_SPARC_WDISP22   sun4c_fault   */
 		int nbase;
-		if (!strncmp (buffer, relrec, rellen))
+		if (!strncmp (buffer, relrec, rellen)) /* Relocaiton records for... */
 			goto main1;
+                /* Figure out address length, 8 or 16 character */
 		if (mode == 0)
 			set_mode (buffer);
 		p = strchr (buffer, '\n');
 		if (p) *p = 0;
+                // Skip short symbols
 		if (strlen (buffer) < 22+mode)
 			continue;
+                // Skip unexpected relocation types
 		if (strncmp (buffer + mode, " R_SPARC_", 9))
 			continue;
+                // i.e. start of the symbol name
 		nbase = 27 - 8 + mode;
+                // Fixups all start ___
 		if (buffer[nbase] != '_' || buffer[nbase+1] != '_' || buffer[nbase+2] != '_')
 			continue;
 		switch (buffer[nbase+3]) {
@@ -156,16 +163,18 @@ main1:
 			default:
 				continue;
 		}
+                // some are name+offset
 		p = strchr (buffer + nbase+5, '+');
 		if (p) *p = 0;
-		shift = nbase + 5;
+		shift = nbase + 5; // In most cases after the added prefix..except
+                // ___fs_
 		if (buffer[nbase+4] == 's' && buffer[nbase+5] == '_') {
 			shift = nbase + 6;
 			if (strcmp (sect, ".text.init")) {
 				fprintf(stderr, "Wrong use of '%s' BTFIXUPSET.\nBTFIXUPSET_CALL can be used only in __init sections\n", buffer+shift);
 				exit(1);
 			}
-		} else if (buffer[nbase+4] != '_')
+		} else if (buffer[nbase+4] != '_') // Fallback for other real symbols?
 			continue;
 		if (strcmp (sect, ".text") && strcmp (sect, ".text.init") && strcmp (sect, ".fixup") && (strcmp (sect, "__ksymtab") || buffer[nbase+3] != 'f')) {
 			if (buffer[nbase+3] == 'f')
@@ -194,6 +203,8 @@ main1:
 			initvalstr = p + 10;
 			*p = 0;
 		}
+                // first arg is 'type' - i.e. the first letter of the tag
+                // second arg is the name with the prefix removed
 		f = find(buffer[nbase+3], buffer + shift);
 		if (buffer[nbase+4] == 's')
 			continue;
diff --git a/arch/sparc/kernel/head.S b/arch/sparc/kernel/head.S
index d8e65b0ff4..e31ee89a2f 100644
--- a/arch/sparc/kernel/head.S
+++ b/arch/sparc/kernel/head.S
@@ -1011,7 +1011,7 @@ sun4c_continue_boot:
 
 		/* I want a kernel stack NOW! */
 		set	C_LABEL(init_task_union), %g1
-		set	(TASK_UNION_SIZE - REGWIN_SZ), %g2
+		set	(TASK_UNION_SIZE - STACKFRAME_SZ), %g2
 		add	%g1, %g2, %sp
 		mov	0, %fp			/* And for good luck */
 
diff --git a/arch/sparc/kernel/traps.c b/arch/sparc/kernel/traps.c
index 5c361f9335..eb08eb55ed 100644
--- a/arch/sparc/kernel/traps.c
+++ b/arch/sparc/kernel/traps.c
@@ -84,6 +84,11 @@ void instruction_dump (unsigned long *pc)
 	printk("\n");
 }
 
+void show_trace_task(struct task_struct *tsk)
+{
+        printk("Dummy show_trace_task\n");
+}
+
 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
 
diff --git a/arch/sparc/kernel/unaligned.c b/arch/sparc/kernel/unaligned.c
index 0f718bac82..af6fb15e2d 100644
--- a/arch/sparc/kernel/unaligned.c
+++ b/arch/sparc/kernel/unaligned.c
@@ -17,7 +17,7 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 
-/* #define DEBUG_MNA */
+#define DEBUG_MNA
 
 enum direction {
 	load,    /* ld, ldd, ldh, ldsh */
diff --git a/arch/sparc/lib/checksum.S b/arch/sparc/lib/checksum.S
index d02b6dfb2d..8ee6af199a 100644
--- a/arch/sparc/lib/checksum.S
+++ b/arch/sparc/lib/checksum.S
@@ -145,36 +145,39 @@ cpout:	retl						! get outta here
 	.globl C_LABEL(__csum_partial_copy_start), C_LABEL(__csum_partial_copy_end)
 C_LABEL(__csum_partial_copy_start):
 
-#define EX(x,y,a,b,z)                           \
+/* Work around cpp -rob */
+#define ALLOC #alloc
+#define EXECINSTR #execinstr
+#define EX(x,y,a,b)				\
 98:     x,y;                                    \
-        .section .fixup,z##alloc,z##execinstr;  \
+        .section .fixup,ALLOC,EXECINSTR;	\
         .align  4;                              \
 99:     ba 30f;                                 \
          a, b, %o3;                             \
-        .section __ex_table,z##alloc;           \
+        .section __ex_table,ALLOC;		\
         .align  4;                              \
         .word   98b, 99b;                       \
         .text;                                  \
         .align  4
 
-#define EX2(x,y,z)                          	\
+#define EX2(x,y)				\
 98:     x,y;                                    \
-        .section __ex_table,z##alloc;           \
+        .section __ex_table,ALLOC;		\
         .align  4;                              \
         .word   98b, 30f;                       \
         .text;                                  \
         .align  4
 
-#define EX3(x,y,z)                          	\
+#define EX3(x,y)				\
 98:     x,y;                                    \
-        .section __ex_table,z##alloc;           \
+        .section __ex_table,ALLOC;		\
         .align  4;                              \
         .word   98b, 96f;                       \
         .text;                                  \
         .align  4
 
-#define EXT(start,end,handler,z)                \
-        .section __ex_table,z##alloc;           \
+#define EXT(start,end,handler)			\
+        .section __ex_table,ALLOC;		\
         .align  4;                              \
         .word   start, 0, end, handler;         \
         .text;                                  \
@@ -247,21 +250,21 @@ C_LABEL(__csum_partial_copy_start):
 cc_end_cruft:
 	be	1f
 	 andcc	%o3, 4, %g0
-	EX(ldd	[%o0 + 0x00], %g2, and %o3, 0xf,#)
+	EX(ldd	[%o0 + 0x00], %g2, and %o3, 0xf)
 	add	%o1, 8, %o1
 	addcc	%g2, %g7, %g7
 	add	%o0, 8, %o0
 	addxcc	%g3, %g7, %g7
-	EX2(st	%g2, [%o1 - 0x08],#)
+	EX2(st	%g2, [%o1 - 0x08])
 	addx	%g0, %g7, %g7
 	andcc	%o3, 4, %g0
-	EX2(st	%g3, [%o1 - 0x04],#)
+	EX2(st	%g3, [%o1 - 0x04])
 1:	be	1f
 	 andcc	%o3, 3, %o3
-	EX(ld	[%o0 + 0x00], %g2, add %o3, 4,#)
+	EX(ld	[%o0 + 0x00], %g2, add %o3, 4)
 	add	%o1, 4, %o1
 	addcc	%g2, %g7, %g7
-	EX2(st	%g2, [%o1 - 0x04],#)
+	EX2(st	%g2, [%o1 - 0x04])
 	addx	%g0, %g7, %g7
 	andcc	%o3, 3, %g0
 	add	%o0, 4, %o0
@@ -271,14 +274,14 @@ cc_end_cruft:
 	 subcc	%o3, 2, %o3
 	b	4f
 	 or	%g0, %g0, %o4
-2:	EX(lduh	[%o0 + 0x00], %o4, add %o3, 2,#)
+2:	EX(lduh	[%o0 + 0x00], %o4, add %o3, 2)
 	add	%o0, 2, %o0
-	EX2(sth	%o4, [%o1 + 0x00],#)
+	EX2(sth	%o4, [%o1 + 0x00])
 	be	6f
 	 add	%o1, 2, %o1
 	sll	%o4, 16, %o4
-4:	EX(ldub	[%o0 + 0x00], %o5, add %g0, 1,#)
-	EX2(stb	%o5, [%o1 + 0x00],#)
+4:	EX(ldub	[%o0 + 0x00], %o5, add %g0, 1)
+	EX2(stb	%o5, [%o1 + 0x00])
 	sll	%o5, 8, %o5
 	or	%o5, %o4, %o4
 6:	addcc	%o4, %g7, %g7
@@ -295,9 +298,9 @@ cc_dword_align:
 	 andcc	%o0, 0x2, %g0
 	be	1f
 	 andcc	%o0, 0x4, %g0
-	EX(lduh	[%o0 + 0x00], %g4, add %g1, 0,#)
+	EX(lduh	[%o0 + 0x00], %g4, add %g1, 0)
 	sub	%g1, 2, %g1
-	EX2(sth	%g4, [%o1 + 0x00],#)
+	EX2(sth	%g4, [%o1 + 0x00])
 	add	%o0, 2, %o0
 	sll	%g4, 16, %g4
 	addcc	%g4, %g7, %g7
@@ -311,9 +314,9 @@ cc_dword_align:
 	or	%g3, %g7, %g7
 1:	be	3f
 	 andcc	%g1, 0xffffff80, %g0
-	EX(ld	[%o0 + 0x00], %g4, add %g1, 0,#)
+	EX(ld	[%o0 + 0x00], %g4, add %g1, 0)
 	sub	%g1, 4, %g1
-	EX2(st	%g4, [%o1 + 0x00],#)
+	EX2(st	%g4, [%o1 + 0x00])
 	add	%o0, 4, %o0
 	addcc	%g4, %g7, %g7
 	add	%o1, 4, %o1
@@ -336,13 +339,13 @@ C_LABEL(__csum_partial_copy_sparc_generic):
 	bne	cc_dword_align		! yes, we check for short lengths there
 	 andcc	%g1, 0xffffff80, %g0	! can we use unrolled loop?
 3:	be	3f			! nope, less than one loop remains
-	 andcc	%o1, 4, %g0		! dest aligned on 4 or 8 byte boundry?
+	 andcc	%o1, 4, %g0		! dest aligned on 4 or 8 byte boundary?
 	be	ccdbl + 4		! 8 byte aligned, kick ass
 5:	CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x00,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
 	CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
 	CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x40,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
 	CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x60,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
-10:	EXT(5b, 10b, 20f,#)		! note for exception handling
+10:	EXT(5b, 10b, 20f)		! note for exception handling
 	sub	%g1, 128, %g1		! detract from length
 	addx	%g0, %g7, %g7		! add in last carry bit
 	andcc	%g1, 0xffffff80, %g0	! more to csum?
@@ -367,7 +370,7 @@ cctbl:	CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x68,%g2,%g3,%g4,%g5)
 	CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x28,%g2,%g3,%g4,%g5)
 	CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x18,%g2,%g3,%g4,%g5)
 	CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x08,%g2,%g3,%g4,%g5)
-12:	EXT(cctbl, 12b, 22f,#)		! note for exception table handling
+12:	EXT(cctbl, 12b, 22f)		! note for exception table handling
 	addx	%g0, %g7, %g7
 	andcc	%o3, 0xf, %g0		! check for low bits set
 ccte:	bne	cc_end_cruft		! something left, handle it out of band
@@ -378,7 +381,7 @@ ccdbl:	CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x00,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o
 	CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
 	CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x40,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
 	CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x60,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
-11:	EXT(ccdbl, 11b, 21f,#)		! note for exception table handling
+11:	EXT(ccdbl, 11b, 21f)		! note for exception table handling
 	sub	%g1, 128, %g1		! detract from length
 	addx	%g0, %g7, %g7		! add in last carry bit
 	andcc	%g1, 0xffffff80, %g0	! more to csum?
@@ -395,9 +398,9 @@ ccslow:	cmp	%g1, 0
 	be,a	1f
 	 srl	%g1, 1, %g4		
 	sub	%g1, 1, %g1	
-	EX(ldub	[%o0], %g5, add %g1, 1,#)
+	EX(ldub	[%o0], %g5, add %g1, 1)
 	add	%o0, 1, %o0	
-	EX2(stb	%g5, [%o1],#)
+	EX2(stb	%g5, [%o1])
 	srl	%g1, 1, %g4
 	add	%o1, 1, %o1
 1:	cmp	%g4, 0		
@@ -406,34 +409,34 @@ ccslow:	cmp	%g1, 0
 	andcc	%o0, 2, %g0	
 	be,a	1f
 	 srl	%g4, 1, %g4
-	EX(lduh	[%o0], %o4, add %g1, 0,#)
+	EX(lduh	[%o0], %o4, add %g1, 0)
 	sub	%g1, 2, %g1	
 	srl	%o4, 8, %g2
 	sub	%g4, 1, %g4	
-	EX2(stb	%g2, [%o1],#)
+	EX2(stb	%g2, [%o1])
 	add	%o4, %g5, %g5
-	EX2(stb	%o4, [%o1 + 1],#)
+	EX2(stb	%o4, [%o1 + 1])
 	add	%o0, 2, %o0	
 	srl	%g4, 1, %g4
 	add	%o1, 2, %o1
 1:	cmp	%g4, 0		
 	be,a	2f
 	 andcc	%g1, 2, %g0
-	EX3(ld	[%o0], %o4,#)
+	EX3(ld	[%o0], %o4)
 5:	srl	%o4, 24, %g2
 	srl	%o4, 16, %g3
-	EX2(stb	%g2, [%o1],#)
+	EX2(stb	%g2, [%o1])
 	srl	%o4, 8, %g2
-	EX2(stb	%g3, [%o1 + 1],#)
+	EX2(stb	%g3, [%o1 + 1])
 	add	%o0, 4, %o0
-	EX2(stb	%g2, [%o1 + 2],#)
+	EX2(stb	%g2, [%o1 + 2])
 	addcc	%o4, %g5, %g5
-	EX2(stb	%o4, [%o1 + 3],#)
+	EX2(stb	%o4, [%o1 + 3])
 	addx	%g5, %g0, %g5	! I am now to lazy to optimize this (question it
 	add	%o1, 4, %o1	! is worthy). Maybe some day - with the sll/srl
 	subcc	%g4, 1, %g4	! tricks
 	bne,a	5b
-	 EX3(ld	[%o0], %o4,#)
+	 EX3(ld	[%o0], %o4)
 	sll	%g5, 16, %g2
 	srl	%g5, 16, %g5
 	srl	%g2, 16, %g2
@@ -441,19 +444,19 @@ ccslow:	cmp	%g1, 0
 	add	%g2, %g5, %g5 
 2:	be,a	3f		
 	 andcc	%g1, 1, %g0
-	EX(lduh	[%o0], %o4, and %g1, 3,#)
+	EX(lduh	[%o0], %o4, and %g1, 3)
 	andcc	%g1, 1, %g0
 	srl	%o4, 8, %g2
 	add	%o0, 2, %o0	
-	EX2(stb	%g2, [%o1],#)
+	EX2(stb	%g2, [%o1])
 	add	%g5, %o4, %g5
-	EX2(stb	%o4, [%o1 + 1],#)
+	EX2(stb	%o4, [%o1 + 1])
 	add	%o1, 2, %o1
 3:	be,a	1f		
 	 sll	%g5, 16, %o4
-	EX(ldub	[%o0], %g2, add %g0, 1,#)
+	EX(ldub	[%o0], %g2, add %g0, 1)
 	sll	%g2, 8, %o4	
-	EX2(stb	%g2, [%o1],#)
+	EX2(stb	%g2, [%o1])
 	add	%g5, %o4, %g5
 	sll	%g5, 16, %o4
 1:	addcc	%o4, %g5, %g5
diff --git a/arch/sparc/lib/copy_user.S b/arch/sparc/lib/copy_user.S
index 239ec762dd..de40b1cc5f 100644
--- a/arch/sparc/lib/copy_user.S
+++ b/arch/sparc/lib/copy_user.S
@@ -16,41 +16,44 @@
 #include <asm/asmmacro.h>
 #include <asm/page.h>
 
-#define EX(x,y,a,b,z) 				\
+/* Work around cpp -rob */
+#define ALLOC #alloc
+#define EXECINSTR #execinstr
+#define EX(x,y,a,b) 				\
 98: 	x,y;					\
-	.section .fixup,z##alloc,z##execinstr;	\
+	.section .fixup,ALLOC,EXECINSTR;	\
 	.align	4;				\
 99:	ba fixupretl;				\
 	 a, b, %g3;				\
-	.section __ex_table,z##alloc;		\
+	.section __ex_table,ALLOC;		\
 	.align	4;				\
 	.word	98b, 99b;			\
 	.text;					\
 	.align	4
 
-#define EX2(x,y,c,d,e,a,b,z) 			\
+#define EX2(x,y,c,d,e,a,b) 			\
 98: 	x,y;					\
-	.section .fixup,z##alloc,z##execinstr;	\
+	.section .fixup,ALLOC,EXECINSTR;	\
 	.align	4;				\
 99:	c, d, e;				\
 	ba fixupretl;				\
 	 a, b, %g3;				\
-	.section __ex_table,z##alloc;		\
+	.section __ex_table,ALLOC;		\
 	.align	4;				\
 	.word	98b, 99b;			\
 	.text;					\
 	.align	4
 
-#define EXO2(x,y,z) 				\
-98: 	x,##y;					\
-	.section __ex_table,z##alloc;		\
+#define EXO2(x,y) 				\
+98: 	x, y;					\
+	.section __ex_table,ALLOC;		\
 	.align	4;				\
 	.word	98b, 97f;			\
 	.text;					\
 	.align	4
 
-#define EXT(start,end,handler,z) 		\
-	.section __ex_table,z##alloc;		\
+#define EXT(start,end,handler)			\
+	.section __ex_table,ALLOC;		\
 	.align	4;				\
 	.word	start, 0, end, handler;		\
 	.text;					\
@@ -104,10 +107,10 @@
 	sth	%t3, [%dst + offset + 0x06];
 
 #define MOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
-	ldub	[%src - offset - 0x02], %t0; \
-	ldub	[%src - offset - 0x01], %t1; \
-	stb	%t0, [%dst - offset - 0x02]; \
-	stb	%t1, [%dst - offset - 0x01];
+	ldub	[%src - (offset) - 0x02], %t0; \
+	ldub	[%src - (offset) - 0x01], %t1; \
+	stb	%t0, [%dst - (offset) - 0x02]; \
+	stb	%t1, [%dst - (offset) - 0x01];
 
 	.text
 	.align	4
@@ -121,23 +124,23 @@ dword_align:
 	be	4f
 	 andcc	%o1, 2, %g0
 
-	EXO2(ldub [%o1], %g2,#)
+	EXO2(ldub [%o1], %g2)
 	add	%o1, 1, %o1
-	EXO2(stb %g2, [%o0],#)
+	EXO2(stb %g2, [%o0])
 	sub	%o2, 1, %o2
 	bne	3f
 	 add	%o0, 1, %o0
 
-	EXO2(lduh [%o1], %g2,#)
+	EXO2(lduh [%o1], %g2)
 	add	%o1, 2, %o1
-	EXO2(sth %g2, [%o0],#)
+	EXO2(sth %g2, [%o0])
 	sub	%o2, 2, %o2
 	b	3f
 	 add	%o0, 2, %o0
 4:
-	EXO2(lduh [%o1], %g2,#)
+	EXO2(lduh [%o1], %g2)
 	add	%o1, 2, %o1
-	EXO2(sth %g2, [%o0],#)
+	EXO2(sth %g2, [%o0])
 	sub	%o2, 2, %o2
 	b	3f
 	 add	%o0, 2, %o0
@@ -160,9 +163,9 @@ C_LABEL(__copy_user):	/* %o0=dst %o1=src %o2=len */
 	be	2f
 	 mov	%o2, %g1
 
-	EXO2(ld [%o1], %o4,#)
+	EXO2(ld [%o1], %o4)
 	sub	%g1, 4, %g1
-	EXO2(st %o4, [%o0],#)
+	EXO2(st %o4, [%o0])
 	add	%o1, 4, %o1
 	add	%o0, 4, %o0
 2:
@@ -177,7 +180,7 @@ C_LABEL(__copy_user):	/* %o0=dst %o1=src %o2=len */
 	MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
 	MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
 80:
-	EXT(5b, 80b, 50f,#)
+	EXT(5b, 80b, 50f)
 	subcc	%g7, 128, %g7
 	add	%o1, 128, %o1
 	bne	5b
@@ -204,37 +207,37 @@ copy_user_table:
 	MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
 	MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
 copy_user_table_end:
-	EXT(copy_user_table, copy_user_table_end, 51f,#)
+	EXT(copy_user_table, copy_user_table_end, 51f)
 	be	copy_user_last7
 	 andcc	%g1, 4, %g0
 
-	EX(ldd	[%o1], %g2, and %g1, 0xf,#)
+	EX(ldd	[%o1], %g2, and %g1, 0xf)
 	add	%o0, 8, %o0
 	add	%o1, 8, %o1
-	EX(st	%g2, [%o0 - 0x08], and %g1, 0xf,#)
-	EX2(st	%g3, [%o0 - 0x04], and %g1, 0xf, %g1, sub %g1, 4,#)
+	EX(st	%g2, [%o0 - 0x08], and %g1, 0xf)
+	EX2(st	%g3, [%o0 - 0x04], and %g1, 0xf, %g1, sub %g1, 4)
 copy_user_last7:
 	be	1f
 	 andcc	%g1, 2, %g0
 
-	EX(ld	[%o1], %g2, and %g1, 7,#)
+	EX(ld	[%o1], %g2, and %g1, 7)
 	add	%o1, 4, %o1
-	EX(st	%g2, [%o0], and %g1, 7,#)
+	EX(st	%g2, [%o0], and %g1, 7)
 	add	%o0, 4, %o0
 1:
 	be	1f
 	 andcc	%g1, 1, %g0
 
-	EX(lduh	[%o1], %g2, and %g1, 3,#)
+	EX(lduh	[%o1], %g2, and %g1, 3)
 	add	%o1, 2, %o1
-	EX(sth	%g2, [%o0], and %g1, 3,#)
+	EX(sth	%g2, [%o0], and %g1, 3)
 	add	%o0, 2, %o0
 1:
 	be	1f
 	 nop
 
-	EX(ldub	[%o1], %g2, add %g0, 1,#)
-	EX(stb	%g2, [%o0], add %g0, 1,#)
+	EX(ldub	[%o1], %g2, add %g0, 1)
+	EX(stb	%g2, [%o0], add %g0, 1)
 1:
 	retl
  	 clr	%o0
@@ -245,7 +248,7 @@ ldd_std:
 	MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
 	MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
 81:
-	EXT(ldd_std, 81b, 52f,#)
+	EXT(ldd_std, 81b, 52f)
 	subcc	%g7, 128, %g7
 	add	%o1, 128, %o1
 	bne	ldd_std
@@ -274,9 +277,9 @@ cannot_optimize:
 	be	10f
 	 nop
 
-	EXO2(ldub [%o1], %g2,#)
+	EXO2(ldub [%o1], %g2)
 	add	%o1, 1, %o1
-	EXO2(stb %g2, [%o0],#)
+	EXO2(stb %g2, [%o0])
 	sub	%o2, 1, %o2
 	andcc	%o2, 0xfffffff0, %o3
 	be	short_end
@@ -285,7 +288,7 @@ cannot_optimize:
 	MOVE_HALFCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
 	MOVE_HALFCHUNK(o1, o0, 0x08, g2, g3, g4, g5)
 82:
-	EXT(10b, 82b, 53f,#)
+	EXT(10b, 82b, 53f)
 	subcc	%o3, 0x10, %o3
 	add	%o1, 0x10, %o1
 	bne	10b
@@ -303,7 +306,7 @@ byte_chunk:
 	MOVE_SHORTCHUNK(o1, o0, -0x0e, g2, g3)
 	MOVE_SHORTCHUNK(o1, o0, -0x10, g2, g3)
 83:
-	EXT(byte_chunk, 83b, 54f,#)
+	EXT(byte_chunk, 83b, 54f)
 	subcc	%o3, 0x10, %o3
 	add	%o1, 0x10, %o1
 	bne	byte_chunk
@@ -328,11 +331,11 @@ short_end:
 	MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
 	MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
 short_table_end:
-	EXT(84b, short_table_end, 55f,#)
+	EXT(84b, short_table_end, 55f)
 	be	1f
 	 nop
-	EX(ldub	[%o1], %g2, add %g0, 1,#)
-	EX(stb	%g2, [%o0], add %g0, 1,#)
+	EX(ldub	[%o1], %g2, add %g0, 1)
+	EX(stb	%g2, [%o0], add %g0, 1)
 1:
 	retl
  	 clr	%o0
@@ -344,11 +347,11 @@ short_aligned_end:
 	be	1f
 	 andcc	%o2, 4, %g0
 
-	EXO2(ld	[%o1 + 0x00], %g2,#)
-	EXO2(ld	[%o1 + 0x04], %g3,#)
+	EXO2(ld	[%o1 + 0x00], %g2)
+	EXO2(ld	[%o1 + 0x04], %g3)
 	add	%o1, 8, %o1
-	EXO2(st	%g2, [%o0 + 0x00],#)
-	EX(st	%g3, [%o0 + 0x04], sub %o2, 4,#)
+	EXO2(st	%g2, [%o0 + 0x00])
+	EX(st	%g3, [%o0 + 0x04], sub %o2, 4)
 	add	%o0, 8, %o0
 1:
 	b	copy_user_last7
diff --git a/arch/sparc/lib/memset.S b/arch/sparc/lib/memset.S
index c5c4073ce8..d049f19b48 100644
--- a/arch/sparc/lib/memset.S
+++ b/arch/sparc/lib/memset.S
@@ -10,20 +10,23 @@
 #include <asm/cprefix.h>
 #include <asm/ptrace.h>
 
-#define EX(x,y,a,b,z) 				\
+/* Work around cpp -rob */
+#define ALLOC #alloc
+#define EXECINSTR #execinstr
+#define EX(x,y,a,b) 				\
 98: 	x,y;					\
-	.section .fixup,z##alloc,z##execinstr;	\
+	.section .fixup,ALLOC,EXECINSTR;	\
 	.align	4;				\
 99:	ba 30f;					\
 	 a, b, %o0;				\
-	.section __ex_table,z##alloc;		\
+	.section __ex_table,ALLOC;		\
 	.align	4;				\
 	.word	98b, 99b;			\
 	.text;					\
 	.align	4
 
-#define EXT(start,end,handler,z) 		\
-	.section __ex_table,z##alloc;		\
+#define EXT(start,end,handler) 			\
+	.section __ex_table,ALLOC;		\
 	.align	4;				\
 	.word	start, 0, end, handler;		\
 	.text;					\
@@ -74,13 +77,13 @@ C_LABEL(memset):
 3:
 	cmp	%o2, 3
 	be	2f
-	 EX(stb	%g3, [%o0], sub %o1, 0,#)
+	 EX(stb	%g3, [%o0], sub %o1, 0)
 
 	cmp	%o2, 2
 	be	2f
-	 EX(stb	%g3, [%o0 + 0x01], sub %o1, 1,#)
+	 EX(stb	%g3, [%o0 + 0x01], sub %o1, 1)
 
-	EX(stb	%g3, [%o0 + 0x02], sub %o1, 2,#)
+	EX(stb	%g3, [%o0 + 0x02], sub %o1, 2)
 2:
 	sub	%o2, 4, %o2
 	add	%o1, %o2, %o1
@@ -101,7 +104,7 @@ C_LABEL(__bzero):
 	be	2f
 	 mov	%g3, %g2
 
-	EX(st	%g3, [%o0], sub %o1, 0,#)
+	EX(st	%g3, [%o0], sub %o1, 0)
 	sub	%o1, 4, %o1
 	add	%o0, 4, %o0
 2:
@@ -113,7 +116,7 @@ C_LABEL(__bzero):
 	subcc	%o3, 128, %o3
 	ZERO_BIG_BLOCK(%o0, 0x40, %g2)
 11:
-	EXT(10b, 11b, 20f,#)
+	EXT(10b, 11b, 20f)
 	bne	10b
 	 add	%o0, 128, %o0
 
@@ -138,17 +141,17 @@ C_LABEL(__bzero):
 	be	1f
 	 andcc	%o1, 2, %g0
 
-	EX(st	%g3, [%o0], and %o1, 7,#)
+	EX(st	%g3, [%o0], and %o1, 7)
 	add	%o0, 4, %o0
 1:
 	be	1f
 	 andcc	%o1, 1, %g0
 
-	EX(sth	%g3, [%o0], and %o1, 3,#)
+	EX(sth	%g3, [%o0], and %o1, 3)
 	add	%o0, 2, %o0
 1:
 	bne,a	8f
-	 EX(stb	%g3, [%o0], and %o1, 1,#)
+	 EX(stb	%g3, [%o0], and %o1, 1)
 8:
 	retl
 	 clr	%o0
@@ -161,7 +164,7 @@ C_LABEL(__bzero):
 	 add	%o0, 1, %o0
 	subcc	%o1, 1, %o1
 	bne,a	8b
-	 EX(stb	%g3, [%o0 - 1], add %o1, 1,#)
+	 EX(stb	%g3, [%o0 - 1], add %o1, 1)
 0:
 	retl
 	 clr	%o0
diff --git a/arch/sparc/math-emu/sfp-util.h b/arch/sparc/math-emu/sfp-util.h
index 75ec691244..dcda4d1df2 100644
--- a/arch/sparc/math-emu/sfp-util.h
+++ b/arch/sparc/math-emu/sfp-util.h
@@ -4,8 +4,8 @@
 #include <asm/byteorder.h>
 
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) 				\
-  __asm__ ("addcc %r4,%5,%1
-	addx %r2,%3,%0"							\
+  __asm__ ("addcc %r4,%5,%1\n\t" \
+	"addx %r2,%3,%0\n"							\
 	   : "=r" ((USItype)(sh)),					\
 	     "=&r" ((USItype)(sl))					\
 	   : "%rJ" ((USItype)(ah)),					\
@@ -14,8 +14,8 @@
 	     "rI" ((USItype)(bl))					\
 	   : "cc")
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) 				\
-  __asm__ ("subcc %r4,%5,%1
-	subx %r2,%3,%0"							\
+  __asm__ ("subcc %r4,%5,%1\n\t" \
+	"subx %r2,%3,%0\n"							\
 	   : "=r" ((USItype)(sh)),					\
 	     "=&r" ((USItype)(sl))					\
 	   : "rJ" ((USItype)(ah)),					\
@@ -25,46 +25,46 @@
 	   : "cc")
 
 #define umul_ppmm(w1, w0, u, v) \
-  __asm__ ("! Inlined umul_ppmm
-	wr	%%g0,%2,%%y	! SPARC has 0-3 delay insn after a wr
-	sra	%3,31,%%g2	! Don't move this insn
-	and	%2,%%g2,%%g2	! Don't move this insn
-	andcc	%%g0,0,%%g1	! Don't move this insn
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,%3,%%g1
-	mulscc	%%g1,0,%%g1
-	add	%%g1,%%g2,%0
-	rd	%%y,%1"							\
+  __asm__ ("! Inlined umul_ppmm\n\t" \
+	"wr	%%g0,%2,%%y	! SPARC has 0-3 delay insn after a wr\n\t" \
+	"sra	%3,31,%%g2	! Don't move this insn\n\t" \
+	"and	%2,%%g2,%%g2	! Don't move this insn\n\t" \
+	"andcc	%%g0,0,%%g1	! Don't move this insn\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,%3,%%g1\n\t" \
+	"mulscc	%%g1,0,%%g1\n\t" \
+	"add	%%g1,%%g2,%0\n\t" \
+	"rd	%%y,%1\n"							\
 	   : "=r" ((USItype)(w1)),					\
 	     "=r" ((USItype)(w0))					\
 	   : "%rI" ((USItype)(u)),					\
@@ -74,30 +74,31 @@
 /* It's quite necessary to add this much assembler for the sparc.
    The default udiv_qrnnd (in C) is more than 10 times slower!  */
 #define udiv_qrnnd(q, r, n1, n0, d) \
-  __asm__ ("! Inlined udiv_qrnnd
-	mov	32,%%g1
-	subcc	%1,%2,%%g0
-1:	bcs	5f
-	 addxcc %0,%0,%0	! shift n1n0 and a q-bit in lsb
-	sub	%1,%2,%1	! this kills msb of n
-	addx	%1,%1,%1	! so this can't give carry
-	subcc	%%g1,1,%%g1
-2:	bne	1b
-	 subcc	%1,%2,%%g0
-	bcs	3f
-	 addxcc %0,%0,%0	! shift n1n0 and a q-bit in lsb
-	b	3f
-	 sub	%1,%2,%1	! this kills msb of n
-4:	sub	%1,%2,%1
-5:	addxcc	%1,%1,%1
-	bcc	2b
-	 subcc	%%g1,1,%%g1
-! Got carry from n.  Subtract next step to cancel this carry.
-	bne	4b
-	 addcc	%0,%0,%0	! shift n1n0 and a 0-bit in lsb
-	sub	%1,%2,%1
-3:	xnor	%0,0,%0
-	! End of inline udiv_qrnnd"					\
+  __asm__ ("! Inlined udiv_qrnnd\n\t"         \
+     "mov 32,%%g1\n\t"            \
+     "subcc %1,%2,%%g0\n\t"         \
+     "1:  bcs 5f\n\t"           \
+     "addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n\t"  \
+  "addxcc %0,%0,%0	! shift n1n0 and a q-bit in lsb\n\t" \
+  "	sub	%1,%2,%1	! this kills msb of n\n\t" \
+  "	addx	%1,%1,%1	! so this can't give carry\n\t" \
+  "	subcc	%%g1,1,%%g1\n\t" \
+  "2:	bne	1b\n\t" \
+  "	 subcc	%1,%2,%%g0\n\t" \
+  "	bcs	3f\n\t" \
+  "	 addxcc %0,%0,%0	! shift n1n0 and a q-bit in lsb\n\t" \
+  "	b	3f\n\t" \
+  "	 sub	%1,%2,%1	! this kills msb of n\n\t" \
+  "4:	sub	%1,%2,%1\n\t" \
+  "5:	addxcc	%1,%1,%1\n\t" \
+  "	bcc	2b\n\t" \
+  "	 subcc	%%g1,1,%%g1\n\t" \
+  "! Got carry from n.  Subtract next step to cancel this carry.\n\t" \
+  "	bne	4b\n\t" \
+  "	 addcc	%0,%0,%0	! shift n1n0 and a 0-bit in lsb\n\t" \
+  "	sub	%1,%2,%1\n\t" \
+  "3:	xnor	%0,0,%0\n\t" \
+  "! End of inline udiv_qrnnd"					\
 	   : "=&r" ((USItype)(q)),					\
 	     "=&r" ((USItype)(r))					\
 	   : "r" ((USItype)(d)),					\
diff --git a/include/asm-sparc/checksum.h b/include/asm-sparc/checksum.h
index 2f92efb444..08b3d97431 100644
--- a/include/asm-sparc/checksum.h
+++ b/include/asm-sparc/checksum.h
@@ -47,76 +47,86 @@ extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned i
   
 extern unsigned int __csum_partial_copy_sparc_generic (const char *, char *);
 
-extern __inline__ unsigned int 
-csum_partial_copy_nocheck (const char *src, char *dst, int len, 
-			   unsigned int sum)
-{
-	register unsigned int ret asm("o0") = (unsigned int)src;
-	register char *d asm("o1") = dst;
-	register int l asm("g1") = len;
-	
-	__asm__ __volatile__ (
-		"call " C_LABEL_STR(__csum_partial_copy_sparc_generic) "\n\t"
-		" mov %4, %%g7\n"
-	: "=r" (ret) : "0" (ret), "r" (d), "r" (l), "r" (sum) :
-	"o1", "o2", "o3", "o4", "o5", "o7", "g1", "g2", "g3", "g4", "g5", "g7");
-	return ret;
-}
+static inline unsigned int 
+ csum_partial_copy_nocheck (const char *src, char *dst, int len,
+         unsigned int sum)
+ {      
+  register unsigned int ret asm("o0") = (unsigned int)src;
+  register char *d asm("o1") = dst;
+  register int l asm("g1") = len;
+
+  __asm__ __volatile__ (
+    "call " C_LABEL_STR(__csum_partial_copy_sparc_generic) "\n\t"
+    " mov %6, %%g7\n"
+  : "=&r" (ret), "=&r" (d), "=&r" (l)
+  : "0" (ret), "1" (d), "2" (l), "r" (sum)
+  : "o2", "o3", "o4", "o5", "o7",
+    "g2", "g3", "g4", "g5", "g7",
+    "memory", "cc");
+  return ret;
+ }
+
+static inline unsigned int
+ csum_partial_copy_from_user(const char *src, char *dst, int len,
+          unsigned int sum, int *err)
+   {
+  if (!access_ok (VERIFY_READ, src, len)) {
+    *err = -EFAULT;
+    memset (dst, 0, len);
+    return sum;
+  } else {
+    register unsigned int ret asm("o0") = (unsigned int)src;
+    register char *d asm("o1") = dst;
+    register int l asm("g1") = len;
+    register unsigned int s asm("g7") = sum;
+
 
-extern __inline__ unsigned int 
-csum_partial_copy_from_user(const char *src, char *dst, int len, 
-			    unsigned int sum, int *err)
-  {
-	if (!access_ok (VERIFY_READ, src, len)) {
-		*err = -EFAULT;
-		memset (dst, 0, len);
-		return sum;
-	} else {
-		register unsigned int ret asm("o0") = (unsigned int)src;
-		register char *d asm("o1") = dst;
-		register int l asm("g1") = len;
-		register unsigned int s asm("g7") = sum;
-
-		__asm__ __volatile__ (
-		".section __ex_table,#alloc\n\t"
-		".align 4\n\t"
-		".word 1f,2\n\t"
-		".previous\n"
-		"1:\n\t"
-		"call " C_LABEL_STR(__csum_partial_copy_sparc_generic) "\n\t"
-		" st %5, [%%sp + 64]\n"
-		: "=r" (ret) : "0" (ret), "r" (d), "r" (l), "r" (s), "r" (err) :
-		"o1", "o2", "o3", "o4", "o5", "o7", "g1", "g2", "g3", "g4", "g5", "g7");
-		return ret;
-	}
+    __asm__ __volatile__ (
+    ".section __ex_table,#alloc\n\t"
+    ".align 4\n\t"
+    ".word 1f,2\n\t"
+    ".previous\n"
+    "1:\n\t"
+    "call " C_LABEL_STR(__csum_partial_copy_sparc_generic) "\n\t"
+    " st %8, [%%sp + 64]\n"
+    : "=&r" (ret), "=&r" (d), "=&r" (l), "=&r" (s)
+    : "0" (ret), "1" (d), "2" (l), "3" (s), "r" (err)
+    : "o2", "o3", "o4", "o5", "o7", "g2", "g3", "g4", "g5",
+      "cc", "memory");
+    return ret;
+   }
   }
+
   
-extern __inline__ unsigned int 
-csum_partial_copy_to_user(const char *src, char *dst, int len, 
-			  unsigned int sum, int *err)
-{
-	if (!access_ok (VERIFY_WRITE, dst, len)) {
-		*err = -EFAULT;
-		return sum;
-	} else {
-		register unsigned int ret asm("o0") = (unsigned int)src;
-		register char *d asm("o1") = dst;
-		register int l asm("g1") = len;
-		register unsigned int s asm("g7") = sum;
-
-		__asm__ __volatile__ (
-		".section __ex_table,#alloc\n\t"
-		".align 4\n\t"
-		".word 1f,1\n\t"
-		".previous\n"
-		"1:\n\t"
-		"call " C_LABEL_STR(__csum_partial_copy_sparc_generic) "\n\t"
-		" st %5, [%%sp + 64]\n"
-		: "=r" (ret) : "0" (ret), "r" (d), "r" (l), "r" (s), "r" (err) :
-		"o1", "o2", "o3", "o4", "o5", "o7", "g1", "g2", "g3", "g4", "g5", "g7");
-		return ret;
-	}
-}
+static inline unsigned int
+ csum_partial_copy_to_user(const char *src, char *dst, int len,
+        unsigned int sum, int *err)
+ {
+  if (!access_ok (VERIFY_WRITE, dst, len)) {
+    *err = -EFAULT;
+    return sum;
+  } else {
+    register unsigned int ret asm("o0") = (unsigned int)src;
+    register char *d asm("o1") = dst;
+    register int l asm("g1") = len;
+    register unsigned int s asm("g7") = sum;
+
+    __asm__ __volatile__ (
+    ".section __ex_table,#alloc\n\t"
+    ".align 4\n\t"
+    ".word 1f,1\n\t"
+    ".previous\n"
+    "1:\n\t"
+    "call " C_LABEL_STR(__csum_partial_copy_sparc_generic) "\n\t"
+    " st %8, [%%sp + 64]\n"
+    : "=&r" (ret), "=&r" (d), "=&r" (l), "=&r" (s)
+    : "0" (ret), "1" (d), "2" (l), "3" (s), "r" (err)
+    : "o2", "o3", "o4", "o5", "o7",
+      "g2", "g3", "g4", "g5",
+      "cc", "memory");
+    return ret;
+  }
+ }
 
 #define HAVE_CSUM_COPY_USER
 #define csum_and_copy_to_user csum_partial_copy_to_user
diff --git a/include/asm-sparc/io.h b/include/asm-sparc/io.h
index 3d74130c7d..8790f87645 100644
--- a/include/asm-sparc/io.h
+++ b/include/asm-sparc/io.h
@@ -14,6 +14,8 @@
 #define virt_to_bus virt_to_phys
 #define bus_to_virt phys_to_virt
 
+#define page_to_phys(page)  ((page - mem_map) << PAGE_SHIFT)
+
 static __inline__ u32 flip_dword (u32 d)
 {
 	return ((d&0xff)<<24) | (((d>>8)&0xff)<<16) | (((d>>16)&0xff)<<8)| ((d>>24)&0xff);
diff --git a/include/asm-sparc/sfp-machine.h b/include/asm-sparc/sfp-machine.h
index f5372637f4..74d6e3958d 100644
--- a/include/asm-sparc/sfp-machine.h
+++ b/include/asm-sparc/sfp-machine.h
@@ -77,9 +77,9 @@
 
 /* Some assembly to speed things up. */
 #define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0)			\
-  __asm__ ("addcc %r7,%8,%2
-	    addxcc %r5,%6,%1
-	    addx %r3,%4,%0"						\
+  __asm__ ("addcc %r7,%8,%2\n\t" \
+	    "addxcc %r5,%6,%1\n\t" \
+	    "addx %r3,%4,%0\n\t"						\
 	   : "=r" ((USItype)(r2)),					\
 	     "=&r" ((USItype)(r1)),					\
 	     "=&r" ((USItype)(r0))					\
@@ -92,9 +92,9 @@
 	   : "cc")
 
 #define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0)			\
-  __asm__ ("subcc %r7,%8,%2
-	    subxcc %r5,%6,%1
-	    subx %r3,%4,%0"						\
+  __asm__ ("subcc %r7,%8,%2\n\t" \
+	    "subxcc %r5,%6,%1\n\t" \
+	    "subx %r3,%4,%0\n\t"						\
 	   : "=r" ((USItype)(r2)),					\
 	     "=&r" ((USItype)(r1)),					\
 	     "=&r" ((USItype)(r0))					\
@@ -111,11 +111,10 @@
     /* We need to fool gcc,  as we need to pass more than 10		\
        input/outputs.  */						\
     register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2");		\
-    __asm__ __volatile__ ("
-	    addcc %r8,%9,%1
-	    addxcc %r6,%7,%0
-	    addxcc %r4,%5,%%g2
-	    addx %r2,%3,%%g1"						\
+    __asm__ __volatile__ ("addcc %r8,%9,%1\n\t" \
+	    "addxcc %r6,%7,%0\n\t" \
+	    "addxcc %r4,%5,%%g2\n\t" \
+	    "addx %r2,%3,%%g1\n\t"						\
 	   : "=&r" ((USItype)(r1)),					\
 	     "=&r" ((USItype)(r0))					\
 	   : "%rJ" ((USItype)(x3)),					\
@@ -136,11 +135,10 @@
     /* We need to fool gcc,  as we need to pass more than 10		\
        input/outputs.  */						\
     register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2");		\
-    __asm__ __volatile__ ("
-	    subcc %r8,%9,%1
-	    subxcc %r6,%7,%0
-	    subxcc %r4,%5,%%g2
-	    subx %r2,%3,%%g1"						\
+    __asm__ __volatile__ ( "subcc %r8,%9,%1\n\t" \
+	    "subxcc %r6,%7,%0\n\t" \
+	    "subxcc %r4,%5,%%g2\n\t" \
+	    "subx %r2,%3,%%g1"						\
 	   : "=&r" ((USItype)(r1)),					\
 	     "=&r" ((USItype)(r0))					\
 	   : "%rJ" ((USItype)(x3)),					\
@@ -161,10 +159,10 @@
 #define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) __FP_FRAC_SUB_4(x3,x2,x1,x0,x3,x2,x1,x0,y3,y2,y1,y0)
 
 #define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i)					\
-  __asm__ ("addcc %3,%4,%3
-	    addxcc %2,%%g0,%2
-	    addxcc %1,%%g0,%1
-	    addx %0,%%g0,%0"						\
+  __asm__ ("addcc %3,%4,%3\n\t" \
+	    "addxcc %2,%%g0,%2\n\t" \
+	    "addxcc %1,%%g0,%1\n\t" \
+	    "addx %0,%%g0,%0"						\
 	   : "=&r" ((USItype)(x3)),					\
 	     "=&r" ((USItype)(x2)),					\
 	     "=&r" ((USItype)(x1)),					\
diff --git a/include/asm-sparc/string.h b/include/asm-sparc/string.h
index 7bce820e86..f470c8fd18 100644
--- a/include/asm-sparc/string.h
+++ b/include/asm-sparc/string.h
@@ -189,10 +189,12 @@ static inline int __constant_strncmp(const char *src, const char *dest, __kernel
 }
 
 #undef strncmp
-#define strncmp(__arg0, __arg1, __arg2)	\
+//#define strncmp(__arg0, __arg1, __arg2)	\
 (__builtin_constant_p(__arg2) ?	\
  __constant_strncmp(__arg0, __arg1, __arg2) : \
  __strncmp(__arg0, __arg1, __arg2))
+
+#define strncmp(__arg0, __arg1, __arg2) __strncmp(__arg0, __arg1, __arg2)
  
 #endif /* !EXPORT_SYMTAB_STROPS */
 
diff --git a/include/asm-sparc/system.h b/include/asm-sparc/system.h
index 4725f9d317..ac41a0c3e8 100644
--- a/include/asm-sparc/system.h
+++ b/include/asm-sparc/system.h
@@ -109,15 +109,14 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
 	 * - Anton
 	 */
 #define switch_to(prev, next, last) do {						\
-	__label__ here;									\
-	register unsigned long task_pc asm("o7");					\
 	extern struct task_struct *current_set[NR_CPUS];				\
 	SWITCH_ENTER									\
 	SWITCH_DO_LAZY_FPU								\
 	next->active_mm->cpu_vm_mask |= (1 << smp_processor_id());			\
-	task_pc = ((unsigned long) &&here) - 0x8;					\
 	__asm__ __volatile__(								\
+        "sethi  %%hi(here - 0x8), %%o7\n\t" \
 	"mov	%%g6, %%g3\n\t"								\
+        "or     %%o7, %%lo(here - 0x8), %%o7\n\t" \
 	"rd	%%psr, %%g4\n\t"							\
 	"std	%%sp, [%%g6 + %4]\n\t"							\
 	"rd	%%wim, %%g5\n\t"							\
@@ -141,15 +140,16 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
 	"nop\n\t"									\
 	"jmpl	%%o7 + 0x8, %%g0\n\t"							\
 	" mov	%%g3, %0\n\t"								\
+        "here:\n"    \
         : "=&r" (last)									\
         : "r" (&(current_set[hard_smp_processor_id()])), "r" (next),			\
 	  "i" ((const unsigned long)(&((struct task_struct *)0)->thread.kpsr)),		\
 	  "i" ((const unsigned long)(&((struct task_struct *)0)->thread.ksp)),		\
-	  "r" (task_pc)									\
+	  "i" ((const unsigned long)(&((struct task_struct *)0)->thread.kpc)) 		\
 	: "g1", "g2", "g3", "g4", "g5", "g7", "l0", "l1",				\
 	"l4", "l5", "l6", "l7", "i0", "i1", "i2", "i3", "i4", "i5", "o0", "o1", "o2",	\
-	"o3");										\
-here:;  } while(0)
+	"o3", "o7");										\
+       } while(0)
 
 /*
  * Changing the IRQ level on the Sparc.
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index 7d0395582e..2da89e1075 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -3,6 +3,7 @@
 
 #include <linux/interrupt.h>
 #include <linux/keyboard.h>
+#include <linux/tty.h>
 
 extern struct tasklet_struct keyboard_tasklet;
 
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index 0241b41fdc..227ad0934c 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -9,6 +9,7 @@
 #include <linux/config.h>
 #include <linux/vt.h>
 #include <linux/kd.h>
+#include <linux/tty.h>
 
 /*
  * Presently, a lot of graphics programs do not restore the contents of
diff --git a/init/main.c b/init/main.c
index c7e9d0faa4..6bf37c6b2b 100644
--- a/init/main.c
+++ b/init/main.c
@@ -233,14 +233,17 @@ static void __init parse_options(char *line)
 	char *next,*quote;
 	int args, envs;
 
+	printk("parse_options entry\n");
 	if (!*line)
 		return;
 	args = 0;
 	envs = 1;	/* TERM is set to 'linux' by default */
 	next = line;
 	while ((line = next) != NULL) {
+	        printk("parse_options loop top\n");
                 quote = strchr(line,'"');
                 next = strchr(line, ' ');
+	        printk("parse_options loop quote=%p next=%p\n", quote, next);
                 while (next != NULL && quote != NULL && quote < next) {
                         /* we found a left quote before the next blank
                          * now we have to find the matching right quote
@@ -251,9 +254,13 @@ static void __init parse_options(char *line)
                                 next = strchr(next+1, ' ');
                         }
                 }
+	        printk("parse_options loop a\n");
                 if (next != NULL)
                         *next++ = 0;
+	        printk("parse_options loop b\n");
+	        printk("parse_options loop line=%s\n", line);
 		if (!strncmp(line,"init=",5)) {
+	                printk("parse_options loop c\n");
 			line += 5;
 			execute_command = line;
 			/* In case LILO is going to boot us with default command line,
@@ -264,24 +271,29 @@ static void __init parse_options(char *line)
 			args = 0;
 			continue;
 		}
+                printk("parse_options loop d\n");
 		if (checksetup(line))
 			continue;
 		
+                printk("parse_options loop e\n");
 		/*
 		 * Then check if it's an environment variable or
 		 * an option.
 		 */
 		if (strchr(line,'=')) {
+                        printk("parse_options loop e.1\n");
 			if (envs >= MAX_INIT_ENVS)
 				break;
 			envp_init[++envs] = line;
 		} else {
+                        printk("parse_options loop e.2\n");
 			if (args >= MAX_INIT_ARGS)
 				break;
 			if (*line)
 				argv_init[++args] = line;
 		}
 	}
+        printk("parse_options loop exit: args=%d envs=%d\n", args, envs);
 	argv_init[args+1] = NULL;
 	envp_init[envs+1] = NULL;
 }
diff --git a/kernel/sched.c b/kernel/sched.c
index db3e42f74c..574a4c857e 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -609,6 +609,7 @@ repeat_schedule:
 			p->counter = (p->counter >> 1) + NICE_TO_TICKS(p->nice);
 		read_unlock(&tasklist_lock);
 		spin_lock_irq(&runqueue_lock);
+                printk("schedle/going repeat_schedule b\n");
 		goto repeat_schedule;
 	}
 
@@ -624,6 +625,7 @@ repeat_schedule:
 	if (unlikely(prev == next)) {
 		/* We won't go through the normal tail, so do this by hand */
 		prev->policy &= ~SCHED_YIELD;
+                printk("schedle/going save_process a\n");
 		goto same_process;
 	}
 
@@ -675,6 +677,8 @@ repeat_schedule:
 		}
 	}
 
+        printk("schedule: prev=%p next=%p\n", prev, next);
+        printk("schedule: active_mm's prev=%p next=%p\n", prev->active_mm, next->active_mm);
 	/*
 	 * This just switches the register state and the
 	 * stack.
@@ -684,8 +688,10 @@ repeat_schedule:
 
 same_process:
 	reacquire_kernel_lock(current);
-	if (current->need_resched)
+	if (current->need_resched) {
+                printk("schedle/going need_resched a\n");
 		goto need_resched_back;
+        }
 	return;
 }
 
-- 
2.47.2

