Implement new system call architecture for alpha
diff --git a/klibc/README b/klibc/README
index 4ed57a3..25735ad 100644
--- a/klibc/README
+++ b/klibc/README
@@ -34,7 +34,7 @@
The following is the last known status of various architectures:
- alpha: Needs sysstub.ph
+ alpha: Untested
arm-thumb: Probably OK
arm26: Not yet ported
arm: Working
diff --git a/klibc/arch/alpha/Makefile.inc b/klibc/arch/alpha/Makefile.inc
index 2a1100f..89f5ecb 100644
--- a/klibc/arch/alpha/Makefile.inc
+++ b/klibc/arch/alpha/Makefile.inc
@@ -26,7 +26,9 @@
arch/$(ARCH)/__divl.o \
arch/$(ARCH)/__reml.o \
arch/$(ARCH)/pipe.o \
- arch/$(ARCH)/setjmp.o
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ arch/$(ARCH)/sysdual.o \
ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
diff --git a/klibc/arch/alpha/syscall.S b/klibc/arch/alpha/syscall.S
new file mode 100644
index 0000000..37c2ae9
--- /dev/null
+++ b/klibc/arch/alpha/syscall.S
@@ -0,0 +1,22 @@
+#
+# arch/alpha/syscall.S
+#
+
+#include <machine/asm.h>
+
+ .text
+ .align 3
+ .type __syscall_common,@function
+ .ent __syscall_common, 0
+ .globl __syscall_common
+__syscall_common:
+ callsys
+ beq a3, 1f
+ ldah a1, errno(zero)
+ lda v0, -1(zero)
+ stq a3, errno(a1)
+1:
+ ret zero,(ra),1
+
+ .size __syscall_common,.-__syscall_common
+ .end __syscall_common
diff --git a/klibc/arch/alpha/sysdual.S b/klibc/arch/alpha/sysdual.S
new file mode 100644
index 0000000..6c9cf51
--- /dev/null
+++ b/klibc/arch/alpha/sysdual.S
@@ -0,0 +1,29 @@
+#
+# arch/alpha/sysdual.S
+#
+
+#
+# Some system calls have an alternate return value in r20 (a4).
+# This system call stub is for system calls where that is
+# the "real" return value.
+#
+
+#include <machine/asm.h>
+
+ .text
+ .align 3
+ .type __syscall_dual1,@function
+ .ent __syscall_dual1, 0
+ .globl __syscall_dual1
+__syscall_dual1:
+ callsys
+ lda v0, 0(a4)
+ beq a3, 1f
+ ldah a1, errno(zero)
+ lda v0, -1(zero)
+ stq a3, errno(a1)
+1:
+ ret zero,(ra),1
+
+ .size __syscall_dual1,.-__syscall_dual1
+ .end __syscall_dual1
diff --git a/klibc/arch/alpha/sysstub.ph b/klibc/arch/alpha/sysstub.ph
new file mode 100644
index 0000000..a24b6c0
--- /dev/null
+++ b/klibc/arch/alpha/sysstub.ph
@@ -0,0 +1,37 @@
+# -*- perl -*-
+#
+# arch/alpha/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+# On Alpha, most system calls follow the standard convention, with the
+# system call number in r0 (v0), return an error value in r19 (a3) as
+# well as the return value in r0 (v0).
+#
+# A few system calls are dual-return with the second return value in
+# r20 (a4).
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ $stype = $stype || 'common';
+ $stype = 'common' if ( $stype eq 'dual0' );
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "#include <machine/asm.h>\n";
+ print OUT "\n";
+ print OUT "\t.text\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.ent\t${fname}, 0\n"; # What is this?
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tlda\tv0, __NR_${sname}(zero)\n";
+ print OUT "\tbr __syscall_${stype}\n";
+ print OUT "\t.size\t${fname},.-${fname}\n";
+ print OUT "\t.end\t${fname}\n";
+ close(OUT);
+}
+
+1;