Subject: Re: __sigreturn14
To: None <thorpej@nas.nasa.gov, port-m68k@netbsd.org>
From: ITOH Yasufumi <yasufu-i@is.aist-nara.ac.jp>
List: port-m68k
Date: 11/21/1998 22:12:07
In article <199811211021.CAA11995@lestat.nas.nasa.gov>
thorpej@nas.nasa.gov writes:
> On Sat, 21 Nov 1998 14:08:55 +0900 (JST)
> yasufu-i@is.aist-nara.ac.jp (ITOH Yasufumi) wrote:
> > Well, then, we waste a trap every time we change signal interface.
> > I don't think this is a good way.
> >
> > How about using d1/a0/a1/stack ?
>
> We (Charles and I) hope to have a getcontext/setcontext system call to
> deal with this issue after 1.4.
Fine, but we use trap #3 only for __sigreturn14
and will allocate another trap for setcontext?
I think setcontext requires special stack operation. (Right?)
I'd like to suggest the following changes rather softly.
This make it possible to use trap #3 for future extention,
such as setcontext syscall.
(The softness is because this may confuse -current users....)
Thanks,
--
ITOH, Yasufumi <yasufu-i@is.aist-nara.ac.jp>, <itohy@netbsd.org>
diff -u lib/libc/arch/m68k/gen/__setjmp14.S.orig lib/libc/arch/m68k/gen/__setjmp14.S
--- lib/libc/arch/m68k/gen/__setjmp14.S.orig Mon Oct 5 20:08:16 1998
+++ lib/libc/arch/m68k/gen/__setjmp14.S Sat Nov 21 20:18:40 1998
@@ -98,9 +98,9 @@
movl sp@(4),a0 /* save area pointer */
tstl a0@(8) /* ensure non-zero SP */
jeq botch /* oops! */
- movl sp@(8),d0 /* grab return value */
+ movl sp@(8),d1 /* grab return value */
jne ok /* non-zero ok */
- moveq #1,d0 /* else make non-zero */
+ moveq #1,d1 /* else make non-zero */
ok:
moveml a0@(44),#0x3CFC /* restore non-scratch regs */
movl a0,sp@- /* let sigreturn */
diff -u lib/libc/arch/m68k/sys/__sigreturn14.S.orig lib/libc/arch/m68k/sys/__sigreturn14.S
--- lib/libc/arch/m68k/sys/__sigreturn14.S.orig Mon Oct 5 20:08:17 1998
+++ lib/libc/arch/m68k/sys/__sigreturn14.S Sat Nov 21 20:18:40 1998
@@ -59,5 +59,6 @@
#endif /* GPROF */
ENTRY(__sigreturn14)
- trap #3 /* special sigreturn syscall entry point */
+ movl #SYS___sigreturn14,d0 /* syscall no. */
+ trap #3 /* special syscall entry point */
jra cerror
diff -u sys/arch/m68k/m68k/sigreturn.s.orig sys/arch/m68k/m68k/sigreturn.s
--- sys/arch/m68k/m68k/sigreturn.s.orig Mon Oct 5 20:11:11 1998
+++ sys/arch/m68k/m68k/sigreturn.s Sat Nov 21 20:32:06 1998
@@ -62,7 +62,7 @@
moveml #0xFFFF,sp@- | save user registers
movl usp,a0 | save the user SP
movl a0,sp@(FR_SP) | in the savearea
- movl #SYS___sigreturn14,sp@- | push syscall number
+ movl d0,sp@- | push syscall number
jbsr _C_LABEL(syscall) | handle it
addql #4,sp | pop syscall#
movl sp@(FR_SP),a0 | grab and restore
diff -u sys/arch/m68k/m68k/sigcode.s.orig sys/arch/m68k/m68k/sigcode.s
--- sys/arch/m68k/m68k/sigcode.s.orig Mon Oct 5 20:11:10 1998
+++ sys/arch/m68k/m68k/sigcode.s Sat Nov 21 20:25:36 1998
@@ -71,7 +71,9 @@
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 #SYS___sigreturn14,d0
+ | syscall == __sigreturn14 (6 bytes)
+ trap #3 | special syscall 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)
diff -uF^[a-zA-Z_][a-z A-Z0-9_]*(.*[^;]$ sys/arch/m68k/m68k/sig_machdep.c.orig sys/arch/m68k/m68k/sig_machdep.c
--- sys/arch/m68k/m68k/sig_machdep.c.orig Mon Oct 5 20:11:10 1998
+++ sys/arch/m68k/m68k/sig_machdep.c Sat Nov 21 20:26:07 1998
@@ -278,8 +278,11 @@ sys___sigreturn14(p, v, retval)
* Grab pointer to hardware state information.
* If zero, the user is probably doing a longjmp.
*/
- if ((rf = scp->sc_ap) == 0)
+ if ((rf = scp->sc_ap) == 0) {
+ /* setjmp() return value is passed in d1 from longjmp() */
+ frame->f_regs[D0] = frame->f_regs[D1];
goto restore;
+ }
/*
* See if there is anything to do before we go to the