aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Jarno <aurel32@debian.org>2010-04-16 18:17:58 +0200
committermaximilian attems <max@stro.at>2010-07-07 14:06:25 +0200
commit529d9d2653e0a7ea8073b4c9c7a15504c44800be (patch)
treee3a6e27f1033ffff85933a8f72238580fc78da15
parent9736adf3ea2100e12299b9e7e292a58f5d6863f6 (diff)
downloadklibc-529d9d2653e0a7ea8073b4c9c7a15504c44800be.tar.gz
[klibc] sh4: syscalls fixes
Using the patch from bug #574834 klibc now builds, but does not work. It assumes that the kernel returns the result of the syscalls in register r3, while it behaves like a normal call, with the results in register r0. Also the pipe syscall needs a special handling as on some other architectures, the structure passed in argument is not filled, instead the two fd are returned in r0 and r1. The patch below fixes the problem. It has been tested by creating an initrd with initramfs and booting the system with it. Closes: #578076 Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/klibc/SYSCALLS.def2
-rw-r--r--usr/klibc/arch/sh/Kbuild2
-rw-r--r--usr/klibc/arch/sh/pipe.S35
-rw-r--r--usr/klibc/arch/sh/syscall.S14
4 files changed, 44 insertions, 9 deletions
diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index e395119811e4ab..437dfa790a1f3b 100644
--- a/usr/klibc/SYSCALLS.def
+++ b/usr/klibc/SYSCALLS.def
@@ -115,7 +115,7 @@ int fchmod(int, mode_t);
int mkdir(const char *, mode_t);
<?> int mkdirat(int, const char *, const char *, mode_t);
int rmdir(const char *);
-<!alpha,ia64,mips,mips64,sparc,sparc64> int pipe(int *);
+<!alpha,ia64,mips,mips64,sh,sparc,sparc64> int pipe(int *);
mode_t umask(mode_t);
int chroot(const char *);
int symlink(const char *, const char *);
diff --git a/usr/klibc/arch/sh/Kbuild b/usr/klibc/arch/sh/Kbuild
index ab7ad5af738115..29b606a7028665 100644
--- a/usr/klibc/arch/sh/Kbuild
+++ b/usr/klibc/arch/sh/Kbuild
@@ -2,7 +2,7 @@
# klibc files for sh
#
-klib-y := setjmp.o syscall.o
+klib-y := pipe.o setjmp.o syscall.o
always := crt0.o
targets := crt0.o
diff --git a/usr/klibc/arch/sh/pipe.S b/usr/klibc/arch/sh/pipe.S
new file mode 100644
index 00000000000000..01b055bc2636f0
--- /dev/null
+++ b/usr/klibc/arch/sh/pipe.S
@@ -0,0 +1,35 @@
+/*
+ * arch/sh/pipe.S
+ *
+ * The pipe system call is special on sh: it returns
+ * the two file descriptors in r0 and r1.
+ */
+
+#include <asm/unistd.h>
+
+ .section ".text.syscall","ax"
+ .align 2
+ .globl pipe
+ .type pipe,@function
+pipe:
+ mov #__NR_pipe, r3
+ trapa #0x10
+ mov.l 1f,r2
+ cmp/hs r0,r2
+ bt/s 3f
+ neg r0,r2
+ mov.l 2f,r3
+ mov.l r2,@r3
+ rts
+ mov #-1,r0
+3:
+ mov.l r0, @r4
+ mov.l r1, @(4, r4)
+ rts
+ mov #0,r0
+
+ .align 2
+1: .long -4096 /* Errno limit */
+2: .long errno
+
+ .size pipe,.-pipe
diff --git a/usr/klibc/arch/sh/syscall.S b/usr/klibc/arch/sh/syscall.S
index f5f85cc9bcb1c1..77245b7ea52a2c 100644
--- a/usr/klibc/arch/sh/syscall.S
+++ b/usr/klibc/arch/sh/syscall.S
@@ -5,7 +5,7 @@
* 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.
+ * The return value is in r0.
*/
.section ".text.syscall","ax"
@@ -16,17 +16,17 @@ __syscall_common:
mov.l @(0,sp),r0
mov.l @(4,sp),r1
trapa #0x15
- mov.l 1f,r0
- cmp/hs r0,r3
+ mov.l 1f,r1
+ cmp/hs r0,r1
bt/s 3f
- neg r3,r4
- mov.l 2f,r5
- mov.l r4,@r5
+ neg r0,r1
+ mov.l 2f,r2
+ mov.l r1,@r2
rts
mov #-1,r0
3:
rts
- mov r3,r0
+ nop
.align 2
1: .long -4096 /* Errno limit */