Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/m68k During signal delivery, arrange to have the si...



details:   https://anonhg.NetBSD.org/src/rev/bf4722509dee
branches:  trunk
changeset: 533557:bf4722509dee
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 04 01:50:39 2002 +0000

description:
During signal delivery, arrange to have the signal handler invoked
directly, using the trampoline only for the return path.  Saves a
"jsr" in the trampoline.

Reviewed, tested and OK'd by Steve Woodford.

diffstat:

 sys/arch/m68k/include/signal.h   |   7 ++-----
 sys/arch/m68k/m68k/sig_machdep.c |  11 +++++++----
 sys/arch/m68k/m68k/sigcode.s     |  35 ++++++++++++++++-------------------
 3 files changed, 25 insertions(+), 28 deletions(-)

diffs (117 lines):

diff -r edb25aff1798 -r bf4722509dee sys/arch/m68k/include/signal.h
--- a/sys/arch/m68k/include/signal.h    Thu Jul 04 00:52:49 2002 +0000
+++ b/sys/arch/m68k/include/signal.h    Thu Jul 04 01:50:39 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signal.h,v 1.9 2002/06/23 21:31:12 thorpej Exp $       */
+/*     $NetBSD: signal.h,v 1.10 2002/07/04 01:50:39 thorpej Exp $      */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
@@ -95,15 +95,12 @@
 
 /*
  * Stack frame layout when delivering a signal.
- *
- * WARNING: code in locore.s assumes the layout shown for sf_signum
- * thru sf_handler, so... don't screw with them!
  */
 struct sigframe {
+       int     sf_ra;                  /* handler return address */
        int     sf_signum;              /* signal number for handler */
        int     sf_code;                /* additional info for handler */
        struct sigcontext *sf_scp;      /* context pointer for handler */
-       sig_t   sf_handler;             /* handler address for u_sigc */
        struct sigcontext sf_sc;        /* actual context */
        struct sigstate sf_state;       /* state of the hardware */
 };
diff -r edb25aff1798 -r bf4722509dee sys/arch/m68k/m68k/sig_machdep.c
--- a/sys/arch/m68k/m68k/sig_machdep.c  Thu Jul 04 00:52:49 2002 +0000
+++ b/sys/arch/m68k/m68k/sig_machdep.c  Thu Jul 04 01:50:39 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.15 2001/07/28 13:08:34 tsutsui Exp $ */
+/*     $NetBSD: sig_machdep.c,v 1.16 2002/07/04 01:50:40 thorpej Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -112,10 +112,10 @@
 #endif
 
        /* Build stack frame for signal trampoline. */
+       kf.sf_ra = (int)p->p_sigctx.ps_sigcode;
        kf.sf_signum = sig;
        kf.sf_code = code;
        kf.sf_scp = &fp->sf_sc;
-       kf.sf_handler = catcher;
 
        /*
         * Save necessary hardware state.  Currently this includes:
@@ -209,9 +209,12 @@
                       kf.sf_sc.sc_sp, kf.sf_sc.sc_ap);
 #endif
 
-       /* Set up the registers to return to sigcode. */
+       /*
+        * Set up the registers to return to the signal handler.  The
+        * handler will then return to the signal trampoline.
+        */
        frame->f_regs[SP] = (int)fp;
-       frame->f_pc = (int)p->p_sigctx.ps_sigcode;
+       frame->f_pc = (int)catcher;
 
        /* Remember that we're now on the signal stack. */
        if (onstack)
diff -r edb25aff1798 -r bf4722509dee sys/arch/m68k/m68k/sigcode.s
--- a/sys/arch/m68k/m68k/sigcode.s      Thu Jul 04 00:52:49 2002 +0000
+++ b/sys/arch/m68k/m68k/sigcode.s      Thu Jul 04 01:50:39 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sigcode.s,v 1.10 2000/11/26 11:47:25 jdolecek Exp $    */
+/*     $NetBSD: sigcode.s,v 1.11 2002/07/04 01:50:40 thorpej Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -50,30 +50,27 @@
  */
 
 /*
- * Signal "trampoline" code (18 bytes).  Invoked from RTE setup by sendsig().
+ * Signal trampoline; copied to top of user stack.
  *
- * Stack looks like:
+ * The handler has returned here as if we had called it.  On
+ * entry, the stack looks like:
  *
- *     sp+0    ->      signal number
- *     sp+4            signal specific code
- *     sp+8            pointer to signal context frame (scp)
- *     sp+12           address of handler
- *     sp+16           saved hardware state
- *                             .
- *                             .
- *                             .
- *     scp+0   ->      beginning of signal context frame
+ *             sigcontext structure                    [12]
+ *             pointer to sigcontext structure         [8]
+ *             signal specific code                    [4]
+ *     sp->    signal number                           [0]
  */
 
        .data
        .align  2
 GLOBAL(sigcode)
-       movl    %sp@(12),%a0    | signal handler addr           (4 bytes)
-       jsr     %a0@            | call signal handler           (2 bytes)
-       addql   #4,%sp          | pop signal number             (2 bytes)
-       trap    #3              | special sigreturn trap        (2 bytes)
-       movl    %d0,%sp@(4)     | save errno                    (4 bytes)
-       moveq   #SYS_exit,%d0   | syscall == exit               (2 bytes)
-       trap    #0              | exit(errno)                   (2 bytes)
+       leal    %sp@(12),%a0    /* get pointer to sigcontext */
+       movl    %a0,%sp@(4)     /* put it in the argument slot */
+                               /* fake return address already there */
+       trap    #3              /* special sigreturn trap */
+       movl    %d0,%sp@(4)     /* exit with errno */
+       moveq   #SYS_exit,%d0   /* if sigreturn fails */
+       trap    #0
+
        .align  2
 GLOBAL(esigcode)



Home | Main Index | Thread Index | Old Index