First cut at updating the sh port to the new syscall stuff

diff --git a/klibc/README b/klibc/README
index 0652ac2..eec0f9a 100644
--- a/klibc/README
+++ b/klibc/README
@@ -35,7 +35,7 @@
    The following is the last known status of various architectures:
 
    alpha:	 Working static, shared untested
-   arm-thumb:	 Probably working
+   arm-thumb:	 Untested
    arm26:	 Not yet ported
    arm:		 Working
    cris:	 Untested
@@ -50,7 +50,7 @@
    ppc:		 Working
    s390:	 Working static, shared untested
    s390x:	 Working
-   sh:		 Needs sysstub.ph
+   sh:		 Untested
    sparc64:	 sigaction() fails in ash for unknown reason
    sparc:	 Working
    v850:	 Not yet ported
diff --git a/klibc/arch/sh/Makefile.inc b/klibc/arch/sh/Makefile.inc
index 16d7ea1..ccabfa4 100644
--- a/klibc/arch/sh/Makefile.inc
+++ b/klibc/arch/sh/Makefile.inc
@@ -7,7 +7,8 @@
 # accordingly.
 #
 
-ARCHOBJS = arch/sh/setjmp.o
+ARCHOBJS = arch/sh/setjmp.o \
+	   arch/sh/syscall.o
 
 ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
 
diff --git a/klibc/arch/sh/crt0.S b/klibc/arch/sh/crt0.S
index c9938a5..21a3765 100644
--- a/klibc/arch/sh/crt0.S
+++ b/klibc/arch/sh/crt0.S
@@ -1,12 +1,11 @@
 #
 # arch/sh/crt0.S
 #
-# void _start(void)
-# {
-#    /* Divine up argc, argv, and envp */
-#    environ = envp;
-#    exit(main(argc, argv, envp));
-# } 
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
 #
 
 	.text
diff --git a/klibc/arch/sh/syscall.S b/klibc/arch/sh/syscall.S
new file mode 100644
index 0000000..41a0486
--- /dev/null
+++ b/klibc/arch/sh/syscall.S
@@ -0,0 +1,35 @@
+/*
+ * arch/sh/syscall.S
+ *
+ * On sh, r3 contains the syscall number (set by generated stub);
+ * r4..r7 contain arguments 0-3 per the standard calling convention,
+ * and arguments 4-5 are passed in r0 and r1.
+ *
+ * The return value is in r3 rather than standard r0.
+ */
+
+	.section ".text.syscall","ax"
+	.align	2
+	.globl	___syscall_common
+	.type	___syscall_common,@function
+___syscall_common:
+	mov.l	@(sp),r0
+	mov.l	@(4,sp),r1
+	trapa	#0x15
+	mov.l	1f,r0
+	cmp/hs	r0,r3
+	bt/s	3f
+	  neg	r3,r4
+	mov.l	2f,r5
+	mov.l	r4,@r5
+	rts
+	  mov	#-1,r0
+3:
+	rts
+	  mov	r3,r0
+
+	.align 2
+1:	.long	-4096		/* Errno limit */
+2:	.long	errno
+
+	.size	___syscall_common,.-___syscall_common
diff --git a/klibc/arch/sh/sysstub.ph b/klibc/arch/sh/sysstub.ph
new file mode 100644
index 0000000..add5d35
--- /dev/null
+++ b/klibc/arch/sh/sysstub.ph
@@ -0,0 +1,34 @@
+# -*- perl -*-
+#
+# arch/sh/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+    my($fname, $type, $sname, $stype, @args) = @_;
+
+    open(OUT, '>', "syscalls/${fname}.S");
+    print OUT "#include <asm/unistd.h>\n";
+    print OUT "\n";
+    print OUT "\t.section\t\".text.syscall\",\"ax\"\n";
+    print OUT "\t.type\t${fname},\#function\n";
+    print OUT "\t.globl\t${fname}\n";
+    print OUT "\t.align\t2\n";
+    print OUT "${fname}:\n";
+    print OUT "\tbra\t__syscall_common\n";
+    print OUT "#if __NR_${sname} >= 128\n";
+    print OUT "\t  mov.l\t1f, r3\n";
+    print OUT "#else\n";
+    print OUT "\t  mov\t# __NR_${sname}, r3\n";
+    print OUT "#endif\n";
+    print OUT "\t.size ${fname},.-${fname}\n";
+    print OUT "\n";
+    print OUT "#if __NR_${sname} >= 128\n";
+    print OUT "\t.align\t2\n";
+    print OUT "1:\t.long\t__NR_${sname}\n";
+    print OUT "#endif\n";
+    close(OUT);
+}
+
+1;