summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemulators/qemu0/DESCR11
-rw-r--r--emulators/qemu0/Makefile127
-rw-r--r--emulators/qemu0/PLIST113
-rw-r--r--emulators/qemu0/distinfo22
-rwxr-xr-xemulators/qemu0/files/Makefile.multinode-NetBSD59
-rwxr-xr-xemulators/qemu0/options.mk19
-rw-r--r--emulators/qemu0/patches/patch-aa57
-rw-r--r--emulators/qemu0/patches/patch-ao170
-rw-r--r--emulators/qemu0/patches/patch-ba46
-rw-r--r--emulators/qemu0/patches/patch-bb21
-rw-r--r--emulators/qemu0/patches/patch-dd66
-rw-r--r--emulators/qemu0/patches/patch-ed32
-rw-r--r--emulators/qemu0/patches/patch-ef16
-rw-r--r--emulators/qemu0/patches/patch-eg25
-rw-r--r--emulators/qemu0/patches/patch-eh30
-rw-r--r--emulators/qemu0/patches/patch-ei16
-rw-r--r--emulators/qemu0/patches/patch-en13
-rw-r--r--emulators/qemu0/patches/patch-et15
-rw-r--r--emulators/qemu0/patches/patch-hw_ppc__newworld.c38
-rw-r--r--emulators/qemu0/patches/patch-hw_ppc__oldworld.c38
-rw-r--r--emulators/qemu0/patches/patch-hw_xilinx__axienet.c15
-rw-r--r--emulators/qemu0/patches/patch-ioport.c33
-rw-r--r--emulators/qemu0/patches/patch-slirp_tcp__subr.c21
23 files changed, 1003 insertions, 0 deletions
diff --git a/emulators/qemu0/DESCR b/emulators/qemu0/DESCR
new file mode 100755
index 00000000000..d939711a261
--- /dev/null
+++ b/emulators/qemu0/DESCR
@@ -0,0 +1,11 @@
+QEMU is a FAST! processor emulator using dynamic translation to achieve
+good emulation speed, QEMU has two operating modes:
+
+ * Full system emulation. In this mode, QEMU emulates a full system
+ (for example a PC), including a processor and various peripherals.
+ It can be used to launch different Operating Systems without rebooting
+ the PC or to debug system code.
+ * User mode emulation (Linux host only). In this mode, QEMU can launch
+ Linux processes compiled for one CPU on another CPU. It can be used
+ to launch the Wine Windows API emulator or to ease cross-compilation
+ and cross-debugging.
diff --git a/emulators/qemu0/Makefile b/emulators/qemu0/Makefile
new file mode 100644
index 00000000000..089d074728f
--- /dev/null
+++ b/emulators/qemu0/Makefile
@@ -0,0 +1,127 @@
+# $NetBSD: Makefile,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+DISTNAME= qemu-0.15.1
+PKGREVISION= 5
+CATEGORIES= emulators
+MASTER_SITES= http://wiki.qemu.org/download/
+
+MAINTAINER= pkgsrc-users@NetBSD.org
+HOMEPAGE= http://www.qemu.org/
+COMMENT= CPU emulator using dynamic translation
+LICENSE= gnu-gpl-v2 AND gnu-lgpl-v2.1 AND mit AND modified-bsd
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+CONFLICTS+= qemu-bin-[0-9]*
+NOT_FOR_PLATFORM= NetBSD-1.[0-6]*-*
+
+USE_TOOLS+= gmake makeinfo perl:build pkg-config
+UNLIMIT_RESOURCES= datasize
+HAS_CONFIGURE= yes
+
+BUILD_DEPENDS+= texi2html-[0-9]*:../../textproc/texi2html
+
+.include "options.mk"
+
+.include "../../mk/bsd.prefs.mk"
+
+CONFIGURE_ARGS+= --prefix=${PREFIX}
+CONFIGURE_ARGS+= --interp-prefix=${PREFIX}/share/qemu
+CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
+CONFIGURE_ARGS+= --mandir=${PREFIX}/${PKGMANDIR}
+CONFIGURE_ARGS+= --python=${PYTHONBIN}
+
+CONF_FILES= ${EGDIR}/target-x86_64.conf \
+ ${PKG_SYSCONFDIR}/target-x86_64.conf
+EGDIR= ${PREFIX}/share/examples/qemu
+INSTALL_MAKE_FLAGS= egdir=${EGDIR}
+PKG_SYSCONFSUBDIR= qemu
+
+# Avoid clash with system include file:
+pre-patch:
+ mv ${WRKSRC}/audio/audio.h ${WRKSRC}/audio/qaudio.h
+
+SUBST_CLASSES+= qaudio
+SUBST_STAGE.qaudio= pre-configure
+SUBST_FILES.qaudio= arch_init.c monitor.c savevm.c vl.c \
+ audio/*.c \
+ hw/ac97.c \
+ hw/adlib.c \
+ hw/cs4231a.c \
+ hw/es1370.c \
+ hw/gus.c \
+ hw/hda-audio.c \
+ hw/marvell_88w8618_audio.c \
+ hw/milkymist-ac97.c \
+ hw/mips_fulong2e.c \
+ hw/mips_jazz.c \
+ hw/mips_malta.c \
+ hw/omap2.c \
+ hw/palm.c \
+ hw/pcspk.c \
+ hw/sb16.c \
+ hw/spitz.c \
+ hw/tsc210x.c \
+ hw/wm8750.c \
+ ui/vnc.h
+SUBST_SED.qaudio= -e s,audio.h\",qaudio.h\",g
+SUBST_MESSAGE.qaudio= Fixing audio.h confusion
+
+REPLACE_PERL+= texi2pod.pl
+
+BUILDLINK_PASSTHRU_DIRS+= /usr/lib
+BUILDLINK_PASSTHRU_RPATHDIRS+= /usr/lib
+
+INSTALLATION_DIRS= ${PKGMANDIR}/man1 share/doc/qemu
+
+UE_ARCHS+= alpha arm armeb cris i386 m68k microblaze mips mipsel
+UE_ARCHS+= ppc ppc64 ppc64abi32 sh4 sh4eb sparc sparc32plus
+UE_ARCHS+= sparc64 x86_64 microblazeel s390x unicore32
+
+.if ${OPSYS} == "NetBSD"
+.if (!empty(OS_VERSION:M5.99.*) || !empty(OS_VERSION:M[6-9].*))
+# XXX
+# i386 and x86_64 user emul require newer binutils for PROVIDE_HIDDEN()
+# http://git.qemu.org/qemu.git/commit/?id=845f2c2812d9ed24b36c02a3d06ee83aeafe8b49
+# but binutils-2.19 was enabled around 5.99.22:
+# http://cvsweb.NetBSD.org/bsdweb.cgi/src/share/mk/bsd.own.mk#rev1.594
+USER_EMUL= i386 x86_64 sparc sparc64
+.else
+CONFIGURE_ARGS+= --disable-bsd-user
+USER_EMUL=
+.endif
+PLIST.nbd= YES
+.elif !empty(OPSYS:M*BSD) || !empty(OPSYS:MDragonFly)
+USER_EMUL= i386 x86_64 sparc sparc64
+PLIST.nbd= YES
+.elif !empty(OPSYS:MDarwin)
+USER_EMUL=
+CONFIGURE_ARGS+= --disable-bsd-user
+CONFIGURE_ARGS+= --disable-darwin-user
+PLIST.nbd= YES
+.elif !empty(OPSYS:MLinux)
+USER_EMUL= ${UE_ARCHS}
+PLIST.nbd= YES
+.endif
+
+PLIST_VARS+= ${UE_ARCHS} nbd
+.for _var_ in ${USER_EMUL}
+PLIST.${_var_}= YES
+.endfor
+
+post-install:
+ ${INSTALL_DATA} ${FILESDIR}/Makefile.multinode-NetBSD \
+ ${DESTDIR}${PREFIX}/share/doc/qemu/
+
+# On Darwin, qemu uses Cocoa and CoreAudio
+.if empty(OPSYS:MDarwin)
+.include "../../mk/oss.buildlink3.mk"
+.endif
+.include "../../devel/glib2/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../lang/python/extension.mk"
+.include "../../www/curl/buildlink3.mk"
+.include "../../mk/curses.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.include "../../mk/terminfo.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/emulators/qemu0/PLIST b/emulators/qemu0/PLIST
new file mode 100644
index 00000000000..9db64f349da
--- /dev/null
+++ b/emulators/qemu0/PLIST
@@ -0,0 +1,113 @@
+@comment $NetBSD: PLIST,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+bin/qemu
+${PLIST.alpha}bin/qemu-alpha
+${PLIST.arm}bin/qemu-arm
+${PLIST.armeb}bin/qemu-armeb
+${PLIST.cris}bin/qemu-cris
+bin/qemu-ga
+${PLIST.i386}bin/qemu-i386
+bin/qemu-img
+bin/qemu-io
+${PLIST.m68k}bin/qemu-m68k
+${PLIST.microblaze}bin/qemu-microblaze
+${PLIST.microblazeel}bin/qemu-microblazeel
+${PLIST.mips}bin/qemu-mips
+${PLIST.mipsel}bin/qemu-mipsel
+${PLIST.nbd}bin/qemu-nbd
+${PLIST.ppc}bin/qemu-ppc
+${PLIST.ppc64}bin/qemu-ppc64
+${PLIST.ppc64abi32}bin/qemu-ppc64abi32
+${PLIST.s390x}bin/qemu-s390x
+${PLIST.sh4}bin/qemu-sh4
+${PLIST.sh4eb}bin/qemu-sh4eb
+${PLIST.sparc}bin/qemu-sparc
+${PLIST.sparc32plus}bin/qemu-sparc32plus
+${PLIST.sparc64}bin/qemu-sparc64
+${PLIST.unicore32}bin/qemu-unicore32
+bin/qemu-system-arm
+bin/qemu-system-cris
+bin/qemu-system-lm32
+bin/qemu-system-m68k
+bin/qemu-system-microblaze
+bin/qemu-system-microblazeel
+bin/qemu-system-mips
+bin/qemu-system-mips64
+bin/qemu-system-mips64el
+bin/qemu-system-mipsel
+bin/qemu-system-ppc
+bin/qemu-system-ppc64
+bin/qemu-system-ppcemb
+bin/qemu-system-s390x
+bin/qemu-system-sh4
+bin/qemu-system-sh4eb
+bin/qemu-system-sparc
+bin/qemu-system-sparc64
+bin/qemu-system-x86_64
+${PLIST.x86_64}bin/qemu-x86_64
+man/man1/qemu-img.1
+man/man1/qemu.1
+man/man8/qemu-nbd.8
+share/doc/qemu/Makefile.multinode-NetBSD
+share/doc/qemu/qemu-doc.html
+share/doc/qemu/qemu-tech.html
+share/examples/qemu/target-x86_64.conf
+share/qemu/bamboo.dtb
+share/qemu/bios.bin
+share/qemu/keymaps/ar
+share/qemu/keymaps/common
+share/qemu/keymaps/da
+share/qemu/keymaps/de
+share/qemu/keymaps/de-ch
+share/qemu/keymaps/en-gb
+share/qemu/keymaps/en-us
+share/qemu/keymaps/es
+share/qemu/keymaps/et
+share/qemu/keymaps/fi
+share/qemu/keymaps/fo
+share/qemu/keymaps/fr
+share/qemu/keymaps/fr-be
+share/qemu/keymaps/fr-ca
+share/qemu/keymaps/fr-ch
+share/qemu/keymaps/hr
+share/qemu/keymaps/hu
+share/qemu/keymaps/is
+share/qemu/keymaps/it
+share/qemu/keymaps/ja
+share/qemu/keymaps/lt
+share/qemu/keymaps/lv
+share/qemu/keymaps/mk
+share/qemu/keymaps/modifiers
+share/qemu/keymaps/nl
+share/qemu/keymaps/nl-be
+share/qemu/keymaps/no
+share/qemu/keymaps/pl
+share/qemu/keymaps/pt
+share/qemu/keymaps/pt-br
+share/qemu/keymaps/ru
+share/qemu/keymaps/sl
+share/qemu/keymaps/sv
+share/qemu/keymaps/th
+share/qemu/keymaps/tr
+share/qemu/linuxboot.bin
+share/qemu/mpc8544ds.dtb
+share/qemu/multiboot.bin
+share/qemu/openbios-ppc
+share/qemu/openbios-sparc32
+share/qemu/openbios-sparc64
+share/qemu/petalogix-ml605.dtb
+share/qemu/petalogix-s3adsp1800.dtb
+share/qemu/ppc_rom.bin
+share/qemu/pxe-e1000.rom
+share/qemu/pxe-eepro100.rom
+share/qemu/pxe-ne2k_pci.rom
+share/qemu/pxe-pcnet.rom
+share/qemu/pxe-rtl8139.rom
+share/qemu/pxe-virtio.rom
+share/qemu/s390-zipl.rom
+share/qemu/slof.bin
+share/qemu/spapr-rtas.bin
+share/qemu/vgabios-cirrus.bin
+share/qemu/vgabios-qxl.bin
+share/qemu/vgabios-stdvga.bin
+share/qemu/vgabios-vmware.bin
+share/qemu/vgabios.bin
diff --git a/emulators/qemu0/distinfo b/emulators/qemu0/distinfo
new file mode 100644
index 00000000000..19384406024
--- /dev/null
+++ b/emulators/qemu0/distinfo
@@ -0,0 +1,22 @@
+$NetBSD: distinfo,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+SHA1 (qemu-0.15.1.tar.gz) = 30cf3b4dabb4b5d8efadb20f364eb8181f317681
+RMD160 (qemu-0.15.1.tar.gz) = fd1cfde94f96569af671cc96d1c2e4bad524fd61
+Size (qemu-0.15.1.tar.gz) = 9576745 bytes
+SHA1 (patch-aa) = ca39d409081cd7d9f038d580c5b90ffca46948ec
+SHA1 (patch-ao) = 610e77fd51595f0f77b82a745d0a546712f6442d
+SHA1 (patch-ba) = c8ad6502b0693cc22a79f89d2935d962066b5d91
+SHA1 (patch-bb) = 17255a240062acfe87401c2168158687f2ebcd20
+SHA1 (patch-dd) = 20637d652963c94c5fe7999f27c31c7fd8864e43
+SHA1 (patch-ed) = 7a77ba9b33d654c9f8278d69f81a2fc06e17a7d3
+SHA1 (patch-ef) = f26f1b860cca477d5e80c9cb2755c8dc6fa593ac
+SHA1 (patch-eg) = 1f3a0320344d930c8df97e322411de3136f398d7
+SHA1 (patch-eh) = c79b915f08941af95611aa43c8c9a342486632d4
+SHA1 (patch-ei) = e2ffd48420e7aa0f0507a741afe6f24c6f06e4c9
+SHA1 (patch-en) = 267500f7c11efacdf1a9ae323595e0469aa791c9
+SHA1 (patch-et) = 53b38e0fbe12c4d199997327b66248f125988a4c
+SHA1 (patch-hw_ppc__newworld.c) = a0011c05cd35aff8982b97c3ec669e18c11ad07b
+SHA1 (patch-hw_ppc__oldworld.c) = 790daed4d0bdc51628a6252716480510f8c444c8
+SHA1 (patch-hw_xilinx__axienet.c) = 6f715e4e2241c3c9006bc571084ca5fd12658f13
+SHA1 (patch-ioport.c) = bb0c6671eaf39ef9b846d0ea2633cb1d56edddb1
+SHA1 (patch-slirp_tcp__subr.c) = d2aca58ea0726b76b5f644af27fde0598beaf048
diff --git a/emulators/qemu0/files/Makefile.multinode-NetBSD b/emulators/qemu0/files/Makefile.multinode-NetBSD
new file mode 100755
index 00000000000..8b0ba82bb79
--- /dev/null
+++ b/emulators/qemu0/files/Makefile.multinode-NetBSD
@@ -0,0 +1,59 @@
+# $Id: Makefile.multinode-NetBSD,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+# Source: http://mail-index.NetBSD.org/netbsd-help/2005/03/25/0005.html
+#
+# Starts up two qemu instances and networks bridges them to the local
+# ethernet (ETHER_IF}. Works best with NetBSD configured to use serial
+# consoles in DISK[12]
+#
+# Usage:
+# sudo make netbsd1
+# sudo make netbsd2
+#
+# - Hubert Feyrer <hubert@feyrer.de>
+#
+
+#NETBSD_NOGFX=
+NETBSD_NOGFX= -nographic
+
+ETHER_IF= tlp0
+QEMU_RAM= 20
+DISK1= harddisk.netbsd1
+DISK2= harddisk.netbsd2
+
+
+all: netbsd1 netbsd2
+
+netbsd1: bridge
+ ifconfig tap1 create up || echo tap1: already there
+ brconfig bridge0 add tap1 up || echo tap1: already on bridge0
+ brconfig bridge0 -learn tap1 # real hub mode, step 1b
+ brconfig bridge0 flush # real hub more, step 2
+ qemu \
+ -m ${QEMU_RAM} \
+ ${NETBSD_NOGFX} \
+ -boot c \
+ -net tap,fd=3,ifname=tap1 3<>/dev/tap1 \
+ -net nic,macaddr=de:ad:be:ef:00:01 \
+ ${DISK1}
+ brconfig bridge0 delete tap1
+ ifconfig tap1 destroy
+
+netbsd2: bridge
+ ifconfig tap2 create up || echo tap2: already there
+ brconfig bridge0 add tap2 up || echo tap2: already on bridge0
+ brconfig bridge0 -learn tap2 # real hub mode, step 1c
+ brconfig bridge0 flush # real hub mode, step 2
+ qemu \
+ -m ${QEMU_RAM} \
+ ${NETBSD_NOGFX} \
+ -boot c \
+ -net tap,fd=3,ifname=tap2 3<>/dev/tap2 \
+ -net nic,macaddr=de:ad:be:ef:00:02 \
+ ${DISK2}
+ brconfig bridge0 delete tap2
+ ifconfig tap2 destroy
+
+bridge:
+ ifconfig bridge0 create || echo bridge0: already there
+ brconfig bridge0 add ${ETHER_IF} || echo bridge0: ${ETHER_IF} already there
+ brconfig bridge0 -learn ${ETHER_IF} # real hub mode, step 1a
diff --git a/emulators/qemu0/options.mk b/emulators/qemu0/options.mk
new file mode 100755
index 00000000000..8f33fce3ebd
--- /dev/null
+++ b/emulators/qemu0/options.mk
@@ -0,0 +1,19 @@
+# $NetBSD: options.mk,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.qemu
+PKG_SUPPORTED_OPTIONS= sdl
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+.if empty(OPSYS:MDarwin)
+PKG_SUGGESTED_OPTIONS= sdl
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Msdl)
+CONFIGURE_ARGS+= --enable-sdl
+.include "../../devel/SDL/buildlink3.mk"
+.else
+CONFIGURE_ARGS+= --disable-sdl
+.endif
diff --git a/emulators/qemu0/patches/patch-aa b/emulators/qemu0/patches/patch-aa
new file mode 100644
index 00000000000..24e38d21c75
--- /dev/null
+++ b/emulators/qemu0/patches/patch-aa
@@ -0,0 +1,57 @@
+$NetBSD: patch-aa,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+* fixes a bug with tap device detection
+
+--- net/tap-bsd.c.orig 2011-08-08 18:28:42.000000000 +0000
++++ net/tap-bsd.c
+@@ -28,6 +28,8 @@
+ #include "qemu-error.h"
+
+ #ifdef __NetBSD__
++#include <sys/ioctl.h>
++#include <net/if.h>
+ #include <net/if_tap.h>
+ #endif
+
+@@ -40,8 +42,12 @@
+ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required)
+ {
+ int fd;
++#ifdef TAPGIFNAME
++ struct ifreq ifr;
++#else
+ char *dev;
+ struct stat s;
++#endif
+
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+ /* if no ifname is given, always start the search from tap0/tun0. */
+@@ -77,14 +83,26 @@ int tap_open(char *ifname, int ifname_si
+ #else
+ TFR(fd = open("/dev/tap", O_RDWR));
+ if (fd < 0) {
+- fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
++ fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation: %s\n", strerror(errno));
+ return -1;
+ }
+ #endif
+
+- fstat(fd, &s);
++#ifdef TAPGIFNAME
++ if (ioctl (fd, TAPGIFNAME, (void*)&ifr) < 0) {
++ fprintf(stderr, "warning: could not open get tap name: %s\n",
++ strerror(errno));
++ return -1;
++ }
++ pstrcpy(ifname, ifname_size, ifr.ifr_name);
++#else
++ if (fstat(fd, &s) < 0) {
++ fprintf(stderr, "warning: could not stat /dev/tap: no virtual network emulation: %s\n", strerror(errno));
++ return -1;
++ }
+ dev = devname(s.st_rdev, S_IFCHR);
+ pstrcpy(ifname, ifname_size, dev);
++#endif
+
+ if (*vnet_hdr) {
+ /* BSD doesn't have IFF_VNET_HDR */
diff --git a/emulators/qemu0/patches/patch-ao b/emulators/qemu0/patches/patch-ao
new file mode 100644
index 00000000000..540db0ba965
--- /dev/null
+++ b/emulators/qemu0/patches/patch-ao
@@ -0,0 +1,170 @@
+$NetBSD: patch-ao,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+--- audio/mixeng.c.orig 2011-08-08 18:28:42 +0000
++++ audio/mixeng.c
+@@ -143,56 +143,64 @@
+ #undef IN_T
+ #undef SHIFT
+
++/*
++ * Work around ugly XX_t #defines in NetBSD 2.x,
++ * fixed as typedefs in NetBSD 3.x. Two macros needed to
++ * get CPP defines expanded properly. - HF
++ */
++#define _NBglue(x,y,z) x ## y ## z
++#define NBglue(x,y,z) _NBglue(x,y,z)
++
+ t_sample *mixeng_conv[2][2][2][3] = {
+ {
+ {
+ {
+- conv_natural_uint8_t_to_mono,
+- conv_natural_uint16_t_to_mono,
+- conv_natural_uint32_t_to_mono
++ NBglue(conv_natural_, uint8_t, _to_mono),
++ NBglue(conv_natural_, uint16_t, _to_mono),
++ NBglue(conv_natural_, uint32_t, _to_mono)
+ },
+ {
+- conv_natural_uint8_t_to_mono,
+- conv_swap_uint16_t_to_mono,
+- conv_swap_uint32_t_to_mono,
++ NBglue(conv_natural_, uint8_t, _to_mono),
++ NBglue(conv_swap_, uint16_t, _to_mono),
++ NBglue(conv_swap_, uint32_t, _to_mono),
+ }
+ },
+ {
+ {
+- conv_natural_int8_t_to_mono,
+- conv_natural_int16_t_to_mono,
+- conv_natural_int32_t_to_mono
++ NBglue(conv_natural_, int8_t, _to_mono),
++ NBglue(conv_natural_, int16_t, _to_mono),
++ NBglue(conv_natural_, int32_t, _to_mono)
+ },
+ {
+- conv_natural_int8_t_to_mono,
+- conv_swap_int16_t_to_mono,
+- conv_swap_int32_t_to_mono
++ NBglue(conv_natural_, int8_t, _to_mono),
++ NBglue(conv_swap_, int16_t, _to_mono),
++ NBglue(conv_swap_, int32_t, _to_mono)
+ }
+ }
+ },
+ {
+ {
+ {
+- conv_natural_uint8_t_to_stereo,
+- conv_natural_uint16_t_to_stereo,
+- conv_natural_uint32_t_to_stereo
++ NBglue(conv_natural_, uint8_t, _to_stereo),
++ NBglue(conv_natural_, uint16_t, _to_stereo),
++ NBglue(conv_natural_, uint32_t, _to_stereo)
+ },
+ {
+- conv_natural_uint8_t_to_stereo,
+- conv_swap_uint16_t_to_stereo,
+- conv_swap_uint32_t_to_stereo
++ NBglue(conv_natural_, uint8_t, _to_stereo),
++ NBglue(conv_swap_, uint16_t, _to_stereo),
++ NBglue(conv_swap_, uint32_t, _to_stereo)
+ }
+ },
+ {
+ {
+- conv_natural_int8_t_to_stereo,
+- conv_natural_int16_t_to_stereo,
+- conv_natural_int32_t_to_stereo
++ NBglue(conv_natural_, int8_t, _to_stereo),
++ NBglue(conv_natural_, int16_t, _to_stereo),
++ NBglue(conv_natural_, int32_t, _to_stereo)
+ },
+ {
+- conv_natural_int8_t_to_stereo,
+- conv_swap_int16_t_to_stereo,
+- conv_swap_int32_t_to_stereo,
++ NBglue(conv_natural_, int8_t, _to_stereo),
++ NBglue(conv_swap_, int16_t, _to_stereo),
++ NBglue(conv_swap_, int32_t, _to_stereo),
+ }
+ }
+ }
+@@ -202,52 +210,52 @@ f_sample *mixeng_clip[2][2][2][3] = {
+ {
+ {
+ {
+- clip_natural_uint8_t_from_mono,
+- clip_natural_uint16_t_from_mono,
+- clip_natural_uint32_t_from_mono
++ NBglue(clip_natural_, uint8_t, _from_mono),
++ NBglue(clip_natural_, uint16_t, _from_mono),
++ NBglue(clip_natural_, uint32_t, _from_mono)
+ },
+ {
+- clip_natural_uint8_t_from_mono,
+- clip_swap_uint16_t_from_mono,
+- clip_swap_uint32_t_from_mono
++ NBglue(clip_natural_, uint8_t, _from_mono),
++ NBglue(clip_swap_, uint16_t, _from_mono),
++ NBglue(clip_swap_, uint32_t, _from_mono)
+ }
+ },
+ {
+ {
+- clip_natural_int8_t_from_mono,
+- clip_natural_int16_t_from_mono,
+- clip_natural_int32_t_from_mono
++ NBglue(clip_natural_, int8_t, _from_mono),
++ NBglue(clip_natural_, int16_t, _from_mono),
++ NBglue(clip_natural_, int32_t, _from_mono)
+ },
+ {
+- clip_natural_int8_t_from_mono,
+- clip_swap_int16_t_from_mono,
+- clip_swap_int32_t_from_mono
++ NBglue(clip_natural_, int8_t, _from_mono),
++ NBglue(clip_swap_, int16_t, _from_mono),
++ NBglue(clip_swap_, int32_t, _from_mono)
+ }
+ }
+ },
+ {
+ {
+ {
+- clip_natural_uint8_t_from_stereo,
+- clip_natural_uint16_t_from_stereo,
+- clip_natural_uint32_t_from_stereo
++ NBglue(clip_natural_, uint8_t, _from_stereo),
++ NBglue(clip_natural_, uint16_t, _from_stereo),
++ NBglue(clip_natural_, uint32_t, _from_stereo)
+ },
+ {
+- clip_natural_uint8_t_from_stereo,
+- clip_swap_uint16_t_from_stereo,
+- clip_swap_uint32_t_from_stereo
++ NBglue(clip_natural_, uint8_t, _from_stereo),
++ NBglue(clip_swap_, uint16_t, _from_stereo),
++ NBglue(clip_swap_, uint32_t, _from_stereo)
+ }
+ },
+ {
+ {
+- clip_natural_int8_t_from_stereo,
+- clip_natural_int16_t_from_stereo,
+- clip_natural_int32_t_from_stereo
++ NBglue(clip_natural_, int8_t, _from_stereo),
++ NBglue(clip_natural_, int16_t, _from_stereo),
++ NBglue(clip_natural_, int32_t, _from_stereo)
+ },
+ {
+- clip_natural_int8_t_from_stereo,
+- clip_swap_int16_t_from_stereo,
+- clip_swap_int32_t_from_stereo
++ NBglue(clip_natural_, int8_t, _from_stereo),
++ NBglue(clip_swap_, int16_t, _from_stereo),
++ NBglue(clip_swap_, int32_t, _from_stereo)
+ }
+ }
+ }
diff --git a/emulators/qemu0/patches/patch-ba b/emulators/qemu0/patches/patch-ba
new file mode 100644
index 00000000000..da2ac773509
--- /dev/null
+++ b/emulators/qemu0/patches/patch-ba
@@ -0,0 +1,46 @@
+$NetBSD: patch-ba,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+--- hw/pcspk.c.orig 2011-08-08 18:28:42 +0000
++++ hw/pcspk.c
+@@ -42,7 +42,6 @@ typedef struct {
+ unsigned int samples;
+ unsigned int play_pos;
+ int data_on;
+- int dummy_refresh_clock;
+ } PCSpkState;
+
+ static const char *s_spk = "pcspk";
+@@ -112,15 +111,31 @@ int pcspk_audio_init(qemu_irq *pic)
+ return 0;
+ }
+
++/*
++ * Emulate the speaker port's refresh clock bit. This is supposed
++ * to toggle between 0 and 1<<4 every 15 microseconds. XXX: We use
++ * gettimeofday() in the real machine instead of a monotonic clock
++ * in the virtual machine, and we are a bit sloppy about the 15
++ * microseconds. This should be good enough for crude loops that
++ * measure approximate delays by counting how often this line toggles.
++ */
++static uint32_t pcspk_dummy_refresh_clock(void)
++{
++ struct timeval tv;
++
++ gettimeofday(&tv, NULL);
++ return ((tv.tv_sec ^ (tv.tv_usec / 15)) & 1) << 4;
++}
++
+ static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
+ {
+ PCSpkState *s = opaque;
+ int out;
+
+- s->dummy_refresh_clock ^= (1 << 4);
+ out = pit_get_out(s->pit, 2, qemu_get_clock_ns(vm_clock)) << 5;
+
+- return pit_get_gate(s->pit, 2) | (s->data_on << 1) | s->dummy_refresh_clock | out;
++ return pit_get_gate(s->pit, 2) | (s->data_on << 1) |
++ pcspk_dummy_refresh_clock() | out;
+ }
+
+ static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
diff --git a/emulators/qemu0/patches/patch-bb b/emulators/qemu0/patches/patch-bb
new file mode 100644
index 00000000000..46ce96d976c
--- /dev/null
+++ b/emulators/qemu0/patches/patch-bb
@@ -0,0 +1,21 @@
+$NetBSD: patch-bb,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+* fix build on NetBSD/4.0.1.
+
+--- scripts/signrom.sh.orig 2011-08-08 18:28:42.000000000 +0000
++++ scripts/signrom.sh
+@@ -26,12 +26,12 @@ test "$1" -a "$2" || exit 1
+ sum=0
+
+ # find out the file size
+-x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
++x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 | sed -e 's/^[0-9]* *//' -e 's/^00*\([0-9]\)/\1/'`
+ #size=`expr $x \* 512 - 1`
+ size=$(( $x * 512 - 1 ))
+
+ # now get the checksum
+-nums=`od -A n -t u1 -v -N $size "$1"`
++nums=`od -t u1 -v "$1" | sed -e 's/^[0-9]* *//' -e 's/^00*\([0-9]\)/\1/' -e 's/ 00*\([0-9]\)/ \1/g'`
+ for i in ${nums}; do
+ # add each byte's value to sum
+ sum=`expr \( $sum + $i \) % 256`
diff --git a/emulators/qemu0/patches/patch-dd b/emulators/qemu0/patches/patch-dd
new file mode 100644
index 00000000000..ce61cc19124
--- /dev/null
+++ b/emulators/qemu0/patches/patch-dd
@@ -0,0 +1,66 @@
+$NetBSD: patch-dd,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Remove confsuffix from sysconfdir so that our PKG_SYSCONFSUBDIR setting
+works.
+
+Install man pages into ${PREFIX}/man, not ${PREFIX}/share/man.
+
+Handle arm and armeb case on NetBSD.
+XXX: it looks mips is always treated as big endian.
+
+--- configure.orig 2011-08-08 18:28:42 +0000
++++ configure
+@@ -141,13 +141,13 @@ bigendian="no"
+ mingw32="no"
+ EXESUF=""
+ prefix="/usr/local"
+-mandir="\${prefix}/share/man"
++mandir="\${prefix}/man"
+ datadir="\${prefix}/share/qemu"
+ docdir="\${prefix}/share/doc/qemu"
+ bindir="\${prefix}/bin"
+ libdir="\${prefix}/lib"
+ sysconfdir="\${prefix}/etc"
+-confsuffix="/qemu"
++confsuffix=""
+ slirp="yes"
+ fmod_lib=""
+ fmod_inc=""
+@@ -281,12 +281,18 @@ elif check_define __s390__ ; then
+ else
+ cpu="s390"
+ fi
++elif check_define __arm__ ; then
++ if check_define __ARMEL__ ; then
++ cpu="arm"
++ elif check_define __ARMEB__ ; then
++ cpu="armeb"
++ fi
+ else
+ cpu=`uname -m`
+ fi
+
+ case "$cpu" in
+- alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
++ alpha|arm|armeb|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
+ cpu="$cpu"
+ ;;
+ i386|i486|i586|i686|i86pc|BePC)
+@@ -1152,7 +1158,7 @@ else
+
+ # if cross compiling, cannot launch a program, so make a static guess
+ case "$cpu" in
+- armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
++ armeb|armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
+ bigendian=yes
+ ;;
+ esac
+@@ -2730,7 +2736,7 @@ case "$cpu" in
+ i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
+ ARCH=$cpu
+ ;;
+- armv4b|armv4l)
++ arm|armeb|armv4b|armv4l)
+ ARCH=arm
+ ;;
+ esac
diff --git a/emulators/qemu0/patches/patch-ed b/emulators/qemu0/patches/patch-ed
new file mode 100644
index 00000000000..fc1415bd937
--- /dev/null
+++ b/emulators/qemu0/patches/patch-ed
@@ -0,0 +1,32 @@
+$NetBSD: patch-ed,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+--- target-i386/translate.c.orig 2011-08-08 18:28:42 +0000
++++ target-i386/translate.c
+@@ -4856,20 +4856,23 @@ static target_ulong disas_insn(DisasCont
+ tcg_gen_sub_tl(t2, cpu_regs[R_EAX], t0);
+ gen_extu(ot, t2);
+ tcg_gen_brcondi_tl(TCG_COND_EQ, t2, 0, label1);
++ label2 = gen_new_label();
+ if (mod == 3) {
+- label2 = gen_new_label();
+ gen_op_mov_reg_v(ot, R_EAX, t0);
+ tcg_gen_br(label2);
+ gen_set_label(label1);
+ gen_op_mov_reg_v(ot, rm, t1);
+- gen_set_label(label2);
+ } else {
+- tcg_gen_mov_tl(t1, t0);
++ /* perform no-op store cycle like physical cpu; must be
++ before changing accumulator to ensure idempotency if
++ the store faults and the instruction is restarted */
++ gen_op_st_v(ot + s->mem_index, t0, a0);
+ gen_op_mov_reg_v(ot, R_EAX, t0);
++ tcg_gen_br(label2);
+ gen_set_label(label1);
+- /* always store */
+ gen_op_st_v(ot + s->mem_index, t1, a0);
+ }
++ gen_set_label(label2);
+ tcg_gen_mov_tl(cpu_cc_src, t0);
+ tcg_gen_mov_tl(cpu_cc_dst, t2);
+ s->cc_op = CC_OP_SUBB + ot;
diff --git a/emulators/qemu0/patches/patch-ef b/emulators/qemu0/patches/patch-ef
new file mode 100644
index 00000000000..af9e9071f79
--- /dev/null
+++ b/emulators/qemu0/patches/patch-ef
@@ -0,0 +1,16 @@
+$NetBSD: patch-ef,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with SSP read() macro in NetBSD's <ssp/unistd.h>
+(PR lib/43832: ssp causes common names to be defines)
+
+--- audio/audio.c.orig 2011-08-08 18:28:42 +0000
++++ audio/audio.c
+@@ -1162,7 +1162,7 @@ int AUD_read (SWVoiceIn *sw, void *buf,
+ return 0;
+ }
+
+- bytes = sw->hw->pcm_ops->read (sw, buf, size);
++ bytes = (*sw->hw->pcm_ops->read)(sw, buf, size);
+ return bytes;
+ }
+
diff --git a/emulators/qemu0/patches/patch-eg b/emulators/qemu0/patches/patch-eg
new file mode 100644
index 00000000000..7f2f486fda1
--- /dev/null
+++ b/emulators/qemu0/patches/patch-eg
@@ -0,0 +1,25 @@
+$NetBSD: patch-eg,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with SSP read() macro in NetBSD's <ssp/unistd.h>
+(PR lib/43832: ssp causes common names to be defines)
+
+--- hw/etraxfs_eth.c.orig 2011-08-08 18:28:42 +0000
++++ hw/etraxfs_eth.c
+@@ -184,7 +184,7 @@ static void mdio_read_req(struct qemu_md
+
+ phy = bus->devs[bus->addr];
+ if (phy && phy->read)
+- bus->data = phy->read(phy, bus->req);
++ bus->data = (*phy->read)(phy, bus->req);
+ else
+ bus->data = 0xffff;
+ }
+@@ -347,7 +347,7 @@ static void eth_validate_duplex(struct f
+ int new_mm = 0;
+
+ phy = eth->mdio_bus.devs[eth->phyaddr];
+- phy_duplex = !!(phy->read(phy, 18) & (1 << 11));
++ phy_duplex = !!((*phy->read)(phy, 18) & (1 << 11));
+ mac_duplex = !!(eth->regs[RW_REC_CTRL] & 128);
+
+ if (mac_duplex != phy_duplex)
diff --git a/emulators/qemu0/patches/patch-eh b/emulators/qemu0/patches/patch-eh
new file mode 100644
index 00000000000..d5846474243
--- /dev/null
+++ b/emulators/qemu0/patches/patch-eh
@@ -0,0 +1,30 @@
+$NetBSD: patch-eh,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with SSP read() macro in NetBSD's <ssp/unistd.h>
+(PR lib/43832: ssp causes common names to be defines)
+
+--- hw/omap_dss.c.orig 2011-08-08 18:28:42 +0000
++++ hw/omap_dss.c
+@@ -774,18 +774,18 @@ static void omap_rfbi_write(void *opaque
+ break;
+ case 0x58: /* RFBI_READ */
+ if ((s->rfbi.control & (1 << 2)) && s->rfbi.chip[0])
+- s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 1);
++ s->rfbi.rxbuf = (*s->rfbi.chip[0]->read)(s->rfbi.chip[0]->opaque, 1);
+ else if ((s->rfbi.control & (1 << 3)) && s->rfbi.chip[1])
+- s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 1);
++ s->rfbi.rxbuf = (*s->rfbi.chip[0]->read)(s->rfbi.chip[0]->opaque, 1);
+ if (!-- s->rfbi.pixels)
+ omap_rfbi_transfer_stop(s);
+ break;
+
+ case 0x5c: /* RFBI_STATUS */
+ if ((s->rfbi.control & (1 << 2)) && s->rfbi.chip[0])
+- s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 0);
++ s->rfbi.rxbuf = (*s->rfbi.chip[0]->read)(s->rfbi.chip[0]->opaque, 0);
+ else if ((s->rfbi.control & (1 << 3)) && s->rfbi.chip[1])
+- s->rfbi.rxbuf = s->rfbi.chip[0]->read(s->rfbi.chip[0]->opaque, 0);
++ s->rfbi.rxbuf = (*s->rfbi.chip[0]->read)(s->rfbi.chip[0]->opaque, 0);
+ if (!-- s->rfbi.pixels)
+ omap_rfbi_transfer_stop(s);
+ break;
diff --git a/emulators/qemu0/patches/patch-ei b/emulators/qemu0/patches/patch-ei
new file mode 100644
index 00000000000..ac6a1ecefd9
--- /dev/null
+++ b/emulators/qemu0/patches/patch-ei
@@ -0,0 +1,16 @@
+$NetBSD: patch-ei,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with SSP read() macro in NetBSD's <ssp/unistd.h>
+(PR lib/43832: ssp causes common names to be defines)
+
+--- rwhandler.c.orig 2011-08-08 18:28:42 +0000
++++ rwhandler.c
+@@ -13,7 +13,7 @@ static void name(void *opaque, type addr
+ static uint32_t name(void *opaque, type addr) \
+ { \
+ struct ReadWriteHandler *handler = opaque; \
+- return handler->read(handler, addr, len); \
++ return (*handler->read)(handler, addr, len); \
+ }
+
+ RWHANDLER_WRITE(cpu_io_memory_simple_writeb, 1, target_phys_addr_t);
diff --git a/emulators/qemu0/patches/patch-en b/emulators/qemu0/patches/patch-en
new file mode 100644
index 00000000000..5e7f3e06aaa
--- /dev/null
+++ b/emulators/qemu0/patches/patch-en
@@ -0,0 +1,13 @@
+$NetBSD: patch-en,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+--- tcg/arm/tcg-target.h.orig 2011-08-08 18:28:42 +0000
++++ tcg/arm/tcg-target.h
+@@ -83,7 +83,7 @@ enum {
+ static inline void flush_icache_range(unsigned long start, unsigned long stop)
+ {
+ #if QEMU_GNUC_PREREQ(4, 1)
+- __builtin___clear_cache((char *) start, (char *) stop);
++ __clear_cache((char *) start, (char *) stop); /* declared in exec-all.h */
+ #else
+ register unsigned long _beg __asm ("a1") = start;
+ register unsigned long _end __asm ("a2") = stop;
diff --git a/emulators/qemu0/patches/patch-et b/emulators/qemu0/patches/patch-et
new file mode 100644
index 00000000000..35da45995dc
--- /dev/null
+++ b/emulators/qemu0/patches/patch-et
@@ -0,0 +1,15 @@
+$NetBSD: patch-et,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+--- Makefile.orig 2011-08-08 18:28:42 +0000
++++ Makefile
+@@ -261,8 +261,8 @@ ifdef CONFIG_POSIX
+ endif
+
+ install-sysconfig:
+- $(INSTALL_DIR) "$(DESTDIR)$(sysconfdir)/qemu"
+- $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(sysconfdir)/qemu"
++ $(INSTALL_DIR) "$(DESTDIR)$(egdir)"
++ $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(egdir)"
+
+ install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig
+ $(INSTALL_DIR) "$(DESTDIR)$(bindir)"
diff --git a/emulators/qemu0/patches/patch-hw_ppc__newworld.c b/emulators/qemu0/patches/patch-hw_ppc__newworld.c
new file mode 100644
index 00000000000..2bbe589243f
--- /dev/null
+++ b/emulators/qemu0/patches/patch-hw_ppc__newworld.c
@@ -0,0 +1,38 @@
+$NetBSD: patch-hw_ppc__newworld.c,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with round_page() macro in DragonFly's <cpu/param.h>
+
+--- hw/ppc_newworld.c.orig 2011-08-08 18:28:42 +0000
++++ hw/ppc_newworld.c
+@@ -120,7 +120,7 @@ static uint64_t translate_kernel_address
+ return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR;
+ }
+
+-static target_phys_addr_t round_page(target_phys_addr_t addr)
++static target_phys_addr_t round_pageq(target_phys_addr_t addr)
+ {
+ return (addr + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
+ }
+@@ -225,7 +225,7 @@ static void ppc_core99_init (ram_addr_t
+ }
+ /* load initrd */
+ if (initrd_filename) {
+- initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
++ initrd_base = round_pageq(kernel_base + kernel_size + KERNEL_GAP);
+ initrd_size = load_image_targphys(initrd_filename, initrd_base,
+ ram_size - initrd_base);
+ if (initrd_size < 0) {
+@@ -233,11 +233,11 @@ static void ppc_core99_init (ram_addr_t
+ initrd_filename);
+ exit(1);
+ }
+- cmdline_base = round_page(initrd_base + initrd_size);
++ cmdline_base = round_pageq(initrd_base + initrd_size);
+ } else {
+ initrd_base = 0;
+ initrd_size = 0;
+- cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
++ cmdline_base = round_pageq(kernel_base + kernel_size + KERNEL_GAP);
+ }
+ ppc_boot_device = 'm';
+ } else {
diff --git a/emulators/qemu0/patches/patch-hw_ppc__oldworld.c b/emulators/qemu0/patches/patch-hw_ppc__oldworld.c
new file mode 100644
index 00000000000..1a8e378444a
--- /dev/null
+++ b/emulators/qemu0/patches/patch-hw_ppc__oldworld.c
@@ -0,0 +1,38 @@
+$NetBSD: patch-hw_ppc__oldworld.c,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with round_page() macro in DragonFly's <cpu/param.h>
+
+--- hw/ppc_oldworld.c.orig 2011-08-08 18:28:42 +0000
++++ hw/ppc_oldworld.c
+@@ -59,7 +59,7 @@ static uint64_t translate_kernel_address
+ return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR;
+ }
+
+-static target_phys_addr_t round_page(target_phys_addr_t addr)
++static target_phys_addr_t round_pageq(target_phys_addr_t addr)
+ {
+ return (addr + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
+ }
+@@ -162,7 +162,7 @@ static void ppc_heathrow_init (ram_addr_
+ }
+ /* load initrd */
+ if (initrd_filename) {
+- initrd_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
++ initrd_base = round_pageq(kernel_base + kernel_size + KERNEL_GAP);
+ initrd_size = load_image_targphys(initrd_filename, initrd_base,
+ ram_size - initrd_base);
+ if (initrd_size < 0) {
+@@ -170,11 +170,11 @@ static void ppc_heathrow_init (ram_addr_
+ initrd_filename);
+ exit(1);
+ }
+- cmdline_base = round_page(initrd_base + initrd_size);
++ cmdline_base = round_pageq(initrd_base + initrd_size);
+ } else {
+ initrd_base = 0;
+ initrd_size = 0;
+- cmdline_base = round_page(kernel_base + kernel_size + KERNEL_GAP);
++ cmdline_base = round_pageq(kernel_base + kernel_size + KERNEL_GAP);
+ }
+ ppc_boot_device = 'm';
+ } else {
diff --git a/emulators/qemu0/patches/patch-hw_xilinx__axienet.c b/emulators/qemu0/patches/patch-hw_xilinx__axienet.c
new file mode 100644
index 00000000000..0edd560bd82
--- /dev/null
+++ b/emulators/qemu0/patches/patch-hw_xilinx__axienet.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-hw_xilinx__axienet.c,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with SSP read() macro in NetBSD's <ssp/unistd.h>
+
+--- hw/xilinx_axienet.c.orig 2011-08-08 18:28:42 +0000
++++ hw/xilinx_axienet.c
+@@ -189,7 +189,7 @@ static uint16_t mdio_read_req(struct MDI
+
+ phy = bus->devs[addr];
+ if (phy && phy->read) {
+- data = phy->read(phy, reg);
++ data = (*phy->read)(phy, reg);
+ } else {
+ data = 0xffff;
+ }
diff --git a/emulators/qemu0/patches/patch-ioport.c b/emulators/qemu0/patches/patch-ioport.c
new file mode 100644
index 00000000000..6a926f11153
--- /dev/null
+++ b/emulators/qemu0/patches/patch-ioport.c
@@ -0,0 +1,33 @@
+$NetBSD: patch-ioport.c,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+Avoid conflicts with SSP read() macro in NetBSD's <ssp/unistd.h>
+
+--- ioport.c.orig 2011-08-08 18:28:42 +0000
++++ ioport.c
+@@ -181,7 +181,7 @@ static uint32_t ioport_readb_thunk(void
+ IORange *ioport = opaque;
+ uint64_t data;
+
+- ioport->ops->read(ioport, addr - ioport->base, 1, &data);
++ (*ioport->ops->read)(ioport, addr - ioport->base, 1, &data);
+ return data;
+ }
+
+@@ -190,7 +190,7 @@ static uint32_t ioport_readw_thunk(void
+ IORange *ioport = opaque;
+ uint64_t data;
+
+- ioport->ops->read(ioport, addr - ioport->base, 2, &data);
++ (*ioport->ops->read)(ioport, addr - ioport->base, 2, &data);
+ return data;
+ }
+
+@@ -199,7 +199,7 @@ static uint32_t ioport_readl_thunk(void
+ IORange *ioport = opaque;
+ uint64_t data;
+
+- ioport->ops->read(ioport, addr - ioport->base, 4, &data);
++ (*ioport->ops->read)(ioport, addr - ioport->base, 4, &data);
+ return data;
+ }
+
diff --git a/emulators/qemu0/patches/patch-slirp_tcp__subr.c b/emulators/qemu0/patches/patch-slirp_tcp__subr.c
new file mode 100644
index 00000000000..187f75ac80d
--- /dev/null
+++ b/emulators/qemu0/patches/patch-slirp_tcp__subr.c
@@ -0,0 +1,21 @@
+$NetBSD: patch-slirp_tcp__subr.c,v 1.1 2012/06/07 21:35:37 ryoon Exp $
+
+When setting up an outgoing user mode networking TCP connection,
+disable the Nagle algorithm in the host-side connection. Either
+the VM is already doing Nagle, in which case there is no point
+in doing it twice, or it has chosen to disable it, in which case
+we should respect that choice. This change speeds up GDB remote
+debugging over TCP over user mode networking by multiple orders
+of magnitude.
+
+--- slirp/tcp_subr.c.orig 2011-10-12 16:41:43.000000000 +0000
++++ slirp/tcp_subr.c
+@@ -334,6 +334,8 @@ int tcp_fconnect(struct socket *so)
+ setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt ));
+ opt = 1;
+ setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(opt ));
++ opt = 1;
++ setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int));
+
+ addr.sin_family = AF_INET;
+ if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==