pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Import virtualbox-ose as virtualbox-ose-4.3.30 - This wip version is purely experimental , it is on the way, not completed at all, or just started to compile by wip/ kBuild-svn kBuild-0.1.5nb20150905 Build framework based on GNU make



Module Name:	pkgsrc-wip
Committed By:	Makoto Fujiwara <makoto%ki.nu@localhost>
Pushed By:	mef
Date:		Tue Sep 22 19:37:32 2015 +0900
Changeset:	f1d2fed01fd6c092a8ddc4a92b9f0f9b69aff506

Added Files:
	virtualbox-ose/DESCR
	virtualbox-ose/Makefile
	virtualbox-ose/PLIST
	virtualbox-ose/TODO
	virtualbox-ose/distinfo
	virtualbox-ose/files/0patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk
	virtualbox-ose/files/0patch-src-VBox-Devices-Bus-DevPciIch9.cpp
	virtualbox-ose/files/extrapatch-Config.kmk
	virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile
	virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile.kmk
	virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
	virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk
	virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri
	virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri2
	virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-x11include-xorg-server-1.17.1-compiler.h
	virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk
	virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-vbox.dsl
	virtualbox-ose/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
	virtualbox-ose/files/extrapatch-src-VBox-Main-src-server-generic-NetIf-generic.cpp
	virtualbox-ose/files/extrapatch-src-recompiler-Makefile.kmk
	virtualbox-ose/files/vboxheadless.in
	virtualbox-ose/files/vboxwatchdog.in
	virtualbox-ose/files/vboxwebsrv.in
	virtualbox-ose/patches/patch-Config.kmk
	virtualbox-ose/patches/patch-configure
	virtualbox-ose/patches/patch-include-VBox-com-array.h
	virtualbox-ose/patches/patch-include-VBox-vmm-cpumctx.h
	virtualbox-ose/patches/patch-include-iprt-x86.h
	virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
	virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
	virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
	virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py
	virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py
	virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py
	virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Additions-freebsd-drm-vboxvideo_drm.c
	virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
	virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop
	virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxmouse-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxvideo-vboxvideo_dri.c
	virtualbox-ose/patches/patch-src-VBox-Additions-x11-x11include-xorg-server-1.16.0-xf86Xinput.h
	virtualbox-ose/patches/patch-src-VBox-Devices-Audio-ossaudio.c
	virtualbox-ose/patches/patch-src-VBox-Devices-Input-PS2M.cpp
	virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h
	virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-resolv_conf_parser.c
	virtualbox-ose/patches/patch-src-VBox-Devices-PC-vbox.dsl
	virtualbox-ose/patches/patch-src-VBox-Devices-USB-DevOHCI.cpp
	virtualbox-ose/patches/patch-src-VBox-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp
	virtualbox-ose/patches/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp
	virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp
	virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_line.h
	virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_point.h
	virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
	virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
	virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c
	virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
	virtualbox-ose/patches/patch-src-VBox-Installer-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-VBox.sh
	virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-virtualbox.desktop
	virtualbox-ose/patches/patch-src-VBox-Main-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp
	virtualbox-ose/patches/patch-src-VBox-Main-src-server-MachineImpl.cpp
	virtualbox-ose/patches/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
	virtualbox-ose/patches/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp
	virtualbox-ose/patches/patch-src-VBox-Main-webservice-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Runtime-Makefile.kmk
	virtualbox-ose/patches/patch-src-VBox-Runtime-common-checksum-manifest3.cpp
	virtualbox-ose/patches/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp
	virtualbox-ose/patches/patch-src-VBox-Runtime-common-misc-uri.cpp
	virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c
	virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
	virtualbox-ose/patches/patch-src-VBox-Runtime-r3-freebsd-RTSystemQueryTotalRam-freebsd.cpp
	virtualbox-ose/patches/patch-src-VBox-Runtime-r3-posix-utf8-posix.cpp
	virtualbox-ose/patches/patch-src-recompiler-Sun-testmath.c
	virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight
	virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight
	virtualbox-ose/patches/patch-src_VBox_Runtime_VBox_log-vbox_cpp
	virtualbox-ose/patches/patch-src_VBox_VMM_testcase_mkdsk__sh

Log Message:
Import virtualbox-ose as virtualbox-ose-4.3.30
 - This wip version is purely experimental, it is on the way, not completed
    at all, or just started to compile by wip/kBuild-svn
    kBuild-0.1.5nb20150905 Build framework based on GNU make

 - This is ported from FreeBSD/ports (4.3.30)
    See http://svnweb.freebsd.org/ports/head/emulators/virtualbox-ose/
 - Thus there should be so many things to adjust from FreeBSD to pkgsrc

VirtualBox is a family of powerful x86 virtualization products for
enterprise as well as home use. Not only is VirtualBox an extremely
feature rich, high performance product for enterprise customers, it
is also the only professional solution that is freely available as
Open Source Software under the terms of the GNU General Public License.

WWW: http://www.virtualbox.org/

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=f1d2fed01fd6c092a8ddc4a92b9f0f9b69aff506

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 virtualbox-ose/DESCR                               |   7 +
 virtualbox-ose/Makefile                            |  91 ++++++
 virtualbox-ose/PLIST                               |   0
 virtualbox-ose/TODO                                |  52 +++
 virtualbox-ose/distinfo                            |  63 ++++
 ...VBox-Additions-common-VBoxGuestLib-Makefile.kmk |  18 ++
 .../0patch-src-VBox-Devices-Bus-DevPciIch9.cpp     |  22 ++
 virtualbox-ose/files/extrapatch-Config.kmk         |  27 ++
 ...rapatch-src-VBox-Additions-freebsd-drm-Makefile |  17 +
 ...tch-src-VBox-Additions-freebsd-drm-Makefile.kmk |  38 +++
 ...-src-VBox-Additions-x11-VBoxClient-Makefile.kmk |  11 +
 ...h-src-VBox-Additions-x11-vboxvideo-Makefile.kmk |  12 +
 ...c-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri | 168 ++++++++++
 ...-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri2 |  47 +++
 ...ns-x11-x11include-xorg-server-1.17.1-compiler.h |  51 +++
 ...xtrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk |  11 +
 .../files/extrapatch-src-VBox-Devices-PC-vbox.dsl  |  21 ++
 ...h-src-VBox-HostDrivers-Support-freebsd-Makefile |  11 +
 ...-VBox-Main-src-server-generic-NetIf-generic.cpp |  10 +
 .../files/extrapatch-src-recompiler-Makefile.kmk   |  10 +
 virtualbox-ose/files/vboxheadless.in               | 138 ++++++++
 virtualbox-ose/files/vboxwatchdog.in               |  53 +++
 virtualbox-ose/files/vboxwebsrv.in                 |  49 +++
 virtualbox-ose/patches/patch-Config.kmk            | 131 ++++++++
 virtualbox-ose/patches/patch-configure             | 135 ++++++++
 .../patches/patch-include-VBox-com-array.h         |  31 ++
 .../patches/patch-include-VBox-vmm-cpumctx.h       |  13 +
 virtualbox-ose/patches/patch-include-iprt-x86.h    |  21 ++
 ...-Additions-common-VBoxGuest-VBoxGuest-freebsd.c | 357 +++++++++++++++++++++
 ...Box-Additions-common-VBoxGuest-freebsd-Makefile |  12 +
 ...itions-common-VBoxGuest-freebsd-files_vboxguest |  20 ++
 ...ditions-common-crOpenGL-FreeBSD_i386_exports.py | 100 ++++++
 ...ons-common-crOpenGL-FreeBSD_i386_exports_dri.py | 100 ++++++
 ...-common-crOpenGL-FreeBSD_i386_glxapi_exports.py | 109 +++++++
 ...src-VBox-Additions-common-crOpenGL-Makefile.kmk |  74 +++++
 ...-src-VBox-Additions-freebsd-drm-vboxvideo_drm.c |  79 +++++
 ...-VBox-Additions-x11-Installer-98vboxadd-xclient |  19 ++
 ...VBox-Additions-x11-Installer-vboxclient.desktop |  12 +
 ...h-src-VBox-Additions-x11-vboxmouse-Makefile.kmk |  64 ++++
 ...rc-VBox-Additions-x11-vboxvideo-vboxvideo_dri.c |  16 +
 ...-x11-x11include-xorg-server-1.16.0-xf86Xinput.h |  30 ++
 .../patch-src-VBox-Devices-Audio-ossaudio.c        |  21 ++
 .../patches/patch-src-VBox-Devices-Input-PS2M.cpp  |  13 +
 ...h-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h |  14 +
 ...VBox-Devices-Network-slirp-resolv_conf_parser.c |  13 +
 .../patches/patch-src-VBox-Devices-PC-vbox.dsl     |  22 ++
 .../patches/patch-src-VBox-Devices-USB-DevOHCI.cpp |  13 +
 ...-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp | 177 ++++++++++
 ...Box-Frontends-VBoxManage-VBoxManageModifyVM.cpp |  13 +
 ...atch-src-VBox-Frontends-VirtualBox-Makefile.kmk |  15 +
 ...ds-VirtualBox-src-runtime-UIKeyboardHandler.cpp |  22 ++
 .../patch-src-VBox-GuestHost-OpenGL-Makefile.kmk   |  22 ++
 ...c-VBox-GuestHost-OpenGL-include-state-cr_line.h |  13 +
 ...-VBox-GuestHost-OpenGL-include-state-cr_point.h |  21 ++
 ...h-src-VBox-HostDrivers-Support-freebsd-Makefile |  20 ++
 ...-VBox-HostDrivers-Support-freebsd-files_vboxdrv |  12 +
 ...ch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk |  27 ++
 ...Drivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c |  16 +
 ...Drivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c |  74 +++++
 .../patches/patch-src-VBox-Installer-Makefile.kmk  |  17 +
 .../patch-src-VBox-Installer-freebsd-VBox.sh       |  63 ++++
 ...h-src-VBox-Installer-freebsd-virtualbox.desktop |  12 +
 .../patches/patch-src-VBox-Main-Makefile.kmk       |  14 +
 ...patch-src-VBox-Main-src-client-ConsoleImpl2.cpp |  36 +++
 .../patch-src-VBox-Main-src-server-MachineImpl.cpp |  49 +++
 ...tch-src-VBox-Main-src-server-VirtualBoxImpl.cpp |  13 +
 ...Main-src-server-freebsd-HostHardwareFreeBSD.cpp |  21 ++
 .../patch-src-VBox-Main-webservice-Makefile.kmk    |  41 +++
 .../patches/patch-src-VBox-Runtime-Makefile.kmk    |  25 ++
 ...-src-VBox-Runtime-common-checksum-manifest3.cpp |  13 +
 ...-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp |  13 +
 .../patch-src-VBox-Runtime-common-misc-uri.cpp     |  16 +
 ...ox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c | 131 ++++++++
 ...untime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h |  22 ++
 ...me-r3-freebsd-RTSystemQueryTotalRam-freebsd.cpp |  85 +++++
 .../patch-src-VBox-Runtime-r3-posix-utf8-posix.cpp |  28 ++
 .../patches/patch-src-recompiler-Sun-testmath.c    |  24 ++
 ...src_VBox_Installer_darwin_VirtualBox_postflight |  13 +
 ...-src_VBox_Installer_darwin_VirtualBox_preflight |  13 +
 .../patch-src_VBox_Runtime_VBox_log-vbox_cpp       |  13 +
 .../patches/patch-src_VBox_VMM_testcase_mkdsk__sh  |  13 +
 81 files changed, 3453 insertions(+)

