Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64/sparc64 syscall clean up from ifdeffed out ...
details: https://anonhg.NetBSD.org/src/rev/c5a4d90d9dfe
branches: trunk
changeset: 555889:c5a4d90d9dfe
user: petrov <petrov%NetBSD.org@localhost>
date: Wed Dec 03 20:23:41 2003 +0000
description:
syscall clean up from ifdeffed out code.
diffstat:
sys/arch/sparc64/sparc64/trap.c | 114 ++++++---------------------------------
1 files changed, 18 insertions(+), 96 deletions(-)
diffs (236 lines):
diff -r 97fd2a377b65 -r c5a4d90d9dfe sys/arch/sparc64/sparc64/trap.c
--- a/sys/arch/sparc64/sparc64/trap.c Wed Dec 03 19:55:37 2003 +0000
+++ b/sys/arch/sparc64/sparc64/trap.c Wed Dec 03 20:23:41 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.103 2003/11/25 05:14:58 cdi Exp $ */
+/* $NetBSD: trap.c,v 1.104 2003/12/03 20:23:41 petrov Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.103 2003/11/25 05:14:58 cdi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.104 2003/12/03 20:23:41 petrov Exp $");
#define NEW_FPSTATE
@@ -955,11 +955,6 @@
printf("trap: done\n");
/* if (type != T_BREAKPOINT) Debugger(); */
}
-#if 0
- if (trapdebug & TDB_FRAME) {
- print_trapframe(tf);
- }
-#endif
#endif
}
@@ -1858,15 +1853,15 @@
*/
void
syscall(tf, code, pc)
+ struct trapframe64 *tf;
register_t code;
- struct trapframe64 *tf;
register_t pc;
{
int i, nsys, nap;
int64_t *ap;
const struct sysent *callp;
struct lwp *l = curlwp;
- struct proc *p = curproc;
+ struct proc *p = l->l_proc;
int error = 0, new;
union args {
register32_t i[8];
@@ -1874,7 +1869,6 @@
} args;
register_t rval[2];
u_quad_t sticks;
- vaddr_t dest;
vaddr_t opc, onpc;
#ifdef DEBUG
@@ -1925,13 +1919,11 @@
onpc = tf->tf_npc;
if (new)
- dest = tf->tf_global[new & SYSCALL_G2RFLAG ? 2 : 7];
+ tf->tf_pc = tf->tf_global[new & SYSCALL_G2RFLAG ? 2 : 7];
else
- dest = tf->tf_npc;
+ tf->tf_pc = tf->tf_npc;
- tf->tf_pc = dest;
- tf->tf_npc = dest + 4;
-
+ tf->tf_npc = tf->tf_pc + 4;
/*
* The first six system call arguments are in the six %o registers.
@@ -2003,26 +1995,8 @@
/* 64-bit stack -- not really supported on 32-bit kernels */
callp += code;
i = callp->sy_narg; /* Why divide? */
-#ifdef DEBUG
- if (i != (long)callp->sy_argsize / sizeof(register64_t))
- printf("syscall %s: narg=%hd, argsize=%hd, call=%p, "
- "argsz/reg64=%ld\n",
- p->p_emul->e_syscallnames ?
- ((code < 0 || code >= nsys) ?
- "illegal syscall" :
- p->p_emul->e_syscallnames[code])
- : "unknown syscall",
- callp->sy_narg, callp->sy_argsize,
- callp->sy_call,
- (long)callp->sy_argsize / sizeof(register64_t));
-#endif
+
if (i > nap) { /* usually false */
-#ifdef DEBUG
- if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW) || i > 8) {
- printf("Args64 %d>%d -- need to copyin\n",
- i, nap);
- }
-#endif
if (i > 8)
panic("syscall nargs");
/* Read the whole block in */
@@ -2038,7 +2012,7 @@
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p, code, code, NULL, (register_t *)args.l);
+ ktrsyscall(p, code, code, NULL, (register_t *)&args);
#endif
if (error)
goto bad;
@@ -2055,26 +2029,21 @@
#endif
} else {
register32_t *argp;
- int j = 0;
+ int j;
/* 32-bit stack */
callp += code;
-#if defined(__arch64__) && defined(DEBUG)
- if ((curproc->p_flag & P_32) == 0) {
+#ifdef DIAGNOSTIC
+#if defined(__arch64__)
+ if ((curproc->p_flag & P_32) == 0)
printf("syscall(): 32-bit stack but no P_32\n");
- Debugger();
- }
+#endif
#endif
i = (long)callp->sy_argsize / sizeof(register32_t);
if (i > nap) { /* usually false */
register32_t temp[6];
-#ifdef DEBUG
- if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW) || i > 8)
- printf("Args %d>%d -- need to copyin\n",
- i, nap);
-#endif
if (i > 8)
panic("syscall nargs");
/* Read the whole block in */
@@ -2117,9 +2086,9 @@
#endif
}
#endif /* KTRACE */
- if (error) {
+ if (error)
goto bad;
- }
+
#ifdef DEBUG
if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW)) {
for (i = 0; i < (long)callp->sy_argsize /
@@ -2147,6 +2116,7 @@
"unknown syscall");
}
#endif
+
/* Lock the kernel if the syscall isn't MP-safe. */
if ((callp->sy_flags & SYCALL_MPSAFE) == 0)
KERNEL_PROC_LOCK(l);
@@ -2161,50 +2131,10 @@
/* Note: fork() does not return here in the child */
tf->tf_out[0] = rval[0];
tf->tf_out[1] = rval[1];
- if (new) {
-#if 0
- /* jmp %g2 (or %g7, deprecated) on success */
- dest = tf->tf_global[new & SYSCALL_G2RFLAG ? 2 : 7];
-#endif
-#ifdef DEBUG
- if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW))
- printf("syscall: return tstate=%llx new "
- "success to %p retval %lx:%lx\n",
- (unsigned long long)tf->tf_tstate,
- (void *)(u_long)dest,
- (u_long)rval[0], (u_long)rval[1]);
-#endif
-#if 0
- if (dest & 3) {
- error = EINVAL;
- goto bad;
- }
-#endif
- } else {
+ if (!new)
/* old system call convention: clear C on success */
tf->tf_tstate &= ~(((int64_t)(ICC_C | XCC_C)) <<
TSTATE_CCR_SHIFT); /* success */
-#if 0
- dest = tf->tf_npc;
-#endif
-#ifdef DEBUG
- if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW))
- printf("syscall: return tstate=%llx old "
- "success to %p retval %lx:%lx\n",
- (unsigned long long)tf->tf_tstate,
- (void *)(u_long)dest,
- (u_long)rval[0], (u_long)rval[1]);
- if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW))
- printf("old pc=%p npc=%p dest=%p\n",
- (void *)(u_long)tf->tf_pc,
- (void *)(u_long)tf->tf_npc,
- (void *)(u_long)dest);
-#endif
- }
-#if 0
- tf->tf_pc = dest;
- tf->tf_npc = dest + 4;
-#endif
break;
case ERESTART:
@@ -2225,12 +2155,6 @@
TSTATE_CCR_SHIFT); /* fail */
tf->tf_pc = onpc;
tf->tf_npc = tf->tf_pc + 4;
-#ifdef DEBUG
- if (trapdebug & (TDB_SYSCALL | TDB_FOLLOW))
- printf("syscall: return tstate=%llx fail %d to %p\n",
- (unsigned long long)tf->tf_tstate, error,
- (void *)(long)dest);
-#endif
break;
}
@@ -2245,8 +2169,6 @@
if (trapdebug & (TDB_STOPCALL | TDB_SYSTOP)) {
Debugger();
}
-#endif
-#ifdef DEBUG
if (trapdebug & TDB_FRAME) {
print_trapframe(tf);
}
Home |
Main Index |
Thread Index |
Old Index