Added getcontext/setcontext. This has not been fully tested, but it seems to

work enough for binaries that use it (eg: telnet).
Problems:
- what should we do with uc_filler?
- how to handle FP regs?
This commit is contained in:
manu 2001-12-25 19:04:18 +00:00
parent 09638d7a55
commit ae9b01a907
15 changed files with 198 additions and 37 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_dirent.c,v 1.1 2001/12/23 20:15:03 manu Exp $ */
/* $NetBSD: irix_dirent.c,v 1.2 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.1 2001/12/23 20:15:03 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.2 2001/12/25 19:04:18 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.1 2001/12/23 20:15:03 manu Exp $")
#include <compat/common/compat_util.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscall.h>
#include <compat/irix/irix_syscallargs.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_fcntl.c,v 1.1 2001/12/25 16:40:48 manu Exp $ */
/* $NetBSD: irix_fcntl.c,v 1.2 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_fcntl.c,v 1.1 2001/12/25 16:40:48 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_fcntl.c,v 1.2 2001/12/25 19:04:18 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_fcntl.c,v 1.1 2001/12/25 16:40:48 manu Exp $");
#include <sys/syscallargs.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscallargs.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_mount.c,v 1.1 2001/12/22 14:43:44 manu Exp $ */
/* $NetBSD: irix_mount.c,v 1.2 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_mount.c,v 1.1 2001/12/22 14:43:44 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_mount.c,v 1.2 2001/12/25 19:04:18 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_mount.c,v 1.1 2001/12/22 14:43:44 manu Exp $");
#include <compat/common/compat_util.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscall.h>
#include <compat/irix/irix_syscallargs.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_prctl.c,v 1.3 2001/12/08 11:17:37 manu Exp $ */
/* $NetBSD: irix_prctl.c,v 1.4 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,10 +37,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.3 2001/12/08 11:17:37 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.4 2001/12/25 19:04:18 manu Exp $");
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/systm.h>
@ -48,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_prctl.c,v 1.3 2001/12/08 11:17:37 manu Exp $");
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_prctl.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscallargs.h>
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_signal.c,v 1.1 2001/12/08 11:17:37 manu Exp $ */
/* $NetBSD: irix_signal.c,v 1.2 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.1 2001/12/08 11:17:37 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_signal.c,v 1.2 2001/12/25 19:04:18 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@ -282,3 +282,97 @@ irix_sys_sginap(p, v, retval)
return 0;
}
/*
* XXX Untested. Expect bugs and security problems here
*/
int
irix_sys_getcontext(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct irix_sys_getcontext_args /* {
syscallarg(struct irix_ucontext *) ucp;
} */ *uap = v;
struct frame *f;
struct irix_ucontext kucp;
int i, error;
f = (struct frame *)p->p_md.md_regs;
kucp.iuc_flags = IRIX_UC_ALL;
kucp.iuc_link = NULL; /* XXX */
native_to_irix_sigset(&p->p_sigctx.ps_sigmask, &kucp.iuc_sigmask);
kucp.iuc_stack.ss_sp = p->p_sigctx.ps_sigstk.ss_sp;
kucp.iuc_stack.ss_size = p->p_sigctx.ps_sigstk.ss_size;
kucp.iuc_stack.ss_flags = 0;
if (p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK)
kucp.iuc_stack.ss_flags &= IRIX_SS_ONSTACK;
if (p->p_sigctx.ps_sigstk.ss_flags & SS_DISABLE)
kucp.iuc_stack.ss_flags &= IRIX_SS_DISABLE;
for (i = 0; i < 36; i++) /* Is order correct? */
kucp.iuc_mcontext.svr4___gregs[i] = f->f_regs[i];
for (i = 0; i < 32; i++)
kucp.iuc_mcontext.svr4___fpregs.svr4___fp_r.svr4___fp_regs[i]
= 0; /* XXX where are FP registers? */
for (i = 0; i < 47; i++)
kucp.iuc_filler[i] = 0; /* XXX */
kucp.iuc_triggersave = 0; /* XXX */
error = copyout(&kucp, SCARG(uap, ucp), sizeof(kucp));
return error;
}
/*
* XXX Untested. Expect bugs and security problems here
*/
int
irix_sys_setcontext(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct irix_sys_setcontext_args /* {
syscallarg(struct irix_ucontext *) ucp;
} */ *uap = v;
struct frame *f;
struct irix_ucontext kucp;
int i, error;
error = copyin(SCARG(uap, ucp), &kucp, sizeof(kucp));
if (error)
goto out;
f = (struct frame *)p->p_md.md_regs;
if (kucp.iuc_flags & IRIX_UC_SIGMASK)
irix_to_native_sigset(&kucp.iuc_sigmask,
&p->p_sigctx.ps_sigmask);
if (kucp.iuc_flags & IRIX_UC_STACK) {
p->p_sigctx.ps_sigstk.ss_sp = kucp.iuc_stack.ss_sp;
p->p_sigctx.ps_sigstk.ss_size =
(unsigned long)kucp.iuc_stack.ss_sp;
p->p_sigctx.ps_sigstk.ss_flags = 0;
if (kucp.iuc_stack.ss_flags & IRIX_SS_ONSTACK)
p->p_sigctx.ps_sigstk.ss_flags &= SS_ONSTACK;
if (kucp.iuc_stack.ss_flags & IRIX_SS_DISABLE)
p->p_sigctx.ps_sigstk.ss_flags &= SS_DISABLE;
}
if (kucp.iuc_flags & IRIX_UC_CPU)
for (i = 0; i < 36; i++) /* Is register order right? */
f->f_regs[i] = kucp.iuc_mcontext.svr4___gregs[i];
if (kucp.iuc_flags & IRIX_UC_MAU) { /* XXX */
#ifdef DEBUG_IRIX
printf("irix_sys_setcontext(): IRIX_UC_MAU requested\n");
#endif
}
out:
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_signal.h,v 1.1 2001/12/08 11:17:37 manu Exp $ */
/* $NetBSD: irix_signal.h,v 1.2 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -42,6 +42,8 @@
#include <sys/types.h>
#include <sys/signal.h>
#include <machine/svr4_machdep.h>
#include <compat/irix/irix_types.h>
/* From IRIX's <sys/signal.h> */
@ -70,6 +72,42 @@ struct irix_sigframe {
struct irix_sigcontext isf_sc;
};
#define IRIX_SS_ONSTACK 0x00000001
#define IRIX_SS_DISABLE 0x00000002
/* From IRIX's <sys/ucontext.h> */
#define IRIX_UC_SIGMASK 001
#define IRIX_UC_STACK 002
#define IRIX_UC_CPU 004
#define IRIX_UC_MAU 010
#define IRIX_UC_MCONTEXT (IRIX_UC_CPU|IRIX_UC_MAU)
#define IRIX_UC_ALL (IRIX_UC_SIGMASK|IRIX_UC_STACK|IRIX_UC_MCONTEXT)
#if 1 /* _MIPS_SZLONG == 32 */
typedef struct irix__sigaltstack {
void *ss_sp;
irix_size_t ss_size;
int ss_flags;
} irix_stack_t;
#endif
#if 0 /* _MIPS_SZLONG == 64 */
typedef struct irix__sigaltstack {
void *ss_sp;
__uint32_t ss_size;
int ss_flags;
} irix_stack_t;
#endif
typedef struct irix_ucontext {
unsigned long iuc_flags;
struct irix_ucontext *iuc_link;
irix_sigset_t iuc_sigmask;
irix_stack_t iuc_stack;
svr4_mcontext_t iuc_mcontext;
long iuc_filler[47];
int iuc_triggersave;
} irix_ucontext_t;
#ifdef _KERNEL
__BEGIN_DECLS
void native_to_irix_sigset __P((const sigset_t *, irix_sigset_t *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_stat.c,v 1.2 2001/12/22 12:09:20 manu Exp $ */
/* $NetBSD: irix_stat.c,v 1.3 2001/12/25 19:04:18 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.2 2001/12/22 12:09:20 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.3 2001/12/25 19:04:18 manu Exp $");
#include <sys/errno.h>
#include <sys/types.h>
@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.2 2001/12/22 12:09:20 manu Exp $");
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscall.h>
#include <compat/irix/irix_syscallargs.h>

View File

@ -1,10 +1,10 @@
/* $NetBSD: irix_syscall.h,v 1.14 2001/12/25 16:40:48 manu Exp $ */
/* $NetBSD: irix_syscall.h,v 1.15 2001/12/25 19:04:18 manu Exp $ */
/*
* System call numbers.
*
* DO NOT EDIT-- this file is automatically generated.
* created from NetBSD: syscalls.master,v 1.12 2001/12/23 20:57:30 manu Exp
* created from NetBSD: syscalls.master,v 1.13 2001/12/25 16:40:48 manu Exp
*/
/* syscall: "syscall" ret: "int" args: */
@ -209,6 +209,12 @@
/* syscall: "sigsuspend" ret: "int" args: "const svr4_sigset_t *" */
#define IRIX_SYS_sigsuspend 165
/* syscall: "getcontext" ret: "int" args: "irix_ucontext_t *" */
#define IRIX_SYS_getcontext 168
/* syscall: "setcontext" ret: "int" args: "const irix_ucontext_t *" */
#define IRIX_SYS_setcontext 169
/* syscall: "getmountid" ret: "int" args: "const char *" "irix_mountid_t *" */
#define IRIX_SYS_getmountid 203

View File

@ -1,10 +1,10 @@
/* $NetBSD: irix_syscallargs.h,v 1.14 2001/12/25 16:40:48 manu Exp $ */
/* $NetBSD: irix_syscallargs.h,v 1.15 2001/12/25 19:04:18 manu Exp $ */
/*
* System call argument lists.
*
* DO NOT EDIT-- this file is automatically generated.
* created from NetBSD: syscalls.master,v 1.12 2001/12/23 20:57:30 manu Exp
* created from NetBSD: syscalls.master,v 1.13 2001/12/25 16:40:48 manu Exp
*/
#ifndef _IRIX_SYS__SYSCALLARGS_H_
@ -246,6 +246,14 @@ struct svr4_sys_sigsuspend_args {
syscallarg(const svr4_sigset_t *) set;
};
struct irix_sys_getcontext_args {
syscallarg(irix_ucontext_t *) ucp;
};
struct irix_sys_setcontext_args {
syscallarg(const irix_ucontext_t *) ucp;
};
struct irix_sys_getmountid_args {
syscallarg(const char *) path;
syscallarg(irix_mountid_t *) buf;
@ -334,6 +342,8 @@ int svr4_sys_sigaction(struct proc *, void *, register_t *);
int svr4_sys_sigpending(struct proc *, void *, register_t *);
int svr4_sys_sigprocmask(struct proc *, void *, register_t *);
int svr4_sys_sigsuspend(struct proc *, void *, register_t *);
int irix_sys_getcontext(struct proc *, void *, register_t *);
int irix_sys_setcontext(struct proc *, void *, register_t *);
int irix_sys_getmountid(struct proc *, void *, register_t *);
int irix_sys_ngetdents(struct proc *, void *, register_t *);
#endif /* _IRIX_SYS__SYSCALLARGS_H_ */

View File

@ -1,14 +1,14 @@
/* $NetBSD: irix_syscalls.c,v 1.14 2001/12/25 16:40:48 manu Exp $ */
/* $NetBSD: irix_syscalls.c,v 1.15 2001/12/25 19:04:18 manu Exp $ */
/*
* System call names.
*
* DO NOT EDIT-- this file is automatically generated.
* created from NetBSD: syscalls.master,v 1.12 2001/12/23 20:57:30 manu Exp
* created from NetBSD: syscalls.master,v 1.13 2001/12/25 16:40:48 manu Exp
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_syscalls.c,v 1.14 2001/12/25 16:40:48 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_syscalls.c,v 1.15 2001/12/25 19:04:18 manu Exp $");
#if defined(_KERNEL_OPT)
#if defined(_KERNEL_OPT)
@ -24,6 +24,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_syscalls.c,v 1.14 2001/12/25 16:40:48 manu Exp
#include <sys/syscallargs.h>
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscallargs.h>
#endif /* _KERNEL_OPT */
@ -208,8 +209,8 @@ const char *const irix_syscallnames[] = {
"sigsuspend", /* 165 = sigsuspend */
"#166 (unimplemented sigpoll_sys)", /* 166 = unimplemented sigpoll_sys */
"#167 (unimplemented swapctl)", /* 167 = unimplemented swapctl */
"#168 (unimplemented getcontext)", /* 168 = unimplemented getcontext */
"#169 (unimplemented setcontext)", /* 169 = unimplemented setcontext */
"getcontext", /* 168 = getcontext */
"setcontext", /* 169 = setcontext */
"#170 (unimplemented waitsys)", /* 170 = unimplemented waitsys */
"#171 (unimplemented sigstack)", /* 171 = unimplemented sigstack */
"#172 (unimplemented sigaltstack)", /* 172 = unimplemented sigaltstack */

View File

@ -1,14 +1,14 @@
/* $NetBSD: irix_sysent.c,v 1.14 2001/12/25 16:40:48 manu Exp $ */
/* $NetBSD: irix_sysent.c,v 1.15 2001/12/25 19:04:19 manu Exp $ */
/*
* System call switch table.
*
* DO NOT EDIT-- this file is automatically generated.
* created from NetBSD: syscalls.master,v 1.12 2001/12/23 20:57:30 manu Exp
* created from NetBSD: syscalls.master,v 1.13 2001/12/25 16:40:48 manu Exp
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_sysent.c,v 1.14 2001/12/25 16:40:48 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_sysent.c,v 1.15 2001/12/25 19:04:19 manu Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ntp.h"
@ -23,6 +23,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_sysent.c,v 1.14 2001/12/25 16:40:48 manu Exp $"
#include <sys/syscallargs.h>
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscallargs.h>
#define s(type) sizeof(type)
@ -379,10 +380,10 @@ struct sysent irix_sysent[] = {
sys_nosys }, /* 166 = unimplemented sigpoll_sys */
{ 0, 0, 0,
sys_nosys }, /* 167 = unimplemented swapctl */
{ 0, 0, 0,
sys_nosys }, /* 168 = unimplemented getcontext */
{ 0, 0, 0,
sys_nosys }, /* 169 = unimplemented setcontext */
{ 1, s(struct irix_sys_getcontext_args), 0,
irix_sys_getcontext }, /* 168 = getcontext */
{ 1, s(struct irix_sys_setcontext_args), 0,
irix_sys_setcontext }, /* 169 = setcontext */
{ 0, 0, 0,
sys_nosys }, /* 170 = unimplemented waitsys */
{ 0, 0, 0,

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_sysmp.c,v 1.2 2001/12/08 11:17:37 manu Exp $ */
/* $NetBSD: irix_sysmp.c,v 1.3 2001/12/25 19:04:19 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_sysmp.c,v 1.2 2001/12/08 11:17:37 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_sysmp.c,v 1.3 2001/12/25 19:04:19 manu Exp $");
#include <sys/errno.h>
#include <sys/param.h>
@ -50,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_sysmp.c,v 1.2 2001/12/08 11:17:37 manu Exp $");
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_sysmp.h>
#include <compat/irix/irix_syscallargs.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_syssgi.c,v 1.8 2001/12/22 09:35:11 manu Exp $ */
/* $NetBSD: irix_syssgi.c,v 1.9 2001/12/25 19:04:19 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.8 2001/12/22 09:35:11 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.9 2001/12/25 19:04:19 manu Exp $");
#include "opt_ddb.h"
@ -67,6 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: irix_syssgi.c,v 1.8 2001/12/22 09:35:11 manu Exp $")
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscall.h>
#include <compat/irix/irix_syscallargs.h>
#include <compat/irix/irix_syssgi.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: irix_types.h,v 1.7 2001/12/23 20:15:04 manu Exp $ */
/* $NetBSD: irix_types.h,v 1.8 2001/12/25 19:04:19 manu Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -65,6 +65,7 @@ typedef long irix_gid_t;
typedef unsigned long irix_nlink_t;
typedef long irix_pid_t;
typedef long irix_time_t;
typedef unsigned int irix_size_t;
#endif
#if 0 /* _MIPS_SZLONG == 64 */
typedef __uint32_t irix_dev_t;
@ -74,6 +75,7 @@ typedef __int32_t irix_gid_t;
typedef __uint32_t irix_nlink_t;
typedef __int32_t irix_pid_t;
typedef int irix_time_t;
typedef unsigned long irix_size_t;
#endif
typedef __int64_t irix_blkcnt_t;
typedef __uint64_t irix_ino64_t;

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.13 2001/12/25 16:40:48 manu Exp $
$NetBSD: syscalls.master,v 1.14 2001/12/25 19:04:19 manu Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@ -47,6 +47,7 @@
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
#include <compat/irix/irix_signal.h>
#include <compat/irix/irix_syscallargs.h>
%%
@ -260,8 +261,8 @@
const svr4_sigset_t *set); }
166 UNIMPL sigpoll_sys
167 UNIMPL swapctl
168 UNIMPL getcontext
169 UNIMPL setcontext
168 STD { int irix_sys_getcontext(irix_ucontext_t *ucp); }
169 STD { int irix_sys_setcontext(const irix_ucontext_t *ucp); }
170 UNIMPL waitsys
171 UNIMPL sigstack
172 UNIMPL sigaltstack