linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sh: Implemented syscall_{get|set}_arguments for i != 0
@ 2014-04-14 17:13 Konstantin Tokarev
  0 siblings, 0 replies; only message in thread
From: Konstantin Tokarev @ 2014-04-14 17:13 UTC (permalink / raw)
  To: Matt Fleming, Paul Mundt; +Cc: linux-kernel, linux-sh

From 5cd11ca62acfcde2757fbcc9bbb55e9449d2d50b Mon Sep 17 00:00:00 2001
From: Konstantin Tokarev <ktokarev@smartlabs.tv>
Date: Mon, 14 Apr 2014 20:38:00 +0400
Subject: [PATCH] sh: Implemented syscall_{get|set}_arguments for i != 0.

syscall_get_arguments and syscall_set_arguments implementations for SH
will not call BUG() when invokend with i != 0 anymore.

Signed-off-by: Konstantin Tokarev <ktokarev@smartlabs.tv>
---
 arch/sh/include/asm/syscall_32.h |   74 
+++++++++++++++++++++-----------------
 1 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/arch/sh/include/asm/syscall_32.h 
b/arch/sh/include/asm/syscall_32.h
index 7d80df4..52fb5ad 100755
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -44,53 +44,61 @@ static inline void syscall_set_return_value(struct 
task_struct *task,
 		regs->regs[0] = val;
 }
 
-static inline void syscall_get_arguments(struct task_struct *task,
-					 struct pt_regs *regs,
-					 unsigned int i, unsigned int n,
-					 unsigned long *args)
+static inline unsigned long sh_get_syscall_arg(struct pt_regs *regs,
+					       unsigned int n)
 {
-	/*
-	 * Do this simply for now. If we need to start supporting
-	 * fetching arguments from arbitrary indices, this will need some
-	 * extra logic. Presently there are no in-tree users that depend
-	 * on this behaviour.
-	 */
-	BUG_ON(i);
-
 	/* Argument pattern is: R4, R5, R6, R7, R0, R1 */
 	switch (n) {
-	case 6: args[5] = regs->regs[1];
-	case 5: args[4] = regs->regs[0];
-	case 4: args[3] = regs->regs[7];
-	case 3: args[2] = regs->regs[6];
-	case 2: args[1] = regs->regs[5];
-	case 1:	args[0] = regs->regs[4];
+	case 5: return regs->regs[1];
+	case 4: return regs->regs[0];
+	case 3: return regs->regs[7];
+	case 2: return regs->regs[6];
+	case 1: return regs->regs[5];
+	case 0: return regs->regs[4];
+	default:
+		BUG();
+	}
+	return ~0;
+}
+
+static inline void sh_set_syscall_arg(struct pt_regs *regs,
+				      unsigned int n,
+				      unsigned long val)
+{
+	switch (n) {
+	case 5:
+		regs->regs[1] = val;
+	case 4:
+		regs->regs[0] = val;
+	case 3:
+		regs->regs[7] = val;
+	case 2:
+		regs->regs[6] = val;
+	case 1:
+		regs->regs[5] = val;
 	case 0:
-		break;
+		regs->regs[4] = val;
 	default:
 		BUG();
 	}
 }
 
+static inline void syscall_get_arguments(struct task_struct *task,
+					 struct pt_regs *regs,
+					 unsigned int i, unsigned int n,
+					 unsigned long *args)
+{
+	while (n--)
+		*args++ = sh_get_syscall_arg(regs, i++);
+}
+
 static inline void syscall_set_arguments(struct task_struct *task,
 					 struct pt_regs *regs,
 					 unsigned int i, unsigned int n,
 					 const unsigned long *args)
 {
-	/* Same note as above applies */
-	BUG_ON(i);
-
-	switch (n) {
-	case 6: regs->regs[1] = args[5];
-	case 5: regs->regs[0] = args[4];
-	case 4: regs->regs[7] = args[3];
-	case 3: regs->regs[6] = args[2];
-	case 2: regs->regs[5] = args[1];
-	case 1: regs->regs[4] = args[0];
-		break;
-	default:
-		BUG();
-	}
+	while (n--)
+		sh_set_syscall_arg(regs, i++, *args++);
 }
 
 #endif /* __ASM_SH_SYSCALL_32_H */
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-14 17:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-14 17:13 [PATCH] sh: Implemented syscall_{get|set}_arguments for i != 0 Konstantin Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).