summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsutsui <tsutsui@pkgsrc.org>2007-03-17 13:44:17 +0000
committertsutsui <tsutsui@pkgsrc.org>2007-03-17 13:44:17 +0000
commit8b9f3e13ab7edd9db4af4ca77ff20764eaa1f36b (patch)
tree2975bd8eb6e7cf1a0325be8b1f0b2575d82cd040
parent1fa6716d5e791933b3b33b66674f35afbd3d909a (diff)
downloadpkgsrc-8b9f3e13ab7edd9db4af4ca77ff20764eaa1f36b.tar.gz
Apply various fixes. Most of them are contributed by Arthur Townsend
(see his ILVSUN3 page http://www.ilvsun3.com/ for more details), and some others are from skrll and me. patch-ab: (from skrll) fix an invalid pointer cast for -fstrict-aliasing patch-a[cijklmn]: PR pkg/34113 (by me) - specify -fno-strict-aliasing in Makefiles (for workaround) - add several casts to appease -Wpointer-sign - remove a static decl from a global function - add a cast and remove unused variable patch-ap: (from Arthur, tweaked by me) disable "cannot generate keysym" warnings on tmesh startup patch-aq: PR pkg/33969 (from Arthur) TME sun3 emulator incorrectly emulates cmp2 and chk2 M68K instructions patch-ar: PR pkg/34538 (from Arthur) TME sun3 emulator incorrectly calculates EA with immediate mode instructions with PC indirect 16-bit displacement addressing patch-aw: PR pkg/35010 (from Arthur) sun3 emulator asserts when using stdin/stdout for emulated serial console patch-ax: PR pkg/35009 (from Arthur) TME sun3 emulator asserts when running two emulators with ethernet patch-az: PR pkg/35305 (from Arthur, with some minor tweaks by me) TME sun3 emulator incorrectly emulates ethernet obie & i825x6 hardware patch-ba: PR pkg/35309 (from Arthur) TME sun3 emulator, running without a window manager, overwrites tmesh prompt patch-bb: PR pkg/34690 (from Arthur, modified by me) TME sun3 emulator incorrectly performs: movel sp,-(sp) (also modify m68k-insns-auto.sh to mark cas instructions CANFAULT) patch-bc: PR pkg/34571 (from Arthur, modified by me) TME sun3 emulator doesn't consider floating point infinities to be equal patch-bd: (by me) - avoid invalid 32 bit shifts in fb-xlat-auto.sh, which may cause broken screen fonts when tme is compiled with gcc4 patch-be: (by me) fix decoding cas instructions Makefile: (by me) - add some CONFIGURE_ARGS to avoid invalid shifts more than (or equal to) variable sizes, which could be problematic on gcc4 - bump PKGREVISION
-rw-r--r--emulators/tme/Makefile7
-rw-r--r--emulators/tme/distinfo22
-rw-r--r--emulators/tme/patches/patch-ab28
-rw-r--r--emulators/tme/patches/patch-ac17
-rw-r--r--emulators/tme/patches/patch-ai242
-rw-r--r--emulators/tme/patches/patch-aj13
-rw-r--r--emulators/tme/patches/patch-ak13
-rw-r--r--emulators/tme/patches/patch-al30
-rw-r--r--emulators/tme/patches/patch-am13
-rw-r--r--emulators/tme/patches/patch-an30
-rw-r--r--emulators/tme/patches/patch-ap20
-rw-r--r--emulators/tme/patches/patch-aq169
-rw-r--r--emulators/tme/patches/patch-ar23
-rw-r--r--emulators/tme/patches/patch-aw84
-rw-r--r--emulators/tme/patches/patch-ax19
-rw-r--r--emulators/tme/patches/patch-az343
-rw-r--r--emulators/tme/patches/patch-ba13
-rw-r--r--emulators/tme/patches/patch-bb192
-rw-r--r--emulators/tme/patches/patch-bc65
-rw-r--r--emulators/tme/patches/patch-bd32
-rw-r--r--emulators/tme/patches/patch-be17
21 files changed, 1384 insertions, 8 deletions
diff --git a/emulators/tme/Makefile b/emulators/tme/Makefile
index 72baf7bd65e..482c850ed58 100644
--- a/emulators/tme/Makefile
+++ b/emulators/tme/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.13 2007/01/13 11:40:08 joerg Exp $
+# $NetBSD: Makefile,v 1.14 2007/03/17 13:44:17 tsutsui Exp $
#
DISTNAME= tme-0.4
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= emulators
MASTER_SITES= http://theory.lcs.mit.edu/~fredette/tme/
@@ -19,6 +19,9 @@ GNU_CONFIGURE= yes
USE_TOOLS+= gmake perl:run
CONFIGURE_ARGS+= --disable-debug
+CONFIGURE_ARGS+= ac_cv_shiftmax_int8_t=8
+CONFIGURE_ARGS+= ac_cv_shiftmax_int16_t=16
+CONFIGURE_ARGS+= ac_cv_shiftmax_int32_t=32
BUILDLINK_DEPMETHOD.libXt?= build
diff --git a/emulators/tme/distinfo b/emulators/tme/distinfo
index 19e6b8380cd..5b1a8a25603 100644
--- a/emulators/tme/distinfo
+++ b/emulators/tme/distinfo
@@ -1,12 +1,30 @@
-$NetBSD: distinfo,v 1.6 2006/09/24 15:20:28 joerg Exp $
+$NetBSD: distinfo,v 1.7 2007/03/17 13:44:18 tsutsui Exp $
SHA1 (tme-0.4.tar.gz) = 7a1a2c6aa05527b11f81925e4931e7250f5be308
RMD160 (tme-0.4.tar.gz) = a5b5ac56c8247f94cd96c92a04a6cb132ba92931
Size (tme-0.4.tar.gz) = 1448981 bytes
SHA1 (patch-aa) = 0fe6c37472caa876c253b9e8bb4e09cd278e5def
-SHA1 (patch-ac) = 885286eb6893d5af9769791805d054212b6d0db5
+SHA1 (patch-ab) = ffadbe0a97737fb8c04913781c78b09f6ddc649b
+SHA1 (patch-ac) = 94940e5f0a99c4c1e4e718ffc35fbb2117bceb21
SHA1 (patch-ad) = 3f5adbaa94e5b97ded14e9a05cce912ed01f406f
SHA1 (patch-ae) = 2f472a55f5afd1c0079349ce49bd3eb251ea9d76
SHA1 (patch-af) = 17bf5f0a52036b50533fdfb9f2b6d74ea9494186
SHA1 (patch-ag) = 9b88bc76c34320e63f7aa4fda6804b7b2c432c5c
SHA1 (patch-ah) = c33a0dd4353aac9d7c01a0c9d5d54e5813e8382d
+SHA1 (patch-ai) = 6f6be39f73542ef128824aaa969fa9e793c478a5
+SHA1 (patch-aj) = 63c804457fae8a3527532e5d6b1ab09a377d41e4
+SHA1 (patch-ak) = 29ededa7be17a570be7d5f38b9536ff725ece5dc
+SHA1 (patch-al) = b36aecb7f3a89d80be4631bebaa3f3230ce7c8e7
+SHA1 (patch-am) = 2c216b3549ad02a81ba829e43dfa46dcd0525e24
+SHA1 (patch-an) = c6317d655348bb679f1ea6eef79e8743f3eb0158
+SHA1 (patch-ap) = 91d7b00791f90666728f85ebb940cbc2a75da2af
+SHA1 (patch-aq) = c426d9576b2d6f460a7b290e9f3be69c98e1dfef
+SHA1 (patch-ar) = 5d01194d1b3516ae387e21e54c861f6b5ec9e28e
+SHA1 (patch-aw) = fed1d90d936eac53dbe5be9a505bd7171768cc37
+SHA1 (patch-ax) = b8f16847326e3599df4d73d1108f6815a9c46164
+SHA1 (patch-az) = ab4a4164b880ed1716e7fed0e269b40c85515973
+SHA1 (patch-ba) = 22a47dfbf0c494916e4e8f15aa1fc11b687feaa8
+SHA1 (patch-bb) = 7790146bcdf2b9b8249ed538e5ef7a57628b0a3f
+SHA1 (patch-bc) = 52253ad742a4f1dd4c437cd7f8df3c9815483390
+SHA1 (patch-bd) = 69d00319ef82c1b274f56a61b5aa23a3770f5012
+SHA1 (patch-be) = b22f599b6c156f404f0d011cb692bb14bf8363e7
diff --git a/emulators/tme/patches/patch-ab b/emulators/tme/patches/patch-ab
new file mode 100644
index 00000000000..67e58c2a15d
--- /dev/null
+++ b/emulators/tme/patches/patch-ab
@@ -0,0 +1,28 @@
+$NetBSD: patch-ab,v 1.3 2007/03/17 13:44:18 tsutsui Exp $
+
+--- ic/i825x6.c.orig 2007-01-24 12:56:18.000000000 +0000
++++ ic/i825x6.c
+@@ -122,11 +122,19 @@ do { \
+ /* an rx buffer: */
+ struct tme_i825x6_rx_buffer {
+
+- /* the generic ethernet frame chunk. this must be first, since we
+- abuse its tme_ethernet_frame_chunk_next for our own next pointer: */
+- struct tme_ethernet_frame_chunk tme_i825x6_rx_buffer_frame_chunk;
++ union {
++ struct tme_i825x6_rx_buffer *rx_buffer_next;
++
++ /* the generic ethernet frame chunk. this must be first, since we
++ abuse its tme_ethernet_frame_chunk_next for our own next pointer: */
++ struct tme_ethernet_frame_chunk buffer_frame_chunk;
++ } rx_un;
++
++#define tme_i825x6_rx_buffer_next rx_un.rx_buffer_next
++#define tme_i825x6_rx_buffer_frame_chunk rx_un.buffer_frame_chunk
++
+ #define TME_I825X6_RX_BUFFER_NEXT(rx_buffer) \
+- (*((struct tme_i825x6_rx_buffer **) &(rx_buffer)->tme_i825x6_rx_buffer_frame_chunk.tme_ethernet_frame_chunk_next))
++ (rx_buffer->tme_i825x6_rx_buffer_next)
+
+ /* when this is TME_I825X6_RU_ADDRESS_UNDEF, this rx buffer was made
+ from a fast-write TLB entry, and the generic ethernet frame chunk
diff --git a/emulators/tme/patches/patch-ac b/emulators/tme/patches/patch-ac
index 8161ef7185f..f4a887b21d2 100644
--- a/emulators/tme/patches/patch-ac
+++ b/emulators/tme/patches/patch-ac
@@ -1,8 +1,17 @@
-$NetBSD: patch-ac,v 1.3 2005/07/27 07:29:26 skrll Exp $
+$NetBSD: patch-ac,v 1.4 2007/03/17 13:44:18 tsutsui Exp $
---- libtme/module.c.orig 2005-01-26 12:59:24.000000000 +0000
-+++ libtme/module.c
-@@ -230,7 +230,7 @@ tme_module_open(const char *module_fake_
+--- libtme/module.c.orig 2005-01-26 21:59:24.000000000 +0900
++++ libtme/module.c 2006-07-29 14:41:36.000000000 +0900
+@@ -214,7 +214,7 @@
+ char *modules_dir;
+ char line_buffer[1024];
+ char **tokens;
+- unsigned int tokens_count;
++ int tokens_count;
+ char *module_basename;
+ char *module_pathname;
+ lt_dlhandle handle;
+@@ -230,7 +230,7 @@
for (p1 = module_raw_name;
(c = *p1) != '\0';
p1++) {
diff --git a/emulators/tme/patches/patch-ai b/emulators/tme/patches/patch-ai
new file mode 100644
index 00000000000..e0c536f9641
--- /dev/null
+++ b/emulators/tme/patches/patch-ai
@@ -0,0 +1,242 @@
+$NetBSD: patch-ai,v 1.1 2007/03/17 13:44:18 tsutsui Exp $
+
+--- bus/multibus/Makefile.in.orig 2005-05-15 10:26:15.000000000 +0900
++++ bus/multibus/Makefile.in 2006-07-29 14:32:31.000000000 +0900
+@@ -221,9 +221,10 @@
+ @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/3c400.Plo ./$(DEPDIR)/sun-mie.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun-sc.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- generic/Makefile.in.orig 2005-05-15 10:26:16.000000000 +0900
++++ generic/Makefile.in 2006-07-29 14:30:19.000000000 +0900
+@@ -247,9 +247,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/scsi.Plo ./$(DEPDIR)/serial.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/tape.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- host/bsd/Makefile.in.orig 2005-05-15 10:26:17.000000000 +0900
++++ host/bsd/Makefile.in 2006-07-29 14:32:41.000000000 +0900
+@@ -217,9 +217,10 @@
+ am__depfiles_maybe = depfiles
+ @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/bsd-bpf.Plo ./$(DEPDIR)/bsd-if.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- host/gtk/Makefile.in.orig 2005-05-15 10:26:17.000000000 +0900
++++ host/gtk/Makefile.in 2006-07-29 14:32:52.000000000 +0900
+@@ -221,9 +221,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/gtk-mouse.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/gtk-screen.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- host/posix/Makefile.in.orig 2005-05-15 10:26:18.000000000 +0900
++++ host/posix/Makefile.in 2006-07-29 14:33:04.000000000 +0900
+@@ -225,9 +225,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/posix-serial.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/posix-tape.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- ic/Makefile.in.orig 2005-05-15 10:26:19.000000000 +0900
++++ ic/Makefile.in 2006-07-29 14:30:51.000000000 +0900
+@@ -280,9 +280,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/isil7170.Plo ./$(DEPDIR)/mm58167.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/ncr5380.Plo ./$(DEPDIR)/z8530.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- ic/ieee754/Makefile.in.orig 2005-05-15 10:26:19.000000000 +0900
++++ ic/ieee754/Makefile.in 2006-07-29 14:33:17.000000000 +0900
+@@ -190,9 +190,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/ieee754-ops-auto.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/softfloat-tme.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- ic/m68k/Makefile.in.orig 2005-05-15 10:26:20.000000000 +0900
++++ ic/m68k/Makefile.in 2006-07-29 14:33:27.000000000 +0900
+@@ -241,9 +241,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/m68k-misc.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/m68k-opmap.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- libltdl/Makefile.in.orig 2003-05-14 11:33:05.000000000 +0900
++++ libltdl/Makefile.in 2006-07-29 14:31:04.000000000 +0900
+@@ -177,9 +177,10 @@
+ depcomp =
+ am__depfiles_maybe =
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- libtme/Makefile.in.orig 2005-05-15 10:26:20.000000000 +0900
++++ libtme/Makefile.in 2006-07-29 14:31:20.000000000 +0900
+@@ -195,9 +195,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/misc.Plo ./$(DEPDIR)/module.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/threads-sjlj.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+
+--- machine/sun/Makefile.in.orig 2005-05-15 10:26:22.000000000 +0900
++++ machine/sun/Makefile.in 2006-07-29 14:33:37.000000000 +0900
+@@ -205,9 +205,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun-mmu.Plo ./$(DEPDIR)/sun-obie.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun-si.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
++++ machine/sun2/Makefile.in 2006-07-29 14:33:45.000000000 +0900
+@@ -230,9 +230,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun2-mainbus.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun2-mmu.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- machine/sun3/Makefile.in.orig 2005-05-15 10:26:23.000000000 +0900
++++ machine/sun3/Makefile.in 2006-07-29 14:33:54.000000000 +0900
+@@ -230,9 +230,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun3-mainbus.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/sun3-mmu.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- scsi/Makefile.in.orig 2005-05-15 10:26:23.000000000 +0900
++++ scsi/Makefile.in 2006-07-29 14:31:42.000000000 +0900
+@@ -235,9 +235,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/scsi-disk.Plo ./$(DEPDIR)/scsi-msg.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/scsi-tape.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- serial/Makefile.in.orig 2005-05-15 10:26:24.000000000 +0900
++++ serial/Makefile.in 2006-07-29 14:31:54.000000000 +0900
+@@ -228,9 +228,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/ms-mssystems.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/serial-kb.Plo ./$(DEPDIR)/serial-ms.Plo
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+--- tmesh/Makefile.in.orig 2005-05-15 10:26:27.000000000 +0900
++++ tmesh/Makefile.in 2006-07-29 14:32:10.000000000 +0900
+@@ -200,9 +200,10 @@
+ @AMDEP_TRUE@ ./$(DEPDIR)/tmesh-input.Plo \
+ @AMDEP_TRUE@ ./$(DEPDIR)/tmesh-util.Plo ./$(DEPDIR)/tmesh.Po
+ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CFLAGS_NO_STRICT_ALIASING)
+ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
+- $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
++ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
++ $(CFLAGS_NO_STRICT_ALIASING)
+ CCLD = $(CC)
+ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
diff --git a/emulators/tme/patches/patch-aj b/emulators/tme/patches/patch-aj
new file mode 100644
index 00000000000..bdef2ca3613
--- /dev/null
+++ b/emulators/tme/patches/patch-aj
@@ -0,0 +1,13 @@
+$NetBSD: patch-aj,v 1.1 2007/03/17 13:44:18 tsutsui Exp $
+
+--- dist/softfloat/softfloat/bits64/softfloat.c.orig 2005-05-11 09:06:30.000000000 +0900
++++ dist/softfloat/softfloat/bits64/softfloat.c 2007-01-07 22:08:03.000000000 +0900
+@@ -4909,7 +4909,7 @@
+ sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 );
+ } while ( 0 <= (sbits64) aSig0 );
+ add128(
+- aSig0, aSig1, alternateASig0, alternateASig1, &sigMean0, &sigMean1 );
++ aSig0, aSig1, alternateASig0, alternateASig1, (bits64 *)&sigMean0, &sigMean1 );
+ if ( ( sigMean0 < 0 )
+ || ( ( ( sigMean0 | sigMean1 ) == 0 ) && ( q & 1 ) ) ) {
+ aSig0 = alternateASig0;
diff --git a/emulators/tme/patches/patch-ak b/emulators/tme/patches/patch-ak
new file mode 100644
index 00000000000..bb589ed0b26
--- /dev/null
+++ b/emulators/tme/patches/patch-ak
@@ -0,0 +1,13 @@
+$NetBSD: patch-ak,v 1.1 2007/03/17 13:44:18 tsutsui Exp $
+
+--- scsi/scsi-cdb.c.orig 2004-12-06 12:40:33.000000000 +0900
++++ scsi/scsi-cdb.c 2006-07-29 15:14:52.000000000 +0900
+@@ -187,7 +187,7 @@
+ /* this adds one of the inquiry strings to the data: */
+ static tme_uint8_t *
+ _tme_scsi_device_make_inquiry_string(tme_uint8_t *data,
+- const tme_uint8_t *string,
++ char *string,
+ unsigned int size)
+ {
+ tme_uint8_t c;
diff --git a/emulators/tme/patches/patch-al b/emulators/tme/patches/patch-al
new file mode 100644
index 00000000000..1a1f57ce02d
--- /dev/null
+++ b/emulators/tme/patches/patch-al
@@ -0,0 +1,30 @@
+$NetBSD: patch-al,v 1.1 2007/03/17 13:44:18 tsutsui Exp $
+
+--- host/gtk/gtk-mouse.c.orig 2003-07-31 10:41:48.000000000 +0900
++++ host/gtk/gtk-mouse.c 2006-07-29 15:04:20.000000000 +0900
+@@ -312,8 +312,8 @@
+ gdk_window_get_geometry(screen->tme_gtk_screen_gtkimage->window,
+ &junk,
+ &junk,
+- &screen->tme_gtk_screen_mouse_warp_x,
+- &screen->tme_gtk_screen_mouse_warp_y,
++ (gint *)&screen->tme_gtk_screen_mouse_warp_x,
++ (gint *)&screen->tme_gtk_screen_mouse_warp_y,
+ &junk);
+ screen->tme_gtk_screen_mouse_warp_x >>= 1;
+ screen->tme_gtk_screen_mouse_warp_y >>= 1;
+@@ -626,12 +626,12 @@
+ /* create the mouse cursor: */
+ source
+ = gdk_bitmap_create_from_data(NULL,
+- _tme_gtk_mouse_cursor_source,
++ (const gchar *)_tme_gtk_mouse_cursor_source,
+ TME_GTK_MOUSE_CURSOR_WIDTH,
+ TME_GTK_MOUSE_CURSOR_HEIGHT);
+ mask
+ = gdk_bitmap_create_from_data (NULL,
+- _tme_gtk_mouse_cursor_mask,
++ (const gchar *)_tme_gtk_mouse_cursor_mask,
+ TME_GTK_MOUSE_CURSOR_WIDTH,
+ TME_GTK_MOUSE_CURSOR_HEIGHT);
+ display->tme_gtk_display_mouse_cursor
diff --git a/emulators/tme/patches/patch-am b/emulators/tme/patches/patch-am
new file mode 100644
index 00000000000..2c630de6059
--- /dev/null
+++ b/emulators/tme/patches/patch-am
@@ -0,0 +1,13 @@
+$NetBSD: patch-am,v 1.1 2007/03/17 13:44:18 tsutsui Exp $
+
+--- ic/m68k/m68k-bus-auto.c.orig 2005-03-23 11:24:55.000000000 +0900
++++ ic/m68k/m68k-bus-auto.c 2006-07-29 14:46:47.000000000 +0900
+@@ -156,7 +156,7 @@
+ };
+
+ /* the 32-bit bus router used on the 68020 and 68030: */
+-static const tme_bus_lane_t tme_m68k_router_32[TME_M68K_BUS_ROUTER_SIZE(TME_BUS32_LOG2)] = {
++const tme_bus_lane_t tme_m68k_router_32[TME_M68K_BUS_ROUTER_SIZE(TME_BUS32_LOG2)] = {
+
+ /* [m68k] initiator maximum cycle size: 8 bits
+ [m68k] initiator A1,A0: 00
diff --git a/emulators/tme/patches/patch-an b/emulators/tme/patches/patch-an
new file mode 100644
index 00000000000..eaea60ac50f
--- /dev/null
+++ b/emulators/tme/patches/patch-an
@@ -0,0 +1,30 @@
+$NetBSD: patch-an,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- machine/sun/sun-si.c.orig 2005-02-17 21:19:17.000000000 +0900
++++ machine/sun/sun-si.c 2006-07-29 14:59:24.000000000 +0900
+@@ -475,7 +475,6 @@
+ tme_uint32_t csr_old, csr_new, csr_diff, csr_mask;
+ tme_bus_addr_t address;
+ tme_uint8_t cycle_size;
+- tme_uint32_t csr;
+ tme_uint32_t dma_count;
+ int new_callouts;
+
+@@ -561,7 +560,7 @@
+ case TME_SUN_SI_TYPE_VME:
+ TME_SUN_SI_REG16_PUT(sun_si, TME_SUN_SI_REG_FIFO_COUNT_L, 0);
+ TME_SUN_SI_REG16_PUT(sun_si, TME_SUN_SI_REG_VME_FIFO_COUNT_H, 0);
+- csr &= ~TME_SUN_SI_CSR_VME_LOB_MASK;
++ csr_new &= ~TME_SUN_SI_CSR_VME_LOB_MASK;
+ break;
+ case TME_SUN_SI_TYPE_COBRA:
+ abort();
+@@ -1428,7 +1427,7 @@
+ sun_si = tme_new0(struct tme_sun_si, 1);
+ sun_si->tme_sun_si_type = si_type;
+ sun_si->tme_sun_si_3e_dma = (si_type == TME_SUN_SI_TYPE_3E
+- ? tme_new(char, TME_SUN_SI_3E_SIZ_DMA)
++ ? tme_new(unsigned char, TME_SUN_SI_3E_SIZ_DMA)
+ : NULL);
+ sun_si->tme_sun_si_element = element;
+ TME_SUN_SI_CSR_PUT(sun_si,
diff --git a/emulators/tme/patches/patch-ap b/emulators/tme/patches/patch-ap
new file mode 100644
index 00000000000..f983a7f2c6c
--- /dev/null
+++ b/emulators/tme/patches/patch-ap
@@ -0,0 +1,20 @@
+$NetBSD: patch-ap,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- host/gtk/gtk-keyboard.c.orig 2006-10-19 10:39:26.000000000 -0400
++++ host/gtk/gtk-keyboard.c 2006-10-19 10:39:50.000000000 -0400
+@@ -399,6 +399,7 @@
+ = display->tme_gtk_display_keyboard_keysyms_bad;
+
+ /* log the complaint: */
++#ifndef NDEBUG
+ tme_log(&display->tme_gtk_display_element->tme_element_log_handle, 0, ENOENT,
+ (&display->tme_gtk_display_element->tme_element_log_handle,
+ _("cannot generate keysym '%s' directly%s"),
+@@ -407,6 +408,7 @@
+ == TME_KEYBOARD_LOOKUP_FLAG_OK_DIRECT
+ ? ""
+ : _(", or through a macro"))));
++#endif
+
+ /* free this record: */
+ display->tme_gtk_display_keyboard_keysyms_bad
diff --git a/emulators/tme/patches/patch-aq b/emulators/tme/patches/patch-aq
new file mode 100644
index 00000000000..f180e4d6fb3
--- /dev/null
+++ b/emulators/tme/patches/patch-aq
@@ -0,0 +1,169 @@
+$NetBSD: patch-aq,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- ic/m68k/m68k-insns.c.orig 2005-03-23 20:53:02.000000000 +0900
++++ ic/m68k/m68k-insns.c 2007-03-14 20:28:31.000000000 +0900
+@@ -485,9 +485,8 @@
+ TME_M68K_INSN(tme_m68k_cmp2_chk2)
+ {
+ tme_uint32_t ireg;
+- unsigned int size_bytes, size_name, size_ireg;
++ unsigned int size_bytes, size_ireg;
+ tme_uint32_t uvalue, ulower, uupper;
+- tme_int32_t value, lower, upper;
+
+ TME_M68K_INSN_CANFAULT;
+
+@@ -495,60 +494,109 @@
+ ireg = TME_M68K_IREG_D0 + TME_FIELD_EXTRACTU(TME_M68K_INSN_SPECOP, 12, 4);
+ size_bytes = TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE, 9, 2);
+ size_ireg = 2 - size_bytes;
+- size_name = TME_M68K_SIZE_8 + size_bytes;
++
++ /* size comes back from cp2 instruction as:
++ 0 : byte
++ 1 : word
++ 2 : long
++ we convert to
++ 0 : byte
++ 1 : word
++ 4 : long
++ */
+ size_bytes = 1 << size_bytes;
+
+ /* read in the two bounds: */
+- (*_tme_m68k_read_mem[size_name])(ic, TME_M68K_IREG_MEMX32 << size_ireg);
++ (*_tme_m68k_read_mem[size_bytes])(ic, TME_M68K_IREG_MEMX32 << size_ireg);
+ if (!TME_M68K_SEQUENCE_RESTARTING) {
+ ic->_tme_m68k_ea_address += size_bytes;
+ }
+- (*_tme_m68k_read_mem[size_name])(ic, TME_M68K_IREG_MEMY32 << size_ireg);
++ (*_tme_m68k_read_mem[size_bytes])(ic, TME_M68K_IREG_MEMY32 << size_ireg);
+
+- /* if we have an address register, sign-extend the bounds to 32
+- bits: */
++ /* if value is an address register, sign-extend the bounds to 32 bits,
++ then set size of bounds and value to 32 bits (so we check entire
++ longword value)
++ */
+ if (ireg >= TME_M68K_IREG_A0) {
+- if (size_name == TME_M68K_SIZE_8) {
++ if (size_bytes == TME_M68K_SIZE_8) {
+ ic->tme_m68k_ireg_int32(TME_M68K_IREG_MEMX32) = TME_EXT_S8_S32(ic->tme_m68k_ireg_int8(TME_M68K_IREG_MEMX8));
+ ic->tme_m68k_ireg_int32(TME_M68K_IREG_MEMY32) = TME_EXT_S8_S32(ic->tme_m68k_ireg_int8(TME_M68K_IREG_MEMY8));
+ }
+- else if (size_name == TME_M68K_SIZE_16) {
++ else if (size_bytes == TME_M68K_SIZE_16) {
+ ic->tme_m68k_ireg_int32(TME_M68K_IREG_MEMX32) = TME_EXT_S16_S32(ic->tme_m68k_ireg_int16(TME_M68K_IREG_MEMX16));
+ ic->tme_m68k_ireg_int32(TME_M68K_IREG_MEMY32) = TME_EXT_S16_S32(ic->tme_m68k_ireg_int16(TME_M68K_IREG_MEMY16));
+ }
+- size_bytes = sizeof(tme_uint32_t);
+- size_name = TME_M68K_SIZE_32;
++ size_bytes = TME_M68K_SIZE_32;
+ }
+
+- /* get the values to check: */
+- switch (size_name) {
++ /* get the bounds and value */
++ switch (size_bytes) {
+ case TME_M68K_SIZE_8:
+- uvalue = ic->tme_m68k_ireg_uint8(ireg);
+ ulower = ic->tme_m68k_ireg_uint8(TME_M68K_IREG_MEMX8);
+ uupper = ic->tme_m68k_ireg_uint8(TME_M68K_IREG_MEMY8);
+- value = ic->tme_m68k_ireg_int8(ireg);
+- lower = ic->tme_m68k_ireg_int8(TME_M68K_IREG_MEMX8);
+- upper = ic->tme_m68k_ireg_int8(TME_M68K_IREG_MEMY8);
++
++ /* if value is a data register, read the entire register, extract
++ the appropriate number of bytes, and sign extend to our own
++ longword size for comparison.
++ if value is an address register, just use the entire register as is
++ */
++ if (ireg < TME_M68K_IREG_A0)
++ uvalue = (tme_uint32_t)TME_EXT_S8_S32
++ ((tme_int32_t)(ic->tme_m68k_ireg_uint32(ireg) & 0xFF));
++ else
++ uvalue = ic->tme_m68k_ireg_uint32(ireg);
++
+ break;
+ case TME_M68K_SIZE_16:
+- uvalue = ic->tme_m68k_ireg_uint16(ireg);
+ ulower = ic->tme_m68k_ireg_uint16(TME_M68K_IREG_MEMX16);
+ uupper = ic->tme_m68k_ireg_uint16(TME_M68K_IREG_MEMY16);
+- value = ic->tme_m68k_ireg_int16(ireg);
+- lower = ic->tme_m68k_ireg_int16(TME_M68K_IREG_MEMX16);
+- upper = ic->tme_m68k_ireg_int16(TME_M68K_IREG_MEMY16);
++
++ /* if value is a data register, read the entire register, extract
++ the appropriate number of bytes, and sign extend to our own
++ longword size for comparison.
++ if value is an address register, just use the entire register as is
++ */
++ if (ireg < TME_M68K_IREG_A0)
++ uvalue = (tme_uint32_t)TME_EXT_S16_S32
++ ((tme_int32_t)(ic->tme_m68k_ireg_uint32(ireg) & 0xFFFF));
++ else
++ uvalue = ic->tme_m68k_ireg_uint32(ireg);
++
+ break;
+ case TME_M68K_SIZE_32:
+- uvalue = ic->tme_m68k_ireg_uint32(ireg);
+ ulower = ic->tme_m68k_ireg_uint32(TME_M68K_IREG_MEMX32);
+ uupper = ic->tme_m68k_ireg_uint32(TME_M68K_IREG_MEMY32);
+- value = ic->tme_m68k_ireg_int32(ireg);
+- lower = ic->tme_m68k_ireg_int32(TME_M68K_IREG_MEMX32);
+- upper = ic->tme_m68k_ireg_int32(TME_M68K_IREG_MEMY32);
++
++ uvalue = ic->tme_m68k_ireg_uint32(ireg);
++
+ break;
+ default: abort();
+ }
+
++ /* cmp2 / chk2 can be used for unsigned, or signed.
++ for either type, the lower bound "should be" <= upper bound
++ (per m68000 family programmer's reference manual)
++
++ cmp2 instruction doesn't know if signed or unsigned
++ if bound 250 250 then bound is the one value, check unsigned or signed
++
++ if bound 253 255 could be unsigned 253 255
++ or signed -3 -1
++ either way, ok to check.
++
++ if bound 255 5 then only makes sense to check signed -1 5
++
++ if bound 255 253 then doesn't make sense either way!
++ its either 255 253 unsigned or -1 -3 signed.
++
++ reverse engineering the code, by running many test cases shows that
++ the motorola 68020 microcode does the following.
++
++ Always check unsigned.
++ if low <= high, then out of bounds if either < low or > high.
++ if high > low, then out of bounds if BOTH < low AND > high.
++ */
++
+ /* do the comparison. if the value is out-of-bounds and this is
+ a chk2 instruction, trap: */
+ ic->tme_m68k_ireg_ccr = (ic->tme_m68k_ireg_ccr & TME_M68K_FLAG_X);
+@@ -556,13 +604,14 @@
+ || uvalue == uupper) {
+ ic->tme_m68k_ireg_ccr |= TME_M68K_FLAG_Z;
+ }
+- else if ((ulower > uupper)
+- /* signed comparison: */
+- ? (value < lower || value > upper)
+- /* unsigned comparison: */
+- : (uvalue < ulower || uvalue > uupper)) {
++ else if (((ulower <= uupper) && (uvalue < ulower || uvalue > uupper)) ||
++ ((ulower > uupper) && (uvalue < ulower && uvalue > uupper))) {
+ ic->tme_m68k_ireg_ccr |= TME_M68K_FLAG_C;
+- if (TME_M68K_INSN_OPCODE & TME_BIT(11)) {
++
++ /* if chk2 instruction,
++ also cause a CHK instruction exception (vector number 6)
++ */
++ if (TME_FIELD_EXTRACTU(TME_M68K_INSN_SPECOP, 11, 1)) {
+ ic->tme_m68k_ireg_pc_last = ic->tme_m68k_ireg_pc;
+ ic->tme_m68k_ireg_pc = ic->tme_m68k_ireg_pc_next;
+ TME_M68K_INSN_EXCEPTION(TME_M68K_EXCEPTION_INST(TME_M68K_VECTOR_CHK));
diff --git a/emulators/tme/patches/patch-ar b/emulators/tme/patches/patch-ar
new file mode 100644
index 00000000000..f55af0f75aa
--- /dev/null
+++ b/emulators/tme/patches/patch-ar
@@ -0,0 +1,23 @@
+$NetBSD: patch-ar,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- ic/m68k/m68k-execute.c.orig 2006-10-01 08:23:58.000000000 -0400
++++ ic/m68k/m68k-execute.c 2006-10-01 08:27:17.000000000 -0400
+@@ -591,6 +591,18 @@
+ _TME_M68K_EXECUTE_FETCH_S16(ea_bd);
+ /* XXX simulates preincremented pc: */
+ ea_address = ic->tme_m68k_ireg_pc + first_ea_extword_offset + ea_bd;
++
++ /* if instruction has immediate, then we need to add either 2 bytes
++ (for byte or word) or 4 bytes (for lword) to get the effective
++ address
++ */
++ if (TME_M68K_OPCODE_HAS_IMM(params)) {
++ if (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,2) == 2)
++ ea_address = ea_address + 4;
++ else
++ ea_address = ea_address + 2;
++ }
++
+ ea_function_code = function_code_program;
+ break;
+ }
diff --git a/emulators/tme/patches/patch-aw b/emulators/tme/patches/patch-aw
new file mode 100644
index 00000000000..1489dac125f
--- /dev/null
+++ b/emulators/tme/patches/patch-aw
@@ -0,0 +1,84 @@
+$NetBSD: patch-aw,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- host/posix/posix-serial.c.orig 2006-11-07 06:29:39.000000000 -0500
++++ host/posix/posix-serial.c 2006-11-07 08:23:59.000000000 -0500
+@@ -839,6 +839,8 @@
+ int saved_errno;
+ int emulate_break;
+
++ int ignore_fd_in = FALSE;
++
+ /* initialize: */
+ filename_in = NULL;
+ filename_out = NULL;
+@@ -915,24 +917,32 @@
+
+ /* open the devices: */
+ fd_in = fd_out = -1;
+- if (fd_in < 0
+- && !strcmp(filename_in, "-")) {
+- fd_in = STDIN_FILENO;
++
++ ignore_fd_in = (strcmp(filename_in,"NONE") == 0);
++
++ if (!ignore_fd_in) {
++ if (fd_in < 0
++ && !strcmp(filename_in, "-")) {
++ fd_in = STDIN_FILENO;
++ }
+ }
+ if (fd_out < 0
+ && !strcmp(filename_out, "-")) {
+ fd_out = STDOUT_FILENO;
+ }
+- if (fd_in < 0) {
+- if (strcmp(filename_in, filename_out) == 0) {
+- fd_in = fd_out = open(filename_in, O_RDWR | O_NONBLOCK);
+- }
+- else {
+- fd_in = open(filename_in, O_RDONLY | O_NONBLOCK);
+- }
++
++ if (!ignore_fd_in) {
+ if (fd_in < 0) {
+- tme_output_append_error(_output, "%s", filename_in);
+- return (errno);
++ if (strcmp(filename_in, filename_out) == 0) {
++ fd_in = fd_out = open(filename_in, O_RDWR | O_NONBLOCK);
++ }
++ else {
++ fd_in = open(filename_in, O_RDONLY | O_NONBLOCK);
++ }
++ if (fd_in < 0) {
++ tme_output_append_error(_output, "%s", filename_in);
++ return (errno);
++ }
+ }
+ }
+ if (fd_out < 0) {
+@@ -962,7 +972,11 @@
+ tme_mutex_init(&serial->tme_posix_serial_mutex);
+ tme_cond_init(&serial->tme_posix_serial_cond_writer);
+ tme_thread_create((tme_thread_t) _tme_posix_serial_th_writer, serial);
+- tme_thread_create((tme_thread_t) _tme_posix_serial_th_reader, serial);
++
++ if (!ignore_fd_in) {
++ tme_thread_create((tme_thread_t) _tme_posix_serial_th_reader, serial);
++ }
++
+ tme_thread_create((tme_thread_t) _tme_posix_serial_th_ctrl, serial);
+
+ /* fill the element: */
+--- libtme/threads-sjlj.c.orig 2006-11-07 06:50:22.000000000 -0500
++++ libtme/threads-sjlj.c 2006-11-07 07:54:07.000000000 -0500
+@@ -833,7 +833,9 @@
+ if (fd_condition_new != 0) {
+
+ /* this thread is now blocking on this fd: */
+- assert(tme_sjlj_fd_thread[fd] == NULL);
++
++ /* assert if this fd is already used - unless its stdin */
++ assert(tme_sjlj_fd_thread[fd] == NULL || fd == STDIN_FILENO);
+ tme_sjlj_fd_thread[fd] = thread;
+
+ #ifdef HAVE_GTK
diff --git a/emulators/tme/patches/patch-ax b/emulators/tme/patches/patch-ax
new file mode 100644
index 00000000000..b57b1eff3a6
--- /dev/null
+++ b/emulators/tme/patches/patch-ax
@@ -0,0 +1,19 @@
+$NetBSD: patch-ax,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- host/bsd/bsd-bpf.c.orig 2007-03-14 20:49:03.000000000 +0900
++++ host/bsd/bsd-bpf.c 2007-03-14 20:51:14.000000000 +0900
+@@ -694,6 +701,14 @@
+ < the_bpf_header.bh_tstamp.tv_usec))) {
+
+ /* set the sleep time: */
++
++ /* if asserting, print likely description first */
++ if (! ((bpf->tme_bsd_bpf_delay_release.tv_sec
++ == the_bpf_header.bh_tstamp.tv_sec)
++ || ((bpf->tme_bsd_bpf_delay_release.tv_sec + 1)
++ == the_bpf_header.bh_tstamp.tv_sec))) {
++ printf("someone started a second tmesh without this tmesh first configuring ie0\n");
++ }
+ assert ((bpf->tme_bsd_bpf_delay_release.tv_sec
+ == the_bpf_header.bh_tstamp.tv_sec)
+ || ((bpf->tme_bsd_bpf_delay_release.tv_sec + 1)
diff --git a/emulators/tme/patches/patch-az b/emulators/tme/patches/patch-az
new file mode 100644
index 00000000000..cec0cdb38cd
--- /dev/null
+++ b/emulators/tme/patches/patch-az
@@ -0,0 +1,343 @@
+$NetBSD: patch-az,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- ic/i825x6.c.orig 2007-03-15 20:29:47.000000000 +0900
++++ ic/i825x6.c 2007-03-17 22:07:48.000000000 +0900
+@@ -809,6 +809,9 @@
+ | TME_I825X6_SCB_CUS_IDLE
+ | TME_I825X6_SCB_RUS_IDLE);
+
++ /* clears the SCB command word": */
++ /* [this is done at end of this routine] */
++
+ /* "The 82596 ... sends an interrupt to the CPU": */
+ i825x6->tme_i825x6_callout_flags = TME_I825X6_CALLOUTS_RUNNING | TME_I825X6_CALLOUT_INT;
+ }
+@@ -1258,8 +1261,10 @@
+ break;
+
+ case TME_I825X6_CB_CMD_DUMP:
+- case TME_I825X6_CB_CMD_DIAGNOSE:
+ abort();
++
++ case TME_I825X6_CB_CMD_DIAGNOSE:
++ break;
+ }
+
+ /* add to the callouts and return the current status: */
+@@ -1898,7 +1903,7 @@
+ tme_uint16_t c_b_ok_a;
+ tme_uint16_t value16;
+ tme_uint32_t value32;
+- int rc, err;
++ int rc, err, tot_length;
+
+ /* recover our data structures: */
+ i825x6 = conn_eth->tme_ethernet_connection.tme_connection_element->tme_element_private;
+@@ -1919,7 +1924,7 @@
+ tme_mutex_lock(&i825x6->tme_i825x6_mutex);
+
+ /* assume that we will have no packet to transmit: */
+- rc = 0;
++ tot_length = 0;
+
+ /* if we have a packet to transmit: */
+ if ((i825x6->tme_i825x6_el_s_i_cmd
+@@ -1934,10 +1939,10 @@
+ #define CHUNKS_DMA_TX(addr, size) \
+ err = _tme_i825x6_chunks_dma_tx(i825x6, frame_chunks, (addr), (size)); \
+ if (err != TME_OK) break; \
+- rc += size
++ tot_length += size
+ #define CHUNKS_MEM_TX(data, size) \
+ _tme_i825x6_chunks_mem_tx(frame_chunks, (data), (size)); \
+- rc += size
++ tot_length += size
+
+ /* if AL-LOC is set to zero, add the Ethernet/802.3 MAC header: */
+ if (i825x6->tme_i825x6_al_loc == 0) {
+@@ -1973,7 +1978,7 @@
+ CHUNKS_DMA_TX(tb_address,
+ (eof_size & TME_I82586_TBD_SIZE_MASK));
+
+- /* the next transmit buffer: */
++ /* get out if no next transmit buffer: */
+ if (eof_size & TME_I82586_TBD_EOF) {
+ break;
+ }
+@@ -2022,7 +2027,7 @@
+ tme_mutex_unlock(&i825x6->tme_i825x6_mutex);
+
+ /* done: */
+- return (rc);
++ return (tot_length);
+ }
+
+ /* this makes a new Ethernet connection: */
+--- host/bsd/bsd-bpf.c.orig2 2006-12-13 08:07:09.000000000 -0500
++++ host/bsd/bsd-bpf.c 2006-12-13 11:38:27.000000000 -0500
+@@ -292,7 +292,7 @@
+ struct tme_ethernet_connection *conn_eth;
+ int callouts, later_callouts;
+ unsigned int ctrl;
+- int rc;
++ int rc, status;
+ tme_ethernet_fid_t frame_id;
+ struct tme_ethernet_frame_chunk frame_chunk_buffer;
+ tme_uint8_t frame[TME_ETHERNET_FRAME_MAX];
+@@ -372,6 +372,9 @@
+ &frame_id,
+ &frame_chunk_buffer,
+ TME_ETHERNET_READ_NEXT)));
++
++ /* ensure don't get back bad length from i825x6 */
++ assert(rc <= sizeof(frame));
+
+ /* lock the mutex: */
+ tme_mutex_lock(&bpf->tme_bsd_bpf_mutex);
+@@ -380,7 +383,11 @@
+ if (rc > 0) {
+
+ /* do the write: */
+- tme_thread_write(bpf->tme_bsd_bpf_fd, frame, rc);
++ status = tme_thread_write(bpf->tme_bsd_bpf_fd, frame, rc);
++
++ /* assert if write failed. also assert if we wrote less bytes
++ than we commanded */
++ assert (status == rc);
+
+ /* mark that we need to loop to callout to read more frames: */
+ bpf->tme_bsd_bpf_callout_flags |= TME_BSD_BPF_CALLOUT_READ;
+--- machine/sun/sun-obie.c.orig 2005-02-17 07:37:25.000000000 -0500
++++ machine/sun/sun-obie.c 2006-12-19 05:34:13.000000000 -0500
+@@ -78,7 +78,6 @@
+ #define TME_SUN_OBIE_CALLOUT_RUNNING TME_BIT(0)
+ #define TME_SUN_OBIE_CALLOUTS_MASK (-2)
+ #define TME_SUN_OBIE_CALLOUT_SIGNALS TME_BIT(1)
+-#define TME_SUN_OBIE_CALLOUT_INT TME_BIT(2)
+
+ /* structures: */
+
+@@ -106,8 +105,15 @@
+ /* the callout flags: */
+ int tme_sun_obie_callout_flags;
+
+- /* if our interrupt line is currently asserted: */
+- int tme_sun_obie_int_asserted;
++ /* the obie CSR interrupt enable bit has been set since powerup */
++ int csr_ie_has_been_set;
++
++ /* the i825x6 interrupt is currently active to the obie */
++ int i825x6_interrupt_is_active;
++
++ /* the obie interrupt (forward of the i825x6 interrupt) is currently active
++ to the bus */
++ int obie_interrupt_is_active;
+
+ /* it's easiest to just model the board registers as a chunk of memory: */
+ tme_uint8_t tme_sun_obie_regs[TME_SUN_OBIE_SIZ_REGS];
+@@ -137,17 +143,67 @@
+ static const struct tme_bus_signals _tme_sun_obie_bus_signals_generic = TME_BUS_SIGNALS_GENERIC;
+ static const struct tme_bus_signals _tme_sun_obie_bus_signals_i825x6 = TME_BUS_SIGNALS_I825X6;
+
++
++/* TME originally never set or cleared TME_SUN_OBIE_CSR_INTR in the obie CSR.
++ * This worked fine for running NetBSD inside the emulator, as the NetBSD ie0
++ * driver never checked that bit. But SunOS 4.1.1 does.
++ * Following is the logic that makes NetBSD and SunOS work inside the
++ * emulator (and therefore is likely close to the logic of the actual OBIE
++ * hardware: The Sun-2 MultiBus Ethernet Controller, part 501-1004).
++ *
++ * When i825x6 chip asserts/deasserts an interrupt to OBIE:
++ * 1) set or clear TME_SUN_OBIE_CSR_INTR as appropriate
++ * and, if the TME_SUN_OBIE_IE (interrupt enable) has ever been set:
++ * 2) pass along signal to main bus.
++ *
++ * Note:
++ * When correcting the TME code to work with SunOS, I originally only
++ * forwarded the interrupt when IE was active, but SunOS fails five minutes
++ * after bootup (complaining about level 3 interrupt) with this arrangement.
++ *
++ * So the actual use of the IE bit remains a mystery. It is likely sufficient
++ * to ignore the IE bit and always pass along the i825x6 interrupt to the main
++ * bus. But the current "has been set" IE logic allows NetBSD and SunOS to
++ * fully run ethernet correctly inside the emulator, and that's good enough
++ * for me. ART
++ */
++
++static void
++_possibly_set_csr_intr_bit(struct tme_sun_obie *sun_obie)
++{
++ tme_uint16_t csr;
++
++ csr = TME_SUN_OBIE_CSR_GET(sun_obie);
++ sun_obie->csr_ie_has_been_set |=
++ ((csr & TME_SUN_OBIE_CSR_IE) == TME_SUN_OBIE_CSR_IE);
++
++ /* if a change in interrupt status */
++ if (sun_obie->obie_interrupt_is_active != sun_obie->i825x6_interrupt_is_active) {
++
++ /* transition to assert */
++ if (!sun_obie->obie_interrupt_is_active) {
++ csr = (csr | TME_SUN_OBIE_CSR_INTR);
++ }
++
++ /* transition to deassert */
++ else {
++ csr = (csr & ~TME_SUN_OBIE_CSR_INTR);
++ }
++
++ TME_SUN_OBIE_CSR_PUT(sun_obie, csr);
++ sun_obie->obie_interrupt_is_active = sun_obie->i825x6_interrupt_is_active;
++ }
++}
++
+ /* the sun_obie callout function. it must be called with the mutex locked: */
+ static void
+ _tme_sun_obie_callout(struct tme_sun_obie *sun_obie, int new_callouts)
+ {
+ struct tme_bus_connection *conn_i825x6;
+- struct tme_bus_connection *conn_bus;
+ tme_uint16_t csr, csr_diff;
+ unsigned int signal, level;
+ int callouts, later_callouts;
+ int rc;
+- int int_asserted;
+
+ /* add in any new callouts: */
+ sun_obie->tme_sun_obie_callout_flags |= new_callouts;
+@@ -176,6 +232,8 @@
+
+ /* get the current CSR value: */
+ csr = TME_SUN_OBIE_CSR_GET(sun_obie);
++ sun_obie->csr_ie_has_been_set |=
++ ((csr & TME_SUN_OBIE_CSR_IE) == TME_SUN_OBIE_CSR_IE);
+
+ /* get the next signal to call out to the i825x6: */
+ csr_diff = ((csr
+@@ -230,7 +288,10 @@
+ (conn_i825x6,
+ signal | level))
+ : TME_OK);
+-
++
++ /* possibly update status of INTR bit in CSR */
++ _possibly_set_csr_intr_bit(sun_obie);
++
+ /* lock the mutex: */
+ tme_mutex_lock(&sun_obie->tme_sun_obie_mutex);
+
+@@ -254,55 +315,6 @@
+ }
+ }
+ }
+-
+- /* if we need to call out a possible change to our interrupt
+- signal: */
+- if (callouts & TME_SUN_OBIE_CALLOUT_INT) {
+-
+- /* get the current CSR value: */
+- csr = TME_SUN_OBIE_CSR_GET(sun_obie);
+-
+- /* see if the interrupt signal should be asserted or negated: */
+- int_asserted = ((csr & (TME_SUN_OBIE_CSR_IE
+- | TME_SUN_OBIE_CSR_INTR))
+- == (TME_SUN_OBIE_CSR_IE
+- | TME_SUN_OBIE_CSR_INTR));
+-
+- /* if the interrupt signal doesn't already have the right state: */
+- if (!int_asserted != !sun_obie->tme_sun_obie_int_asserted) {
+-
+- /* get our bus connection: */
+- conn_bus = sun_obie->tme_sun_obie_conn_regs;
+-
+- /* unlock our mutex: */
+- tme_mutex_unlock(&sun_obie->tme_sun_obie_mutex);
+-
+- /* call out the bus interrupt signal edge: */
+- rc = (conn_bus != NULL
+- ? ((*conn_bus->tme_bus_signal)
+- (conn_bus,
+- TME_BUS_SIGNAL_INT_UNSPEC
+- | (int_asserted
+- ? TME_BUS_SIGNAL_LEVEL_ASSERTED
+- : TME_BUS_SIGNAL_LEVEL_NEGATED)))
+- : TME_OK);
+-
+- /* lock our mutex: */
+- tme_mutex_lock(&sun_obie->tme_sun_obie_mutex);
+-
+- /* if this callout was successful, note the new state of the
+- interrupt signal: */
+- if (rc == TME_OK) {
+- sun_obie->tme_sun_obie_int_asserted = int_asserted;
+- }
+-
+- /* otherwise, remember that at some later time this callout
+- should be attempted again: */
+- else {
+- later_callouts |= TME_SUN_OBIE_CALLOUT_INT;
+- }
+- }
+- }
+ }
+
+ /* put in any later callouts, and clear that callouts are running: */
+@@ -321,6 +333,9 @@
+ /* recover our data structure: */
+ sun_obie = (struct tme_sun_obie *) _sun_obie;
+
++ /* possibly update status of INTR bit in CSR */
++ _possibly_set_csr_intr_bit(sun_obie);
++
+ /* assume we won't need any new callouts: */
+ new_callouts = 0;
+
+@@ -329,6 +344,8 @@
+
+ /* get the previous CSR value: */
+ csr_old = TME_SUN_OBIE_CSR_GET(sun_obie);
++ sun_obie->csr_ie_has_been_set |=
++ ((csr_old & TME_SUN_OBIE_CSR_IE) == TME_SUN_OBIE_CSR_IE);
+
+ /* run the cycle: */
+ tme_bus_cycle_xfer_memory(cycle_init,
+@@ -354,12 +371,6 @@
+ new_callouts |= TME_SUN_OBIE_CALLOUT_SIGNALS;
+ }
+
+- /* if this is an interrupt mask change, possibly call out an
+- interrupt signal change to the bus: */
+- if (csr_diff & TME_SUN_OBIE_CSR_IE) {
+- new_callouts |= TME_SUN_OBIE_CALLOUT_INT;
+- }
+-
+ #ifndef TME_NO_LOG
+ if (csr_new != sun_obie->tme_sun_obie_last_log_csr) {
+ sun_obie->tme_sun_obie_last_log_csr = csr_new;
+@@ -397,6 +408,15 @@
+ /* recover our data structures: */
+ sun_obie = conn_bus->tme_bus_connection.tme_connection_element->tme_element_private;
+
++ /* save this information so we'll know it later */
++ sun_obie->i825x6_interrupt_is_active =
++ ((signal & TME_BUS_SIGNAL_LEVEL_ASSERTED) == TME_BUS_SIGNAL_LEVEL_ASSERTED);
++
++ /* return now if interrupt enable has never been set in CSR */
++ if (!sun_obie->csr_ie_has_been_set) {
++ return (TME_OK);
++ }
++
+ /* pass the i825x6's signal through to the obio bus: */
+ conn_bus = sun_obie->tme_sun_obie_conn_regs;
+ return (conn_bus != NULL
+--- ic/i825x6reg.h.orig 2006-12-13 08:27:48.000000000 -0500
++++ ic/i825x6reg.h 2006-12-13 08:28:27.000000000 -0500
+@@ -156,7 +156,7 @@
+ /* the i82586 and 32-bit segmented i82586 Transmit Buffer: */
+ #define TME_I82586_TBD_EOF_SIZE (0)
+ #define TME_I82586_TBD_EOF (0x8000)
+-#define TME_I82586_TBD_SIZE_MASK (0x7fff)
++#define TME_I82586_TBD_SIZE_MASK (0x3fff)
+ #define TME_I82586_TBD_TBD_OFFSET (2)
+ #define TME_I82586_TBD_TB_ADDRESS (4)
+
diff --git a/emulators/tme/patches/patch-ba b/emulators/tme/patches/patch-ba
new file mode 100644
index 00000000000..f29573da6ca
--- /dev/null
+++ b/emulators/tme/patches/patch-ba
@@ -0,0 +1,13 @@
+$NetBSD: patch-ba,v 1.1 2007/03/17 13:44:19 tsutsui Exp $
+
+--- host/gtk/gtk-screen.c.orig 2006-12-18 09:35:14.000000000 -0500
++++ host/gtk/gtk-screen.c 2006-12-18 09:36:18.000000000 -0500
+@@ -537,6 +537,8 @@
+ and auto-shrink: */
+ screen->tme_gtk_screen_window
+ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
++ gtk_window_set_position(GTK_WINDOW(screen->tme_gtk_screen_window),
++ GTK_WIN_POS_CENTER);
+ gtk_window_set_policy(GTK_WINDOW(screen->tme_gtk_screen_window),
+ TRUE, TRUE, TRUE);
+
diff --git a/emulators/tme/patches/patch-bb b/emulators/tme/patches/patch-bb
new file mode 100644
index 00000000000..6d6a3d5eb94
--- /dev/null
+++ b/emulators/tme/patches/patch-bb
@@ -0,0 +1,192 @@
+$NetBSD: patch-bb,v 1.1 2007/03/17 13:44:20 tsutsui Exp $
+
+--- ic/m68k/m68k-insns-auto.sh.orig 2005-03-23 11:09:33.000000000 +0900
++++ ic/m68k/m68k-insns-auto.sh 2007-03-15 01:11:22.000000000 +0900
+@@ -51,8 +51,92 @@
+ _TME_RCSID("\$Id: patch-bb,v 1.1 2007/03/17 13:44:20 tsutsui Exp $");
+
+ EOF
+-if $header; then :; else
++if $header; then
+ cat <<EOF
++
++/* following are to fix the movel sp,-(sp) problem (of the value being pushed
++ on the stack being off by four) and to warn if there are other possible
++ problems that haven't been tested */
++
++#define PREDEC_POSTINC_CONCERN ( \\
++ \\
++/* if source and destination register are the same number */ \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,0,3) == \\
++ TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,9,3)) && \\
++ \\
++/* and both are address registers */ \\
++ ( \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) >= 1) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) <= 6) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) >= 1) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) <= 6) \\
++ ) && \\
++ \\
++/* and there is a predec or postinc in the src, or a predec in dest */ \\
++ ( \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) == 3) || \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) == 4) || \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) == 4) \\
++ ) \\
++ )
++
++
++#define DEST_IS_PREDEC_SRC_IS_REG_BOTH_SP ( \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) == 4) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) == 1) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,0,3) == 7) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,9,3) == 7) \\
++ )
++
++/* following modes test ok */
++#define MODE35_MODE24_OR_MODE54 ( \\
++ \\
++/* src/dest mode 3,5 : this is move.l (a5)+,(028,a5) */ \\
++ ( \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) == 3) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) == 5) \\
++ ) || \\
++ \\
++/* or src/dest mode 2,4 : this is move.l (a5),-(a5) */ \\
++ ( \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) == 2) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) == 4) \\
++ ) || \\
++ \\
++/* or src/dest mode 5,4 : this is move.l (028,a5),-(a5) */ \\
++ ( \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3) == 5) && \\
++ (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3) == 4) \\
++ ) \\
++ )
++
++
++#define PRINT_WEIRD_SRC_DST_REG_MODE(msg) \\
++ printf("%s\nsrc reg: %x src mode: %x dest reg: %x dest mode %x at pc:%x\n", \\
++ msg, \\
++ TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,0,3), \\
++ TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,3), \\
++ TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,9,3), \\
++ TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,6,3), \\
++ ic->tme_m68k_ireg_pc)
++
++
++#define HITRETURN(msg) do { \\
++ printf("%s, pc:0x%08x, insn:0x%08x: please", \\
++ msg, ic->tme_m68k_ireg_pc, TME_M68K_INSN_OPCODE); \\
++ printf(" analyze M68K instruction.\n"); \\
++ printf(" generate test case.\n"); \\
++ printf(" if TME emulation is incorrect, correct problem.\n"); \\
++ printf(" modify source to avoid this message in the future.\n"); \\
++ printf("press any to continue:"); \\
++ (void)getchar(); \\
++ printf("continuing\n"); \\
++} while (0)
++
++EOF
++else
++ cat <<EOF
++#include <stdio.h>
+ #include "m68k-impl.h"
+
+ EOF
+@@ -162,16 +246,16 @@
+ echo ""
+ echo " if (!TME_M68K_SEQUENCE_RESTARTING) {"
+ echo " ic->_tme_m68k_ea_function_code = function_code;"
+- echo " ic->_tme_m68k_ea_address = ic->tme_m68k_ireg_uint32(TME_M68K_IREG_A0 + ireg_dst);"
+- echo " ic->tme_m68k_ireg_uint32(TME_M68K_IREG_A0 + ireg_dst) += ireg_dst_adjust;"
+- echo " }"
+- echo " tme_m68k_read_memx${size}(ic);"
+- echo " if (!TME_M68K_SEQUENCE_RESTARTING) {"
+- echo " ic->_tme_m68k_ea_function_code = function_code;"
+ echo " ic->_tme_m68k_ea_address = ic->tme_m68k_ireg_uint32(TME_M68K_IREG_A0 + ireg_src);"
+ echo " ic->tme_m68k_ireg_uint32(TME_M68K_IREG_A0 + ireg_src) += ireg_src_adjust;"
+ echo " }"
+ echo " tme_m68k_read_mem${size}(ic, TME_M68K_IREG_MEMY${size});"
++ echo " if (!TME_M68K_SEQUENCE_RESTARTING) {"
++ echo " ic->_tme_m68k_ea_function_code = function_code;"
++ echo " ic->_tme_m68k_ea_address = ic->tme_m68k_ireg_uint32(TME_M68K_IREG_A0 + ireg_dst);"
++ echo " ic->tme_m68k_ireg_uint32(TME_M68K_IREG_A0 + ireg_dst) += ireg_dst_adjust;"
++ echo " }"
++ echo " tme_m68k_read_memx${size}(ic);"
+ echo " ${dst} = ic->tme_m68k_ireg_memx${size};"
+ echo " ${src} = ic->tme_m68k_ireg_memy${size};"
+ ;;
+@@ -181,6 +265,12 @@
+ addx|subx)
+ echo " tme_uint16_t memory;"
+ echo ""
++ # sanity checks for addx/subx
++ echo " if ((ireg_src == ireg_dst) &&"
++ echo " (TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,3,1) == 1)) {"
++ echo " HITRETURN(\"weird ${name}${size}\");"
++ echo " }"
++ echo ""
+ echo " memory = (TME_M68K_INSN_OPCODE & TME_BIT(3));"
+ echo " if (memory) {"
+ echo " TME_M68K_INSN_CANFAULT;"
+@@ -239,6 +329,35 @@
+ fi
+ echo ";"
+
++ # check "moveX sp,-(sp)" and adjust res
++ if test ${name} = move; then
++ echo ""
++ echo " if (PREDEC_POSTINC_CONCERN) {"
++ echo " if (DEST_IS_PREDEC_SRC_IS_REG_BOTH_SP) {"
++ if test ${size} = 8; then
++ echo " printf(\"ERROR: ${name}${size}: how can addr/addr be 8 bits? at pc:%x\\n\","
++ echo " ic->tme_m68k_ireg_pc);"
++ else
++ echo "#if 0"
++ echo " printf(\"${name}${size}: chg predec dest res from:%x to %x for register %d at pc %x\\n\","
++ echo " res, res + (${size} / 8), TME_FIELD_EXTRACTU(TME_M68K_INSN_OPCODE,0,3), ic->tme_m68k_ireg_pc);"
++ echo "#endif"
++ echo " res = res + (${size} / 8);"
++ fi
++ echo " } else if (!(MODE35_MODE24_OR_MODE54)) {"
++ echo " PRINT_WEIRD_SRC_DST_REG_MODE(\"WEIRD: ${name}${size}\");"
++ echo " }"
++ echo " }"
++ fi
++
++ # sanity check for cmpa16
++ if test ${name} = cmpa; then
++ echo ""
++ echo " if PREDEC_POSTINC_CONCERN {"
++ echo " PRINT_WEIRD_SRC_DST_REG_MODE(\"weird ${name}${size}\");"
++ echo " }"
++ fi
++
+ # store the result:
+ if $store_res; then
+ echo ""
+@@ -362,6 +481,10 @@
+ adda) op='+' ; src="_op0" ; dst="_op1" ;;
+ movea) op='' ; src="_op1" ; dst="_op0" ;;
+ esac
++ echo " if (PREDEC_POSTINC_CONCERN) {"
++ echo " PRINT_WEIRD_SRC_DST_REG_MODE(\"weird ${name}${size}\");"
++ echo " }"
++ echo ""
+ echo " *((tme_int32_t *) ${dst}) ${op}= *((tme_int${size}_t *) ${src});"
+ echo " TME_M68K_INSN_OK;"
+ echo "}"
+@@ -801,6 +924,10 @@
+ echo " tme_uint16_t specopy = TME_M68K_INSN_OP0(tme_uint16_t);"
+ echo " tme_uint32_t addrx;"
+ echo " tme_uint32_t addry;"
++ fi
++ echo ""
++ echo " TME_M68K_INSN_CANFAULT;"
++ if test $name = cas2_; then
+ echo ""
+ echo " /* get the function code and addresses we'll be dealing with: */"
+ echo " ic->_tme_m68k_ea_function_code = TME_M68K_FUNCTION_CODE_DATA(ic);"
diff --git a/emulators/tme/patches/patch-bc b/emulators/tme/patches/patch-bc
new file mode 100644
index 00000000000..34f3d585455
--- /dev/null
+++ b/emulators/tme/patches/patch-bc
@@ -0,0 +1,65 @@
+$NetBSD: patch-bc,v 1.1 2007/03/17 13:44:20 tsutsui Exp $
+
+--- ic/ieee754/ieee754-ops-auto.sh.orig 2005-03-23 20:47:37.000000000 +0900
++++ ic/ieee754/ieee754-ops-auto.sh 2007-03-14 22:00:59.000000000 +0900
+@@ -126,7 +126,7 @@
+
+ # generate the operations:
+ #
+- for name in add sub mul div \
++ for name in add cmp sub mul div \
+ rem sqrt abs neg move \
+ rint \
+ cos acos cosh \
+@@ -144,7 +144,7 @@
+ #
+ monadic=true
+ case "${name}" in
+- add | sub | mul | div | rem | pow | scale)
++ add | cmp | sub | mul | div | rem | pow | scale)
+ monadic=false
+ ;;
+ esac
+@@ -243,13 +243,14 @@
+ func_softfloat="${name}"
+ ;;
+ *-add) op_builtin='+' ;;
++ *-cmp) op_builtin='-' ;;
+ *-sub) op_builtin='-' ;;
+ *-mul) op_builtin='*' ;;
+ *-div) op_builtin='/' ;;
+ *-sqrt) func_libm=sqrt ;;
+ partial-abs | unknown-abs) func_libm=fabs ;;
+ strict-neg) op0=0 ; func_softfloat=sub ; op1=src0 ;;
+- partial-neg | unknown-neg) op0=0 ; op_builtin='-'; op1=src0 ;;
++ partial-neg | unknown-neg) op0=-1.0 ; op_builtin='*'; op1=src0 ;;
+ strict-move) func_softfloat=add ; op1=0 ;;
+ *-move) type="${level_stricter}-move" ; src0_buffer=false ;;
+ strict-rint) func_softfloat=round_to_int ;;
+@@ -547,6 +548,15 @@
+ # a builtin operation:
+ #
+ builtin)
++ if test ${name} = "cmp"; then
++
++ echo " if (tme_float_is_inf(src0, TME_FLOAT_FORMAT_IEEE754_${capprecision} ) &"
++ echo " tme_float_is_inf(src1, TME_FLOAT_FORMAT_IEEE754_${capprecision}) &"
++ echo " (tme_float_is_negative(src0, TME_FLOAT_FORMAT_IEEE754_${capprecision}) =="
++ echo " tme_float_is_negative(src1, TME_FLOAT_FORMAT_IEEE754_${capprecision})))"
++ echo " tme_ieee754_${precision}_value_builtin_set(dst, TME_FLOAT_FORMAT_IEEE754_${capprecision}_BUILTIN, 0.0);"
++ echo " else"
++ fi;
+ echo " tme_ieee754_${precision}_value_builtin_set(dst, TME_FLOAT_FORMAT_IEEE754_${capprecision}_BUILTIN, ${op0} ${op_builtin} ${op1});"
+ ;;
+
+--- ic/m68k/m6888x-auto.sh.orig 2006-10-01 08:22:49.000000000 -0400
++++ ic/m68k/m6888x-auto.sh 2006-10-01 08:22:56.000000000 -0400
+@@ -136,7 +136,7 @@
+ 12) name=asin ; fpu_types=TME_M68K_FPU_M6888X ;; # fasin pp 315
+ 10) name=atan ; fpu_types=TME_M68K_FPU_M6888X ;; # fatan pp 318
+ 13) name=atanh ; fpu_types=TME_M68K_FPU_M6888X ;; # fatanh pp 321
+- 56) name=cmp ; name_ieee754=sub ; optype=DST_SRC ;; # fcmp pp 326
++ 56) name=cmp ; optype=DST_SRC ;; # fcmp pp 326
+ 29) name=cos ; fpu_types=TME_M68K_FPU_M6888X ;; # fcos pp 329
+ 25) name=cosh ; fpu_types=TME_M68K_FPU_M6888X ;; # fcosh pp 332
+
diff --git a/emulators/tme/patches/patch-bd b/emulators/tme/patches/patch-bd
new file mode 100644
index 00000000000..0fd68e606c8
--- /dev/null
+++ b/emulators/tme/patches/patch-bd
@@ -0,0 +1,32 @@
+$NetBSD: patch-bd,v 1.1 2007/03/17 13:44:20 tsutsui Exp $
+
+--- generic/fb-xlat-auto.sh.orig 2005-05-15 04:02:20.000000000 +0900
++++ generic/fb-xlat-auto.sh 2007-03-11 18:06:24.000000000 +0900
+@@ -458,11 +458,11 @@
+ if (bits < 32) { \\
+ if (order == TME_ENDIAN_BIG) { \\
+ fifo |= (next >> bits); \\
+- next <<= (32 - bits); \\
++ next = (bits == 0) ? 0 : (next << (32 - bits)); \\
+ } \\
+ else { \\
+ fifo |= (next << bits); \\
+- next >>= (32 - bits); \\
++ next = (bits == 0) ? 0 : (next >> (32 - bits)); \\
+ } \\
+ } \\
+ \\
+@@ -506,11 +506,12 @@
+ /* shift the FIFO: */ \\
+ if (order == TME_ENDIAN_BIG) { \\
+ next |= (fifo >> bits); \\
+- fifo <<= (32 - bits); \\
++ fifo = (bits == 0) ? 0 : (fifo << (32 - bits)); \\
+ } \\
+ else { \\
+ next |= (fifo << bits); \\
+ fifo >>= (32 - bits); \\
++ fifo = (bits == 0) ? 0 : (fifo >> (32 - bits)); \\
+ } \\
+ bits += (shift); \\
+ \\
diff --git a/emulators/tme/patches/patch-be b/emulators/tme/patches/patch-be
new file mode 100644
index 00000000000..ccfc6d03f92
--- /dev/null
+++ b/emulators/tme/patches/patch-be
@@ -0,0 +1,17 @@
+$NetBSD: patch-be,v 1.1 2007/03/17 13:44:20 tsutsui Exp $
+
+--- ic/m68k/m68k-iset.txt.orig 2005-03-23 20:55:34.000000000 +0900
++++ ic/m68k/m68k-iset.txt 2007-03-14 01:31:57.000000000 +0900
+@@ -59,8 +59,10 @@
+ .if m68020 || m68030
+ specop specop16 cmp2_chk2
+ 0000 0ss0 11xx xxxx cmp2_chk2 X, x0/control ! chk2 pp 174, cmp2 pp 185
+-specop specop16 cas
+-0000 1SS0 11xx xxxx cas.S X, x0/memalt/un ! cas pp 169
++specop specop16 cas8 cas16 cas32
++0000 1010 11xx xxxx cas8 X, x0/memalt/un ! cas pp 169
++0000 1100 11xx xxxx cas16 X, x0/memalt/un ! cas pp 169
++0000 1110 11xx xxxx cas32 X, x0/memalt/un ! cas pp 169
+ specop specop16 cas2_16 cas2_32
+ 0000 1100 1111 1100 cas2_16 #16 ! cas2 pp 169
+ 0000 1110 1111 1100 cas2_32 #16 ! cas2 pp 169