Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Add a syscall variant passing the return address in...
details: https://anonhg.NetBSD.org/src/rev/b67d66013442
branches: trunk
changeset: 763533:b67d66013442
user: martin <martin%NetBSD.org@localhost>
date: Wed Mar 23 20:41:30 2011 +0000
description:
Add a syscall variant passing the return address in %g5 (we need %g7 for
pthread_self and %g2 is an application register, so we can not use those
anymore).
diffstat:
sys/arch/sparc/include/trap.h | 3 ++-
sys/arch/sparc/sparc/syscall.c | 26 ++++++++++++++++++--------
sys/arch/sparc64/include/trap.h | 3 ++-
sys/arch/sparc64/sparc64/syscall.c | 20 +++++++++++++-------
4 files changed, 35 insertions(+), 17 deletions(-)
diffs (137 lines):
diff -r 163eab60ac6f -r b67d66013442 sys/arch/sparc/include/trap.h
--- a/sys/arch/sparc/include/trap.h Wed Mar 23 20:22:33 2011 +0000
+++ b/sys/arch/sparc/include/trap.h Wed Mar 23 20:41:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.h,v 1.16 2005/12/11 12:19:06 christos Exp $ */
+/* $NetBSD: trap.h,v 1.17 2011/03/23 20:41:30 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -131,6 +131,7 @@
/* flags to system call (flags in %g1 along with syscall number) */
#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */
#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */
+#define SYSCALL_G5RFLAG 0x1000 /* use %g5 as above (only ABI compatible way) */
/*
* `software trap' macros to keep people happy (sparc v8 manual says not
diff -r 163eab60ac6f -r b67d66013442 sys/arch/sparc/sparc/syscall.c
--- a/sys/arch/sparc/sparc/syscall.c Wed Mar 23 20:22:33 2011 +0000
+++ b/sys/arch/sparc/sparc/syscall.c Wed Mar 23 20:41:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.23 2010/12/20 00:25:44 matt Exp $ */
+/* $NetBSD: syscall.c,v 1.24 2011/03/23 20:41:31 martin Exp $ */
/*
* Copyright (c) 1996
@@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.23 2010/12/20 00:25:44 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.24 2011/03/23 20:41:31 martin Exp $");
#include "opt_sparc_arch.h"
#include "opt_multiprocessor.h"
@@ -108,8 +108,8 @@
static inline int
handle_new(struct trapframe *tf, register_t *code)
{
- int new = *code & (SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
- *code &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
+ int new = *code & (SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
+ *code &= ~(SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
return new;
}
@@ -249,8 +249,13 @@
tf->tf_out[0] = rval.o[0];
tf->tf_out[1] = rval.o[1];
if (new) {
- /* jmp %g2 (or %g7, deprecated) on success */
- i = tf->tf_global[new & SYSCALL_G2RFLAG ? 2 : 7];
+ /* jmp %g5, (or %g2 or %g7, deprecated) on success */
+ if (new & SYSCALL_G5RFLAG)
+ i = tf->tf_global[5];
+ else if (new & SYSCALL_G2RFLAG)
+ i = tf->tf_global[2];
+ else
+ i = tf->tf_global[7];
if (i & 3) {
error = EINVAL;
goto bad;
@@ -334,8 +339,13 @@
tf->tf_out[0] = rval.o[0];
tf->tf_out[1] = rval.o[1];
if (new) {
- /* jmp %g2 (or %g7, deprecated) on success */
- i = tf->tf_global[new & SYSCALL_G2RFLAG ? 2 : 7];
+ /* jmp %g5, (or %g2 or %g7, deprecated) on success */
+ if (new & SYSCALL_G5RFLAG)
+ i = tf->tf_global[5];
+ else if (new & SYSCALL_G2RFLAG)
+ i = tf->tf_global[2];
+ else
+ i = tf->tf_global[7];
if (i & 3) {
error = EINVAL;
goto bad;
diff -r 163eab60ac6f -r b67d66013442 sys/arch/sparc64/include/trap.h
--- a/sys/arch/sparc64/include/trap.h Wed Mar 23 20:22:33 2011 +0000
+++ b/sys/arch/sparc64/include/trap.h Wed Mar 23 20:41:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.h,v 1.7 2010/12/13 06:40:13 mrg Exp $ */
+/* $NetBSD: trap.h,v 1.8 2011/03/23 20:41:31 martin Exp $ */
/*
* Copyright (c) 1996-1999 Eduardo Horvath
@@ -142,6 +142,7 @@
/* flags to system call (flags in %g1 along with syscall number) */
#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */
#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */
+#define SYSCALL_G5RFLAG 0x1000 /* use %g5 as above (only ABI compatible way) */
/*
* `software trap' macros to keep people happy (sparc v8 manual says not
diff -r 163eab60ac6f -r b67d66013442 sys/arch/sparc64/sparc64/syscall.c
--- a/sys/arch/sparc64/sparc64/syscall.c Wed Mar 23 20:22:33 2011 +0000
+++ b/sys/arch/sparc64/sparc64/syscall.c Wed Mar 23 20:41:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.37 2010/04/23 19:18:10 rmind Exp $ */
+/* $NetBSD: syscall.c,v 1.38 2011/03/23 20:41:31 martin Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.37 2010/04/23 19:18:10 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.38 2011/03/23 20:41:31 martin Exp $");
#include "opt_sa.h"
@@ -127,12 +127,18 @@
static inline int
handle_old(struct trapframe64 *tf, register_t *code)
{
- int new = *code & (SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
- *code &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG);
- if (new)
- tf->tf_pc = tf->tf_global[new & SYSCALL_G2RFLAG ? 2 : 7];
- else
+ int new = *code & (SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
+ *code &= ~(SYSCALL_G7RFLAG|SYSCALL_G2RFLAG|SYSCALL_G5RFLAG);
+ if (new) {
+ if (new & SYSCALL_G5RFLAG)
+ tf->tf_pc = tf->tf_global[5];
+ else if (new & SYSCALL_G7RFLAG)
+ tf->tf_pc = tf->tf_global[7];
+ else
+ tf->tf_pc = tf->tf_global[2];
+ } else {
tf->tf_pc = tf->tf_npc;
+ }
return new;
}
Home |
Main Index |
Thread Index |
Old Index