mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 10:50:07 +00:00
entered into RCS
This commit is contained in:
parent
c4a19f6a24
commit
76657427f5
95
sysdeps/mach/hurd/mips/exc2signal.c
Normal file
95
sysdeps/mach/hurd/mips/exc2signal.c
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/* Translate Mach exception codes into signal numbers. MIPS version.
|
||||||
|
Copyright (C) 1991, 1992, 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <hurd.h>
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <mach/exception.h>
|
||||||
|
|
||||||
|
/* Translate the Mach exception codes, as received in an `exception_raise' RPC,
|
||||||
|
into a signal number and signal subcode. */
|
||||||
|
|
||||||
|
void
|
||||||
|
_hurd_exception2signal (int exception, int code, int subcode,
|
||||||
|
int *signo, int *sigcode)
|
||||||
|
{
|
||||||
|
switch (exception)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
*signo = SIGIOT;
|
||||||
|
*sigcode = exception;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_BAD_ACCESS:
|
||||||
|
if (code == KERN_PROTECTION_FAILURE)
|
||||||
|
*signo = SIGSEGV;
|
||||||
|
else
|
||||||
|
*signo = SIGBUS;
|
||||||
|
*sigcode = subcode;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_BAD_INSTRUCTION:
|
||||||
|
*signo = SIGILL;
|
||||||
|
if (code == EXC_MIPS_II)
|
||||||
|
*sigcode = code;
|
||||||
|
else
|
||||||
|
*sigcode = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_ARITHMETIC:
|
||||||
|
switch (code)
|
||||||
|
{
|
||||||
|
case EXC_MIPS_OV: /* integer overflow */
|
||||||
|
*signo = SIGFPE;
|
||||||
|
*sigcode = EXC_MIPS_FLT_OVERFLOW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
*signo = SIGFPE;
|
||||||
|
*sigcode = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_MIPS_INT:
|
||||||
|
/* Subcode is the fp_status word saved by the hardware.
|
||||||
|
Give an error code corresponding to the first bit set. */
|
||||||
|
if (subcode == EXC_MIPS_FLT_UNIMP)
|
||||||
|
*signo = SIGILL;
|
||||||
|
else
|
||||||
|
*signo = SIGFPE;
|
||||||
|
*sigcode = subcode;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_EMULATION:
|
||||||
|
/* 3.0 doesn't give this one, why, I don't know. */
|
||||||
|
*signo = SIGEMT;
|
||||||
|
*sigcode = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_SOFTWARE:
|
||||||
|
*signo = SIGEMT;
|
||||||
|
*sigcode = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EXC_BREAKPOINT:
|
||||||
|
*signo = SIGTRAP;
|
||||||
|
*sigcode = code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
41
sysdeps/mach/hurd/mips/init-fault.c
Normal file
41
sysdeps/mach/hurd/mips/init-fault.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* Set up a thread_state for proc_handle_exceptions. MIPS version.
|
||||||
|
Copyright (C) 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <mach/thread_status.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
|
extern jmp_buf _hurd_sigthread_fault_env;
|
||||||
|
|
||||||
|
static char fault_stack[32];
|
||||||
|
static volatile void
|
||||||
|
faulted (void)
|
||||||
|
{
|
||||||
|
__longjmp (_hurd_sigthread_fault_env, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_hurd_initialize_fault_recovery_state (void *state)
|
||||||
|
{
|
||||||
|
struct mips_thread_state *ts = state;
|
||||||
|
memset (ts, 0, sizeof (*ts));
|
||||||
|
ts->r29 = (int) &fault_stack[sizeof (fault_stack)];
|
||||||
|
ts->pc = (int) &faulted;
|
||||||
|
}
|
41
sysdeps/mach/hurd/mips/longjmp-ctx.c
Normal file
41
sysdeps/mach/hurd/mips/longjmp-ctx.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* Perform a `longjmp' on a `struct sigcontext'. MIPS version.
|
||||||
|
Copyright (C) 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_hurd_longjmp_sigcontext (struct sigcontext *scp, jmp_buf env, int retval)
|
||||||
|
{
|
||||||
|
scp->sc_gpr[16] = env[0].__regs[0];
|
||||||
|
scp->sc_gpr[17] = env[0].__regs[1];
|
||||||
|
scp->sc_gpr[18] = env[0].__regs[2];
|
||||||
|
scp->sc_gpr[19] = env[0].__regs[3];
|
||||||
|
scp->sc_gpr[20] = env[0].__regs[4];
|
||||||
|
scp->sc_gpr[21] = env[0].__regs[5];
|
||||||
|
scp->sc_gpr[22] = env[0].__regs[6];
|
||||||
|
scp->sc_gpr[23] = env[0].__regs[7];
|
||||||
|
|
||||||
|
scp->sc_gpr[28] = (int) env[0].__gp;
|
||||||
|
scp->sc_fp = (int) env[0].__fp;
|
||||||
|
scp->sc_sp = (int) env[0].__sp;
|
||||||
|
scp->sc_pc = (int) env[0].__pc;
|
||||||
|
scp->sc_gpr[2] = retval ?: 1;
|
||||||
|
}
|
45
sysdeps/mach/hurd/mips/longjmp-ts.c
Normal file
45
sysdeps/mach/hurd/mips/longjmp-ts.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* Perform a `longjmp' on a Mach thread_state. MIPS version.
|
||||||
|
Copyright (C) 1991, 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <mach/thread_status.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */
|
||||||
|
|
||||||
|
void
|
||||||
|
_hurd_longjmp_thread_state (void *state, jmp_buf env, int val)
|
||||||
|
{
|
||||||
|
struct mips_thread_state *ts = state;
|
||||||
|
|
||||||
|
ts->r16 = env[0].__regs[0];
|
||||||
|
ts->r17 = env[0].__regs[1];
|
||||||
|
ts->r18 = env[0].__regs[2];
|
||||||
|
ts->r19 = env[0].__regs[3];
|
||||||
|
ts->r20 = env[0].__regs[4];
|
||||||
|
ts->r21 = env[0].__regs[5];
|
||||||
|
ts->r22 = env[0].__regs[6];
|
||||||
|
ts->r23 = env[0].__regs[7];
|
||||||
|
ts->r28 = (int) env[0].__gp;
|
||||||
|
ts->r29 = (int) env[0].__sp;
|
||||||
|
ts->r30 = (int) env[0].__fp;
|
||||||
|
ts->pc = (int) env[0].__pc;
|
||||||
|
ts->r2 = val ?: 1;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
93
sysdeps/mach/hurd/mips/sigreturn.c
Normal file
93
sysdeps/mach/hurd/mips/sigreturn.c
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 1991, 1992, 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <hurd.h>
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <hurd/threadvar.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
__sigreturn (const struct sigcontext *scp)
|
||||||
|
{
|
||||||
|
struct hurd_sigstate *ss;
|
||||||
|
mach_port_t *reply_port;
|
||||||
|
|
||||||
|
if (scp == NULL)
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss = _hurd_self_sigstate ();
|
||||||
|
ss->blocked = scp->sc_mask;
|
||||||
|
ss->intr_port = scp->sc_intr_port;
|
||||||
|
if (scp->sc_onstack)
|
||||||
|
ss->sigaltstack.ss_flags &= ~SA_ONSTACK; /* XXX threadvars */
|
||||||
|
__mutex_unlock (&ss->lock);
|
||||||
|
|
||||||
|
/* Destroy the MiG reply port used by the signal handler, and restore the
|
||||||
|
reply port in use by the thread when interrupted. */
|
||||||
|
reply_port =
|
||||||
|
(mach_port_t *) __hurd_threadvar_location (_HURD_THREADVAR_MIG_REPLY);
|
||||||
|
if (*reply_port)
|
||||||
|
__mach_port_destroy (__mach_task_self (), *reply_port);
|
||||||
|
*reply_port = scp->sc_reply_port;
|
||||||
|
|
||||||
|
/* Restore registers. */
|
||||||
|
#define restore_gpr(n) \
|
||||||
|
asm volatile ("lw $" #n ",%0" : : "m"(at->sc_gpr[(n)]))
|
||||||
|
|
||||||
|
asm volatile (".set noreorder; .set noat;");
|
||||||
|
{
|
||||||
|
register const struct sigcontext *at asm ("$1") = scp;
|
||||||
|
|
||||||
|
restore_gpr(2);
|
||||||
|
restore_gpr(3);
|
||||||
|
restore_gpr(4);
|
||||||
|
restore_gpr(5);
|
||||||
|
restore_gpr(6);
|
||||||
|
restore_gpr(7);
|
||||||
|
restore_gpr(8);
|
||||||
|
restore_gpr(9);
|
||||||
|
restore_gpr(10);
|
||||||
|
restore_gpr(11);
|
||||||
|
restore_gpr(12);
|
||||||
|
restore_gpr(13);
|
||||||
|
restore_gpr(14);
|
||||||
|
restore_gpr(15);
|
||||||
|
restore_gpr(16);
|
||||||
|
restore_gpr(17);
|
||||||
|
restore_gpr(18);
|
||||||
|
restore_gpr(19);
|
||||||
|
restore_gpr(20);
|
||||||
|
restore_gpr(21);
|
||||||
|
restore_gpr(22);
|
||||||
|
restore_gpr(23);
|
||||||
|
restore_gpr(24);
|
||||||
|
restore_gpr(25);
|
||||||
|
restore_gpr(28);
|
||||||
|
asm volatile ("lw $29,%0" : : "m"(scp->sc_sp));
|
||||||
|
asm volatile ("lw $30,%0" : : "m"(scp->sc_fp));
|
||||||
|
asm volatile ("lw $31,%0" : : "m"(scp->sc_pc));
|
||||||
|
asm volatile ("j $31");
|
||||||
|
restore_gpr(1);
|
||||||
|
asm volatile (".set reorder; .set at;");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NOTREACHED */
|
||||||
|
return -1;
|
||||||
|
}
|
96
sysdeps/mach/hurd/mips/trampoline.c
Normal file
96
sysdeps/mach/hurd/mips/trampoline.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/* Set thread_state for sighandler, and sigcontext to recover. MIPS version.
|
||||||
|
Copyright (C) 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <mach/thread_status.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
trampoline (void (*handler) (int signo, int sigcode, struct sigcontext *scp),
|
||||||
|
int signo, int sigcode, struct sigcontext *scp)
|
||||||
|
{
|
||||||
|
(*handler) (signo, sigcode, scp);
|
||||||
|
(void) __sigreturn (scp); /* Does not return. */
|
||||||
|
while (1)
|
||||||
|
LOSE; /* Firewall. */
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sigcontext *
|
||||||
|
_hurd_setup_sighandler (int flags,
|
||||||
|
__sighandler_t handler,
|
||||||
|
struct sigaltstack *sigaltstack,
|
||||||
|
int signo, int sigcode,
|
||||||
|
void *state)
|
||||||
|
{
|
||||||
|
struct mips_thread_state *ts;
|
||||||
|
void *sigsp;
|
||||||
|
struct sigcontext *scp;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
void *retaddr; /* Never used. */
|
||||||
|
__sighandler_t handler;
|
||||||
|
int signo;
|
||||||
|
int sigcode;
|
||||||
|
struct sigcontext *scp; /* Points to ctx, below. */
|
||||||
|
struct sigcontext ctx;
|
||||||
|
} *stackframe;
|
||||||
|
|
||||||
|
ts = state;
|
||||||
|
|
||||||
|
if ((flags & SA_ONSTACK) &&
|
||||||
|
!(sigaltstack->ss_flags & (SA_DISABLE|SA_ONSTACK)))
|
||||||
|
{
|
||||||
|
sigsp = sigaltstack->ss_sp + sigaltstack->ss_size;
|
||||||
|
sigaltstack->ss_flags |= SA_ONSTACK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sigsp = (char *) ts->r29;
|
||||||
|
|
||||||
|
/* Push the arguments to call `trampoline' on the stack. */
|
||||||
|
sigsp -= sizeof (*stackframe);
|
||||||
|
stackframe = sigsp;
|
||||||
|
stackframe->handler = handler;
|
||||||
|
stackframe->signo = signo;
|
||||||
|
stackframe->sigcode = sigcode;
|
||||||
|
stackframe->scp = scp = &stackframe->ctx;
|
||||||
|
|
||||||
|
/* Set up the sigcontext from the current state of the thread. */
|
||||||
|
|
||||||
|
scp->sc_onstack = sigaltstack->ss_flags & SA_ONSTACK ? 1 : 0;
|
||||||
|
|
||||||
|
scp->sc_gpr[16] = ts->r16;
|
||||||
|
scp->sc_gpr[17] = ts->r17;
|
||||||
|
scp->sc_gpr[18] = ts->r18;
|
||||||
|
scp->sc_gpr[19] = ts->r19;
|
||||||
|
scp->sc_gpr[20] = ts->r20;
|
||||||
|
scp->sc_gpr[21] = ts->r21;
|
||||||
|
scp->sc_gpr[22] = ts->r22;
|
||||||
|
scp->sc_gpr[23] = ts->r23;
|
||||||
|
scp->sc_gpr[28] = ts->r28;
|
||||||
|
scp->sc_gpr[31] = ts->r31;
|
||||||
|
|
||||||
|
scp->sc_pc = ts->pc;
|
||||||
|
scp->sc_sp = ts->r29;
|
||||||
|
scp->sc_fp = ts->r30;
|
||||||
|
|
||||||
|
/* Modify the thread state to call `trampoline' on the new stack. */
|
||||||
|
ts->r29 = (int) sigsp;
|
||||||
|
ts->pc = (int) &trampoline;
|
||||||
|
|
||||||
|
return scp;
|
||||||
|
}
|
73
sysdeps/mach/mips/machine-lock.h
Normal file
73
sysdeps/mach/mips/machine-lock.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* Machine-specific definition for spin locks. MIPS version.
|
||||||
|
Copyright (C) 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#ifndef _MACHINE_LOCK_H
|
||||||
|
#define _MACHINE_LOCK_H
|
||||||
|
|
||||||
|
/* The type of a spin lock variable. */
|
||||||
|
|
||||||
|
typedef __volatile int __spin_lock_t;
|
||||||
|
|
||||||
|
/* Value to initialize `__spin_lock_t' variables to. */
|
||||||
|
|
||||||
|
#define __SPIN_LOCK_INITIALIZER 0
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _EXTERN_INLINE
|
||||||
|
#define _EXTERN_INLINE extern __inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Unlock LOCK. */
|
||||||
|
|
||||||
|
_EXTERN_INLINE void
|
||||||
|
__spin_unlock (__spin_lock_t *__lock)
|
||||||
|
{
|
||||||
|
*__lock = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
|
||||||
|
|
||||||
|
_EXTERN_INLINE int
|
||||||
|
__spin_try_lock (register __spin_lock_t *__lock)
|
||||||
|
{
|
||||||
|
register int __rtn;
|
||||||
|
__asm__ __volatile (".set noreorder");
|
||||||
|
#if 0
|
||||||
|
__asm__ __volatile ("lw %0,0(%1)": "=r" (__rtn) : "r" (__lock));
|
||||||
|
__asm__ __volatile ("sw %0,0(%0)": : "r" (__lock));
|
||||||
|
__asm__ __volatile ("xor %0,%1,%0": "=r" (__rtn) : "r" (__lock));
|
||||||
|
#else
|
||||||
|
/* Use the Mach microkernel's emulated TAS pseudo-instruction. */
|
||||||
|
register int __rtn __asm__ ("a0");
|
||||||
|
__asm__ __volatile (".word 0xf ! %0 " : "=r" (__rtn) : "0" (__lock));
|
||||||
|
#endif
|
||||||
|
__asm__ __volatile (".set reorder");
|
||||||
|
return __rtn ^ (int) __lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return nonzero if LOCK is locked. */
|
||||||
|
|
||||||
|
_EXTERN_INLINE int
|
||||||
|
__spin_lock_locked (__spin_lock_t *__lock)
|
||||||
|
{
|
||||||
|
return *__lock != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* machine-lock.h */
|
38
sysdeps/mach/mips/machine-sp.h
Normal file
38
sysdeps/mach/mips/machine-sp.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* Machine-specific function to return the stack pointer. MIPS version.
|
||||||
|
Copyright (C) 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#ifndef _MACHINE_SP_H
|
||||||
|
#define _MACHINE_SP_H
|
||||||
|
|
||||||
|
/* Return the current stack pointer. */
|
||||||
|
|
||||||
|
#ifndef _EXTERN_INLINE
|
||||||
|
#define _EXTERN_INLINE extern __inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_EXTERN_INLINE void *
|
||||||
|
__thread_stack_pointer (void)
|
||||||
|
{
|
||||||
|
void *__sp__;
|
||||||
|
__asm__ ("move %0,$29" : "=r" (__sp__));
|
||||||
|
return __sp__;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* machine-sp.h */
|
||||||
|
|
69
sysdeps/mach/mips/sysdep.h
Normal file
69
sysdeps/mach/mips/sysdep.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* Copyright (C) 1991, 1992, 1993, 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#define MOVE(x,y) move y , x
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define LOSE asm volatile ("1: b 1b")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SNARF_ARGS(argc, argv, envp) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
int *entry_sp; \
|
||||||
|
register char **p; \
|
||||||
|
\
|
||||||
|
asm ("addu %0,$30,4" : "=r" (entry_sp)); \
|
||||||
|
\
|
||||||
|
argc = *entry_sp; \
|
||||||
|
argv = (char **) (entry_sp + 1); \
|
||||||
|
p = argv; \
|
||||||
|
while (*p++ != NULL) \
|
||||||
|
; \
|
||||||
|
if (p >= (char **) argv[0]) \
|
||||||
|
--p; \
|
||||||
|
envp = p; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define CALL_WITH_SP(fn, sp) \
|
||||||
|
({ register int __fn = fn, __sp = (int) sp; \
|
||||||
|
asm volatile ("move $sp,%0; j %1" : : "r" (__sp), "r" (__fn));})
|
||||||
|
|
||||||
|
#define STACK_GROWTH_DOWN
|
||||||
|
|
||||||
|
#ifdef P40
|
||||||
|
#include <syscall.h>
|
||||||
|
|
||||||
|
#define SYSCALL(name, args) \
|
||||||
|
.globl syscall_error; \
|
||||||
|
kernel_trap(name,SYS_##name,args); \
|
||||||
|
beq $1,$0,1f; \
|
||||||
|
j syscall_error; \
|
||||||
|
1:
|
||||||
|
|
||||||
|
#define SYSCALL__(name, args) \
|
||||||
|
.globl syscall_error; \
|
||||||
|
kernel_trap(__##name,SYS_##name,args); \
|
||||||
|
beq $1,$0,1f; \
|
||||||
|
j syscall_error; \
|
||||||
|
1:
|
||||||
|
|
||||||
|
#define ret j ra; nop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include_next <sysdep.h>
|
30
sysdeps/mach/mips/thread_state.h
Normal file
30
sysdeps/mach/mips/thread_state.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* Mach thread state definitions for machine-independent code. MIPS version.
|
||||||
|
Copyright (C) 1994 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
/* Everything else is called `thread_state', but CMU's header file is
|
||||||
|
called `thread_status'. Oh boy. */
|
||||||
|
#include <mach/thread_status.h>
|
||||||
|
|
||||||
|
#define MACHINE_THREAD_STATE_FLAVOR MIPS_THREAD_STATE
|
||||||
|
#define MACHINE_THREAD_STATE_COUNT MIPS_THREAD_STATE_COUNT
|
||||||
|
|
||||||
|
#define machine_thread_state mips_thread_state
|
||||||
|
|
||||||
|
#define PC pc
|
||||||
|
#define SP r29
|
Loading…
Reference in New Issue
Block a user