diff options
author | cherry <cherry> | 2011-07-27 10:23:48 +0000 |
---|---|---|
committer | cherry <cherry> | 2011-07-27 10:23:48 +0000 |
commit | 5e9b1e1622d9813c9d85621a3c1aec274016daa5 (patch) | |
tree | eca2ffa7ff162dbab8bcb5803fa6b75d9bb1e54d /emulators/ski | |
parent | 3ea80a1400ec0da72b664728e5a363f071318573 (diff) | |
download | pkgsrc-5e9b1e1622d9813c9d85621a3c1aec274016daa5.tar.gz |
import wip/ski
Diffstat (limited to 'emulators/ski')
-rw-r--r-- | emulators/ski/patches/patch-aa | 37 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ab | 13 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ac | 13 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ad | 53 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ae | 52 | ||||
-rw-r--r-- | emulators/ski/patches/patch-af | 145 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ag | 47 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ah | 45 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ai | 60 | ||||
-rw-r--r-- | emulators/ski/patches/patch-aj | 125 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ak | 238 | ||||
-rw-r--r-- | emulators/ski/patches/patch-al | 176 | ||||
-rw-r--r-- | emulators/ski/patches/patch-am | 51 | ||||
-rw-r--r-- | emulators/ski/patches/patch-an | 468 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ao | 667 | ||||
-rw-r--r-- | emulators/ski/patches/patch-ap | 149 |
16 files changed, 2339 insertions, 0 deletions
diff --git a/emulators/ski/patches/patch-aa b/emulators/ski/patches/patch-aa new file mode 100644 index 00000000000..3f4c1c170cd --- /dev/null +++ b/emulators/ski/patches/patch-aa @@ -0,0 +1,37 @@ +$NetBSD: patch-aa,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/dos.c.orig 2008-02-05 04:11:38.000000000 +0000 ++++ src/dos.c +@@ -26,14 +26,14 @@ + #include <errno.h> + #include <fcntl.h> + #include <sys/ioctl.h> +-#if !defined(__FreeBSD__) ++#if !defined(__FreeBSD__) && !defined(__NetBSD__) + #include <syscall.h> + #endif + #include <sys/times.h> + #include <sys/stat.h> + #include <signal.h> + #include <string.h> +-#if defined(__FreeBSD__) ++#if defined(__FreeBSD__) || defined(__NetBSD__) + #include <termios.h> + #define termio termios + #define TCGETA TIOCGETA +@@ -44,12 +44,14 @@ + #include <time.h> + #if defined __linux__ + # include <sys/time.h> ++#elif defined(__NetBSD__) ++# include <time.h> + #else /* !defined __linux */ + extern int localtime_r(const __time_t *, __struct_tm *); + # include <ulimit.h> + #endif /* !defined __linux */ + #include <unistd.h> /* Also #includes <utime.h> */ +-#if !defined(__FreeBSD__) ++#if !defined(__FreeBSD__) && !defined(__NetBSD__) + #include <ustat.h> + #endif + #include <sys/utsname.h> diff --git a/emulators/ski/patches/patch-ab b/emulators/ski/patches/patch-ab new file mode 100644 index 00000000000..b5e3c0339f8 --- /dev/null +++ b/emulators/ski/patches/patch-ab @@ -0,0 +1,13 @@ +$NetBSD: patch-ab,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/load.c.orig 2008-02-05 04:11:38.000000000 +0000 ++++ src/load.c +@@ -106,7 +106,7 @@ LMINFO lminfo[MAX_LOAD_MODULES]; + + #include <sys/mman.h> + #include <sys/param.h> +-#if !defined __linux__ ++#if !defined __linux__ && !defined(__NetBSD__) + #include <sys/pstat.h> + #endif /* !defined __linux__ */ + #include <sys/unistd.h> diff --git a/emulators/ski/patches/patch-ac b/emulators/ski/patches/patch-ac new file mode 100644 index 00000000000..52f6aa85216 --- /dev/null +++ b/emulators/ski/patches/patch-ac @@ -0,0 +1,13 @@ +$NetBSD: patch-ac,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/sim.c.orig 2008-02-05 04:11:38.000000000 +0000 ++++ src/sim.c +@@ -29,7 +29,7 @@ + #include <ltdl.h> + + /* XXX should list systems that need the header */ +-#if !defined(linux) && !defined HPUX9 && !defined(__FreeBSD__) ++#if !defined(linux) && !defined HPUX9 && !defined(__FreeBSD__) && !defined(__NetBSD__) + #include <dl.h> + #endif + #ifdef NEW_MP diff --git a/emulators/ski/patches/patch-ad b/emulators/ski/patches/patch-ad new file mode 100644 index 00000000000..887630f534f --- /dev/null +++ b/emulators/ski/patches/patch-ad @@ -0,0 +1,53 @@ +$NetBSD: patch-ad,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/Makefile.am.orig 2008-02-05 04:11:38.000000000 +0000 ++++ src/Makefile.am +@@ -130,7 +130,7 @@ if LINUX + ski_LDFLAGS = + endif + +-ski_LDADD= libski.la -ldl ++ski_LDADD= libski.la + + skiincludedir= $(includedir)/ski-$(SKI_MAJOR_VERSION).$(SKI_MINOR_VERSION) + skiinclude_HEADERS= \ +@@ -226,6 +226,23 @@ else + freebsd_FILES = + endif + ++EXTRA_netbsd_FILES= \ ++ netbsd/convert-netbsd.c \ ++ netbsd/dwarf-netbsd.c \ ++ netbsd/firmware-netbsd.c \ ++ netbsd/machdep-netbsd.h \ ++ netbsd/misc-netbsd.c \ ++ netbsd/osload-netbsd.c \ ++ netbsd/signal-netbsd.c \ ++ netbsd/ssc-netbsd.c \ ++ netbsd/syscall-netbsd.c \ ++ netbsd/syscall-netbsd.h ++ ++if NETBSD ++netbsd_FILES = $(EXTRA_netbsd_FILES) ++else ++netbsd_FILES = ++endif + libski_la_SOURCES= \ + $(COMBFNS_DERIVED) \ + $(PREDECODE_DERIVED) \ +@@ -252,6 +269,7 @@ libski_la_SOURCES= \ + $(linux_FILES) \ + $(hpux_FILES) \ + $(freebsd_FILES) \ ++ $(netbsd_FILES) \ + libsym.c \ + $(ASM_HASH_DERIVED) \ + $(IADAS_DECODER_DERIVED) \ +@@ -288,6 +306,7 @@ EXTRA_libski_la_SOURCES = \ + $(EXTRA_linux_FILES) \ + $(EXTRA_hpux_FILES) \ + $(EXTRA_freebsd_FILES) \ ++ $(EXTRA_netbsd_FILES) \ + netdev.c + + libski_la_LDFLAGS = \ diff --git a/emulators/ski/patches/patch-ae b/emulators/ski/patches/patch-ae new file mode 100644 index 00000000000..de9faed1442 --- /dev/null +++ b/emulators/ski/patches/patch-ae @@ -0,0 +1,52 @@ +$NetBSD: patch-ae,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- configure.ac.orig 2008-02-05 09:41:37.000000000 +0530 ++++ configure.ac +@@ -33,12 +33,14 @@ case $host_os in + linux*) HOST_OS=linux;; + hpux*) HOST_OS=hpux;; + freebsd*) HOST_OS=freebsd;; ++ netbsd*) HOST_OS=netbsd;; + *) HOST_OS=unknown;; + esac + AC_SUBST(HOST_OS) + AM_CONDITIONAL(LINUX, test "$HOST_OS" = linux) + AM_CONDITIONAL(HPUX, test "$HOST_OS" = hpux) + AM_CONDITIONAL(FREEBSD, test "$HOST_OS" = freebsd) ++AM_CONDITIONAL(NETBSD, test "$HOST_OS" = netbsd) + + # Version number definitions + # +@@ -259,6 +261,10 @@ if test "$HOST_OS" = freebsd; then + LDFLAGS="$LDFLAGS -lutil" + fi + ++if test "$HOST_OS" = netbsd; then ++ LDFLAGS="$LDFLAGS -lutil" ++fi ++ + dnl Check for optional libs + AC_CHECK_LIB(unwind-ia64, _Uia64_get_proc_name, ) + +@@ -331,6 +337,13 @@ if test "$HOST_OS" = hpux; then + check_curses=no], []) + fi + ++if test "$HOST_OS" = netbsd; then ++ # Not ported to NetBSD curses yet. ++ AC_SEARCH_LIBS(tgetent, ncurses, ++ [check_curses=no], ++ [AC_MSG_ERROR(Required ncurses library not found.)]) ++fi ++ + if test "x$check_curses" != xno; then + AC_CHECK_LIB(curses, tgetent, [], + [AC_CHECK_LIB(ncurses, tgetent, , +@@ -347,6 +360,7 @@ case $host_os in + hpux10*) CFLAGS="$CFLAGS -DHPUX1020";; + hpux11*) CFLAGS="$CFLAGS -DHPUX1100";; + freebsd*) CFLAGS="$CFLAGS -DFREEBSD -D__linux__";; ++ netbsd*) CFLAGS="$CFLAGS -DNETBSD -D__linux__";; + esac + + dnl Add extra flags to CFLAGS depending on compiler diff --git a/emulators/ski/patches/patch-af b/emulators/ski/patches/patch-af new file mode 100644 index 00000000000..7103decab60 --- /dev/null +++ b/emulators/ski/patches/patch-af @@ -0,0 +1,145 @@ +$NetBSD: patch-af,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/netbsd/convert-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/convert-netbsd.c +@@ -0,0 +1,140 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include <sys/types.h> ++#include <sys/param.h> ++#include <sys/stat.h> ++#include <sys/time.h> ++#include <sys/mount.h> ++#include <sys/resource.h> ++#include <string.h> ++ ++#include "netbsd/syscall-netbsd.h" ++ ++void ntos_itimerval(const struct itimerval *it, struct itimerval64 *it64) ++{ ++ ntos_timeval(&it->it_interval, &it64->it_interval); ++ ntos_timeval(&it->it_value, &it64->it_value); ++} ++ ++void ntos_rusage(const struct rusage *ru, struct rusage64 *ru64) ++{ ++ ntos_timeval(&ru->ru_utime, &ru64->ru_utime); ++ ntos_timeval(&ru->ru_stime, &ru64->ru_stime); ++ ru64->ru_maxrss = ru->ru_maxrss; ++ ru64->ru_ixrss = ru->ru_ixrss; ++ ru64->ru_idrss = ru->ru_idrss; ++ ru64->ru_isrss = ru->ru_isrss; ++ ru64->ru_minflt = ru->ru_minflt; ++ ru64->ru_majflt = ru->ru_majflt; ++ ru64->ru_nswap = ru->ru_nswap; ++ ru64->ru_inblock = ru->ru_inblock; ++ ru64->ru_oublock = ru->ru_oublock; ++ ru64->ru_msgsnd = ru->ru_msgsnd; ++ ru64->ru_msgrcv = ru->ru_msgrcv; ++ ru64->ru_nsignals = ru->ru_nsignals; ++ ru64->ru_nvcsw = ru->ru_nvcsw; ++ ru64->ru_nivcsw = ru->ru_nivcsw; ++} ++ ++/* Assume we're on POSIX, so we're rather portable */ ++void ntos_stat(const struct stat *st, struct stat64 *st64) ++{ ++ st64->st_dev = st->st_dev; ++ st64->st_ino = st->st_ino; ++ st64->st_mode = st->st_mode; ++ st64->st_nlink = st->st_nlink; ++ st64->st_uid = st->st_uid; ++ st64->st_gid = st->st_gid; ++ st64->st_rdev = st->st_rdev; ++ st64->st_size = st->st_size; ++ ++#if defined(_NETBSD_SOURCE) ++ ntos_timespec(&st->st_atimespec, &st64->st_atimespec); ++ ntos_timespec(&st->st_mtimespec, &st64->st_mtimespec); ++ ntos_timespec(&st->st_ctimespec, &st64->st_ctimespec); ++ ntos_timespec(&st->st_birthtimespec, &st64->st_birthtimespec); ++#else ++ st64->st_atime = st->st_atime; ++ st64->st_atimensec = 0; ++ st64->st_mtime = st->st_mtime; ++ st64->st_mtimensec = 0; ++ st64->st_ctime = st->st_ctime; ++ st64->st_ctimensec = 0; ++#endif ++ ++ st64->st_blksize = st->st_blksize; ++ st64->st_blocks = st->st_blocks; ++} ++ ++void ntos_statvfs(const struct statvfs *f, struct statvfs64 *f64) ++{ ++ f64->f_bsize = f->f_bsize; ++ f64->f_frsize = f->f_frsize; ++ f64->f_blocks = f->f_blocks; ++ f64->f_bfree = f->f_bfree; ++ f64->f_bavail = f->f_bavail; ++ f64->f_files = f->f_files; ++ f64->f_ffree = f->f_ffree; ++ f64->f_favail = f->f_favail; ++ f64->f_fsid = f->f_fsid; ++ f64->f_flag = f->f_flag; ++ f64->f_namemax = f->f_namemax; ++ ++ ++#if defined(_NETBSD_SOURCE) ++ /* NetBSD specific fields */ ++ ++ f64->f_owner = f->f_owner; ++ ++ memcpy(f64->f_fstypename, f->f_fstypename, VFS_NAMELEN); ++ ++ f64->f_syncwrites = f->f_syncwrites; ++ f64->f_asyncwrites = f->f_asyncwrites; ++ memcpy(f64->f_fstypename, f->f_fstypename, VFS_NAMELEN); ++ memcpy(f64->f_mntonname, f->f_mntonname, VFS_MNAMELEN); ++ f64->f_syncreads = f->f_syncreads; ++ f64->f_asyncreads = f->f_asyncreads; ++ memcpy(f64->f_mntfromname, f->f_mntfromname, VFS_MNAMELEN); ++#endif ++} ++ ++void ntos_timespec(const struct timespec * tv, struct timespec64 *tv64) ++{ ++ tv64->tv_sec = tv->tv_sec; ++ tv64->tv_nsec = tv->tv_nsec; ++} ++ ++void ntos_timeval(const struct timeval *tv, struct timeval64 *tv64) ++{ ++ tv64->tv_sec = tv->tv_sec; ++ tv64->tv_usec = tv->tv_usec; ++} ++ ++void ston_itimerval(const struct itimerval64 *it64, struct itimerval *it) ++{ ++ ston_timeval(&it64->it_interval, &it->it_interval); ++ ston_timeval(&it64->it_value, &it->it_value); ++} ++ ++void ston_timeval(const struct timeval64 *tv64, struct timeval *tv) ++{ ++ tv->tv_sec = tv64->tv_sec; ++ tv->tv_usec = tv64->tv_usec; ++} diff --git a/emulators/ski/patches/patch-ag b/emulators/ski/patches/patch-ag new file mode 100644 index 00000000000..30601dc3004 --- /dev/null +++ b/emulators/ski/patches/patch-ag @@ -0,0 +1,47 @@ +$NetBSD: patch-ag,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/netbsd/dwarf-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/dwarf-netbsd.c +@@ -0,0 +1,42 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include "types.h" ++ ++char *src_root; /* hold the prefix for all filenames */ ++ ++char * ++getSrcLines(ADDR offset, unsigned int *count) ++{ ++ ++ *count = 0; ++ return (""); ++} ++ ++char * ++getSrcName(ADDR offset) ++{ ++ ++ return (""); ++} ++ ++void ++initDwUnitTbl(int fd) ++{ ++} diff --git a/emulators/ski/patches/patch-ah b/emulators/ski/patches/patch-ah new file mode 100644 index 00000000000..f50f1db37ab --- /dev/null +++ b/emulators/ski/patches/patch-ah @@ -0,0 +1,45 @@ +$NetBSD: patch-ah,v 1.1.1.1 2011/07/27 10:23:48 cherry Exp $ + +--- src/netbsd/firmware-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/firmware-netbsd.c +@@ -0,0 +1,40 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include <sys/time.h> ++#include <assert.h> ++#include <errno.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <unistd.h> ++ ++#include "std.h" ++#include "types.h" ++#include "state.h" ++#include "sim.h" ++ ++#include "netbsd/machdep-netbsd.h" ++ ++WORD pciBar[6] = {0xFFFFE001, 0xFFFFE000, 0xFFFFE000}; ++ ++REG doFW(REG imm, REG arg0, REG arg1, REG arg2, REG arg3) ++{ ++ ++ progStop("bad FW call\n"); ++} diff --git a/emulators/ski/patches/patch-ai b/emulators/ski/patches/patch-ai new file mode 100644 index 00000000000..6121b1fba1f --- /dev/null +++ b/emulators/ski/patches/patch-ai @@ -0,0 +1,60 @@ +$NetBSD: patch-ai,v 1.1.1.1 2011/07/27 10:23:49 cherry Exp $ + +--- src/netbsd/machdep-netbsd.h.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/machdep-netbsd.h +@@ -0,0 +1,55 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++#ifndef _SKI_MACHDEP_H ++#define _SKI_MACHDEP_H ++ ++#define SKI_NFDS 20 ++ ++typedef struct { ++ ADDR addr; ++ WORD len; ++} SscDiskReq; ++ ++typedef struct { ++ int fd; ++ WORD count; ++} SscDiskStat; ++ ++typedef struct { ++ WORD year; ++ WORD mon; ++ WORD mday; ++ WORD hour; ++ WORD min; ++ WORD sec; ++ WORD msec; ++ WORD wday; ++} SscTime; ++ ++typedef struct { ++ WORD ssc_Sec; ++ WORD ssc_Usec; ++} SscTimeval; ++ ++typedef struct { ++ WORD ssc_Minuteswest; ++ WORD ssc_Dsttime; ++} SscTimezone; ++ ++#endif /* _SKI_MACHDEP_H */ diff --git a/emulators/ski/patches/patch-aj b/emulators/ski/patches/patch-aj new file mode 100644 index 00000000000..4a6f2e5ec37 --- /dev/null +++ b/emulators/ski/patches/patch-aj @@ -0,0 +1,125 @@ +$NetBSD: patch-aj,v 1.1.1.1 2011/07/27 10:23:49 cherry Exp $ + +--- src/netbsd/misc-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/misc-netbsd.c +@@ -0,0 +1,120 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include <sys/time.h> ++#include <assert.h> ++#include <errno.h> ++#include <stdio.h> ++#include <stdlib.h> ++#include <unistd.h> ++ ++#include "std.h" ++#include "types.h" ++#include "state.h" ++ ++#include "netbsd/machdep-netbsd.h" ++ ++int _close(int); ++int _open(const char *, int, int); ++ ++CTR prof_insts = ~0ULL; ++char *src_root; ++ ++#define SKI_NFDS 20 ++int fdlimit; ++int fdmap[SKI_NFDS]; ++ ++void setFdmap(int fd1, int fd2) ++{ ++ assert(0); ++} ++ ++void profCnt(void) ++{ ++ assert(0); ++} ++ ++void saveOpenFiles(FILE *f) ++{ ++} ++ ++void restoreOpenFile(char *name, unsigned flag, unsigned mode, unsigned offset) ++{ ++} ++ ++/* ++ * We use our own implementation of open to force file descriptors ++ * opened by ski for ski to be larger than what we allow for the ++ * simulated process. This avoids nasty mappings... ++ */ ++int open(const char *path, int flags, int mode) ++{ ++ int res, fd; ++ ++ if (!unixABI) ++ return (_open(path, flags, mode)); ++ ++ if (fdlimit == 0) { ++ fdlimit = getdtablesize() - SKI_NFDS; ++ if (fdlimit < 20) { ++ fprintf(stderr, "FD table size underflow\n"); ++ abort(); ++ } ++ dup2(0, fdlimit); ++ dup2(1, fdlimit + 1); ++ dup2(2, fdlimit + 2); ++ fdmap[0] = fdmap[1] = fdmap[2] = 1; ++ /* XXX we shouldn't go under the hood */ ++ stdin->_file += fdlimit; ++ stdout->_file += fdlimit; ++ stderr->_file += fdlimit; ++ } ++ ++ res = _open(path, flags, mode); ++ if (res >= fdlimit) { ++ _close(res); ++ errno = EMFILE; ++ return (-1); ++ } else if (res == -1) ++ return (res); ++ ++ fd = 0; ++ while (fd < SKI_NFDS && fdmap[fd]) ++ fd++; ++ if (fd == SKI_NFDS) { ++ _close(res); ++ errno = EMFILE; ++ return (-1); ++ } ++ if (dup2(res, fd + fdlimit) == -1) { ++ _close(res); ++ errno = EMFILE; ++ return (-1); ++ } ++ _close(res); ++ fdmap[fd] = 1; ++ return (fd + fdlimit); ++} ++ ++int close(int fd) ++{ ++ if (fd >= fdlimit && fdlimit != 0) ++ fdmap[fd - fdlimit] = 0; ++ _close(fd); ++} diff --git a/emulators/ski/patches/patch-ak b/emulators/ski/patches/patch-ak new file mode 100644 index 00000000000..ea02f3aebe3 --- /dev/null +++ b/emulators/ski/patches/patch-ak @@ -0,0 +1,238 @@ +$NetBSD: patch-ak,v 1.1.1.1 2011/07/27 10:23:49 cherry Exp $ + +--- src/netbsd/osload-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/osload-netbsd.c +@@ -0,0 +1,233 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include <string.h> ++ ++#include <sys/types.h> ++#include <sys/exec_elf.h> ++ ++#include <sys/exec.h> ++ ++#include "std.h" ++#include "types.h" ++#include "osload.h" ++#include "state.h" ++#include "fields.h" ++#include "libcore.h" ++#include "sim.h" ++#include "simmem.h" ++ ++extern char **environ; ++ ++int ++os_elf32_abi(char *ident, Elf32_Ehdr *ehdr, int set) ++{ ++ /* No ILP32. */ ++ return (0); ++} ++ ++int ++os_elf64_abi(char *ident, Elf64_Ehdr *ehdr, int set) ++{ ++ int region; ++ BOOL abi; ++ ++ if (ident[EI_OSABI] != ELFOSABI_SYSV) ++ return (0); ++ ++ region = ehdr->e_entry >> 61; ++ abi = (ehdr->e_type == ET_DYN || (region > 0 && region < 5)) ++ ? YES : NO; ++ if (set) ++ unixABI = abi; ++ else if (unixABI != abi) ++ return (0); ++ ++ return (1); ++} ++ ++ADDR ++os_rtld32_text(Elf32_Phdr *phdr) ++{ ++ /* No ILP32. */ ++ return (0); ++} ++ ++ADDR ++os_rtld32_data(Elf32_Phdr *phdr) ++{ ++ /* No ILP32. */ ++ return (0); ++} ++ ++ADDR ++os_rtld64_text(Elf64_Phdr *phdr) ++{ ++ return (0x2000000000000000ULL); ++} ++ ++ADDR ++os_rtld64_data(Elf64_Phdr *phdr) ++{ ++ return (os_rtld64_text(phdr) + phdr->p_vaddr); ++} ++ ++/* ++ * Initial stack layout: ++ * USRSTACK +------------------------+ ++ * | struct ps_strings | ++ * PS_STRINGS +------------------------+ ++ * | signal trampoline code | ++ * +------------------------+ ++ * | SPARE_USRSPACE | ++ * +------------------------+ ++ * | arg & env strings | ++ * +------------------------+ ++ * | AUX entries | ++ * +------------------------+ ++ * | environ[envc + 1] | ++ * +------------------------+ ++ * | argv[argc + 1] | ++ * +------------------------+ ++ * | argc | ++ * SP +------------------------+ ++ * ++ * AUX entries required by rtld: ++ * AT_BASE ++ * AT_ENTRY ++ * AT_PHDR ++ * AT_PHENT ++ * AT_PHNUM ++ */ ++struct ia64_ps_strings { ++ uint64_t ps_argvstr; /* VA of first argument string. */ ++ int ps_nargvstr; /* Number of argument strings. */ ++ int ps_pad0; ++ uint64_t ps_envstr; /* VA of first environment string. */ ++ int ps_nenvstr; /* Number of environment strings. */ ++ int ps_pad1; ++}; ++ ++#define AUX(sp, tag, ptr) \ ++ do { \ ++ (void)memWrt8(sp, tag); \ ++ (void)memWrt8(sp + 8, ptr); \ ++ sp += 16; \ ++ } while (0) ++ ++int ++os_setup_process(const char *file_name, int argc, char *argv[], ++ struct os_proc *proc) ++{ ++ struct ia64_ps_strings ps_strings; ++ ADDR sp, strings, strp; ++ size_t argsz, envsz, strsz; ++ int envc, i; ++ ++ /* Initialize FP state (architected default value). */ ++ arSet(0, FPSR_ID, 0x0009804c0270033fULL); ++ ++ sp = 0xA000000000000000ULL; ++ sp -= 1048576; /* 1MB gateway page for EPC support. */ ++ setMaxSP(sp); /* =USRSTACK */ ++ ++ sp -= sizeof(ps_strings); ++ strings = sp; /* =PS_STRINGS */ ++ ++ /* XXX no signal trampoline code. */ ++ ++// XXX: sp -= SPARE_USRSPACE; ++ ++ argsz = 0; ++ for (i = 0; i < argc; i++) ++ argsz += strlen(argv[i]) + 1; ++ envsz = 0; ++ for (envc = 0; environ[envc]; envc++) ++ envsz += strlen(environ[envc]) + 1; ++ sp -= (argsz + envsz + 7) & ~7; ++ strp = sp; ++ ++ if (proc->has_rtld) ++ sp -= 6 * 16; /* AUX entries */ ++ ++ sp -= (envc + 1) * 8; /* envp[] */ ++ ps_strings.ps_envstr = sp; ++ ps_strings.ps_nenvstr = envc; ++ sp -= (argc + 1) * 8; /* argv[] */ ++ ps_strings.ps_argvstr = sp; ++ ps_strings.ps_nargvstr = argc; ++ ++ sp -= 8; /* argc */ ++ ++ grSet(0, 32, sp); ++ grSet(0, 33, strings); ++ grSet(0, 34, 0); ++ ++ sp &= ~15; ++ grSet(0, SP_ID, sp - 16); ++ ++ /* Map all pages. */ ++ sp = page_base(sp); ++ do { ++ pmemLookup_p(sp); ++ sp += page_size; ++ } while (sp < getMaxSP()); ++ ++ /* Copy out arguments. */ ++ sp = ps_strings.ps_argvstr; ++ memWrt8(sp - 8, argc); ++ for (i = 0; i < argc; i++) { ++ strsz = strlen(argv[i]) + 1; ++ memBBWrt(strp, (BYTE *)argv[i], strsz); ++ memWrt8(sp, strp); ++ strp += strsz; ++ sp += 8; ++ } ++ memWrt8(sp, 0); ++ sp += 8; ++ ++ /* Copy out environment strings. */ ++ for (i = 0; i < envc; i++) { ++ strsz = strlen(environ[i]) + 1; ++ memBBWrt(strp, (BYTE *)environ[i], strsz); ++ memWrt8(sp, strp); ++ strp += strsz; ++ sp += 8; ++ } ++ memWrt8(sp, 0); ++ sp += 8; ++ ++ if (proc->has_rtld) { ++ AUX(sp, AT_BASE, proc->rtld_base); ++ AUX(sp, AT_ENTRY, proc->proc_entry); ++ AUX(sp, AT_PHDR, proc->phdr_addr); ++ AUX(sp, AT_PHENT, sizeof(Elf64_Phdr)); ++ AUX(sp, AT_PHNUM, proc->phdr_count); ++ AUX(sp, AT_NULL, NULL); ++ } ++ ++ /* Copy out ps_strings. */ ++ memBBWrt(strings, (BYTE *)&ps_strings, sizeof(ps_strings)); ++ ++ /* Set backing store. */ ++ arSet(0, BSP_ID, 0x9FFFFFFF80000000ULL); ++ arSet(0, BSPST_ID, 0x9FFFFFFF80000000ULL); ++ ++ return (0); ++} diff --git a/emulators/ski/patches/patch-al b/emulators/ski/patches/patch-al new file mode 100644 index 00000000000..61668ead57c --- /dev/null +++ b/emulators/ski/patches/patch-al @@ -0,0 +1,176 @@ +$NetBSD: patch-al,v 1.1.1.1 2011/07/27 10:23:49 cherry Exp $ + +--- src/netbsd/signal-netbsd.c.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/signal-netbsd.c +@@ -0,0 +1,171 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include <sys/types.h> ++#include <assert.h> ++#include <errno.h> ++#include <signal.h> ++#include <string.h> ++ ++#include "std.h" ++#include "types.h" ++#include "exportui.h" ++#include "coreui.h" ++#include "sim.h" ++#include "libsrs.h" ++#include "libcore.h" ++#include "state.h" ++ ++#include "netbsd/signal-netbsd.h" ++ ++static struct { ++ int valid; ++ int flags; ++ ADDR handler; ++ sigset_t mask; ++ struct siginfo64 info; ++} siginfo[SIGRTMAX]; ++ ++static sigset_t sigpend, sigmask; ++ ++void signal_return(void) ++{ ++ assert(0); ++} ++ ++void signal_invoke_handler(int in_syscall) ++{ ++ int i, sig; ++ uint32_t sigword; ++ ++ for (i = 0, sig = 0; i < _SIG_WORDS; i++, sig += 32) { ++ sigword = sigpend.__bits[i] & ~sigmask.__bits[i]; ++ if (sigword) ++ break; ++ } ++ assert(sigword); ++ sig += ffs(sigword); ++ assert(sig > 0 && sig <= SIGRTMAX); ++ ++ /* XXX need to actually deliver the signal. Ignore for now. */ ++ sigdelset(&sigpend, sig); ++} ++ ++int signal_pending(void) ++{ ++ int i; ++ ++ for (i = 0; i < _SIG_WORDS; i++) { ++ if (sigpend.__bits[i] && ++ sigpend.__bits[i] & ~sigmask.__bits[i]) ++ return (1); ++ } ++ return (0); ++} ++ ++void signal_queue_info(int sig, ADDR ifa) ++{ ++ struct siginfo64 *si64; ++ ++ /* Sanity checks. */ ++ if (sig <= 0 || sig > SIGRTMAX) ++ return; ++ ++ /* XXX We need to deliver the trap. For now, halt the program. */ ++ progStop("Got trap %d (IFA=0x%016llx, IP=0x%016llx)\n", sig, ifa, ip); ++ ++ sigaddset(&sigpend, sig); ++ si64 = &siginfo[sig - 1].info; ++ memset(si64, 0, sizeof(*si64)); ++ si64->si_addr = ifa; /* XXX: normalise pointers to ptr64_t */ ++} ++ ++static void signal_handler(int sig, siginfo_t *si, void *uc) ++{ ++ struct siginfo64 *si64; ++ ++ /* Sanity checks. */ ++ if (sig <= 0 || sig > SIGRTMAX) { ++ return; ++ } ++ ++#if 0 ++ printf("Got signal %d\n", sig); ++#endif ++ ++ sigaddset(&sigpend, sig); ++ si64 = &siginfo[sig - 1].info; ++ si64->si_signo = sig; ++ si64->si_errno = si->si_errno; ++ si64->si_code = si->si_code; ++ si64->si_pid = si->si_pid; ++ si64->si_uid = si->si_uid; ++ si64->si_status = si->si_status; ++ si64->si_addr = (long)si->si_addr; ++ si64->si_value.sival_ptr = si->si_value.sival_ptr; ++ si64->si_band = si->si_band; ++} ++ ++int signal_get_handler(int sig, struct sigaction64 *sa64) ++{ ++ struct sigaction sa; ++ ++ if (sig <= 0 || sig > SIGRTMAX) ++ return (EINVAL); ++ ++ if (!siginfo[sig - 1].valid) { ++ if (sigaction(sig, NULL, &sa) == -1) ++ return (errno); ++ siginfo[sig - 1].valid = 1; ++ siginfo[sig - 1].handler = 0; ++ siginfo[sig - 1].flags = sa.sa_flags; ++ siginfo[sig - 1].mask = sa.sa_mask; ++ } ++ sa64->sa_handler = siginfo[sig - 1].handler; ++ sa64->sa_flags = siginfo[sig - 1].flags; ++ sa64->sa_mask = siginfo[sig - 1].mask; ++ return (0); ++} ++ ++int signal_set_handler(int sig, struct sigaction64 *sa64) ++{ ++ struct sigaction sa; ++ ++ if (sig <= 0 || sig > SIGRTMAX) ++ return (EINVAL); ++ ++ sa.sa_flags = sa64->sa_flags; ++ sa.sa_mask = sa64->sa_mask; ++ if (sa64->sa_handler == 0) ++ sa.sa_handler = SIG_DFL; ++ else if (sa64->sa_handler == 1) ++ sa.sa_handler = SIG_IGN; ++ else { ++ sa.sa_sigaction = signal_handler; ++ sa.sa_flags |= SA_SIGINFO; ++ } ++ if (sigaction(sig, &sa, NULL) == -1) ++ return (errno); ++ ++ siginfo[sig - 1].handler = sa64->sa_handler; ++ siginfo[sig - 1].flags = sa64->sa_flags; ++ siginfo[sig - 1].mask = sa64->sa_mask; ++ siginfo[sig - 1].valid = 1; ++ return (0); ++} diff --git a/emulators/ski/patches/patch-am b/emulators/ski/patches/patch-am new file mode 100644 index 00000000000..e7853143a3e --- /dev/null +++ b/emulators/ski/patches/patch-am @@ -0,0 +1,51 @@ +$NetBSD: patch-am,v 1.1.1.1 2011/07/27 10:23:49 cherry Exp $ + +--- src/netbsd/signal-netbsd.h.orig 2009-12-16 12:47:32.000000000 +0000 ++++ src/netbsd/signal-netbsd.h +@@ -0,0 +1,46 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++#ifndef _SKI_SIGNAL_H ++#define _SKI_SIGNAL_H ++ ++#define SIGRTMAX 63 ++#define _SIG_WORDS 4 ++ ++typedef long long ptr64 __attribute__((aligned(8))); ++ ++struct sigaction64 { ++ union { ++ ptr64 _sa_handler; ++ ptr64 _sa_sigaction; ++ } _sa_u; ++ sigset_t sa_mask; ++ int sa_flags; ++}; ++ ++struct siginfo64 { ++ union { ++ char si_pad[128]; ++ struct _ksiginfo _info; /* XXX: open this out. pointers need to become (ptr64) */ ++ }; ++}; ++ ++int signal_get_handler(int, struct sigaction64 *); ++int signal_set_handler(int, struct sigaction64 *); ++ ++#endif /* _SKI_SIGNAL_H */ diff --git a/emulators/ski/patches/patch-an b/emulators/ski/patches/patch-an new file mode 100644 index 00000000000..bffb263a48d --- /dev/null +++ b/emulators/ski/patches/patch-an @@ -0,0 +1,468 @@ +$NetBSD: patch-an,v 1.1.1.1 2011/07/27 10:23:50 cherry Exp $ + +--- src/netbsd/ssc-netbsd.c.orig 2010-11-04 05:01:51.000000000 +0000 ++++ src/netbsd/ssc-netbsd.c +@@ -0,0 +1,463 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++#include <sys/param.h> ++#include <sys/types.h> ++#include <sys/mman.h> ++#include <sys/time.h> ++#include <sys/wait.h> ++ ++#include <assert.h> ++#include <fcntl.h> ++#include <util.h> ++#include <poll.h> ++#include <signal.h> ++#include <string.h> ++#include <termios.h> ++#include <unistd.h> ++ ++/* XXX - B0 is defined in termios.h to mean 0 baud. B0 is also ++ * a macro defined in field.h. Undefine B0 here... ++ */ ++#undef B0 ++ ++#include "std.h" ++#include "types.h" ++#include "bits.h" ++#include "exportui.h" ++#include "coreui.h" ++#include "fields.h" ++#include "libui.h" ++#include "sim.h" ++#include "state.h" ++#include "simmem.h" ++#include "ssc.h" ++ ++#include "interruption.h" ++ ++#include "netbsd/machdep-netbsd.h" ++ ++extern char commandline[]; ++extern unsigned int commandline_len; ++ ++#ifdef NEW_MP ++extern REG os_boot_rendez_ip; ++extern REG os_boot_rendez_gp; ++#endif ++ ++SscReqNode *sscHead = NULL; ++SscReqNode *sscPend = NULL; ++ ++static struct { ++ short type; ++ short irrBit; ++} irptTbl[30]; ++static unsigned int irptTop = 0; ++ ++static pid_t console; ++static int fdin, fdout; ++static struct termios saved_tios; ++ ++static void sigchld_handler(int sig, siginfo_t *si, void *ctx) ++{ ++ tcsetattr(fdin, TCSANOW, &saved_tios); ++ _exit(1); ++} ++ ++static void restore_tios(void) ++{ ++ int status; ++ ++ tcsetattr(fdin, TCSANOW, &saved_tios); ++ if (console) { ++ kill(console, SIGKILL); ++ wait(&status); ++ } ++} ++ ++static void init_console(int fin, int fout) ++{ ++ struct termios tios; ++ ++ tcgetattr(fin, &tios); ++ saved_tios = tios; ++ tios.c_lflag &= ~(ICANON|ECHO); ++ tcsetattr(fin, TCSANOW, &tios); ++ atexit(restore_tios); ++ fdin = fin; ++ fdout = fout; ++} ++ ++static int xconsole() ++{ ++ char name[PATH_MAX]; ++ struct sigaction act; ++ char tty[PATH_MAX]; ++ int namelen; ++ int master, slave; ++ ++ if (openpty(&master, &slave, name, NULL, NULL) == -1) ++ goto fail; ++ ++ console = fork(); ++ switch (console) { ++ case -1: ++ goto fail; ++ case 0: /* child */ ++ close(0); ++ close(1); ++ close(2); ++ close(master); ++ ++ sprintf(tty, "-S%s/%d", name, slave); ++ execlp("xterm", "xterm", tty, "-geo", "80x24", "-name", ++ "xski console", 0); ++ perror("execlp(\"xterm\", ...) failed."); ++ abort(); ++ ++ default: /* parent */ ++ close(slave); ++ init_console(master, master); ++ act.sa_sigaction = sigchld_handler; ++ act.sa_flags = SA_NOCLDSTOP|SA_SIGINFO; ++ sigaction(SIGCHLD, &act, NULL); ++ ++ /* Read the window ID. */ ++ if (read(master, name, 128) == -1) ++ goto fail; ++ ++ fcntl(master, F_SETFL, O_NONBLOCK); ++ ++ break; ++ } ++ ++ return 0; ++ ++ fail: ++ progExit("Unable to create console window\n"); ++ return -1; ++} ++ ++static BOOL addSscReq(int fd, size_t size) ++{ ++ SscReqNode *np, *p; ++ int prevcnt = 0; ++ ++ if (!(np = malloc(sizeof *np))) ++ return NO; ++ for (p = sscPend; p; p = p->next) ++ prevcnt += p->irptcnt; ++ np->fd = fd; ++ np->count = size; ++ np->irptcnt = IO_IRPT_CNT - prevcnt; ++ np->next = 0; ++ if (sscHead) { ++ for (p = sscHead; p->next; p = p->next) ; ++ p->next = np; ++ } else ++ sscHead = np; ++ ++ if (!sscPend) ++ sscPend = np; ++ ++ return YES; ++} ++ ++static void delSscReq(SscReqNode *p) ++{ ++ SscReqNode *q = sscHead; ++ ++ if (p != sscHead) { ++ while (q->next != p) ++ q = q->next; ++ q->next = p->next; ++ } else ++ sscHead = sscHead->next; ++ ++ if (p == sscPend) ++ sscPend = sscPend->next; ++ free(p); ++} ++ ++void pendSscIrpt(unsigned int type) ++{ ++ unsigned i, reg, bit, vector; ++ REG *p = &IRR0; /* assume IRR0-3 are contiguous */ ++ ++ for (i = 0; i < irptTop; i++) { ++ if (type == irptTbl[i].type) { ++ vector = irptTbl[i].irrBit; ++ if (vector == 1 || (vector >= 3 && vector <= 15)) ++ continue; /* ignore vectors 1 and 3-15 */ ++ ++ reg = vector >> 6 & 0x3; ++ bit = vector & 0x3F; ++ *(p + reg) |= (REG)1 << bit; ++ } ++ } ++ ++ if (acceptIrpt()) ++ intrsim = extint = YES; ++} ++ ++void doSSC(HWORD num, REG arg0, REG arg1, REG arg2, REG arg3, REG *ret) ++{ ++ BOOL olddt = PSR_DT; ++ ++ PSR_DT = 0; ++ ++ switch (num) { ++ case SSC_CLOSE: ++ *ret = close(arg0); ++ break; ++ ++ case SSC_CONSOLE_INIT: { ++ if (interface == BATCH) ++ init_console(0, 1); ++ else ++ xconsole(); ++ break; ++ } ++ ++ case SSC_EXIT: ++ GrWrtx (8, arg0, 0); ++ progExit("kernel exited with status %d\n", (int)arg0); ++ break; ++ ++ case SSC_GENERATE_INTERRUPT: ++ pendSscIrpt(arg0); ++ break; ++ ++ case SSC_GET_ARGS: ++ memBBWrt(arg0, commandline, commandline_len); ++ *ret = commandline_len; ++ break; ++ ++ case SSC_GET_RTC: { ++ struct timeval tp; ++ struct timezone tzp; ++ struct tm *tm; ++ SscTime sscTime; ++ ++ gettimeofday (&tp, &tzp); ++ tm = localtime((const time_t *)&tp.tv_sec); ++ sscTime.year = tm->tm_year; ++ sscTime.mon = tm->tm_mon; ++ sscTime.mday = tm->tm_mday; ++ sscTime.hour = tm->tm_hour; ++ sscTime.min = tm->tm_min; ++ sscTime.sec = tm->tm_sec; ++ sscTime.msec = tp.tv_usec/1000; ++ sscTime.wday = tm->tm_wday; ++ memBBWrtP(arg0, (BYTE *)&sscTime, sizeof(SscTime)); ++ /* no return value */ ++ break; ++ } ++ ++ case SSC_GET_TOD: { ++ struct timeval tp; ++ struct timezone tzp; ++ SscTimeval tv; ++ SscTimezone tz; ++ ++ gettimeofday (&tp, &tzp); ++ tv.ssc_Sec = tp.tv_sec; ++ tv.ssc_Usec = tp.tv_usec; ++ tz.ssc_Minuteswest = tzp.tz_minuteswest; ++ tz.ssc_Dsttime = tzp.tz_dsttime; ++ memBBWrtP(arg0, (BYTE *)&tv, sizeof(tv)); ++ if (arg1 != 0) ++ memBBWrtP(arg1, (BYTE *)&tz, sizeof(tz)); ++ break; ++ } ++ ++ case SSC_GETCHAR: { ++ int sz; ++ char buf[1]; ++ ++ sz = read(fdin, buf, 1); ++ *ret = (sz == 1) ? buf[0] : 0; ++ break; ++ } ++ ++ case SSC_LOAD_SYMBOLS: { ++ char fn[PATH_MAX]; ++ memBBRd(arg1, fn, 0); ++ *ret = (elfSymLoad(fn)) ? 0 : -1; ++ break; ++ } ++ ++ case SSC_OPEN: { ++ int flags; ++ char fn[PATH_MAX]; ++ ++ memBBRd(arg0, fn, 0); ++ if (arg1 == SSC_READ_ACCESS) ++ flags = O_RDONLY; ++ else if (arg1 == SSC_WRITE_ACCESS) ++ flags = O_WRONLY; ++ else if (arg1 == (SSC_READ_ACCESS | SSC_WRITE_ACCESS)) ++ flags = O_RDWR; ++ else ++ flags = -1; ++ ++ *ret = (flags != -1) ? open(fn, flags) : -1; ++ break; ++ } ++ ++ case SSC_PUTCHAR: { ++ char buf[1]; ++ ++ buf[0] = arg0; ++ write(fdout, buf, 1); ++ break; ++ } ++ ++ case SSC_READ: { ++ SscDiskReq iov; ++ off_t filesize; ++ size_t size, ofs; ++ ADDR adr; ++ char *map; ++ int i; ++ ++ filesize = lseek(arg0, 0LL, SEEK_END); ++ if (filesize == -1 || arg3 > filesize) { ++ *ret = -1; ++ break; ++ } ++ ++ size = 0; ++ adr = arg2; ++ for (i = 0; i < arg1; i++) { ++ memBBRd(adr, (BYTE *)&iov, sizeof(iov)); ++ size += iov.len; ++ adr += sizeof(iov); ++ } ++ ++ if (arg3 + size > filesize) ++ size = filesize - arg3; ++ ++ map = mmap(0, size, PROT_READ, MAP_SHARED, arg0, arg3); ++ if (map == MAP_FAILED) { ++ *ret = -1; ++ break; ++ } ++ ++ adr = arg2; ++ ofs = 0; ++ for (i = 0; i < arg1; i++) { ++ memBBRd(adr, (BYTE *)&iov, sizeof(iov)); ++ if (ofs + iov.len >= size) ++ iov.len = size - ofs; ++ memBBWrt_opt(iov.addr, map + ofs, iov.len); ++ ofs += iov.len; ++ adr += sizeof(iov); ++ } ++ ++ munmap(map, size); ++ ++ if (!addSscReq(arg0, size)) ++ *ret = -1; ++ break; ++ } ++ ++ case SSC_WAIT_COMPLETION: { ++ SscDiskStat stat; ++ SscReqNode *p; ++ ++ memBBRd(arg0, (BYTE *)&stat, sizeof(stat)); ++ *ret = -1; ++ for (p = sscPend; p; p = p->next) { ++ if (p->fd == stat.fd) { ++ stat.count = p->count; ++ delSscReq(p); ++ memBBWrt(arg0, (BYTE *)&stat, sizeof(stat)); ++ *ret = 0; ++ break; ++ } ++ } ++ break; ++ } ++ ++ case SSC_WRITE: { ++ SscDiskReq iov; ++ off_t filesize; ++ size_t size, ofs; ++ ADDR adr; ++ char *map; ++ int i; ++ ++ filesize = lseek(arg0, 0LL, SEEK_END); ++ if (filesize == -1 || arg3 > filesize) { ++ *ret = -1; ++ break; ++ } ++ ++ size = 0; ++ adr = arg2; ++ for (i = 0; i < arg1; i++) { ++ memBBRd(adr, (BYTE *)&iov, sizeof(iov)); ++ size += iov.len; ++ adr += sizeof(iov); ++ } ++ ++ if (arg3 + size > filesize) ++ size = filesize - arg3; ++ ++ map = mmap(0, size, PROT_WRITE, MAP_SHARED, arg0, arg3); ++ if (map == MAP_FAILED) { ++ *ret = -1; ++ break; ++ } ++ ++ adr = arg2; ++ ofs = 0; ++ for (i = 0; i < arg1; i++) { ++ memBBRd(adr, (BYTE *)&iov, sizeof(iov)); ++ if (ofs + iov.len >= size) ++ iov.len = size - ofs; ++ memBBRd(iov.addr, map, iov.len); ++ ofs += iov.len; ++ adr += sizeof(iov); ++ } ++ ++ munmap(map, size); ++ ++ if (!addSscReq(arg0, size)) ++ *ret = -1; ++ break; ++ } ++ ++#ifdef NEW_MP ++ case SSC_SAL_SET_VECTORS: ++ if (arg0 == 2) { ++ os_boot_rendez_ip=arg1; ++ os_boot_rendez_gp=arg2; ++ } ++ break; ++#endif ++ ++ default: ++ progExit("SSC #%d: unimplemented call\n", num); ++ break; ++ } ++ ++ PSR_DT = olddt; ++} diff --git a/emulators/ski/patches/patch-ao b/emulators/ski/patches/patch-ao new file mode 100644 index 00000000000..4f11140004f --- /dev/null +++ b/emulators/ski/patches/patch-ao @@ -0,0 +1,667 @@ +$NetBSD: patch-ao,v 1.1.1.1 2011/07/27 10:23:50 cherry Exp $ + +--- src/netbsd/syscall-netbsd.c.orig 2010-06-09 19:58:06.000000000 +0530 ++++ src/netbsd/syscall-netbsd.c +@@ -0,0 +1,662 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++ ++/* ++ * Note: We provide binary support only for NetBSD here. ++ */ ++ ++#include <sys/types.h> ++#include <sys/ioctl.h> ++#include <sys/mman.h> ++#include <sys/param.h> ++#include <sys/socket.h> ++#include <sys/stat.h> ++#include <sys/syscall.h> ++#include <sys/sysctl.h> ++#include <sys/syslimits.h> ++#include <sys/time.h> ++#include <sys/mount.h> ++#include <sys/resource.h> ++#include <assert.h> ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <poll.h> ++#include <signal.h> ++#include <string.h> ++#include <unistd.h> ++ ++#include "std.h" ++#include "types.h" ++#include "sim.h" ++#include "state.h" ++#include "simmem.h" ++#include "libsrs.h" ++#include "libcore.h" ++#include "os_support.h" ++ ++#include "netbsd/machdep-netbsd.h" ++#include "netbsd/signal-netbsd.h" ++#include "netbsd/syscall-netbsd.h" ++ ++#define NBSD_PAGESIZE 16384 ++#define NBSD_PAGEMASK (NBSD_PAGESIZE-1) ++ ++/* Arbitrary... */ ++#define NBSD_MMAP_START 0x6000000100000000ULL ++#define NBSD_MMAP_END 0x7FFFFFFFFFFFFFFFULL ++ ++#define nbsd_trunc_page(x) ((ADDR)(x) & ~NBSD_PAGEMASK) ++#define nbsd_round_page(x) nbsd_trunc_page((x) + NBSD_PAGEMASK) ++ ++void memFree(ADDR adr); ++BOOL pmemMap(ADDR adr, void *hostadr); ++ ++extern int fdlimit; ++ ++int _close(int); ++int _open(const char *, int, int); ++ ++BOOL trace_syscalls = NO; ++char *consLog = NULL; ++ ++static ADDR mmap_base = NBSD_MMAP_START; ++ ++static void * ++unmap_mapped_pages(ADDR base, REG size) ++{ ++ ADDR addr, end; ++ void *res; ++ ++ /* We expect page aligned addresses here. */ ++ assert((base & NBSD_PAGEMASK) == 0); ++ ++ end = nbsd_round_page(base + size); ++ res = pmemLookup(base); ++ for (addr = base; addr < end; addr += page_size) { ++ if (pmemLookup(addr) == NULL) ++ continue; ++ memFree(addr); ++ } ++ return res; ++} ++ ++static ADDR ++verify_unmapped_pages(ADDR base, REG size) ++{ ++ ADDR addr, end; ++ ++ /* We expect page aligned addresses here. */ ++ assert((base & NBSD_PAGEMASK) == 0); ++ ++ end = nbsd_round_page(base + size); ++ for (addr = base; addr < end; addr += page_size) { ++ if (pmemLookup(addr) != NULL) ++ return 0; ++ } ++ return base; ++} ++ ++static ADDR ++get_unmapped_pages(REG size) ++{ ++ ADDR start; ++ ++ while (mmap_base <= NBSD_MMAP_END) { ++ start = verify_unmapped_pages(mmap_base, size); ++ if (start != 0) { ++ mmap_base = nbsd_round_page(mmap_base + size); ++ return start; ++ } ++ mmap_base += NBSD_PAGESIZE; ++ } ++ return 0ULL; ++} ++ ++static int ++nbsd_ioctl(int fd, unsigned long com, REG data) ++{ ++ void *buf; ++ size_t len; ++ int res; ++ ++ len = IOCPARM_LEN(com); ++ if (len > NBSD_PAGESIZE) { ++ errno = ENOTTY; ++ return -1; ++ } ++ if (len) ++ buf = alloca(len); ++ else ++ buf = (void*)(intptr_t)data; ++ if ((com & IOC_IN) && len) ++ memBBRd(data, buf, len); ++ res = ioctl(fd, com, buf); ++ if ((com & IOC_OUT) && len) ++ memBBWrt_alloc(data, buf, len); ++ return res; ++} ++ ++void doSyscall(HWORD num, REG arg0, REG arg1, REG arg2, REG arg3, REG arg4, ++ REG arg5, REG arg6, REG arg7, REG *ret, REG *status) ++{ ++ int res = -1; ++ ++ *status = 0; ++ ++ /* syscalls and user space support not available for NetBSD */ ++ ret = ENOSYS; ++ goto out; ++ ++#if 0 ++ if (num == SYS___syscall) { ++ num = arg0; ++ arg0 = arg1; ++ arg1 = arg2; ++ arg2 = arg3; ++ arg3 = arg4; ++ arg4 = arg5; ++ arg5 = arg6; ++ arg6 = arg7; ++ } ++ ++#if 0 ++ printf("syscall %d", num); ++#endif ++ ++ switch (num) { ++ case SYS_exit: ++ /* void sys_exit(int rval); */ ++ GrWrtx(8, arg0, 0); ++ progExit("program exited with status %d\n", (int)arg0); ++ goto out; ++ case SYS_read: { ++ /* ssize_t read(int fd, void *buf, size_t nbyte); */ ++ char *buf = alloca(arg2); ++ res = read(arg0, buf, arg2); ++ if (res > 0) ++ memBBWrt_alloc(arg1, buf, res); ++ break; ++ } ++ case SYS_write: { ++ /* ssize_t write(int fd, const void *buf, size_t nbyte); */ ++ char *buf = alloca(arg2); ++ memBBRd(arg1, buf, arg2); ++ res = write(arg0, buf, arg2); ++ break; ++ } ++ case SYS_open: { ++ /* int open(char *path, int flags, int mode); */ ++ char path[PATH_MAX]; ++ simroot(arg0, path, arg1 & O_CREAT); ++ res = _open(path, arg1, arg2); ++ if (res >= fdlimit) { ++ _close(res); ++ errno = EMFILE; ++ res = -1; ++ } ++ break; ++ } ++ case SYS_close: ++ /* int close(int fd); */ ++ if (arg0 >= fdlimit) { ++ errno = EBADF; ++ res = -1; ++ } else ++ res = _close(arg0); ++ break; ++ case SYS_unlink: { ++ /* int unlink(char *path); */ ++ char path[PATH_MAX]; ++ simroot(arg0, path, 0); ++ res = unlink(path); ++ break; ++ } ++ case SYS_fchdir: ++ /* int fchdir(int fd); */ ++ res = fchdir(arg0); ++ break; ++ case SYS_break: { ++ /* int obreak(char *nsize); */ ++ REG brk = heapGet(0); ++ if (brk <= NBSD_MMAP_END) { ++ if (arg0 > brk) { ++ for (brk = page_base(brk); brk < arg0; ++ brk += page_size) ++ pmemLookup_p(brk); ++ heapSet(0, brk); ++ } else if (arg0 == 0) ++ arg0 = brk; ++ res = 0; ++ } else { ++ errno = EINVAL; ++ res = -1; ++ } ++ break; ++ } ++ case SYS_getpid: ++ /* pid_t getpid(void); */ ++ *ret = getpid(); ++ goto out; ++ case SYS_getuid: ++ /* uid_t getuid(void); */ ++ *ret = getuid(); ++ goto out; ++ case SYS_geteuid: ++ /* uid_t geteuid(void); */ ++ *ret = geteuid(); ++ goto out; ++ case SYS_access: { ++ /* int access(char *path, int flags); */ ++ char path[PATH_MAX]; ++ simroot(arg0, path, 0); ++ res = access(path, arg1); ++ break; ++ } ++ case SYS_chflags: { ++ /* int chflags(char *path, int flags); */ ++ char path[PATH_MAX]; ++ simroot(arg0, path, 0); ++ res = chflags(path, arg1); ++ break; ++ } ++ case SYS_kill: ++ /* int kill(int pid, int signum); */ ++ res = kill(arg0, arg1); ++ break; ++ case SYS_pipe: { ++ /* (int,int) pipe(void); */ ++ int fildes[2]; ++ res = pipe(fildes); ++ if (res == 0) { ++ GrWrtx(9, (REG)fildes[1], 0); ++ res = (REG)fildes[0]; ++ } ++ break; ++ } ++ case SYS_getegid: ++ /* gid_t getegid(void); */ ++ *ret = getegid(); ++ goto out; ++ case SYS_getgid: ++ /* gid_t getgid(void); */ ++ *ret = getgid(); ++ goto out; ++ case SYS_ioctl: ++ /* int ioctl(int fd, u_long com, caddr_t data); */ ++ res = nbsd_ioctl(arg0, arg1, arg2); ++ break; ++ case SYS_readlink: { ++ /* int readlink(char *path, char *buf, int count); */ ++ char *buf, path[PATH_MAX]; ++ size_t count; ++ simroot(arg0, path, 0); ++ count = arg2; ++ buf = alloca(count); ++ res = readlink(path, buf, count); ++ memBBWrt_alloc(arg1, buf, count); ++ break; ++ } ++ case SYS_munmap: { ++ /* int munmap(void *addr, size_t len); */ ++ caddr_t addr; ++ ADDR reloc; ++ reloc = arg0; ++ arg0 = nbsd_trunc_page(arg0); ++ reloc -= arg0; ++ arg1 += reloc; ++ addr = unmap_mapped_pages(arg0, arg1); ++ res = munmap(addr, arg1); ++ break; ++ } ++ case SYS_mprotect: { ++ /* int mprotect(const void *addr, size_t len, int prot); */ ++ ADDR reloc; ++ void *addr; ++ reloc = arg0; ++ arg0 = nbsd_trunc_page(arg0); ++ arg1 += reloc - arg0; ++ arg1 = nbsd_round_page(arg1); ++ addr = pmemLookup(arg0); ++ res = mprotect(addr, arg1, arg2); ++ break; ++ } ++ case SYS___setitimer50: { ++ /* int setitimer(u_int which, struct itimerval *itv, ++ * struct itimerval *oitv); ++ */ ++ struct itimerval itv, oitv, *itvp; ++ struct itimerval64 itv64; ++ itvp = (arg1 != 0) ? &itv : NULL; ++ if (arg1 != 0) { ++ memBBRd(arg1, (void*)&itv64, sizeof(itv64)); ++ ston_itimerval(&itv64, itvp); ++ } ++ res = setitimer((int)arg0, itvp, &oitv); ++ if (arg2 != 0) { ++ ntos_itimerval(&oitv, &itv64); ++ memBBWrt_alloc(arg2, (void*)&itv64, sizeof(itv64)); ++ } ++ break; ++ } ++ /* XXX: Fix this */ ++ /* case SYS_getdtablesize: */ ++ /* /\* int getdtablesize(void); *\/ */ ++ /* res = getdtablesize() - SKI_NFDS; */ ++ /* break; */ ++ case SYS_dup2: ++ /* int dup2(u_int from, u_int to); */ ++ if (arg1 >= fdlimit) { ++ errno = EBADF; ++ res = -1; ++ } else ++ res = dup2(arg0, arg1); ++ break; ++ case SYS_fcntl: { ++ /* int fcntl(int fd, int cmd, long arg); */ ++ struct flock l; ++ switch (arg1) { ++ case F_GETLK: ++ case F_SETLK: ++ case F_SETLKW: ++ memBBRd(arg2, (void*)&l, sizeof(l)); ++ res = fcntl(arg0, arg1, &l); ++ memBBWrt_alloc(arg2, (void*)&l, sizeof(l)); ++ break; ++ default: ++ res = fcntl(arg0, arg1, arg2); ++ break; ++ } ++ break; ++ } ++ case SYS___socket30: ++ /* int socket(int domain, int type, int protocol); */ ++ res = socket(arg0, arg1, arg2); ++ break; ++ case SYS_connect: { ++ /* int connect(int s, caddr_t name, int namelen); */ ++ void *name; ++ name = alloca(arg2); ++ memBBRd(arg1, name, arg2); ++ res = connect(arg0, name, arg2); ++ break; ++ } ++ case SYS___gettimeofday50: { ++ /* int gettimeofday(struct timeval *tp, ++ * struct timezone *tzp); ++ */ ++ struct timeval64 tp64; ++ struct timeval tp; ++ struct timezone tzp; ++ res = gettimeofday(&tp, &tzp); ++ ntos_timeval(&tp, &tp64); ++ if (arg0 != 0) ++ memBBWrt_alloc(arg0, (void*)&tp64, sizeof(tp64)); ++ if (arg1 != 0) ++ memBBWrt_alloc(arg1, (void*)&tzp, sizeof(tzp)); ++ break; ++ } ++ case SYS___getrusage50: { ++ /* int getrusage(int who, struct rusage *rusage); */ ++ struct rusage64 ru64; ++ struct rusage ru; ++ res = getrusage(arg0, &ru); ++ ntos_rusage(&ru, &ru64); ++ memBBWrt_alloc(arg1, (void*)&ru64, sizeof(ru64)); ++ break; ++ } ++ case SYS_sendto: { ++ /* int sendto(int s, caddr_t buf, size_t len, int flags, ++ * caddr_t to, int tolen); ++ */ ++ void *msg, *to; ++ msg = alloca(arg2); ++ memBBRd(arg1, msg, arg2); ++ to = alloca(arg5); ++ memBBRd(arg4, to, arg5); ++ res = sendto(arg0, msg, arg2, arg3, to, arg5); ++ break; ++ } ++ /* XXX: case SYS_compat_20_fstatfs: { */ ++ /* /\* int fstatfs(int fd, struct statfs *buf); *\/ */ ++ /* struct statfs64 buf64; */ ++ /* struct statfs buf; */ ++ /* res = fstatfs(arg0, &buf); */ ++ /* ntos_statfs(&buf, &buf64); */ ++ /* memBBWrt_alloc(arg1, (void*)&buf64, sizeof(buf64)); */ ++ /* break; */ ++ /* } */ ++ case SYS___stat50: { ++ /* int stat(char *path, struct stat *ub); */ ++ char path[PATH_MAX]; ++ struct stat64 sb64; ++ struct stat sb; ++ simroot(arg0, path, 0); ++ res = stat(path, &sb); ++ ntos_stat(&sb, &sb64); ++ memBBWrt_alloc(arg1, (void*)&sb64, sizeof(sb64)); ++ break; ++ } ++ case SYS___fstat50: { ++ /* int fstat(int fd, struct stat *sb); */ ++ struct stat64 sb64; ++ struct stat sb; ++ res = fstat(arg0, &sb); ++ ntos_stat(&sb, &sb64); ++ memBBWrt_alloc(arg1, (void*)&sb64, sizeof(sb64)); ++ break; ++ } ++ case SYS___lstat50: { ++ /* int lstat(char *path, struct stat *ub); */ ++ char path[PATH_MAX]; ++ struct stat64 sb64; ++ struct stat sb; ++ simroot(arg0, path, 0); ++ res = stat(path, &sb); ++ ntos_stat(&sb, &sb64); ++ memBBWrt_alloc(arg1, (void*)&sb64, sizeof(sb64)); ++ break; ++ } ++ case SYS_getrlimit: { ++ /* int getrlimit(u_int which, struct rlimit *rlp); */ ++ struct rlimit rlp; ++ res = getrlimit(arg0, &rlp); ++ memBBWrt_alloc(arg1, (void*)&rlp, sizeof(rlp)); ++ break; ++ } ++ case SYS_compat_12_getdirentries: { ++ /* int getdirentries(int fd, char *buf, u_int count, ++ * long *basep); ++ */ ++ long64 basep64; ++ char *buf; ++ long basep; ++ buf = alloca(arg2); ++ res = getdirentries(arg0, buf, arg2, &basep); ++ memBBWrt_alloc(arg1, (void*)buf, arg2); ++ basep64 = basep; ++ memBBWrt_alloc(arg3, (void*)&basep64, sizeof(basep64)); ++ break; ++ } ++ case SYS_mmap: { ++ /* caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, ++ * int fd, int pad, off_t pos); ++ */ ++ caddr_t addr; ++ ADDR arg, reloc; ++ addr = NULL; ++ reloc = arg0; ++ arg0 = nbsd_trunc_page(arg0); ++ reloc -= arg0; ++ arg1 += reloc; ++ arg6 -= reloc; ++ arg1 = nbsd_round_page(arg1); ++ /* Try to map where the process wants it. */ ++ arg = (arg0 != 0) ? verify_unmapped_pages(arg0, arg1) : 0; ++ if (arg == 0) { ++ if (arg3 & MAP_FIXED) ++ addr = unmap_mapped_pages(arg0, arg1); ++ else ++ arg0 = get_unmapped_pages(arg1); ++ } else ++ arg0 = arg; ++ if (arg0 == 0) { ++ errno = EINVAL; ++ res = -1; ++ break; ++ } ++ if (arg3 == MAP_STACK) ++ arg3 = MAP_ANON; ++ addr = mmap(addr, arg1, arg2, arg3, arg4, arg6); ++ if (addr != (void*)-1) { ++ for (arg = arg0; arg1 > 0; arg1 -= page_size) { ++ pmemMap(arg, addr); ++ arg += page_size; ++ addr += page_size; ++ } ++ *ret = arg0 + reloc; ++ goto out; ++ } ++ res = -1; ++ break; ++ } ++ case SYS_lseek: ++ /* off_t lseek(int fd, int pad, off_t offset, int whence); */ ++ res = lseek(arg0, arg2, arg3); ++ break; ++ case SYS___sysctl: { ++ /* int __sysctl(int *name, u_int namelen, void *old, ++ * size_t *oldlenp, void *new, size_t newlen); ++ */ ++ char *buf; ++ int *name; ++ size_t namelen, newlen, oldlen, *oldlenp; ++ void *new, *old; ++ namelen = arg1 << 2; ++ newlen = (arg4) ? arg5 : 0; ++ if (arg3 != 0L) { ++ memBBRd(arg3, (void*)&oldlen, sizeof(size_t)); ++ oldlenp = &oldlen; ++ } else { ++ oldlen = 0; ++ oldlenp = NULL; ++ } ++ buf = alloca(namelen + newlen + oldlen); ++ name = (void*)buf; ++ new = (newlen) ? buf + namelen : NULL; ++ old = (oldlen) ? buf + namelen + newlen : NULL; ++ memBBRd(arg0, (void*)name, namelen); ++ if (newlen) ++ memBBRd(arg4, new, newlen); ++ if (name[0] == CTL_HW && name[1] == HW_PAGESIZE && arg1 == 2) { ++ *oldlenp = sizeof(int); ++ *(int*)old = NBSD_PAGESIZE; ++ res = 0; ++ /* XXX: } else if (name[0] == CTL_KERN && name[1] == KERN_USRSTACK && */ ++ /* arg1 == 2) { */ ++ /* *oldlenp = sizeof(uint64_t); */ ++ /* *(uint64_t*)old = 0xA000000000000000ULL; */ ++ /* res = 0; */ ++ } else ++ res = sysctl(name, namelen >> 2, old, oldlenp, new, ++ newlen); ++ if (old != NULL) { ++ memBBWrt_alloc(arg3, (void*)oldlenp, sizeof(size_t)); ++ memBBWrt_alloc(arg2, old, oldlen); ++ } ++ break; ++ } ++ case SYS_poll: { ++ /* int poll(struct pollfd *fds, u_int nfds, int timeout); */ ++ struct pollfd *fds; ++ size_t fdssz; ++ fdssz = arg1 * sizeof(struct pollfd); ++ fds = alloca(fdssz); ++ memBBRd(arg0, (void*)fds, fdssz); ++ res = poll(fds, arg1, arg2); ++ memBBWrt(arg0, (void*)fds, fdssz); ++ break; ++ } ++ case SYS___clock_gettime50: { ++ /* int clock_gettime(clockid_t clock_id, struct timespec *tp); ++ */ ++ struct timespec ts; ++ struct timespec64 ts64; ++ res = clock_gettime(arg0, &ts); ++ ntos_timespec(&ts, &ts64); ++ memBBWrt_alloc(arg1, (void*)&ts64, sizeof(ts64)); ++ break; ++ } ++ case SYS_issetugid: ++ /* int issetugid(void); */ ++ *ret = issetugid(); ++ goto out; ++ case SYS___sigprocmask14: { ++ /* int sigprocmask(int how, const sigset_t *set, ++ * sigset_t *oset); ++ */ ++ sigset_t set, oset; ++ sigset_t *setp, *osetp; ++ if (arg1 != 0) { ++ setp = &set; ++ memBBRd(arg1, (void*)setp, sizeof(*setp)); ++ } else ++ setp = NULL; ++ osetp = (arg2 != 0) ? &oset : NULL; ++ res = sigprocmask(arg0, setp, osetp); ++ if (arg2 != 0) ++ memBBWrt_alloc(arg2, (void*)osetp, sizeof(*osetp)); ++ break; ++ } ++ case 416: { ++ /* int sigaction(int sig, const struct sigaction *act, ++ * struct sigaction *oact); ++ */ ++ struct sigaction64 sa; ++ if (arg2 != 0) { ++ res = signal_get_handler((int)arg0, &sa); ++ memBBWrt_alloc(arg2, (void*)&sa, sizeof(sa)); ++ } ++ if (arg1 != 0) { ++ memBBRd(arg1, (void*)&sa, sizeof(sa)); ++ res = signal_set_handler((int)arg0, &sa); ++ } ++ break; ++ } ++ default: ++ printf("syscall %d\n", num); ++ /* We'll give it a shot */ ++ res = __syscall(num, arg0, arg1, arg2, arg3, arg4, arg5); ++ break; ++ } ++ ++ if (res == -1) { ++ *ret = errno; ++ *status = ~0ULL; ++ } else ++ *ret = res; ++#endif ++ ++ out: ; ++#if 0 ++ printf(" = %llx,%llx\n", *status, *ret); ++#endif ++ ++} ++ diff --git a/emulators/ski/patches/patch-ap b/emulators/ski/patches/patch-ap new file mode 100644 index 00000000000..a82f96912f3 --- /dev/null +++ b/emulators/ski/patches/patch-ap @@ -0,0 +1,149 @@ +$NetBSD: patch-ap,v 1.1.1.1 2011/07/27 10:23:50 cherry Exp $ + +--- src/netbsd/syscall-netbsd.h.orig 2009-12-16 13:06:31.000000000 +0000 ++++ src/netbsd/syscall-netbsd.h +@@ -0,0 +1,144 @@ ++/* ++ * Copyright (C) 1995-2007, Hewlett-Packard Development Company, L.P. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program 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 General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License along ++ * with this program; if not, write to the Free Software Foundation, Inc., ++ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ */ ++#ifndef _SKI_SYSCALL_H ++#define _SKI_SYSCALL_H ++ ++#define STAT64_USE_TIMESPEC 1 ++ ++typedef long long long64 __attribute__((aligned(8))); ++typedef long64 time64; ++ ++struct timeval64 { ++ long64 tv_sec; ++ long64 tv_usec; ++}; ++ ++struct itimerval64 { ++ struct timeval64 it_interval; ++ struct timeval64 it_value; ++}; ++ ++struct rusage64 { ++ struct timeval64 ru_utime; ++ struct timeval64 ru_stime; ++ long64 ru_maxrss; ++ long64 ru_ixrss; ++ long64 ru_idrss; ++ long64 ru_isrss; ++ long64 ru_minflt; ++ long64 ru_majflt; ++ long64 ru_nswap; ++ long64 ru_inblock; ++ long64 ru_oublock; ++ long64 ru_msgsnd; ++ long64 ru_msgrcv; ++ long64 ru_nsignals; ++ long64 ru_nvcsw; ++ long64 ru_nivcsw; ++}; ++ ++struct timespec64 { ++ time64 tv_sec; ++ long64 tv_nsec; ++}; ++ ++ ++/* $NetBSD: patch-ap,v 1.1.1.1 2011/07/27 10:23:50 cherry Exp $ */ ++ ++struct stat64 { ++ dev_t st_dev; /* inode's device */ ++ mode_t st_mode; /* inode protection mode */ ++ ino_t st_ino; /* inode's number */ ++ nlink_t st_nlink; /* number of hard links */ ++ uid_t st_uid; /* user ID of the file's owner */ ++ gid_t st_gid; /* group ID of the file's group */ ++ dev_t st_rdev; /* device type */ ++ ++#if defined(_NETBSD_SOURCE) ++ struct timespec64 st_atimespec;/* time of last access */ ++ struct timespec64 st_mtimespec;/* time of last data modification */ ++ struct timespec64 st_ctimespec;/* time of last file status change */ ++ struct timespec64 st_birthtimespec; /* time of creation */ ++#else ++ time_t st_atime; /* time of last access */ ++ long st_atimensec; /* nsec of last access */ ++ time_t st_mtime; /* time of last data modification */ ++ long st_mtimensec; /* nsec of last data modification */ ++ time_t st_ctime; /* time of last file status change */ ++ long st_ctimensec; /* nsec of last file status change */ ++ time_t st_birthtime; /* time of creation */ ++ long st_birthtimensec; /* nsec of time of creation */ ++#endif ++ off_t st_size; /* file size, in bytes */ ++ blkcnt_t st_blocks; /* blocks allocated for file */ ++ blksize_t st_blksize; /* optimal blocksize for I/O */ ++ uint32_t st_flags; /* user defined flags for file */ ++ uint32_t st_gen; /* file generation number */ ++ uint32_t st_spare[2]; ++}; ++ ++ ++/* $NetBSD: patch-ap,v 1.1.1.1 2011/07/27 10:23:50 cherry Exp $ */ ++struct statvfs64 { ++ unsigned long f_flag; /* copy of mount exported flags */ ++ unsigned long f_bsize; /* file system block size */ ++ unsigned long f_frsize; /* fundamental file system block size */ ++ unsigned long f_iosize; /* optimal file system block size */ ++ ++ fsblkcnt_t f_blocks; /* number of blocks in file system, */ ++ /* (in units of f_frsize) */ ++ fsblkcnt_t f_bfree; /* free blocks avail in file system */ ++ fsblkcnt_t f_bavail; /* free blocks avail to non-root */ ++ fsblkcnt_t f_bresvd; /* blocks reserved for root */ ++ ++ fsfilcnt_t f_files; /* total file nodes in file system */ ++ fsfilcnt_t f_ffree; /* free file nodes in file system */ ++ fsfilcnt_t f_favail; /* free file nodes avail to non-root */ ++ fsfilcnt_t f_fresvd; /* file nodes reserved for root */ ++ ++ uint64_t f_syncreads; /* count of sync reads since mount */ ++ uint64_t f_syncwrites; /* count of sync writes since mount */ ++ ++ uint64_t f_asyncreads; /* count of async reads since mount */ ++ uint64_t f_asyncwrites; /* count of async writes since mount */ ++ ++ fsid_t f_fsidx; /* NetBSD compatible fsid */ ++ unsigned long f_fsid; /* Posix compatible fsid */ ++ unsigned long f_namemax; /* maximum filename length */ ++ uid_t f_owner; /* user that mounted the file system */ ++ ++ uint32_t f_spare[4]; /* spare space */ ++ ++ char f_fstypename[_VFS_NAMELEN]; /* fs type name */ ++ char f_mntonname[_VFS_MNAMELEN]; /* directory on which mounted */ ++ char f_mntfromname[_VFS_MNAMELEN]; /* mounted file system */ ++ ++}; ++ ++void ntos_itimerval(const struct itimerval *, struct itimerval64 *); ++void ntos_rusage(const struct rusage *, struct rusage64 *); ++void ntos_stat(const struct stat *, struct stat64 *); ++void ntos_statvfs(const struct statvfs *, struct statvfs64 *); ++void ntos_timespec(const struct timespec *, struct timespec64 *); ++void ntos_timeval(const struct timeval *, struct timeval64 *); ++ ++void ston_itimerval(const struct itimerval64 *, struct itimerval *); ++void ston_timeval(const struct timeval64 *, struct timeval *); ++ ++#endif /* _SKI_SYSCALL_H */ |