diff options
Diffstat (limited to 'sysdeps/unix/bsd/sun/m68k')
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/Dist | 1 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/Makefile | 3 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h | 30 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/brk.S | 49 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/dl-brk.S | 1 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/sethostid.S | 44 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/sigtramp.c | 145 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/syscall.S | 28 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/sysdep.h | 62 | ||||
-rw-r--r-- | sysdeps/unix/bsd/sun/m68k/vfork.S | 56 |
10 files changed, 419 insertions, 0 deletions
diff --git a/sysdeps/unix/bsd/sun/m68k/Dist b/sysdeps/unix/bsd/sun/m68k/Dist new file mode 100644 index 0000000..cd893ff --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/Dist @@ -0,0 +1 @@ +sigtramp.c diff --git a/sysdeps/unix/bsd/sun/m68k/Makefile b/sysdeps/unix/bsd/sun/m68k/Makefile new file mode 100644 index 0000000..ac4121d --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),signal) +sysdep_routines := $(sysdep_routines) sigtramp +endif diff --git a/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h b/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h new file mode 100644 index 0000000..99a0506 --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/bits/sigcontext.h @@ -0,0 +1,30 @@ +/* Structure describing state saved while handling a signal. Sun 3 version. + Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SIGNAL_H +# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead." +#endif + +struct sigcontext + { + int sc_onstack; + __sigset_t sc_mask; + + int sc_sp, sc_pc, sc_ps; + }; diff --git a/sysdeps/unix/bsd/sun/m68k/brk.S b/sysdeps/unix/bsd/sun/m68k/brk.S new file mode 100644 index 0000000..07af96d --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/brk.S @@ -0,0 +1,49 @@ +/* Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +#ifndef SYS_brk +#define SYS_brk 17 +#endif + +#ifndef HAVE_GNU_LD +#define __end _end +#endif + +.data +.globl ___curbrk +___curbrk: + .long __end + +.text +ENTRY (__brk) + movel #__end, d0 + cmpl sp@(4), d0 + ble 0f + movel d0, sp@(4) +0: pea SYS_brk + trap #0 + bcs 1f + movel sp@(4), ___curbrk + clrl d0 + rts +1: + jmp syscall_error + +weak_alias (__brk, brk) diff --git a/sysdeps/unix/bsd/sun/m68k/dl-brk.S b/sysdeps/unix/bsd/sun/m68k/dl-brk.S new file mode 100644 index 0000000..eeb9654 --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/dl-brk.S @@ -0,0 +1 @@ +#include <brk.S> diff --git a/sysdeps/unix/bsd/sun/m68k/sethostid.S b/sysdeps/unix/bsd/sun/m68k/sethostid.S new file mode 100644 index 0000000..73ee796 --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/sethostid.S @@ -0,0 +1,44 @@ +/* Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +#ifdef SYS_sethostid + +SYSCALL (sethostid, 1) + ret + +#else + +#include <bits/errno.h> + +.globl _sethostid +.even +_sethostid: + movel #ENOSYS, _errno + moveq #-1, d0 + rts + +#ifdef HAVE_GNU_LD + +.stabs "warning: sethostid is not implemented and will always fail",30,0,0,0 +.stabs "_sethostid",1,0,0,0 + +#endif + +#endif diff --git a/sysdeps/unix/bsd/sun/m68k/sigtramp.c b/sysdeps/unix/bsd/sun/m68k/sigtramp.c new file mode 100644 index 0000000..5a3ca3c --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/sigtramp.c @@ -0,0 +1,145 @@ +/* Copyright (C) 1993, 1996, 1997, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __GNUC__ + #error This file uses GNU C extensions; you must compile with GCC. +#endif + +/* Get the definition of `struct sigcontext'. */ +#define KERNEL +#define sigvec sun_sigvec +#define sigstack sun_sigstack +#define sigcontext sun_sigcontext +#include "/usr/include/sys/signal.h" +#undef sigvec +#undef sigstack +#undef sigcontext +#undef NSIG +#undef SIGABRT +#undef SIGCLD +#undef SV_ONSTACK +#undef SV_RESETHAND +#undef SV_INTERRUPT +#undef SA_ONSTACK +#undef SA_NOCLDSTOP +#undef SIG_ERR +#undef SIG_DFL +#undef SIG_IGN +#undef sigmask +#undef SIG_BLOCK +#undef SIG_UNBLOCK +#undef SIG_SETMASK + +#include <signal.h> +#include <stddef.h> +#include <errno.h> + +/* Defined in __sigvec.S. */ +extern int __raw_sigvec (int sig, const struct sigvec *vec, + struct sigvec *ovec); + +/* User-specified signal handlers. */ +#define mytramp 1 +#ifdef mytramp +static __sighandler_t handlers[NSIG]; +#else +#define handlers _sigfunc +extern __sighandler_t _sigfunc[]; +#endif + +#if mytramp + +/* Handler for all signals that are handled by a user-specified function. + Saves and restores the general regs %g2-%g7, the %y register, and + all the FPU regs (including %fsr), around calling the user's handler. */ +static void +trampoline (sig, code, context, addr) + int sig; + int code; + struct sigcontext *context; + void *addr; +{ + int save[4]; + + /* Save the call-clobbered registers. */ + asm volatile ("movem%.l d0-d1/a0-a1, %0" : : "m" (save[0])); + + /* XXX should save/restore FP regs */ + + /* Call the user's handler. */ + (*((void (*) (int sig, int code, struct sigcontext *context, + PTR addr)) handlers[sig])) + (sig, code, context, addr); + + /* Restore the call-clobbered registers. */ + asm volatile ("movem%.l %0, d0-d1/a0-a1" : : "g" (save[0]) : + "d0", "d1", "a0", "a1"); + + __sigreturn (context); +} + +#endif + +int +__sigvec (sig, vec, ovec) + int sig; + const struct sigvec *vec; + struct sigvec *ovec; +{ +#ifndef mytramp + extern void _sigtramp (int); +#define trampoline _sigtramp +#endif + struct sigvec myvec; + int mask; + __sighandler_t ohandler; + + if (sig <= 0 || sig >= NSIG) + { + __set_errno (EINVAL); + return -1; + } + + mask = __sigblock(sigmask(sig)); + + ohandler = handlers[sig]; + + if (vec != NULL && + vec->sv_handler != SIG_IGN && vec->sv_handler != SIG_DFL) + { + handlers[sig] = vec->sv_handler; + myvec = *vec; + myvec.sv_handler = trampoline; + vec = &myvec; + } + + if (__raw_sigvec(sig, vec, ovec) < 0) + { + int save = errno; + (void) __sigsetmask(mask); + errno = save; + return -1; + } + + if (ovec != NULL && ovec->sv_handler == trampoline) + ovec->sv_handler = ohandler; + + (void) __sigsetmask(mask); + + return 0; +} diff --git a/sysdeps/unix/bsd/sun/m68k/syscall.S b/sysdeps/unix/bsd/sun/m68k/syscall.S new file mode 100644 index 0000000..1d4d5be --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/syscall.S @@ -0,0 +1,28 @@ +/* Copyright (C) 1993, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +ENTRY (syscall) + movel sp@, d0 /* Save return address in D0. */ + movel sp@(4), sp@ /* Put syscall number at top of stack. */ + movel d0, sp@(4) /* Put return address under it. */ + trap #0 /* Do syscall; pops number from stack. */ + jcs error + ret +error: jmp syscall_error diff --git a/sysdeps/unix/bsd/sun/m68k/sysdep.h b/sysdeps/unix/bsd/sun/m68k/sysdep.h new file mode 100644 index 0000000..e51ab0a --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/sysdep.h @@ -0,0 +1,62 @@ +/* Copyright (C) 1991, 1992, 1994, 1995, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdeps/unix/sysdep.h> + +#ifdef __ASSEMBLER__ + +#define POUND # + +#ifdef __STDC__ +#define ENTRY(name) \ + .globl _##name; \ + .even; \ + _##name##: +#else +#define ENTRY(name) \ + .globl _/**/name; \ + .even; \ + _/**/name/**/: +#endif + +#ifdef __STDC__ +#define PSEUDO(name, syscall_name, args) \ + .even; \ + .globl syscall_error; \ + error: jmp syscall_error; \ + ENTRY (name) \ + pea SYS_##syscall_name; \ + trap POUND 0; \ + bcs error +#else +#define PSEUDO(name, syscall_name, args) \ + .even; \ + .globl syscall_error; \ + error: jmp syscall_error; \ + ENTRY (name) \ + pea SYS_/**/syscall_name; \ + trap POUND 0; \ + bcs error +#endif + +#define ret rts +#define r0 d0 +#define r1 d1 +#define MOVE(x,y) movel x , y + +#endif /* __ASSEMBLER__ */ diff --git a/sysdeps/unix/bsd/sun/m68k/vfork.S b/sysdeps/unix/bsd/sun/m68k/vfork.S new file mode 100644 index 0000000..cf9e2e9 --- /dev/null +++ b/sysdeps/unix/bsd/sun/m68k/vfork.S @@ -0,0 +1,56 @@ +/* Copyright (C) 1991, 92, 93, 94, 95, 97, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +#ifndef SYS_vfork +#define SYS_vfork 66 +#endif + +/* Clone the calling process, but without copying the whole address space. + The calling process is suspended until the new process exits or is + replaced by a call to `execve'. Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ +.globl ___vfork +___vfork: + /* Pop the return PC value into A0. */ + movel sp@+, a0 + + /* Push the syscall number and trap into the kernel. */ + movel #SYS_vfork, sp@- + trap #0 + bcs error /* Branch forward if it failed. */ + + /* It succeeded. See which fork we're in. D1 is now 0 for the + parent and 1 for the child. Decrement it to make it -1 (all + bits set) for the parent, and 0 (no bits set) for the child. + Then AND it with D0, so the parent gets D0&-1==R0, and the child + gets D0&0==0. */ + subql #1, d1 + andl d1, d0 + + /* Jump to the return PC. */ + jmp a0@ + +error: + movel d0, _errno + moveq #-1, d0 + jmp a0@ +libc_hidden_def (__vfork) + +weak_alias (__vfork, vfork) |