diffs:
diff --git a/virtualbox-ose/DESCR b/virtualbox-ose/DESCR
new file mode 100644
index 0000000..d10019c
--- /dev/null
+++ b/virtualbox-ose/DESCR
@@ -0,0 +1,7 @@
+VirtualBox is a family of powerful x86 virtualization products for
+enterprise as well as home use. Not only is VirtualBox an extremely
+feature rich, high performance product for enterprise customers, it
+is also the only professional solution that is freely available as
+Open Source Software under the terms of the GNU General Public License.
+
+WWW: http://www.virtualbox.org/
diff --git a/virtualbox-ose/Makefile b/virtualbox-ose/Makefile
new file mode 100644
index 0000000..6e9fdfe
--- /dev/null
+++ b/virtualbox-ose/Makefile
@@ -0,0 +1,91 @@
+# $NetBSD$
+DISTNAME=virtualbox-ose-${DISTVERSION}
+
+# FreeBSD ports in emulator category
+CATEGORIES=	devel
+DISTVERSION=	4.3.30
+MASTER_SITES=	http://download.virtualbox.org/virtualbox/${DISTVERSION}/ \
+	http://tmp.chruetertee.ch/ \
+	http://disasterarea.chruetertee.ch/ \
+	http://download.virtualbox.org/virtualbox/${VBOX_GUEST_VER}/:guestadditions
+DISTFILES= VirtualBox-${DISTVERSION}${EXTRACT_SUFX} ${GADISTFILES}
+EXTRACT_ONLY= VirtualBox-${DISTVERSION}${EXTRACT_SUFX}
+EXTRACT_SUFX=	.tar.bz2
+
+# To try, disable following line, thanks
+BROKEN=		Package is not completed yet, sorry.
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+COMMENT=	General-purpose full virtualizer for x86 hardware
+LICENSE=	gnu-gpl-v2
+
+DEPENDS+=	cdrtools-[0-9]*:../../sysutils/cdrtools
+
+BUILD_DEPENDS+=	yasm-[0-9]*:../../devel/yasm
+BUILD_DEPENDS+=	kBuild-[0-9]*:../../wip/kBuild-svn
+
+USE_TOOLS+=	gtar pkg-config gmake
+#MAKE_ENV+=	PATH_KBUILD=${WRKDIR}${WRKSRC}/kBuild
+
+KMK_CONFIG=	`cat ${WRKSRC}/LocalConfig.kmk`
+WRKSRC=		${WRKDIR}/VirtualBox-${DISTVERSION}
+ONLY_FOR_ARCHS= i386 amd64
+
+CONFIGURE_ARGS=	# empty
+CONFIGURE_ARGS+= --disable-java --passive-mesa
+CONFIGURE_ARGS+= --with-gcc="${CC}" --with-g++="${CXX}"
+GNU_CONFIGURE=	yes
+USE_LANGUAGES+=	c c++
+
+SUBST_CLASSES+=		prefix
+SUBST_FILES.prefix+=	configure
+SUBST_FILES.prefix+=	src/VBox/Additions/x11/Installer/98vboxadd-xclient
+SUBST_FILES.prefix+=	src/VBox/Installer/freebsd/VBox.sh
+SUBST_FILES.prefix+=	src/VBox/Additions/x11/Installer/vboxclient.desktop
+
+SUBST_MESSAGE.prefix+=	Configure prefix to ${PREFIX}
+SUBST_STAGE.prefix+=	pre-configure
+SUBST_VARS.prefix+=	PREFIX X11BASE PYVERSSUFFIX
+
+KMK_CONFIG=	VBOX_LIBPATH_X11=${X11BASE}/lib
+KMK_CONFIG+=	VBOX_FREEBSD_SRC=/usr/src/sys
+KMK_CONFIG+=	KBUILD_PATH=${WRKSRC}/kBuild
+KMK_FLAGS=	-j1
+
+post-patch:
+	@${ECHO} 'VBOX_PATH_APP_PRIVATE_ARCH = ${VBOX_DIR}' > \
+	${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_PATH_SHARED_LIBS = ${VBOX_DIR}' >> \
+	${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_RUNPATH = ${VBOX_DIR}' >> \
+	${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_VBOXDRV =' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_TESTCASES =' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'SDK_VBOX_LIBPNG_INCS = ${PREFIX}/include/libpng' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'SDK_VBOX_LIBPNG_LIBS = png' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_ADDITIONS =' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_DRAG_AND_DROP = ${VBOX_WITH_QT4}' >> ${WRKSRC}/LocalConfig.kmk
+	@${ECHO} 'VBOX_WITH_X11_ADDITIONS =' >> ${WRKSRC}/LocalConfig.kmk
+
+do-build:
+	cd ${WRKSRC}/ && \
+	${SH} -c . kBuild/env.sh && ${KMK_CONFIG} ${PREFIX}/bin/kmk ${KMK_FLAGS}
+	.if ${PORT_OPTIONS:MPYTHON}
+	${PYTHON_CMD} -mcompileall ${KMK_BUILDDIR}/bin/sdk/bindings/xpcom/python/xpcom
+	.endif
+
+.include	"../../graphics/png/buildlink3.mk"
+.include	"../../multimedia/libvpx/buildlink3.mk"
+.include	"../../www/curl/buildlink3.mk"
+.include	"../../graphics/png/buildlink3.mk"
+.include	"../../textproc/libxslt/buildlink3.mk"
+.include	"../../devel/SDL/buildlink3.mk"
+.include	"../../x11/libXext/buildlink3.mk"
+.include	"../../x11/qt4-libs/buildlink3.mk"
+.include	"../../lang/python/pyversion.mk"
+.include	"../../lang/python/application.mk"
+
+.include	"../../mk/bsd.pkg.mk"
diff --git a/virtualbox-ose/PLIST b/virtualbox-ose/PLIST
new file mode 100644
index 0000000..e69de29
diff --git a/virtualbox-ose/TODO b/virtualbox-ose/TODO
new file mode 100644
index 0000000..976cdb5
--- /dev/null
+++ b/virtualbox-ose/TODO
@@ -0,0 +1,52 @@
+ - This wip version is purely experimental, it is on the way, not completed 
+   at all, or just started to compile by wip/kBuild-svn
+    kBuild-0.1.5nb20150905 Build framework based on GNU make
+
+ - This is ported from FreeBSD/ports (4.3.30)
+   See http://svnweb.freebsd.org/ports/head/emulators/virtualbox-ose/
+ - Thus there should be so many things to adjust from FreeBSD to pkgsrc
+
+ - Now you need to adjust src/VBox/Runtime/VBox/log-vbox.cpp first, say,
+   patches/patch-src_VBox_Runtime_VBox_log-vbox_cpp
+
+ - Current build status (errors are):
+
+(1) before patch to src/VBox/Runtime/VBox/log-vbox.cpp 
+------------------------------------------------------
+kBuild: Compiling RuntimeBldProg - /export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp:420:5: error: #error needs porting.
+ #   error needs porting.
+     ^
+kmk: *** [/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/out/netbsd.amd64/release/obj/RuntimeBldProg/VBox/log-vbox.o] Error 1
+The failing command:
+@c++ -c -O2 -g -pipe -pedantic -Wshadow -Wshadow -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-trigraphs -fdiagnostics-show-option -Wno-unused-parameter -Wno-long-long -Wno-long-long -Wno-delete-non-virtual-dtor -Wno-variadic-macros -O2 -fno-omit-frame-pointer -fno-strict-aliasing -m64 -I/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/include -I/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/libs/liblzf-3.4 -I/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/libs/kStuff/kStuff/include -I/usr/local/include -I/usr/pkg/include/libxml2 -I/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/include -I/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/out/netbsd.amd64/release -DVBOX -DVBOX_OSE -DVBOX_WITH_64_BITS_GUESTS -DVBOX_WITH_DEBUGGER -DRT_OS_NETBSD -DRT_ARCH_AMD64 -D__AMD64__ -DVBOX_WITH_HARDENING -D_REENTRANT -DIN_RING3 -DLOG_DISABLED -DIN_RT_R3 -DIN_RT_R3 -DLDR_WITH_NATIVE -DLDR_WI
TH_ELF32 -DLDR_WITH_PE -DRT_WITH_VBOX -DRT_NO_GIP -DRT_WITHOUT_NOCRT_WRAPPERS -DIPRT_WITH_OPENSSL -DLDR_WITH_KLDR -DRT_WITH_ICONV_CACHE -DIPRT_WITHOUT_LDR_VERIFY -DRT_NO_GIP -Wp,-MD,/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/out/netbsd.amd64/release/obj/RuntimeBldProg/VBox/log-vbox.o.dep -Wp,-MT,/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/out/netbsd.amd64/release/obj/RuntimeBldProg/VBox/log-vbox.o -Wp,-MP -o /export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/out/netbsd.amd64/release/obj/RuntimeBldProg/VBox/log-vbox.o /export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp
+*** Error code 2
+
+Stop.
+make[1]: stopped in /usr/pkgsrc/wip/virtualbox-ose
+*** Error code 1
+
+Stop.
+make: stopped in /usr/pkgsrc/wip/virtualbox-ose
+h97@makoto 17:51:24/150922(..wip/virtualbox-ose)% 
+
+(2) after easy patch to src/VBox/Runtime/VBox/log-vbox.cpp:
+
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp: In function 'RTLOGGER* RTLogDefaultInit()':
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp:386:21: error: 'CTL_KERN' was not declared in this scope
+         aiName[0] = CTL_KERN;
+                     ^
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp:387:21: error: 'KERN_PROC' was not declared in this scope
+         aiName[1] = KERN_PROC;
+                     ^
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp:388:21: error: 'KERN_PROC_ARGS' was not declared in this scope
+         aiName[2] = KERN_PROC_ARGS;     /* Introduced in FreeBSD 4.0 */
+                     ^
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp:389:28: error: 'getpid' was not declared in this scope
+         aiName[3] = getpid();
+                            ^
+/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/src/VBox/Runtime/VBox/log-vbox.cpp:391:80: error: 'sysctl' was not declared in this scope
+         int rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), NULL, &cchArgs, NULL, 0);
+                                                                                ^
+kmk: *** [/export/WRKOBJDIR/wip/virtualbox-ose/work/VirtualBox-4.3.30/out/netbsd.amd64/release/obj/RuntimeBldProg/VBox/log-vbox.o] Error 1
+The failing command:
diff --git a/virtualbox-ose/distinfo b/virtualbox-ose/distinfo
new file mode 100644
index 0000000..8c1cac6
--- /dev/null
+++ b/virtualbox-ose/distinfo
@@ -0,0 +1,63 @@
+$NetBSD$
+
+SHA1 (VirtualBox-4.3.30.tar.bz2) = 16976f2d520af78797f85404e38c3abb6084db09
+RMD160 (VirtualBox-4.3.30.tar.bz2) = bc43b45cc7eeecc2fde922d197cde3a1e6cede14
+Size (VirtualBox-4.3.30.tar.bz2) = 97428942 bytes
+SHA1 (patch-Config.kmk) = 9a3e0e7ccf45aecca2651c60d39eb78da734dead
+SHA1 (patch-configure) = 949f32c43fdd44dbfdd60312b7a088b2bb25af4a
+SHA1 (patch-include-VBox-com-array.h) = 3df9650bd11f2e21bdcb40d2b68d28121c3e01ea
+SHA1 (patch-include-VBox-vmm-cpumctx.h) = de663f58a60b79ba071457ffb001ff56580aa2ea
+SHA1 (patch-include-iprt-x86.h) = 09a66d29203ff7afa0a21be73bbf381243047d4f
+SHA1 (patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c) = b476d84a307cd50b3988a91636127e1c33a36770
+SHA1 (patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile) = 0a27940fa1270ce6f32ce56a4537988c378de59b
+SHA1 (patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest) = c431ea5ad26fbf5415ee71a482d6150cc603d1f3
+SHA1 (patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py) = f2b0f5017eef940e5be6c0cfe5d93f9919dd8e30
+SHA1 (patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py) = 4a47fc5ec3e986ddfa7c8a1c061345d7fda41ce9
+SHA1 (patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py) = 8f06961064e22d42306fd5d8796afee411cf5b62
+SHA1 (patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk) = 125d800b719b1981f2a87399938f862bb4c4fee5
+SHA1 (patch-src-VBox-Additions-freebsd-drm-vboxvideo_drm.c) = 055a052d35486ffd73ee6d9310e713bec2b8e540
+SHA1 (patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient) = 8ca6254f2f9eb4f1e69b51c4534796285e23aafe
+SHA1 (patch-src-VBox-Additions-x11-Installer-vboxclient.desktop) = fdfc40363156f67bd711bd33f8bd2ea11e501023
+SHA1 (patch-src-VBox-Additions-x11-vboxmouse-Makefile.kmk) = 1507c839b2a7bfdc723d3440051e9c3c9ee96036
+SHA1 (patch-src-VBox-Additions-x11-vboxvideo-vboxvideo_dri.c) = debe5caeaaff7ac14e8c1432d79dd8d0a4381337
+SHA1 (patch-src-VBox-Additions-x11-x11include-xorg-server-1.16.0-xf86Xinput.h) = 77e101c5def326698b0d95badea8d0986041bd71
+SHA1 (patch-src-VBox-Devices-Audio-ossaudio.c) = bb314ec5079168354e280eb76784d6ff352b8605
+SHA1 (patch-src-VBox-Devices-Input-PS2M.cpp) = f71d2382daefcdc829c354203f42f9cd9d19c352
+SHA1 (patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h) = 5b4a29696e70bcfc10f442125e572799d57bcca6
+SHA1 (patch-src-VBox-Devices-Network-slirp-resolv_conf_parser.c) = 92f2b982d16f43ee5ee90a98b009c4ebbcb1e104
+SHA1 (patch-src-VBox-Devices-PC-vbox.dsl) = 81f09bb27aeca654a89ff4d56e2945acc027b789
+SHA1 (patch-src-VBox-Devices-USB-DevOHCI.cpp) = 825c1cd44abb1695decb0d4c0c9605ac6bf998c7
+SHA1 (patch-src-VBox-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp) = ecad301eabd300cc82cb5ec86d86206da429175d
+SHA1 (patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp) = 3d74f987c7a63651dcd84924346c9dc0dd844e98
+SHA1 (patch-src-VBox-Frontends-VirtualBox-Makefile.kmk) = 24ea4f0db723fca0e06ab09abd0e0198faf0bdbb
+SHA1 (patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp) = de1d96a8669a160158d83d97676c9ea1a97fd512
+SHA1 (patch-src-VBox-GuestHost-OpenGL-Makefile.kmk) = bc235bfdd1ed27fc78d73806a59571c90d3e53be
+SHA1 (patch-src-VBox-GuestHost-OpenGL-include-state-cr_line.h) = 33601aab3c001887bc78bc509148e70297e193eb
+SHA1 (patch-src-VBox-GuestHost-OpenGL-include-state-cr_point.h) = cd55aedcefe10177b3e50245a3b938b34300ad64
+SHA1 (patch-src-VBox-HostDrivers-Support-freebsd-Makefile) = e0a4811a7efdc9abc5ae8ec616b69f79150ef903
+SHA1 (patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv) = fc1cb45677ef0c0028fc1b0d258fa74e6efa92c7
+SHA1 (patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk) = ad975823a6e88babb2145d122a87d372b43dafd9
+SHA1 (patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c) = 99bcd5bfd419065d87610730e5f5178f50dde664
+SHA1 (patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c) = c1f97103511e8b0e2ed75666e27a4117b2826702
+SHA1 (patch-src-VBox-Installer-Makefile.kmk) = 7fa3024aa4f6b4d439e70f813e4bb51924610dad
+SHA1 (patch-src-VBox-Installer-freebsd-VBox.sh) = 38f9b95e5de2758bc2b0b081938c959bd6612bc6
+SHA1 (patch-src-VBox-Installer-freebsd-virtualbox.desktop) = 4a36818a51a6f49da3433beda9c28b242025cdee
+SHA1 (patch-src-VBox-Main-Makefile.kmk) = 4cdba772fb94ee64624754ed2ecbba2edac17145
+SHA1 (patch-src-VBox-Main-src-client-ConsoleImpl2.cpp) = 780b0201662db38c079790ea496e2b3da8823063
+SHA1 (patch-src-VBox-Main-src-server-MachineImpl.cpp) = bd9ae36daaaf5e269d03b003f37095297668be90
+SHA1 (patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp) = f953af7f809d3a0672bb46a2c68ce72647fb8697
+SHA1 (patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp) = f52eb861940fffdc715a3f945721d61bedd8a6e1
+SHA1 (patch-src-VBox-Main-webservice-Makefile.kmk) = 6170994631263fb586015ac3ef9957932addda32
+SHA1 (patch-src-VBox-Runtime-Makefile.kmk) = e6eb99cf13e234fb412c74eb9ba78cdf1b2b861a
+SHA1 (patch-src-VBox-Runtime-common-checksum-manifest3.cpp) = 0848a226baef539ed703ecb4c694fe56e915b32c
+SHA1 (patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp) = 3c85ec921bfad6c654780db4c410f2ce327909dd
+SHA1 (patch-src-VBox-Runtime-common-misc-uri.cpp) = efac47610a942e196b8bb5cadec02b1c62086b3d
+SHA1 (patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c) = 7622528f6988110cfe2887f9d22a502b2839a556
+SHA1 (patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h) = 46f398e36198533a49799ce23b9c073a7a366861
+SHA1 (patch-src-VBox-Runtime-r3-freebsd-RTSystemQueryTotalRam-freebsd.cpp) = 2b6bc12c6d9a768ed6a3e1206ef032fad468cff2
+SHA1 (patch-src-VBox-Runtime-r3-posix-utf8-posix.cpp) = c14f53cbfd5b52c441a901b92375a7a52026cfb6
+SHA1 (patch-src-recompiler-Sun-testmath.c) = 89c5f18ff91b21da7e6096ef27421a05897bd76d
+SHA1 (patch-src_VBox_Installer_darwin_VirtualBox_postflight) = 7ca0133e7027a96779fa27cb0f525ed72d00e7c2
+SHA1 (patch-src_VBox_Installer_darwin_VirtualBox_preflight) = e4a020048a70095679f3e6716b242563e982608e
+SHA1 (patch-src_VBox_Runtime_VBox_log-vbox_cpp) = 94e6f6db208562682f8d5229b7e8273f62b08d82
+SHA1 (patch-src_VBox_VMM_testcase_mkdsk__sh) = 62e37d27d94330ff441ceaf47d111353bb696b2e
diff --git a/virtualbox-ose/files/0patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk b/virtualbox-ose/files/0patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk
new file mode 100644
index 0000000..71e85c9
--- /dev/null
+++ b/virtualbox-ose/files/0patch-src-VBox-Additions-common-VBoxGuestLib-Makefile.kmk
@@ -0,0 +1,18 @@
+--- src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk.orig	2010-10-07 11:37:10.000000000 +0200
++++ src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk	2010-10-07 11:36:16.000000000 +0200
+@@ -140,6 +140,7 @@
+ # the X server runtime instead of IPRT, for use with old servers where the
+ # C library is not available.
+ #
++ifdef VBOX_WITH_X11_ADDITIONS
+ VBoxGuestR3LibXFree86_TEMPLATE = VBOXGUESTR3XF86LIB
+ VBoxGuestR3LibXFree86_DEFS     = \
+ 	VBOX_WITH_HGCM \
+@@ -163,6 +164,7 @@
+         $(VBOX_PATH_X11_XFREE_4_3)/exports/include/X11
+ 
+ VBoxGuestR3LibRuntimeXF86.cpp_CXXFLAGS = -Wno-shadow
++endif
+ 
+ include	$(KBUILD_PATH)/subfooter.kmk
+ 
diff --git a/virtualbox-ose/files/0patch-src-VBox-Devices-Bus-DevPciIch9.cpp b/virtualbox-ose/files/0patch-src-VBox-Devices-Bus-DevPciIch9.cpp
new file mode 100644
index 0000000..6354f1e
--- /dev/null
+++ b/virtualbox-ose/files/0patch-src-VBox-Devices-Bus-DevPciIch9.cpp
@@ -0,0 +1,22 @@
+Fix ich9 bios to correctly configure pci bridge1 and pci bridge2
+
+avg: I think that it is a valid report, the patch is not perfect, but
+avg: it fixes the problem for most configurations and demonstrates the problem well
+avg: the explanation for them is that FreeBSD (unlike Linux and maybe other OSes)
+avg: entirely relies on platform doing correct bus numbering
+avg: currently we can not do any re-numbering/corrections
+
+See:		http://article.gmane.org/gmane.os.freebsd.devel.emulation/10438
+Submitted by:	Gustau Perez i Querol <gperez%entel.upc.edu@localhost>
+--- src/VBox/Devices/Bus/DevPciIch9.cpp.orig	2012-06-15 21:22:15.000000000 +0200
++++ src/VBox/Devices/Bus/DevPciIch9.cpp	2012-09-02 14:17:49.804118887 +0200
+@@ -1812,7 +1812,8 @@
+         PICH9PCIBUS pChildBus = PDMINS_2_DATA(pBridge->pDevIns, PICH9PCIBUS);
+         ich9pciInitBridgeTopology(pGlobals, pChildBus);
+     }
+-    PCIDevSetByte(pBridgeDev, VBOX_PCI_SUBORDINATE_BUS, pGlobals->uBus);
++    PCIDevSetByte(pBridgeDev, VBOX_PCI_PRIMARY_BUS, 0);
++    PCIDevSetByte(pBridgeDev, VBOX_PCI_SUBORDINATE_BUS, (pGlobals->uBus)-1);
+     Log2(("ich9pciInitBridgeTopology: for bus %p: primary=%d secondary=%d subordinate=%d\n",
+           pBus,
+           PCIDevGetByte(pBridgeDev, VBOX_PCI_PRIMARY_BUS),
diff --git a/virtualbox-ose/files/extrapatch-Config.kmk b/virtualbox-ose/files/extrapatch-Config.kmk
new file mode 100644
index 0000000..39f729b
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-Config.kmk
@@ -0,0 +1,27 @@
+--- Config.kmk.orig	2014-03-26 15:12:14.000000000 -0400
++++ Config.kmk	2014-05-07 16:07:36.000000000 -0400
+@@ -3042,6 +3042,7 @@
+  ifeq ($(VBOX_LDR_FMT32),elf)
+  TEMPLATE_VBoxRc_TOOL                = $(VBOX_GCC32_TOOL)
+  TEMPLATE_VBoxRc_CXXFLAGS            = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden) -fno-rtti
++ TEMPLATE_VBoxRc_CXXFLAGS.freebsd    = -fno-builtin
+  TEMPLATE_VBoxRc_CFLAGS              = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C)   $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden)
+   ifeq ($(KBUILD_TARGET),solaris)
+    TEMPLATE_VBoxRc_LDFLAGS           = -r
+@@ -3170,6 +3171,7 @@
+ TEMPLATE_VBoxR0_TOOL                = $(VBOX_GCC_TOOL)
+ TEMPLATE_VBoxR0_CFLAGS              = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_C)   $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions $(VBOX_GCC_fno-stack-protector) -fno-common $(VBOX_GCC_fvisibility-hidden) -std=gnu99
+ TEMPLATE_VBoxR0_CXXFLAGS            = -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-exceptions $(VBOX_GCC_fno-stack-protector) -fno-common $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) -fno-rtti
++TEMPLATE_VBoxR0_CXXFLAGS.freebsd    = -fno-builtin
+ TEMPLATE_VBoxR0_CFLAGS.amd64        = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables -ffreestanding
+ TEMPLATE_VBoxR0_CXXFLAGS.amd64      = -m64 -mno-red-zone -mcmodel=kernel -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-asynchronous-unwind-tables
+ ifeq ($(KBUILD_TARGET),solaris)
+@@ -3435,7 +3437,7 @@
+ 		| xargs -J% objcopy % $(out)
+ 
+ ## Strip debug info (comment out if debugging or something).
+-	objcopy --strip-debug $(out)
++#	objcopy --strip-debug $(out)
+ endef
+  else # x86
+ TOOL_FREEBSDKMODLD_LINK_SYSMOD_OUTPUT = $(outbase).kld
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile b/virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile
new file mode 100644
index 0000000..ef93e11
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile
@@ -0,0 +1,17 @@
+--- src/VBox/Additions/freebsd/drm/Makefile.orig	2015-03-16 13:00:32.000000000 -0400
++++ src/VBox/Additions/freebsd/drm/Makefile	2015-03-27 18:18:03.432353000 -0400
+@@ -18,10 +18,10 @@
+ 
+ KMOD = vboxvideo
+ 
+-SRCS = \
+-	vboxvideo_drm.c
++SRCS = vboxvideo_drm.c
++SRCS += device_if.h bus_if.h pci_if.h
++SRCS += opt_compat.h opt_drm.h opt_syscons.h
+ 
+-SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
++CFLAGS+= -DVBOXVIDEO_DRM2
+ 
+ .include <bsd.kmod.mk>
+-
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile.kmk b/virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile.kmk
new file mode 100644
index 0000000..b14967f
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-freebsd-drm-Makefile.kmk
@@ -0,0 +1,38 @@
+--- src/VBox/Additions/freebsd/drm/Makefile.kmk.orig	2015-03-16 13:00:32.000000000 -0400
++++ src/VBox/Additions/freebsd/drm/Makefile.kmk	2015-03-27 22:28:21.000000000 -0400
+@@ -46,6 +46,7 @@
+ vboxvideo_drm_TEMPLATE      = VBOXGUESTR0
+ vboxvideo_drm_NAME          = vboxvideo
+ vboxvideo_drm_DEFS          = VBOX_WITH_HGCM VBOX_SVN_REV=$(VBOX_SVN_REV)
++vboxvideo_drm_DEFS         += VBOXVIDEO_DRM2
+ vboxvideo_drm_DEPS         += $(VBOX_SVN_REV_KMK)
+ vboxvideo_drm_INCS.freebsd  = \
+ 	$(vboxvideo_drm_0_OUTDIR) \
+@@ -58,15 +59,24 @@
+ 	$(PATH_STAGE)/gen-sys-hdrs/pci_if.h \
+ 	$(PATH_STAGE)/gen-sys-hdrs/bus_if.h \
+ 	$(PATH_STAGE)/gen-sys-hdrs/device_if.h \
+-	$(vboxvideo_drm_0_OUTDIR)/opt_drm.h
++	$(vboxvideo_drm_0_OUTDIR)/opt_compat.h \
++	$(vboxvideo_drm_0_OUTDIR)/opt_drm.h \
++	$(vboxvideo_drm_0_OUTDIR)/opt_syscons.h
+ vboxvideo_drm_CLEAN.freebsd = $(vboxvideo_drm_DEPS)
+ 
+ #
+-# Header for DRM not included by us.
++# Headers for DRM not included by us.
+ #
++$$(vboxvideo_drm_0_OUTDIR)/opt_compat.h:
++	$(QUIET)$(MKDIR) -p $(vboxvideo_drm_0_OUTDIR)
++	$(QUIET)touch $(vboxvideo_drm_0_OUTDIR)/opt_compat.h
++
+ $$(vboxvideo_drm_0_OUTDIR)/opt_drm.h:
+ 	$(QUIET)$(MKDIR) -p $(vboxvideo_drm_0_OUTDIR)
+ 	$(QUIET)touch $(vboxvideo_drm_0_OUTDIR)/opt_drm.h
+ 
+-include $(FILE_KBUILD_SUB_FOOTER)
++$$(vboxvideo_drm_0_OUTDIR)/opt_syscons.h:
++	$(QUIET)$(MKDIR) -p $(vboxvideo_drm_0_OUTDIR)
++	$(QUIET)touch $(vboxvideo_drm_0_OUTDIR)/opt_syscons.h
+ 
++include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
new file mode 100644
index 0000000..70fce51
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
@@ -0,0 +1,11 @@
+--- src/VBox/Additions/x11/VBoxClient/Makefile.kmk.orig	2013-11-29 14:20:43.000000000 -0500
++++ src/VBox/Additions/x11/VBoxClient/Makefile.kmk	2013-12-16 14:03:08.000000000 -0500
+@@ -50,7 +50,7 @@
+ #	Xtst
+ # These are static replacements for gcc-specific parts of libstdc++
+ VBoxClient_LIBS += \
+-	supc++ \
++	cxxrt \
+ 	gcc_eh
+ ifdef VBOX_X11_SEAMLESS_GUEST
+  VBoxClient_DEFS += SEAMLESS_GUEST DYNAMIC_RESIZE
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk
new file mode 100644
index 0000000..ffcd895
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk
@@ -0,0 +1,12 @@
+--- src/VBox/Additions/x11/vboxvideo/Makefile.kmk.orig	2015-03-16 13:00:34.000000000 -0400
++++ src/VBox/Additions/x11/vboxvideo/Makefile.kmk	2015-03-30 02:29:37.842678000 -0400
+@@ -20,6 +20,9 @@
+ 
+ vboxvideo_70_DEFS := \
+ 	IN_MODULE XORG_7X RENDER=1 IN_RT_STATIC
++ifeq ($(KBUILD_TARGET),freebsd) # don't use .freebsd or anything here.
++ vboxvideo_70_DEFS += GCCUSESGAS
++endif
+ ifeq ($(KBUILD_TARGET),solaris) # don't use .solaris or anything here.
+  vboxvideo_70_DEFS += __EXTENSIONS__  ## @todo Why this?
+ endif
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri
new file mode 100644
index 0000000..9f7ba39
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri
@@ -0,0 +1,168 @@
+--- src/VBox/Additions/x11/vboxvideo/Makefile.kmk.orig	2015-03-02 10:06:58.000000000 -0500
++++ src/VBox/Additions/x11/vboxvideo/Makefile.kmk	2015-03-02 18:25:17.273964000 -0500
+@@ -26,7 +26,7 @@
+ vboxvideo_13_DEFS := $(vboxvideo_70_DEFS) VBOXVIDEO_13
+ vboxvideo_15_DEFS := \
+ 	$(vboxvideo_13_DEFS) NO_ANSIC PCIACCESS XSERVER_LIBPCIACCESS _XORG_SERVER_H_ _DIX_CONFIG_H_
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_15_DEFS += \
+  	VBOX_DRI
+ endif
+@@ -190,7 +190,7 @@
+ vboxvideo_drv_15_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_15_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_15_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10503000
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_15_DEFS += \
+  	VBOX_DRI_OLD
+ endif
+@@ -199,7 +199,7 @@
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.5.3
+ vboxvideo_drv_15_INCS += $(PATH_ROOT)/src/VBox/Runtime/include
+ vboxvideo_drv_15_SOURCES  = $(vboxvideo_drv_13_SOURCES)
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_15_SOURCES += \
+  	vboxvideo_dri.c
+ endif
+@@ -212,7 +212,7 @@
+ vboxvideo_drv_16_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_16_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_16_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10600000
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_16_DEFS += \
+  	VBOX_DRI_OLD
+ endif
+@@ -230,11 +230,19 @@
+ vboxvideo_drv_17_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_17_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_17_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10699000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_17_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_17_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.7.7
+ vboxvideo_drv_17_INCS += $(PATH_ROOT)/src/VBox/Runtime/include
+ vboxvideo_drv_17_SOURCES := $(vboxvideo_drv_13_SOURCES)
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_17_SOURCES += \
++ 	vboxvideo_dri.c
++endif
+ if1of ($(KBUILD_TARGET), linux solaris)
+  vboxvideo_drv_17_SOURCES += \
+  	vboxvideo_dri2.c
+@@ -248,6 +256,10 @@
+ vboxvideo_drv_18_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_18_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_18_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10800000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_18_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_18_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.8.0
+@@ -262,6 +274,10 @@
+ vboxvideo_drv_19_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_19_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_19_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10900000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_19_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_19_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.9.0
+@@ -276,6 +292,10 @@
+ vboxvideo_drv_110_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_110_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_110_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11000000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_110_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_110_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.10.0
+@@ -290,6 +310,10 @@
+ vboxvideo_drv_111_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_111_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_111_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11100000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_111_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_111_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.11.0
+@@ -304,6 +328,10 @@
+ vboxvideo_drv_112_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_112_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_112_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11200000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_112_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_112_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.12.0
+@@ -318,6 +346,10 @@
+ vboxvideo_drv_113_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_113_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_113_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11300000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_113_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_113_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.13.0
+@@ -332,6 +364,10 @@
+ vboxvideo_drv_114_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_114_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_114_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11400000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_114_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_114_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.14.0
+@@ -346,6 +382,10 @@
+ vboxvideo_drv_115_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_115_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_115_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11500000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_115_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_115_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.15.0
+@@ -360,6 +400,10 @@
+ vboxvideo_drv_116_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_116_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_116_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11600000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_116_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_116_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.16.0
+@@ -374,6 +418,10 @@
+ vboxvideo_drv_117_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_117_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_117_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=11700000
++if1of ($(KBUILD_TARGET), freebsd)
++ vboxvideo_drv_117_DEFS += \
++ 	VBOX_DRI_OLD
++endif
+ vboxvideo_drv_117_INCS = \
+ 	$(vboxvideo_xorg_INCS) \
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.17.1
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri2 b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri2
new file mode 100644
index 0000000..50d6c56
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk.dri2
@@ -0,0 +1,47 @@
+--- src/VBox/Additions/x11/vboxvideo/Makefile.kmk.orig	2015-03-16 13:00:34.000000000 -0400
++++ src/VBox/Additions/x11/vboxvideo/Makefile.kmk	2015-03-30 02:29:06.707754000 -0400
+@@ -26,7 +26,7 @@
+ vboxvideo_13_DEFS := $(vboxvideo_70_DEFS) VBOXVIDEO_13
+ vboxvideo_15_DEFS := \
+ 	$(vboxvideo_13_DEFS) NO_ANSIC PCIACCESS XSERVER_LIBPCIACCESS _XORG_SERVER_H_ _DIX_CONFIG_H_
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_15_DEFS += \
+  	VBOX_DRI
+ endif
+@@ -190,7 +190,7 @@
+ vboxvideo_drv_15_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_15_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_15_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10503000
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_15_DEFS += \
+  	VBOX_DRI_OLD
+ endif
+@@ -199,7 +199,7 @@
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.5.3
+ vboxvideo_drv_15_INCS += $(PATH_ROOT)/src/VBox/Runtime/include
+ vboxvideo_drv_15_SOURCES  = $(vboxvideo_drv_13_SOURCES)
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_15_SOURCES += \
+  	vboxvideo_dri.c
+ endif
+@@ -212,7 +212,7 @@
+ vboxvideo_drv_16_TEMPLATE = VBOXGUESTR3XORGMOD
+ vboxvideo_drv_16_CFLAGS := $(vboxvideo_drv_70_CFLAGS)
+ vboxvideo_drv_16_DEFS := $(vboxvideo_15_DEFS) XORG_VERSION_CURRENT=10600000
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_16_DEFS += \
+  	VBOX_DRI_OLD
+ endif
+@@ -235,7 +235,7 @@
+ 	$(VBOX_PATH_X11_ROOT)/xorg-server-1.7.7
+ vboxvideo_drv_17_INCS += $(PATH_ROOT)/src/VBox/Runtime/include
+ vboxvideo_drv_17_SOURCES := $(vboxvideo_drv_13_SOURCES)
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), freebsd linux solaris)
+  vboxvideo_drv_17_SOURCES += \
+  	vboxvideo_dri2.c
+ endif
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-x11include-xorg-server-1.17.1-compiler.h b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-x11include-xorg-server-1.17.1-compiler.h
new file mode 100644
index 0000000..90db3b3
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-x11include-xorg-server-1.17.1-compiler.h
@@ -0,0 +1,51 @@
+--- src/VBox/Additions/x11/x11include/xorg-server-1.17.1/compiler.h.orig	2015-02-12 11:08:51.000000000 -0500
++++ src/VBox/Additions/x11/x11include/xorg-server-1.17.1/compiler.h	2015-02-18 17:44:16.919457000 -0500
+@@ -972,26 +972,26 @@
+ static __inline__ void
+ outb(unsigned short port, unsigned char val)
+ {
+-    __asm__ __volatile__("out%B0 (%1)"::"a"(val), "d"(port));
++    __asm__ __volatile__("outb %0,%1"::"a"(val), "d"(port));
+ }
+ 
+ static __inline__ void
+ outw(unsigned short port, unsigned short val)
+ {
+-    __asm__ __volatile__("out%W0 (%1)"::"a"(val), "d"(port));
++    __asm__ __volatile__("outw %0,%1"::"a"(val), "d"(port));
+ }
+ 
+ static __inline__ void
+ outl(unsigned short port, unsigned int val)
+ {
+-    __asm__ __volatile__("out%L0 (%1)"::"a"(val), "d"(port));
++    __asm__ __volatile__("outl %0,%1"::"a"(val), "d"(port));
+ }
+ 
+ static __inline__ unsigned int
+ inb(unsigned short port)
+ {
+     unsigned char ret;
+-    __asm__ __volatile__("in%B0 (%1)":"=a"(ret):"d"(port));
++    __asm__ __volatile__("inb %1,%0":"=a"(ret):"d"(port));
+ 
+     return ret;
+ }
+@@ -1000,7 +1000,7 @@
+ inw(unsigned short port)
+ {
+     unsigned short ret;
+-    __asm__ __volatile__("in%W0 (%1)":"=a"(ret):"d"(port));
++    __asm__ __volatile__("inw %1,%0":"=a"(ret):"d"(port));
+ 
+     return ret;
+ }
+@@ -1009,7 +1009,7 @@
+ inl(unsigned short port)
+ {
+     unsigned int ret;
+-    __asm__ __volatile__("in%L0 (%1)":"=a"(ret):"d"(port));
++    __asm__ __volatile__("inl %1,%0":"=a"(ret):"d"(port));
+ 
+     return ret;
+ }
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk b/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk
new file mode 100644
index 0000000..c2a39f4
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-ipxe-Makefile.kmk
@@ -0,0 +1,11 @@
+--- src/VBox/Devices/PC/ipxe/Makefile.kmk.orig	2013-11-29 14:23:32.000000000 -0500
++++ src/VBox/Devices/PC/ipxe/Makefile.kmk	2013-12-13 15:06:45.000000000 -0500
+@@ -35,7 +35,7 @@
+ iPxeBiosBin_CLEAN    = \
+ 	$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c \
+ 
+-if1of ($(KBUILD_TARGET), darwin os2 solaris win)
++if1of ($(KBUILD_TARGET), darwin freebsd os2 solaris win)
+  $$(iPxeBiosBin_0_OUTDIR)/iPxeBiosBin.c: $(PATH_SUB_CURRENT)/iPxeBiosBin.rom $(VBOX_BIN2C) | $$(dir $$@)
+ 	$(call MSG_TOOL,bin2c,iPxeBiosBin,$<,$@)
+ 	$(QUIET)$(VBOX_BIN2C) -min 32 -max 56 -mask 0x1ff -export NetBiosBinary $< $@
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-vbox.dsl b/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-vbox.dsl
new file mode 100644
index 0000000..0de4a37
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Devices-PC-vbox.dsl
@@ -0,0 +1,21 @@
+Workaround for an regression in acpica 20101015.
+
+Compile error:
+kBuild: iasl DevicesR3 - src/VBox/Devices/PC/vbox.dsl
+   736:                           Name (_CID, "smc-napa")
+Error 4001 - String must be entirely alphanumeric ^
+(smc-napa)
+
+See: http://lists.freebsd.org/pipermail/freebsd-acpi/2010-October/006795.html
+
+--- src/VBox/Devices/PC/vbox.dsl.orig	2010-10-08 22:10:12.000000000 +0200
++++ src/VBox/Devices/PC/vbox.dsl	2010-10-27 14:45:38.000000000 +0200
+@@ -733,7 +733,7 @@
+                 Device (SMC)
+                 {
+                     Name (_HID, EisaId ("APP0001"))
+-                    Name (_CID, "smc-napa")
++                    Name (_CID, "smcnapa")
+ 
+                     Method (_STA, 0, NotSerialized)
+                     {
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile b/virtualbox-ose/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
new file mode 100644
index 0000000..67361da
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-HostDrivers-Support-freebsd-Makefile
@@ -0,0 +1,11 @@
+--- src/VBox/HostDrivers/Support/freebsd/Makefile.orig	2012-10-18 16:23:16.000000000 +0200
++++ src/VBox/HostDrivers/Support/freebsd/Makefile	2012-10-20 08:13:07.301179212 +0200
+@@ -27,7 +27,7 @@
+ 
+ KMOD = vboxdrv
+ 
+-CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS
++CFLAGS += -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVBOX_WITH_64_BITS_GUESTS -DDEBUG
+ 
+ .if (${MACHINE_ARCH} == "i386")
+  CFLAGS += -DRT_ARCH_X86
diff --git a/virtualbox-ose/files/extrapatch-src-VBox-Main-src-server-generic-NetIf-generic.cpp b/virtualbox-ose/files/extrapatch-src-VBox-Main-src-server-generic-NetIf-generic.cpp
new file mode 100644
index 0000000..18702f2
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-VBox-Main-src-server-generic-NetIf-generic.cpp
@@ -0,0 +1,10 @@
+--- src/VBox/Main/src-server/generic/NetIf-generic.cpp.orig	2013-08-21 13:05:31.000000000 +0400
++++ src/VBox/Main/src-server/generic/NetIf-generic.cpp	2013-08-27 18:17:51.598216723 +0400
+@@ -22,6 +22,7 @@
+ #include <iprt/path.h>
+ #include <iprt/param.h>
+ #include <sys/ioctl.h>
++#include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <net/if.h>
+ #include <errno.h>
diff --git a/virtualbox-ose/files/extrapatch-src-recompiler-Makefile.kmk b/virtualbox-ose/files/extrapatch-src-recompiler-Makefile.kmk
new file mode 100644
index 0000000..cb720f9
--- /dev/null
+++ b/virtualbox-ose/files/extrapatch-src-recompiler-Makefile.kmk
@@ -0,0 +1,10 @@
+--- src/recompiler/Makefile.kmk.orig	2013-11-29 14:25:09.000000000 -0500
++++ src/recompiler/Makefile.kmk	2013-12-13 14:23:11.000000000 -0500
+@@ -41,6 +41,7 @@
+ #
+ ifneq ($(KBUILD_TARGET),win)
+  VBoxRemPrimary_TEMPLATE       = VBOXR3NP
++ VBoxRemPrimary_TOOL.freebsd   = VBoxGccFreeBSD
+  # workaround the regparm bug in gcc <= 3.3
+  VBoxRemPrimary_DEFS           = $(if $(VBOX_GCC_BUGGY_REGPARM),GCC_WITH_BUGGY_REGPARM,)
+ else
diff --git a/virtualbox-ose/files/vboxheadless.in b/virtualbox-ose/files/vboxheadless.in
new file mode 100644
index 0000000..4934ef8
--- /dev/null
+++ b/virtualbox-ose/files/vboxheadless.in
@@ -0,0 +1,138 @@
+#!/bin/sh
+
+# $FreeBSD: head/emulators/virtualbox-ose/files/vboxheadless.in 379144 2015-02-17 07:07:01Z jkim $
+#
+# PROVIDE: vboxheadless
+# REQUIRE: LOGIN vboxnet
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxheadless
+#
+# vboxheadless_enable (bool):         Set to "NO" by default.
+#                                     Set it to "YES" to enable vboxheadless.
+# vboxheadless_machines (str):        Space separated list of machines 
+# vboxheadless_user (str):            Default user account to run with.
+#                                     (default: %%VBOXUSER%%)
+# vboxheadless_stop (str):            Default stop cmd for VBoxManage controlvm.
+#                                     (default: savestate)
+# vboxheadless_delay (int):           Default startup/shutdown delay in seconds.
+#                                     (default: 0)
+# vboxheadless_<machine>_name (str):  Virtualbox machine name or UUID.
+# vboxheadless_<machine>_user (str):  User account to run with.
+# vboxheadless_<machine>_flags (str): Additional flags for VBoxHeadless.
+# vboxheadless_<machine>_stop (str):  Stop command for VBoxManage controlvm.
+# vboxheadless_<machine>_delay (int): Startup and shutdown delay in seconds.
+
+. /etc/rc.subr
+
+name="vboxheadless"
+rcvar=vboxheadless_enable
+
+command="%%VBOXDIR%%/VBoxHeadless"
+pidbase="/var/run/${name}"
+   
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+status_cmd="${name}_status"
+
+vboxheadless_start()
+{
+	local machine mpidfile pid vmname vmuser vmflags vmdelay
+
+	echo "Starting Virtual Machines:"
+	for machine in ${vboxheadless_machines}; do
+		mpidfile="${pidbase}_${machine}.pid"
+		pid=$(check_pidfile $mpidfile $command)
+		eval vmname="\${vboxheadless_${machine}_name:-${machine}}"
+		eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}"
+		eval vmflags="\${vboxheadless_${machine}_flags:-}"
+		eval vmdelay="\${vboxheadless_${machine}_delay:-${vboxheadless_delay}}"
+
+		HOME=$(/usr/sbin/pw usershow -7 -n "${vmuser}" | /usr/bin/cut -d: -f6)
+
+		/usr/bin/printf "%25s " "${vmname}"
+
+		/usr/bin/su ${vmuser} -c "%%VBOXDIR%%/VBoxManage showvminfo '${vmname}' >/dev/null" 2>/dev/null
+
+		if [ $? != 0 ]; then
+			echo "Unknown machine"
+			continue
+		fi
+
+		if [ -n "${pid}" ]; then 
+			echo "Already running? (pid=${pid})"
+			continue
+		fi
+
+		/bin/sleep ${vmdelay}
+		/usr/bin/install -o ${vmuser} -g %%VBOXGROUP%% -m 644 /dev/null ${mpidfile}
+		/usr/sbin/daemon -f -p ${mpidfile} -u ${vmuser} ${command} --startvm "${vmname}" ${vmflags}
+		echo "Started"
+	done
+}
+
+vboxheadless_stop()
+{
+	local machine mpidfile pid vmname vmuser vmstop vmdelay
+
+	echo "Saving states for Virtual Machines:"
+	for machine in ${vboxheadless_machines}; do
+		mpidfile="${pidbase}_${machine}.pid"
+		pid=$(check_pidfile $mpidfile $command)
+		eval vmname="\${vboxheadless_${machine}_name:-${machine}}"
+		eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}"
+		eval vmstop="\${vboxheadless_${machine}_stop:-${vboxheadless_stop}}"
+		eval vmdelay="\${vboxheadless_${machine}_delay:-${vboxheadless_delay}}"
+
+		/usr/bin/printf "%25s " "${vmname}"
+
+		if [ -n "${pid}" ]; then
+			/bin/sleep ${vmdelay}
+			/usr/bin/su ${vmuser} -c "%%VBOXDIR%%/VBoxManage controlvm '${vmname}' ${vmstop} >/dev/null" 2>/dev/null
+			wait_for_pids $pid >/dev/null
+			echo "Stopped"
+		else
+			echo "Not running?"
+		fi
+	done
+}
+
+vboxheadless_status()
+{
+	local machine mpidfile pid vmname vmuser
+
+	/usr/bin/printf "%25s %s\n" "Machine" "Status"
+	/usr/bin/printf "%25s %s\n" "-------------------------" "------------"
+
+	for machine in ${vboxheadless_machines}; do
+		mpidfile="${pidbase}_${machine}.pid"
+		pid=$(check_pidfile $mpidfile $command)
+		eval vmname="\${vboxheadless_${machine}_name:-${machine}}"
+		eval vmuser="\${vboxheadless_${machine}_user:-${vboxheadless_user}}"
+
+		/usr/bin/su ${vmuser} -c "%%VBOXDIR%%/VBoxManage showvminfo '${vmname}' >/dev/null" 2>/dev/null
+
+		if [ $? != 0 ]; then
+			/usr/bin/printf "%20s %s\n" "${vmname}" "Unknown Machine"
+		elif [ -n "${pid}" ]; then
+			/usr/bin/printf "%25s %s\n" "${vmname}" "Running"
+		else
+			/usr/bin/printf "%25s %s\n" "${vmname}" "Powered Off"
+		fi
+	done
+}
+
+load_rc_config $name
+
+: ${vboxheadless_enable="NO"}
+: ${vboxheadless_user="%%VBOXUSER%%"}
+: ${vboxheadless_stop="savestate"}
+: ${vboxheadless_delay="0"}
+
+cmd_arg="$1" ; shift
+
+if [ -n "$*" ]; then
+    vboxheadless_machines="$*"
+fi
+
+run_rc_command "${cmd_arg}"
diff --git a/virtualbox-ose/files/vboxwatchdog.in b/virtualbox-ose/files/vboxwatchdog.in
new file mode 100644
index 0000000..244caea
--- /dev/null
+++ b/virtualbox-ose/files/vboxwatchdog.in
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# $FreeBSD: head/emulators/virtualbox-ose/files/vboxwatchdog.in 379144 2015-02-17 07:07:01Z jkim $
+#
+# PROVIDE: vboxwatchdog
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxwatchdog
+#
+# vboxwatchdog_enable (bool):	Set to "NO" by default.
+#				Set it to "YES" to enable vboxwatchdog.
+# vboxwatchdog_user (str):	User account to run with.
+# vboxwatchdog_flags (str):	Custom flags for VBoxWatchdog.
+
+. /etc/rc.subr
+
+name=vboxwatchdog
+rcvar=vboxwatchdog_enable
+
+command="%%VBOXDIR%%/VBoxBalloonCtrl"
+pidfile="/var/run/${name}.pid"
+
+start_cmd="${name}_start"
+
+vboxwatchdog_start()
+{
+	local pid
+
+	HOME=$(/usr/sbin/pw usershow -7 -n "${vboxwatchdog_user}" | /usr/bin/cut -d: -f6)
+	pid=$(check_pidfile $pidfile $command)
+
+	if [ -n "${pid}" ]; then
+		echo "${name} already running? (pid=${pid})."
+		return 1
+	fi
+
+	# prevent inheriting this setting to VBoxSVC
+	unset VBOX_RELEASE_LOG_DEST
+
+	echo -n "Starting ${name}"
+	/usr/bin/install -o ${vboxwatchdog_user} -g %%VBOXGROUP%% -m 644 /dev/null ${pidfile}
+	/usr/sbin/daemon -f -p ${pidfile} -u ${vboxwatchdog_user} ${command} ${vboxwatchdog_flags}
+	echo '.'
+}
+
+load_rc_config $name
+
+: ${vboxwatchdog_enable="NO"}
+: ${vboxwatchdog_user="%%VBOXUSER%%"}
+: ${vboxwatchdog_flags=""}
+
+run_rc_command "$1"
diff --git a/virtualbox-ose/files/vboxwebsrv.in b/virtualbox-ose/files/vboxwebsrv.in
new file mode 100644
index 0000000..81fe4d3
--- /dev/null
+++ b/virtualbox-ose/files/vboxwebsrv.in
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# $FreeBSD: head/emulators/virtualbox-ose/files/vboxwebsrv.in 379144 2015-02-17 07:07:01Z jkim $
+#
+# PROVIDE: vboxwebsrv
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following line to /etc/rc.conf[.local] to enable vboxwebsrv
+#
+# vboxwebsrv_enable (bool):	Set to "NO" by default.
+#				Set it to "YES" to enable vboxwebsrv.
+# vboxwebsrv_user (str):	User account to run with.
+# vboxwebsrv_flags (str):	Custom flags for vboxwebsrv.
+
+. /etc/rc.subr
+
+name=vboxwebsrv
+rcvar=vboxwebsrv_enable
+
+command="%%VBOXDIR%%/vboxwebsrv"
+pidfile="/var/run/${name}.pid"
+
+start_cmd="${name}_start"
+
+vboxwebsrv_start()
+{
+	local pid
+
+	HOME=$(/usr/sbin/pw usershow -7 -n "${vboxwebsrv_user}" | /usr/bin/cut -d: -f6)
+	pid=$(check_pidfile $pidfile $command)
+
+	if [ -n "${pid}" ]; then
+		echo "${name} already running? (pid=${pid})."
+		return 1
+	fi
+
+	echo -n "Starting ${name}"
+	/usr/bin/install -o ${vboxwebsrv_user} -g %%VBOXGROUP%% -m 644 /dev/null ${pidfile}
+	/usr/sbin/daemon -f -p ${pidfile} -u ${vboxwebsrv_user} ${command} ${vboxwebsrv_flags}
+	echo '.'
+}
+
+load_rc_config $name
+
+: ${vboxwebsrv_enable="NO"}
+: ${vboxwebsrv_user="%%VBOXWSUSER%%"}
+
+run_rc_command "$1"
diff --git a/virtualbox-ose/patches/patch-Config.kmk b/virtualbox-ose/patches/patch-Config.kmk
new file mode 100644
index 0000000..3a94027
--- /dev/null
+++ b/virtualbox-ose/patches/patch-Config.kmk
@@ -0,0 +1,131 @@
+$NetBSD$
+
+--- Config.kmk.orig	2014-07-16 16:59:27.000000000 -0400
++++ Config.kmk	2014-07-16 17:12:48.000000000 -0400
+@@ -339,7 +339,7 @@
+ # Include documentation in the package
+ VBOX_WITH_DOCS_PACKING = 1
+ # Include CHM when building docs (unset in LocalConfig.kmk to suppress CHM)
+-ifn1of ($(KBUILD_TARGET), linux)
++ifn1of ($(KBUILD_TARGET), freebsd linux)
+  VBOX_WITH_DOCS_CHM = 1
+ endif
+ # By default only include translations in documentation-only builds
+@@ -602,7 +602,7 @@
+ # Enable this to build vbox-img even if VBOX_WITH_TESTCASES is disabled
+ VBOX_WITH_VBOX_IMG =
+ # Enables the VPX module for VM video capturing
+-if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), darwin.x86 darwin.amd64 linux.x86 linux.amd64 solaris.amd64 win.x86 win.amd64)
++if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH), darwin.x86 darwin.amd64 freebsd.x86 freebsd.amd64 linux.x86 linux.amd64 solaris.amd64 win.x86 win.amd64)
+  VBOX_WITH_VPX = 1
+ endif
+ # Enable shared folders
+@@ -891,10 +891,6 @@
+  VBOX_WITH_VBOXSDL=
+ endif
+ 
+-ifeq ($(KBUILD_TARGET),freebsd)
+- VBOX_WITH_DOCS=
+-endif
+-
+ ifeq ($(KBUILD_TARGET),haiku)
+  # Don't bother with SDL ttf for now.
+  VBOX_WITH_SECURELABEL=
+@@ -1050,7 +1046,7 @@
+  VBOX_WITH_SECURELABEL=
+  VBOX_WITH_KCHMVIEWER=
+  VBOX_WITH_PLUGIN_CRYPT=
+- ifn1of ($(KBUILD_TARGET), linux)
++ ifn1of ($(KBUILD_TARGET), freebsd linux)
+   VBOX_WITH_DOCS=
+   VBOX_WITH_DOCS_PACKING=
+  endif
+@@ -3476,16 +3472,16 @@
+ 	$(VBOX_GCC_WARN) -Wpointer-arith -Winline $(VBOX_GCC_Wno-pointer-sign) $(VBOX_GCC_fdiagnostics-show-option) \
+ 	-Wstrict-prototypes -Wmissing-prototypes -Wstrict-prototypes \
+ 	-Wimplicit-function-declaration -Werror-implicit-function-declaration \
+-	-O2 -fformat-extensions -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 \
++	-O2 -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 \
+ 	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
+ 	-nostdinc -std=c99
+-TEMPLATE_VBOXR0DRV_CFLAGS.x86          = -m32 -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
++TEMPLATE_VBOXR0DRV_CFLAGS.x86          = -m32 -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2
+ TEMPLATE_VBOXR0DRV_CFLAGS.amd64        = -m64 --param inline-unit-growth=100 --param large-function-growth=1000 \
+ 	-fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx \
+ 	-mno-3dnow -msoft-float -fno-asynchronous-unwind-tables -Wundef
+ TEMPLATE_VBOXR0DRV_CXXFLAGS            = -fno-exceptions -fno-rtti \
+ 	$(VBOX_GCC_WARN) -Wpointer-arith -Winline \
+-	-O2 -fno-format-extensions -fno-strict-aliasing -fno-common -finline-limit=8000 \
++	-O2 -fno-strict-aliasing -fno-common -finline-limit=8000 \
+ 	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
+ 	-nostdinc
+ TEMPLATE_VBOXR0DRV_CXXFLAGS.x86        = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
+@@ -3719,12 +3715,8 @@
+ TEMPLATE_VBOXR3EXE_TOOL                = GXX3
+ TEMPLATE_VBOXR3EXE_LIBS                = pthread
+ TEMPLATE_VBOXR3EXE_INCS               += \
+-	/usr/include \
+-	/usr/X11R6/include \
+ 	/usr/local/include
+ TEMPLATE_VBOXR3EXE_LIBPATH            += \
+-	/usr/lib \
+-	/usr/X11R6/lib \
+ 	/usr/local/lib
+  else ifeq ($(KBUILD_TARGET),solaris)
+ TEMPLATE_VBOXR3EXE_TOOL                = GXX3PLAIN
+@@ -3982,7 +3974,7 @@
+  TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.win.amd64 = $(TEMPLATE_VBOXR3EXE_LDFLAGS.win.amd64) /entry:suplibHardenedWindowsMain
+  TEMPLATE_VBOXR3HARDENEDEXE_LIBS.x86       = $(NOT_SUCH_VARIABLE)
+  TEMPLATE_VBOXR3HARDENEDEXE_LIBS.amd64     = $(NOT_SUCH_VARIABLE)
+-else ifn1of ($(KBUILD_TARGET), os2)
++else ifn1of ($(KBUILD_TARGET), os2 freebsd)
+  TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS       = $(filter-out '$(VBOX_GCC_RPATH_OPT)%,$(TEMPLATE_VBOXR3EXE_LDFLAGS))
+  TEMPLATE_VBOXR3HARDENEDEXE_LDFLAGS.linux = $(filter-out $(VBOX_GCC_ORIGIN_OPT),$(TEMPLATE_VBOXR3EXE_LDFLAGS.linux))
+ endif
+@@ -4370,12 +4362,8 @@
+ TEMPLATE_VBOXMAINEXE_TOOL                = GXX3
+ TEMPLATE_VBOXMAINEXE_LIBS                = $(LIB_RUNTIME)
+ TEMPLATE_VBOXMAINEXE_INCS               += \
+-	/usr/include \
+-	/usr/X11R6/include \
+ 	/usr/local/include
+ TEMPLATE_VBOXMAINEXE_LIBPATH            += \
+-	/usr/lib \
+-	/usr/X11R6/lib \
+ 	/usr/local/lib
+ else ifeq ($(KBUILD_TARGET),solaris)
+ TEMPLATE_VBOXMAINEXE_TOOL                = GXX3PLAIN
+@@ -4838,12 +4826,8 @@
+ 	$(VBOX_LIBPATH_X11)
+    ifeq ($(KBUILD_TARGET),freebsd)
+     TEMPLATE_VBOXQT4GUIEXE_INCS += \
+-	/usr/include \
+-	/usr/X11R6/include \
+ 	/usr/local/include
+     TEMPLATE_VBOXQT4GUIEXE_LIBPATH += \
+-	/usr/lib \
+-	/usr/X11R6/lib \
+ 	/usr/local/lib
+    endif
+    ifeq ($(KBUILD_TARGET),solaris)
+@@ -5035,12 +5019,8 @@
+ TEMPLATE_VBoxBldProg_TOOL                = GXX3
+ TEMPLATE_VBoxBldProg_LIBS                = pthread
+ TEMPLATE_VBoxBldProg_INCS               += \
+-	/usr/include \
+-	/usr/X11R6/include \
+ 	/usr/local/include
+ TEMPLATE_VBoxBldProg_LIBPATH            += \
+-	/usr/lib \
+-	/usr/X11R6/lib \
+ 	/usr/local/lib
+  else ifeq ($(KBUILD_HOST),solaris)
+ TEMPLATE_VBoxBldProg_TOOL                = GXX3PLAIN
+@@ -5427,6 +5407,7 @@
+ 	-current_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
+ 	-compatibility_version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD)
+ TEMPLATE_VBOXCROGLR3HOSTDLL_LDFLAGS.linux    = -Wl,--no-as-needed
++TEMPLATE_VBOXCROGLR3HOSTDLL_LDFLAGS.freebsd  = -Wl,--no-as-needed
+ TEMPLATE_VBOXCROGLR3HOSTDLL_BLDDIRS          = $(VBOX_PATH_CROGL_GENFILES)/
+ 
+ #
diff --git a/virtualbox-ose/patches/patch-configure b/virtualbox-ose/patches/patch-configure
new file mode 100644
index 0000000..83e6ac7
--- /dev/null
+++ b/virtualbox-ose/patches/patch-configure
@@ -0,0 +1,135 @@
+$NetBSD$
+
+--- configure.orig	2015-07-10 23:27:43.000000000 +0900
++++ configure	2015-09-22 00:23:56.000000000 +0900
+@@ -49,7 +49,7 @@ case "$OS" in
+     ;;
+   darwin)
+     ;;
+-  freebsd)
++  freebsd|netbsd)
+     ;;
+   sunos)
+     OS='solaris'
+@@ -118,8 +118,8 @@ LIBPTHREAD="-lpthread"
+ LIBCAP="-lcap"
+ GSOAP=""
+ GSOAP_IMPORT=""
+-INCX11="/usr/local/include"
+-LIBX11="-L/usr/X11R6/lib -L/usr/X11R6/lib64 -L/usr/local/lib -lXext -lX11"
++INCX11="@X11BASE@/include"
++LIBX11="-Wl,-rpath=@X11BASE@/lib -L@X11BASE@/lib -L/usr/X11R6/lib64 -L/usr/local/lib -lXext -lX11"
+ LIBXCURSOR="-lXcursor"
+ LIBXMU="-lXmu"
+ LIBXINERAMA="-lXinerama"
+@@ -133,6 +133,7 @@ LIBVNCSERVER="-lvncserver"
+ INCDEVMAPPER=""
+ LIBDEVMAPPER="-ldevmapper"
+ CXX_FLAGS=""
++  echo '*** ' OS is $OS ' ***'
+ if [ "$OS" = "freebsd" ]; then
+   INCCURL="-I/usr/local/include"
+   LIBCURL="-L/usr/local/lib -lcurl"
+@@ -140,6 +141,19 @@ if [ "$OS" = "freebsd" ]; then
+   LIBPULSE="-L/usr/local/lib"
+   INCPNG="-I/usr/local/include"
+   LIBPNG="-L/usr/local/lib -lpng"
++  INCVNCSERVER="-I/usr/local/include"
++  LIBVNCSERVER="-L/usr/local/lib"
++elif [ "$OS" = "netbsd" ]; then
++  echo '*** ' OS is $OS ' ***'
++  CXX_FLAGS= "-I@PREFIX@/include"
++  INCCURL="-I@PREFIX@/include"
++  LIBCURL="-Wl,-rpath=@PREFIX@/lib -lcurl -L@PREFIX@/lib"
++  INCPULSE="-I@PREFIX@/include"
++  LIBPULSE="-L@PREFIX@/lib"
++  INCPNG="-I@PREFIX@/include"
++  LIBPNG="-Wl,-rpath=@PREFIX@/lib -lpng -L@PREFIX@/lib"
++  INCVNCSERVER="-I@PREFIX@/include"
++  LIBVNCSERVER="-L@PREFIX@/lib"
+ else
+   INCCURL=""
+   LIBCURL="-lcurl"
+@@ -147,10 +161,10 @@ else
+   LIBPNG="-lpng"
+ fi
+ INCVPX=""
+-LIBVPX="-lvpx"
++LIBVPX="-Wl,-rpath=@PREFIX@/lib -lvpx -L@PREFIX@/lib"
+ PKGCONFIG="`which_wrapper pkg-config`"
+-PYTHONDIR="/usr /usr/local"
+-QT4DIR="/usr/lib/qt4 /usr/share/qt4 /usr/lib64/qt4 /usr /usr/local"
++PYTHONDIR="/usr @PREFIX@"
++QT4DIR="/usr/lib/qt4 /usr/share/qt4 /usr/lib64/qt4 /usr @PREFIX@/qt4"
+ QT4DIR_PKGCONFIG=1
+ QT4UIC3DIR="/usr/bin"
+ KBUILDDIR="`cd \`dirname $0\`; pwd`/kBuild"
+@@ -183,7 +197,7 @@ fi
+ 
+ cleanup()
+ {
+-  rm -f $ODIR.tmp_src.cc $ODIR.tmp_src.c $ODIR.tmp_out $ODIR.test_execute.log
++#  rm -f $ODIR.tmp_src.cc $ODIR.tmp_src.c $ODIR.tmp_out $ODIR.test_execute.log
+ }
+ 
+ fail()
+@@ -278,8 +292,8 @@ test_compile()
+   echo "compiling the following source file:" >> $LOG
+   cat $ODIR.tmp_src.cc >> $LOG
+   echo "using the following command line:" >> $LOG
+-  echo "$CXX $CXX_FLAGS -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc \"$1\"" >> $LOG
+-  $CXX $CXX_FLAGS -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $1 >> $LOG 2>&1
++  echo "$CXX $CXX_FLAGS -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $1" >> $LOG
++  $CXX $CXX_FLAGS -g -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc $1>> $LOG 2>&1
+   if [ $? -ne 0 ]; then
+     if [ -z "$4" ]; then
+       echo
+@@ -1641,7 +1655,9 @@ check_vpx()
+       if [ $? -eq 0 ]; then
+         FLGVPX=`pkg-config vpx --cflags`
+         INCVPX=`strip_I "$FLGVPX"`
++  	if [ -z "$LIBVPX" ]; then
+         LIBVPX=`pkg-config vpx --libs`
++	fi
+       fi
+       cat > $ODIR.tmp_src.cc << EOF
+ #include <cstdio>
+@@ -1948,8 +1964,8 @@ EOF
+         echo "compiling the following source file:" >> $LOG
+         cat $ODIR.tmp_src.cc >> $LOG
+         echo "using the following command line:" >> $LOG
+-        echo "$CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so" >> $LOG
+-        $CXX -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
++        echo "$CXX -O -Wall -Wl,-rpath=@PREFIX@/lib -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so" >> $LOG
++              $CXX -O -Wall -Wl,-rpath=@PREFIX@/lib -o $ODIR.tmp_out $ODIR.tmp_src.cc -I$p/include/$d $p/$b/lib$d.so >> $LOG 2>&1
+         if [ $? -eq 0 ]; then
+           found=1
+           break
+@@ -2332,6 +2348,18 @@ for option in $*; do
+     --help|-help|-h)
+       show_help
+       ;;
++    --prefix=*)
++      ;;
++    --build=x86_64--netbsd)
++      ;;
++    --host=x86_64--netbsd) 
++      ;;
++    --mandir=/usr/pkg/man)
++      ;;
++    --x-includes=/usr/X11R7/include)
++      ;;
++    --x-libraries=/usr/X11R7/lib)
++      ;;
+     --nofatal)
+       nofatal=1
+       ;;
+@@ -2358,7 +2386,7 @@ for option in $*; do
+     --with-openssl-dir=*)
+       OPENSSLDIR=`echo $option | cut -d'=' -f2`
+       INCCRYPTO="-I${OPENSSLDIR}/include"
+-      LIBCRYPTO="${OPENSSLDIR}/lib/libcrypto.a ${OPENSSLDIR}/lib/libssl.a"
++      LIBCRYPTO="-L${OPENSSLDIR}/lib -lcrypto -lssl"
+       ;;
+     --with-ow-dir=*)
+       WATCOM=`echo $option | cut -d'=' -f2`
diff --git a/virtualbox-ose/patches/patch-include-VBox-com-array.h b/virtualbox-ose/patches/patch-include-VBox-com-array.h
new file mode 100644
index 0000000..0e730a7
--- /dev/null
+++ b/virtualbox-ose/patches/patch-include-VBox-com-array.h
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- include/VBox/com/array.h.orig	2015-03-02 10:06:38.000000000 -0500
++++ include/VBox/com/array.h	2015-03-12 17:52:37.107759000 -0400
+@@ -908,12 +908,12 @@
+      */
+     const T operator[] (size_t aIdx) const
+     {
+-        AssertReturn(m.arr != NULL,  *((T *)NULL));
+-        AssertReturn(aIdx < size(), *((T *)NULL));
++        Assert(m.arr != NULL);
++        Assert(aIdx < size());
+ #ifdef VBOX_WITH_XPCOM
+         return m.arr[aIdx];
+ #else
+-        AssertReturn(m.raw != NULL,  *((T *)NULL));
++        Assert(m.raw != NULL);
+         return m.raw[aIdx];
+ #endif
+     }
+@@ -1409,8 +1409,8 @@
+      */
+     const nsID &operator[] (size_t aIdx) const
+     {
+-        AssertReturn(m.arr != NULL,  **((const nsID * *)NULL));
+-        AssertReturn(aIdx < size(), **((const nsID * *)NULL));
++        Assert(m.arr != NULL);
++        Assert(aIdx < size());
+         return *m.arr[aIdx];
+     }
+ 
diff --git a/virtualbox-ose/patches/patch-include-VBox-vmm-cpumctx.h b/virtualbox-ose/patches/patch-include-VBox-vmm-cpumctx.h
new file mode 100644
index 0000000..f40a9fc
--- /dev/null
+++ b/virtualbox-ose/patches/patch-include-VBox-vmm-cpumctx.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- include/VBox/vmm/cpumctx.h.orig	2015-03-12 18:53:45.762704000 -0400
++++ include/VBox/vmm/cpumctx.h	2015-03-12 18:56:23.765105000 -0400
+@@ -84,7 +84,7 @@
+ # define CPUMSELREG_ARE_HIDDEN_PARTS_VALID(a_pVCpu, a_pSelReg) \
+     (   ((a_pSelReg)->fFlags & CPUMSELREG_FLAGS_VALID) \
+      && (   (a_pSelReg)->ValidSel == (a_pSelReg)->Sel \
+-         || (   (a_pVCpu) /*!= NULL*/ \
++         || (   ((a_pVCpu) != NULL) \
+              && (a_pSelReg)->ValidSel == ((a_pSelReg)->Sel & X86_SEL_MASK_OFF_RPL) \
+              && ((a_pSelReg)->Sel      & X86_SEL_RPL) == 1 \
+              && ((a_pSelReg)->ValidSel & X86_SEL_RPL) == 0 \
diff --git a/virtualbox-ose/patches/patch-include-iprt-x86.h b/virtualbox-ose/patches/patch-include-iprt-x86.h
new file mode 100644
index 0000000..df9d041
--- /dev/null
+++ b/virtualbox-ose/patches/patch-include-iprt-x86.h
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- include/iprt/x86.h.orig	2014-02-25 11:59:50.000000000 -0500
++++ include/iprt/x86.h	2014-03-11 16:46:08.000000000 -0400
+@@ -35,6 +35,16 @@
+ # pragma D depends_on library vbox-types.d
+ #endif
+ 
++/* Workaround for FreeBSD machine/specialreg.h defining MSRs */
++#ifdef RT_OS_FREEBSD
++# undef MSR_P5_MC_ADDR
++# undef MSR_P5_MC_TYPE
++# undef MSR_IA32_PLATFORM_ID
++# undef MSR_BBL_CR_CTL3
++# undef MSR_IA32_MISC_ENABLE
++# undef MSR_IA32_FEATURE_CONTROL
++#endif
++
+ /* Workaround for Solaris sys/regset.h defining CS, DS */
+ #ifdef RT_OS_SOLARIS
+ # undef CS
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c b/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
new file mode 100644
index 0000000..14ea341
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-VBoxGuest-freebsd.c
@@ -0,0 +1,357 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c.orig	2015-03-02 10:06:54.000000000 -0500
++++ src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c	2015-03-09 18:02:36.502945000 -0400
+@@ -80,8 +80,6 @@
+     struct resource   *pIrqRes;
+     /** Pointer to the IRQ handler. */
+     void              *pfnIrqHandler;
+-    /** VMMDev version */
+-    uint32_t           u32Version;
+ };
+ 
+ static MALLOC_DEFINE(M_VBOXDEV, "vboxdev_pci", "VirtualBox Guest driver PCI");
+@@ -89,8 +87,7 @@
+ /*
+  * Character device file handlers.
+  */
+-static d_fdopen_t VBoxGuestFreeBSDOpen;
+-static d_close_t  VBoxGuestFreeBSDClose;
++static d_open_t   VBoxGuestFreeBSDOpen;
+ static d_ioctl_t  VBoxGuestFreeBSDIOCtl;
+ static d_write_t  VBoxGuestFreeBSDWrite;
+ static d_read_t   VBoxGuestFreeBSDRead;
+@@ -103,13 +100,6 @@
+ static int  VBoxGuestFreeBSDAddIRQ(device_t pDevice, void *pvState);
+ static int  VBoxGuestFreeBSDISR(void *pvState);
+ 
+-/*
+- * Available functions for kernel drivers.
+- */
+-DECLVBGL(int)    VBoxGuestFreeBSDServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);
+-DECLVBGL(void *) VBoxGuestFreeBSDServiceOpen(uint32_t *pu32Version);
+-DECLVBGL(int)    VBoxGuestFreeBSDServiceClose(void *pvSession);
+-
+ #ifndef D_NEEDMINOR
+ # define D_NEEDMINOR 0
+ #endif
+@@ -121,8 +111,7 @@
+ {
+     .d_version =        D_VERSION,
+     .d_flags =          D_TRACKCLOSE | D_NEEDMINOR,
+-    .d_fdopen =         VBoxGuestFreeBSDOpen,
+-    .d_close =          VBoxGuestFreeBSDClose,
++    .d_open =           VBoxGuestFreeBSDOpen,
+     .d_ioctl =          VBoxGuestFreeBSDIOCtl,
+     .d_read =           VBoxGuestFreeBSDRead,
+     .d_write =          VBoxGuestFreeBSDWrite,
+@@ -130,106 +119,45 @@
+     .d_name =           DEVICE_NAME
+ };
+ 
++/** Device structure. */
++static struct cdev         *g_pDev;
+ /** Device extention & session data association structure. */
+ static VBOXGUESTDEVEXT      g_DevExt;
+-/** List of cloned device. Managed by the kernel. */
+-static struct clonedevs    *g_pVBoxGuestFreeBSDClones;
+-/** The dev_clone event handler tag. */
+-static eventhandler_tag     g_VBoxGuestFreeBSDEHTag;
+ /** Reference counter */
+ static volatile uint32_t    cUsers;
+ /** selinfo structure used for polling. */
+ static struct selinfo       g_SelInfo;
+ 
+-/**
+- * DEVFS event handler.
+- */
+-static void VBoxGuestFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
++static void VBoxGuestFreeBSDDtr(void *pSession)
+ {
+-    int iUnit;
+-    int rc;
+-
+-    Log(("VBoxGuestFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev));
+-
+-    /*
+-     * One device node per user, si_drv1 points to the session.
+-     * /dev/vboxguest<N> where N = {0...255}.
+-     */
+-    if (!ppDev)
+-        return;
+-    if (strcmp(pszName, "vboxguest") == 0)
+-        iUnit =  -1;
+-    else if (dev_stdclone(pszName, NULL, "vboxguest", &iUnit) != 1)
+-        return;
+-    if (iUnit >= 256)
+-    {
+-        Log(("VBoxGuestFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit));
+-        return;
+-    }
+-
+-    Log(("VBoxGuestFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit));
+-
+-    rc = clone_create(&g_pVBoxGuestFreeBSDClones, &g_VBoxGuestFreeBSDChrDevSW, &iUnit, ppDev, 0);
+-    Log(("VBoxGuestFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
+-    if (rc)
+-    {
+-        *ppDev = make_dev(&g_VBoxGuestFreeBSDChrDevSW,
+-                          iUnit,
+-                          UID_ROOT,
+-                          GID_WHEEL,
+-                          0664,
+-                          "vboxguest%d", iUnit);
+-        if (*ppDev)
+-        {
+-            dev_ref(*ppDev);
+-            (*ppDev)->si_flags |= SI_CHEAPCLONE;
+-            Log(("VBoxGuestFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
+-                     *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
+-            (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL;
+-        }
+-        else
+-            Log(("VBoxGuestFreeBSDClone: make_dev iUnit=%d failed\n", iUnit));
+-    }
+-    else
+-        Log(("VBoxGuestFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
+-             *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
++    VBoxGuestCloseSession(&g_DevExt, pSession);
++    ASMAtomicDecU32(&cUsers);
+ }
+ 
+ /**
+  * File open handler
+  *
+  */
+-#if __FreeBSD_version >= 700000
+-static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd, struct file *pFd)
+-#else
+-static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd)
+-#endif
++static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, int DevType, struct thread *pTd)
+ {
+-    int                 rc;
+-    PVBOXGUESTSESSION   pSession;
++    PVBOXGUESTSESSION pSession;
++    int rc;
+ 
+     LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDOpen\n"));
+ 
+     /*
+-     * Try grab it (we don't grab the giant, remember).
+-     */
+-    if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, (void *)0x42, NULL))
+-        return EBUSY;
+-
+-    /*
+      * Create a new session.
+      */
+     rc = VBoxGuestCreateUserSession(&g_DevExt, &pSession);
+     if (RT_SUCCESS(rc))
+     {
+-        if (ASMAtomicCmpXchgPtr(&pDev->si_drv1, pSession, (void *)0x42))
+-        {
+-            Log((DEVICE_NAME ":VBoxGuestFreeBSDOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
++        Log((DEVICE_NAME ":VBoxGuestFreeBSDOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
++        rc = devfs_set_cdevpriv(pSession, VBoxGuestFreeBSDDtr);
++        if (rc)
++            VBoxGuestCloseSession(&g_DevExt, pSession);
++        else
+             ASMAtomicIncU32(&cUsers);
+-            return 0;
+-        }
+-
+-        VBoxGuestCloseSession(&g_DevExt, pSession);
++        return rc;
+     }
+ 
+     LogRel((DEVICE_NAME ":VBoxGuestFreeBSDOpen: failed. rc=%d\n", rc));
+@@ -237,47 +165,19 @@
+ }
+ 
+ /**
+- * File close handler
+- *
+- */
+-static int VBoxGuestFreeBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd)
+-{
+-    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
+-    Log(("VBoxGuestFreeBSDClose: fFile=%#x pSession=%p\n", fFile, pSession));
+-
+-    /*
+-     * Close the session if it's still hanging on to the device...
+-     */
+-    if (VALID_PTR(pSession))
+-    {
+-        VBoxGuestCloseSession(&g_DevExt, pSession);
+-        if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, NULL, pSession))
+-            Log(("VBoxGuestFreeBSDClose: si_drv1=%p expected %p!\n", pDev->si_drv1, pSession));
+-        ASMAtomicDecU32(&cUsers);
+-        /* Don't use destroy_dev here because it may sleep resulting in a hanging user process. */
+-        destroy_dev_sched(pDev);
+-    }
+-    else
+-        Log(("VBoxGuestFreeBSDClose: si_drv1=%p!\n", pSession));
+-    return 0;
+-}
+-
+-/**
+  * IOCTL handler
+  *
+  */
+ static int VBoxGuestFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
+ {
+-    LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl\n"));
++    PVBOXGUESTSESSION pSession;
++    int rc;
+ 
+-    int rc = 0;
++    LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl\n"));
+ 
+-    /*
+-     * Validate the input.
+-     */
+-    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
+-    if (RT_UNLIKELY(!VALID_PTR(pSession)))
+-        return EINVAL;
++    rc = devfs_get_cdevpriv((void **)&pSession);
++    if (rc)
++        return rc;
+ 
+     /*
+      * Validate the request wrapper.
+@@ -294,43 +194,46 @@
+         Log((DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd));
+         return EINVAL;
+     }
+-    if (RT_UNLIKELY(   ReqWrap->cbData == 0
+-                    || ReqWrap->cbData > _1M*16))
++
++    if (RT_UNLIKELY(ReqWrap->cbData > _1M*16))
+     {
+         printf(DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd);
+         return EINVAL;
+     }
+ 
+     /*
+-     * Read the request.
++     * Read the request payload if any; requests like VBOXGUEST_IOCTL_CANCEL_ALL_WAITEVENTS have no data payload.
+      */
+-    void *pvBuf = RTMemTmpAlloc(ReqWrap->cbData);
+-    if (RT_UNLIKELY(!pvBuf))
++    void *pvBuf = NULL;
++    if (RT_LIKELY(ReqWrap->cbData > 0))
+     {
+-        Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData));
+-        return ENOMEM;
+-    }
++        pvBuf = RTMemTmpAlloc(ReqWrap->cbData);
++        if (RT_UNLIKELY(!pvBuf))
++        {
++            Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData));
++            return ENOMEM;
++        }
+ 
+-    rc = copyin((void *)(uintptr_t)ReqWrap->pvDataR3, pvBuf, ReqWrap->cbData);
+-    if (RT_UNLIKELY(rc))
+-    {
+-        RTMemTmpFree(pvBuf);
+-        Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
+-        return EFAULT;
+-    }
+-    if (RT_UNLIKELY(   ReqWrap->cbData != 0
+-                    && !VALID_PTR(pvBuf)))
+-    {
+-        RTMemTmpFree(pvBuf);
+-        Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf));
+-        return EINVAL;
++        rc = copyin((void *)(uintptr_t)ReqWrap->pvDataR3, pvBuf, ReqWrap->cbData);
++        if (RT_UNLIKELY(rc))
++        {
++            RTMemTmpFree(pvBuf);
++            Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
++            return EFAULT;
++        }
++        if (RT_UNLIKELY(!VALID_PTR(pvBuf)))
++        {
++            RTMemTmpFree(pvBuf);
++            Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf));
++            return EINVAL;
++        }
+     }
+     Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));
+ 
+     /*
+      * Process the IOCtl.
+      */
+-    size_t cbDataReturned;
++    size_t cbDataReturned = 0;
+     rc = VBoxGuestCommonIOCtl(ulCmd, &g_DevExt, pSession, pvBuf, ReqWrap->cbData, &cbDataReturned);
+     if (RT_SUCCESS(rc))
+     {
+@@ -355,18 +258,21 @@
+         Log((DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: VBoxGuestCommonIOCtl failed. rc=%d\n", rc));
+         rc = EFAULT;
+     }
+-    RTMemTmpFree(pvBuf);
++    if (pvBuf)
++        RTMemTmpFree(pvBuf);
+     return rc;
+ }
+ 
+ static int VBoxGuestFreeBSDPoll (struct cdev *pDev, int fEvents, struct thread *td)
+ {
+-    int fEventsProcessed;
++    PVBOXGUESTSESSION pSession;
++    int fEventsProcessed, rc;
+ 
+     LogFlow((DEVICE_NAME "::Poll: fEvents=%d\n", fEvents));
+ 
+-    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
+-    if (RT_UNLIKELY(!VALID_PTR(pSession))) {
++    rc = devfs_get_cdevpriv((void **)&pSession);
++    if (rc)
++    {
+         Log((DEVICE_NAME "::Poll: no state data for %s\n", devtoname(pDev)));
+         return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
+     }
+@@ -407,10 +313,7 @@
+     /*
+      * Reverse what we did in VBoxGuestFreeBSDAttach.
+      */
+-    if (g_VBoxGuestFreeBSDEHTag != NULL)
+-        EVENTHANDLER_DEREGISTER(dev_clone, g_VBoxGuestFreeBSDEHTag);
+-
+-    clone_cleanup(&g_pVBoxGuestFreeBSDClones);
++    destroy_dev(g_pDev);
+ 
+     VBoxGuestFreeBSDRemoveIRQ(pDevice, pState);
+ 
+@@ -562,18 +465,21 @@
+                 if (RT_SUCCESS(rc))
+                 {
+                     /*
+-                     * Configure device cloning.
++                     * Configure device.
+                      */
+-                    clone_setup(&g_pVBoxGuestFreeBSDClones);
+-                    g_VBoxGuestFreeBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, VBoxGuestFreeBSDClone, 0, 1000);
+-                    if (g_VBoxGuestFreeBSDEHTag)
++                    g_pDev = make_dev(&g_VBoxGuestFreeBSDChrDevSW,
++                                      0,
++                                      UID_ROOT,
++                                      GID_WHEEL,
++                                      0664,
++                                      "vboxguest");
++                    if (g_pDev)
+                     {
+                         printf(DEVICE_NAME ": loaded successfully\n");
+                         return 0;
+                     }
+ 
+-                    printf(DEVICE_NAME ": EVENTHANDLER_REGISTER(dev_clone,,,) failed\n");
+-                    clone_cleanup(&g_pVBoxGuestFreeBSDClones);
++                    printf(DEVICE_NAME ": make_dev failed\n");
+                     VBoxGuestFreeBSDRemoveIRQ(pDevice, pState);
+                 }
+                 else
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile b/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
new file mode 100644
index 0000000..95a1abb
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-Makefile
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/freebsd/Makefile.orig	2014-09-18 22:18:11.602040183 +0400
++++ src/VBox/Additions/common/VBoxGuest/freebsd/Makefile	2014-09-18 22:18:29.900039743 +0400
+@@ -72,6 +72,7 @@
+ 	handletable.c \
+ 	handletablectx.c \
+ 	once.c \
++	term.c \
+ 	thread.c
+ 
+ .PATH:	${.CURDIR}/common/string
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest b/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
new file mode 100644
index 0000000..7f6be23
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-VBoxGuest-freebsd-files_vboxguest
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest.orig	2014-09-09 23:46:56.000000000 +0400
++++ src/VBox/Additions/common/VBoxGuest/freebsd/files_vboxguest	2014-09-18 22:06:32.817093478 +0400
+@@ -102,6 +102,7 @@
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.h=>common/misc/handletable.h \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletablectx.cpp=>common/misc/handletablectx.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/once.cpp=>common/misc/once.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/term.cpp=>common/misc/term.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/thread.cpp=>common/misc/thread.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg1Weak.cpp=>common/misc/RTAssertMsg1Weak.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2.cpp=>common/misc/RTAssertMsg2.c \
+@@ -185,6 +186,7 @@
+     ${PATH_ROOT}/src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h=>r0drv/freebsd/sleepqueue-r0drv-freebsd.h \
+     ${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/semspinmutex-r0drv-generic.c=>r0drv/generic/semspinmutex-r0drv-generic.c \
+     ${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/mpnotification-r0drv-generic.cpp=>r0drv/generic/mpnotification-r0drv-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/threadctxhooks-r0drv-generic.cpp=>r0drv/generic/threadctxhooks-r0drv-generic.c \
+     ${PATH_ROOT}/src/VBox/Runtime/r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.cpp=>r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.c \
+     ${PATH_ROOT}/src/VBox/Runtime/r0drv/memobj-r0drv.cpp=>r0drv/memobj-r0drv.c \
+     ${PATH_ROOT}/src/VBox/Runtime/VBox/log-vbox.cpp=>VBox/log-vbox.c \
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py
new file mode 100644
index 0000000..8b3030e
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports.py
@@ -0,0 +1,100 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/FreeBSD_i386_exports.py.orig	2014-12-19 16:58:04.474417000 -0500
++++ src/VBox/Additions/common/crOpenGL/FreeBSD_i386_exports.py	2014-11-21 10:16:35.000000000 -0500
+@@ -0,0 +1,95 @@
++# Copyright (c) 2001, Stanford University
++# All rights reserved.
++#
++# See the file LICENSE.txt for information on redistributing this software.
++
++
++import sys
++
++import apiutil
++
++
++def GenerateEntrypoints():
++
++    #apiutil.CopyrightC()
++
++    # Get sorted list of dispatched functions.
++    # The order is very important - it must match cr_opcodes.h
++    # and spu_dispatch_table.h
++    print '%include "iprt/asmdefs.mac"'
++    print ""
++    print "%ifdef RT_ARCH_AMD64"
++    print "extern glim"
++    print "%else ; X86"
++    print "extern glim"
++    print "%endif"
++    print ""
++
++    keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
++
++    for index in range(len(keys)):
++        func_name = keys[index]
++        if apiutil.Category(func_name) == "Chromium":
++            continue
++        if apiutil.Category(func_name) == "VBox":
++            continue
++
++        print "BEGINPROC_EXPORTED gl%s" % func_name
++        print "%ifdef RT_ARCH_AMD64"
++        print "\tmov \trax, qword glim+%d" % (8*index)
++        print "\tjmp \t[rax]"
++        print "%else ; X86"
++        print "\tmov \teax, dword glim+%d" % (4*index)
++        print "\tjmp \t[eax]"
++        print "%endif"
++        print "ENDPROC gl%s" % func_name
++        print ""
++
++
++    print ';'
++    print '; Aliases'
++    print ';'
++
++    # Now loop over all the functions and take care of any aliases
++    allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
++    for func_name in allkeys:
++        if "omit" in apiutil.ChromiumProps(func_name):
++            continue
++
++        if func_name in keys:
++            # we already processed this function earlier
++            continue
++
++        # alias is the function we're aliasing
++        alias = apiutil.Alias(func_name)
++        if alias:
++            # this dict lookup should never fail (raise an exception)!
++            index = keys.index(alias)
++            print "BEGINPROC_EXPORTED gl%s" % func_name
++            print "%ifdef RT_ARCH_AMD64"
++            print "\tmov \trax, qword glim+%d" % (8*index)
++            print "\tjmp \t[rax]"
++            print "%else ; X86"
++            print "\tmov \teax, dword glim+%d" % (4*index)
++            print "\tjmp \t[eax]"
++            print "%endif"
++            print "ENDPROC gl%s" % func_name
++            print ""
++
++
++    print ';'
++    print '; No-op stubs'
++    print ';'
++
++    # Now generate no-op stub functions
++    for func_name in allkeys:
++        if "stub" in apiutil.ChromiumProps(func_name):
++            print "BEGINPROC_EXPORTED gl%s" % func_name
++            print "\tleave"
++            print "\tret"
++            print "ENDPROC gl%s" % func_name
++            print ""
++
++
++GenerateEntrypoints()
++
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py
new file mode 100644
index 0000000..3e5d8d3
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_exports_dri.py
@@ -0,0 +1,100 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/FreeBSD_i386_exports_dri.py.orig	2014-12-19 16:58:04.474417000 -0500
++++ src/VBox/Additions/common/crOpenGL/FreeBSD_i386_exports_dri.py	2014-11-21 10:16:35.000000000 -0500
+@@ -0,0 +1,95 @@
++# Copyright (c) 2001, Stanford University
++# All rights reserved.
++#
++# See the file LICENSE.txt for information on redistributing this software.
++
++
++import sys
++
++import apiutil
++
++
++def GenerateEntrypoints():
++
++    #apiutil.CopyrightC()
++
++    # Get sorted list of dispatched functions.
++    # The order is very important - it must match cr_opcodes.h
++    # and spu_dispatch_table.h
++    print '%include "iprt/asmdefs.mac"'
++    print ""
++    print "%ifdef RT_ARCH_AMD64"
++    print "extern glim"
++    print "%else ; X86"
++    print "extern glim"
++    print "%endif"
++    print ""
++
++    keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
++
++    for index in range(len(keys)):
++        func_name = keys[index]
++        if apiutil.Category(func_name) == "Chromium":
++            continue
++        if apiutil.Category(func_name) == "VBox":
++            continue
++
++        print "BEGINPROC_EXPORTED cr_gl%s" % func_name
++        print "%ifdef RT_ARCH_AMD64"
++        print "\tmov \trax, qword glim+%d" % (8*index)
++        print "\tjmp \t[rax]"
++        print "%else ; X86"
++        print "\tmov \teax, dword glim+%d" % (4*index)
++        print "\tjmp \t[eax]"
++        print "%endif"
++        print "ENDPROC cr_gl%s" % func_name
++        print ""
++
++
++    print ';'
++    print '; Aliases'
++    print ';'
++
++    # Now loop over all the functions and take care of any aliases
++    allkeys = apiutil.GetAllFunctions(sys.argv[1]+"/APIspec.txt")
++    for func_name in allkeys:
++        if "omit" in apiutil.ChromiumProps(func_name):
++            continue
++
++        if func_name in keys:
++            # we already processed this function earlier
++            continue
++
++        # alias is the function we're aliasing
++        alias = apiutil.Alias(func_name)
++        if alias:
++            # this dict lookup should never fail (raise an exception)!
++            index = keys.index(alias)
++            print "BEGINPROC_EXPORTED cr_gl%s" % func_name
++            print "%ifdef RT_ARCH_AMD64"
++            print "\tmov \trax, qword glim+%d" % (8*index)
++            print "\tjmp \t[rax]"
++            print "%else ; X86"
++            print "\tmov \teax, dword glim+%d" % (4*index)
++            print "\tjmp \t[eax]"
++            print "%endif"
++            print "ENDPROC cr_gl%s" % func_name
++            print ""
++
++
++    print ';'
++    print '; No-op stubs'
++    print ';'
++
++    # Now generate no-op stub functions
++    for func_name in allkeys:
++        if "stub" in apiutil.ChromiumProps(func_name):
++            print "BEGINPROC_EXPORTED cr_gl%s" % func_name
++            print "\tleave"
++            print "\tret"
++            print "ENDPROC cr_gl%s" % func_name
++            print ""
++
++
++GenerateEntrypoints()
++
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py
new file mode 100644
index 0000000..c2a6cb8
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-FreeBSD_i386_glxapi_exports.py
@@ -0,0 +1,109 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/FreeBSD_i386_glxapi_exports.py.orig	2014-12-19 16:58:04.474417000 -0500
++++ src/VBox/Additions/common/crOpenGL/FreeBSD_i386_glxapi_exports.py	2014-11-21 10:16:35.000000000 -0500
+@@ -0,0 +1,104 @@
++"""
++Copyright (C) 2009-2012 Oracle Corporation
++
++This file is part of VirtualBox Open Source Edition (OSE), as
++available from http://www.virtualbox.org. This file is free software;
++you can redistribute it and/or modify it under the terms of the GNU
++General Public License (GPL) as published by the Free Software
++Foundation, in version 2 as it comes in the "COPYING" file of the
++VirtualBox OSE distribution. VirtualBox OSE is distributed in the
++hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
++"""
++
++import sys
++
++#Note, this should match the fakedri_glxfuncsList.h order
++glx_functions = [
++"CopyContext",
++"UseXFont",
++#"GetDriverConfig",
++"GetProcAddress",
++"QueryExtension",
++"IsDirect",
++"DestroyGLXPbufferSGIX",
++"QueryGLXPbufferSGIX",
++"CreateGLXPixmap",
++"CreateGLXPixmapWithConfigSGIX",
++"QueryContext",
++"CreateContextWithConfigSGIX",
++"SwapBuffers",
++"CreateNewContext",
++"SelectEventSGIX",
++"GetCurrentDrawable",
++"ChooseFBConfig",
++"WaitGL",
++"GetFBConfigs",
++"CreatePixmap",
++"GetSelectedEventSGIX",
++"GetCurrentReadDrawable",
++"GetCurrentDisplay",
++"QueryServerString",
++"CreateWindow",
++"SelectEvent",
++"GetVisualFromFBConfigSGIX",
++"GetFBConfigFromVisualSGIX",
++"QueryDrawable",
++"CreateContext",
++"GetConfig",
++"CreateGLXPbufferSGIX",
++"CreatePbuffer",
++"ChooseFBConfigSGIX",
++"WaitX",
++"GetVisualFromFBConfig",
++#"GetScreenDriver",
++"GetFBConfigAttrib",
++"GetCurrentContext",
++"GetClientString",
++"DestroyPixmap",
++"MakeCurrent",
++"DestroyContext",
++"GetProcAddressARB",
++"GetSelectedEvent",
++"DestroyPbuffer",
++"DestroyWindow",
++"DestroyGLXPixmap",
++"QueryVersion",
++"ChooseVisual",
++"MakeContextCurrent",
++"QueryExtensionsString",
++"GetFBConfigAttribSGIX",
++"FreeMemoryMESA",
++"QueryContextInfoEXT",
++"ImportContextEXT",
++"GetContextIDEXT",
++"MakeCurrentReadSGI",
++"AllocateMemoryMESA",
++"GetMemoryOffsetMESA",
++"CreateGLXPixmapMESA",
++"GetCurrentDisplayEXT",
++"FreeContextEXT"
++];
++
++print '%include "iprt/asmdefs.mac"'
++print ""
++print "%ifdef RT_ARCH_AMD64"
++print "extern glxim"
++print "%else ; X86"
++print "extern glxim"
++print "%endif"
++print ""
++
++for index in range(len(glx_functions)):
++    func_name = glx_functions[index]
++
++    print "BEGINPROC_EXPORTED vbox_glX%s" % func_name
++    print "%ifdef RT_ARCH_AMD64"
++    print "\tmov \trax, qword glxim+%d" % (8*index)
++    print "\tjmp \t[rax]"
++    print "%else ; X86"
++    print "\tmov \teax, dword glxim+%d" % (4*index)
++    print "\tjmp \t[eax]"
++    print "%endif"
++    print "ENDPROC vbox_glX%s" % func_name
++    print ""
++
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk
new file mode 100644
index 0000000..4a3834c
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-common-crOpenGL-Makefile.kmk
@@ -0,0 +1,74 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/Makefile.kmk.orig	2014-11-21 10:16:35.000000000 -0500
++++ src/VBox/Additions/common/crOpenGL/Makefile.kmk	2014-12-19 16:55:22.000000000 -0500
+@@ -172,7 +172,7 @@
+   VBoxOGL_SOURCES.solaris += \
+   	$(VBOX_PATH_CROGL_GENFILES)/solaris_exports.c
+   VBoxOGL_SOURCES.freebsd += \
+-  	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.c
++  	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.asm
+  endif
+ endif
+ 
+@@ -190,10 +190,12 @@
+ 	$(VBOX_PATH_CROGL_GENFILES)/linux_exports.asm
+ VBoxOGL_CLEAN.solaris        += \
+ 	$(VBOX_PATH_CROGL_GENFILES)/solaris_exports.c
++VBoxOGL_CLEAN.freebsd  += \
++	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.asm
+ VBoxOGL_CLEAN.win      = \
+ 	$(VBOX_PATH_CROGL_GENFILES)/windows_exports.asm \
+ 	$(VBOX_PATH_CROGL_GENFILES)/cropengl.def
+-if1of ($(KBUILD_TARGET), linux solaris)
++if1of ($(KBUILD_TARGET), linux solaris freebsd)
+  ifdef VBoxOGL_DRI
+   VBoxOGL_CLEAN   += \
+  	$(VBOX_PATH_CROGL_GENFILES)/cr_gl.h \
+@@ -206,6 +208,8 @@
+  	$(VBOX_PATH_CROGL_GENFILES)/linux_glxapi_exports.asm
+   VBoxOGL_CLEAN.solaris   += \
+  	$(VBOX_PATH_CROGL_GENFILES)/solaris_glxapi_exports.asm
++  VBoxOGL_CLEAN.freebsd += \
++ 	$(VBOX_PATH_CROGL_GENFILES)/freebsd_glxapi_exports.asm
+  endif
+ endif
+ VBoxOGL_LIBS = \
+@@ -235,7 +239,7 @@
+ ifdef VBOX_WITH_WDDM
+ VBoxOGL_DEFS.win   += VBOX_WITH_WDDM
+ endif
+-if1of ($(KBUILD_TARGET), linux)
++if1of ($(KBUILD_TARGET), linux freebsd)
+ VBoxOGL_LDFLAGS += -Wl,-z,nodelete
+ endif
+ ifdef VBOX_WITH_WDDM
+@@ -317,8 +321,8 @@
+ 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
+ 
+   else ifeq ($(KBUILD_TARGET),freebsd)
+-$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.c: \
+-		$(PATH_SUB_CURRENT)/FreeBSD_exports.py \
++$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.asm: \
++		$(PATH_SUB_CURRENT)/FreeBSD_i386_exports.py \
+ 		$(VBOX_CROGL_API_FILES) $(PATH_SUB_CURRENT)/entrypoints.py \
+ 		| $$(dir $$@)
+ 	$(call MSG_GENERATE,python,$@,$<)
+@@ -387,7 +391,16 @@
+ $(VBOX_PATH_CROGL_GENFILES)/solaris_glxapi_exports.asm: $(PATH_SUB_CURRENT)/SunOS_i386_glxapi_exports.py | $$(dir $$@)
+ 	$(call MSG_GENERATE,python,$@,$<)
+ 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $<
+-
++   else ifeq ($(KBUILD_TARGET),freebsd)
++$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports_dri.asm: \
++		$(PATH_SUB_CURRENT)/FreeBSD_i386_exports_dri.py \
++		$(VBOX_CROGL_API_FILES) $(PATH_SUB_CURRENT)/entrypoints.py \
++		| $$(dir $$@)
++	$(call MSG_GENERATE,python,$@,$<)
++	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
++$(VBOX_PATH_CROGL_GENFILES)/freebsd_glxapi_exports.asm: $(PATH_SUB_CURRENT)/FreeBSD_i386_glxapi_exports.py | $$(dir $$@)
++	$(call MSG_GENERATE,python,$@,$<)
++	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $<
+    else
+ $(VBOX_PATH_CROGL_GENFILES)/linux_exports_dri.asm: \
+ 		$(PATH_SUB_CURRENT)/Linux_i386_exports_dri.py \
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-freebsd-drm-vboxvideo_drm.c b/virtualbox-ose/patches/patch-src-VBox-Additions-freebsd-drm-vboxvideo_drm.c
new file mode 100644
index 0000000..4d2d073
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-freebsd-drm-vboxvideo_drm.c
@@ -0,0 +1,79 @@
+$NetBSD$
+
+--- src/VBox/Additions/freebsd/drm/vboxvideo_drm.c.orig	2015-03-16 13:00:32.000000000 -0400
++++ src/VBox/Additions/freebsd/drm/vboxvideo_drm.c	2015-03-27 17:40:43.686690000 -0400
+@@ -54,8 +54,13 @@
+ #include <sys/cdefs.h>
+ __FBSDID("$FreeBSD$");
+ 
++#ifdef VBOXVIDEO_DRM2
++#include "dev/drm2/drmP.h"
++#include "dev/drm2/drm_pciids.h"
++#else
+ #include "dev/drm/drmP.h"
+ #include "dev/drm/drm_pciids.h"
++#endif
+ 
+ #define DRIVER_AUTHOR                   "Oracle Corporation"
+ #define DRIVER_NAME                     "vboxvideo"
+@@ -74,6 +79,54 @@
+ 	vboxvideo_PCI_IDS
+ };
+ 
++#ifdef VBOXVIDEO_DRM2
++
++static struct drm_driver vboxvideo_info = {
++	.buf_priv_size			= 1, /* No dev_priv */
++
++	.num_ioctls			= 0,
++
++	.name				= DRIVER_NAME,
++	.desc				= DRIVER_DESC,
++	.date				= DRIVER_DATE,
++	.major				= DRIVER_MAJOR,
++	.minor				= DRIVER_MINOR,
++	.patchlevel			= DRIVER_PATCHLEVEL,
++};
++
++static int
++vboxvideo_probe(device_t kdev)
++{
++	return -drm_probe_helper(kdev, vboxvideo_pciidlist);
++}
++
++static int
++vboxvideo_attach(device_t kdev)
++{
++	return -drm_attach_helper(kdev, vboxvideo_pciidlist, &vboxvideo_info);
++}
++
++static device_method_t vboxvideo_methods[] = {
++	/* Device interface */
++	DEVMETHOD(device_probe,		vboxvideo_probe),
++	DEVMETHOD(device_attach,	vboxvideo_attach),
++	DEVMETHOD(device_detach,	drm_generic_detach),
++
++	DEVMETHOD_END
++};
++
++static driver_t vboxvideo_driver = {
++	"drmn",
++	vboxvideo_methods,
++	sizeof(struct drm_device)
++};
++
++extern devclass_t drm_devclass;
++DRIVER_MODULE(vboxvideo, vgapci, vboxvideo_driver, drm_devclass, 0, 0);
++MODULE_DEPEND(vboxvideo, drmn, 1, 1, 1);
++
++#else /* !VBOXVIDEO_DRM2 */
++
+ static void vboxvideo_configure(struct drm_device *dev)
+ {
+ #if __FreeBSD_version >= 702000
+@@ -161,3 +214,5 @@
+ DRIVER_MODULE(vboxvideo, pci, vboxvideo_driver, drm_devclass, 0, 0);
+ #endif
+ MODULE_DEPEND(vboxvideo, drm, 1, 1, 1);
++
++#endif /* VBOXVIDEO_DRM2 */
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
new file mode 100644
index 0000000..f3606ad
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-98vboxadd-xclient
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- src/VBox/Additions/x11/Installer/98vboxadd-xclient.orig	2015-02-12 11:08:13.000000000 -0500
++++ src/VBox/Additions/x11/Installer/98vboxadd-xclient	2015-02-12 14:38:40.689104000 -0500
+@@ -28,9 +28,9 @@
+    # This script can also be triggered by a connection over SSH, which is not
+    # what we had in mind, so we do not start VBoxClient in that case.  We do
+    # not use "exit" here as this script is "source"d, not executed.
+-  /usr/bin/VBoxClient --clipboard
+-  /usr/bin/VBoxClient --checkhostversion
+-  /usr/bin/VBoxClient --display
+-  /usr/bin/VBoxClient --seamless
+-  /usr/bin/VBoxClient --draganddrop
++  @PREFIX@/bin/VBoxClient --clipboard
++  @PREFIX@/bin/VBoxClient --checkhostversion
++  @PREFIX@/bin/VBoxClient --display
++  @PREFIX@/bin/VBoxClient --seamless
++  @PREFIX@/bin/VBoxClient --draganddrop
+ fi
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop
new file mode 100644
index 0000000..275b16e
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-Installer-vboxclient.desktop
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/VBox/Additions/x11/Installer/vboxclient.desktop.orig	2009-06-12 12:34:57.000000000 +0000
++++ src/VBox/Additions/x11/Installer/vboxclient.desktop	2011-01-13 22:07:37.000000000 +0000
+@@ -8,6 +8,6 @@
+ Comment=VirtualBox User Session Services
+ Comment[it]=Servizi di sessione utente di VirtualBox
+ Comment[pl]=Usługi sesji użytkownika VirtualBox
+-Exec=/usr/bin/VBoxClient-all
++Exec=@PREFIX@/bin/VBoxClient-all
+ X-GNOME-Autostart-enabled=true
+ X-KDE-autostart-after=panel
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxmouse-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxmouse-Makefile.kmk
new file mode 100644
index 0000000..7e44eb7
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxmouse-Makefile.kmk
@@ -0,0 +1,64 @@
+$NetBSD$
+
+--- src/VBox/Additions/x11/vboxmouse/Makefile.kmk.orig	2014-11-21 10:16:53.000000000 -0500
++++ src/VBox/Additions/x11/vboxmouse/Makefile.kmk	2014-12-10 14:10:02.000000000 -0500
+@@ -236,6 +236,50 @@
+ vboxmouse_drv_112_SOURCES = \
+ 	vboxmouse.c
+ 
++DLLS += vboxmouse_drv_113
++vboxmouse_drv_113_TEMPLATE = VBOXGUESTR3XORGMOD
++vboxmouse_drv_113_DEFS := $(vboxmouse_drv_70_DEFS) NO_ANSIC
++## @todo replace $(VBOX_PATH_X11_ROOT)/xorg-server-1.6.0-local
++vboxmouse_drv_113_INCS := \
++    $(vboxmouse_xorg_INCS) \
++	$(VBOX_PATH_X11_ROOT)/xorg-server-1.13.0 \
++	$(PATH_SUB_CURRENT)
++vboxmouse_drv_113_SOURCES = \
++	vboxmouse.c
++
++DLLS += vboxmouse_drv_114
++vboxmouse_drv_114_TEMPLATE = VBOXGUESTR3XORGMOD
++vboxmouse_drv_114_DEFS := $(vboxmouse_drv_70_DEFS) NO_ANSIC
++## @todo replace $(VBOX_PATH_X11_ROOT)/xorg-server-1.6.0-local
++vboxmouse_drv_114_INCS := \
++    $(vboxmouse_xorg_INCS) \
++	$(VBOX_PATH_X11_ROOT)/xorg-server-1.14.0 \
++	$(PATH_SUB_CURRENT)
++vboxmouse_drv_114_SOURCES = \
++	vboxmouse.c
++
++DLLS += vboxmouse_drv_115
++vboxmouse_drv_115_TEMPLATE = VBOXGUESTR3XORGMOD
++vboxmouse_drv_115_DEFS := $(vboxmouse_drv_70_DEFS) NO_ANSIC
++## @todo replace $(VBOX_PATH_X11_ROOT)/xorg-server-1.6.0-local
++vboxmouse_drv_115_INCS := \
++    $(vboxmouse_xorg_INCS) \
++	$(VBOX_PATH_X11_ROOT)/xorg-server-1.15.0 \
++	$(PATH_SUB_CURRENT)
++vboxmouse_drv_115_SOURCES = \
++	vboxmouse.c
++
++DLLS += vboxmouse_drv_116
++vboxmouse_drv_116_TEMPLATE = VBOXGUESTR3XORGMOD
++vboxmouse_drv_116_DEFS := $(vboxmouse_drv_70_DEFS) NO_ANSIC
++## @todo replace $(VBOX_PATH_X11_ROOT)/xorg-server-1.6.0-local
++vboxmouse_drv_116_INCS := \
++    $(vboxmouse_xorg_INCS) \
++	$(VBOX_PATH_X11_ROOT)/xorg-server-1.16.0 \
++	$(PATH_SUB_CURRENT)
++vboxmouse_drv_116_SOURCES = \
++	vboxmouse.c
++
+ endif # neq ($(KBUILD_TARGET),linux)
+ 
+ 
+@@ -284,7 +328,7 @@
+      $(foreach ver, _70 _71 _13 _14 _15 _16, $(eval $(def_vboxmouse_test)))
+ 
+      ifneq ($(KBUILD_TARGET), linux)
+-      $(foreach ver, _17 _18 _19 _110 _111 _112 _113, $(eval $(def_vboxmouse_test)))
++      $(foreach ver, _17 _18 _19 _110 _111 _112 _113 _114 _115 _116, $(eval $(def_vboxmouse_test)))
+ 
+      endif # neq ($(KBUILD_TARGET),linux)
+ 
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxvideo-vboxvideo_dri.c b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxvideo-vboxvideo_dri.c
new file mode 100644
index 0000000..495ea81
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-vboxvideo-vboxvideo_dri.c
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/VBox/Additions/x11/vboxvideo/vboxvideo_dri.c.orig	2015-03-02 10:06:59.000000000 -0500
++++ src/VBox/Additions/x11/vboxvideo/vboxvideo_dri.c	2015-03-02 18:33:59.041474000 -0500
+@@ -238,9 +238,11 @@
+         pDRIInfo->TransitionTo2d = VBOXDRITransitionTo2d;
+         pDRIInfo->TransitionTo3d = VBOXDRITransitionTo3d;
+ 
++#if defined(XORG_VERSION_CURRENT) && XORG_VERSION_CURRENT < 11700000
+         /* These two are set in DRICreateInfoRec(). */
+         pDRIInfo->wrap.ValidateTree = NULL;
+         pDRIInfo->wrap.PostValidateTree = NULL;
++#endif
+ 
+         pDRIInfo->drmDriverName = VBOX_DRM_DRIVER_NAME;
+         pDRIInfo->clientDriverName = VBOX_DRI_DRIVER_NAME;
diff --git a/virtualbox-ose/patches/patch-src-VBox-Additions-x11-x11include-xorg-server-1.16.0-xf86Xinput.h b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-x11include-xorg-server-1.16.0-xf86Xinput.h
new file mode 100644
index 0000000..554fbdf
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Additions-x11-x11include-xorg-server-1.16.0-xf86Xinput.h
@@ -0,0 +1,30 @@
+$NetBSD$
+
+--- src/VBox/Additions/x11/x11include/xorg-server-1.16.0/xf86Xinput.h.orig	2014-11-21 10:18:44.000000000 -0500
++++ src/VBox/Additions/x11/x11include/xorg-server-1.16.0/xf86Xinput.h	2014-12-18 16:26:57.000000000 -0500
+@@ -51,6 +51,7 @@
+ #ifndef _xf86Xinput_h
+ #define _xf86Xinput_h
+ 
++#include "xf86.h"
+ #include "xf86str.h"
+ #include "inputstr.h"
+ #include <X11/extensions/XI.h>
+@@ -85,7 +86,7 @@
+ 
+ /* This is to input devices what the ScrnInfoRec is to screens. */
+ 
+-typedef struct _InputInfoRec {
++struct _InputInfoRec {
+     struct _InputInfoRec *next;
+     char *name;
+     char *driver;
+@@ -110,7 +111,7 @@
+     void *module;
+     XF86OptionPtr options;
+     InputAttributes *attrs;
+-} *InputInfoPtr;
++};
+ 
+ /* xf86Globals.c */
+ extern InputInfoPtr xf86InputDevs;
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-Audio-ossaudio.c b/virtualbox-ose/patches/patch-src-VBox-Devices-Audio-ossaudio.c
new file mode 100644
index 0000000..7865cdb
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-Audio-ossaudio.c
@@ -0,0 +1,21 @@
+$NetBSD$
+
+Fix recording with OSS Audio backend to record at a proper volume
+
+Obtained from:	https://www.virtualbox.org/ticket/10695
+--- src/VBox/Devices/Audio/ossaudio.c.orig	2012-12-19 19:26:32.000000000 +0100
++++ src/VBox/Devices/Audio/ossaudio.c	2012-12-20 12:23:18.476851732 +0100
+@@ -795,13 +795,8 @@
+                            hw->info.align + 1);
+                 }
+                 read_samples += nread >> hwshift;
+-#ifndef VBOX
+                 hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,
+                           &nominal_volume);
+-#else
+-                hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift,
+-                          &pcm_in_volume);
+-#endif
+             }
+ 
+             if (bufs[i].len - nread) {
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-Input-PS2M.cpp b/virtualbox-ose/patches/patch-src-VBox-Devices-Input-PS2M.cpp
new file mode 100644
index 0000000..afbc1cf
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-Input-PS2M.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/Input/PS2M.cpp.orig	2015-03-02 10:09:15.000000000 -0500
++++ src/VBox/Devices/Input/PS2M.cpp	2015-03-16 13:38:03.324517000 -0400
+@@ -709,7 +709,7 @@
+ static void ps2mReportAccumulatedEvents(PPS2M pThis)
+ {
+     uint8_t     val;
+-    int8_t      dX, dY, dZ;
++    int         dX, dY, dZ;
+ 
+     /* Clamp the accumulated delta values to the allowed range. */
+     dX = RT_MIN(RT_MAX(pThis->iAccumX, -256), 255);
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h b/virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h
new file mode 100644
index 0000000..88cd482
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-bsd-sys-mbuf.h
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- src/VBox/Devices/Network/slirp/bsd/sys/mbuf.h.orig	2015-03-02 10:09:19.000000000 -0500
++++ src/VBox/Devices/Network/slirp/bsd/sys/mbuf.h	2015-03-02 19:42:56.808020000 -0500
+@@ -241,6 +241,9 @@
+ #define	M_FRAG		0x00000800 /* packet is a fragment of a larger packet */
+ #define	M_FIRSTFRAG	0x00001000 /* packet is first fragment */
+ #define	M_LASTFRAG	0x00002000 /* packet is last fragment */
++#ifdef M_SKIP_FIREWALL
++#undef M_SKIP_FIREWALL
++#endif
+ #define	M_SKIP_FIREWALL	0x00004000 /* skip firewall processing */
+ #define	M_FREELIST	0x00008000 /* mbuf is on the free list */
+ #define	M_VLANTAG	0x00010000 /* ether_vtag is valid */
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-resolv_conf_parser.c b/virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-resolv_conf_parser.c
new file mode 100644
index 0000000..d8f6c68
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-Network-slirp-resolv_conf_parser.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/Network/slirp/resolv_conf_parser.c.orig	2014-01-30 22:19:47.429683181 +0400
++++ src/VBox/Devices/Network/slirp/resolv_conf_parser.c	2014-01-30 22:22:08.149672985 +0400
+@@ -15,6 +15,8 @@
+  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+  */
+ 
++#include <sys/socket.h>
++
+ #include <iprt/assert.h>
+ #include <iprt/initterm.h>
+ #include <iprt/net.h>
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-PC-vbox.dsl b/virtualbox-ose/patches/patch-src-VBox-Devices-PC-vbox.dsl
new file mode 100644
index 0000000..7ccfe4e
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-PC-vbox.dsl
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/Devices/PC/vbox.dsl.orig	2011-04-28 10:00:53.000000000 +0200
++++ src/VBox/Devices/PC/vbox.dsl	2011-07-25 19:36:06.000000000 +0200
+@@ -1161,7 +1161,7 @@
+                              // (all of low memory space)
+                      ResourceProducer,        // bit 0 of general flags is 0
+                      PosDecode,               // positive Decode
+-                     MinNotFixed,             // Range is not fixed
++                     MinFixed,                // Range is not fixed
+                      MaxFixed,                // Range is fixed
+                      Cacheable,
+                      ReadWrite,
+@@ -1170,7 +1170,7 @@
+ 
+                      0xffdfffff,              // Max = 4GB - 2MB
+                      0x00000000,              // Translation
+-                     0x00000000,              // Range Length (calculated
++                     0xffe00000,              // Range Length (calculated
+                                               // dynamically)
+                      ,                        // Optional field left blank
+                      ,                        // Optional field left blank
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-USB-DevOHCI.cpp b/virtualbox-ose/patches/patch-src-VBox-Devices-USB-DevOHCI.cpp
new file mode 100644
index 0000000..6843f9a
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-USB-DevOHCI.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/USB/DevOHCI.cpp.orig	2015-03-02 10:09:35.000000000 -0500
++++ src/VBox/Devices/USB/DevOHCI.cpp	2015-03-12 16:15:51.519656000 -0400
+@@ -3717,7 +3717,7 @@
+             pUrb = pThis->aInFlight[i].pUrb;
+             if (pThis->aInFlight[i].fInactive
+                 && pUrb->enmState == VUSBURBSTATE_IN_FLIGHT
+-                && !pUrb->enmType == VUSBXFERTYPE_CTRL)
++                && pUrb->enmType != VUSBXFERTYPE_CTRL)
+                 pThis->RootHub.pIRhConn->pfnCancelUrbsEp(pThis->RootHub.pIRhConn, pUrb);
+         }
+     }
diff --git a/virtualbox-ose/patches/patch-src-VBox-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp b/virtualbox-ose/patches/patch-src-VBox-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp
new file mode 100644
index 0000000..2d7149c
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Devices-USB-freebsd-USBProxyDevice-freebsd.cpp
@@ -0,0 +1,177 @@
+$NetBSD$
+
+--- src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp.orig	2014-11-21 16:22:08.000000000 +0100
++++ src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp	2014-11-28 17:25:16.000000000 +0100
+@@ -52,6 +52,7 @@
+ #include <iprt/asm.h>
+ #include <iprt/string.h>
+ #include <iprt/file.h>
++#include <iprt/pipe.h>
+ #include "../USBProxyDevice.h"
+ 
+ /** Maximum endpoints supported. */
+@@ -95,12 +96,16 @@
+ {
+     /** The open file. */
+     RTFILE                 hFile;
+-    /** Software endpoint structures */
+-    USBENDPOINTFBSD        aSwEndpoint[USBFBSD_MAXENDPOINTS];
+     /** Flag whether an URB is cancelling. */
+     bool                   fCancelling;
+     /** Flag whether initialised or not */
+     bool                   fInit;
++    /** Pipe handle for waking up - writing end. */
++    RTPIPE                 hPipeWakeupW;
++    /** Pipe handle for waking up - reading end. */
++    RTPIPE                 hPipeWakeupR;
++    /** Software endpoint structures */
++    USBENDPOINTFBSD        aSwEndpoint[USBFBSD_MAXENDPOINTS];
+     /** Kernel endpoint structures */
+     struct usb_fs_endpoint aHwEndpoint[USBFBSD_MAXENDPOINTS];
+ } USBPROXYDEVFBSD, *PUSBPROXYDEVFBSD;
+@@ -383,10 +388,17 @@
+         rc = usbProxyFreeBSDFsInit(pProxyDev);
+         if (RT_SUCCESS(rc))
+         {
+-            LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n",
+-                     pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg));
++            /*
++             * Create wakeup pipe.
++             */
++            rc = RTPipeCreate(&pDevFBSD->hPipeWakeupR, &pDevFBSD->hPipeWakeupW, 0);
++            if (RT_SUCCESS(rc))
++            {
++                LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n",
++                         pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg));
+ 
+-            return VINF_SUCCESS;
++                return VINF_SUCCESS;
++            }
+         }
+ 
+         RTFileClose(hFile);
+@@ -449,12 +461,12 @@
+ 
+     usbProxyFreeBSDFsUnInit(pProxyDev);
+ 
++    RTPipeClose(pDevFBSD->hPipeWakeupR);
++    RTPipeClose(pDevFBSD->hPipeWakeupW);
++
+     RTFileClose(pDevFBSD->hFile);
+     pDevFBSD->hFile = NIL_RTFILE;
+ 
+-    RTMemFree(pDevFBSD);
+-    pProxyDev->Backend.pv = NULL;
+-
+     LogFlow(("usbProxyFreeBSDClose: returns\n"));
+ }
+ 
+@@ -688,9 +700,10 @@
+              pUrb, (unsigned)pUrb->EndPt, (unsigned)pUrb->enmDir));
+ 
+     ep_num = pUrb->EndPt;
+-
+-    if ((pUrb->enmType != VUSBXFERTYPE_MSG) && (pUrb->enmDir == VUSBDIRECTION_IN))
++    if ((pUrb->enmType != VUSBXFERTYPE_MSG) && (pUrb->enmDir == VUSBDIRECTION_IN)) {
++        /* set IN-direction bit */
+         ep_num |= 0x80;
++    }
+ 
+     index = 0;
+ 
+@@ -822,7 +835,7 @@
+     PUSBENDPOINTFBSD pEndpointFBSD;
+     PVUSBURB pUrb;
+     struct usb_fs_complete UsbFsComplete;
+-    struct pollfd PollFd;
++    struct pollfd pfd[2];
+     int rc;
+ 
+     LogFlow(("usbProxyFreeBSDUrbReap: pProxyDev=%p, cMillies=%u\n",
+@@ -946,23 +959,38 @@
+                  (unsigned)pEndpointFBSD->acbData[1]));
+ 
+     }
+-    else if (cMillies && rc == VERR_RESOURCE_BUSY)
++    else if (cMillies != 0 && rc == VERR_RESOURCE_BUSY)
+     {
+-        /* Poll for finished transfers */
+-        PollFd.fd = RTFileToNative(pDevFBSD->hFile);
+-        PollFd.events = POLLIN | POLLRDNORM;
+-        PollFd.revents = 0;
+-
+-        rc = poll(&PollFd, 1, (cMillies == RT_INDEFINITE_WAIT) ? INFTIM : cMillies);
+-        if (rc >= 1)
+-        {
+-            goto repeat;
+-        }
+-        else
++        for (;;)
+         {
+-            LogFlow(("usbProxyFreeBSDUrbReap: "
+-                     "poll returned rc=%d\n", rc));
++            pfd[0].fd = RTFileToNative(pDevFBSD->hFile);
++            pfd[0].events = POLLIN | POLLRDNORM;
++            pfd[0].revents = 0;
++
++            pfd[1].fd = RTPipeToNative(pDevFBSD->hPipeWakeupR);
++            pfd[1].events = POLLIN | POLLRDNORM;
++            pfd[1].revents = 0;
++
++            rc = poll(pfd, 2, (cMillies == RT_INDEFINITE_WAIT) ? INFTIM : cMillies);
++            if (rc > 0)
++            {
++                if (pfd[1].revents & POLLIN)
++                {
++                    /* Got woken up, drain pipe. */
++                    uint8_t bRead;
++                    size_t cbIgnored = 0;
++                    RTPipeRead(pDevFBSD->hPipeWakeupR, &bRead, 1, &cbIgnored);
++                    /* Make sure we return from this function */
++                    cMillies = 0;
++                }
++                break;
++            }
++            if (rc == 0)
++                return NULL;
++            if (errno != EAGAIN)
++                return NULL;
+         }
++        goto repeat;
+     }
+     return pUrb;
+ }
+@@ -984,6 +1012,16 @@
+     return usbProxyFreeBSDEndpointClose(pProxyDev, index);
+ }
+ 
++static DECLCALLBACK(int) usbProxyFreeBSDWakeup(PUSBPROXYDEV pProxyDev)
++{
++    PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD);
++    size_t cbIgnored;
++
++    LogFlowFunc(("pProxyDev=%p\n", pProxyDev));
++
++    return RTPipeWrite(pDevFBSD->hPipeWakeupW, "", 1, &cbIgnored);
++}
++
+ /**
+  * The FreeBSD USB Proxy Backend.
+  */
+@@ -992,7 +1030,7 @@
+     /* pszName */
+     "host",
+     /* cbBackend */
+-    sizeof(PUSBPROXYDEVFBSD),
++    sizeof(USBPROXYDEVFBSD),
+     usbProxyFreeBSDOpen,
+     usbProxyFreeBSDInit,
+     usbProxyFreeBSDClose,
+@@ -1005,6 +1043,7 @@
+     usbProxyFreeBSDUrbQueue,
+     usbProxyFreeBSDUrbCancel,
+     usbProxyFreeBSDUrbReap,
++    usbProxyFreeBSDWakeup,
+     0
+ };
+ 
diff --git a/virtualbox-ose/patches/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp b/virtualbox-ose/patches/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp
new file mode 100644
index 0000000..afbdedc
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Frontends-VBoxManage-VBoxManageModifyVM.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp.orig	2015-03-02 10:09:37.000000000 -0500
++++ src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	2015-03-12 18:33:09.348465000 -0400
+@@ -1732,7 +1732,7 @@
+                 CHECK_ERROR(nic, COMGETTER(NATEngine)(engine.asOutParam()));
+ 
+                 uint32_t aliasMode = 0;
+-                if (!RTStrCmp(ValueUnion.psz, "default") == 0)
++                if (RTStrCmp(ValueUnion.psz, "default") != 0)
+                 {
+                     char *token = (char *)ValueUnion.psz;
+                     while(token)
diff --git a/virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-Makefile.kmk
new file mode 100644
index 0000000..fed4d5a
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-Makefile.kmk
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VirtualBox/Makefile.kmk.orig	2013-10-16 21:47:09.588793988 +0400
++++ src/VBox/Frontends/VirtualBox/Makefile.kmk	2013-10-16 21:47:37.458794265 +0400
+@@ -175,10 +175,6 @@
+ # Necessary for the hdd backend enumeration
+ VirtualBox_LIBS = $(LIB_DDU)
+ 
+-if1of ($(KBUILD_TARGET), linux freebsd netbsd openbsd)
+- VirtualBox_LIBS += dl
+-endif
+-
+ # This library is required for multi-monitor support
+ VirtualBox_LIBS.linux   += Xinerama
+ VirtualBox_LIBS.solaris += Xinerama
diff --git a/virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp b/virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp
new file mode 100644
index 0000000..7d84448
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Frontends-VirtualBox-src-runtime-UIKeyboardHandler.cpp
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp.orig	2015-03-02 10:09:41.000000000 -0500
++++ src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp	2015-03-12 17:11:33.029804000 -0400
+@@ -622,7 +622,7 @@
+             unsigned scan = handleXKeyEvent(pEvent);
+ 
+             /* Scancodes 0x00 (no valid translation) and 0x80 are ignored: */
+-            if (!scan & 0x7F)
++            if (!(scan & 0x7F))
+             {
+                 fResult = true;
+                 break;
+@@ -1603,7 +1603,7 @@
+     {
+         KeySym ks = wrapXkbKeycodeToKeysym(pDisplay, keyCode, i, 0);
+         char symbol = 0;
+-        if (!XkbTranslateKeySym(pDisplay, &ks, 0, &symbol, 1, NULL) == 1)
++        if (XkbTranslateKeySym(pDisplay, &ks, 0, &symbol, 1, NULL) == 0)
+             symbol = 0;
+         if (symbol)
+         {
diff --git a/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk
new file mode 100644
index 0000000..1e460d3
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-Makefile.kmk
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/Makefile.kmk.orig	2014-11-21 10:22:21.000000000 -0500
++++ src/VBox/GuestHost/OpenGL/Makefile.kmk	2014-12-22 17:20:31.000000000 -0500
+@@ -116,7 +116,7 @@
+ endif
+ VBoxOGLcrutil_CLEAN = \
+ 	$(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c
+-if1of ($(KBUILD_TARGET), linux)
++if1of ($(KBUILD_TARGET), linux freebsd)
+ VBoxOGLcrutil_LDFLAGS += -Wl,-z,nodelete
+ endif
+ 
+@@ -160,7 +160,7 @@
+ if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_WDDM)
+  VBoxOGLhostcrutil_INSTTYPE.win = both
+ endif
+-if1of ($(KBUILD_TARGET), linux)
++if1of ($(KBUILD_TARGET), linux freebsd)
+ VBoxOGLhostcrutil_LDFLAGS = $(NO_SUCH_VARIABLE)
+ endif
+ VBoxOGLhostcrutil_LDFLAGS.darwin = $(VBoxOGLcrutil_LDFLAGS.darwin) \
diff --git a/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_line.h b/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_line.h
new file mode 100644
index 0000000..5031367
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_line.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/include/state/cr_line.h.orig	2015-03-02 10:09:45.000000000 -0500
++++ src/VBox/GuestHost/OpenGL/include/state/cr_line.h	2015-03-02 19:26:01.576169000 -0500
+@@ -5,7 +5,7 @@
+  */
+ 
+ #ifndef CR_STATE_LINE_H
+-#define SR_STATE_LINE_H
++#define CR_STATE_LINE_H
+ 
+ #include "state/cr_statetypes.h"
+ 
diff --git a/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_point.h b/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_point.h
new file mode 100644
index 0000000..dc43f94
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-GuestHost-OpenGL-include-state-cr_point.h
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/include/state/cr_point.h.orig	2015-03-02 10:09:45.000000000 -0500
++++ src/VBox/GuestHost/OpenGL/include/state/cr_point.h	2015-03-02 19:21:08.518525000 -0500
+@@ -4,8 +4,8 @@
+  * See the file LICENSE.txt for information on redistributing this software.
+  */
+ 
+-#ifndef CR_STATE_LINE_H
+-#define SR_STATE_LINE_H
++#ifndef CR_STATE_POINT_H
++#define CR_STATE_POINT_H
+ 
+ #include "state/cr_statetypes.h"
+ 
+@@ -59,4 +59,4 @@
+ }
+ #endif
+ 
+-#endif /* CR_STATE_LINE_H */
++#endif /* CR_STATE_POINT_H */
diff --git a/virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-Makefile b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
new file mode 100644
index 0000000..eeb2bcd
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-Makefile
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/freebsd/Makefile.orig	2014-09-09 23:54:29.000000000 +0400
++++ src/VBox/HostDrivers/Support/freebsd/Makefile	2014-09-15 02:58:19.712268153 +0400
+@@ -81,6 +81,7 @@
+ 	handletable.c \
+ 	handletablectx.c \
+ 	once.c \
++	term.c \
+ 	thread.c
+ 
+ .PATH:	${.CURDIR}/common/string
+@@ -170,6 +171,7 @@
+ SRCS += \
+ 	semspinmutex-r0drv-generic.c \
+ 	mpnotification-r0drv-generic.c \
++	threadctxhooks-r0drv-generic.c \
+ 	RTMpIsCpuWorkPending-r0drv-generic.c
+ 
+ .PATH:	${.CURDIR}/VBox
diff --git a/virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
new file mode 100644
index 0000000..b9d1f8a
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-Support-freebsd-files_vboxdrv
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/freebsd/files_vboxdrv.orig	2014-09-15 03:01:58.782238686 +0400
++++ src/VBox/HostDrivers/Support/freebsd/files_vboxdrv	2014-09-15 03:02:08.840242076 +0400
+@@ -112,6 +112,7 @@
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.h=>common/misc/handletable.h \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletablectx.cpp=>common/misc/handletablectx.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/once.cpp=>common/misc/once.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/term.cpp=>common/misc/term.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/misc/thread.cpp=>common/misc/thread.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopyP.cpp=>common/string/RTStrCopyP.c \
+     ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopy.cpp=>common/string/RTStrCopy.c \
diff --git a/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
new file mode 100644
index 0000000..caf10b1
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-Makefile.kmk
@@ -0,0 +1,27 @@
+$NetBSD$
+
+Fix kmod panic when VIMAGE is disabled in the kernel and port
+
+Submitted by:	Gleb Kurtsou <gleb%freebsd.org@localhost>
+--- src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk.orig	2013-04-12 03:38:10.000000000 -0700
++++ src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk	2013-06-11 21:24:05.000000000 -0700
+@@ -143,12 +143,15 @@
+ 		$$(if $$(eq $$(VBoxNetAdp/freebsd/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
+ 		| $$(dir $$@)
+ 	$(QUIET)$(RM) -f -- $@
+- ifndef VBOX_WITH_HARDENING
+-	$(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@ $<
+- else
+ 	$(QUIET)$(CP) -f $< $@
++ ifndef VBOX_WITH_HARDENING
++	$(QUIET)$(SED) -e "s;-DVBOX_WITH_HARDENING;;g" --output $@.tmp $@
++	${QUIET}$(MV) -f $@.tmp $@
++ endif
++ ifndef VBOX_WITH_NETFLT_VIMAGE
++	$(QUIET)$(SED) -e "s;-DVIMAGE;;g" --output $@.tmp $@
++	${QUIET}$(MV) -f $@.tmp $@
+  endif
+-
+ endif # freebsd
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c
new file mode 100644
index 0000000..ac415e5
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig	2014-09-09 15:54:30.000000000 -0400
++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c	2014-09-30 15:36:06.000000000 -0400
+@@ -234,7 +234,11 @@
+     ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+     while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
+     {
++#if __FreeBSD_version >= 1100036
++        if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
++#else
+         ifp->if_opackets++;
++#endif
+         IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+         BPF_MTAP(ifp, m);
+         m_freem(m);
diff --git a/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
new file mode 100644
index 0000000..1a2c9a2
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
@@ -0,0 +1,74 @@
+$NetBSD$
+
+Add VLAN trunking support to vboxnetflt
+
+See:		http://lists.freebsd.org/pipermail/freebsd-emulation/2012-April/009698.html
+See:		http://lists.freebsd.org/pipermail/freebsd-emulation/2013-May/010605.html
+Submitted by:	Landon J Fuller <landonf at plausible.coop>
+--- ./src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c.orig	2013-04-12 06:38:11.000000000 -0400
++++ ./src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c	2013-05-25 20:14:52.152180452 -0400
+@@ -51,6 +51,7 @@
+ #include <net/if_dl.h>
+ #include <net/if_types.h>
+ #include <net/ethernet.h>
++#include <net/if_vlan_var.h>
+ 
+ #include <netgraph/ng_message.h>
+ #include <netgraph/netgraph.h>
+@@ -427,6 +428,8 @@
+     struct ifnet *ifp = pThis->u.s.ifp;
+     unsigned int cSegs = 0;
+     bool fDropIt = false, fActive;
++    bool is_vl_tagged = false;
++    uint16_t vl_tag;
+     PINTNETSG pSG;
+ 
+     VBOXCURVNET_SET(ifp->if_vnet);
+@@ -439,6 +442,19 @@
+         if (m == NULL)
+             break;
+ 
++        /* Prepend a VLAN header for consumption by the virtual switch */
++        if (m->m_flags & M_VLANTAG) {
++            vl_tag = m->m_pkthdr.ether_vtag;
++            is_vl_tagged = true;
++
++            m = ether_vlanencap(m, m->m_pkthdr.ether_vtag);
++            if (m == NULL) {
++                printf("vboxflt: unable to prepend VLAN header\n");
++                break;
++            }
++            m->m_flags &= ~M_VLANTAG;
++        }
++
+         for (m0 = m; m0 != NULL; m0 = m0->m_next)
+             if (m0->m_len > 0)
+                 cSegs++;
+@@ -453,6 +469,27 @@
+         vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0);
+         fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, NULL /* pvIf */, pSG, INTNETTRUNKDIR_WIRE);
+         RTMemTmpFree(pSG);
++
++        /* Restore the VLAN flags before re-injecting the packet */
++        if (is_vl_tagged && !fDropIt) {
++            struct ether_vlan_header *vl_hdr;
++
++            /* This shouldn't fail, as the header was just prepended */
++            if (m->m_len < sizeof(*vl_hdr) && (m = m_pullup(m, sizeof(*vl_hdr))) == NULL) {
++                printf("vboxflt: unable to pullup VLAN header\n");
++                m_freem(m);
++                break;
++            }
++
++            /* Copy the MAC dhost/shost over the 802.1q field */
++            vl_hdr = mtod(m, struct ether_vlan_header *);
++            bcopy((char *)vl_hdr, (char *)vl_hdr + ETHER_VLAN_ENCAP_LEN, ETHER_HDR_LEN - ETHER_TYPE_LEN);
++            m_adj(m, ETHER_VLAN_ENCAP_LEN);
++
++            m->m_pkthdr.ether_vtag = vl_tag;
++            m->m_flags |= M_VLANTAG;
++        }
++
+         if (fDropIt)
+             m_freem(m);
+         else
diff --git a/virtualbox-ose/patches/patch-src-VBox-Installer-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Installer-Makefile.kmk
new file mode 100644
index 0000000..8671f3a
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Installer-Makefile.kmk
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/Installer/Makefile.kmk.orig	2009-10-05 14:31:40.000000000 +0200
++++ src/VBox/Installer/Makefile.kmk	2009-10-05 14:32:09.000000000 +0200
+@@ -38,10 +38,12 @@
+  if "$(KBUILD_TARGET)" == "win" && "$(KBUILD_HOST)" == "win"
+   include $(PATH_SUB_CURRENT)/win/Makefile.kmk
+  endif
++if 0
+  if "$(KBUILD_TARGET)" == "freebsd" && "$(KBUILD_HOST)" == "freebsd"
+   include $(PATH_SUB_CURRENT)/freebsd/Makefile.kmk
+  endif
+ endif
++endif
+ 
+ include $(PATH_SUB_CURRENT)/common/Makefile.kmk
+ 
diff --git a/virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-VBox.sh b/virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-VBox.sh
new file mode 100644
index 0000000..e736cd5
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-VBox.sh
@@ -0,0 +1,63 @@
+$NetBSD$
+
+--- src/VBox/Installer/freebsd/VBox.sh.orig	2015-02-16 12:58:52.951032000 -0500
++++ src/VBox/Installer/freebsd/VBox.sh	2015-02-16 13:00:48.096063000 -0500
+@@ -0,0 +1,58 @@
++#!/bin/sh
++#
++# Oracle VM VirtualBox startup script, FreeBSD hosts.
++#
++# Copyright (C) 2006-2012 Oracle Corporation
++#
++# This file is part of VirtualBox Open Source Edition (OSE), as
++# available from http://www.virtualbox.org. This file is free software;
++# you can redistribute it and/or modify it under the terms of the GNU
++# General Public License (GPL) as published by the Free Software
++# Foundation, in version 2 as it comes in the "COPYING" file of the
++# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
++# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
++#
++
++PATH="/usr/bin:/bin:/usr/sbin:/sbin"
++CONFIG="@PREIFX@/etc/vbox/vbox.cfg"
++
++test -r "${CONFIG}" &&
++    . "${CONFIG}"
++test -z "${INSTALL_DIR}" &&
++    if test -d @PREIFX@/lib/virtualbox &&
++        test -f @PREIFX@/lib/virtualbox/VBoxRT.so; then
++        INSTALL_DIR=@PREIFX@/lib/virtualbox
++    else
++        echo "Could not find VirtualBox installation. Please reinstall."
++        exit 1
++    fi
++
++APP=`basename $0`
++case "$APP" in
++    VirtualBox|virtualbox)
++        exec "$INSTALL_DIR/VirtualBox" "$@"
++        ;;
++    VBoxManage|vboxmanage)
++        exec "$INSTALL_DIR/VBoxManage" "$@"
++        ;;
++    VBoxSDL|vboxsdl)
++        exec "$INSTALL_DIR/VBoxSDL" "$@"
++        ;;
++    VBoxVRDP|VBoxHeadless|vboxheadless)
++        exec "$INSTALL_DIR/VBoxHeadless" "$@"
++        ;;
++    VBoxAutostart|vboxautostart)
++        exec "$INSTALL_DIR/VBoxAutostart" "$@"
++        ;;
++    VBoxBalloonCtrl|vboxballoonctrl)
++        exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
++        ;;
++    vboxwebsrv)
++        exec "$INSTALL_DIR/vboxwebsrv" "$@"
++        ;;
++    *)
++        echo "Unknown application - $APP"
++        exit 1
++        ;;
++esac
++exit 0
diff --git a/virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-virtualbox.desktop b/virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-virtualbox.desktop
new file mode 100644
index 0000000..9731f6b
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Installer-freebsd-virtualbox.desktop
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/VBox/Installer/freebsd/virtualbox.desktop.orig	2010-10-07 10:42:04.000000000 +0200
++++ src/VBox/Installer/freebsd/virtualbox.desktop	2010-10-07 10:43:20.000000000 +0200
+@@ -7,7 +7,6 @@
+ Type=Application
+ Exec=VirtualBox
+ TryExec=VirtualBox
+-DocPath=file://$VBOX_DOC_PATH/UserManual.pdf
+ Icon=VBox
+ Categories=Emulator;System;
+ Comment=Run several virtual systems on a single host computer
diff --git a/virtualbox-ose/patches/patch-src-VBox-Main-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Main-Makefile.kmk
new file mode 100644
index 0000000..1a8ec6f
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Main-Makefile.kmk
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- src/VBox/Main/Makefile.kmk.orig	2013-11-09 02:27:38.919839981 +0400
++++ src/VBox/Main/Makefile.kmk	2013-11-09 02:19:21.868873439 +0400
+@@ -404,7 +404,8 @@
+ 	src-server/HostDnsServiceResolvConf.cpp
+ 
+ VBoxSVC_SOURCES.freebsd = \
+-	src-server/freebsd/HostHardwareFreeBSD.cpp
++	src-server/freebsd/HostHardwareFreeBSD.cpp \
++	src-server/HostDnsServiceResolvConf.cpp
+ 
+ 
+ ifdef VBOX_WITH_USB
diff --git a/virtualbox-ose/patches/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp b/virtualbox-ose/patches/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp
new file mode 100644
index 0000000..d2241ae
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Main-src-client-ConsoleImpl2.cpp
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- src/VBox/Main/src-client/ConsoleImpl2.cpp.orig	2015-03-02 10:09:53.000000000 -0500
++++ src/VBox/Main/src-client/ConsoleImpl2.cpp	2015-03-13 12:49:53.780376000 -0400
+@@ -4447,12 +4447,12 @@
+                     }
+                 }
+ 
+-                Assert((int)maTapFD[uInstance] >= 0);
+-                if ((int)maTapFD[uInstance] >= 0)
++                Assert((intptr_t)maTapFD[uInstance] >= 0);
++                if ((intptr_t)maTapFD[uInstance] >= 0)
+                 {
+                     InsertConfigString(pLunL0, "Driver", "HostInterface");
+                     InsertConfigNode(pLunL0, "Config", &pCfg);
+-                    InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]);
++                    InsertConfigInteger(pCfg, "FileHandle", (intptr_t)maTapFD[uInstance]);
+                 }
+ 
+ #elif defined(VBOX_WITH_NETFLT)
+@@ -4646,12 +4646,12 @@
+                         }
+                     }
+ 
+-                    Assert((int)maTapFD[uInstance] >= 0);
+-                    if ((int)maTapFD[uInstance] >= 0)
++                    Assert((intptr_t)maTapFD[uInstance] >= 0);
++                    if ((intptr_t)maTapFD[uInstance] >= 0)
+                     {
+                         InsertConfigString(pLunL0, "Driver", "HostInterface");
+                         InsertConfigNode(pLunL0, "Config", &pCfg);
+-                        InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]);
++                        InsertConfigInteger(pCfg, "FileHandle", (intptr_t)maTapFD[uInstance]);
+                     }
+                     break;
+                 }
diff --git a/virtualbox-ose/patches/patch-src-VBox-Main-src-server-MachineImpl.cpp b/virtualbox-ose/patches/patch-src-VBox-Main-src-server-MachineImpl.cpp
new file mode 100644
index 0000000..86e050e
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Main-src-server-MachineImpl.cpp
@@ -0,0 +1,49 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/MachineImpl.cpp.orig	2013-12-18 11:10:25.000000000 -0500
++++ src/VBox/Main/src-server/MachineImpl.cpp	2014-02-20 19:17:10.000000000 -0500
+@@ -2374,7 +2374,7 @@
+         case 0x8:
+         case 0x9:
+         case 0xA:
+-            AssertCompile(RT_ELEMENTS(mHWData->mCpuIdStdLeafs) == 0xB);
++            // AssertCompile(RT_ELEMENTS(mHWData->mCpuIdStdLeafs) == 0xB);
+             AssertRelease(aId < RT_ELEMENTS(mHWData->mCpuIdStdLeafs));
+             setModified(IsModified_MachineData);
+             mHWData.backup();
+@@ -2396,7 +2396,7 @@
+         case 0x80000008:
+         case 0x80000009:
+         case 0x8000000A:
+-            AssertCompile(RT_ELEMENTS(mHWData->mCpuIdExtLeafs) == 0xB);
++            // AssertCompile(RT_ELEMENTS(mHWData->mCpuIdExtLeafs) == 0xB);
+             AssertRelease(aId - 0x80000000 < RT_ELEMENTS(mHWData->mCpuIdExtLeafs));
+             setModified(IsModified_MachineData);
+             mHWData.backup();
+@@ -2436,7 +2436,7 @@
+         case 0x8:
+         case 0x9:
+         case 0xA:
+-            AssertCompile(RT_ELEMENTS(mHWData->mCpuIdStdLeafs) == 0xB);
++            // AssertCompile(RT_ELEMENTS(mHWData->mCpuIdStdLeafs) == 0xB);
+             AssertRelease(aId < RT_ELEMENTS(mHWData->mCpuIdStdLeafs));
+             setModified(IsModified_MachineData);
+             mHWData.backup();
+@@ -2455,7 +2455,7 @@
+         case 0x80000008:
+         case 0x80000009:
+         case 0x8000000A:
+-            AssertCompile(RT_ELEMENTS(mHWData->mCpuIdExtLeafs) == 0xB);
++            // AssertCompile(RT_ELEMENTS(mHWData->mCpuIdExtLeafs) == 0xB);
+             AssertRelease(aId - 0x80000000 < RT_ELEMENTS(mHWData->mCpuIdExtLeafs));
+             setModified(IsModified_MachineData);
+             mHWData.backup();
+@@ -9322,7 +9322,7 @@
+         mHWData->mVideoCaptureEnabled = data.fVideoCaptureEnabled;
+         for (unsigned i = 0; i < RT_ELEMENTS(mHWData->maVideoCaptureScreens); i++)
+             mHWData->maVideoCaptureScreens[i] = ASMBitTest(&data.u64VideoCaptureScreens, i);
+-        AssertCompile(RT_ELEMENTS(mHWData->maVideoCaptureScreens) == sizeof(data.u64VideoCaptureScreens) * 8);
++        // AssertCompile(RT_ELEMENTS(mHWData->maVideoCaptureScreens) == sizeof(data.u64VideoCaptureScreens) * 8);
+         mHWData->mVideoCaptureRate = data.ulVideoCaptureRate;
+         mHWData->mVideoCaptureFPS = data.ulVideoCaptureFPS;
+         if (!data.strVideoCaptureFile.isEmpty())
diff --git a/virtualbox-ose/patches/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp b/virtualbox-ose/patches/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
new file mode 100644
index 0000000..8133403
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Main-src-server-VirtualBoxImpl.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/VirtualBoxImpl.cpp.orig	2013-12-18 11:10:25.000000000 -0500
++++ src/VBox/Main/src-server/VirtualBoxImpl.cpp	2014-02-20 19:51:23.000000000 -0500
+@@ -2355,7 +2355,7 @@
+     if (aCiphertextSize < 32)
+         return VERR_INVALID_PARAMETER;
+ 
+-    AssertCompile(sizeof(m->SettingsCipherKey) >= 32);
++    // AssertCompile(sizeof(m->SettingsCipherKey) >= 32);
+ 
+     /* store the first 8 bytes of the cipherkey for verification */
+     for (i = 0, j = 0; i < 8; i++, j++)
diff --git a/virtualbox-ose/patches/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp b/virtualbox-ose/patches/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp
new file mode 100644
index 0000000..790acf4
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Main-src-server-freebsd-HostHardwareFreeBSD.cpp
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp.orig	2013-11-29 14:24:12.000000000 -0500
++++ src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp	2013-12-13 18:03:02.000000000 -0500
+@@ -39,6 +39,7 @@
+ # include <sys/stat.h>
+ # include <unistd.h>
+ # include <sys/ioctl.h>
++# include <stdio.h>
+ # include <fcntl.h>
+ # include <cam/cam.h>
+ # include <cam/cam_ccb.h>
+@@ -250,7 +251,7 @@
+                         PeriphMatchPattern.pattern.periph_pattern.path_id    = paMatches[i].result.device_result.path_id;
+                         PeriphMatchPattern.pattern.periph_pattern.target_id  = paMatches[i].result.device_result.target_id;
+                         PeriphMatchPattern.pattern.periph_pattern.target_lun = paMatches[i].result.device_result.target_lun;
+-                        PeriphMatchPattern.pattern.periph_pattern.flags      = PERIPH_MATCH_PATH | PERIPH_MATCH_TARGET | PERIPH_MATCH_LUN;
++                        PeriphMatchPattern.pattern.periph_pattern.flags      = static_cast<periph_pattern_flags>(PERIPH_MATCH_PATH | PERIPH_MATCH_TARGET | PERIPH_MATCH_LUN);
+                         PeriphCCB.cdm.num_patterns    = 1;
+                         PeriphCCB.cdm.pattern_buf_len = sizeof(struct dev_match_result);
+                         PeriphCCB.cdm.patterns        = &PeriphMatchPattern;
diff --git a/virtualbox-ose/patches/patch-src-VBox-Main-webservice-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Main-webservice-Makefile.kmk
new file mode 100644
index 0000000..dcd5686
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Main-webservice-Makefile.kmk
@@ -0,0 +1,41 @@
+$NetBSD$
+
+--- src/VBox/Main/webservice/Makefile.kmk.orig	2014-09-09 23:54:50.000000000 +0400
++++ src/VBox/Main/webservice/Makefile.kmk	2014-09-11 16:34:40.678876468 +0400
+@@ -159,7 +159,6 @@
+ RECOMPILE_ON_MAKEFILE_CURRENT := $(MAKEFILE_CURRENT)
+ 
+ PATH_TARGET_SOAPDEMOXML       := $(VBOXWEB_OUT_DIR)/demo_soapxml
+-PATH_TARGET_SOAPDEMOHEADERS   := $(VBOXWEB_OUT_DIR)/demo_headers
+ PATH_TARGET_SOAPDEMONSMAPS    := $(VBOXWEB_OUT_DIR)/demo_namespacemaps
+ PATH_TARGET_WEBTEST           := $(VBOXWEB_OUT_DIR)/webtest
+ 
+@@ -512,8 +511,6 @@
+ 	$(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts \
+ 	$(wildcard $(PATH_TARGET_SOAPDEMOXML)/*) \
+ 	$(PATH_TARGET_SOAPDEMOXML)/dummy_file \
+-	$(wildcard $(PATH_TARGET_SOAPDEMOHEADERS)/*) \
+-	$(PATH_TARGET_SOAPDEMOHEADERS)/dummy_file \
+ 	$(wildcard $(PATH_TARGET_SOAPDEMONSMAPS)/*) \
+ 	$(PATH_TARGET_SOAPDEMONSMAPS)/dummy_file
+ 
+@@ -691,17 +688,14 @@
+ # however we cannot as it is subject to caching.  Let the shell do the globbing.
+ $(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts: $(VBOXWEB_OUT_DIR)/gsoap_generate_all_ts | $$(dir $$@)
+ 	$(RM) -f $@
+-	$(MKDIR) -p $(PATH_TARGET_SOAPDEMOXML) $(PATH_TARGET_SOAPDEMOHEADERS) $(PATH_TARGET_SOAPDEMONSMAPS)
++	$(MKDIR) -p $(PATH_TARGET_SOAPDEMOXML) $(PATH_TARGET_SOAPDEMONSMAPS)
+ ifdef VBOX_GSOAP_VERBOSE
+ 	$(MV_EXT) -f -- $(VBOXWEB_OUT_DIR)/*.req.xml $(VBOXWEB_OUT_DIR)/*.res.xml $(PATH_TARGET_SOAPDEMOXML)/
+ endif
+-	$(MV_EXT) -f -- $(VBOXWEB_OUT_DIR)/soapvbox*.h $(PATH_TARGET_SOAPDEMOHEADERS)/
+ 	$(MV_EXT) -f -- $(VBOXWEB_OUT_DIR)/vboxBinding.nsmap $(PATH_TARGET_SOAPDEMONSMAPS)/
+ 	$(APPEND) $@ done
+ 
+-$(PATH_TARGET_SOAPDEMONSMAPS) \
+-$(PATH_TARGET_SOAPDEMOHEADERS)/soapvboxBindingProxy.h \
+-$(PATH_TARGET_SOAPDEMOHEADERS)/soapvboxBindingObject.h: $(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts
++$(PATH_TARGET_SOAPDEMONSMAPS): $(VBOXWEB_OUT_DIR)/gsoap_copy_all_ts
+ 
+ # soapcpp2 -2: generate SOAP 1.2 calls
+ # soapcpp2 -S: server-side code only
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-Makefile.kmk b/virtualbox-ose/patches/patch-src-VBox-Runtime-Makefile.kmk
new file mode 100644
index 0000000..5d50482
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-Makefile.kmk
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- src/VBox/Runtime/Makefile.kmk.orig	2014-07-15 13:25:15.000000000 -0400
++++ src/VBox/Runtime/Makefile.kmk	2014-07-16 17:15:58.000000000 -0400
+@@ -146,6 +146,11 @@
+ 	IPRT_BLDCFG_TYPE=\"$(KBUILD_TYPE)\"
+ 
+ #
++# Set the defines that utf8-posix.cpp needs. It's used by several targets.
++#
++r3/posix/utf8-posix.cpp_DEFS.freebsd = $(VBOX_ICONV_DEFS)
++
++#
+ # Unicode Specification reader used to regenerate unidata-*.cpp.
+ #
+ uniread_TEMPLATE = VBoxBldProg
+@@ -1004,7 +1009,7 @@
+ 	r3/posix/RTMemProtect-posix.cpp \
+ 	r3/posix/RTPathUserHome-posix.cpp \
+ 	r3/posix/RTSystemQueryOSInfo-posix.cpp \
+-	r3/posix/RTSystemQueryTotalRam-posix.cpp \
++	r3/freebsd/RTSystemQueryTotalRam-freebsd.cpp \
+ 	r3/posix/RTTimeNow-posix.cpp \
+ 	r3/posix/RTTimeSet-posix.cpp \
+ 	r3/posix/dir-posix.cpp \
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-common-checksum-manifest3.cpp b/virtualbox-ose/patches/patch-src-VBox-Runtime-common-checksum-manifest3.cpp
new file mode 100644
index 0000000..bdc6f5c
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-common-checksum-manifest3.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Runtime/common/checksum/manifest3.cpp.orig	2015-03-02 10:09:59.000000000 -0500
++++ src/VBox/Runtime/common/checksum/manifest3.cpp	2015-03-12 15:40:09.008443000 -0400
+@@ -427,7 +427,7 @@
+     uint32_t cRefs = RTManifestRetain(hManifest);
+     AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE);
+     cRefs = RTVfsIoStrmRetain(hVfsIos);
+-    AssertReturnStmt(cRefs != UINT32_MAX, VERR_INVALID_HANDLE, RTManifestRelease(hManifest));
++    AssertReturnStmt(cRefs != UINT32_MAX, RTManifestRelease(hManifest), VERR_INVALID_HANDLE);
+ 
+     /*
+      * Create an instace of the passthru I/O stream.
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp b/virtualbox-ose/patches/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp
new file mode 100644
index 0000000..939201e
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-common-dbg-dbgmodcodeview.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp.orig	2015-03-02 10:10:00.000000000 -0500
++++ src/VBox/Runtime/common/dbg/dbgmodcodeview.cpp	2015-03-12 16:22:25.459078000 -0400
+@@ -2717,7 +2717,7 @@
+         {
+             /* Try the executable in case it has a NBxx tail header. */
+             rc2 = rtDbgModCvProbeFile(pMod, pMod->pszImgFile, enmArch);
+-            if (RT_FAILURE(rc2) && (RT_SUCCESS(rc) || VERR_DBG_NO_MATCHING_INTERPRETER))
++            if (RT_FAILURE(rc2) && (RT_SUCCESS(rc) || rc == VERR_DBG_NO_MATCHING_INTERPRETER))
+                 rc = rc2;
+         }
+     }
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-common-misc-uri.cpp b/virtualbox-ose/patches/patch-src-VBox-Runtime-common-misc-uri.cpp
new file mode 100644
index 0000000..e2861c8
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-common-misc-uri.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/VBox/Runtime/common/misc/uri.cpp.orig	2013-12-18 11:10:34.000000000 -0500
++++ src/VBox/Runtime/common/misc/uri.cpp	2013-12-19 20:57:32.000000000 -0500
+@@ -132,7 +132,10 @@
+             /* % encoding means the percent sign and exactly 2 hexadecimal
+              * digits describing the ASCII number of the character. */
+             ++iIn;
+-            char szNum[] = { pszString[iIn++], pszString[iIn++], '\0' };
++            char szNum[3];
++            szNum[0] = pszString[iIn++];
++            szNum[1] = pszString[iIn++];
++            szNum[2] = '\0';
+             uint8_t u8;
+             rc = RTStrToUInt8Ex(szNum, NULL, 16, &u8);
+             if (RT_FAILURE(rc))
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c b/virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c
new file mode 100644
index 0000000..c7b268b
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-memobj-r0drv-freebsd.c
@@ -0,0 +1,131 @@
+$NetBSD$
+
+From Alan L. Cox on FreeBSD-current:
+
+    I just glanced at the virtualbox code for a couple minutes.  For
+    FreeBSD 9 and 10, these lock acquires are completely unnecessary, and
+    have been since FreeBSD 9.0.  Just delete them.  They may be equally
+    unnecessary under FreeBSD 8, but I didn't look carefully enough to
+    answer that question.
+
+[1] http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html
+--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c.orig	2015-05-13 11:12:38.000000000 -0400
++++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	2015-06-10 16:42:33.632228000 -0400
+@@ -168,14 +168,19 @@
+             VM_OBJECT_LOCK(pMemFreeBSD->pObject);
+ #endif
+             vm_page_t pPage = vm_page_find_least(pMemFreeBSD->pObject, 0);
++#if __FreeBSD_version < 900000
++            /* See http://lists.freebsd.org/pipermail/freebsd-current/2012-November/037963.html */
+             vm_page_lock_queues();
++#endif
+             for (vm_page_t pPage = vm_page_find_least(pMemFreeBSD->pObject, 0);
+                  pPage != NULL;
+                  pPage = vm_page_next(pPage))
+             {
+                 vm_page_unwire(pPage, 0);
+             }
++#if __FreeBSD_version < 900000
+             vm_page_unlock_queues();
++#endif
+ #if __FreeBSD_version >= 1000030
+             VM_OBJECT_WUNLOCK(pMemFreeBSD->pObject);
+ #else
+@@ -201,12 +206,12 @@
+     vm_page_t pPages;
+     int cTries = 0;
+ 
+-#if __FreeBSD_version > 1000000
++#if __FreeBSD_version >= 902508
+     int fFlags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY;
+     if (fWire)
+         fFlags |= VM_ALLOC_WIRED;
+ 
+-    while (cTries <= 1)
++    while (1)
+     {
+ #if __FreeBSD_version >= 1000030
+         VM_OBJECT_WLOCK(pObject);
+@@ -220,18 +225,20 @@
+ #else
+         VM_OBJECT_UNLOCK(pObject);
+ #endif
+-        if (pPages)
++        if (pPages || cTries >= 1)
+             break;
++#if __FreeBSD_version >= 1000015
+         vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
++#else
++        vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
++#endif
+         cTries++;
+     }
+-
+-    return pPages;
+ #else
+-    while (cTries <= 1)
++    while (1)
+     {
+         pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
+-        if (pPages)
++        if (pPages || cTries >= 1)
+             break;
+         vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
+         cTries++;
+@@ -239,11 +246,8 @@
+ 
+     if (!pPages)
+         return pPages;
+-#if __FreeBSD_version >= 1000030
+-    VM_OBJECT_WLOCK(pObject);
+-#else
++
+     VM_OBJECT_LOCK(pObject);
+-#endif
+     for (vm_pindex_t iPage = 0; iPage < cPages; iPage++)
+     {
+         vm_page_t pPage = pPages + iPage;
+@@ -255,13 +259,9 @@
+             atomic_add_int(&cnt.v_wire_count, 1);
+         }
+     }
+-#if __FreeBSD_version >= 1000030
+-    VM_OBJECT_WUNLOCK(pObject);
+-#else
+     VM_OBJECT_UNLOCK(pObject);
+ #endif
+     return pPages;
+-#endif
+ }
+ 
+ static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
+@@ -291,11 +291,15 @@
+             while (iPage-- > 0)
+             {
+                 pPage = vm_page_lookup(pObject, iPage);
++#if __FreeBSD_version < 900000
+                 vm_page_lock_queues();
++#endif
+                 if (fWire)
+                     vm_page_unwire(pPage, 0);
+                 vm_page_free(pPage);
++#if __FreeBSD_version < 900000
+                 vm_page_unlock_queues();
++#endif
+             }
+ #if __FreeBSD_version >= 1000030
+             VM_OBJECT_WUNLOCK(pObject);
+@@ -743,7 +747,12 @@
+     {
+         /** @todo: is this needed?. */
+         PROC_LOCK(pProc);
+-        AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr + lim_max(pProc, RLIMIT_DATA));
++        AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr +
++#if __FreeBSD_version >= 1100077
++                            lim_max_proc(pProc, RLIMIT_DATA));
++#else
++                            lim_max(pProc, RLIMIT_DATA));
++#endif
+         PROC_UNLOCK(pProc);
+     }
+     else
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h b/virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
new file mode 100644
index 0000000..617da15
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-r0drv-freebsd-sleepqueue-r0drv-freebsd.h
@@ -0,0 +1,22 @@
+$NetBSD$
+
+Without this patch any waits for periods shorter than a single tick return
+immediately leading to a lot of unnecessary spinning. For example, I observe that
+my guest's idle loop does a lot of sleeps with periods slightly shorter than 1 ms
+(1/hz), e.g. 900us.  All that waiting turns into pure spinning and VirtualBox eats
+100% of a core.
+The patch improves the situation significantly. Also, it (approximately) follows
+what tvtohz does.
+
+Submitted by:	Andriy Gapon <avg%FreeBSD.org@localhost>
+--- src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h.orig	2012-12-19 19:27:29.000000000 +0100
++++ src/VBox/Runtime/r0drv/freebsd/sleepqueue-r0drv-freebsd.h	2012-12-20 12:07:48.941861966 +0100
+@@ -82,6 +82,8 @@
+     uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
+     if (cTicks >= INT_MAX)
+         return RTSEMWAIT_FLAGS_INDEFINITE;
++    else if (cTicks == 0 && uTimeout > 0)
++        pWait->iTimeout     = 1;
+     else
+         pWait->iTimeout     = (int)cTicks;
+ #endif
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-r3-freebsd-RTSystemQueryTotalRam-freebsd.cpp b/virtualbox-ose/patches/patch-src-VBox-Runtime-r3-freebsd-RTSystemQueryTotalRam-freebsd.cpp
new file mode 100644
index 0000000..0ec57c5
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-r3-freebsd-RTSystemQueryTotalRam-freebsd.cpp
@@ -0,0 +1,85 @@
+$NetBSD$
+
+--- ./src/VBox/Runtime/r3/freebsd/RTSystemQueryTotalRam-freebsd.cpp.ORIG	2013-06-30 09:27:59.000000000 +0200
++++ ./src/VBox/Runtime/r3/freebsd/RTSystemQueryTotalRam-freebsd.cpp	2013-06-30 09:51:29.000000000 +0200
+@@ -0,0 +1,80 @@
++/* $Id: RTSystemQueryTotalRam-freebsd.cpp $ */
++/** @file
++ * IPRT - RTSystemQueryTotalRam, FreeBSD style
++ */
++
++/*
++ * Copyright (C) 2013 Martin Birgmeier, Oracle Corporation
++ *
++ * This file is part of VirtualBox Open Source Edition (OSE), as
++ * available from http://www.virtualbox.org. This file is free software;
++ * you can redistribute it and/or modify it under the terms of the GNU
++ * General Public License (GPL) as published by the Free Software
++ * Foundation, in version 2 as it comes in the "COPYING" file of the
++ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
++ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
++ *
++ * The contents of this file may alternatively be used under the terms
++ * of the Common Development and Distribution License Version 1.0
++ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
++ * VirtualBox OSE distribution, in which case the provisions of the
++ * CDDL are applicable instead of those of the GPL.
++ *
++ * You may elect to license modified versions of this file under the
++ * terms and conditions of either the GPL or the CDDL or both.
++ */
++
++
++/*******************************************************************************
++*   Header Files                                                               *
++*******************************************************************************/
++#include <iprt/system.h>
++#include "internal/iprt.h"
++
++#include <iprt/err.h>
++#include <iprt/assert.h>
++#include <iprt/string.h>
++
++/* FreeBSD */
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <sys/errno.h>
++
++RTDECL(int) RTSystemQueryTotalRam(uint64_t *pcb)
++{
++    int mib[2];
++    size_t pcblen = sizeof(*pcb);
++
++    AssertPtrReturn(pcb, VERR_INVALID_POINTER);
++
++    mib[0] = CTL_HW;
++    mib[1] = HW_PHYSMEM;	/* HW_REALMEM is also possible, but
++				   includes non-main memory as well */
++    *pcb = 0;
++    if (sysctl(mib, 2, pcb, &pcblen, NULL, 0) == 0) {
++	if (pcblen == sizeof(*pcb) || pcblen == sizeof(uint32_t))
++	    return VINF_SUCCESS;
++	else
++	    return VERR_NO_MEMORY;	/* XXX */
++    }
++    return RTErrConvertFromErrno(errno);
++}
++
++RTDECL(int) RTSystemQueryAvailableRam(uint64_t *pcb)
++{
++    int mib[2];
++    size_t pcblen = sizeof(*pcb);
++
++    AssertPtrReturn(pcb, VERR_INVALID_POINTER);
++
++    mib[0] = CTL_HW;
++    mib[1] = HW_USERMEM;
++    *pcb = 0;
++    if (sysctl(mib, 2, pcb, &pcblen, NULL, 0) == 0) {
++	if (pcblen == sizeof(*pcb) || pcblen == sizeof(uint32_t))
++	    return VINF_SUCCESS;
++	else
++	    return VERR_NO_MEMORY;	/* XXX */
++    }
++    return RTErrConvertFromErrno(errno);
++}
diff --git a/virtualbox-ose/patches/patch-src-VBox-Runtime-r3-posix-utf8-posix.cpp b/virtualbox-ose/patches/patch-src-VBox-Runtime-r3-posix-utf8-posix.cpp
new file mode 100644
index 0000000..40e39ab
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-VBox-Runtime-r3-posix-utf8-posix.cpp
@@ -0,0 +1,28 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/utf8-posix.cpp.orig	2015-03-16 17:04:36 UTC
++++ src/VBox/Runtime/r3/posix/utf8-posix.cpp
+@@ -194,7 +194,10 @@ static int rtstrConvertCached(const void
+             const void *pvInputLeft = pvInput;
+             void       *pvOutputLeft = pvOutput;
+             size_t      cchNonRev;
+-#if defined(RT_OS_LINUX) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS) || (defined(RT_OS_DARWIN) && defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)) /* there are different opinions about the constness of the input buffer. */
++#if defined(RT_OS_LINUX) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS) \
++ || defined(RT_OS_FREEBSD) || defined(RT_OS_DRAGONFLY) \
++ || (defined(RT_OS_DARWIN) && defined(_DARWIN_FEATURE_UNIX_CONFORMANCE))
++/* there are different opinions about the constness of the input buffer. */
+             cchNonRev = iconv(hIconv, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
+ #else
+             cchNonRev = iconv(hIconv, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
+@@ -324,7 +327,10 @@ static int rtStrConvertUncached(const vo
+             const void *pvInputLeft = pvInput;
+             void       *pvOutputLeft = pvOutput;
+             size_t      cchNonRev;
+-#if defined(RT_OS_LINUX) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS) || (defined(RT_OS_DARWIN) && defined(_DARWIN_FEATURE_UNIX_CONFORMANCE)) /* there are different opinions about the constness of the input buffer. */
++#if defined(RT_OS_LINUX) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS) \
++ || defined(RT_OS_FREEBSD) || defined(RT_OS_DRAGONFLY) \
++ || (defined(RT_OS_DARWIN) && defined(_DARWIN_FEATURE_UNIX_CONFORMANCE))
++/* there are different opinions about the constness of the input buffer. */
+             cchNonRev = iconv(icHandle, (char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
+ #else
+             cchNonRev = iconv(icHandle, (const char **)&pvInputLeft, &cbInLeft, (char **)&pvOutputLeft, &cbOutLeft);
diff --git a/virtualbox-ose/patches/patch-src-recompiler-Sun-testmath.c b/virtualbox-ose/patches/patch-src-recompiler-Sun-testmath.c
new file mode 100644
index 0000000..f9b7f33
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src-recompiler-Sun-testmath.c
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- src/recompiler/Sun/testmath.c.orig	2011-01-14 21:15:07.000000000 +0100
++++ src/recompiler/Sun/testmath.c	2011-08-05 13:54:49.000000000 +0200
+@@ -261,8 +261,6 @@
+ #endif
+     set_cw(0x27f);
+ 
+-    CHECK(logl(2.7182818284590452353602874713526625L), 1.0);
+-
+     CHECK(remainderl(1.0L, 1.0L), 0.0);
+     CHECK(remainderl(1.0L, 1.5L), -0.5);
+     CHECK(remainderl(42.0L, 34.25L), 7.75);
+@@ -315,10 +313,6 @@
+     CHECK(tanl(0.0L), 0.0);
+     CHECK(tanl(0.7853981633974483096156608458198757L), 1.0);
+ 
+-    CHECK(powl(0.0, 0.0), 1.0);
+-    CHECK(powl(2.0, 2.0), 4.0);
+-    CHECK(powl(3.0, 3.0), 27.0);
+-
+     return cErrors;
+ }
+ 
diff --git a/virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight b/virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight
new file mode 100644
index 0000000..891e7c4
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Installer/darwin/VirtualBox/postflight~	2015-07-10 23:31:33.000000000 +0900
++++ src/VBox/Installer/darwin/VirtualBox/postflight	2015-09-05 18:28:21.000000000 +0900
+@@ -85,7 +85,7 @@ if [[ -e "${LSREGISTER}" && "x" != "x${U
+ fi
+ 
+ # Check environment.
+-if [ "${INSTALLER_TEMP}x" == "x" ]; then
++if [ "${INSTALLER_TEMP}x" = "x" ]; then
+     echo "Required environment variable INSTALLER_TEMP is missing. Aborting installation."
+     exit 1;
+ fi
diff --git a/virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight b/virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight
new file mode 100644
index 0000000..184ce1e
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Installer/darwin/VirtualBox/preflight~	2015-07-10 23:31:33.000000000 +0900
++++ src/VBox/Installer/darwin/VirtualBox/preflight	2015-09-05 18:30:37.000000000 +0900
+@@ -15,7 +15,7 @@
+ set -e
+ 
+ # Check environment.
+-if [ "${INSTALLER_TEMP}x" == "x" ]; then
++if [ "${INSTALLER_TEMP}x" = "x" ]; then
+     echo "Required environment variable INSTALLER_TEMP is missing. Aborting installation."
+     exit 1;
+ fi
diff --git a/virtualbox-ose/patches/patch-src_VBox_Runtime_VBox_log-vbox_cpp b/virtualbox-ose/patches/patch-src_VBox_Runtime_VBox_log-vbox_cpp
new file mode 100644
index 0000000..f363f11
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src_VBox_Runtime_VBox_log-vbox_cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Runtime/VBox/log-vbox.cpp~	2015-07-10 23:31:43.000000000 +0900
++++ src/VBox/Runtime/VBox/log-vbox.cpp	2015-09-22 18:04:09.000000000 +0900
+@@ -380,7 +380,7 @@ RTDECL(PRTLOGGER) RTLogDefaultInit(void)
+             RTLogLoggerEx(pLogger, 0, ~0U, "Commandline: %.64s\n", info.args);
+         }
+ 
+-#  elif defined(RT_OS_FREEBSD)
++#  elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         /* Retrieve the required length first */
+         int aiName[4];
+         aiName[0] = CTL_KERN;
diff --git a/virtualbox-ose/patches/patch-src_VBox_VMM_testcase_mkdsk__sh b/virtualbox-ose/patches/patch-src_VBox_VMM_testcase_mkdsk__sh
new file mode 100644
index 0000000..87226bc
--- /dev/null
+++ b/virtualbox-ose/patches/patch-src_VBox_VMM_testcase_mkdsk__sh
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/VMM/testcase/mkdsk.sh~	2015-07-10 23:32:03.000000000 +0900
++++ src/VBox/VMM/testcase/mkdsk.sh	2015-09-05 18:25:59.000000000 +0900
+@@ -11,7 +11,7 @@
+ # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ #
+ 
+-if [ "x$3" == "x" ]; then
++if [ "x$3" = "x" ]; then
+ 
+     echo "syntax error"
+     echo "syntax: $0 imagename <size-in-KBs> <init prog> [tar files]"


Home | Main Index | Thread Index | Old Index